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

class RRPPROXY
{
    public 
$url null;
    public 
$user null;
    public 
$password null;
    public 
$error null;

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

    public function 
send($request)
    {
        
$fp curl_init(); 
        
curl_setopt($fpCURLOPT_URL$this->url."?s_login=".$this->user."&s_pw=".$this->password."&".$request);
        
curl_setopt($fpCURL_HTTP_VERSION_1_11);
        
curl_setopt($fpCURLOPT_POST0);
        
curl_setopt($fpCURLOPT_SSL_VERIFYPEER0);
        
curl_setopt($fpCURLOPT_SSL_VERIFYHOST0);
        
curl_setopt($fpCURLOPT_RETURNTRANSFER,1);
        
curl_setopt($fpCURLOPT_TIMEOUT120);

        
$result curl_exec($fp);

        if (@
curl_errno($fp)) {
            
$this->error "cURL Error ".@curl_errno($fp).": ".@curl_error($fp);
            return 
false;
        }

        
curl_close($fp);  

        return 
$this->parseResult($result);
    }

    public function 
parseResult($result)
    {
        
preg_match_all("/([a-zA-Z0-9 []]+) ?= ?(.+)/ui",$result,$arr);
        
$res=array();
        for (
$i=0$i<count($arr[0]); $i++) {
            
$k $arr[1][$i];
            
$k preg_replace("/] ?[/ui","_",$k);
            
$k preg_replace("/[/ui","_",$k);
            
$k preg_replace("/]/ui","",$k);
            
$k trim($k);
            
$k preg_replace("/ /ui","_",$k);

            
$v $arr[2][$i];

            
$res[$k] = $v;
        }

        if (
count($res) > 0) {
            return 
$res;
        } else {
            return 
false;
        }
    }

    public function 
createContact($Firstname,$Middlename,$Lastname,$Organization,$Street,$City,$State,$Zip,$Country,$Phone,$Fax,$Email)
    {
        
$req "command=AddContact&new=1&phone=".urlencode($Phone)."&firstname=".urlencode($Firstname)."&lastname=".urlencode($Lastname)."&street=".urlencode($Street)."&city=".urlencode($City)."&zip=".urlencode($Zip)."&country=".urlencode($Country)."&email=".urlencode($Email)."&middlename=".urlencode($Middlename)."&organization=".urlencode($Organization)."&state=".urlencode($State)."&fax=".urlencode($Fax);
        
$result $this->send($req);

        if (
$result) {
            if (
$result[code] == "200" and $result[property_contact_0]) {
                return 
$result[property_contact_0];
            } else {
                
$this->error "createContact: Code ".$result[code]."; ".$result[description];
            }
        } else {
            
$this->error "createContact: no result or cant parse result";
            return 
false;
        }
    }


    public function 
regDomain($domain,$period,$contactId,$ns1,$ns2,$ns3,$ns4,$promo,$country,$email)
    {
        
$req "command=AddDomain&domain=$domain&period=$period&ownercontact0=$contactId&admincontact0=$contactId&techcontact0=$contactId&billingcontact0=$contactId&nameserver0=$ns1&nameserver1=$ns2&nameserver2=$ns3&nameserver3=$ns4";
        if (
$promo) { $req $req."&X-PROMOTION-CODE=$promo"; }
        if (
preg_match("/.de$/iu",$domain)) { $req $req."&x-de-accept-trustee-tac=0"; }
        if (
preg_match("/.eu$/iu",$domain)) { $req $req."&x-eu-registrant-lang=$country"; }
        if (
preg_match("/.name$/iu",$domain)) { $req $req."&x-name-noemail=1"; }
        if (
preg_match("/.nl$/iu",$domain)) { $req $req."&x-nl-accept-trustee-tac=0"; }
        if (
preg_match("/.us$/iu",$domain)) { $req $req."&x-us-nexus-apppurpose=P3&x-us-nexus-category=C12"; }

        
$result $this->send($req);

        if (
$result) {
            if (
$result[code] == "200") {
                return 
true;
            } else {
                
$this->error "regDomain: Code ".$result[code]."; ".$result[description];
            }
        } else {
            
$this->error "regDomain: no result or cant parse result";
            return 
false;
        }
    }

    public function 
transferDomain($domain,$authinfo)
    {
        
$req "command=TransferDomain&domain=$domain&auth=$authinfo&action=REQUEST";

        
$result $this->send($req);

        if (
$result) {
            if (
$result[code] == "200") {
                return 
true;
            } else {
                
$this->error "transferDomain: Code ".$result[code]."; ".$result[description];
            }
        } else {
            
$this->error "transferDomain: no result or cant parse result";
            return 
false;
        }
    }

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

        
$req "command=RenewDomain&domain=$domain&period=$period&expiration=$expiration";
        if (
$promo) { $req $req."&X-PROMOTION-CODE=$promo"; }

        
$result $this->send($req);

