WHM/Cpanel添加用户后自动绑定一个三级域名的php代码


#!/usr/bin/php -q
<\?php $dotdomain = ".host.dnsfresh.com"; function argv2array ($argv) { $opts = array(); $argv0 = array_shift($argv); while(count($argv)) { $key = array_shift($argv); $value = array_shift($argv); $opts[$key] = $value; } return $opts; } $opts = argv2array($argv); $username = $opts['user']; if (empty($username)) { exit; } $whmusername = "root"; $whmpassword = "00434433"; $query = "http://127.0.0.1:2086/xml-api/cpanel?user={$username}&cpanel_xmlapi_module=Park&cpanel_xmlapi_func=park&domain={$username}{$dotdomain}"; $curl = curl_init(); # Create Curl Object curl_setopt($curl, CURLOPT_SSL_VERIFYPEER,0); # Allow self-signed certs curl_setopt($curl, CURLOPT_SSL_VERIFYHOST,0); # Allow certs that do not match the hostname curl_setopt($curl, CURLOPT_HEADER,0); # Do not include header in output curl_setopt($curl, CURLOPT_RETURNTRANSFER,1); # Return contents of transfer on curl_exec $header[0] = "Authorization: Basic " . base64_encode($whmusername.":".$whmpassword) . "\n\r"; curl_setopt($curl, CURLOPT_HTTPHEADER, $header); # set the username and password curl_setopt($curl, CURLOPT_URL, $query); # execute the query $result = curl_exec($curl); if ($result == false) { error_log("curl_exec threw error \"" . curl_error($curl) . "\" for $query"); # log error if curl exec fails } curl_close($curl); print $result; /* include("/usr/local/cpanel/php/cpanel.php"); $cpanel = &new CPANEL(); print_r($cpanel->api2('Park','park',array("domain"=>'sub1.vr002.qiaogen.org',"topdomain"=>'cjboy.org')));
$cpanel->end();
*/
?>


发表评论 0

Your email address will not be published. Required fields are marked *