Вход Регистрация
Файл: _rootinc/hosterby.inc.php
Строк: 1530
<?

class HOSTERBY
{
    private 
$timeout 30;
    private 
$debug 0;

    private 
$host null;
    private 
$port null;
    private 
$user null;
    private 
$password null;
    private 
$log null;

    public 
$error null;

    private 
$socket null;
    private 
$answer null;
    private 
$answerArray null;
    private 
$request null;
    private 
$code null;
    private 
$msg null;

    private 
$isConnected false;

    public function 
init($host,$port,$user,$password,$log)
    {
        
$this->host $host;
        
$this->port $port;
        
$this->user $user;
        
$this->password $password;
        
$this->log $log;
    }

    private function 
getFrame() {
        if (
feof($this->socket)) {
            return 
false;
        }
        
$hdr = @fread($this->socket4);
        if (empty(
$hdr)) {
            return 
false;
        } else {
            
$unpacked unpack('N'$hdr);
            if ((
$unpacked[1]) > 8*1024) {
                return 
false;
            }
            
$this->answer fread($this->socket, ($unpacked[1] - 4));

            if (
$this->debug) { print $this->answer."nn"; }

            
$this->slog("n>>> Got Responsen");
            
$this->slog($this->answerMODE_SERVER);

            
$this->answerArray xmlToArrayL($this->answer);

            if (
$this->debug) { print_r($this->answerArray); print "nn"; }

            if (isset(
$this->answerArray['epp']['response']['result_attr']['code'])) {
                
$this->code $this->answerArray['epp']['response']['result_attr']['code'];
            } else {
                
$this->code "";
            }

            if (isset(
$this->answerArray['epp']['response']['result']['msg'])) {
                
$this->msg $this->answerArray['epp']['response']['result']['msg'];
                
$this->msg preg_replace("/%20/"," ",$this->msg);
            } else {
                
$this->msg "";
            }

            return 
true;
        }
    }

    private function 
sendFrame() {
        
$this->slog("n<<< Send Requestn");
        
$this->slog($this->requestMODE_CLIENT);

        if (
$this->debug) { print $this->request."nn"; }

        return @
fwrite($this->socketpack('N', (strlen($this->request)+4)).$this->request);
    }

    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($tmp3"./_rootlogs/".date("Ymd")."_hosterby.log");
                }
            }
        }
    }

    private function 
connect() {
        if (
$this->isConnected) { return true; }

        
$errno ""$errstr "";

        
$target $this->host.':'.$this->port;

        
$this->socket = @stream_socket_client($target$errno$errstr$this->timeout);

        if (!
$this->socket) {
            
$this->error "::: connect: Error connecting to $target: ($errno$errstr"$this->slog($this->error);
            return 
false;
        }

        
$this->isConnected true;

        if (!
$this->getFrame() or !$this->answerArray[epp][greeting][svID]) {
            
$this->error "::: connect: getFrame error"$this->slog($this->error);
            
$this->disconnect();
            return 
false;
        }

        if (!
$this->login()) {
            return 
false;
        }

        return 
true;
    }

    public function 
disconnect() {
        if (
$this->isConnected) {
            @
fclose($this->socket);
            
$this->isConnected false;

            return 
true;
        } else {
            return 
false;
        }
    }

    private function 
login() {

        
$clTRID htmlspecialchars(strtoupper($this->user))."-".time();
        
$this->request = <<<EOF
<?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>
<login>
<clID>
$this->user</clID>
<pw>
$this->password</pw>
<options>
<version>1.0</version>
<lang>en</lang>
</options>
</login>
<clTRID>
$clTRID</clTRID>
</command>
</epp>
EOF;

        if (!
$this->sendFrame()) { $this->error "::: login: sendFrame error"$this->slog($this->error); $this->disconnect(); return false; }
        if (!
$this->getFrame()) { $this->error "::: login: getFrame error"$this->slog($this->error); $this->disconnect(); return false; }

        if (
$this->code != 1000) { $this->error "::: login: $this->code $this->msg"$this->slog($this->error); $this->disconnect(); return false; }

        return 
true;
    }

    public function 
