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

class HOSTMASTEREPP
{
    private 
$timeout = 30;

    private 
$host = null;
    private 
$port = null;
    private 
$user = null;
    private 
$password = null;
    private 
$ssl = 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 
$extmsg = null;

    private 
$isConnected = false;

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

    private function 
getFrame() {
        if (
feof($this->socket)) {
            return 
false;
        }
        
$hdr = @fread($this->socket, 4);
        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));

            
$this->slog("n>>> Got Responsen");
            
$this->slog($this->answer, MODE_SERVER);

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

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

            if (isset(
$this->answerArray['epp']['response']['result']['extValue'][0]['reason'])) {
                
$this->msgExt = "";
                while (list(
$k,$v) = @each($this->answerArray['epp']['response']['result']['extValue'])) {
                    
$this->msgExt .= $v['reason']."; ";
                }
            } else if (isset(
$this->answerArray['epp']['response']['result']['extValue']['reason'])) {
                
$this->msgExt = $this->answerArray['epp']['response']['result']['extValue']['reason'];
            } else {
                
$this->msgExt = "";
            }

            if (isset(
$this->answerArray['epp']['response']['result']['msg'])) {
                
$this->msg = $this->answerArray['epp']['response']['result']['msg'];
            } else {
                
$this->msg = "";
            }

            return 
true;
        }
    }

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

        return @
fwrite($this->socket, pack('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($tmp, 3, "./_rootlogs/".date("Ymd")."_hostmasterepp.log");
                }
            }
        }
    }

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

        
$errno = ""; $errstr = "";

        
$target = 'ssl://'.$this->host.':'.$this->port;

        if (
$this->ssl) {
            
$context = stream_context_create();
            
$result  = stream_context_set_option($context, 'ssl', 'local_cert', $this->ssl);
            
$this->socket = @stream_socket_client($target, $errno, $errstr, $this->timeout, STREAM_CLIENT_CONNECT, $context);
        } else {
            
$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;
    }

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

            return 
true;
        } else {
            return 
false;
        }
    }

    public function 
login() {

        
$clTRID = "DRID-".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">
  <command>
    <login>
      <clID>
$this->user</clID>
      <pw>
$this->password</pw>
      <options>
        <version>1.0</version>
        <lang>en</lang>
      </options>
      <svcs>
        <objURI>http://hostmaster.ua/epp/contact-1.1</objURI>
        <objURI>http://hostmaster.ua/epp/domain-1.1</objURI>
        <objURI>http://hostmaster.ua/epp/host-1.1</objURI>
      </svcs>
    </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->msgExt)"; $this->slog($this->error); $this->disconnect(); return false; }

        return 
true;
    }

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

        
$clTRID = "DRID-".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">
  <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, $org, $street, $city, $sp, $pc, $cc, $voice, $fax, $email, $disclose) {
        if (!
$this->connect()) { return false; }

        
$clTRID = "DRID-".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">
  <command>
    <create>
      <contact:create xmlns:contact="http://hostmaster.ua/epp/contact-1.1">
        <contact:id>autonic</contact:id>
        <contact:postalInfo type="int">
          <contact:name>
$name</contact:name>
          <contact:org>
$org</contact:org>
          <contact:addr>
            <contact:street>
$street</contact:street>
            <contact:city>
$city</contact:city>
            <contact:sp>
$sp</contact:sp>
            <contact:pc>
$pc</contact:pc>
            <contact:cc>
$cc</contact:cc>
          </contact:addr>
        </contact:postalInfo>
        <contact:voice>
$voice</contact:voice>
        <contact:fax>
$fax</contact:fax>
        <contact:email>
$email</contact:email>
        <contact:authInfo>
      <contact:pw/>
        </contact:authInfo>
        <contact:disclose flag="
$disclose">
          <contact:name type="int"/>
          <contact:org type="int"/>
          <contact:addr type="int"/>
          <contact:voice/>
          <contact:fax/>
        </contact:disclose>
      </contact:create>
    </create>
    <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->msgExt)"; $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, $org, $street, $city, $sp, $pc, $cc, $voice, $fax, $email, $disclose) {
        if (!
$this->connect()) { return false; }

        
$clTRID = "DRID-".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">
  <command>
    <update>
      <contact:update xmlns:contact="http://hostmaster.ua/epp/contact-1.1">
        <contact:id>
