#1 (permalink)  
Old 10-08-2003, 06:47 AM
Registered User
 
Join Date: Oct 2003
Location: Dublin, Ireland
Posts: 2
ph3n0m
Auto sub domain creation

Just wondering has anyone succesfully implemented such a feature in Control Panel

The feature would be web based using a simple form, connecting to either a php or perl script that would allow registered users to automatically create their own sub domain, after first checking that the sub domain was available

cPanel.net Support Ticket Number:
__________________
"Eh...you never know what you're capable of. I never thought I could shoot down a German plane, but last year I proved myself wrong" - Abe Simpson
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 10-10-2003, 11:28 PM
Registered User
 
Join Date: Sep 2003
Posts: 6
pigstuy
//Make sure to store the $cpaneluser and $cpanelpass in a secure directory, or outside of the public_html folder.

$socket = fsockopen("www.domain.com",2082);
$authstr = "$cpaneluser:$cpanelpass";
$pass = base64_encode($authstr);

//First, we add an FTP account with the username and home directory named to $ustring.

$in = "GET /frontend/x2/ftp/doaddftp.html?login=$ustring&password=$password&ho medir=$ustring\r\n HTTP/1.0\r\nAuthorization: Basic $pass \r\n";

fputs($socket,$in);
fclose($socket);

//Next, we add a subdomain with $ustring which will give the user FTP access to /$ustring and the subdomain $ustring.domain.com will reference all files in the user's FTP account.

$socket2 = fsockopen("www.domain.com",2082);

$indom = "GET /frontend/x2/subdomain/doadddomain.html?domain=$ustring&rootdomain=domain .com\r\n HTTP/1.0\r\nAuthorization: Basic $pass \r\n";

fputs($socket2,$indom);
fclose($socket2);

//Finally, we create a mail account for the user.

$socket3 = fsockopen("www.domain.com",2082);

$inpop = "GET /frontend/x2/mail/doaddpop.html?domain=domain.com&email=$ustring&pas sword=$password&quota=5\r\n HTTP/1.0\r\nAuthorization: Basic $pass \r\n";

fputs($socket3,$inpop);
fclose($socket3);



---
I use many modifications of this script to run chunks of my site. The trick is to go to cPanel and view the html source code for whatever you are trying to do (edit mail account, add, FTP, etc.) and then use the values (input type=text NAME="IMPORTANTVARIABLE" and action="dourl.htm") that are inside of the html form. Just replace the variable you find in the form within the GET statement. Study the script above to learn more.

If you are going to check to see if the subdomain already exists, write a PHP script to first check if a user exists in a database, and if not add them to the database and create the account.

Good luck!

cPanel.net Support Ticket Number:
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 05-03-2004, 02:30 PM
Registered User
 
Join Date: Mar 2003
Posts: 574
noimad1
Quote:
Originally posted by pigstuy
//Make sure to store the $cpaneluser and $cpanelpass in a secure directory, or outside of the public_html folder.

$socket = fsockopen("www.domain.com",2082);
$authstr = "$cpaneluser:$cpanelpass";
$pass = base64_encode($authstr);

//First, we add an FTP account with the username and home directory named to $ustring.

$in = "GET /frontend/x2/ftp/doaddftp.html?login=$ustring&password=$password&ho medir=$ustring\r\n HTTP/1.0\r\nAuthorization: Basic $pass \r\n";

fputs($socket,$in);
fclose($socket);

//Next, we add a subdomain with $ustring which will give the user FTP access to /$ustring and the subdomain $ustring.domain.com will reference all files in the user's FTP account.

$socket2 = fsockopen("www.domain.com",2082);

$indom = "GET /frontend/x2/subdomain/doadddomain.html?domain=$ustring&rootdomain=domain .com\r\n HTTP/1.0\r\nAuthorization: Basic $pass \r\n";

fputs($socket2,$indom);
fclose($socket2);

//Finally, we create a mail account for the user.

$socket3 = fsockopen("www.domain.com",2082);

$inpop = "GET /frontend/x2/mail/doaddpop.html?domain=domain.com&email=$ustring&pas sword=$password&quota=5\r\n HTTP/1.0\r\nAuthorization: Basic $pass \r\n";

fputs($socket3,$inpop);
fclose($socket3);

---

Good luck!

cPanel.net Support Ticket Number:

I've been trying to use your above code (just the subdomain section), but it doesn't seem to work. I just get blank page, no subdomain is created?

Do you know if this still works with current versions of cpanel? Have you had to change anything?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 05-03-2004, 08:10 PM
Registered User
 
Join Date: Mar 2003
Posts: 574
noimad1
Quote:
Originally posted by noimad1
I've been trying to use your above code (just the subdomain section), but it doesn't seem to work. I just get blank page, no subdomain is created?

Do you know if this still works with current versions of cpanel? Have you had to change anything?
I had to modify the code to work. Put the solution in this thread:

http://forums.cpanel.net/showthread....253#post111253

Damion
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 08:49 AM.


Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© cPanel Inc