logout() {
        if (!
$this->isConnected) { return false; }

        
$clTRID htmlspecialchars(strtoupper($this->user))."-".time();
        
$this->request = <<<EOF
<?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>
<logout/>
<clTRID>
$clTRID</clTRID>
</command>
</epp>
EOF;

        if (!
$this->sendFrame()) { $this->error "::: logout: sendFrame error"$this->slog($this->error); $this->disconnect(); return false; }
        if (!
$this->getFrame()) { $this->error "::: logout: getFrame error"$this->slog($this->error); $this->disconnect(); return false; }

        
$this->isLogged false;

        
$this->disconnect();

        return 
true;
    }

    public function 
createContact($name$street$city$pc$cc$voice$email$type) {
        if (!
$this->connect()) { return false; }

        
$clTRID htmlspecialchars(strtoupper($this->user))."-".time();
        
$this->request = <<<EOF
<?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:addr>
<contact:street>
$street</contact:street>
<contact:city>
$city</contact:city>
<contact:pc>
$pc</contact:pc>
<contact:cc>
$cc</contact:cc>
</contact:addr>
</contact:postalInfo>
<contact:voice>
$voice</contact:voice>
<contact:email>
$email</contact:email>
</contact:create>
</create>
<extension>
<by-ext-contact:create xmlns:by-ext-contact="http://www.hoster.by/xsd/by-ext-contact-1.0" xsi:schemaLocation="http://www.hoster.by/xsd/by-ext-contact-1.0 by-ext-contact-1.0.xsd">
<by-ext-contact:type>
$type</by-ext-contact:type>
</by-ext-contact:create>
</extension>
<clTRID>
$clTRID</clTRID>
</command>
</epp>
EOF;

        if (!
$this->sendFrame()) { $this->error "::: createContact: sendFrame error"$this->slog($this->error); $this->disconnect(); return false; }
        if (!
$this->getFrame()) { $this->error "::: createContact: getFrame error"$this->slog($this->error); $this->disconnect(); return false; }

        if (
$this->code != 1000) { $this->error "::: createContact: $this->code $this->msg"$this->slog($this->error); $this->logout(); return false; }

        if (isset(
$this->answerArray['epp']['response']['resData']['creData']['id'])) {
            return 
$this->answerArray['epp']['response']['resData']['creData']['id'];
        } else {
            
$this->error "::: createContact: contact id missing"$this->slog($this->error); $this->logout(); return false;
        }
    }

    public function 
updateContact($contactId$name$street$city$pc$cc$voice$email$type) {
        if (!
$this->connect()) { return false; }

        
$clTRID htmlspecialchars(strtoupper($this->user))."-".time();
        
$this->request = <<<EOF
<?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:postalInfo type="loc">
<contact:name>
$name</contact:name>
<contact:addr>
<contact:street>
$street</contact:street>
<contact:city>
$city</contact:city>
<contact:pc>
$pc</contact:pc>
<contact:cc>
$cc</contact:cc>
</contact:addr>
</contact:postalInfo>
<contact:voice>
$voice</contact:voice>
<contact:email>
$email</contact:email>
</contact:update>
</update>
<extension>
<by-ext-contact:update xmlns:by-ext-contact="http://www.hoster.by/xsd/by-ext-contact-1.0" xsi:schemaLocation="http://www.hoster.by/xsd/by-ext-contact-1.0 by-ext-contact-1.0.xsd">
<by-ext-contact:type>
$type</by-ext-contact:type>
</by-ext-contact:update>
</extension>
<clTRID>
$clTRID</clTRID>
</command>
</epp>
EOF;

        if (!
$this->sendFrame()) { $this->error "::: updateContact: sendFrame error"$this->slog($this->error); $this->disconnect(); return false; }
        if (!
$this->getFrame()) { $this->error "::: updateContact: getFrame error"$this->slog($this->error); $this->disconnect(); return false; }

        if (
$this->code != 1000) { $this->error "::: updateContact: $this->code $this->msg"$this->slog($this->error); $this->logout(); return false; }

        return 
true;
    }

    public function 
