Вход Регистрация
Файл: RootPanel 1.7.0 FreeCode/RootPanel 1.7.0 FreeCode/_rootinc/ukrnames.inc.php
Строк: 599
<?

class UKRNAMES
{
    public 
$controller true;
    public 
$url null;
    public 
$port null;
    public 
$user null;
    public 
$password null;
    public 
$error null;
    public 
$fp null;
    public 
$isConnected false;

    public function 
startup(&$controller)
    {
        
$this->controller =& $controller;
    }

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

    public function 
connect()
    {
        
$socket = @fsockopen("ssl://".$this->url$this->port$errno$errstr10);

        if (!
$socket) {
            
$this->error "connect: Error connecting to $this->url$errstr (code $errno)";
            return 
false;
        } else {
            
$this->fp=$socket;
        }

        
$result $this->get();

        if (
$result[epp][0][greeting][0][svID]) {
            if (
$this->login()) {
                
$this->isConnected true;
                return 
true;
            }
            else { 
                return 
false
            }
        } else if (!
$this->error) {
            
$this->error "connect: Unable to get Hello message.";
            return 
false;
        } else {
            
$this->error "connect: ".$this->error;
            return 
false;
        }
    }

    public function 
disconnect()
    {
        if (
$this->isConnected) {
            
$xml "<?xml version="1.0" encoding="UTF-8" standalone="no"?>
            <epp xmlns="
urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchemainstance" xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd">
            
<command>
            <
logout/>
            <
clTRID>".time()."</clTRID>
            </
command>
            </
epp>
            
";

            
$this->send($xml);
            
$this->isConnected = false;
        }
        @fclose(
$this->fp);
    }

    public function get()
    {
        if (@feof(
$this->fp)) {
            
$this->error = "getConnection appears to have closed.";
            return false;
        }

        
$hdr = @fread($this->fp, 4);

        if (empty(
$hdr)) {
            
$this->error = "getError reading from server$php_errormsg";
            return false;
        } else {
            
$unpacked = unpack('N', $hdr);
            
$answer = @fread($this->fp, ($unpacked[1] - 4));

            return xml2array(
$answer);
        }
    }

    public function send(
$xml)
    {
        return @fwrite(
$this->fp, pack('N', (strlen($xml)+4)).$xml);
    }

    public function login()
    {
        
$xml = "<?xml version="1.0" encoding="UTF-8" standalone="no"?>
            <epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchemainstance" xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd">
            <command>
            <login>
            <clID>".$this->user."</clID>
            <pw>".$this->password."</pw>
            <options>
            <version>1.0</version>
            <lang>en</lang>
            </options>
            </login>
            <clTRID>".time()."</clTRID>
            </command>
            </epp>
        ";

        if(!$this->send($xml)) {
            $this->error='login: Unable to send query.'; 
            return false; 
        } else {
            $result = $this->get();

            if (is_array($result)) {
                if ($result[epp][0][response][0][result][0][msg] == "Command completed successfully") {
                    return true;
                } else {
                    $this->error = "login: ".$result[epp][0][response][0][result][0][msg]." (".$result[epp][0][response][0][result][0][value][0]["oxrs:xcp"].")";
                    return false;
                }
            } else if (!$this->error) {
                $this->error = "login: Unable to get result.";
                return false;
            } else {
                $this->error = "login: ".$this->error;
                return false;
            }
        }
    }

