diff --git a/solus.php b/solus.php index 557cfb8..0f017d2 100644 --- a/solus.php +++ b/solus.php @@ -1,14 +1,16 @@ url . "/command.php"); curl_setopt($ch, CURLOPT_POST, 1); - curl_setopt($ch, CURLOPT_TIMEOUT, 20); + curl_setopt($ch, CURLOPT_TIMEOUT, 360); curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); @@ -53,11 +55,11 @@ private function execute(array $params) { curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $params); $response = curl_exec($ch); - curl_close($ch); if($response === false) throw new Exception("Curl error: " . curl_error($ch)); + curl_close($ch); return $response; } @@ -336,6 +338,35 @@ public function listClients() { return $this->execute(array("action"=>"client-list")); } + /** + * Retrieves reseller list + * + * https://documentation.solusvm.com/display/DOCS/List+Resellers + * + * @access public + * @param + * @return str + */ + public function listResellers() { + return $this->execute(array("action"=>"reseller-list")); + } + + /** + * Retrieves details of reseller specified by username + * + * https://documentation.solusvm.com/display/DOCS/Reseller+Information + * + * @access public + * @param str + * @return str + */ + public function getResellerInfo($username) { + if(!ctype_alnum($username)) + throw new Exception("Invalid Username"); + + return $this->execute(array("action"=>"reseller-info", "username"=>$username)); + } + /** * Retrieves a list of virtual servers on specified node * @@ -390,7 +421,7 @@ public function addIP($serverID, $ipv4addr=0, $forceaddip=0) { if(filter_var($ipv4addr, FILTER_VALIDATE_IP) === false) throw new Exception("Invalid IPv4 Address"); - if(filter_var($forceaddip, FILTER_VALIDATE_BOOLEAN) === false) +if((filter_var($forceaddip, FILTER_VALIDATE_BOOLEAN) !== false) && (filter_var($deleteclient, FILTER_VALIDATE_BOOLEAN) !== true)) throw new Exception("forceaddip must be boolean"); $args['ipv4addr'] = $ipv4addr; @@ -451,7 +482,7 @@ public function changePlan($serverID, $plan, $changeHDD=false) { if(!is_numeric($serverID)) throw new Exception("Invalid ServerID"); - if(filter_var($changeHDD, FILTER_VALIDATE_BOOLEAN) === false) +if((filter_var($changeHDD, FILTER_VALIDATE_BOOLEAN) !== false) && (filter_var($deleteclient, FILTER_VALIDATE_BOOLEAN) !== true)) throw new Exception("changeHDD must be boolean"); return $this->execute(array("action"=>"vserver-change", "vserverid"=>$serverID, "plan"=>$plan, "changehdd"=>$changeHDD)); @@ -470,7 +501,7 @@ public function terminate($serverID, $deleteclient=false) { if(!is_numeric($serverID)) throw new Exception("Invalid ServerID"); - if(filter_var($deleteclient, FILTER_VALIDATE_BOOLEAN) === false) +if((filter_var($deleteclient, FILTER_VALIDATE_BOOLEAN) !== false) && (filter_var($deleteclient, FILTER_VALIDATE_BOOLEAN) !== true)) throw new Exception("deleteclient must be boolean"); return $this->execute(array("action"=>"vserver-terminate", "vserverid"=>$serverID, "deleteclient"=>$deleteclient));