Файл: _rootinc/rootpanelapih.inc.php
Строк: 102
<?
class ROOTPANELAPIH
{
public $url = null;
public $login = null;
public $pass = null;
public $error = null;
public function init($url,$login,$pass)
{
$this->url = $url;
$this->login = $login;
$this->pass = $pass;
}
public function send($params)
{
while (list($k,$v) = @each($params)) {
$req = $req."$k=".urlencode($v)."&";
}
$fp = curl_init();
curl_setopt($fp, CURLOPT_URL, $this->url);
curl_setopt($fp, CURLOPT_RETURNTRANSFER, true);
curl_setopt($fp, CURLOPT_POST, true);
curl_setopt($fp, CURLOPT_POSTFIELDS, $req);
curl_setopt($fp, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($fp, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($fp, CURLOPT_FAILONERROR, false);
curl_setopt($fp, CURLOPT_TIMEOUT, 120);
$result = curl_exec($fp);
if (curl_errno($fp)) {
$this->error = "cURL Error ".curl_errno($fp).": ".curl_error($fp);
curl_close($fp);
return false;
} else {
curl_close($fp);
$result = unserialize($result);
if (is_array($result) and count($result) > 1) {
return $result;
} else {
$this->error = "send: No output";
return false;
}
}
}
public function createOrder($vid, $tarifid, $period, $domain, $addonsArray)
{
$params["login"] = $this->login;
$params["pass"] = $this->pass;
$params["command"] = "createOrder";
$params["vid"] = $vid;
$params["tarifid"] = $tarifid;
$params["period"] = $period;
$params["domain"] = $domain;
$params["addons"] = @join(",",$addonsArray);
$result = $this->send($params);
if ($result) {
if ($result[status] == "SUCCESS") {
return $result;
} else {
$this->error = "createOrder: Code ".$result[errorCode].", ".$result[errorMsg];
return false;
}
}
else {
return false;
}
}
public function renewOrder($orderid, $period)
{
$params["login"] = $this->login;
$params["pass"] = $this->pass;
$params["command"] = "renewOrder";
$params["orderid"] = $orderid;
$params["period"] = $period;
$result = $this->send($params);
if ($result) {
if ($result[status] == "SUCCESS") {
return true;
} else {
$this->error = "renewOrder: Code ".$result[errorCode].", ".$result[errorMsg];
return false;
}
}
else {
return false;
}
}
public function suspendOrder($orderid)
{
$params["login"] = $this->login;
$params["pass"] = $this->pass;
$params["command"] = "suspendOrder";
$params["orderid"] = $orderid;
$result = $this->send($params);
if ($result) {
if ($result[status] == "SUCCESS") {
return true;
} else {
$this->error = "suspendOrder: Code ".$result[errorCode].", ".$result[errorMsg];
return false;
}
}
else {
return false;
}
}
public function unSuspendOrder($orderid)
{
$params["login"] = $this->login;
$params["pass"] = $this->pass;
$params["command"] = "unSuspendOrder";
$params["orderid"] = $orderid;
$result = $this->send($params);
if ($result) {
if ($result[status] == "SUCCESS") {
return true;
} else {
$this->error = "unSuspendOrder: Code ".$result[errorCode].", ".$result[errorMsg];
return false;
}
}
else {
return false;
}
}
public function restartOrder($orderid)
{
$params["login"] = $this->login;
$params["pass"] = $this->pass;
$params["command"] = "restartOrder";
$params["orderid"] = $orderid;
$result = $this->send($params);
if ($result) {
if ($result[status] == "SUCCESS") {
return true;
} else {
$this->error = "restartOrder: Code ".$result[errorCode].", ".$result[errorMsg];
return false;
}
}
else {
return false;
}
}
public function reinstallOrder($orderid)
{
$params["login"] = $this->login;
$params["pass"] = $this->pass;
$params["command"] = "reinstallOrder";
$params["orderid"] = $orderid;
$result = $this->send($params);
if ($result) {
if ($result[status] == "SUCCESS") {
return true;
} else {
$this->error = "reinstallOrder: Code ".$result[errorCode].", ".$result[errorMsg];
return false;
}
}
else {
return false;
}
}
}
?>