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

class HyperVM
{
    public 
$protocol null;
    public 
$host null;
    public 
$user null;
    public 
$password null;
    public 
$error null;

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

    public function 
send($data) {
        if (
$this->protocol == "http")  {$port "8888";}
        else if (
$this->protocol == "https")  {$port "8887";}

        
$fp curl_init(); 
        
curl_setopt($fpCURLOPT_URL$this->protocol."://".$this->host.":".$port."/".$data);
        
curl_setopt($fpCURLOPT_SSL_VERIFYPEER0);
        
curl_setopt($fpCURLOPT_SSL_VERIFYHOST0);
        
curl_setopt($fpCURLOPT_FAILONERROR0); 
        
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 
$result;
    }

    public function 
createServer($login,$password,$hostname,$tarif,$os,$email,$ipnum,$ip,$servername,$servertype) {
        if (
preg_match("/[а-яёЁїЇіІєЄӘәҒғҚқҢңӨөҮүҰұҺһ]/ui",$hostname)) {
            
$idna = new idna_convert();
            
$hostname $idna->encode($hostname);
        }

        
$result $this->send("webcommand.php?login-class=client&login-name=".$this->user."&login-password=".$this->password."&action=add&v-plan_name=$tarif&v-ostemplate=$os&class=vps&name=$login&v-type=$servertype&v-contactemail=$email&v-send_welcome_f=off&v-syncserver=$servername&v-password=$password&v-one_ipaddress_f=$ip&v-num_ipaddress_f=$ipnum&v-hostname=$hostname");

        if (
preg_match("/__success_add_successful/i",$result)) {
            return 
true;
        } else {
            
$this->error "createServer: ".$result;
            return 
false;
        }
    }

    public function 
disableServer($login) {

        
$result $this->send("webcommand.php?login-class=client&login-name=".$this->user."&login-password=".$this->password."&class=vps&action=update&subaction=disable&name=$login");

        if (
preg_match("/__success_update_successful/i",$result)) {
            return 
true;
        } else {
            
$this->error "disableServer: ".$result;
            return 
false;
        }
    }

    public function 
enableServer($login) {

        
$result $this->send("webcommand.php?login-class=client&login-name=".$this->user."&login-password=".$this->password."&class=vps&action=update&subaction=enable&name=$login");

        if (
preg_match("/__success_update_successful/i",$result)) {
            return 
true;
        } else {
            
$this->error "enableServer: ".$result;
            return 
false;
        }
    }

    public function 
deleteServer($login) {

        
$result $this->send("webcommand.php?login-class=client&login-name=".$this->user."&login-password=".$this->password."&class=vps&action=delete&name=$login");

        if (
preg_match("/__success_delete_successful/i",$result)) {
            return 
true;
        } else {
            
$this->error "deleteServer: ".$result;
            return 
false;
        }
    }

    public function 
changePackage($login,$tarif) {

        
$result $this->send("webcommand.php?login-class=client&login-name=".$this->user."&login-password=".$this->password."&class=vps&action=update&subaction=change_plan&name=$login&v-newresourceplan=$tarif");

        if (
preg_match("/__success_update_successful/i",$result)) {
            return 
true;
        } else {
            
$this->error "changePackage: ".$result;
            return 
false;
        }
    }

    public function 
restartServer($login) {

        
$result $this->send("webcommand.php?login-class=client&login-name=".$this->user."&login-password=".$this->password."&class=vps&action=update&subaction=reboot&name=$login");

        if (
preg_match("/__success_update_successful/i",$result)) {
            return 
true;
        } else {
            
$this->error "restartServer: ".$result;
            return 
false;
        }
    }

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