checkHost($ns) {
        if (!
$this->connect()) { return false; }

        if (
preg_match("/[а-яёЁїЇіІєЄӘәҒғҚқҢңӨөҮүҰұҺһ]/ui",$ns)) {
            
$idna = new idna_convert();
            
$ns $idna->encode($ns);
        }

        
$clTRID htmlspecialchars(strtoupper($this->user))."-".time();
        
$this->request = <<<EOF
<?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>
<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>
$clTRID</clTRID>
</command>
</epp>
EOF;

        if (!
$this->sendFrame()) { $this->error "::: checkHost: sendFrame error"$this->slog($this->error); $this->disconnect(); return false; }
        if (!
$this->getFrame()) { $this->error "::: checkHost: getFrame error"$this->slog($this->error); $this->disconnect(); return false; }

        if (
$this->code != 1000) { $this->error "::: checkHost: $this->code $this->msg"$this->slog($this->error); $this->logout(); return false; }

        
$result["avail"] = $this->answerArray['epp']['response']['resData']['chkData']['cd']['name_attr']['avail'];

        return 
$result;
    }

    public function 
createHost($ns$ip '') {
        if (!
$this->connect()) { return false; }

        if (
preg_match("/[а-яёЁїЇіІєЄӘәҒғҚқҢңӨөҮүҰұҺһ]/ui",$ns)) {
            
$idna = new idna_convert();
            
$ns $idna->encode($ns);
        }

        if (
$ip) { $ip "<host:addr ip="v4">$ip</host:addr>"; }

        
$clTRID htmlspecialchars(strtoupper($this->user))."-".time();
        
$this->request = <<<EOF
<?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>
<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>
$clTRID</clTRID>
</command>
</epp>
EOF;

        if (!
$this->sendFrame()) { $this->error "::: createHost: sendFrame error"$this->slog($this->error); $this->disconnect(); return false; }
        if (!
$this->getFrame()) { $this->error "::: createHost: getFrame error"$this->slog($this->error); $this->disconnect(); return false; }

        if (
$this->code != 1000) { $this->error "::: createHost: $this->code $this->msg"$this->slog($this->error); $this->logout(); return false; }

        return 
true;
    }

    public function 
updateHost($ns$ip) {
        if (!
$this->connect()) { return false; }

        if (
preg_match("/[а-яёЁїЇіІєЄӘәҒғҚқҢңӨөҮүҰұҺһ]/ui",$ns)) {
            
$idna = new idna_convert();
            
$ns $idna->encode($ns);
        }

        
$clTRID htmlspecialchars(strtoupper($this->user))."-".time();
        
$this->request = <<<EOF
<?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>
<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:addr ip="v4">
$ip</host:addr>
</host:update>
</update>
<clTRID>
$clTRID</clTRID>
</command>
</epp>
EOF;

        if (!
$this->sendFrame()) { $this->error "::: updateHost: sendFrame error"$this->slog($this->error); $this->disconnect(); return false; }
        if (!
$this->getFrame()) { $this->error "::: updateHost: getFrame error"$this->slog($this->error); $this->disconnect(); return false; }

        if (
$this->code != 1000) { $this->error "::: updateHost: $this->code $this->msg"$this->slog($this->error); $this->logout(); return false; }

        return 
true;
    }

    public function 
infoIpHost($ns) {
        if (!
$this->connect()) { return false; }

        if (
preg_match("/[а-яёЁїЇіІєЄӘәҒғҚқҢңӨөҮүҰұҺһ]/ui",$ns)) {
            
$idna = new idna_convert();
            
$ns $idna->encode($ns);
        }

        
$clTRID htmlspecialchars(strtoupper($this->user))."-".time();
        
$this->request = <<<EOF
<?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>
<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>
$clTRID</clTRID>
</command>
</epp>
EOF;

        if (!
$this->sendFrame()) { $this->error "::: infoIpHost: sendFrame error"$this->slog($this->error); $this->disconnect(); return false; }
        if (!
$this->getFrame()) { $this->error "::: infoIpHost: getFrame error"$this->slog($this->error); $this->disconnect(); return false; }

        if (
$this->code != 1000) { $this->error "::: infoIpHost: $this->code $this->msg"$this->slog($this->error); $this->logout(); return false; }

        return 
$this->answerArray['epp']['response']['resData']['infData']['addr'];
    }

    public function 
