- Impact
- 17
A few days ago, when I got bored, I wrote this small bunch of code for automated WHM account creation.
It does works, but note that this is just a rough bunch of code; you'll have to change a lot of settings in order to get the script suit your needs.
There is also no checkup written into it to check if the account really is created
**NOTE 1: PHP Safe Mode must be turned off, in order to get this script working, else a few cURL options will issue an error.
**NOTE 2:cURL must be installed at your PHP server.
**NOTE 3:Create an empty cookie.txt file, upload it to your server, and make sure it is 777-CHMOD'ed
If you like the script, rep is appreciated :hehe:
whm-create.php
If you need any support with it, just reply to this topic, i'm watching it
Cheers,
It does works, but note that this is just a rough bunch of code; you'll have to change a lot of settings in order to get the script suit your needs.
There is also no checkup written into it to check if the account really is created
**NOTE 1: PHP Safe Mode must be turned off, in order to get this script working, else a few cURL options will issue an error.
**NOTE 2:cURL must be installed at your PHP server.
**NOTE 3:Create an empty cookie.txt file, upload it to your server, and make sure it is 777-CHMOD'ed
If you like the script, rep is appreciated :hehe:
whm-create.php
PHP:
<?php
/* HOW TO INSTALL
1 - Save this code as a PHP file (or any file, as long as the server recognizes it as PHP)
2 - Change the configuration part in this file, save it, and upload to your server
3 - Create an empty .txt file in notepad, call it cookie.txt, upload it to your server.
4 - Is your server a unix-like server? CHMOD that file to 777.
This is not need for windows servers.
*/
// Configure
define("WHM_USER", "your-username"); // WHM username
define("WHM_PASS", "your-password"); // WHM password
define("WHM_DOMAIN", "127.0.0.1"); // IP or hostname could be enterred here
// The new account settings!
// Go to line 75 in this file, and change everything to suit your needs.
// cURL class: Thanks to Sean Huber
class CURL {
var $callback = false;
function setCallback($func_name) {
$this->callback = $func_name;
}
function doRequest($method, $url, $vars) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt');
if ($method == 'POST') {
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $vars);
}
$data = curl_exec($ch);
curl_close($ch);
if ($data) {
if ($this->callback)
{
$callback = $this->callback;
$this->callback = false;
return call_user_func($callback, $data);
} else {
return $data;
}
} else {
return curl_error($ch);
}
}
function get($url) {
return $this->doRequest('GET', $url, 'NULL');
}
function post($url, $vars) {
return $this->doRequest('POST', $url, $vars);
}
}
// Initialize cURL library
$curl = new CURL;
$text = $curl->get("http://" . WHM_USER . ":" . WHM_PASS . "@" . WHM_DOMAIN .":2086/");
// Create account now
// First going to this form; required, else wont work
$text = $curl->get("http://" . WHM_USER . ":" . WHM_PASS . "@" . WHM_DOMAIN .":2086/scripts2/wwwacctform");
// Fine! Set the options now.
$options = "sign=&plan=hansvdp_tp&domain=tgz33.com&username=tg33&password=test"a=6&ip=0&cgi=1&frontpage=1&maxftp=unlimited&maxpop=unlimited&maxlst=unlimited&maxsql=unlimited&maxsub=unlimited&maxpark=5&maxaddon=3&bwlimit=50&cpmod=x&msel=n,y,unlimited,y,unlimited,unlimited,unlimited,unlimited,unlimited,unlimited,unlimited,y,0,0&[email protected]";
// And post it!
$text = $curl->post("http://" . WHM_USER . ":" . WHM_PASS . "@" . WHM_DOMAIN .":2086/scripts/wwwacct", $options);
// Eventually you can output the text here
echo $text;
?>
If you need any support with it, just reply to this topic, i'm watching it
Cheers,
Last edited:






