The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Auto sub domain creation

Discussion in 'General Discussion' started by ph3n0m, Oct 8, 2003.

  1. ph3n0m

    ph3n0m Registered

    Joined:
    Oct 7, 2003
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Dublin, Ireland
    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. pigstuy

    pigstuy Member

    Joined:
    Sep 4, 2003
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    //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. noimad1

    noimad1 Well-Known Member

    Joined:
    Mar 27, 2003
    Messages:
    627
    Likes Received:
    0
    Trophy Points:
    16

    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. noimad1

    noimad1 Well-Known Member

    Joined:
    Mar 27, 2003
    Messages:
    627
    Likes Received:
    0
    Trophy Points:
    16
    I had to modify the code to work. Put the solution in this thread:

    http://forums.cpanel.net/showthread.php?s=&postid=111253#post111253

    Damion
     
Loading...

Share This Page