예제 #1
0
function security_blanket_main()
{
    global $argv;
    //sleep(100);
    $rem = unserialize(lfile_get_contents($argv[1]));
    unlink($argv[1]);
    if (!$rem) {
        exit;
    }
    // Merged from 6.1.x/kloxo/bin/common/securityblanket.php	(revision 472)
    // workaround for the following php bug:
    //   http://bugs.php.net/bug.php?id=47948
    //   http://bugs.php.net/bug.php?id=51329
    if (is_array($rem->func) && count($rem->func) > 0) {
        $class = $rem->func[0];
        class_exists($class);
    }
    // ---
    call_user_func_array($rem->func, $rem->arglist);
    $sq = new Sqlite(null, $rem->table);
    $res = $sq->getRowsWhere("nname = '{$rem->nname}'", array($rem->flagvariable));
    if ($res[0][$rem->flagvariable] === 'doing') {
        $sq->rawQuery("update {$rem->table} set {$rem->flagvariable} = 'Program Got aborted in the midst. Please try again.' where nname = '{$rem->nname}'");
    }
}
예제 #2
0
 function updateRemove($param)
 {
     if_demo_throw_exception();
     $server = $this->syncserver;
     $sq = new Sqlite(null, "lxguardhit");
     foreach ($param['_accountselect'] as $ip) {
         $sq->rawQuery("delete from lxguardhit where syncserver = '{$server}' AND ipaddress = '{$ip}'");
     }
     self::save_current_hitlist($server);
 }
예제 #3
0
function driverload_main()
{
    global $argv, $gbl, $sgbl, $login, $ghtml;
    initProgram('admin');
    $p = parse_opt($argv);
    if (isset($p['clear-existing'])) {
        $sq = new Sqlite(null, "driver");
        $sq->rawQuery("delete from driver");
    }
    $list = $login->getList('pserver');
    foreach ($list as $l) {
        $l->getandWriteModuleDriver();
    }
}
예제 #4
0
function database_main()
{
    global $argc, $argv;
    global $gbl, $login, $ghtml;
    initProgram('admin');
    if ($argv[1] == 'exec') {
        $db = new Sqlite(null, 'client');
        $res = $db->rawQuery($argv[2]);
        foreach ($res as &$r) {
            foreach ($r as $k => &$__r) {
                if (csb($k, "ser_")) {
                    $__r = unserialize(base64_decode($__r));
                }
            }
        }
        print_r($res);
        exit;
    }
}
예제 #5
0
if (isset($list['day'])) {
    $day = $list['day'];
} else {
    print "Day not set... Defaulting to {$day}\n";
}
$oldtime = time() - $day * 24 * 3600;
$sq = new Sqlite(null, "{$class}traffic");
$res = $sq->getTable();
foreach ($res as $r) {
    if (!csa($r['nname'], ":")) {
        continue;
    }
    $t = explode(":", $r['nname']);
    $ot = $t[1];
    if ($ot > $oldtime) {
        print "deleting {$oldtime} {$r['nname']}\n";
        $sq->rawQuery("delete from {$class}traffic where nname = '{$r['nname']}'");
    } else {
        //print("not deleting $oldtime {$r['nname']}\n");
    }
}
$c = "{$class}traffic";
$laccess = new $c(null, null, '__last_access_domain_');
$laccess->get();
if ($laccess->timestamp > $oldtime) {
    $laccess->timestamp = $oldtime;
    $laccess->setUpdateSubaction();
    $laccess->write();
}
system("lphp.exe ../bin/gettraffic.php");
system("lphp.exe ../bin/collectquota.php");
예제 #6
0
function write_to_object($object, $message, $syncserver)
{
    $sq = new Sqlite(null, $object->get__table());
    $sq->rawQuery("update {$object->get__table()} set olddeleteflag = 'Switch to {$syncserver} failed due to {$message}' where nname = '{$object->nname}'");
}
예제 #7
0
 static function addToTmpIpAssign($l)
 {
     $sq = new Sqlite(null, 'tmpipassign');
     $date = time();
     $sq->rawQuery("insert into tmpipassign (nname, ddate) values ('{$l}', '{$date}');");
 }