    public function createContact($name,$org,$street,$city,$oblast,$post,$country,$phone,$email,$pw)
    {
        if ($this->isConnected or $this->connect()) {
            $xml = "<?xml version="1.0" encoding="UTF-8" standalone="no"?>
                <epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd">
                <command>
                <create>
                <contact:create xmlns:contact="urn:ietf:params:xml:ns:contact-1.0" xsi:schemaLocation="urn:ietf:params:xml:ns:contact-1.0 contact-1.0.xsd">
                <contact:id>AUTO</contact:id>
                <contact:postalInfo type="loc">
                <contact:name>$name</contact:name>
                <contact:org>$org</contact:org>
                <contact:addr>
                    <contact:street>$street</contact:street>
                    <contact:city>$city</contact:city>
                    <contact:sp>$oblast</contact:sp>
                    <contact:pc>$post</contact:pc>
                    <contact:cc>$country</contact:cc>
                </contact:addr>
                </contact:postalInfo>
                <contact:voice>$phone</contact:voice>
                <contact:email>$email</contact:email>
                <contact:authInfo>
                    <contact:pw>$pw</contact:pw>
                </contact:authInfo>
                <contact:disclose flag="0">
                    <contact:voice />
                    <contact:email />
                </contact:disclose>
                </contact:create>
                </create>
                <clTRID>".time()."</clTRID>
                </command>
                </epp>
            ";

            if(!$this->send($xml)) {
                $this->error='createContact: Unable to send query.'; 
                $this->disconnect();
                return false; 
            } else {
                $result = $this->get();

                if (is_array($result)) {
                    if ($result[epp][0][response][0][result][0][msg] == "Command completed successfully" and $result[epp][0][response][0][resData][0]["contact:creData"][0]["contact:id"]) {
                        return $result[epp][0][response][0][resData][0]["contact:creData"][0]["contact:id"];
                    } else {
                        $this->error = "createContact: ".$result[epp][0][response][0][result][0][msg]." (".$result[epp][0][response][0][result][0][value][0]["oxrs:xcp"].")";
                        $this->disconnect();
                        return false;
                    }
                } else if (!$this->error) {
                    $this->error = "createContact: Unable to get result.";
                    $this->disconnect();
                    return false;
                } else {
                    $this->error = "createContact: ".$this->error;
                    $this->disconnect();
                    return false;
                }
            }
        } else {
            $this->disconnect();
            return false;
        }
    }

    public function registerDomain($domain,$ns1,$ns2,$ns3,$ns4,$cRegistrant,$cAdmin,$cTech,$cBilling,$pw)
    {
        if ($this->isConnected or $this->connect()) {
            $nscode = "<domain:hostObj>$ns1</domain:hostObj>n<domain:hostObj>$ns2</domain:hostObj>";
            if ($ns3) { $nscode = $nscode."n<domain:hostObj>$ns3</domain:hostObj>"; }
            if ($ns4) { $nscode = $nscode."n<domain:hostObj>$ns3</domain:hostObj>"; }

            $xml = "<?xml version="1.0" encoding="UTF-8" standalone="no"?>
            <epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd">
            <command>
            <create>
            <domain:create xmlns:domain="urn:ietf:params:xml:ns:domain-1.0" xsi:schemaLocation="urn:ietf:params:xml:ns:domain-1.0 domain-1.0.xsd">
            <domain:name>$domain</domain:name>
            <domain:ns>
            $nscode
            </domain:ns>
            <domain:registrant>$cRegistrant</domain:registrant>
            <domain:contact type="admin">$cAdmin</domain:contact>
            <domain:contact type="tech">$cTech</domain:contact>
            <domain:contact type="billing">$cBilling</domain:contact>
            <domain:authInfo>
            <domain:pw>$pw</domain:pw>
            </domain:authInfo>
            </domain:create>
            </create>
            <clTRID>".time()."</clTRID>
            </command>
            </epp>
            ";

            if(!$this->send($xml)) {
                $this->error='registerDomain: Unable to send query.'; 
                $this->disconnect();
                return false; 
            } else {
                $result = $this->get();

                if (is_array($result)) {
                    if ($result[epp][0][response][0][result][0][msg] == "Command completed successfully") {
                        $this->disconnect();
                        return true;
                    } else {
                        $this->error = "registerDomain: ".$result[epp][0][response][0][result][0][msg]." (".$result[epp][0][response][0][result][0][value][0]["oxrs:xcp"].")";
                        $this->disconnect();
                        return false;
                    }
                } else if (!$this->error) {
                    $this->error = "registerDomain: Unable to get result.";
                    $this->disconnect();
                    return false;
                } else {
                    $this->error = "registerDomain: ".$this->error;
                    $this->disconnect();
                    return false;
                }
            }
        } else {
            $this->disconnect();
            return false;
        }
    }

