Surferdude

Registered
Nov 6, 2004
3
0
151
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?
 

linuxdoctor

Registered
Oct 6, 2004
1
0
151
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.