Файл: billing/_rootinc/internetx.inc.php
Строк: 327
<?
class INTERNETX
{
public $controller = true;
public $url = null;
public $user = null;
public $password = null;
public $context = null;
public $error = null;
public function startup(&$controller)
{
$this->controller =& $controller;
}
public function init($url,$user,$password,$context)
{
$this->url=$url;
$this->user=$user;
$this->password=$password;
$this->context=$context;
}
public function send($request)
{
$fp = curl_init();
curl_setopt($fp, CURLOPT_URL, $this->url);
curl_setopt($fp, CURL_HTTP_VERSION_1_1, 1);
curl_setopt($fp, CURLOPT_POST, 1);
curl_setopt($fp, CURLOPT_POSTFIELDS, $request);
curl_setopt($fp, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($fp, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($fp, CURLOPT_RETURNTRANSFER,1);
curl_setopt($fp, CURLOPT_TIMEOUT, 120);
$result = curl_exec($fp);
curl_close($fp);
return $result;
}
public function createContact($type,$fname,$lname,$organization,$address,$pcode,$city,$state,$country,$phone,$fax,$email,$protection,$manager_email)
{
$req = "<?xml version="1.0" encoding="UTF-8"?>
<request>
<auth>
<user>".$this->user."</user>
<password>".$this->password."</password>
<context>".$this->context."</context>
</auth>
<task>
<code>0301</code>
<reply_to>$manager_email</reply_to>
<handle>
<alias></alias>
<type>$type</type>
<fname>$fname</fname>
<lname>$lname</lname>
<title></title>
<organization>$organization</organization>
<address>$address</address>
<pcode>$pcode</pcode>
<city>$city</city>
<state>$state</state>
<country>$country</country>
<phone>$phone</phone>
<fax>$fax</fax>
<email>$email</email>
<sip></sip>
<protection>$protection</protection>
<remarks></remarks>
</handle>
</task>
</request>
";
$result = $this->send($req);
$xmlArray = xml2array($result);
if ($xmlArray[response][0][result][0][status][0][type] == "success" and $xmlArray[response][0][result][0][status][0][object][0][value]) {
return $xmlArray[response][0][result][0][status][0][object][0][value];
} else {
$this->error = "createContact: ".$this->getError($xmlArray);
return false;
}
}
public function regDomain($domain,$email,$contactId,$ns1,$ns2,$ns3,$ns4,$manager_email)
{
$ns = "<nserver>
<name>$ns1</name>
</nserver>
<nserver>
<name>$ns2</name>
</nserver>";
if ($ns3) {
$ns = $ns."n<nserver>
<name>$ns3</name>
</nserver>";
}
if ($ns4) {
$ns = $ns."n<nserver>
<name>$ns4</name>
</nserver>";
}
$req = "<?xml version="1.0" encoding="UTF-8"?>
<request>
<auth>
<user>".$this->user."</user>
<password>".$this->password."</password>
<context>".$this->context."</context>
</auth>
<task>
<code>0101</code>
<reply_to>$manager_email</reply_to>
<domain>
<name>$domain</name>
<ownerc>$contactId</ownerc>
<adminc>$contactId</adminc>
<techc>$contactId</techc>
<zonec>$contactId</zonec>
$ns
</domain>
</task>
</request>
";
$result = $this->send($req);
$xmlArray = xml2array($result);
if ($xmlArray[response][0][result][0][status][0][type] == "success" or $xmlArray[response][0][result][0][status][0][type] == "notify") {
return true;
} else {
$this->error = "regDomain: ".$this->getError($xmlArray);
return false;
}
}
public function renewDomain($domain_id,$years)
{
$req = "<?xml version="1.0" encoding="UTF-8"?>
<RequestBody>
<reseller>
<login>".$this->user."</login>
<password>".$this->password."</password>
</reseller>
<objRequest>
<method>create</method>
<type>domain</type>
<who_pay>reseller</who_pay>
<years>$years</years>
<domain_id>$domain_id</domain_id>
<operation>prolong</operation>
</objRequest>
</RequestBody>";
$result = $this->send($req);
$xmlArray = toarray($result,"AnswerBody",1);
if ($xmlArray["request_id"][0][value]) {
return true;
} else {
$this->error = "renewDomain: ".$xmlArray["statusCode"][0][value]." ".$xmlArray["statusMessage"][0][value];
return false;
}
}
public function domainCancelCreate($domain,$manager_email)
{
$req = "<?xml version="1.0" encoding="UTF-8"?>
<request>
<auth>
<user>".$this->user."</user>
<password>".$this->password."</password>
<context>".$this->context."</context>
</auth>
<task>
<code>0103101</code>
<cancelation>
<domain>$domain</domain>
<type>delete</type>
<execdate>expire</execdate>
<disconnect>1</disconnect>
</cancelation>
<reply_to>$manager_email</reply_to>
</task>
</request>
";
$result = $this->send($req);
$xmlArray = xml2array($result);
if ($xmlArray[response][0][result][0][status][0][type] == "success") {
return true;
} else {
$this->error = "domainCancelCreate: ".$this->getError($xmlArray);
return false;
}
}
public function domainCancelDelete($domain)
{
$req = "<?xml version="1.0" encoding="UTF-8"?>
<request>
<auth>
<user>".$this->user."</user>
<password>".$this->password."</password>
<context>".$this->context."</context>
</auth>
<task>
<code>0103103</code>
<cancelation>
<domain>$domain</domain>
</cancelation>
</task>
</request>
";
$result = $this->send($req);
$xmlArray = xml2array($result);
if ($xmlArray[response][0][result][0][status][0][type] == "success" or $xmlArray[response][0][result][0][msg][0][text] == "no cancel task found for this domain.") {
return true;
} else {
$this->error = "domainCancelDelete: ".$this->getError($xmlArray);
return false;
}
}
public function getNS($domain)
{
$req = "<?xml version="1.0" encoding="UTF-8"?>
<request>
<auth>
<user>".$this->user."</user>
<password>".$this->password."</password>
<context>".$this->context."</context>
</auth>
<task>
<code>0105</code>
<domain>
<name>$domain</name>
<show_handle_details>all</show_handle_details>
</domain>
</task>
</request>
";
$result = $this->send($req);
$xmlArray = xml2array($result);
if ($xmlArray[response][0][result][0][data][0][domain][0][status] == "success") {
$resultArray[] = $xmlArray[response][0][result][0][data][0][domain][0][nserver][0][name];
$resultArray[] = $xmlArray[response][0][result][0][data][0][domain][0][nserver][1][name];
$resultArray[] = $xmlArray[response][0][result][0][data][0][domain][0][nserver][2][name];
$resultArray[] = $xmlArray[response][0][result][0][data][0][domain][0][nserver][3][name];
return $resultArray;
} else {
$this->error = "getNS: ".$this->getError($xmlArray);
return false;
}
}
public function updateNS($domain,$ns1,$ns2,$ns3,$ns4,$manager_email)
{
$ns = "<nserver>
<name>$ns1</name>
</nserver>
<nserver>
<name>$ns2</name>
</nserver>";
if ($ns3) {
$ns = $ns."n<nserver>
<name>$ns3</name>
</nserver>";
}
if ($ns4) {
$ns = $ns."n<nserver>
<name>$ns4</name>
</nserver>";
}
$req = "<?xml version="1.0" encoding="UTF-8"?>
<request>
<auth>
<user>".$this->user."</user>
<password>".$this->password."</password>
<context>".$this->context."</context>
</auth>
<task>
<code>0102</code>
<domain>
<name>$domain</name>
$ns
</domain>
<reply_to>$manager_email</reply_to>
</task></request>
";
$result = $this->send($req);
$xmlArray = xml2array($result);
if ($xmlArray[response][0][result][0][status][0][type] == "success" or $xmlArray[response][0][result][0][status][0][type] == "notify") {
return true;
} else {
$this->error = "updateNS: ".$this->getError($xmlArray);
return false;
}
}
public function getError($x)
{
$error = array();
$error[] = $x[response][0][result][0][status][0][code].": ".$x[response][0][result][0][status][0][text];
$error[] = $x[response][0][result][0][msg][0][code].": ".$x[response][0][result][0][msg][0][text]." (".$x[response][0][result][0][msg][0][object][0][type]." ".$x[response][0][result][0][msg][0][object][0][value].")";
return @join(", ",$error);
}
}
?>