$contactId</contact:id>
        <contact:chg>
          <contact:postalInfo type="int">
            <contact:name>
$name</contact:name>
            <contact:org>
$org</contact:org>
            <contact:addr>
              <contact:street>
$street</contact:street>
              <contact:city>
$city</contact:city>
              <contact:sp>
$sp</contact:sp>
              <contact:pc>
$pc</contact:pc>
              <contact:cc>
$cc</contact:cc>
            </contact:addr>
          </contact:postalInfo>
          <contact:voice>
$voice</contact:voice>
          <contact:fax>
$fax</contact:fax>
          <contact:email>
$email</contact:email>
          <contact:authInfo>
            <contact:pw/>
          </contact:authInfo>
          <contact:disclose flag="
$disclose">
            <contact:name type="int"/>
            <contact:org type="int"/>
            <contact:addr type="int"/>
            <contact:voice/>
            <contact:fax/>
          </contact:disclose>
        </contact:chg>
      </contact:update>
    </update>
    <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->msgExt)"; $this->slog($this->error); $this->logout(); return false; }

        return 
true;
    }

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

        
$clTRID = "DRID-".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">
  <command>
    <delete>
      <contact:delete xmlns:contact="http://hostmaster.ua/epp/contact-1.1">
        <contact:id>
$contactId</contact:id>
      </contact:delete>
    </delete>
    <clTRID>
$clTRID</clTRID>
  </command>
</epp>
EOF;

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

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

        return 
true;
    }

    public function 
registerDomain($domain, $period, $ns1, $ns2, $ns3, $ns4, $ns1ip, $ns2ip, $ns3ip, $ns4ip, $contactId, $authinfo, $license) {
        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'] or (!$result['avail'] and $result['reason'] == "Parent domain not exists")) {
                if (
$ns1ip) {
                    
$nscode .= "<domain:hostAttr>n<domain:hostName>$ns1</domain:hostName>n<domain:hostAddr ip="v4">$ns1ip</domain:hostAddr>n</domain:hostAttr>n";
                } else {
                    
$nscode .= "<domain:hostAttr>n<domain:hostName>$ns1</domain:hostName>n</domain:hostAttr>n";
                }
            } else if (!
$result['avail'] and $result['reason'] == "Object exists") {
                
$nscode .= "<domain:hostAttr>n<domain:hostName>$ns1</domain:hostName>n</domain:hostAttr>n";
            } else {
                
$this->error = "::: registerDomain: NS1: ".$result['reason']; $this->slog($this->error); $this->logout(); return false;
            }
        }
        if (
$ns2) {
            
$result = $this->checkHost($ns2);
            if (!
$result) { return false; }

            if (
$result['avail'] or (!$result['avail'] and $result['reason'] == "Parent domain not exists")) {
                if (
$ns2ip) {
                    
$nscode .= "<domain:hostAttr>n<domain:hostName>$ns2</domain:hostName>n<domain:hostAddr ip="v4">$ns2ip</domain:hostAddr>n</domain:hostAttr>n";
                } else {
                    
$nscode .= "<domain:hostAttr>n<domain:hostName>$ns2</domain:hostName>n</domain:hostAttr>n";
                }
            } else if (!
$result['avail'] and $result['reason'] == "Object exists") {
                
$nscode .= "<domain:hostAttr>n<domain:hostName>$ns2</domain:hostName>n</domain:hostAttr>n";
            } else {
                
$this->error = "::: registerDomain: NS2: ".$result['reason']; $this->slog($this->error); $this->logout(); return false;
            }
        }
        if (
$ns3) {
            
$result = $this->checkHost($ns3);
            if (!
$result) { return false; }

            if (
$result['avail'] or (!$result['avail'] and $result['reason'] == "Parent domain not exists")) {
                if (
$ns3ip) {
                    
$nscode .= "<domain:hostAttr>n<domain:hostName>$ns3</domain:hostName>n<domain:hostAddr ip="v4">$ns3ip</domain:hostAddr>n</domain:hostAttr>n";
                } else {
                    
$nscode .= "<domain:hostAttr>n<domain:hostName>$ns3</domain:hostName>n</domain:hostAttr>n";
                }
            } else if (!
$result['avail'] and $result['reason'] == "Object exists") {
                
$nscode .= "<domain:hostAttr>n<domain:hostName>$ns3</domain:hostName>n</domain:hostAttr>n";
            } else {
                
$this->error = "::: registerDomain: NS3: ".$result['reason']; $this->slog($this->error); $this->logout(); return false;
            }
        }
        if (
$ns4) {
            
$result = $this->checkHost($ns4);
            if (!
$result) { return false; }

            if (
$result['avail'] or (!$result['avail'] and $result['reason'] == "Parent domain not exists")) {
                if (
$ns4ip) {
                    
$nscode .= "<domain:hostAttr>n<domain:hostName>$ns4</domain:hostName>n<domain:hostAddr ip="v4">$ns4ip</domain:hostAddr>n</domain:hostAttr>n";
                } else {
                    
$nscode .= "<domain:hostAttr>n<domain:hostName>$ns4</domain:hostName>n</domain:hostAttr>n";
                }
            } else if (!
$result['avail'] and $result['reason'] == "Object exists") {
                
$nscode .= "<domain:hostAttr>n<domain:hostName>$ns4</domain:hostName>n</domain:hostAttr>n";
            } else {
                
$this->error = "::: registerDomain: NS4: ".$result['reason']; $this->slog($this->error); $this->logout(); return false;
            }
        }

        if (
$license) { $license = "<domain:license>$license</domain:license>"; }

        
$clTRID = "DRID-".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">
  <command>
    <create>
      <domain:create xmlns:domain="http://hostmaster.ua/epp/domain-1.1">
        <domain:name>
