Файл: _rootinc/billmgr.inc.php
Строк: 241
<?
require_once($full_home_path."/_rootinc/todaynic/xmlbase.inc.php");
class BILLMGR
{
public $user = null;
public $password = null;
public $error = null;
public $url = null;
public $prices = null;
public $periods = null;
public function init($provider,$user,$password) {
$this->user=$user;
$this->password=$password;
if (!$provider or $provider == "ispsystemru") {
$this->url = "https://my.ispsystem.com/manager/";
$this->prices = array(
"ispmanagerlite" => "7",
"ispmanagerlitefull" => "7",
"ispmanagerlitetrial" => "7",
"ispmanagerpro" => "11",
"ispmanagerprofull" => "11",
"ispmanagerprotrial" => "11",
"vdsmanagerlinux" => "15",
"vdsmanagerlinuxfull" => "15",
"vdsmanagerfreebsd" => "884",
"vdsmanagerfreebsdfull" => "884",
"billmanagerstandart" => "432",
"billmanageradvanced" => "434",
"billmanagercorporate" => "435",
"dsmanager" => "16",
"dsmanagerfull" => "16",
"dnsmanagerfull" => "17",
"ipmanagerfull" => "18"
);
$this->periods = array(
"ispmanagerlite" => array("month" => "8"),
"ispmanagerlitefull" => array("one" => "9"),
"ispmanagerlitetrial" => array("one" => "7"),
"ispmanagerpro" => array("month" => "16"),
"ispmanagerprofull" => array("one" => "17"),
"ispmanagerprotrial" => array("one" => "15"),
"vdsmanagerlinux" => array("month" => "25"),
"vdsmanagerlinuxfull" => array("one" => "26"),
"vdsmanagerfreebsd" => array("month" => "535"),
"vdsmanagerfreebsdfull" => array("one" => "536"),
"billmanagerstandart" => array("month" => "380", "year" => "381"),
"billmanageradvanced" => array("month" => "382", "year" => "383"),
"billmanagercorporate" => array("month" => "384", "year" => "385"),
"dsmanager" => array("month" => "28", "year" => "29"),
"dsmanagerfull" => array("one" => "661"),
"dnsmanagerfull" => array("one" => "31"),
"ipmanagerfull" => array("one" => "33")
);
}
else if ($provider == "isplicenseru") {
$this->url = "https://my.isplicense.ru/manager/";
$this->prices = array(
"ispmanagerlite" => "8",
"ispmanagerlitefull" => "8",
"ispmanagerlitetrial" => "8",
"ispmanagerpro" => "10",
"ispmanagerprofull" => "10",
"ispmanagerprotrial" => "10",
"vdsmanagerlinux" => "11",
"vdsmanagerlinuxfull" => "11",
"vdsmanagerfreebsd" => "12",
"vdsmanagerfreebsdfull" => "12",
"billmanagerstandart" => "14",
"billmanageradvanced" => "13",
"billmanagercorporate" => "15",
"dsmanager" => "18",
"dsmanagerfull" => "18",
"dnsmanagerfull" => "16",
"ipmanagerfull" => "17"
);
$this->periods = array(
"ispmanagerlite" => array("month" => "11"),
"ispmanagerlitefull" => array("one" => "12"),
"ispmanagerlitetrial" => array("one" => "10"),
"ispmanagerpro" => array("month" => "14"),
"ispmanagerprofull" => array("one" => "15"),
"ispmanagerprotrial" => array("one" => "13"),
"vdsmanagerlinux" => array("month" => "23"),
"vdsmanagerlinuxfull" => array("one" => "24"),
"vdsmanagerfreebsd" => array("month" => "26"),
"vdsmanagerfreebsdfull" => array("one" => "27"),
"billmanagerstandart" => array("month" => "47", "year" => "48"),
"billmanageradvanced" => array("month" => "45", "year" => "46"),
"billmanagercorporate" => array("month" => "49", "year" => "50"),
"dsmanager" => array("month" => "53", "year" => "54"),
"dsmanagerfull" => array("one" => "55"),
"dnsmanagerfull" => array("one" => "51"),
"ipmanagerfull" => array("one" => "52")
);
}
}
public function connect($query) {
$this->fp = curl_init();
curl_setopt($this->fp, CURLOPT_URL, $this->url.$query);
curl_setopt($this->fp, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($this->fp, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($this->fp, CURLOPT_FAILONERROR, 0);
curl_setopt($this->fp, CURLOPT_RETURNTRANSFER,1);
curl_setopt($this->fp, CURLOPT_TIMEOUT, 120);
$result = curl_exec($this->fp);
curl_close($this->fp);
return $result;
}
public function createLicense($licenseType, $costType, $licenseName, $licenseIP) {
$price = $this->prices[$licenseType];
$period = $this->periods[$licenseType][$costType];
if (!$price) {
$this->error = "createLicense: Price for $licenseType, costtype $costType not found.";
return false;
}
if (!$period) {
$this->error = "createLicense: Period for $licenseType, costtype $costType not found.";
return false;
}
$xmlstr = $this->connect("billmgr?authinfo=".$this->user.":".$this->password."&out=xml&func=software.edit&price=$price&period=$period&licname=".urlencode($licenseName)."&ip=$licenseIP&sok=ok");
if ($xmlstr=='') {
$this->error='createLicense: No output.';
return false;
} else {
$xmlArray = toarray($xmlstr,"doc",1);
if (isset($xmlArray[ok][0])) {
return $xmlArray[id][0][value];
} else if (isset($xmlArray[error][0])) {
$this->error = "createLicense: ".$this->getError($xmlArray[error][0]);
return false;
} else {
$this->error = "createLicense: unknown error";
return false;
}
}
}
public function renewLicense($licenseType, $costType, $licenseID) {
$period = $this->periods[$licenseType][$costType];
if (!$period) {
$this->error = "renewLicense: Period for $licenseType, costtype $costType not found.";
return false;
}
$xmlstr = $this->connect("billmgr?authinfo=".$this->user.":".$this->password."&out=xml&func=software.period&elid=$licenseID&period=$period&sok=ok");
if ($xmlstr=='') {
$this->error='renewLicense: No output.';
return false;
} else {
$xmlArray = toarray($xmlstr,"doc",1);
if (isset($xmlArray[ok][0])) {
return true;
} else if (isset($xmlArray[error][0])) {
$this->error = "renewLicense: ".$this->getError($xmlArray[error][0]);
return false;
} else {
$this->error = "renewLicense: unknown error";
return false;
}
}
}
public function updateLicense($licenseID, $field, $value) {
if ($field == "name") {
$queryAddon = "licname=".urlencode($value);
} else if ($field == "ip") {
$queryAddon = "ip=$value";
}
$xmlstr = $this->connect("billmgr?authinfo=".$this->user.":".$this->password."&out=xml&func=software.edit&elid=$licenseID&sok=ok&".$queryAddon);
if ($xmlstr=='') {
$this->error='updateLicense: No output.';
return false;
} else {
$xmlArray = toarray($xmlstr,"doc",1);
if (isset($xmlArray[ok][0])) {
return true;
} else if (isset($xmlArray[error][0])) {
$this->error = "updateLicense: ".$this->getError($xmlArray[error][0]);
return false;
} else {
$this->error = "updateLicense: unknown error";
return false;
}
}
}
public function getError($errorArray) {
$error = "Code: ".$errorArray[attributes][code].". ";
if ($errorArray[attributes][obj]) { $error = $error."Object: ".$errorArray[attributes][obj].". "; }
if ($errorArray[attributes][val]) { $error = $error."Val: ".$errorArray[attributes][val].". "; }
if ($errorArray[attributes][msg]) { $error = $error."Msg: ".$errorArray[attributes][msg].". "; }
if ($errorArray[value]) { $error = $error."Error: ".$errorArray[value]."."; }
return $error;
}
}
?>