registerDomain($domain$ns1$ns2$ns3$ns4$ns1ip$ns2ip$ns3ip$ns4ip$contactId) {
        if (!
$this->connect()) { return false; }

        if (
preg_match("/[а-яёЁїЇіІєЄӘәҒғҚқҢңӨөҮүҰұҺһ]/ui",$domain)) { $idna = new idna_convert(); $domain $idna->encode($domain); }
        if (
$ns1 and preg_match("/[а-яёЁїЇіІєЄӘәҒғҚқҢңӨөҮүҰұҺһ]/ui",$ns1)) { $idna = new idna_convert(); $ns1 $idna->encode($ns1); }
        if (
$ns2 and preg_match("/[а-яёЁїЇіІєЄӘәҒғҚқҢңӨөҮүҰұҺһ]/ui",$ns2)) { $idna = new idna_convert(); $ns2 $idna->encode($ns2); }
        if (
$ns3 and preg_match("/[а-яёЁїЇіІєЄӘәҒғҚқҢңӨөҮүҰұҺһ]/ui",$ns3)) { $idna = new idna_convert(); $ns3 $idna->encode($ns3); }
        if (
$ns4 and preg_match("/[а-яёЁїЇіІєЄӘәҒғҚқҢңӨөҮүҰұҺһ]/ui",$ns4)) { $idna = new idna_convert(); $ns4 $idna->encode($ns4); }

        if (
$ns1) {
            
$result $this->checkHost($ns1); if (!$result) { return false; }
            if (
$result['avail']) { $this->createHost($ns1$ns1ip); } else if ($ns1ip) { 
                
$hostOldIp $this->infoIpHost($ns1);
                if (!
$hostOldIp) { return false; }
                if (
$hostOldIp != $ns1ip) { $this->updateHost($ns1$ns1ip); }
            }
            if (
$this->error) { return false; }
            
$ns .= "<domain:hostObj>$ns1</domain:hostObj>n";
        }
        if (
$ns2) {
            
$result $this->checkHost($ns2); if (!$result) { return false; }
            if (
$result['avail']) { $this->createHost($ns2$ns2ip); } else if ($ns2ip) { 
                
$hostOldIp $this->infoIpHost($ns2);
                if (!
$hostOldIp) { return false; }
                if (
$hostOldIp != $ns2ip) { $this->updateHost($ns2$ns2ip); }
            }
            if (
$this->error) { return false; }
            
$ns .= "<domain:hostObj>$ns2</domain:hostObj>n";
        }
        if (
$ns3) {
            
$result $this->checkHost($ns3); if (!$result) { return false; }
            if (
$result['avail']) { $this->createHost($ns3$ns3ip); } else if ($ns3ip) { 
                
$hostOldIp $this->infoIpHost($ns3);
                if (!
$hostOldIp) { return false; }
                if (
$hostOldIp != $ns3ip) { $this->updateHost($ns3$ns3ip); }
            }
            if (
$this->error) { return false; }
            
$ns .= "<domain:hostObj>$ns3</domain:hostObj>n";
        }
        if (
$ns4) {
            
$result $this->checkHost($ns4); if (!$result) { return false; }
            if (
$result['avail']) { $this->createHost($ns4$ns4ip); } else if ($ns4ip) { 
                
$hostOldIp $this->infoIpHost($ns4);
                if (!
$hostOldIp) { return false; }
                if (
$hostOldIp != $ns4ip) { $this->updateHost($ns4$ns4ip); }
            }
            if (
$this->error) { return false; }
            
$ns .= "<domain:hostObj>$ns4</domain:hostObj>n";
        }

        
$clTRID htmlspecialchars(strtoupper($this->user))."-".time();
        
$this->request = <<<EOF
<?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>
$ns
</domain:ns>
<domain:registrant>
$contactId</domain:registrant>
<domain:contact type="admin">
$contactId</domain:contact>
</domain:create>
</create>
<clTRID>
$clTRID</clTRID>
</command>
</epp>
EOF;

        if (!
$this->sendFrame()) { $this->error "::: registerDomain: sendFrame error"$this->slog($this->error); $this->disconnect(); return false; }
        if (!
$this->getFrame()) { $this->error "::: registerDomain: getFrame error"$this->slog($this->error); $this->dicsonnect(); return false; }

        if (
$this->code != 1000) { $this->error "::: registerDomain: $this->code $this->msg"$this->slog($this->error); $this->logout(); return false; }

        return 
true;
    }

    public function 
