Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 41 additions & 10 deletions solus.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
<?php

/**
* PHP Library for SolusVM's XMLRPC API
* PHP Library for SolusVM's XMLRPC API - Updated Fork
*
* https://documentation.solusvm.com/display/DOCS/API
*
* @author Benton Snyder
* @website http://www.bensnyde.me
* @created 12/22/2012
* @updated 4/2/2015
* @author Josh Wieder
* @website https://consulting.joshwieder.net
* @updated 1/4/2017
*
* Original Author: Benton Snyder
*
*/

class Solus {
Expand Down Expand Up @@ -44,7 +46,7 @@ private function execute(array $params) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->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);
Expand All @@ -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;
}

Expand Down Expand Up @@ -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
*
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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));
Expand All @@ -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));
Expand Down