예제 #8
0
<?php

include_once "htmllib/lib/include.php";
initProgram('admin');
$list = $login->getList('ippool');
$sq = new Sqlite(null, 'tmpipassign');
$res = $sq->getTable();
foreach ($res as $r) {
    if (!ippool::checkIfAlreadyAssigned('vps', $r['nname'])) {
        $sq->rawQuery("delete from tmpipassign where nname = '{$r['nname']}';");
        continue;
    }
    if (time() - $r['ddate'] > 40) {
        $sq->rawQuery("delete from tmpipassign where nname = '{$r['nname']}';");
    }
}
foreach ($list as $l) {
    $l->freeflag = 'on';
    $fip = $l->getFreeIp(10000);
    if ($fip) {
        $l->freeflag = 'on';
    } else {
        $l->freeflag = 'dull';
    }
    $l->setUpdateSubaction();
    $l->write();
}
예제 #9
0
<?php 
} elseif ($cgi_forgotpwd == 2) {
    $progname = $sgbl->__var_program_name;
    $cprogname = ucfirst($progname);
    $cgi_clientname = $ghtml->frm_clientname;
    $cgi_email = $ghtml->frm_email;
    htmllib::checkForScript($cgi_clientname);
    $classname = $ghtml->frm_class;
    if (!$classname) {
        $classname = getClassFromName($cgi_clientname);
    }
    if (!empty($cgi_clientname) && !empty($cgi_email)) {
        $tablename = $classname;
        $database = new Sqlite(null, $tablename);
        $data = $database->rawQuery("select contactemail from {$tablename} where nname = '{$cgi_clientname}';");
        if (empty($data)) {
            $ghtml->print_redirect("/login/?frm_emessage=nouser_email");
            //throw lxException('Contact email is not set on Kloxo, it could not be send to a empty address.');
        } elseif (!isset($data[0]['contactemail'])) {
            $ghtml->print_redirect("/login/?frm_emessage=nouser_email");
            //throw lxException('Contact email is not set on Kloxo, it could not be send to a empty address.');
        } else {
            $contact_email = $data[0]['contactemail'];
            if (empty($contact_email)) {
                //throw lxException('Contact email is not set on Kloxo, it could not be send to a empty address.');
                $ghtml->print_redirect("/login/?frm_emessage=nouser_email");
            }
        }
        if ($cgi_email == $contact_email) {
            $rndstring = randomString(8);
예제 #10
0
<?php

include "htmllib/lib/include.php";
$db = new Sqlite(null, $argv[1]);
$res = $db->getTable();
$class = $argv[1];
foreach ($res as $r) {
    if (isset($stored[$r['nname']])) {
        print "duplicate found {$r['nname']}\n";
        $db->rawQuery("delete from {$class} where nname = '{$r['nname']}'");
        $ob = new $class(null, null, $r['nname']);
        $ob->create($r);
        $ob->write();
        continue;
    }
    $stored[$r['nname']] = $r;
}
예제 #11
0
 static function add($parent, $class, $param)
 {
     global $gbl, $sgbl, $login, $ghtml;
     if (if_demo()) {
         throw new lxException("demo", $v);
     }
     lxclient::fixpserver_list($param);
     $param['nname'] = strtolower($param['nname']);
     if (!cse($param['nname'], ".vm")) {
         $param['nname'] .= ".vm";
     }
     if (csa($param['nname'], '-')) {
         throw new lxexception('name_cannot_contain_dash', 'nname', '');
     }
     if (csa($param['nname'], ' ')) {
         throw new lxexception('name_cannot_contain_space', 'nname', '');
     }
     // the uuser is two steps removed from the main object (domain), and thus the automatic nname creation doesn't seem to work. So we have to do it here.
     $param['realpass'] = $param['password'];
     $param['password'] = crypt($param['password']);
     $total = db_get_value("pserver", $param['syncserver'], "max_vps_num");
     if ($total) {
         $sq = new Sqlite(null, 'vps');
         $countres = $sq->rawQuery("select count(*) from vps where syncserver = '{$param['syncserver']}'");
         $countres = $countres[0]['count(*)'];
         if ($countres >= $total) {
             throw new lxexception('vps_per_server_exceeded', 'syncserver', "{$countres} > {$total}");
         }
     }
     return $param;
 }
예제 #12
0
    exit;
}
//dprintr($nlist);
foreach ($res as $r) {
    if ($slave) {
        if ($r['syncserver'] !== $slave) {
            continue;
        }
    } else {
        if (!csa($r['nname'], "openvz")) {
            print "Not imported ... Skipping\n";
            continue;
        }
    }
    print "Fixing {$r['nname']} ..\n";
    print_r($nlist[$r['vpsid']]);
    print "\n";
    if (!isset($nlist[$r['vpsid']])) {
        print "No Data entry for {$r['vpsid']} {$r['nname']}\n";
        continue;
    }
    $l = $nlist[$r['vpsid']];
    $newname = $l['nname'];
    $contact = $l['contactemail'];
    $password = $l['password'];
    $rootpassword = $l['rootpassword'];
    $sq->rawQuery("update vps set nname = '{$newname}' where nname = '{$r['nname']}'");
    $sq->rawQuery("update vps set contactemail = '{$contact}' where nname = '{$r['nname']}'");
    $sq->rawQuery("update vps set password = '******' where nname = '{$r['nname']}'");
    $sq->rawQuery("update vps set rootpassword = '******' where nname = '{$r['nname']}'");
}
예제 #13
0
파일: lib.php 프로젝트: zseand/kloxo
function getTabledetails($tbl_name)
{
    dprint("table. values are ..........\n");
    $db = new Sqlite($tbl_name);
    $res = $db->rawQuery("select * from " . $tbl_name);
    print_r($res);
}
예제 #14
0
<?php

include_once "htmllib/lib/include.php";
initProgram('admin');
if (!$sgbl->isHyperVM()) {
    print "Only implemented for hyperVM\n";
    exit;
}
$oslave = $argv[1];
$nslave = $argv[2];
if (!$nslave) {
    print "Usage: change-slave-name old-slave-id new-slave-id\n";
    exit;
}
$sq = new Sqlite(null, "pserver");
$r = $sq->getRowsWhere("nname = '{$oslave}'");
if (!$r) {
    print "No slave as {$oslave}\n";
    exit;
}
$r = $sq->getRowsWhere("nname = '{$nslave}'");
if ($r) {
    print "slave {$nslave} already exists\n";
    exit;
}
$sq->rawQuery("update driver set nname = '{$nslave}' where nname = '{$oslave}'");
$sq->rawQuery("update vps set syncserver = '{$nslave}' where syncserver = '{$oslave}'");
$sq->rawQuery("update pserver set syncserver = '{$nslave}' where nname = '{$oslave}'");
$sq->rawQuery("update pserver set nname = '{$nslave}' where nname = '{$oslave}'");
$sq->rawQuery("update dirlocation set nname = '{$nslave}' where nname = '{$oslave}'");
$sq->rawQuery("update ipaddress set syncserver = '{$nslave}' where syncserver = '{$oslave}'");
예제 #15
0
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;
}
예제 #16
0
<?php

include_once "htmllib/lib/include.php";
$sq = new Sqlite(null, 'general');
$sq->rawQuery("update general set disable_admin = 'off' where nname = 'admin'");
예제 #17
0
 static function createHitList($server)
 {
     $sq = new Sqlite(null, "lxguardhit");
     $res = $sq->rawQuery("SELECT ipaddress, access, count(*) FROM lxguardhit WHERE syncserver = '{$server}' GROUP BY ipaddress, access");
     foreach ($res as $r) {
         $total[$r['ipaddress']][$r['access']] = $r['count(*)'];
     }
     foreach ($total as $k => $t) {
         $res['nname'] = $k;
         $res['currentip_flag'] = 'null';
         if (isset($_SERVER['REMOTE_ADDR']) && $k === $_SERVER['REMOTE_ADDR']) {
             $res['currentip_flag'] = 'on';
         }
         $res['ipaddress'] = $k;
         $res['failcount'] = isset($t['fail']) ? $t['fail'] : 0;
         $res['successcount'] = isset($t['success']) ? $t['success'] : 0;
         $ret[] = $res;
     }
     return $ret;
 }
예제 #18
0
<?php

include_once "htmllib/lib/include.php";
$sq = new Sqlite(null, 'vps');
$sq->rawQuery("update vps set lxadmin_flag = 'off'");
예제 #19
0
 function getLastLogin(&$ilist)
 {
     $sq = new Sqlite(null, 'utmp');
     $res = $sq->rawQuery("select * from utmp where parent_clname = '{$this->getClName()}' order by (logintime + 0) DESC limit 2");
     //if (!$res) { return "Not Logged"; }
     if (!isset($res[1])) {
         return;
     }
     $url = "a=list&c=utmp";
     $ilist['Last Login'] = "******";
     $date = @date('h.i,d-M-Y', $res[1]['logintime']);
     $ilist['Last Login Time'] = "_lxinurl:{$url}:{$date}:";
 }
예제 #20
0
<?php

include_once "htmllib/lib/include.php";
initProgram('admin');
$sq = new Sqlite(null, 'ftpuser');
$list = $sq->getRowsWhere("realpass = ''");
if (!$list) {
    exit;
}
foreach ($list as $l) {
    if ($l['realpass']) {
        continue;
    }
    print "setting pass for {$l['nname']}\n";
    $name = $l['nname'];
    $pass = randomString(8);
    $sq->rawQuery("update ftpuser set realpass = '******' where nname = '{$name}'");
    lxshell_input("{$pass}\n{$pass}\n", "pure-pw", "passwd", $name, "-m");
}
예제 #21
0
<?php

include_once "htmllib/lib/include.php";
initProgram('admin');
$list = parse_opt($argv);
if (isset($list['oldmaster'])) {
    $oldmaster = $list['oldmaster'];
} else {
    print "Usage: {$argv['0']} --oldmaster=old-master-slave-id\n";
    exit;
}
$sq = new Sqlite(null, 'vps');
$res = $sq->rawQuery("select * from pserver where nname = '{$oldmaster}'");
if (!$res) {
    print "Old Master is not present as a slave\n";
    exit;
}
$sq->rawQuery("update vps set syncserver = '{$oldmaster}' where syncserver = 'localhost'");
print "Converted all the vpses from localhost to {$oldmaster}\n";
예제 #22
0
파일: updatelib.php 프로젝트: zseand/kloxo
function fixDataBaseIssues()
{
    log_cleanup("Fix Database Issues");
    log_cleanup("- Fix admin account database settings");
    $sq = new Sqlite(null, 'domain');
    $sq->rawQuery("update domain set priv_q_php_flag = 'on'");
    $sq->rawQuery("update web set priv_q_php_flag = 'on'");
    $sq->rawQuery("update client set priv_q_php_flag = 'on'");
    $sq->rawQuery("update client set priv_q_addondomain_num = 'Unlimited' where nname = 'admin'");
    $sq->rawQuery("update client set priv_q_rubyrails_num = 'Unlimited' where nname = 'admin'");
    $sq->rawQuery("update client set priv_q_rubyfcgiprocess_num = 'Unlimited' where nname = 'admin'");
    $sq->rawQuery("update client set priv_q_mysqldb_usage = 'Unlimited' where nname = 'admin'");
    $sq->rawQuery("update client set priv_q_phpfcgi_flag = 'on' where nname = 'admin'");
    $sq->rawQuery("update client set priv_q_phpfcgiprocess_num = 'Unlimited' where nname = 'admin'");
    $sq->rawQuery("update client set priv_q_subdomain_num = 'Unlimited' where nname = 'admin'");
    $sq->rawQuery("update client set priv_q_totaldisk_usage = 'Unlimited' where nname = 'admin'");
    $sq->rawQuery("update client set priv_q_php_manage_flag = 'on' where nname = 'admin'");
    $sq->rawQuery("update client set priv_q_installapp_flag = 'on' where nname = 'admin'");
    $sq->rawQuery("update client set priv_q_cron_minute_flag = 'on' where nname = 'admin'");
    $sq->rawQuery("update client set priv_q_document_root_flag = 'on' where nname = 'admin'");
    $sq->rawQuery("update client set priv_q_runstats_flag = 'on' where nname = 'admin'");
    $sq->rawQuery("update client set priv_q_webhosting_flag = 'on' where nname = 'admin'");
    $sq->rawQuery("update ticket set parent_clname = 'client-admin' where subject = 'Welcome to Kloxo'");
    $sq->rawQuery("update domain set dtype = 'maindomain' where dtype = 'domain'");
    log_cleanup("- Set default database settings");
    db_set_default('mmail', 'remotelocalflag', 'local');
    db_set_default('mmail', 'syncserver', 'localhost');
    db_set_default('dns', 'syncserver', 'localhost');
    db_set_default('pserver', 'coma_psrole_a', ',web,dns,mmail,mysqldb,');
    db_set_default('web', 'syncserver', 'localhost');
    db_set_default('uuser', 'syncserver', 'localhost');
    db_set_default('client', 'syncserver', 'localhost');
    db_set_default('addondomain', 'mail_flag', 'on');
    db_set_default('client', 'priv_q_can_change_limit_flag', 'on');
    db_set_default('web', 'priv_q_installapp_flag', 'on');
    db_set_default('client', 'priv_q_installapp_flag', 'on');
    db_set_default('client', 'websyncserver', 'localhost');
    db_set_default('client', 'mmailsyncserver', 'localhost');
    db_set_default('client', 'mysqldbsyncserver', 'localhost');
    db_set_default('client', 'priv_q_can_change_password_flag', 'on');
    db_set_default('client', 'coma_dnssyncserver_list', ',localhost,');
    db_set_default('domain', 'priv_q_installapp_flag', 'on');
    db_set_default('domain', 'dtype', 'domain');
    db_set_default('domain', 'priv_q_php_manage_flag', 'on');
    db_set_default('web', 'priv_q_php_manage_flag', 'on');
    db_set_default('client', 'priv_q_php_manage_flag', 'on');
    db_set_default('client', 'priv_q_webhosting_flag', 'on');
    db_set_default_variable_diskusage('client', 'priv_q_totaldisk_usage', 'priv_q_disk_usage');
    db_set_default_variable_diskusage('domain', 'priv_q_totaldisk_usage', 'priv_q_disk_usage');
    db_set_default_variable('web', 'docroot', 'nname');
    db_set_default_variable('client', 'used_q_maindomain_num', 'used_q_domain_num');
    db_set_default_variable('client', 'priv_q_maindomain_num', 'priv_q_domain_num');
    db_set_default("servermail", "domainkey_flag", "on");
    log_cleanup("- Fix resourceplan settings in database");
    migrateResourceplan('domain');
    $sq->rawQuery("update resourceplan set realname = nname where realname = ''");
    $sq->rawQuery("update resourceplan set realname = nname where realname is null");
    lxshell_php("../bin/common/fixresourceplan.php");
    log_cleanup("- Alter some database tables to fit that of Kloxo");
    // TODO: Check if this is still longer needed!
    $sq->rawQuery("alter table sslcert change text_ca_content text_ca_content longtext");
    $sq->rawQuery("alter table sslcert change text_key_content text_key_content longtext");
    $sq->rawQuery("alter table sslcert change text_csr_content text_csr_content longtext");
    $sq->rawQuery("alter table sslcert change text_crt_content text_crt_content longtext");
    $sq->rawQuery("alter table mailaccount change ser_forward_a ser_forward_a longtext");
    $sq->rawQuery("alter table dns change ser_dns_record_a ser_dns_record_a longtext");
    $sq->rawQuery("alter table installsoft change ser_installappmisc_b ser_installappmisc_b longtext");
    $sq->rawQuery("alter table web change ser_redirect_a ser_redirect_a longtext");
    log_cleanup("- Set default welcome text at Kloxo login page");
    initDbLoginPre();
    log_cleanup("- Remove default db password if exists");
    critical_change_db_pass();
}
예제 #23
0
function fix_vmipaddress()
{
    $sq = new Sqlite(null, "vps");
    $res = $sq->getTable(array('nname', 'coma_vmipaddress_a'));
    foreach ($res as $r) {
        $ip = $r['coma_vmipaddress_a'];
        $ip = trim($ip);
        if (!$ip) {
            continue;
        }
        $iplist = explode(",", $ip);
        foreach ($iplist as &$__ip) {
            $__ip = trim($__ip);
        }
        $ip = implode(",", $iplist);
        $ip = ",{$ip},";
        $sq->rawQuery("update vps set coma_vmipaddress_a = '{$ip}' where nname = '{$r['nname']}'");
    }
}
예제 #24
0
 protected final function initVirtualListIfUndef($class)
 {
     global $gbl, $sgbl, $login, $ghtml;
     $list = "{$class}_l";
     //list($iclass, $mclass, $rclass) = get_composite($class);
     $rclass = $class;
     $this->__list_list = array_push_unique($this->__list_list, $class);
     $typevar = "__listtype_{$class}";
     $totalvar = "__virtualtotal_{$class}";
     if (!isset($this->{$list})) {
         $this->{$list} = null;
     }
     if (isset($this->{$typevar}) && ($this->{$typevar} === 'fullist' || $this->{$typevar} === 'virtuallist')) {
         return $this->{$totalvar};
     }
     $this->backuplist = $this->{$list};
     if ($rule = exec_class_method($rclass, 'initThisListRule', $this, $class)) {
         $query = $this->getDefaultQuery($class, $rule);
         //dprint(' <br> ' .$query . "<br> \n");
         $filter = $this->getFilterForThis($class);
         $string = exec_class_method($rclass, "getdbFilter", $filter, $class);
         if ($string) {
             if ($query) {
                 $query .= " AND {$string}";
             } else {
                 $query .= " where {$string}";
             }
         }
         $db = new Sqlite($this->__masterserver, $this->getTheTable($rclass));
         $countquery = $query;
         $table = $this->getTheTable($rclass);
         print_time('count');
         //$db->rawquery("begin;");
         $countres = $db->rawquery("select count(*) from {$table} {$countquery}");
         if ($sgbl->__var_database_type === 'mysql') {
             $countres = $countres[0]['count(*)'];
         } else {
             if ($sgbl->__var_database_type === 'mssql') {
                 $countres = $countres[0]['computed'];
             } else {
                 $countres = $countres[0]['count(*)'];
             }
         }
         //print_time('count', "CountResult");
         print_time('getdb');
         $f = $this->getDbOrderLimit($filter, $countres, $class);
         $table = $this->getTheTable($rclass);
         $sortby = $f['sortby'];
         $sortdir = $f['sortdir'];
         $skiprows = $f['skiprows'];
         $pagesize = $f['pagesize'];
         $revsortdir = $f['revsortdir'];
         if ($sgbl->__var_database_type === 'mysql') {
             $desc = get_classvar_description($class, $sortby);
             if (csa($desc[0], "q")) {
                 $sortby = "(used_q_{$sortby} + 0)";
             }
             $query = "select * from {$table} {$countquery} order by {$sortby} {$sortdir} limit {$skiprows}, {$pagesize}";
         } else {
             if ($sgbl->__var_database_type === 'mssql') {
                 $tot = $pagesize + $skiprows;
                 $query = "select * from (select top {$pagesize} * from ( select top {$tot} * from {$table} {$countquery} order by {$sortby} {$sortdir} ) as t_{$table} order by {$sortby} {$revsortdir}) as t2_{$table} order by {$sortby} {$sortdir}";
             } else {
                 $query = "select * from {$table} {$countquery} order by {$sortby} {$sortdir} limit {$skiprows}, {$pagesize}";
             }
         }
         $res = $db->rawQuery($query);
         //$db->rawquery("commit;");
         //print_time('getdb', 'GetResult');
     } else {
         $res = exec_class_method($rclass, 'initThisList', $this, $class);
         $countres = count($res);
     }
     //$this->ApplyFilter($res);
     $this->setListFromArray($this->__masterserver, $this->__readserver, $class, $res);
     foreach ((array) $this->backuplist as $v) {
         $this->{$list}[$v->nname] = $v;
     }
     $this->{$typevar} = 'virtuallist';
     $this->{$totalvar} = $countres;
     return $countres;
 }
예제 #25
0
 function deleteSpecific()
 {
     if_demo_throw_exception('demo');
     $sq = new Sqlite(null, 'ipaddress');
     $sq->rawQuery("delete from ipaddress where syncserver = '{$this->nname}'");
     //$this->fixDatabaseServers();
 }
예제 #26
0
파일: lxlib.php 프로젝트: zseand/kloxo
function create_table_with_drop($tbl_name, $list)
{
    global $gbl, $sgbl, $login, $ghtml;
    $__db = new Sqlite(null, 'sqlite');
    $__db->rawQuery("drop table {$tbl_name}");
    create_table($__db, $tbl_name, $list);
}
예제 #27
0
function fix_vmipaddress()
{
    $file = "__path_program_root/etc/flag/newfixed_vmipaddress";
    if (lxfile_exists($file)) {
        return;
    }
    lxfile_touch($file);
    $sq = new Sqlite(null, "vps");
    $res = $sq->getTable(array('nname', 'coma_vmipaddress_a'));
    foreach ($res as $r) {
        $ip = $r['coma_vmipaddress_a'];
        $ip = trim($ip);
        if (!$ip) {
            continue;
        }
        $iplist = explode(",", $ip);
        foreach ($iplist as &$__ip) {
            $__ip = trim($__ip);
        }
        $ip = implode(",", $iplist);
        $ip = ",{$ip},";
        $sq->rawQuery("update vps set coma_vmipaddress_a = '{$ip}' where nname = '{$r['nname']}'");
    }
}
예제 #28
0
파일: lib.php 프로젝트: lonelywoolf/hypervm
function migrateResourceplan($class)
{
    $ss = new Sqlite(null, "resourceplan");
    $r = $ss->getTable();
    if ($r) {
        return;
    }
    $sq = new Sqlite(null, 'clienttemplate');
    $cres = $sq->getTable();
    if ($class) {
        $nsq = new Sqlite(null, "{$class}template");
        $dres = $nsq->getTable();
        $total = lx_array_merge(array($cres, $dres));
    } else {
        $total = $cres;
    }
    foreach ($total as $t) {
        $string = $ss->createQueryStringAdd($t);
        $addstring = "insert into resourceplan {$string};";
        $ss->rawQuery($addstring);
    }
}
예제 #29
0
 function checkOpenvzVpsid($r)
 {
     $sq = new Sqlite(null, 'vps');
     $v = $sq->rawQuery("select * from vps where vpsid = '{$r->vpsid}'");
     if (!$v) {
         return false;
     }
     if ($v[0]['syncserver'] === $r->syncserver) {
         dprint("{$r->vpsid} already exists on the same server {$r->syncserver} <br> ");
         return true;
     } else {
         dprint("{$r->vpsid} already exists on the another server {$v[0]['syncserver']} <br> ");
         throw new lxexception('vpsid_already_exists_on_another_server', '', "{$r->vpsid} : {$v[0]['syncserver']}");
     }
 }
예제 #30
0
function trafficperslave($slave, $oldtime, $newtime)
{
    global $gbl, $sgbl, $login, $ghtml;
    $sq = new Sqlite(null, 'vps');
    $res = $sq->getRowswhere("syncserver = '{$slave}'", array('nname'));
    if (!$res) {
        return;
    }
    foreach ($res as $r) {
        $vps = new Vps(null, null, $r['nname']);
        $vps->get();
        $vpslist[] = $vps;
    }
    $list = null;
    foreach ($vpslist as $d) {
        $rt = new Remote();
        if ($d->isXen()) {
            $rt->viflist = $d->getViflist();
        } else {
            $rt->vpsid = $d->vpsid;
        }
        $rt->nname = $d->nname;
        $list[$d->nname] = $rt;
    }
    $driverapp = $gbl->getSyncClass(null, $slave, 'vps');
    try {
        $vps_usage = rl_exec_get(null, $slave, array("vpstraffic__{$driverapp}", 'findTotaltrafficUsage'), array($list, $oldtime, $newtime));
    } catch (exception $e) {
        exit;
    }
    dprintr($vps_usage);
    $res = "";
    foreach ($vpslist as $d) {
        $res['nname'] = "{$d->nname}:{$oldtime}:{$newtime}";
        $domt = new Vpstraffic(null, null, $res['nname']);
        $res['timestamp'] = @strftime("%c", $newtime);
        $res['oldtimestamp'] = @strftime("%c", $oldtime);
        $res['ddate'] = time();
        $res['comment'] = null;
        $res['parent_list'] = null;
        $res['parent_clname'] = $d->getClName();
        $res['traffic_usage'] = $vps_usage[$d->nname]['total'];
        $res['incoming_usage'] = $vps_usage[$d->nname]['incoming'];
        $res['outgoing_usage'] = $vps_usage[$d->nname]['outgoing'];
        //		print_r($res);
        $domt->create($res);
        $domt->was();
    }
    $firstofmonth = @mktime(00, 01, 00, @date("n"), 1, @date("Y"));
    $today = time() + 2 * 24 * 60 * 60;
    if ($vpslist) {
        foreach ($vpslist as $vps) {
            $vpst = $vps->getList("vpstraffic");
            $list = get_namelist_from_objectlist($vpst);
            $tu = trafficGetIndividualObjectTotal($vpst, $firstofmonth, $today, $vps->nname);
            $sq->rawQuery("update vps set used_q_traffic_usage = '{$tu}' where nname = '{$vps->nname}'");
            list($month, $year) = get_last_month_and_year();
            $tlu = VpstrafficHistory::getMonthTotal($vpst, $month, $year, null);
            $tlu = $tlu['traffic_usage'];
            $sq->rawQuery("update vps set used_q_traffic_last_usage = '{$tlu}' where nname = '{$vps->nname}'");
            /*
            	try {
            		$sgbl->__var_backupdisk_usage[$vps->getClName()] = rl_exec_get(null, $vps->syncserver, array("vps", "getBackupDiskSize"), array($vps->nname));
            	} catch (Exception $e) {
            		$sgbl->__var_backupdisk_usage[$vps->getClName()] = null;
            	}
            */
        }
    }
}