$domain</domain:name>
        <domain:period unit="y">
$period</domain:period>
        <domain:ns>
$nscode
        </domain:ns>
        <domain:registrant>
$contactId</domain:registrant>
        <domain:contact type="admin">
$contactId</domain:contact>
        <domain:contact type="tech">
$contactId</domain:contact>
$license
        <domain:authInfo>
          <domain:pw>
$authinfo</domain:pw>
        </domain:authInfo>
      </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 and $this->code != 1001) { $this->error = "::: registerDomain: $this->code $this->msg ($this->msgExt)"; $this->slog($this->error); $this->logout(); return false; }

        if (
$this->code == 1000) { 
            return 
"ok"; 
        } else { 
            return 
"pending"; 
        }
    }

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

        if (
preg_match("/[а-яёЁїЇіІєЄӘәҒғҚқҢңӨөҮүҰұҺһ]/ui",$domain)) { $idna = new idna_convert(); $domain = $idna->encode($domain); }
        
$clTRID = "DRID-".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">
<command>
<info>
<domain:info xmlns:domain="http://hostmaster.ua/epp/domain-1.1">
<domain:name>
$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->msgExt)"; $this->slog($this->error); $this->logout(); return false; }

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

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

        
$expDate = $this->infoDomain($domain);
        if (!
$expDate) { return false; }

        
$expDate = @mb_split("T", $expDate['exDate']);
        
$expDate = $expDate[0];

        if (
preg_match("/[а-яёЁїЇіІєЄӘәҒғҚқҢңӨөҮүҰұҺһ]/ui",$domain)) { $idna = new idna_convert(); $domain = $idna->encode($domain); }
        
$clTRID = "DRID-".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">
<command>
<renew>
<domain:renew xmlns:domain="http://hostmaster.ua/epp/domain-1.1">
<domain:name>
$domain</domain:name>
<domain:curExpDate>
$expDate</domain:curExpDate>
<domain:period unit="y">
$period</domain:period>
</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 and $this->code != 1001) { $this->error = "::: renewDomain: $this->code $this->msg ($this->msgExt)"; $this->slog($this->error); $this->logout(); return false; }

        return 
true;
    }

    public function 
