コード例 #1
0
ファイル: init.php プロジェクト: soar-team/kloxo
function createDnsTemplate()
{
    global $gbl, $sgbl, $login, $ghtml;
    if ($sgbl->dbg < 1) {
        return;
    }
    $ip = getOneIPForLocalhost('something');
    $dnstemp = new DnsTemplate(null, null, 'test');
    $dnstemp->nameserver_f = "ns.lxlabs.com";
    $dnstemp->webipaddress = $ip;
    $dnstemp->mmailipaddress = $ip;
    $dnstemp->parent_clname = $login->getClName();
    $dnstemp->shared = "on";
    $dnstemp->dbaction = 'add';
    $dnstemp->postAdd();
    $dnstemp->was();
    create_default_template($dnstemp);
}
コード例 #2
0
ファイル: remotelib.php プロジェクト: soar-team/kloxo
function do_remote_exec($machine, $rmt, $cmdtype, $nname, $dbaction)
{
    global $gbl, $sgbl, $login, $ghtml;
    $remotechar = $sgbl->__var_remote_char;
    if ($login && $login->isSuperClient()) {
        $table = 'node';
        $class = 'admin';
    } else {
        $table = 'pserver';
        $class = 'slave';
    }
    if (!isLocalhost($machine)) {
        $var = $table . "_password";
        if (isset($gbl->{$var}) && $gbl->{$var}) {
            $password = $gbl->{$var};
        } else {
            $ssm = new Sqlite(null, $table);
            $res = $ssm->rawQuery("select realpass from {$table} where nname = '{$machine}'");
            if ($res) {
                $password = $res[0]['realpass'];
            } else {
                throw new lxException("machine_doesnt_exist_in_db", 'nname', $machine);
            }
        }
    } else {
        $password = getAdminDbPass();
        $machine = 'localhost';
    }
    $port = $sgbl->__var_prog_port;
    $rmt->version = $sgbl->__ver_major_minor_release;
    $rmt->machine = $machine;
    $rmt->remote_login = $class;
    $rmt->password = $password;
    $rmt->master_c = getOneIPForLocalhost($machine);
    $var = base64_encode(serialize($rmt));
    if (!isLocalhost($rmt->machine)) {
        $user = base64_encode('slave');
        $pass = base64_encode($rmt->password);
        $var = $remotechar . "\n" . $user . "\n" . $pass . "\n" . $var;
    }
    $totalout = send_to_some_server($machine, $var);
    $res = unserialize(base64_decode($totalout));
    if (!$res) {
        throw new lxException('could_not_connect_to_server', 'syncserver', $machine);
    }
    //dprint($res->message);
    if ($res->exception) {
        throw $res->exception;
    }
    //dprint($res->message);
    //print_time('server', "remote<b> $raddress</b>: $size KB", 2);
    // We have only return values. The output of the command is discarded. This leads to tremendous savings of bandwidth; makes the communication almost one way. If you want to get the output, you have to use the lxshell_output function and give your command as the argument. This function changes the output as a return value which is then returned back. The whole concept is about function execution, and returning the ret value of the function.
    $err = $res ? 3 : 2;
    dprint("<br>  <table border=2> <tr> <td > Remote: {$machine}, {$cmdtype}, {$nname}, {$dbaction}<br> ", $err);
    if (!$res) {
        dprint("<b> <font color=red>Got Error: </b> </font> {$res}", $err);
        //$ser = base64_decode($res);
        //dprint($ser);
    } else {
        dprint("Message: " . $res->message . "<br> ", $err);
    }
    dprint("</td> </tr> </table>  ", $err);
    if (!$res) {
        dprint("Warning");
    }
    if ($res->__this_warning) {
        $gbl->__this_warning = $res->__this_warning;
    }
    return $res;
}
コード例 #3
0
ファイル: lxclass.php プロジェクト: hypervm-ng/hypervm-ng
 function restoreMeUpThere($oldserver, $backupfilepass)
 {
     $this->setUpdateSubaction('top_level_network_restore');
     $this->createExtraVariables();
     if (isLocalhost($oldserver) && !isLocalhost($this->getDataServer())) {
         $oldserver = getOneIPForLocalhost($this->getDataServer());
     }
     $this->__var_machine = $oldserver;
     $this->__var_backupfilepass = $backupfilepass;
     $res = rl_exec_set(null, $this->getDataServer(), $this);
 }