    public function renewDomain($domain,$period,$expdate)
    {
        if ($this->isConnected or $this->connect()) {
            $xml = "<?xml version="1.0" encoding="UTF-8" standalone="no"?>
                <epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd">
                <command>
                <renew>
                <domain:renew xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
                <domain:name>$domain</domain:name>
                <domain:curExpDate>$expdate</domain:curExpDate>
                <domain:period unit="y">$period</domain:period>
                </domain:renew>
                </renew>
                <clTRID>".time()."</clTRID>
                </command>
                </epp>
            ";

            if(!$this->send($xml)) {
                $this->error='renewDomain: Unable to send query.'; 
                $this->disconnect();
                return false; 
            } else {
                $result = $this->get();

                if (is_array($result)) {
                    if ($result[epp][0][response][0][result][0][msg] == "Command completed successfully") {
                        $this->disconnect();
                        return true;
                    } else {
                        $this->error = "renewDomain: ".$result[epp][0][response][0][result][0][msg]." (".$result[epp][0][response][0][result][0][value][0]["oxrs:xcp"].")";
                        $this->disconnect();
                        return false;
                    }
                } else if (!$this->error) {
                    $this->error = "renewDomain: Unable to get result.";
                    $this->disconnect();
                    return false;
                } else {
                    $this->error = "renewDomain: ".$this->error;
                    $this->disconnect();
                    return false;
                }
            }
        } else {
            $this->disconnect();
            return false;
        }
    }

    public function getNS($domain)
    {
        $d = new domain($domain);
        $result = $d->info();
    
        if (!$d->last_error) {
            $result1 = mb_split("n", $result);
            while (list($index,$res) = each($result1)) {
                if (preg_match("/nserver/ui",$res)) {
                    preg_match("/nserver:s+(.*)/iu",$res,$arr);
                    $resultarray[]=$arr[1];
                } else if (preg_match("/Name Server/ui",$res)) {
                    preg_match("/Name Server:s+(.*)/iu",$res,$arr);
                    $resultarray[]=$arr[1];
                }
            }
            return $resultarray;
        } else {
            $this->error = "getNS: $d->last_error";;
            return false;
        }
    }

    public function updateNS($domain,$ns1,$ns2,$ns3,$ns4)
    {
        $remNS = $this->getNS($domain);
        if (is_array($remNS)) {
            $nscoderem = "<domain:hostObj>".$remNS[0]."</domain:hostObj>n<domain:hostObj>".$remNS[1]."</domain:hostObj>";
            if ($remNS[2]) { $nscoderem = $nscoderem."n<domain:hostObj>".$remNS[2]."</domain:hostObj>"; }
            if ($remNS[3]) { $nscoderem = $nscoderem."n<domain:hostObj>".$remNS[3]."</domain:hostObj>"; }
        } else {
            $this->error = "updateNS: Unable to get current DNS-servers.";
            return false;
        }

        if ($this->isConnected or $this->connect() and !$this->error) {
            $nscode = "<domain:hostObj>$ns1</domain:hostObj>n<domain:hostObj>$ns2</domain:hostObj>";
            if ($ns3) { $nscode = $nscode."n<domain:hostObj>$ns3</domain:hostObj>"; }
            if ($ns4) { $nscode = $nscode."n<domain:hostObj>$ns3</domain:hostObj>"; }

            $xml = "<epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd">
                <command>
                <update>
                <domain:update xmlns:domain="urn:ietf:params:xml:ns:domain-1.0" xsi:schemaLocation="urn:ietf:params:xml:ns:domain-1.0 domain-1.0.xsd">
                <domain:name>$domain</domain:name>
                <domain:add>
                <domain:ns>
                $nscode
                </domain:ns>
                </domain:add>
                <domain:rem>
                <domain:ns>
                $nscoderem
                </domain:ns>
                </domain:rem>
                </domain:update>
                </update>
                <clTRID>".time()."</clTRID>
                </command>
                </epp>
            ";

            if(!$this->send($xml)) {
                $this->error='updateNS: Unable to send query.'; 
                $this->disconnect();
                return false; 
            } else {
                $result = $this->get();

                if (is_array($result)) {
                    if (preg_match("/Command completed successfully/ui", $result[epp][0][response][0][result][0][msg])) {
                        $this->disconnect();
                        return true;
                    } else {
                        $this->error = "updateNS: ".$result[epp][0][response][0][result][0][msg]." (".$result[epp][0][response][0][result][0][value][0]["oxrs:xcp"].")";
                        $this->disconnect();
                        return false;
                    }
                } else if (!$this->error) {
                    $this->error = "updateNS: Unable to get result.";
                    $this->disconnect();
                    return false;
                } else {
                    $this->error = "updateNS: ".$this->error;
                    $this->disconnect();
                    return false;
                }
            }
        } else {
            $this->disconnect();
            return false;
        }
    }
}
?>
Онлайн: 0
Реклама