transferDomain($domain, $period, $auth) {
        if (!
$this->connect()) { return false; }

        if (
preg_match("/[а-яёЁїЇіІєЄӘәҒғҚқҢңӨөҮүҰұҺһ]/ui",$domain)) { $idna = new idna_convert(); $domain = $idna->encode($domain); }
        
$clTRID = "DRID-".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">
  <command>
    <transfer op="request">
      <domain:transfer xmlns:domain="http://hostmaster.ua/epp/domain-1.1">
        <domain:name>
$domain</domain:name>
        <domain:period unit="y">
$period</domain:period>
        <domain:authInfo>
          <domain:pw>
$auth</domain:pw>
        </domain:authInfo>
      </domain:transfer>
    </transfer>
    <clTRID>
$clTRID</clTRID>
  </command>
</epp>
EOF;

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

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

        return 
true;
    }

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

        
$domainRem = "";
        if (!
$oldContactId) {
            
$info = $this->infoDomain($domain);
            if (!
$info) { return false; }

            while (list(
$k,$v) = each($info[contact])) {
                if (!
is_array($v)) {
                    
$idx = $k."_attr";
                    
$domainRem .= "<domain:contact type="".$info[contact][$idx][type]."">$v</domain:contact>n";
                }
            }

        }
        else if (!
is_array($oldContactId)) {
            
$domainRem .= "<domain:contact type="admin">$oldContactId</domain:contact>n<domain:contact type="tech">$oldContactId</domain:contact>n";
        }

        if (
$domainRem) {
            
$domainRem = "<domain:rem>n$domainRem</domain:rem>"; 
        }

        if (
$authinfo) { $authinfo = "<domain:authInfo>n<domain:pw>$authinfo</domain:pw>n</domain:authInfo>n";}

        if (
preg_match("/[а-яёЁїЇіІєЄӘәҒғҚқҢңӨөҮүҰұҺһ]/ui",$domain)) { $idna = new idna_convert(); $domain = $idna->encode($domain); }
        
$clTRID = "DRID-".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">
  <command>
    <update>
      <domain:update xmlns:domain="http://hostmaster.ua/epp/domain-1.1">
        <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>
$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;
    }

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

        if (
preg_match("/[а-яёЁїЇіІєЄӘәҒғҚқҢңӨөҮүҰұҺһ]/ui",$domain)) { $idna = new idna_convert(); $domain = $idna->encode($domain); }
        
$clTRID = "DRID-".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">
  <command>
    <update>
      <domain:update xmlns:domain="http://hostmaster.ua/epp/domain-1.1">
        <domain:name>
$domain</domain:name>
        <domain:chg>
          <domain:authInfo>
        <domain:pw>
$authinfo</domain:pw>
          </domain:authInfo>
        </domain:chg>
      </domain:update>
    </update>
    <clTRID>
$clTRID</clTRID>
  </command>
  </epp>
EOF;

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

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

        return 
true;
    }

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

        if (
preg_match("/[а-яёЁїЇіІєЄӘәҒғҚқҢңӨөҮүҰұҺһ]/ui",$domain)) { $idna = new idna_convert(); $domain = $idna->encode($domain); }
        
$clTRID = "DRID-".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">
  <command>
    <update>
      <domain:update xmlns:domain="http://hostmaster.ua/epp/domain-1.1">
        <domain:name>
$domain</domain:name>
        <domain:add>
          <domain:status s="clientHold"/>
        </domain:add>
      </domain:update>
    </update>
    <clTRID>
$clTRID</clTRID>
  </command>
</epp>
EOF;

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

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

        return 
true;
    }

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

        if (
preg_match("/[а-яёЁїЇіІєЄӘәҒғҚқҢңӨөҮүҰұҺһ]/ui",$domain)) { $idna = new idna_convert(); $domain = $idna->encode($domain); }
        
$clTRID = "DRID-".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">
  <command>
    <update>
      <domain:update xmlns:domain="http://hostmaster.ua/epp/domain-1.1">
        <domain:name>
$domain</domain:name>
        <domain:rem>
          <domain:status s="clientHold"/>
        </domain:rem>
      </domain:update>
    </update>
    <clTRID>
$clTRID</clTRID>
  </command>
</epp>
EOF;

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

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

        return 
true;
    }

    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->updateIpHost($oldns1, $hostOldIp, $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->updateIpHost($oldns2, $hostOldIp, $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->updateIpHost($oldns3, $hostOldIp, $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->updateIpHost($oldns4, $hostOldIp, $hostNewIp)) { return false; } }
                }

                
$notRemedNS[] = $oldns4;
            } 
        }
        if (
$nscoderem) { $nscoderem = "<domain:rem>n<domain:ns>n".$nscoderem."</domain:ns>n</domain:rem>"; }

        
####################################################################################################################
        