        if (
$result) {
            if (
$result[code] == "200") {
                return 
true;
            } else {
                
$this->error "renewDomain: Code ".$result[code]."; ".$result[description];
            }
        } else {
            
$this->error "renewDomain: no result or cant parse result";
            return 
false;
        }
    }

    public function 
getNS($domain)
    {
        
$req "command=StatusDomain&domain=$domain";
        
$result $this->send($req);

        if (
$result) {
            if (
$result[code] == "200") {
                
$resultArray[] = $result[property_nameserver_0];
                
$resultArray[] = $result[property_nameserver_1];
                
$resultArray[] = $result[property_nameserver_2];
                
$resultArray[] = $result[property_nameserver_3];

                return 
$resultArray;
            } else {
                
$this->error "getNS: Code ".$result[code]."; ".$result[description];
            }
        } else {
            
$this->error "getNS: no result or cant parse result";
            return 
false;
        }
    }

    public function 
getYear($domain)
    {
        
$req "command=StatusDomain&domain=$domain";
        
$result $this->send($req);

        if (
$result) {
            if (
$result[code] == "200") {
                if (
$result[property_registrationexpirationdate_0]) {
                    
$result $result[property_registrationexpirationdate_0];
                } else if (
$result[property_registration_expiration_date_0]) {
                    
$result $result[property_registration_expiration_date_0];
                }

                
$result = @mb_split(" ",$result);
                
$result = @mb_split("-",$result[0]);
                
$result $result[0];

                if (
$result) {
                    return 
$result;
                } else {
                    
$this->error "getYear: Can't parse Year of expiration.";
                }

            } else {
                
$this->error "getYear: Code ".$result[code]."; ".$result[description];
            }
        } else {
            
$this->error "getYear: no result or cant parse result";
            return 
false;
        }
    }

    public function 
updateNS($domain,$ns1,$ns2,$ns3,$ns4)
    {
        
$req "command=ModifyDomain&domain=$domain&nameserver0=$ns1&nameserver1=$ns2&nameserver2=$ns3&nameserver3=$ns4";
        
$result $this->send($req);

        if (
$result) {
            if (
$result[code] == "200") {
                return 
true;
            } else {
                
$this->error "updateNS: Code ".$result[code]."; ".$result[description];
            }
        } else {
            
$this->error "updateNS: no result or cant parse result";
            return 
false;
        }
    }

    public function 
updateContact($contactId,$Firstname,$Middlename,$Lastname,$Organization,$Street,$City,$State,$Zip,$Country,$Phone,$Fax,$Email)
    {
        
$req "command=ModifyContact&contact=$contactId&phone=".urlencode($Phone)."&firstname=".urlencode($Firstname)."&lastname=".urlencode($Lastname)."&street=".urlencode($Street)."&city=".urlencode($City)."&zip=".urlencode($Zip)."&country=".urlencode($Country)."&email=".urlencode($Email)."&middlename=".urlencode($Middlename)."&organization=".urlencode($Organization)."&state=".urlencode($State)."&fax=".urlencode($Fax);
        
$result $this->send($req);

        if (
$result) {
            if (
$result[code] == "200") {
                return 
true;
            } else {
                
$this->error "updateContact: Code ".$result[code]."; ".$result[description];
            }
        } else {
            
$this->error "updateContact: no result or cant parse result";
            return 
false;
        }
    }

    public function 
AddNameserver($ns,$ip)
    {
        
$req "command=AddNameserver&nameserver=$ns&ipaddress0=$ip";
        
$result $this->send($req);

        if (
$result) {
            if (
$result[code] == "200") {
                return 
true;
            } else {
                
$this->error "AddNameserver: Code ".$result[code]."; ".$result[description];
            }
        } else {
            
$this->error "AddNameserver: no result or cant parse result";
            return 
false;
        }
    }

    public function 
DeleteNameserver($ns)
    {
        
$req "command=DeleteNameserver&nameserver=$ns";
        
$result $this->send($req);

        if (
$result) {
            if (
$result[code] == "200") {
                return 
true;
            } else {
                
$this->error "DeleteNameserver: Code ".$result[code]."; ".$result[description];
            }
        } else {
            
$this->error "DeleteNameserver: no result or cant parse result";
            return 
false;
        }
    }

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