Last active
August 29, 2015 14:13
-
-
Save lats/c04e8faa2e461f02b824 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
//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 = "[email protected]"; | |
$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