if ($ns1 and !@in_array($ns1,$notRemedNS)) {
            
$result = $this->checkHost($ns1);
            if (!
$result) { return false; }

            if (
$result['avail']) {
                if (
$ns1ip) {
                    
$nscode .= "<domain:hostAttr>n<domain:hostName>$ns1</domain:hostName>n<domain:hostAddr ip="v4">$ns1ip</domain:hostAddr>n</domain:hostAttr>n";
                } else {
                    
$nscode .= "<domain:hostAttr>n<domain:hostName>$ns1</domain:hostName>n</domain:hostAttr>n";
                }
            } else if (!
$result['avail'] and $result['reason'] == "Object exists") {
                
$hostOldIp = "";
                if (
$ns1ip) {
                    
$hostOldIp = $this->infoIpHost($ns1);
                    if (!
$hostOldIp) { return false;}
                    if (
$hostOldIp != $ns1ip) { if (!$this->updateIpHost($ns1, $hostOldIp, $ns1ip)) { return false; } }
                }
                
$nscode .= "<domain:hostAttr>n<domain:hostName>$ns1</domain:hostName>n</domain:hostAttr>n";
            } else {
                
$this->error = "::: updateNS: NS1: ".$result['reason']; $this->slog($this->error); $this->logout(); return false;
            }
        }
        if (
$ns2 and !@in_array($ns2,$notRemedNS)) {
            
$result = $this->checkHost($ns2);
            if (!
$result) { return false; }

            if (
$result['avail']) {
                if (
$ns2ip) {
                    
$nscode .= "<domain:hostAttr>n<domain:hostName>$ns2</domain:hostName>n<domain:hostAddr ip="v4">$ns2ip</domain:hostAddr>n</domain:hostAttr>n";
                } else {
                    
$nscode .= "<domain:hostAttr>n<domain:hostName>$ns2</domain:hostName>n</domain:hostAttr>n";
                }
            } else if (!
$result['avail'] and $result['reason'] == "Object exists") {
                
$hostOldIp = "";
                if (
$ns2ip) {
                    
$hostOldIp = $this->infoIpHost($ns2);
                    if (!
$hostOldIp) { return false;}
                    if (
$hostOldIp != $ns2ip) { if (!$this->updateIpHost($ns2, $hostOldIp, $ns2ip)) { return false; } }
                }
                
$nscode .= "<domain:hostAttr>n<domain:hostName>$ns2</domain:hostName>n</domain:hostAttr>n";
            } else {
                
$this->error = "::: updateNS: NS2: ".$result['reason']; $this->slog($this->error); $this->logout(); return false;
            }
        }
        if (
$ns3 and !@in_array($ns3,$notRemedNS)) {
            
$result = $this->checkHost($ns3);
            if (!
$result) { return false; }

            if (
$result['avail']) {
                if (
$ns3ip) {
                    
$nscode .= "<domain:hostAttr>n<domain:hostName>$ns3</domain:hostName>n<domain:hostAddr ip="v4">$ns3ip</domain:hostAddr>n</domain:hostAttr>n";
                } else {
                    
$nscode .= "<domain:hostAttr>n<domain:hostName>$ns3</domain:hostName>n</domain:hostAttr>n";
                }
            } else if (!
$result['avail'] and $result['reason'] == "Object exists") {
                
$hostOldIp = "";
                if (
$ns3ip) {
                    
$hostOldIp = $this->infoIpHost($ns3);
                    if (!
$hostOldIp) { return false;}
                    if (
$hostOldIp != $ns3ip) { if (!$this->updateIpHost($ns3, $hostOldIp, $ns3ip)) { return false; } }
                }
                
$nscode .= "<domain:hostAttr>n<domain:hostName>$ns3</domain:hostName>n</domain:hostAttr>n";
            } else {
                
$this->error = "::: updateNS: NS3: ".$result['reason']; $this->slog($this->error); $this->logout(); return false;
            }
        }
        if (
$ns4 and !@in_array($ns4,$notRemedNS)) {
            
$result = $this->checkHost($ns4);
            if (!
$result) { return false; }

            if (
$result['avail']) {
                if (
$ns4ip) {
                    
$nscode .= "<domain:hostAttr>n<domain:hostName>$ns4</domain:hostName>n<domain:hostAddr ip="v4">$ns4ip</domain:hostAddr>n</domain:hostAttr>n";
                } else {
                    
$nscode .= "<domain:hostAttr>n<domain:hostName>$ns4</domain:hostName>n</domain:hostAttr>n";
                }
            } else if (!
$result['avail'] and $result['reason'] == "Object exists") {
                
$hostOldIp = "";
                if (
$ns4ip) {
                    
$hostOldIp = $this->infoIpHost($ns4);
                    if (!
$hostOldIp) { return false;}
                    if (
$hostOldIp != $ns4ip) { if (!$this->updateIpHost($ns4, $hostOldIp, $ns4ip)) { return false; } }
                }
                
$nscode .= "<domain:hostAttr>n<domain:hostName>$ns4</domain:hostName>n</domain:hostAttr>n";
            } else {
                
$this->error = "::: updateNS: NS2: ".$result['reason']; $this->slog($this->error); $this->logout(); return false;
            }
        }
        if (
$nscode) { $nscode = "<domain:add>n<domain:ns>n".$nscode."</domain:ns>n</domain:add>"; }
        