renewDomain($domain) {
        if (!
$this->connect()) { return false; }

        if (
preg_match("/[а-яёЁїЇіІєЄӘәҒғҚқҢңӨөҮүҰұҺһ]/ui",$domain)) { $idna = new idna_convert(); $domain $idna->encode($domain); }
        
$clTRID htmlspecialchars(strtoupper($this->user))."-".time();
        
$this->request = <<<EOF
<?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" xsi:schemaLocation="urn:ietf:params:xml:ns:domain-1.0 domain-1.0.xsd">
<domain:name>
$domain</domain:name>
</domain:renew>
</renew>
<clTRID>
$clTRID</clTRID>
</command>
</epp>
EOF;

        if (!
$this->sendFrame()) { $this->error "::: renewDomain: sendFrame error"$this->slog($this->error); $this->disconnect(); return false; }
        if (!
$this->getFrame()) { $this->error "::: renewDomain: getFrame error"$this->slog($this->error); $this->disconnect(); return false; }

        if (
$this->code != 1000) { $this->error "::: renewDomain: $this->code $this->msg"$this->slog($this->error); $this->logout(); return false; }

        return 
true;
    }

    public function 
infoDomain($domain) {
        if (!
$this->connect()) { return false; }

        if (
preg_match("/[а-яёЁїЇіІєЄӘәҒғҚқҢңӨөҮүҰұҺһ]/ui",$domain)) { $idna = new idna_convert(); $domain $idna->encode($domain); }
        
$clTRID htmlspecialchars(strtoupper($this->user))."-".time();
        
$this->request = <<<EOF
<?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 hosts="all">
$domain</domain:name>
</domain:info>
</info>
<clTRID>
$clTRID</clTRID>
</command>
</epp>
EOF;

        if (!
$this->sendFrame()) { $this->error "::: infoDomain: sendFrame error"$this->slog($this->error); $this->disconnect(); return false; }
        if (!
$this->getFrame()) { $this->error "::: infoDomain: getFrame error"$this->slog($this->error); $this->disconnect(); return false; }

        if (
$this->code != 1000) { $this->error "::: infoDomain: $this->code $this->msg"$this->slog($this->error); $this->logout(); return false; }

        return 
$this->answerArray['epp']['response']['resData']['infData'];
    }

    public function 
getNS($domain) {
        if (!
$this->connect()) { return false; }

        
$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;
        
    }

    public function 
