Файл: _rootinc/onlinenic.inc.php
Строк: 700
<?
$onlinenicDomainTypes["biz"] = 800;
$onlinenicDomainTypes["info"] = 805;
$onlinenicDomainTypes["us"] = 806;
$onlinenicDomainTypes["in"] = 808;
$onlinenicDomainTypes["cn"] = 220;
$onlinenicDomainTypes["com"] = 0;
$onlinenicDomainTypes["net"] = 0;
$onlinenicDomainTypes["org"] = 0;
$onlinenicDomainTypes["ws"] = 301;
$onlinenicDomainTypes["tv"] = 400;
$onlinenicDomainTypes["mobi"] = 903;
$onlinenicDomainTypes["cc"] = 600;
$onlinenicDomainTypes["eu"] = 902;
$onlinenicDomainTypes["asia"] = 905;
$onlinenicDomainTypes["me"] = 906;
$onlinenicDomainTypes["uk"] = 901;
$onlinenicDomainTypes["tw"] = 302;
$onlinenicDomainTypes["name"] = 804;
class ONLINENIC
{
public $url = null;
public $port = null;
public $user = null;
public $password = null;
public $md5password = null;
public $clTRID = null;
public $error = null;
public $fp = null;
public function init($url,$port,$user,$password)
{
$this->url = $url;
$this->port = $port;
$this->user = $user;
$this->password = $password;
$this->md5password = md5($password);
}
public function get($size = "")
{
if ($size) {
$result = socket_read($this->fp, $size);
} else {
$result="";
while (false !== ($res = socket_read($this->fp, 2))){
$result .= $res;
if (preg_match("/</epp>/u",$result))
break;
}
}
$result = toarray($result,"epp",1);
if (is_array($result)) {
return $result;
} else {
return false;
}
}
public function connect()
{
if (($sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP)) < 0) {
$this->error="Socket Error: Could not initialize socket.";
return false;
}
if (!$result = socket_connect($sock, $this->url, $this->port)) {
$this->error="Socket Error: Could not connect to the host.";
return false;
}
$this->fp=$sock;
$result = $this->get();
if ($result[svID][0][value]) {
if ($this->login()) {
return true;
}
else {
return false;
}
} else {
$this->error = "connect: No response from server";
return false;
}
}
public function disconnect()
{
$command = "<command>logout</command>n<chksum>".md5("logout".$this->user.$this->md5password)."</chksum>n<auth>".$this->auth."</auth>";
socket_write($this->fp, $command, strlen($command));
}
public function login()
{
$this->clTRID = microtime();
$query = "<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp>
<command>
<creds>
<clID>".$this->user."</clID>
<options>
<version>1.0</version>
<lang>en</lang>
</options>
</creds>
<clTRID>".$this->clTRID."</clTRID>
<login><chksum>".md5($this->user.$this->md5password.$this->clTRID."login")."</chksum></login>
</command>
</epp>
";
if(!socket_write($this->fp, $query, strlen($query))) {
$this->error='logIn: Unable to send query';
return false;
} else {
$result = $this->get();
if ($result) {
if ($result[result][0][attributes][code] == "1000") {
return true;
} else {
$this->error = "logIn: Code=".$result[result][0][attributes][code]." ".$result[msg][0][value]." (".$result[value][0][value].")";
return false;
}
} else {
$this->error = "logIn: Unable to get result";
return false;
}
}
}
public function createContact($domaintype,$name,$org,$street1,$street2,$city,$sp,$pc,$cc,$voice,$fax,$email,$pw)
{
$this->clTRID = microtime();
$query = "<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="urn:iana:xml:ns:epp-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:iana:xml:ns:epp-1.0 epp-1.0.xsd">
<command>
<create>
<contact:create xmlns:contact="urn:iana:xml:ns:contact-1.0" xsi:schemaLocation="urn:iana:xml:ns:con tact-1.0 contact-1.0.xsd">
<contact:domaintype>".$domaintype."</contact:domaintype>
<contact:ascii>
<contact:name>".$name."</contact:name>
<contact:org>".$org."</contact:org>
<contact:addr>
<contact:street1>".$street1."</contact:street1>
<contact:street2>".$street2."</contact:street2>
<contact:city>".$city."</contact:city>
<contact:sp>".$sp."</contact:sp>
<contact:pc>".$pc."</contact:pc>
<contact:cc>".$cc."</contact:cc>
</contact:addr>
</contact:ascii>
<contact:voice>".$voice."</contact:voice>
<contact:fax>".$fax."</contact:fax>
<contact:email>".$email."</contact:email>
<contact:pw>".$pw."</contact:pw>
</contact:create>
</create>
<unspec/>
<clTRID>".$this->clTRID."</clTRID>
<chksum>".md5($this->user.$this->md5password.$this->clTRID."crtcontact".$name.$org.$email)."</chksum>
</command>
</epp>
";
if(!socket_write($this->fp, $query, strlen($query))) {
$this->error='createContact: Unable to send query';
return false;
} else {
$result = $this->get();
if ($result) {
if ($result[result][0][attributes][code] == "1000") {
return $result["contact:id"][0][value];
} else {
$this->error = "createContact: Code=".$result[result][0][attributes][code]." ".$result[msg][0][value]." (".$result[value][0][value].")";
return false;
}
} else {
$this->error = "createContact: Unable to get result";
return false;
}
}
}
public function regDomain($domain,$period,$ns1,$ns2,$ns3,$ns4,$domaintype,$name,$org,$street1,$street2,$city,$sp,$pc,$cc,$voice,$fax,$email,$pw)
{
if ($this->connect()) {
$contactId = $this->createContact($domaintype,$name,$org,$street1,$street2,$city,$sp,$pc,$cc,$voice,$fax,$email,$pw);
if ($contactId) {
$this->clTRID = microtime();
if ($domaintype == "902") {
// .EU
$contactsQ = "<domain:registrant>".$contactId."</domain:registrant>";
$contactsCHK = $contactId;
} else {
// Other Zones
$contactsQ = "<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>";
$contactsCHK = $contactId.$contactId.$contactId.$contactId;
}
$nsQ = "<domain:ns1>".$ns1."</domain:ns1>
<domain:ns2>".$ns2."</domain:ns2>";
$nsCHK = $ns1.$ns2;
if ($ns3 and $domaintype != "902") { $nsQ = $nsQ."rn <domain:ns3>".$ns3."</domain:ns3>"; $nsCHK = $nsCHK.$ns3; }
if ($ns4 and $domaintype != "902") { $nsQ = $nsQ."rn <domain:ns4>".$ns4."</domain:ns4>"; $nsCHK = $nsCHK.$ns4; }
$query = "<?xml version="1.0" encoding="UTF-8"?>
<epp>
<command>
<create>
<domain:create>
<domain:type>".$domaintype."</domain:type>
<domain:name>".$domain."</domain:name>
<domain:period>".$period."</domain:period>
".$nsQ."
".$contactsQ."
<domain:authInfo type="pw">".$pw."</domain:authInfo>
</domain:create>
</create>
<clTRID>".$this->clTRID."</clTRID>
<chksum>".md5($this->user.$this->md5password.$this->clTRID."crtdomain".$domaintype.$domain.$period.$nsCHK.$contactsCHK.$pw)."</chksum>
</command>
</epp>
";
if(!socket_write($this->fp, $query, strlen($query))) {
$this->error='regDomain: Unable to send query';
return false;
} else {
$result = $this->get();
if ($result) {
if ($result[result][0][attributes][code] == "1000") {
return $contactId;
} else {
$this->error = "regDomain: Code=".$result[result][0][attributes][code]." ".$result[msg][0][value]." (".$result[value][0][value].")";
return false;
}
} else {
$this->error = "regDomain: Unable to get result";
return false;
}
}
} else {
return false;
}
} else {
return false;
}
}
public function renewDomain($domain,$domaintype,$period)
{
if ($this->connect()) {
$this->clTRID = microtime();
$query = "<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="urn:iana:xml:ns:epp-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:iana:xml:ns:epp-1.0 epp-1.0.xsd">
<command>
<renew>
<domain:renew xmlns:domain="urn:iana:xml:ns:domain-1.0" xsi:schemaLocation="urn:iana:xml:ns:domain-1.0 domain-1.0.xsd">
<domain:type>".$domaintype."</domain:type>
<domain:name>".$domain."</domain:name>
<domain:period>".$period."</domain:period>
</domain:renew>
</renew>
<unspec/>
<clTRID>".$this->clTRID."</clTRID>
<chksum>".md5($this->user.$this->md5password.$this->clTRID."renewdomain".$domaintype.$domain.$period)."</chksum>
</command>
</epp>
";
if(!socket_write($this->fp, $query, strlen($query))) {
$this->error='renewDomain: Unable to send query';
return false;
} else {
$result = $this->get();
if ($result) {
if ($result[result][0][attributes][code] == "1000") {
return true;
} else {
$this->error = "renewDomain: Code=".$result[result][0][attributes][code]." ".$result[msg][0][value]." (".$result[value][0][value].")";
return false;
}
} else {
$this->error = "renewDomain: Unable to get result";
return false;
}
}
} else {
return false;
}
}
public function getNS($domain,$domaintype)
{
if ($this->connect()) {
$this->clTRID = microtime();
$query = "<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp>
<command>
<getdomaininfo>
<clID>".$this->user."</clID>
<domain>".$domain."</domain>
<domain:type>".$domaintype."</domain:type>
<options>
<version>1.0</version>
<lang>en</lang>
</options>
</getdomaininfo>
<clTRID>".$this->clTRID."</clTRID>
<chksum>".md5($this->user.$this->md5password.$this->clTRID."getdomaininfo")."</chksum>
</command>
</epp>
";
if(!socket_write($this->fp, $query, strlen($query))) {
$this->error='getNS: Unable to send query';
return false;
} else {
$result = $this->get();
if ($result) {
if ($result[result][0][attributes][code] == "1000") {
if ($result[dns1][0][value]) {$resultarray[]=$result[dns1][0][value];}
if ($result[dns2][0][value]) {$resultarray[]=$result[dns2][0][value];}
if ($result[dns3][0][value]) {$resultarray[]=$result[dns3][0][value];}
if ($result[dns4][0][value]) {$resultarray[]=$result[dns4][0][value];}
return $resultarray;
} else {
$this->error = "getNS: Code=".$result[result][0][attributes][code]." ".$result[msg][0][value]." (".$result[value][0][value].")";
return false;
}
} else {
$this->error = "getNS: Unable to get result";
return false;
}
}
} else {
return false;
}
}
public function updateNS($domain,$domaintype,$ns1,$ns2,$ns3,$ns4,$pw)
{
if ($this->connect()) {
$this->clTRID = microtime();
$nsQ = "<domain:ns1>".$ns1."</domain:ns1>
<domain:ns2>".$ns2."</domain:ns2>";
$nsCHK = $ns1.$ns2;
if ($ns3 and $domaintype != "902") { $nsQ = $nsQ."rn <domain:ns3>".$ns3."</domain:ns3>"; $nsCHK = $nsCHK.$ns3; }
if ($ns4 and $domaintype != "902") { $nsQ = $nsQ."rn <domain:ns4>".$ns4."</domain:ns4>"; $nsCHK = $nsCHK.$ns4; }
$query = "<?xml version="1.0" encoding="UTF-8"?>
<epp>
<command>
<update>
<domain:update xmlns:domain="urn:iana:xml:ns:domain-1.0" xsi:schemaLocation="urn:iana:xml:ns:domain-1.0 domain-1.0.xsd">
<domain:type>".$domaintype."</domain:type>
<domain:name>".$domain."</domain:name>
<domain:rep>
".$nsQ."
<domain:authInfo type="pw">".$pw."</domain:authInfo>
</domain:rep>
</domain:update>
</update>
<clTRID>".$this->clTRID."</clTRID>
<chksum>".md5($this->user.$this->md5password.$this->clTRID."upddomain".$domaintype.$domain.$nsCHK.$pw)."</chksum>
</command>
</epp>
";
if(!socket_write($this->fp, $query, strlen($query))) {
$this->error='updateNS: Unable to send query';
return false;
} else {
$result = $this->get();
if ($result) {
if ($result[result][0][attributes][code] == "1000") {
return true;
} else {
$this->error = "updateNS: Code=".$result[result][0][attributes][code]." ".$result[msg][0][value]." (".$result[value][0][value].")";
return false;
}
} else {
$this->error = "updateNS: Unable to get result";
return false;
}
}
} else {
return false;
}
}
public function createNS($domaintype,$ns,$ip)
{
if ($this->connect()) {
$this->clTRID = microtime();
$query = "<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp>
<command>
<create>
<host:create xmlns:host="urn:iana:xml:ns:host-1.0" xsi:schemaLocation="urn:iana:xml:ns:host-1.0 host-1.0.xsd">
<host:domaintype>".$domaintype."</host:domaintype>
<host:name>".$ns."</host:name>
<host:addr ip="v4">".$ip."</host:addr>
</host:create>
</create>
<unspec/>
<clTRID>>".$this->clTRID."</clTRID>
<chksum>".md5($this->user.$this->md5password.$this->clTRID."crthost".$domaintype.$ns.$ip)."</chksum>
</command>
</epp>
";
if(!socket_write($this->fp, $query, strlen($query))) {
$this->error='createNS: Unable to send query';
return false;
} else {
$result = $this->get();
if ($result) {
if ($result[result][0][attributes][code] == "1000") {
return true;
} else {
$this->error = "createNS: Code=".$result[result][0][attributes][code]." ".$result[msg][0][value]." (".$result[value][0][value].")";
return false;
}
} else {
$this->error = "createNS: Unable to get result";
return false;
}
}
} else {
return false;
}
}
public function deleteNS($domaintype,$ns)
{
if ($this->connect()) {
$this->clTRID = microtime();
$query = "<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="urn:iana:xml:ns:epp-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:iana:xml:ns:epp-1.0 epp-1.0.xsd">
<command>
<delete>
<host:delete xmlns:host="urn:iana:xml:ns:host-1.0" xsi:schemaLocation="urn:iana:xml:ns:host-1.0 host-1.0.xsd">
<host:domaintype>".$domaintype."</host:domaintype>
<host:name>".$ns."</host:name>
</host:delete>
</delete>
<unspec/>
<clTRID>".$this->clTRID."</clTRID>
<chksum>".md5($this->user.$this->md5password.$this->clTRID."delhost".$domaintype.$ns)."</chksum>
</command>
</epp>
";
if(!socket_write($this->fp, $query, strlen($query))) {
$this->error='deleteNS: Unable to send query';
return false;
} else {
$result = $this->get();
if ($result) {
if ($result[result][0][attributes][code] == "1000") {
return true;
} else {
$this->error = "deleteNS: Code=".$result[result][0][attributes][code]." ".$result[msg][0][value]." (".$result[value][0][value].")";
return false;
}
} else {
$this->error = "deleteNS: Unable to get result";
return false;
}
}
} else {
return false;
}
}
}
?>