####################################################################################################################

        
$clTRID = "DRID-".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">
    <command>
      <update>
        <domain:update xmlns:domain="http://hostmaster.ua/epp/domain-1.1">
          <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 and $this->code != 1001) { $this->error = "::: updateNS: $this->code $this->msg ($this->msgExt)"; $this->slog($this->error); $this->logout(); return false; }

        return 
true;
    }

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

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


        
$clTRID = "DRID-".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">
   <command>
     <check>
       <host:check xmlns:host="http://hostmaster.ua/epp/host-1.1">
         <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->msgExt)"; $this->slog($this->error); $this->logout(); return false; }

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

        return 
$result;

    }


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

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


        
$clTRID = "DRID-".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">
  <command>
    <info>
      <host:info xmlns:host="http://hostmaster.ua/epp/host-1.1">
        <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->msgExt)"; $this->slog($this->error); $this->logout(); return false; }

        
$result = $this->answerArray['epp']['response']['resData']['infData']['addr'];

        return 
$result;
    }


    private function 
updateIpHost($ns, $oldIP, $newIP) {
        if (!
$this->connect()) { return false; }

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

        
$clTRID = "DRID-".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">
   <command>
     <update>
       <host:update xmlns:host="http://hostmaster.ua/epp/host-1.1">
         <host:name>
$ns</host:name>
         <host:add>
           <host:addr ip="v4">
$newIP</host:addr>
         </host:add>
         <host:rem>
           <host:addr ip="v4">
$oldIP</host:addr>
         </host:rem>
       </host:update>
     </update>
     <clTRID>
$clTRID</clTRID>
   </command>
 </epp>
EOF;

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

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

        return 
true;
    }

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

        
$clTRID = "DRID-".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">
  <command>
    <delete>
      <host:delete xmlns:host="http://hostmaster.ua/epp/host-1.1">
        <host:name>
$ns</host:name>
      </host:delete>
    </delete>
    <clTRID>
$clTRID</clTRID>
  </command>
</epp>
EOF;

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

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

        return 
true;
    }

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

        
$clTRID = "DRID-".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">
  <command>
    <poll op="req" />
    <clTRID>
$clTRID</clTRID>
  </command>
</epp>
EOF;

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

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

        
$result['msgId'] = $this->answerArray['epp']['response']['msgQ_attr']['id'];
        
$result['msgText'] = $this->answerArray['epp']['response']['msgQ']['msg'];
        
