Community Forums
Connect with us on LinkedIn
Community Notice
+ Reply to Thread
Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Oct 2003
    Location
    Dublin, Ireland
    Posts
    2

    Default 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:

  2. #2
    Member
    Join Date
    Sep 2003
    Posts
    6

    Default

    //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&homedir=$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&password=$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:

  3. #3
    Member
    Join Date
    Mar 2003
    Posts
    601

    Default

    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&homedir=$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&password=$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?

  4. #4
    Member
    Join Date
    Mar 2003
    Posts
    601

    Default

    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

Similar Threads & Tags
Similar threads

  1. Auto Account Creation
    By lblanchardiii in forum cPanel Developers
    Replies: 8
    Last Post: 10-23-2007, 04:03 PM
  2. Auto-Creation
    By arshem in forum cPanel and WHM Discussions
    Replies: 0
    Last Post: 07-16-2006, 03:57 PM
  3. auto account creation
    By ronsiso in forum New User Questions
    Replies: 1
    Last Post: 04-26-2005, 04:32 PM
  4. Auto Account Creation
    By WMSYS.net in forum cPanel and WHM Discussions
    Replies: 3
    Last Post: 12-16-2004, 01:15 PM
  5. Auto Webmail Creation
    By demine0 in forum cPanel and WHM Discussions
    Replies: 2
    Last Post: 05-17-2004, 12:37 PM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube