Файл: _rootinc/ppua.inc.php
Строк: 1602
<?
class PPUA
{
public $url = null;
public $port = null;
public $user = null;
public $password = null;
public $error = null;
public $fp = null;
public $isConnected = false;
private $log = null;
private $answer = null;
private $answerArray = null;
public function init($url,$port,$user,$password,$log)
{
$this->user = $user;
$this->url = $url;
$this->port = $port;
$this->password = $password;
$this->log = $log;
}
private function slog($str, $mode = MODE_INFO) {
if ($this->log) {
switch($mode) {
case MODE_INFO: $mode = "I"; break;
case MODE_CLIENT: $mode = "C"; break;
case MODE_SERVER: $mode = "S"; break;
}
if (is_string($str)) {
$str = explode("n", $str);
}
if (is_array($str)) {
foreach($str as $tmp) {
if (function_exists("posix_getpid")) { $pid = @posix_getpid(); }
else if (function_exists("getmypid")) { $pid = @getmypid(); }
$dt = date("Y-m-d H:i:s");
$tmp = sprintf("%s [%5s] %s: %sn", $dt, $pid, $mode, $tmp);
@error_log($tmp, 3, "./_rootlogs/".date("Ymd")."_drsua.log");
}
}
}
}
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)"; $this->slog($this->error);
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."; $this->slog($this->error);
return false;
} else {
$this->error = "connect: ".$this->error; $this->slog($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."; $this->slog($this->error);
return false;
}
$hdr = @fread($this->fp, 4);
if (empty($hdr)) {
$this->error = "get: Error reading from server: $php_errormsg"; $this->slog($this->error);
return false;
} else {
$unpacked = unpack('N', $hdr);
$answer = @fread($this->fp, ($unpacked[1] - 4));
if ($print) { print "nn".$answer."nn"; }
$this->answer = $answer;
$this->answerArray = xmlToArrayL($this->answer);
$this->slog("n>>> Got Responsen");
$this->slog($this->answer, MODE_SERVER);
return xml2array($answer);
}
}
public function send($xml)
{
$this->slog("n<<< Send Requestn");
$this->slog($xml, MODE_CLIENT);
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>
<objURI>urn:drs:xmlns:drs-1.0</objURI>
<objURI>urn:drs:xmlns:dotua-1.0</objURI>
<svcExtension>
<extURI>http://custom/obj1ext-1.0</extURI>
</svcExtension>
</svcs>
</login>
<clTRID>".time()."</clTRID>
</command>
</epp>
";
if(!$this->send($xml)) {
$this->error='login: Unable to send query.'; $this->slog($this->error);
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]." (".$result[epp][0][response][0][result][0][value][0]["oxrs:xcp"].")"; $this->slog($this->error);
return false;
}
} else if (!$this->error) {
$this->error = "login: Unable to get result."; $this->slog($this->error);
return false;
} else {
$this->error = "login: ".$this->error; $this->slog($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:email />
</contact:disclose>
</contact:create>
</create>
<clTRID>".time()."</clTRID>
</command>
</epp>
";
if(!$this->send($xml)) {
$this->error='createContact: Unable to send query.'; $this->slog($this->error);
$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]." (".$result[epp][0][response][0][result][0][value][0]["oxrs:xcp"].")"; $this->slog($this->error);
$this->disconnect();
return false;
}
} else if (!$this->error) {
$this->error = "createContact: Unable to get result."; $this->slog($this->error);
$this->disconnect();
return false;
} else {
$this->error = "createContact: ".$this->error; $this->slog($this->error);
$this->disconnect();
return false;
}
}
} else {
$this->disconnect();
return false;
}
}
public function registerDomain($domain,$period,$ns1,$ns2,$ns3,$ns4,$ns1ip,$ns2ip,$ns3ip,$ns4ip,$contactId,$pw)
{
if ($this->isConnected or $this->connect()) {
if ($ns1ip) {
$nscode = "<domain:hostAttr>n<domain:hostName>$ns1</domain:hostName>n<domain:hostAddr ip="v4">$ns1ip</domain:hostAddr>n</domain:hostAttr>";
} else {
$nscode = "<domain:hostAttr>n<domain:hostName>$ns1</domain:hostName>n</domain:hostAttr>";
}
if ($ns2ip) {
$nscode .= "<domain:hostAttr>n<domain:hostName>$ns2</domain:hostName>n<domain:hostAddr ip="v4">$ns2ip</domain:hostAddr>n</domain:hostAttr>";
} else {
$nscode .= "<domain:hostAttr>n<domain:hostName>$ns2</domain:hostName>n</domain:hostAttr>";
}
if ($ns3) {
if ($ns3ip) {
$nscode .= "<domain:hostAttr>n<domain:hostName>$ns3</domain:hostName>n<domain:hostAddr ip="v4">$ns3ip</domain:hostAddr>n</domain:hostAttr>";
} else {
$nscode .= "<domain:hostAttr>n<domain:hostName>$ns3</domain:hostName>n</domain:hostAttr>";
}
}
if ($ns4) {
if ($ns4ip) {
$nscode .= "<domain:hostAttr>n<domain:hostName>$ns4</domain:hostName>n<domain:hostAddr ip="v4">$ns4ip</domain:hostAddr>n</domain:hostAttr>";
} else {
$nscode .= "<domain:hostAttr>n<domain:hostName>$ns4</domain:hostName>n</domain:hostAttr>";
}
}
$dom=mb_split(".",$domain);
$zone=preg_replace("/$dom[0]./ui","",$domain);
if (mb_strtolower($zone) == "pp.ua" or mb_strtolower($zone) == "co.ua" or mb_strtolower($zone) == "biz.ua") {
$registrant = "<domain:registrant>$contactId</domain:registrant>";
$billing = "<domain:contact type="billing">$contactId</domain:contact>";
}
else {
$registrant = "";
$billing = "";
}
$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>
$registrant
<domain:contact type="admin">$contactId</domain:contact>
<domain:contact type="tech">$contactId</domain:contact>
$billing
<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->slog($this->error);
$this->disconnect();
return false;
} else {
$result = $this->get();
if (is_array($result)) {
if ($result[epp][0][response][0][result][0][msg] == "Command completed successfully" or $result[epp][0][response][0][result][0][msg] == "Command completed successfully, action pending" or $result[epp][0][response][0][result][0][msg] == "Command completed successfully; action pending") {
$this->disconnect();
if ($result[epp][0][response][0][result][0][msg] == "Command completed successfully") {
return "ok";
} else {
return "pending";
}
} else {
$this->error = "registerDomain: ".$result[epp][0][response][0][result][0][msg]." (".$result[epp][0][response][0][result][0][value][0]["oxrs:xcp"].")"; $this->slog($this->error);
$this->disconnect();
return false;
}
} else if (!$this->error) {
$this->error = "registerDomain: Unable to get result."; $this->slog($this->error);
$this->disconnect();
return false;
} else {
$this->error = "registerDomain: ".$this->error; $this->slog($this->error);
$this->disconnect();
return false;
}
}
} else {
$this->disconnect();
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->slog($this->error);
$this->disconnect();
return false;
} else {
$result = $this->get();
if (is_array($result)) {
if ($result[epp][0][response][0][result][0][msg] == "Command completed successfully" or $result[epp][0][response][0][result][0][msg] == "Command completed successfully; action pending") {
$this->disconnect();
return true;
} else {
$this->error = "transferDomain: ".$result[epp][0][response][0][result][0][msg]." (".$result[epp][0][response][0][result][0][value][0]["oxrs:xcp"].")"; $this->slog($this->error);
$this->disconnect();
return false;
}
} else if (!$this->error) {
$this->error = "transferDomain: Unable to get result."; $this->slog($this->error);
$this->disconnect();
return false;
} else {
$this->error = "transferDomain: ".$this->error; $this->slog($this->error);
$this->disconnect();
return false;
}
}
} else {
$this->disconnect();
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">
<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->slog($this->error);
$this->disconnect();
return false;
} else {
$result = $this->get();
if (is_array($result)) {
if ($result[epp][0][response][0][result][0][msg] == "Command completed successfully") {
$this->disconnect();
return $this->answerArray;
} else {
$this->error = "infoDomain: ".$result[epp][0][response][0][result][0][msg]." (".$result[epp][0][response][0][result][0][value][0]["oxrs:xcp"].")"; $this->slog($this->error);
$this->disconnect();
return false;
}
} else if (!$this->error) {
$this->error = "infoDomain: Unable to get result."; $this->slog($this->error);
$this->disconnect();
return false;
} else {
$this->error = "infoDomain: ".$this->error; $this->slog($this->error);
$this->disconnect();
return false;
}
}
} else {
$this->disconnect();
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->slog($this->error);
$this->disconnect();
return false;
} else {
$result = $this->get();
if (is_array($result)) {
if ($result[epp][0][response][0][result][0][msg] == "Command completed successfully" or $result[epp][0][response][0][result][0][msg] == "Command completed successfully; action pending") {
$this->disconnect();
return true;
} else {
$this->error = "renewDomain: ".$result[epp][0][response][0][result][0][msg]." (".$result[epp][0][response][0][result][0][value][0]["oxrs:xcp"].")"; $this->slog($this->error);
$this->disconnect();
return false;
}
} else if (!$this->error) {
$this->error = "renewDomain: Unable to get result."; $this->slog($this->error);
$this->disconnect();
return false;
} else {
$this->error = "renewDomain: ".$this->error; $this->slog($this->error);
$this->disconnect();
return false;
}
}
} else {
$this->disconnect();
return false;
}
}
public function getNS($domain)
{
$d = new domain($domain);
$result = $d->info();
if (!$d->last_error) {
$result1 = mb_split("n", $result);
while (list($index,$res) = each($result1)) {
if (preg_match("/nserver/ui",$res)) {
$res = preg_replace("/ d+.d+.d+.d+/iu","",$res);
preg_match("/nserver:s*(.*)/iu",$res,$arr);
$resultarray[]=trim($arr[1]);
} else if (preg_match("/Name Server/ui",$res)) {
$res = preg_replace("/ d+.d+.d+.d+/iu","",$res);
preg_match("/Name Server:s*(.*)/iu",$res,$arr);
$resultarray[]=trim($arr[1]);
}
}
return $resultarray;
} else {
$this->error = "getNS: $d->last_error"; $this->slog($this->error);
return false;
}
}
public function updateNS($domain,$ns1,$ns2,$ns3,$ns4,$ns1ip,$ns2ip,$ns3ip,$ns4ip)
{
$remNS = $this->getNS($domain);
if (is_array($remNS)) {
$nscoderem = "<domain:hostObj>".$remNS[0]."</domain:hostObj>n<domain:hostObj>".$remNS[1]."</domain:hostObj>";
if ($remNS[2]) { $nscoderem = $nscoderem."n<domain:hostObj>".$remNS[2]."</domain:hostObj>"; }
if ($remNS[3]) { $nscoderem = $nscoderem."n<domain:hostObj>".$remNS[3]."</domain:hostObj>"; }
} else {
$this->error = "updateNS: Unable to get current DNS-servers."; $this->slog($this->error);
return false;
}
if ($this->isConnected or $this->connect() and !$this->error) {
if ($ns1ip) {
$nscode = "<domain:hostAttr>n<domain:hostName>$ns1</domain:hostName>n<domain:hostAddr ip="v4">$ns1ip</domain:hostAddr>n</domain:hostAttr>";
} else {
$nscode = "<domain:hostAttr>n<domain:hostName>$ns1</domain:hostName>n</domain:hostAttr>";
}
if ($ns2ip) {
$nscode .= "<domain:hostAttr>n<domain:hostName>$ns2</domain:hostName>n<domain:hostAddr ip="v4">$ns2ip</domain:hostAddr>n</domain:hostAttr>";
} else {
$nscode .= "<domain:hostAttr>n<domain:hostName>$ns2</domain:hostName>n</domain:hostAttr>";
}
if ($ns3) {
if ($ns3ip) {
$nscode .= "<domain:hostAttr>n<domain:hostName>$ns3</domain:hostName>n<domain:hostAddr ip="v4">$ns3ip</domain:hostAddr>n</domain:hostAttr>";
} else {
$nscode .= "<domain:hostAttr>n<domain:hostName>$ns3</domain:hostName>n</domain:hostAttr>";
}
}
if ($ns4) {
if ($ns4ip) {
$nscode .= "<domain:hostAttr>n<domain:hostName>$ns4</domain:hostName>n<domain:hostAddr ip="v4">$ns4ip</domain:hostAddr>n</domain:hostAttr>";
} else {
$nscode .= "<domain:hostAttr>n<domain:hostName>$ns4</domain:hostName>n</domain:hostAttr>";
}
}
$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>
<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>
<domain:add>
<domain:ns>
$nscode
</domain:ns>
</domain:add>
<domain:rem>
<domain:ns>
$nscoderem
</domain:ns>
</domain:rem>
</domain:update>
</update>
<clTRID>".time()."</clTRID>
</command>
</epp>
";
if(!$this->send($xml)) {
$this->error='updateNS: Unable to send query.'; $this->slog($this->error);
$this->disconnect();
return false;
} else {
$result = $this->get();
if (is_array($result)) {
if ($result[epp][0][response][0][result][0][msg] == "Command completed successfully" or $result[epp][0][response][0][result][0][msg] == "Command completed successfully; action pending") {
$this->disconnect();
return true;
} else {
$this->error = "updateNS: ".$result[epp][0][response][0][result][0][msg]." (".$result[epp][0][response][0][result][0][value][0]["oxrs:xcp"].")"; $this->slog($this->error);
$this->disconnect();
return false;
}
} else if (!$this->error) {
$this->error = "updateNS: Unable to get result."; $this->slog($this->error);
$this->disconnect();
return false;
} else {
$this->error = "updateNS: ".$this->error; $this->slog($this->error);
$this->disconnect();
return false;
}
}
} else {
$this->disconnect();
return false;
}
}
public function updateContactDomain($domain, $oldContactId, $newContactId, $authinfo='')
{
if ($this->isConnected or $this->connect()) {
if ($oldContactId) { $domainRem = "<domain:rem>n<domain:contact type="admin">$oldContactId</domain:contact>n<domain:contact type="tech">$oldContactId</domain:contact>n</domain:rem>"; }
if ($authinfo) { $authinfo = "<domain:authInfo>n<domain:pw>$authinfo</domain:pw>n</domain:authInfo>n";}
$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>
<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>
<domain:add>
<domain:contact type="admin">$newContactId</domain:contact>
<domain:contact type="tech">$newContactId</domain:contact>
</domain:add>
$domainRem
<domain:chg>
<domain:registrant>$newContactId</domain:registrant>
$authinfo
</domain:chg>
</domain:update>
</update>
<clTRID>".time()."</clTRID>
</command>
</epp>
";
if(!$this->send($xml)) {
$this->error='updateContactDomain: Unable to send query.'; $this->slog($this->error);
$this->disconnect();
return false;
} else {
$result = $this->get();
if (is_array($result)) {
if ($result[epp][0][response][0][result][0][msg] == "Command completed successfully" or $result[epp][0][response][0][result][0][msg] == "Command completed successfully; action pending") {
$this->disconnect();
return true;
} else {
$this->error = "updateContactDomain: ".$result[epp][0][response][0][result][0][msg]." (".$result[epp][0][response][0][result][0][value][0]["oxrs:xcp"].")"; $this->slog($this->error);
$this->disconnect();
return false;
}
} else if (!$this->error) {
$this->error = "updateContactDomain: Unable to get result."; $this->slog($this->error);
$this->disconnect();
return false;
} else {
$this->error = "updateNS: ".$this->error; $this->slog($this->error);
$this->disconnect();
return false;
}
}
} else {
$this->disconnect();
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: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->slog($this->error);
$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]." (".$result[epp][0][response][0][result][0][value][0]["oxrs:xcp"].")"; $this->slog($this->error);
$this->disconnect();
return false;
}
} else if (!$this->error) {
$this->error = "updateContact: Unable to get result."; $this->slog($this->error);
$this->disconnect();
return false;
} else {
$this->error = "updateContact: ".$this->error; $this->slog($this->error);
$this->disconnect();
return false;
}
}
} else {
$this->disconnect();
return false;
}
}
public function reqPoll() {
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>
<poll op="req" />
<clTRID>".time()."</clTRID>
</command>
</epp>
";
if(!$this->send($xml)) {
$this->error='reqPoll: Unable to send query.'; $this->slog($this->error);
$this->disconnect();
return false;
} else {
$result = $this->get();
if (is_array($result)) {
if ($this->answerArray[epp][response][result_attr][code] == "1000" or $this->answerArray[epp][response][result_attr][code] == "1300" or $this->answerArray[epp][response][result_attr][code] == "1301") {
$res['msgId'] = $this->answerArray['epp']['response']['msgQ_attr']['id'];
$res['msgCount'] = $this->answerArray['epp']['response']['msgQ_attr']['count'];
if ($this->answerArray['epp']['response']['resData']['notify']['message']) {
$res['msgText'] = $this->answerArray['epp']['response']['resData']['notify']['message'];
} else {
$res['msgText'] = $this->answerArray['epp']['response']['msgQ']['msg'];
}
if (preg_match("/Pending action completed successfully/iu",$res['msgText'])) {
# Регистрация домена подтверждена
$res['type'] = "domainActivated";
$res['domain'] = $this->answerArray['epp']['response']['resData']['panData']['name'];
}
else if (preg_match("/has been cancelled/iu",$res['msgText'])) {
# Регистрация домена не подтверждена
$res['type'] = "domainCanceled";
$res['domain'] = $this->answerArray['epp']['response']['resData']['notify']['object'];
}
else if (preg_match("/has been pending to delete/iu",$res['msgText'])) {
# Регистрация домена не подтверждена
$res['type'] = "domainCanceled";
$res['domain'] = $this->answerArray['epp']['response']['resData']['notify']['object'];
}
else if (preg_match("/Pending action completed with error/iu",$res['msgText'])) {
# Регистрация домена не подтверждена
$res['type'] = "domainCanceled";
$res['domain'] = $this->answerArray['epp']['response']['resData']['panData']['name'];;
}
else if (preg_match("/has been held/iu",$res['msgText'])) {
# Домен приостановлен
$res['type'] = "domainHeld";
$res['domain'] = $this->answerArray['epp']['response']['resData']['notify']['object'];;
}
else if (preg_match("/TRANSFER_PENDING/iu",$res['msgText'])) {
# Запрос на трансфер к другому регистратору
$res['type'] = "transferPending";
$res['domain'] = $this->answerArray['epp']['response']['resData']['trnData']['name'];
$res['registrator'] = $this->answerArray['epp']['response']['resData']['trnData']['reID'];
}
else if (preg_match("/TRANSFER_CLIENT_APPROVED/iu",$res['msgText'])) {
# Запрос на трансфер к другому регистратору подтвержден
$res['type'] = "transferRequestApprove";
$res['domain'] = $this->answerArray['epp']['response']['resData']['trnData']['name'];
$res['registrator'] = $this->answerArray['epp']['response']['resData']['trnData']['reID'];
}
else if (preg_match("/TRANSFER_CLIENT_REJECTED/iu",$res['msgText'])) {
# Запрос на трансфер от другого регистратора не подтвержден
$res['type'] = "transferReject";
$res['domain'] = $this->answerArray['epp']['response']['resData']['trnData']['name'];
$res['registrator'] = $this->answerArray['epp']['response']['resData']['trnData']['reID'];
}
else if (preg_match("/Domain is pending delete/iu",$res['msgText'])) {
# Заявка на удаление домена принята
$res['type'] = "domainPendingDelete";
$res['domain'] = $this->answerArray['epp']['response']['resData']['infData']['name'];
}
else if (preg_match("/has been deleted/iu",$res['msgText'])) {
# Заявка на удаление домена обработана
$res['type'] = "domainDeleted";
$res['domain'] = $this->answerArray['epp']['response']['resData']['notify']['object'];
}
$res['xml'] = $this->answer;
return $res;
} else {
$this->error = "reqPoll: ".$this->answerArray[epp][response][result_attr][code]." ".$this->answerArray[epp][response][result][msg]." (".$this->answerArray[epp][response][result][extValue][reason].")"; $this->slog($this->error);
$this->disconnect();
return false;
}
} else if (!$this->error) {
$this->error = "reqPoll: Unable to get result."; $this->slog($this->error);
$this->disconnect();
return false;
} else {
$this->error = "reqPoll: ".$this->error; $this->slog($this->error);
$this->disconnect();
return false;
}
}
} else {
$this->disconnect();
return false;
}
}
public function ackPoll($msgId) {
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>
<poll op="ack" msgID="$msgId" />
<clTRID>".time()."</clTRID>
</command>
</epp>
";
if(!$this->send($xml)) {
$this->error='ackPoll: Unable to send query.'; $this->slog($this->error);
$this->disconnect();
return false;
} else {
$result = $this->get();
if (is_array($result)) {
if ($this->answerArray[epp][response][result_attr][code] == "1000" or $this->answerArray[epp][response][result_attr][code] == "1300" or $this->answerArray[epp][response][result_attr][code] == "1301") {
return true;
} else {
$this->error = "ackPoll: ".$this->answerArray[epp][response][result_attr][code]." ".$this->answerArray[epp][response][result][msg]." (".$this->answerArray[epp][response][result][extValue][reason].")"; $this->slog($this->error);
$this->disconnect();
return false;
}
} else if (!$this->error) {
$this->error = "ackPoll: Unable to get result."; $this->slog($this->error);
$this->disconnect();
return false;
} else {
$this->error = "ackPoll: ".$this->error; $this->slog($this->error);
$this->disconnect();
return false;
}
}
} else {
$this->disconnect();
return false;
}
}
public function approveTransfer($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>
<transfer op="approve">
<domain:transfer xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
<domain:name>$domain</domain:name>
</domain:transfer>
</transfer>
<clTRID>".time()."</clTRID>
</command>
</epp>
";
if(!$this->send($xml)) {
$this->error='approveTransfer: Unable to send query.'; $this->slog($this->error);
$this->disconnect();
return false;
} else {
$result = $this->get();
if (is_array($result)) {
if ($this->answerArray[epp][response][result_attr][code] == "1000") {
return true;
} else {
$this->error = "approveTransfer: ".$this->answerArray[epp][response][result_attr][code]." ".$this->answerArray[epp][response][result][msg]." (".$this->answerArray[epp][response][result][extValue][reason].")"; $this->slog($this->error);
$this->disconnect();
return false;
}
} else if (!$this->error) {
$this->error = "approveTransfer: Unable to get result."; $this->slog($this->error);
$this->disconnect();
return false;
} else {
$this->error = "approveTransfer: ".$this->error; $this->slog($this->error);
$this->disconnect();
return false;
}
}
} else {
$this->disconnect();
return false;
}
}
public function rejectTransfer($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>
<transfer op="reject">
<domain:transfer xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
<domain:name>$domain</domain:name>
</domain:transfer>
</transfer>
<clTRID>".time()."</clTRID>
</command>
</epp>
";
if(!$this->send($xml)) {
$this->error='rejectTransfer: Unable to send query.'; $this->slog($this->error);
$this->disconnect();
return false;
} else {
$result = $this->get();
if (is_array($result)) {
if ($this->answerArray[epp][response][result_attr][code] == "1000") {
return true;
} else {
$this->error = "rejectTransfer: ".$this->answerArray[epp][response][result_attr][code]." ".$this->answerArray[epp][response][result][msg]." (".$this->answerArray[epp][response][result][extValue][reason].")"; $this->slog($this->error);
$this->disconnect();
return false;
}
} else if (!$this->error) {
$this->error = "rejectTransfer: Unable to get result."; $this->slog($this->error);
$this->disconnect();
return false;
} else {
$this->error = "rejectTransfer: ".$this->error; $this->slog($this->error);
$this->disconnect();
return false;
}
}
} else {
$this->disconnect();
return false;
}
}
}
?>