Skip to content

Instantly share code, notes, and snippets.

@lats
Last active August 29, 2015 14:13
Show Gist options
  • Save lats/c04e8faa2e461f02b824 to your computer and use it in GitHub Desktop.
Save lats/c04e8faa2e461f02b824 to your computer and use it in GitHub Desktop.
<?
//Required info
$whmusername = "root";
//Contains the hash from /etc/.accesshash
include_once('hash.php');
//A bunch of vars, the ones listed here are required for any cp scrip. Replace or add to this as needed, can be changed to inputs as well.
$user = "somename";
$pass = "somepass";
$domain = "someurl.tld";
$email = "some@url.tld";
$function = "somefunction"
//The main portion of the script, this will contain the xml/json call you wish to make.
$query = "https://localhost:2087/xml-api/" . $function . " ?api.version=1&username=" . $user . "&domain=" . $domain . "&password=" . $pass . "&contactemail=" . $email . "&reseller=1";
//$query = "https://localhost:2087/json-api/" . $function . " ?api.version=1&username=" . $user . "&domain=" . $domain . "&password=" . $pass . "&contactemail=" . $email . "&reseller=1";
//Execution start
$curl = curl_init();
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST,0);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER,0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER,1);
$header[0] = "Authorization: WHM $whmusername:" . preg_replace("'(\r|\n)'","",$hash);
curl_setopt($curl,CURLOPT_HTTPHEADER,$header);
curl_setopt($curl, CURLOPT_URL, $query);
$result = curl_exec($curl);
if ($result == false) {
error_log("curl_exec threw error \"" . curl_error($curl) . "\" for $query");
}
curl_close($curl);
//Execution finish
//Display the output of the command (for confirmation/debugging purposes).
print $result;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment