Файл: _rootinc/dotfm.inc.php
Строк: 1425
<?
class DOTFM
{
public $url = null;
public $port = null;
public $user = null;
public $password = null;
public $error = null;
private $fp = null;
private $isConnected = false;
private $answerArray = null;
public function init($url,$port,$user,$password)
{
$this->user = $user;
$this->url = $url;
$this->port = $port;
$this->password = $password;
}
public function connect()
{
$socket = @fsockopen("tls://".$this->url, $this->port, $errno, $errstr, 10);
if (!$socket) {
$this->error = "connect: Error connecting to $this->url: $errstr (code $errno)";
return false;
} else {
$this->fp=$socket;
}
$result = $this->get();
if ($result[epp][0][greeting][0][svID]) {
if ($this->login()) {
$this->isConnected = true;
return true;
}
else {
return false;
}
} else if (!$this->error) {
$this->error = "connect: Unable to get Hello message.";
return false;
} else {
$this->error = "connect: ".$this->error;
return false;
}
}
public function disconnect()
{
if ($this->isConnected) {
$xml = "<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchemainstance" xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd">
<command>
<logout/>
<clTRID>".time()."</clTRID>
</command>
</epp>
";
$this->send($xml);
$this->isConnected = false;
}
@fclose($this->fp);
}
public function get($print = 0)
{
if (@feof($this->fp)) {
$this->error = "get: Connection appears to have closed.";
return false;
}
$hdr = @fread($this->fp, 4);
if (empty($hdr)) {
$this->error = "get: Error reading from server: $php_errormsg";
return false;
} else {
$unpacked = unpack('N', $hdr);
$answer = @fread($this->fp, ($unpacked[1] - 4));
if ($print) { print "nn".$answer."nn"; }
$this->answerArray = xmlToArrayL($answer);
return xml2array($answer);
}
}
public function send($xml)
{
return @fwrite($this->fp, pack('N', (strlen($xml)+4)).$xml);
}
public function login()
{
$xml = "<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchemainstance" xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd">
<command>
<login>
<clID>".$this->user."</clID>
<pw>".$this->password."</pw>
<options>
<version>1.0</version>
<lang>en</lang>
</options>
<svcs>
<objURI>urn:ietf:params:xml:ns:domain-1.0</objURI>
<objURI>urn:ietf:params:xml:ns:contact-1.0</objURI>
</svcs>
</login>
<clTRID>".time()."</clTRID>
</command>
</epp>
";
if(!$this->send($xml)) {
$this->error='login: Unable to send query.';
return false;
} else {
$result = $this->get();
if (is_array($result)) {
if ($result[epp][0][response][0][result][0][msg] == "Command completed successfully") {
return true;
} else {
$this->error = "login: ".$result[epp][0][response][0][result][0][msg];
return false;
}
} else if (!$this->error) {
$this->error = "login: Unable to get result.";
return false;
} else {
$this->error = "login: ".$this->error;
return false;
}
}
}
public function createContact($name,$org,$street,$city,$oblast,$post,$country,$phone,$email,$pw)
{
if ($this->isConnected or $this->connect()) {
$cunic = generatePassword(7)."-cunic";
$xml = "<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd">
<command>
<create>
<contact:create xmlns:contact="urn:ietf:params:xml:ns:contact-1.0" xsi:schemaLocation="urn:ietf:params:xml:ns:contact-1.0 contact-1.0.xsd">
<contact:id>$cunic</contact:id>
<contact:postalInfo type="loc">
<contact:name>$name</contact:name>
<contact:org>$org</contact:org>
<contact:addr>
<contact:street>$street</contact:street>
<contact:city>$city</contact:city>
<contact:sp>$oblast</contact:sp>
<contact:pc>$post</contact:pc>
<contact:cc>$country</contact:cc>
</contact:addr>
</contact:postalInfo>
<contact:voice>$phone</contact:voice>
<contact:email>$email</contact:email>
<contact:authInfo>
<contact:pw>$pw</contact:pw>
</contact:authInfo>
<contact:disclose flag="0">
<contact:voice />
<contact:email />
</contact:disclose>
</contact:create>
</create>
<clTRID>".time()."</clTRID>
</command>
</epp>
";
if(!$this->send($xml)) {
$this->error='createContact: Unable to send query.';
$this->disconnect();
return false;
} else {
$result = $this->get();
if (is_array($result)) {
if ($result[epp][0][response][0][result][0][msg] == "Command completed successfully" and $result[epp][0][response][0][resData][0]["contact:creData"][0]["contact:id"]) {
return $result[epp][0][response][0][resData][0]["contact:creData"][0]["contact:id"];
} else {
$this->error = "createContact: ".$result[epp][0][response][0][result][0][msg];
$this->disconnect();
return false;
}
} else if (!$this->error) {
$this->error = "createContact: Unable to get result.";
$this->disconnect();
return false;
} else {
$this->error = "createContact: ".$this->error;
$this->disconnect();
return false;
}
}
} else {
return false;
}
}
public function registerDomain($domain,$period,$ns1,$ns2,$ns3,$ns4,$contactId,$pw)
{
if ($this->isConnected or $this->connect()) {
$nscode = "";
if ($ns1) {
$result = $this->checkNS($ns1);
if (!$result) { return false; }
if ($result['avail']) { if (!$this->createNS($ns1)) { return false; } }
$nscode .= "<domain:hostObj>$ns1</domain:hostObj>n";
}
if ($ns2) {
$result = $this->checkNS($ns2);
if (!$result) { return false; }
if ($result['avail']) { if (!$this->createNS($ns2)) { return false; } }
$nscode .= "<domain:hostObj>$ns2</domain:hostObj>n";
}
if ($ns3) {
$result = $this->checkNS($ns3);
if (!$result) { return false; }
if ($result['avail']) { if (!$this->createNS($ns3)) { return false; } }
$nscode .= "<domain:hostObj>$ns3</domain:hostObj>n";
}
if ($ns4) {
$result = $this->checkNS($ns4);
if (!$result) { return false; }
if ($result['avail']) { if (!$this->createNS($ns4)) { return false; } }
$nscode .= "<domain:hostObj>$ns4</domain:hostObj>n";
}
$xml = "<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd">
<command>
<create>
<domain:create xmlns:domain="urn:ietf:params:xml:ns:domain-1.0" xsi:schemaLocation="urn:ietf:params:xml:ns:domain-1.0 domain-1.0.xsd">
<domain:name>$domain</domain:name>
<domain:period unit="y">".$period."</domain:period>
<domain:ns>
$nscode
</domain:ns>
<domain:registrant>$contactId</domain:registrant>
<domain:contact type="admin">$contactId</domain:contact>
<domain:contact type="tech">$contactId</domain:contact>
<domain:contact type="billing">$contactId</domain:contact>
<domain:authInfo>
<domain:pw>$pw</domain:pw>
</domain:authInfo>
</domain:create>
</create>
<clTRID>".time()."</clTRID>
</command>
</epp>
";
if(!$this->send($xml)) {
$this->error='registerDomain: Unable to send query.';
$this->disconnect();
return false;
} else {
$result = $this->get();
if (is_array($result)) {
if ($result[epp][0][response][0][result][0][msg] == "Command completed successfully") {
return true;
} else {
$this->error = "registerDomain: ".$result[epp][0][response][0][result][0][msg];
$this->disconnect();
return false;
}
} else if (!$this->error) {
$this->error = "registerDomain: Unable to get result.";
$this->disconnect();
return false;
} else {
$this->error = "registerDomain: ".$this->error;
$this->disconnect();
return false;
}
}
} else {
return false;
}
}
public function infoDomain($domain)
{
if ($this->isConnected or $this->connect()) {
$xml = "<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd">
<command>
<info>
<domain:info xmlns:domain="urn:ietf:params:xml:ns:domain-1.0" xsi:schemaLocation="urn:ietf:params:xml:ns:domain-1.0 domain-1.0.xsd">
<domain:name>$domain</domain:name>
</domain:info>
</info>
<clTRID>".time()."</clTRID>
</command>
</epp>
";
if(!$this->send($xml)) {
$this->error='infoDomain: Unable to send query.';
$this->disconnect();
return false;
} else {
$result = $this->get();
if (is_array($result)) {
if ($result[epp][0][response][0][result][0][msg] == "Command completed successfully") {
return $this->answerArray['epp']['response']['resData']['infData'];
} else {
$this->error = "infoDomain: ".$result[epp][0][response][0][result][0][msg];
$this->disconnect();
return false;
}
} else if (!$this->error) {
$this->error = "registerDomain: Unable to get result.";
$this->disconnect();
return false;
} else {
$this->error = "registerDomain: ".$this->error;
$this->disconnect();
return false;
}
}
} else {
return false;
}
}
public function transferDomain($domain,$period,$contactId,$authinfo)
{
if ($this->isConnected or $this->connect()) {
if ($period) {
$periodTxt = "n<domain:period unit="y">".$period."</domain:period>";
}
$xml = "<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd">
<command>
<transfer op="request">
<domain:transfer xmlns:domain="urn:ietf:params:xml:ns:domain-1.0" xsi:schemaLocation="urn:ietf:params:xml:ns:domain-1.0 domain-1.0.xsd">
<domain:name>$domain</domain:name>$periodTxt
<domain:authInfo>
<domain:pw>$authinfo</domain:pw>
</domain:authInfo>
</domain:transfer>
</transfer>
<clTRID>".time()."</clTRID>
</command>
</epp>
";
if(!$this->send($xml)) {
$this->error='transferDomain: Unable to send query.';
$this->disconnect();
return false;
} else {
$result = $this->get();
if (is_array($result)) {
if ($result[epp][0][response][0][result][0][msg] == "Command completed successfully") {
return true;
} else {
$this->error = "transferDomain: ".$result[epp][0][response][0][result][0][msg];
$this->disconnect();
return false;
}
} else if (!$this->error) {
$this->error = "transferDomain: Unable to get result.";
$this->disconnect();
return false;
} else {
$this->error = "transferDomain: ".$this->error;
$this->disconnect();
return false;
}
}
} else {
return false;
}
}
public function renewDomain($domain,$period,$expdate)
{
if ($this->isConnected or $this->connect()) {
$xml = "<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd">
<command>
<renew>
<domain:renew xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
<domain:name>$domain</domain:name>
<domain:curExpDate>$expdate</domain:curExpDate>
<domain:period unit="y">$period</domain:period>
</domain:renew>
</renew>
<clTRID>".time()."</clTRID>
</command>
</epp>
";
if(!$this->send($xml)) {
$this->error='renewDomain: Unable to send query.';
$this->disconnect();
return false;
} else {
$result = $this->get();
if (is_array($result)) {
if ($result[epp][0][response][0][result][0][msg] == "Command completed successfully") {
return true;
} else {
$this->error = "renewDomain: ".$result[epp][0][response][0][result][0][msg];
$this->disconnect();
return false;
}
} else if (!$this->error) {
$this->error = "renewDomain: Unable to get result.";
$this->disconnect();
return false;
} else {
$this->error = "renewDomain: ".$this->error;
$this->disconnect();
return false;
}
}
} else {
return false;
}
}
public function getNS($domain)
{
if ($this->isConnected or $this->connect()) {
$info = $this->infoDomain($domain);
if (!$info) { return false; }
if ($info['ns']['hostObj'][0]) { $result[] = $info['ns']['hostObj'][0]; }
if ($info['ns']['hostObj'][1]) { $result[] = $info['ns']['hostObj'][1]; }
if ($info['ns']['hostObj'][2]) { $result[] = $info['ns']['hostObj'][2]; }
if ($info['ns']['hostObj'][3]) { $result[] = $info['ns']['hostObj'][3]; }
return $result;
} else {
return false;
}
}
public function updateNS($domain,$ns1,$ns2,$ns3,$ns4,$ns1ip,$ns2ip,$ns3ip,$ns4ip)
{
if ($this->isConnected or $this->connect()) {
$oldNSs = $this->getNS($domain);
if (!$oldNSs) { return false; }
$oldns1 = $oldNSs[0]; $oldns2 = $oldNSs[1]; $oldns3 = $oldNSs[2]; $oldns4 = $oldNSs[3];
$nscode = ""; $nscoderem = ""; $notRemedNS = array();
####################################################################################################################
if ($oldns1) {
if ($oldns1 != $ns1 and $oldns1 != $ns2 and $oldns1 != $ns3 and $oldns1 != $ns4) {
$nscoderem .= "<domain:hostObj>".$oldns1."</domain:hostObj>n";
} else {
if ($oldns1 == $ns1 and $ns1ip) { $hostNewIp = $ns1ip; } else if ($oldns1 == $ns2 and $ns2ip) { $hostNewIp = $ns2ip; } else if ($oldns1 == $ns3 and $ns3ip) { $hostNewIp = $ns3ip; } else if ($oldns1 == $ns4 and $ns4ip) { $hostNewIp = $ns4ip; } else { $hostNewIp = ""; }
$hostOldIp = "";
if ($hostNewIp) {
$hostOldIp = $this->infoIpHost($oldns1);
if (!$hostOldIp) { return false;}
if ($hostOldIp != $hostNewIp) { if (!$this->updateIpHost($oldns1, $hostOldIp, $hostNewIp)) { return false; } }
}
$notRemedNS[] = $oldns1;
}
}
if ($oldns2) {
if ($oldns2 != $ns1 and $oldns2 != $ns2 and $oldns2 != $ns3 and $oldns2 != $ns4) {
$nscoderem .= "<domain:hostObj>".$oldns2."</domain:hostObj>n";
} else {
if ($oldns2 == $ns1 and $ns1ip) { $hostNewIp = $ns1ip; } else if ($oldns2 == $ns2 and $ns2ip) { $hostNewIp = $ns2ip; } else if ($oldns2 == $ns3 and $ns3ip) { $hostNewIp = $ns3ip; } else if ($oldns2 == $ns4 and $ns4ip) { $hostNewIp = $ns4ip; } else { $hostNewIp = ""; }
$hostOldIp = "";
if ($hostNewIp) {
$hostOldIp = $this->infoIpHost($oldns2);
if (!$hostOldIp) { return false;}
if ($hostOldIp != $hostNewIp) { if (!$this->updateIpHost($oldns2, $hostOldIp, $hostNewIp)) { return false; } }
}
$notRemedNS[] = $oldns2;
}
}
if ($oldns3) {
if ($oldns3 != $ns1 and $oldns3 != $ns2 and $oldns3 != $ns3 and $oldns3 != $ns4) {
$nscoderem .= "<domain:hostObj>".$oldns3."</domain:hostObj>n";
} else {
if ($oldns3 == $ns1 and $ns1ip) { $hostNewIp = $ns1ip; } else if ($oldns3 == $ns2 and $ns2ip) { $hostNewIp = $ns2ip; } else if ($oldns3 == $ns3 and $ns3ip) { $hostNewIp = $ns3ip; } else if ($oldns3 == $ns4 and $ns4ip) { $hostNewIp = $ns4ip; } else { $hostNewIp = ""; }
$hostOldIp = "";
if ($hostNewIp) {
$hostOldIp = $this->infoIpHost($oldns3);
if (!$hostOldIp) { return false;}
if ($hostOldIp != $hostNewIp) { if (!$this->updateIpHost($oldns3, $hostOldIp, $hostNewIp)) { return false; } }
}
$notRemedNS[] = $oldns3;
}
}
if ($oldns4) {
if ($oldns4 != $ns1 and $oldns4 != $ns2 and $oldns4 != $ns3 and $oldns4 != $ns4) {
$nscoderem .= "<domain:hostObj>".$oldns4."</domain:hostObj>n";
} else {
if ($oldns4 == $ns1 and $ns1ip) { $hostNewIp = $ns1ip; } else if ($oldns4 == $ns2 and $ns2ip) { $hostNewIp = $ns2ip; } else if ($oldns4 == $ns3 and $ns3ip) { $hostNewIp = $ns3ip; } else if ($oldns4 == $ns4 and $ns4ip) { $hostNewIp = $ns4ip; } else { $hostNewIp = ""; }
$hostOldIp = "";
if ($hostNewIp) {
$hostOldIp = $this->infoIpHost($oldns4);
if (!$hostOldIp) { return false;}
if ($hostOldIp != $hostNewIp) { if (!$this->updateIpHost($oldns4, $hostOldIp, $hostNewIp)) { return false; } }
}
$notRemedNS[] = $oldns4;
}
}
if ($nscoderem) { $nscoderem = "<domain:rem>n<domain:ns>n".$nscoderem."</domain:ns>n</domain:rem>"; }
####################################################################################################################
if ($ns1 and !@in_array($ns1,$notRemedNS)) {
$result = $this->checkNS($ns1);
if (!$result) { return false; }
if ($result['avail']) { if (!$this->createNS($ns1,$ns1ip)) { return false; } }
else {
$hostOldIp = "";
if ($ns1ip) {
$hostOldIp = $this->infoIpHost($ns1);
if (!$hostOldIp) { return false;}
if ($hostOldIp != $ns1ip) { if (!$this->updateIpHost($ns1, $hostOldIp, $ns1ip)) { return false; } }
}
}
$nscode .= "<domain:hostObj>".$ns1."</domain:hostObj>n";
}
if ($ns2 and !@in_array($ns2,$notRemedNS)) {
$result = $this->checkNS($ns2);
if (!$result) { return false; }
if ($result['avail']) { if (!$this->createNS($ns2,$ns2ip)) { return false; } }
else {
$hostOldIp = "";
if ($ns2ip) {
$hostOldIp = $this->infoIpHost($ns2);
if (!$hostOldIp) { return false;}
if ($hostOldIp != $ns2ip) { if (!$this->updateIpHost($ns2, $hostOldIp, $ns2ip)) { return false; } }
}
}
$nscode .= "<domain:hostObj>".$ns2."</domain:hostObj>n";
}
if ($ns3 and !@in_array($ns3,$notRemedNS)) {
$result = $this->checkNS($ns3);
if (!$result) { return false; }
if ($result['avail']) { if (!$this->createNS($ns3,$ns3ip)) { return false; } }
else {
$hostOldIp = "";
if ($ns3ip) {
$hostOldIp = $this->infoIpHost($ns3);
if (!$hostOldIp) { return false;}
if ($hostOldIp != $ns3ip) { if (!$this->updateIpHost($ns3, $hostOldIp, $ns3ip)) { return false; } }
}
}
$nscode .= "<domain:hostObj>".$ns3."</domain:hostObj>n";
}
if ($ns4 and !@in_array($ns4,$notRemedNS)) {
$result = $this->checkNS($ns4);
if (!$result) { return false; }
if ($result['avail']) { if (!$this->createNS($ns4,$ns4ip)) { return false; } }
else {
$hostOldIp = "";
if ($ns4ip) {
$hostOldIp = $this->infoIpHost($ns4);
if (!$hostOldIp) { return false;}
if ($hostOldIp != $ns4ip) { if (!$this->updateIpHost($ns4, $hostOldIp, $ns4ip)) { return false; } }
}
}
$nscode .= "<domain:hostObj>".$ns4."</domain:hostObj>n";
}
if ($nscode) { $nscode = "<domain:add>n<domain:ns>n".$nscode."</domain:ns>n</domain:add>"; }
####################################################################################################################
$xml = "<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd">
<command>
<update>
<domain:update xmlns:domain="urn:ietf:params:xml:ns:domain-1.0" xsi:schemaLocation="urn:ietf:params:xml:ns:domain-1.0 domain-1.0.xsd">
<domain:name>$domain</domain:name>
$nscode
$nscoderem
</domain:update>
</update>
<clTRID>".time()."</clTRID>
</command>
</epp>
";
if(!$this->send($xml)) {
$this->error='updateNS: Unable to send query.';
$this->disconnect();
return false;
} else {
$result = $this->get();
if (is_array($result)) {
if (preg_match("/Command completed successfully/ui", $result[epp][0][response][0][result][0][msg])) {
return true;
} else {
$this->error = "updateNS: ".$result[epp][0][response][0][result][0][msg];
$this->disconnect();
return false;
}
} else if (!$this->error) {
$this->error = "updateNS: Unable to get result.";
$this->disconnect();
return false;
} else {
$this->error = "updateNS: ".$this->error;
$this->disconnect();
return false;
}
}
} else {
return false;
}
}
public function checkNS($ns)
{
if ($this->isConnected or $this->connect()) {
$xml = "<epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd">
<command>
<check>
<host:check xmlns:host="urn:ietf:params:xml:ns:host-1.0" xsi:schemaLocation="urn:ietf:params:xml:ns:host-1.0 host-1.0.xsd">
<host:name>$ns</host:name>
</host:check>
</check>
<clTRID>".time()."</clTRID>
</command>
</epp>
";
if(!$this->send($xml)) {
$this->error='checkNS: Unable to send query.';
$this->disconnect();
return false;
} else {
$result = $this->get();
if (is_array($result)) {
if (preg_match("/Command completed successfully/ui", $result[epp][0][response][0][result][0][msg])) {
$res['avail'] = $this->answerArray['epp']['response']['resData']['chkData']['cd']['name_attr']['avail'];
$res['reason'] = $this->answerArray['epp']['response']['resData']['chkData']['cd']['reason'];
return $res;
} else {
$this->error = "checkNS: ".$result[epp][0][response][0][result][0][msg];
$this->disconnect();
return false;
}
} else if (!$this->error) {
$this->error = "checkNS: Unable to get result.";
$this->disconnect();
return false;
} else {
$this->error = "checkNS: ".$this->error;
$this->disconnect();
return false;
}
}
} else {
return false;
}
}
public function infoIpHost($ns)
{
if ($this->isConnected or $this->connect()) {
$xml = "<epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd">
<command>
<info>
<host:info xmlns:host="urn:ietf:params:xml:ns:host-1.0" xsi:schemaLocation="urn:ietf:params:xml:ns:host-1.0 host-1.0.xsd">
<host:name>$ns</host:name>
</host:info>
</info>
<clTRID>".time()."</clTRID>
</command>
</epp>
";
if(!$this->send($xml)) {
$this->error='infoIpHost: Unable to send query.';
$this->disconnect();
return false;
} else {
$result = $this->get();
if (is_array($result)) {
if (preg_match("/Command completed successfully/ui", $result[epp][0][response][0][result][0][msg])) {
return $this->answerArray['epp']['response']['resData']['infData']['addr'];
} else {
$this->error = "infoIpHost: ".$result[epp][0][response][0][result][0][msg];
$this->disconnect();
return false;
}
} else if (!$this->error) {
$this->error = "infoIpHost: Unable to get result.";
$this->disconnect();
return false;
} else {
$this->error = "infoIpHost: ".$this->error;
$this->disconnect();
return false;
}
}
} else {
return false;
}
}
public function updateIpHost($ns, $oldIP, $newIP)
{
if ($this->isConnected or $this->connect()) {
$xml = "<epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd">
<command>
<update>
<host:update xmlns:host="urn:ietf:params:xml:ns:host-1.0" xsi:schemaLocation="urn:ietf:params:xml:ns:host-1.0 host-1.0.xsd">
<host:name>$ns</host:name>
<host:add>
<host:addr ip="v4">$newIP</host:addr>
</host:add>
<host:rem>
<host:addr ip="v4">$oldIP</host:addr>
</host:rem>
</host:update>
</update>
<clTRID>".time()."</clTRID>
</command>
</epp>
";
if(!$this->send($xml)) {
$this->error='updateIpHost: Unable to send query.';
$this->disconnect();
return false;
} else {
$result = $this->get();
if (is_array($result)) {
if (preg_match("/Command completed successfully/ui", $result[epp][0][response][0][result][0][msg])) {
return true;
} else {
$this->error = "updateIpHost: ".$result[epp][0][response][0][result][0][msg];
$this->disconnect();
return false;
}
} else if (!$this->error) {
$this->error = "updateIpHost: Unable to get result.";
$this->disconnect();
return false;
} else {
$this->error = "updateIpHost: ".$this->error;
$this->disconnect();
return false;
}
}
} else {
return false;
}
}
public function createNS($ns,$ip='')
{
if ($this->isConnected or $this->connect()) {
if ($ip) { $ip = "<host:addr ip="v4">$ip</host:addr>"; }
$xml = "<epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd">
<command>
<create>
<host:create xmlns:host="urn:ietf:params:xml:ns:host-1.0" xsi:schemaLocation="urn:ietf:params:xml:ns:host-1.0 host-1.0.xsd">
<host:name>$ns</host:name>
$ip
</host:create>
</create>
<clTRID>".time()."</clTRID>
</command>
</epp>
";
if(!$this->send($xml)) {
$this->error='createNS: Unable to send query.';
$this->disconnect();
return false;
} else {
$result = $this->get();
if (is_array($result)) {
if (preg_match("/Command completed successfully/ui", $result[epp][0][response][0][result][0][msg])) {
return true;
} else {
$this->error = "createNS: ".$result[epp][0][response][0][result][0][msg];
$this->disconnect();
return false;
}
} else if (!$this->error) {
$this->error = "createNS: Unable to get result.";
$this->disconnect();
return false;
} else {
$this->error = "createNS: ".$this->error;
$this->disconnect();
return false;
}
}
} else {
return false;
}
}
public function deleteNS($ns,$ip)
{
if ($this->isConnected or $this->connect()) {
$xml = "<epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd">
<command>
<delete>
<host:delete xmlns:host="urn:ietf:params:xml:ns:host-1.0" xsi:schemaLocation="urn:ietf:params:xml:ns:host-1.0 host-1.0.xsd">
<host:name>$ns</host:name>
<host:addr ip="v4">$ip</host:addr>
</host:delete>
</delete>
<clTRID>".time()."</clTRID>
</command>
</epp>
";
if(!$this->send($xml)) {
$this->error='deleteNS: Unable to send query.';
$this->disconnect();
return false;
} else {
$result = $this->get();
if (is_array($result)) {
if (preg_match("/Command completed successfully/ui", $result[epp][0][response][0][result][0][msg])) {
return true;
} else {
$this->error = "deleteNS: ".$result[epp][0][response][0][result][0][msg];
$this->disconnect();
return false;
}
} else if (!$this->error) {
$this->error = "deleteNS: Unable to get result.";
$this->disconnect();
return false;
} else {
$this->error = "deleteNS: ".$this->error;
$this->disconnect();
return false;
}
}
} else {
return false;
}
}
public function updateContact($contactId,$name,$org,$street,$city,$oblast,$post,$country,$phone,$email,$pw)
{
if ($this->isConnected or $this->connect()) {
$xml = "<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd">
<command>
<update>
<contact:update xmlns:contact="urn:ietf:params:xml:ns:contact-1.0" xsi:schemaLocation="urn:ietf:params:xml:ns:contact-1.0 contact-1.0.xsd">
<contact:id>$contactId</contact:id>
<contact:chg>
<contact:postalInfo type="loc">
<contact:name>$name</contact:name>
<contact:org>$org</contact:org>
<contact:addr>
<contact:street>$street</contact:street>
<contact:city>$city</contact:city>
<contact:sp>$oblast</contact:sp>
<contact:pc>$post</contact:pc>
<contact:cc>$country</contact:cc>
</contact:addr>
</contact:postalInfo>
<contact:voice>$phone</contact:voice>
<contact:email>$email</contact:email>
<contact:authInfo>
<contact:pw>$pw</contact:pw>
</contact:authInfo>
<contact:disclose flag="0">
<contact:voice />
<contact:email />
</contact:disclose>
</contact:chg>
</contact:update>
</update>
<clTRID>".time()."</clTRID>
</command>
</epp>
";
if(!$this->send($xml)) {
$this->error='updateContact: Unable to send query.';
$this->disconnect();
return false;
} else {
$result = $this->get();
if (is_array($result)) {
if ($result[epp][0][response][0][result][0][msg] == "Command completed successfully") {
return true;
} else {
$this->error = "updateContact: ".$result[epp][0][response][0][result][0][msg];
return false;
}
} else if (!$this->error) {
$this->error = "updateContact: Unable to get result.";
$this->disconnect();
return false;
} else {
$this->error = "updateContact: ".$this->error;
$this->disconnect();
return false;
}
}
} else {
return false;
}
}
}
?>