$result['msgCount'] = $this->answerArray['epp']['response']['msgQ_attr']['count'];

        if (
preg_match("/Domain transfer completed/iu",$result['msgText'])) {
            
$result['type'] = "transferApproved";
            
$result['domain'] = $this->answerArray['epp']['response']['resData']['trnData']['name'];

            
$expDate = @mb_split("T", $this->answerArray['epp']['response']['resData']['trnData']['exDate']); $expDate = $expDate[0];
            
$result['exDate'] = $expDate;
        }
        else if (
preg_match("/Domain transfer requested/iu",$result['msgText'])) {
            
$result['type'] = "transferRequest";
            
$result['domain'] = $this->answerArray['epp']['response']['resData']['trnData']['name'];
            
$result['registrator'] = $this->answerArray['epp']['response']['resData']['trnData']['reID'];
        }
        else if (
preg_match("/Domain transfer rejected/iu",$result['msgText'])) {
            
$result['type'] = "transferRequestReject";
            
$result['domain'] = $this->answerArray['epp']['response']['resData']['trnData']['name'];
            
$result['registrator'] = $this->answerArray['epp']['response']['resData']['trnData']['reID'];
        }
        else if (
preg_match("/Domain is pending delete/iu",$result['msgText'])) {
            
$result['type'] = "domainPendingDelete";
            
$result['domain'] = $this->answerArray['epp']['response']['resData']['infData']['name'];
        }
        else if (
preg_match("/Domain is expired/iu",$result['msgText'])) {
            
$result['type'] = "domainExpired";
            
$result['domain'] = $this->answerArray['epp']['response']['resData']['infData']['name'];
        }
        else if (
preg_match("/Domain deleted/iu",$result['msgText'])) {
            
$result['type'] = "domainDeleted";
            
$result['domain'] = $this->answerArray['epp']['response']['resData']['infData']['name'];
        }
        else if (
preg_match("/Domain transfer cancelled/iu",$result['msgText'])) {
            
$result['type'] = "transferCancelled";
            
$result['domain'] = $this->answerArray['epp']['response']['resData']['trnData']['name'];
            
$result['registrator'] = $this->answerArray['epp']['response']['resData']['trnData']['reID'];
        }
        else if (
preg_match("/Contact created/iu",$result['msgText'])) {
            
$result['type'] = "contactCreated";
        }
        else if (
preg_match("/Contact modified/iu",$result['msgText'])) {
            
$result['type'] = "contactModified";
        }
        else if (
preg_match("/Domain created/iu",$result['msgText'])) {
            
$result['type'] = "domainCreated";
            
$result['domain'] = $this->answerArray['epp']['response']['resData']['creData']['name'];
        }
        else if (
preg_match("/Domain modified/iu",$result['msgText'])) {
            
$result['type'] = "domainModified";
            
$result['domain'] = $this->answerArray['epp']['response']['resData']['infData']['name'];
        }
        else if (
preg_match("/automatically renewed/iu",$result['msgText'])) {
            
$result['type'] = "domainAutoRenewed";
            
$result['domain'] = $this->answerArray['epp']['response']['resData']['infData']['name'];
        }
        
$result['xml'] = $this->answer;

        return 
$result;
    }

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

        
$clTRID = "DRID-".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">
  <command>
    <poll op="ack" msgID="
$msgId" />
    <clTRID>
$clTRID</clTRID>
  </command>
</epp>
EOF;

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

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

        return 
true;
    }

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

        if (
preg_match("/[а-яёЁїЇіІєЄӘәҒғҚқҢңӨөҮүҰұҺһ]/ui",$domain)) { $idna = new idna_convert(); $domain = $idna->encode($domain); }
        
$clTRID = "DRID-".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">
  <command>
    <transfer op="approve">
      <domain:transfer xmlns:domain="http://hostmaster.ua/epp/domain-1.1">
        <domain:name>
$domain</domain:name>
      </domain:transfer>
    </transfer>
    <clTRID>
$clTRID</clTRID>
  </command>
</epp>
EOF;

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

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

        return 
true;
    }

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

        if (
preg_match("/[а-яёЁїЇіІєЄӘәҒғҚқҢңӨөҮүҰұҺһ]/ui",$domain)) { $idna = new idna_convert(); $domain = $idna->encode($domain); }
        
$clTRID = "DRID-".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">
  <command>
    <transfer op="reject">
      <domain:transfer xmlns:domain="http://hostmaster.ua/epp/domain-1.1">
        <domain:name>
$domain</domain:name>
      </domain:transfer>
    </transfer>
    <clTRID>
$clTRID</clTRID>
  </command>
</epp>
EOF;

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

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

        return 
true;
    }

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

        if (
preg_match("/[а-яёЁїЇіІєЄӘәҒғҚқҢңӨөҮүҰұҺһ]/ui",$domain)) { $idna = new idna_convert(); $domain = $idna->encode($domain); }
        
$clTRID = "DRID-".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">
  <command>
    <delete>
      <domain:delete xmlns:domain="http://hostmaster.ua/epp/domain-1.1">
        <domain:name>
$domain</domain:name>
      </domain:delete>
    </delete>
    <clTRID>
$clTRID</clTRID>
  </command>
</epp>
EOF;

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

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

        return 
true;
    }

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