Файл: _rootinc/ukrnames.inc.php
Строк: 1056
<?
class UKRNAMES
{
public $url = null;
public $port = null;
public $user = null;
public $password = null;
public $error = null;
public $fp = null;
public $isConnected = false;
public function init($url,$port,$user,$password)
{
$this->user = $user;
$this->url = $url;
$this->port = $port;
$this->password = $password;
}
public function connect()
{
$socket = @fsockopen("ssl://".$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()
{
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));
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>
</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]." (".$result[epp][0][response][0][result][0][value][0]["oxrs:xcp"].")";
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()) {
$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>AUTO</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]." (".$result[epp][0][response][0][result][0][value][0]["oxrs:xcp"].")";
$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 {
$this->disconnect();
return false;
}
}
public function registerDomain($domain,$ns1,$ns2,$ns3,$ns4,$cRegistrant,$cAdmin,$cTech,$cBilling,$pw)
{
if ($this->isConnected or $this->connect()) {
$nscode = "<domain:hostObj>$ns1</domain:hostObj>n<domain:hostObj>$ns2</domain:hostObj>";
if ($ns3) { $nscode = $nscode."n<domain:hostObj>$ns3</domain:hostObj>"; }
if ($ns4) { $nscode = $nscode."n<domain:hostObj>$ns4</domain:hostObj>"; }
$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:ns>
$nscode
</domain:ns>
<domain:registrant>$cRegistrant</domain:registrant>
<domain:contact type="admin">$cAdmin</domain:contact>
<domain:contact type="tech">$cTech</domain:contact>
<domain:contact type="billing">$cBilling</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") {
$this->disconnect();
return true;
} else {
$this->error = "registerDomain: ".$result[epp][0][response][0][result][0][msg]." (".$result[epp][0][response][0][result][0][value][0]["oxrs:xcp"].")";
$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 {
$this->disconnect();
return false;
}
}
public function transferDomain($domain,$period,$cRegistrant,$cAdmin,$cTech,$cBilling,$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>
<extension>
<transfer>
<domain:registrant>$cRegistrant</domain:registrant>
<domain:contact type="admin">$cAdmin</domain:contact>
<domain:contact type="tech">$cTech</domain:contact>
<domain:contact type="billing">$cBilling</domain:contact>
</transfer>
</extension>
<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; 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->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 {
$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->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 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->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 {
$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";;
return false;
}
}
public function updateNS($domain,$ns1,$ns2,$ns3,$ns4)
{
$remNS = $this->getNS($domain);
$nscoderem = "";
if (is_array($remNS)) {
if ($remNS[0] and $remNS[0] != $ns1 and $remNS[0] != $ns2 and $remNS[0] != $ns3 and $remNS[0] != $ns4) { $nscoderem = $nscoderem."n<domain:hostObj>".$remNS[0]."</domain:hostObj>"; }
if ($remNS[1] and $remNS[1] != $ns1 and $remNS[1] != $ns2 and $remNS[1] != $ns3 and $remNS[1] != $ns4) { $nscoderem = $nscoderem."n<domain:hostObj>".$remNS[1]."</domain:hostObj>"; }
if ($remNS[2] and $remNS[2] != $ns1 and $remNS[2] != $ns2 and $remNS[2] != $ns3 and $remNS[2] != $ns4) { $nscoderem = $nscoderem."n<domain:hostObj>".$remNS[2]."</domain:hostObj>"; }
if ($remNS[3] and $remNS[3] != $ns1 and $remNS[3] != $ns2 and $remNS[3] != $ns3 and $remNS[3] != $ns4) { $nscoderem = $nscoderem."n<domain:hostObj>".$remNS[3]."</domain:hostObj>"; }
} else {
$this->error = "updateNS: Unable to get current DNS-servers.";
return false;
}
if ($nscoderem) {
$nscoderem = "<domain:rem>n<domain:ns>".$nscoderem."n</domain:ns>n</domain:rem>";
}
if ($this->isConnected or $this->connect() and !$this->error) {
$nscode = "<domain:hostObj>$ns1</domain:hostObj>n<domain:hostObj>$ns2</domain:hostObj>";
if ($ns3) { $nscode = $nscode."n<domain:hostObj>$ns3</domain:hostObj>"; }
if ($ns4) { $nscode = $nscode."n<domain:hostObj>$ns4</domain:hostObj>"; }
$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>
$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])) {
$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->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 {
$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: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; action pending") {
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->disconnect();
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 {
$this->disconnect();
return false;
}
}
public function createNS($ns,$ip,$zone)
{
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">
<command>
<create>
<host:create xmlns:host="urn:ietf:params:xml:ns:host-1.0">
<host:name>$ns</host:name>
<host:addr ip="v4">$ip</host:addr>
</host:create>
</create>
<extension>
<create>
<zone>$zone</zone>
</create>
</extension>
<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 ($result[epp][0][response][0][result][0][msg] == "Command completed successfully") {
$this->disconnect();
return true;
} else {
$this->error = "createNS: ".$result[epp][0][response][0][result][0][msg]." (".$result[epp][0][response][0][result][0][value][0]["oxrs:xcp"].")";
$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 {
$this->disconnect();
return false;
}
}
public function deleteNS($ns,$ip,$zone)
{
$this->error = "deleteNS: function temporarily don't exists";
return true;
}
public function enablePrivacyProtection($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">
<command>
<protect>
<protect>
<name>$domain</name>
</protect>
</protect>
<clTRID>".time()."</clTRID>
</command>
</epp>
";
if(!$this->send($xml)) {
$this->error='enablePrivacyProtection: 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") {
$this->disconnect();
return true;
} else {
$this->error = "enablePrivacyProtection: ".$result[epp][0][response][0][result][0][msg]." (".$result[epp][0][response][0][result][0][value][0]["oxrs:xcp"].")";
$this->disconnect();
return false;
}
} else if (!$this->error) {
$this->error = "enablePrivacyProtection: Unable to get result.";
$this->disconnect();
return false;
} else {
$this->error = "enablePrivacyProtection: ".$this->error;
$this->disconnect();
return false;
}
}
} else {
$this->disconnect();
return false;
}
}
public function disablePrivacyProtection($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">
<command>
<unprotect>
<unprotect>
<name>$domain</name>
</unprotect>
</unprotect>
<clTRID>".time()."</clTRID>
</command>
</epp>
";
if(!$this->send($xml)) {
$this->error='disablePrivacyProtection: 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") {
$this->disconnect();
return true;
} else {
$this->error = "disablePrivacyProtection: ".$result[epp][0][response][0][result][0][msg]." (".$result[epp][0][response][0][result][0][value][0]["oxrs:xcp"].")";
$this->disconnect();
return false;
}
} else if (!$this->error) {
$this->error = "disablePrivacyProtection: Unable to get result.";
$this->disconnect();
return false;
} else {
$this->error = "disablePrivacyProtection: ".$this->error;
$this->disconnect();
return false;
}
}
} else {
$this->disconnect();
return false;
}
}
}
?>