updateNS($domain$ns1$ns2$ns3$ns4$ns1ip$ns2ip$ns3ip$ns4ip) {
        if (!
$this->connect()) { return false; }

        
$oldNSs $this->getNS($domain); 
        if (!
$oldNSs) { return false; }

        
$oldns1 $oldNSs[0]; $oldns2 $oldNSs[1]; $oldns3 $oldNSs[2]; $oldns4 $oldNSs[3];

        if (
preg_match("/[а-яёЁїЇіІєЄӘәҒғҚқҢңӨөҮүҰұҺһ]/ui",$domain)) { $idna = new idna_convert(); $domain $idna->encode($domain); }
        if (
$ns1 and preg_match("/[а-яёЁїЇіІєЄӘәҒғҚқҢңӨөҮүҰұҺһ]/ui",$ns1)) { $idna = new idna_convert(); $domain $idna->encode($ns1); }
        if (
$ns2 and preg_match("/[а-яёЁїЇіІєЄӘәҒғҚқҢңӨөҮүҰұҺһ]/ui",$ns2)) { $idna = new idna_convert(); $domain $idna->encode($ns2); }
        if (
$ns3 and preg_match("/[а-яёЁїЇіІєЄӘәҒғҚқҢңӨөҮүҰұҺһ]/ui",$ns3)) { $idna = new idna_convert(); $domain $idna->encode($ns3); }
        if (
$ns4 and preg_match("/[а-яёЁїЇіІєЄӘәҒғҚқҢңӨөҮүҰұҺһ]/ui",$ns4)) { $idna = new idna_convert(); $domain $idna->encode($ns4); }
        if (
$oldns1 and preg_match("/[а-яёЁїЇіІєЄӘәҒғҚқҢңӨөҮүҰұҺһ]/ui",$oldns1)) { $idna = new idna_convert(); $domain $idna->encode($oldns1); }
        if (
$oldns2 and preg_match("/[а-яёЁїЇіІєЄӘәҒғҚқҢңӨөҮүҰұҺһ]/ui",$oldns2)) { $idna = new idna_convert(); $domain $idna->encode($oldns2); }
        if (
$oldns3 and preg_match("/[а-яёЁїЇіІєЄӘәҒғҚқҢңӨөҮүҰұҺһ]/ui",$oldns3)) { $idna = new idna_convert(); $domain $idna->encode($oldns3); }
        if (
$oldns4 and preg_match("/[а-яёЁїЇіІєЄӘәҒғҚқҢңӨөҮүҰұҺһ]/ui",$oldns4)) { $idna = new idna_convert(); $domain $idna->encode($oldns4); }

        
$nscode ""$nscoderem ""$notRemedNS = array();
        
####################################################################################################################
        
if ($oldns1) { 
            if (
$oldns1 != $ns1 and $oldns1 != $ns2 and $oldns1 != $ns3 and $oldns1 != $ns4) { 
                
$nscoderem $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->updateHost($oldns1$hostNewIp)) { return false; } }
                }
                
$notRemedNS[] = $oldns1
            } 
        }
        if (
$oldns2) { 
            if (
$oldns2 != $ns1 and $oldns2 != $ns2 and $oldns2 != $ns3 and $oldns2 != $ns4) { 
                
$nscoderem $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->updateHost($oldns2$hostNewIp)) { return false; } }
                }
                
$notRemedNS[] = $oldns2
            } 
        }
        if (
$oldns3) { 
            if (
$oldns3 != $ns1 and $oldns3 != $ns2 and $oldns3 != $ns3 and $oldns3 != $ns4) { 
                
$nscoderem $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->updateHost($oldns3$hostNewIp)) { return false; } }
                }
                
