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.

Cpanel Php Module... Help

Discussion in 'General Discussion' started by Surferdude, Nov 23, 2004.

  1. Surferdude

    Surferdude Registered

    Joined:
    Nov 6, 2004
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    Hey Everyone,

    Hoping someone can help me here, specifically a webhost or someone who has a Cpanel Licence.

    I currently own a webhost company, and am trying to create automated signups for free accounts. After doing some research, I found this can all be done with php through the module that Cpanel has created. After getting the module enabled, I made a quick script to see if it works. The script consists of two files:

    order.php:

    CODE
    <?php

    // Cpanel WHM Account Creation Script {Form}
    // START SCRIPT!

    print ' <b>Free Hosting Sign-up</b> <br /><br /><br />
    <form action="create.php" mehtod="POST" >
    <TABLE BORDER>
    <TR><TH>Domain</TH>
    <TD><input type="text" name="domain">.future-hosting.info</TD></TR>
    <TR><TH>Username</TH>
    <TD><input type="text" name="username"></TD></TR>
    <TR><TH>Password</TH>
    <TD><input type="text" name="password"></TD></TR>
    <TR><TH>Plan</TH>
    <TD>Free</TD></TR>
    <TR><TH>Submit/Reset</TH>
    <TD><input type="submit" value="Set Up Hosting!"><input type="reset" value="Reset Fields"></TD></TR>


    </TABLE>
    </form>
    ';



    // END SCRIPT
    ?>


    And create.php to proccess the information

    CODE
    <?php

    // Cpanel WHM Account Creation Script {Account Creation}


    // VARS
    require '/usr/local/cpanel/Cpanel/Accounting.php.inc'; // DO NOT EDIT!
    $host = "localhost";
    $user = "future";
    $accesshash = ''<Access Key Here>";
    $form_domain = "$_POST[domain]";
    $form_username = "$_POST[username]";
    $form_password = "$_POST[password]";
    $plan = "future_Future-Free";


    // CREATE ACCOUNT

    $create = createacct ($host,$user,$accesshash,0,$form_domain .future-hosting.info,$form_username,$form_password,$plan);

    // SHOW SUCCESS/FAIL MESSAGE

    if (!$create)
    {
    print("Sorry, account creation failed. Please try again.");
    }
    else
    {
    print("Account Created! you can access your website at $form_domain . future-hosting.info. Log into C-Panel at www.future-hosting.info/cpanel. Thank you for choosing Future Hosting and have a nice day! ");
    }
    ?>



    The problem is when I test the script, it prints the success message even when I am missing fields which are needed to create the account and the account isnt created when I log into WHM...

    Any Ideas?
     
  2. linuxdoctor

    linuxdoctor Registered

    Joined:
    Oct 6, 2004
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    I tried your script out and needed to make several corrections.

    1. In your "create.php" file, you mispelled 'method'.

    That was about all I needed to do to get it to work. To make it neat and tidy, I added a couple of lines to read the WHM access key in from a file:

    $filename = "key.txt";
    $handle = fopen($filename, 'r');
    $accesshash = fread($handle, filesize($filename));
    fclose($handle);

    Thanks for the script. I was looking for something like that.
     
Loading...

Share This Page