コード例 #4
0
ファイル: ffilelib.php プロジェクト: lonelywoolf/hypervm
 function updateUpload_s($param)
 {
     global $gbl, $sgbl, $login, $ghtml;
     $this->up_temp_file_name = $_FILES['upload_file_f']['tmp_name'];
     $this->__var_upload_filepass = cp_fileserv($this->up_temp_file_name);
     $this->__var_upload_tmp_server = getOneIPForLocalhost($this->syncserver);
     $this->upload_file_name = $_FILES["upload_file_f"]["name"];
     if (!$this->upload_file_name) {
         throw new lxexception('no_file_in_upload', 'upload_name_f');
     }
     $this->upload_file_name = str_replace("'", "", $this->upload_file_name);
     $this->setUpdateSubaction('upload_s');
     $gbl->__this_redirect = $this->getCurDirUrl();
     $this->upload_overwrite_f = $param['upload_overwrite_f'];
     return null;
 }
コード例 #5
0
ファイル: domainlib.php プロジェクト: zseand/kloxo
 function postAdd()
 {
     global $gbl, $sgbl, $login, $ghtml;
     $gen = $login->getObject('general')->generalmisc_b;
     $parent = $this->getParentO();
     $domdefault = $parent->getObject('domaindefault');
     $web = $this->getObject("web");
     $mmail = $this->getObject('mmail');
     $dns = $this->getObject("dns");
     $web->remove_processed_stats = $domdefault->remove_processed_stats;
     $dname = $this->nname;
     //$dname = self::createUusername($dname);
     $web->ftpusername = substr($dname, 0, 31);
     $gen = $login->getObject('general')->generalmisc_b;
     $web->__var_extrabasedir = $gen->extrabasedir;
     $this->cpstatus = 'on';
     $this->ttype = 'virtual';
     $web->ttype = 'virtual';
     $mmail->ttype = 'virtual';
     if ($this->isClass('subdomain')) {
         $parentdomain = $parent->getFromList('domaina', $this->subdomain_parent);
     }
     if ($this->isOn("simple_add_f") || $this->isClass('subdomain')) {
         if ($this->isClass('subdomain')) {
             $cparent = $parentdomain;
         } else {
             $cparent = $parent;
         }
         $this->template_used = $cparent->template_used;
         $this->resourceplan_used = $cparent->resourceplan_used;
         $this->priv = clone $cparent->priv;
         $this->listpriv = clone $cparent->listpriv;
         $this->disable_per = $cparent->disable_per;
         $this->password = $cparent->password;
         $this->realpass = $cparent->realpass;
         $this->priv->phpfcgiprocess_num = 0;
         $web->priv->phpfcgiprocess_num = 0;
         $this->priv->phpfcgi_flag = 'off';
         $web->priv->phpfcgi_flag = 'off';
     } else {
         $this->realpass = $parent->realpass;
         $this->password = crypt($this->realpass);
         if ($this->isOn('use_resourceplan_f')) {
             $template = getFromAny(array($login, $parent), 'resourceplan', $this->resourceplan_f);
             if (!$template) {
                 throw new lxexception("the_resourceplan_doesnt_exist", 'resourceplan_f', $this->resourceplan_f);
             }
             $this->template_used = $this->resourceplan_f;
             $this->resourceplan_used = $this->resourceplan_f;
             $this->priv = clone $template->priv;
             $this->listpriv = clone $template->listpriv;
             $this->disable_per = $template->disable_per;
             if (!$this->dnstemplate_f) {
                 $list = domainBase::getDnsTemplateList($parent);
                 $this->dnstemplate_f = $list[0];
             }
         }
     }
     if (!$this->docroot) {
         $this->docroot = $this->nname;
     }
     $this->docroot = coreFfile::getRealpath($this->docroot);
     if ($this->isClass('subdomain')) {
         $dnstemplate = $parentdomain->getObject('dns');
     } else {
         $dnstemplate = new Dnstemplate($this->__masterserver, null, $this->dnstemplate_f);
         $dnstemplate->get();
         if ($dnstemplate->dbaction === 'add') {
             throw new lxexception('the_dns_template_doesnt_exist', 'dnstemplate_f', $this->dnstemplate_f);
         }
     }
     //$mmail->catchall = $domaindefault->catchall;
     if (!$mmail->catchall) {
         $mmail->catchall = 'Delete';
     }
     $web->ipaddress = $dnstemplate->getIpForBaseDomain();
     $web->docroot = $this->docroot;
     ///#656 When adding a subdomain, the Document Root field is not being validated
     if (csa($web->docroot, " /")) {
         throw new lxexception("document_root_may_not_contain_spaces", 'docroot', "");
     } else {
         $domain_validation = str_split($web->docroot);
         $domain_validation_num = strlen($web->docroot) - 1;
         if ($domain_validation[$domain_validation_num] == " ") {
             throw new lxexception("document_root_may_not_contain_spaces", 'docroot', "");
         }
     }
     $web->docroot = trim($web->docroot, "/");
     $dns->copyObject($dnstemplate);
     $dns->dbaction = 'add';
     $web->syncserver = $parent->websyncserver;
     $dns->syncserver = implode(",", $parent->dnssyncserver_list);
     $mmail->syncserver = $parent->mmailsyncserver;
     $dns->zone_type = 'master';
     unset($this->cttype);
     if ($this->isClass('subdomain')) {
         $this->dtype = 'subdomain';
     } else {
         $this->dtype = 'maindomain';
     }
     $mmail->fixSyncServer();
     $web->fixSyncServer();
     $dns->fixSyncServer();
     if ($sgbl->dbg < 0) {
         if (getOsForServer($dns->syncserver) === 'windows') {
             throw new lxexception('no_dns_on_windows');
         }
         if (getOsForServer($mmail->syncserver) === 'windows') {
             throw new lxexception('no_mail_on_windows');
         }
     }
     $skelf = "__path_client_root/{$parent->nname}/skeleton.zip";
     if (!lxfile_exists($skelf)) {
         $skelf = "__path_client_root/admin/skeleton.zip";
     }
     //--- for new user-skeleton (since 6.1.7)
     if (!lxfile_exists($skelf)) {
         // MR -- must using \- for zip name
         $skelf = "__path_kloxo_httpd_root/" . "user\\-skeleton.zip";
     }
     if (!lxfile_exists($skelf)) {
         $skelf = "__path_kloxo_httpd_root/skeleton.zip";
     }
     if (!lxfile_exists($skelf)) {
         $skelf = null;
     }
     if ($skelf) {
         $web->__var_skelmachine = getOneIPForLocalhost($web->syncserver);
         $ret = cp_fileserv($skelf);
         $web->__var_skelfile = $ret;
     } else {
         $web->__var_skelfile = null;
     }
     $ftpuser = new Ftpuser(null, $web->syncserver, $web->ftpusername);
     $ftpuser->initThisdef();
     //$uuser = new Uuser(null, $web->syncserver, $dname);
     //$uuser->initThisdef();
     //$web->addObject('uuser', $uuser);
     $ftpuser->directory = $this->docroot;
     $parent->addObject('ftpuser', $ftpuser);
     $ftpuser->username = $parent->username;
     if ($this->getRealClientParentO()->username) {
         $web->username = $this->getRealClientParentO()->username;
     } else {
         $web->username = $this->getRealClientParentO()->nname;
     }
     $rp = $this->getRealClientParentO();
     $web->customer_name = $rp->getPathFromName('nname');
     $mmail->systemuser = $web->username;
     $this->mmailpserver = $mmail->syncserver;
     $this->webpserver = $web->syncserver;
     $this->dnspserver = $dns->syncserver;
     // hack hack convert listpriv into a differnet object.
     $this->generateCMList();
     $this->distributeChildQuota();
     $driverapp = $gbl->getSyncClass($this->__masterserver, $web->syncserver, 'web');
     ////////////////////
     //$uuser->syncserver = $web->syncserver;
     $ftpuser->syncserver = $web->syncserver;
     //$ftpuser->directory =  "/domain/$this->nname";
     //Hack hack uuser needs driver to be redone, since the driver was created when uuser had no syncserver....
     //$uuser->createSyncClass();
     $ftpuser->createSyncClass();
     $web->createSyncClass();
     $mmail->createSyncClass();
     $dns->createSyncClass();
     //$uuser->realpass = $this->realpass;
     //$uuser->password = crypt($this->realpass);
     $ftpuser->realpass = $this->realpass;
     $ftpuser->password = crypt($this->realpass);
     $mmail->remotelocalflag = 'local';
     $web->stats_username = $this->nname;
     $web->stats_password = null;
     // Gotta Add postmaster...
     $mailaccount = new Mailaccount($this->__masterserver, $this->__readserver, "postmaster@{$this->nname}");
     $mailaccount->initThisdef();
     $mailaccount->__parent_o = $mmail;
     $mailaccount->syncserver = $mmail->syncserver;
     $mailaccount->parent_clname = $mmail->getClName();
     $mailaccount->postAdd();
     $mailaccount->cpstatus = 'on';
     $mailaccount->password = $this->password;
     $mailaccount->realpass = $this->realpass;
     //$mailaccount->metadbaction = 'writeonly';
     $mmail->addToList('mailaccount', $mailaccount);
     $spam = new Spam($this->__masterserver, $this->__readserver, $this->nname);
     $spam->initThisdef();
     $res['syncserver'] = $mmail->syncserver;
     $spam->create($res);
     $spam->parent_clname = $mmail->getClName();
     $mmail->addObject('spam', $spam);
     /* Not needed, instead the admin can configure this after the domain is created.
     	if ($maindomain) {
     		$parked = new addondomain(null, null, "{$this->nname}.$maindomain");
     		$parked->initThisdef();
     		$res['mail_flag'] = 'off';
     		$parked->create($res);
     		$parked->parent_clname = $this->getClName();
     		$this->addToList('addondomain', $parked);
     	}
     */
     //$uuser->shellflag = 'off';
     //$uuser->shell = '--Disabled--';
     /*
     	if (exists_in_db($this->__masterserver, "uuser", $uuser->nname)) {
     		throw new lxexception('user_exists_in_db', 'uuser');
     	}
     */
     /*
     $backup = new LxBackup($this->__masterserver, $this->__readserver, $this->getClName());
     $backup->initThisDef();
     $this->AddObject('lxbackup', $backup);
     */
     //lxfile_mkdir("__path_program_home/domain/$this->nname/__backup");
     $this->lxclientpostAdd();
     $this->generateDomainKey(true);
 }
コード例 #6
0
ファイル: vpslib.php プロジェクト: digideskio/hypervm
 function setUpOsTemplateDownloadParam()
 {
     if ($this->isLocalhost()) {
         return;
     }
     if (!lxfile_real($this->getFullPathOstemplate())) {
         return;
     }
     $this->__var_ost_md5 = lmd5_file($this->getFullPathOstemplate());
     $this->__var_ostemplatefileserv = cp_fileserv($this->getFullPathOstemplate());
     $this->__var_masterip = getOneIPForLocalhost($this->syncserver);
 }