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

$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 
$controller true;
    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 
startup(&$controller)
    {
        
$this->controller =& $controller;
    }

    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->fp2))){
                
$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_INETSOCK_STREAMSOL_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$commandstrlen($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$querystrlen($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 = "createContactCode=".$result[result][0][attributes][code]." ".$result[msg][0][value]." (".$result[value][0][value].")";
                    return false;
                }
            } else {
                
$this->error = "createContactUnable to get result";
                return false;
            }
        }

    }

    public function regDomain(
$domain,$period,$ns1,$ns2,$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();

                
$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>
                    <domain:ns1>".strtolower($ns1)."</domain:ns1>
                    <domain:ns2>".strtolower($ns2)."</domain:ns2>
                    <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>
                    <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.strtolower($ns1).strtolower($ns2).$contactId.$contactId.$contactId.$contactId.$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];}

                        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,$pw)
    {
        if ($this->connect()) {
            $this->clTRID = microtime();

            $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>
                <domain:ns1>".strtolower($ns1)."</domain:ns1>
                <domain:ns2>".strtolower($ns2)."</domain:ns2>
                <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.strtolower($ns1).strtolower($ns2).$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;
        }
    }
}
?>
Онлайн: 1
Реклама