$notRemedNS[] = $oldns3
            } 
        }
        if (
$oldns4) { 
            if (
$oldns4 != $ns1 and $oldns4 != $ns2 and $oldns4 != $ns3 and $oldns4 != $ns4) { 
                
$nscoderem $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->updateHost($oldns4$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->checkHost($ns1); if (!$result) { return false; }
            if (
$result['avail']) { $this->createHost($ns1$ns1ip); } else if ($ns1ip) { 
                
$hostOldIp $this->infoIpHost($ns1);
                if (!
$hostOldIp) { return false; }
                if (
$hostOldIp != $ns1ip) { $this->updateHost($ns1$ns1ip); }
            }
            if (
$this->error) { return false; }

            
$nscode $nscode."<domain:hostObj>".$ns1."</domain:hostObj>n"
        }
        if (
$ns2 and !@in_array($ns2,$notRemedNS)) {
            
$result $this->checkHost($ns2); if (!$result) { return false; }
            if (
$result['avail']) { $this->createHost($ns2$ns2ip); } else if ($ns2ip) { 
                
$hostOldIp $this->infoIpHost($ns2);
                if (!
$hostOldIp) { return false; }
                if (
$hostOldIp != $ns2ip) { $this->updateHost($ns2$ns2ip); }
            }
            if (
$this->error) { return false; }

            
$nscode $nscode."<domain:hostObj>".$ns2."</domain:hostObj>n"
        }
        if (
$ns3 and !@in_array($ns3,$notRemedNS)) {
            
$result $this->checkHost($ns3); if (!$result) { return false; }
            if (
$result['avail']) { $this->createHost($ns3$ns3ip); } else if ($ns3ip) { 
                
$hostOldIp $this->infoIpHost($ns3);
                if (!
$hostOldIp) { return false; }
                if (
$hostOldIp != $ns3ip) { $this->updateHost($ns3$ns3ip); }
            }
            if (
$this->error) { return false; }

            
$nscode $nscode."<domain:hostObj>".$ns3."</domain:hostObj>n"
        }
        if (
$ns4 and !@in_array($ns4,$notRemedNS)) {
            
$result $this->checkHost($ns4); if (!$result) { return false; }
            if (
$result['avail']) { $this->createHost($ns4$ns4ip); } else if ($ns4ip) { 
                
$hostOldIp $this->infoIpHost($ns4);
                if (!
$hostOldIp) { return false; }
                if (
$hostOldIp != $ns4ip) { $this->updateHost($ns4$ns4ip); }
            }
            if (
$this->error) { return false; }

            
$nscode $nscode."<domain:hostObj>".$ns4."</domain:hostObj>n"
        }

        if (
$nscode) { $nscode "<domain:add>n<domain:ns>n".$nscode."</domain:ns>n</domain:add>"; }
        
####################################################################################################################

        
$clTRID htmlspecialchars(strtoupper($this->user))."-".time();
        
$this->request = <<<EOF
<?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>
$clTRID</clTRID>
</command>
</epp>
EOF;

        if (!
$this->sendFrame()) { $this->error "::: updateNS: sendFrame error"$this->slog($this->error); $this->disconnect(); return false; }
        if (!
$this->getFrame()) { $this->error "::: updateNS: getFrame error"$this->slog($this->error); $this->disconnect(); return false; }

        if (
$this->code != 1000) { $this->error "::: updateNS: $this->code $this->msg ($this->msgExt)"$this->slog($this->error); $this->logout(); return false; }

        return 
true;
    }

    public function 
updateContactDomain($domain$oldContactId$newContactId) {
        if (!
$this->connect()) { return false; }

        if (
preg_match("/[а-яёЁїЇіІєЄӘәҒғҚқҢңӨөҮүҰұҺһ]/ui",$domain)) { $idna = new idna_convert(); $domain $idna->encode($domain); }
        
$clTRID htmlspecialchars(strtoupper($this->user))."-".time();
        
$this->request = <<<EOF
<?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>
<domain:add>
<domain:contact type="admin">
$newContactId</domain:contact>
</domain:add>
<domain:rem>
<domain:contact type="admin">
$oldContactId</domain:contact>
</domain:rem>
<domain:chg>
<domain:registrant>
$newContactId</domain:registrant>
</domain:chg>
</domain:update>
</update>
<clTRID>
$clTRID</clTRID>
</command>
</epp>
EOF;

        if (!
$this->sendFrame()) { $this->error "::: updateContactDomain: sendFrame error"$this->slog($this->error); $this->disconnect(); return false; }
        if (!
$this->getFrame()) { $this->error "::: updateContactDomain: getFrame error"$this->slog($this->error); $this->disconnect(); return false; }

        if (
$this->code != 1000) { $this->error "::: updateContactDomain: $this->code $this->msg ($this->msgExt)"$this->slog($this->error); $this->logout(); return false; }

        return 
true;
    }

}
?>
Онлайн: 1
Реклама