コード例 #1
0
ファイル: reversednslib.php プロジェクト: lonelywoolf/hypervm
 function createExtraVariables()
 {
     global $gbl, $sgbl, $login, $ghtml;
     $revc = $login->getObject('general')->reversedns_b;
     if (!$revc->dns_slave_list) {
         throw new lxexception("dns_params_not_configured", '', "");
     }
     $this->syncserver = implode(",", $revc->dns_slave_list);
     $rdrlist = $this->getList('rdnsrange');
     $rdrange = null;
     foreach ($rdrlist as $k => $v) {
         list($base, $first) = self::getBaseEnd($v->firstip);
         list($base, $last) = self::getBaseEnd($v->lastip);
         $rdrange[] = array($base, $first, $last);
     }
     $this->__var_rdnsrange = $rdrange;
     dprintr($this->__var_rdnsrange);
     $sq = new Sqlite(null, 'reversedns');
     $res = $sq->getTable();
     foreach ($res as $r) {
         list($base, $last) = self::getBaseEnd($r['nname'], $this->__var_rdnsrange);
         $total[$base][] = array('nname' => $r['nname'], 'end' => $last, 'reversename' => $r['reversename']);
     }
     $this->__var_revdns1 = $revc->primarydns;
     $this->__var_revdns2 = $revc->secondarydns;
     $this->__var_reverse_list = $total;
 }
コード例 #2
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}'");
    }
}
コード例 #3
0
ファイル: dnslib.php プロジェクト: soar-team/kloxo
 function createExtraVariables()
 {
     // Not here. Two different extra variables are needed, so they are created in synctosystem.
     // Brought back here, since the secondary server concept has been abolished in favor of multiple primary servers.
     global $gbl, $sgbl, $login, $ghtml;
     if ($sgbl->isHyperVm()) {
         $this->createExtraVariablesHyperVM();
         return;
     }
     $db = new Sqlite($this->__masterserver, "dns");
     $gen = $login->getObject('general')->generalmisc_b;
     $serverlist = explode(",", $this->syncserver);
     $list = null;
     foreach ($serverlist as $server) {
         $string = "syncserver LIKE '%{$server}%'";
         $nlist = $db->getRowsWhere($string, array('nname'));
         $dlistv = "__var_domainlist_{$server}";
         $this->{$dlistv} = $nlist;
     }
     //FIXME: We should only get the addon domains for the domains configured on that particular server. IN the case of single server system, it is not a problem, since that means we will have to get all the domains. but in the case of distributed setup, we need to properly get only the add domains under the domains loaded above.
     $dbaddon = new Sqlite(null, "addondomain");
     $addr = $dbaddon->getTable(array('nname'));
     foreach ($serverlist as $server) {
         $dlistv = "__var_domainlist_{$server}";
         $this->{$dlistv} = lx_array_merge(array($this->{$dlistv}, $addr));
     }
     $this->fixDateSerial();
     $this->__var_addonlist = $this->getParentO()->getList('addondomain');
     $mydb = new Sqlite(null, "ipaddress");
     $string = "syncserver = '{$this->syncserver}'";
     $this->__var_ipssllist = $mydb->getRowsWhere($string, array('ipaddr', 'nname'));
 }
コード例 #4
0
ファイル: gbllib.php プロジェクト: lonelywoolf/hypervm
 function loaddriverappInfo($master)
 {
     $db = new Sqlite($master, 'driver');
     $res = $db->getTable();
     // Doing the setFromArray stuff here itself. Since that is the place from where we are called, and if we call setfromarray here, naturally it results in a loop.
     $__t_ob = null;
     foreach ((array) $res as $row) {
         $nname = $row['nname'];
         $obj = new driver($master, null, $nname);
         foreach ($row as $key => $value) {
             if (csb($key, "ser_")) {
                 $key = strfrom($key, "ser_");
                 $value = unserialize(base64_decode($value));
             }
             if (cse($key, "_b") && !is_object($value)) {
                 $value = new $key(null, null, $nname);
             }
             if (is_numeric($key)) {
                 continue;
             }
             $obj->{$key} = $value;
         }
         $__t_ob[$nname] = $obj;
     }
     if (!isset($this->driver)) {
         $this->driver = array();
     }
     $this->driver[$master] = $__t_ob;
     //dprintr($this->driver);
 }
コード例 #5
0
 function createExtraVariables()
 {
     $parent = $this->getParentO();
     $sq = new Sqlite(null, "lxguardwhitelist");
     $res = $sq->getRowsWhere("syncserver = '{$parent->syncserver}'", array('nname', 'ipaddress'));
     $this->__var_whitelist = $res;
 }
コード例 #6
0
 function updateform($subaction, $param)
 {
     global $gbl, $sgbl, $login, $ghtml;
     $sq = new Sqlite(null, 'web');
     $list = $sq->getRowsWhere("syncserver = '{$this->syncserver}'", array('nname'));
     $dlist = get_namelist_from_arraylist($list, 'nname');
     if (!$login->isAdmin()) {
         $sq = new Sqlite(null, 'domain');
         $nlist = $sq->getRowsWhere("parent_clname = '{$login->getClName()}'", array('nname'));
         $ndlist = get_namelist_from_arraylist($nlist);
         foreach ($dlist as $k => $v) {
             if (!array_search_bool($v, $ndlist)) {
                 unset($dlist[$k]);
             }
         }
     }
     if ($dlist) {
         $dlist = add_disabled($dlist);
         $vlist['domain'] = array('s', $dlist);
     } else {
         $vlist['domain'] = array('M', "No Domain");
         $vlist['__v_button'] = array();
     }
     return $vlist;
 }
コード例 #7
0
 function defaultValue($var)
 {
     if ($var === 'ipaddr') {
         $db = new Sqlite($this->__masterserver, 'ipaddress');
         $res = $db->getRowsWhere("nname = '{$this->nname}'");
         return $res[0]['ipaddr'];
     }
     return null;
 }
コード例 #8
0
ファイル: hostdenylib.php プロジェクト: lonelywoolf/hypervm
 function createExtraVariables()
 {
     $pserver = $this->getParentO();
     $hdb = new Sqlite($this->__masterserver, 'hostdeny');
     $string = "syncserver = '{$pserver->nname}' ";
     $hlist = $hdb->getRowsWhere($string);
     $this->__var_hostlist = $hlist;
     dprintr($this->__var_hostlist);
 }
コード例 #9
0
ファイル: davuserlib.php プロジェクト: soar-team/kloxo
 function createExtraVariables()
 {
     $this->__var_system_username = $this->getParentO()->username;
     $sq = new Sqlite(null, 'davuser');
     $list = $sq->getRowsWhere("parent_clname = '{$this->parent_clname}'", array("username", "realpass"));
     $this->__var_davuser = $list;
     $sq = new Sqlite(null, 'web');
     $list = $sq->getRowsWhere("syncserver = '{$this->getParentO()->syncserver}'", array('nname'));
     $this->__var_domlist = get_namelist_from_arraylist($list);
 }
コード例 #10
0
ファイル: lxguardlib.php プロジェクト: lonelywoolf/hypervm
 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);
 }
コード例 #11
0
 static function initThisList($parent, $class)
 {
     $db = new Sqlite($parent->__masterserver, "ipaddress");
     if ($parent->isAdmin()) {
         $result = $db->getTable();
     } else {
         $result = $db->getRowsWhere("clientname = '" . $parent->nname . "'");
     }
     return $result;
 }
コード例 #12
0
ファイル: cronlib.php プロジェクト: zseand/kloxo
 function createExtraVariables()
 {
     global $gbl, $sgbl, $login, $ghtml;
     $this->__var_mailto = $this->getParentO()->cron_mailto;
     $mydb = new Sqlite($this->__masterserver, "cron");
     $parent = $this->getParentO();
     $this->__var_cron_list = $mydb->getRowsWhere("username = '******'");
     $mydb = new Sqlite($this->__masterserver, "uuser");
     $userlist = $mydb->getRowsWhere("nname = '{$parent->username}'");
     $this->__var_user_list = $userlist[0];
 }
コード例 #13
0
ファイル: invoicelib.php プロジェクト: soar-team/kloxo
 function getTotalPaid()
 {
     $sq = new Sqlite(null, "paymentdetail");
     $res = $sq->getRowsWhere("month = '{$this->month}' AND client = '{$this->client}'");
     $total = 0;
     if ($res) {
         foreach ($res as $r) {
             $total += $r['amount'];
         }
     }
     return $total;
 }
コード例 #14
0
ファイル: mimehandler.php プロジェクト: zseand/kloxo
 function createExtraVariables()
 {
     $path = $this->getParentO()->getFullDocRoot();
     $this->__var_htp = "{$path}/.htaccess";
     $sq = new Sqlite(null, $this->get__table());
     $res = $sq->getRowsWhere("parent_clname = '{$this->parent_clname}'");
     $result = merge_array_object_not_deleted($res, $this);
     foreach ($result as $r) {
         $out[$r['mimehandler']] = $r['extension'];
     }
     $this->__var_mimehandler = $out;
 }
コード例 #15
0
ファイル: driverload.php プロジェクト: lonelywoolf/hypervm
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();
    }
}
コード例 #16
0
ファイル: domainbaselib.php プロジェクト: soar-team/kloxo
 static function getDnsTemplateList($parent)
 {
     $res = $parent->dnstemplate_list;
     dprintr($res);
     if (!$res) {
         $sq = new Sqlite(null, "dnstemplate");
         $res = $sq->getTable();
         $res = get_namelist_from_arraylist($res);
     }
     if (!$res) {
         throw new lxException("err_no_dns_template", '', '');
     }
     return $res;
 }
コード例 #17
0
ファイル: dnstemplatelib.php プロジェクト: soar-team/kloxo
 function createUsed()
 {
     if (isset($this->used_f)) {
         return $this->used_f;
     }
     $db = new Sqlite($this->__masterserver, 'domaintemplate');
     $res = $db->getRowsWhere("dnstemplate = '{$this->nname}'");
     if ($res) {
         $this->used_f = 'on';
     } else {
         $this->used_f = 'off';
     }
     return $this->used_f;
 }
コード例 #18
0
 static function columns($table, $connection = 'default')
 {
     foreach (Sqlite::query("pragma table_info({$table});") as $c) {
         $columns[] = $c['name'];
     }
     return @$columns ?: array();
 }
コード例 #19
0
ファイル: sqlite.php プロジェクト: lonelywoolf/hypervm
 function reconnect()
 {
     global $gbl, $sgbl, $login, $ghtml;
     $this->__readserver = 'localhost';
     $user = $sgbl->__var_admin_user;
     $db = $sgbl->__var_dbf;
     $pass = getAdminDbPass();
     $readserver = $this->__readserver;
     $fdbvar = "__fdb_" . $this->__readserver;
     log_log("database_reconnect", "Reconnecting again");
     if ($sgbl->__var_database_type === 'mysql') {
         $gbl->{$fdbvar} = mysql_connect($readserver, $user, $pass);
         mysql_select_db($db);
         self::$__database = 'mysql';
     } else {
         if ($sgbl->__var_database_type === 'mssql') {
             //print("$user, $pass <br> \n");
             //$gbl->$fdbvar = mssql_connect('\\.\pipe\MSSQL$LXLABS\sql\query');
             $gbl->{$fdbvar} = mssql_pconnect("{$readserver},{$sgbl->__var_mssqlport}");
             mssql_select_db($db);
             self::$__database = 'mssql';
         } else {
             $gbl->{$fdbvar} = new PDO("sqlite:{$db}");
             self::$__database = 'sqlite';
         }
     }
 }
コード例 #20
0
ファイル: updatelib.php プロジェクト: lonelywoolf/hypervm
function update_all_slave()
{
    $db = new Sqlite(null, "pserver");
    $list = $db->getTable(array("nname"));
    foreach ($list as $l) {
        if ($l['nname'] === 'localhost') {
            continue;
        }
        try {
            print "Upgrading Slave {$l['nname']}...\n";
            rl_exec_get(null, $l['nname'], 'remotetestfunc', null);
        } catch (exception $e) {
            print $e->getMessage();
            print "\n";
        }
    }
}
コード例 #21
0
ファイル: database.php プロジェクト: soar-team/kloxo
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;
    }
}
コード例 #22
0
ファイル: sqlite.php プロジェクト: nofuyun/note
 /**
  *
  * @param array $dbconfig 数据库连接参数
  * @return object $this
  */
 private function connect($dbsetting)
 {
     if (self::$dbh) {
         return $this;
     }
     $dbconfig = Config::get($dbsetting);
     $dsn = "sqlite:" . Db_PATH . "testdrive.db";
     //{$dbconfig['host']}
     $dbh = new PDO($dsn, null, null, array(PDO::ATTR_PERSISTENT => true));
     self::$dbh = $dbh;
 }
コード例 #23
0
ファイル: initlib.php プロジェクト: lonelywoolf/hypervm
function add_admin($pass)
{
    global $gbl, $sgbl, $login, $ghtml;
    $client = new Client(null, null, 'admin');
    $login = $client;
    $client->initThisDef();
    $client->priv->pserver_num = 'Unlimited';
    $client->priv->maindomain_num = 'Unlimited';
    $client->priv->vps_num = 'Unlimited';
    $client->priv->client_num = 'Unlimited';
    $client->ddate = time();
    $ddb = new Sqlite(null, "client");
    if (!$ddb->existInTable("nname", 'admin')) {
        if ($sgbl->dbg > 0) {
            $pass = '******';
            $res['contacemail'] = '*****@*****.**';
        }
        $res['password'] = crypt($pass);
        $res['cttype'] = 'admin';
        $res['cpstatus'] = 'on';
        if (if_demo()) {
            $res['email'] = "*****@*****.**";
        }
        $client->create($res);
        $client->driverApp = new client__sync(null, null, 'admin');
        $client->was();
        lxfile_mkdir("__path_client_root/{$client->nname}");
        lxfile_generic_chown("__path_client_root/{$client->nname}", "lxlabs");
    }
    $notif = new Notification(null, null, $client->getClName());
    $notif->initThisDef();
    $notif->dbaction = 'add';
    $notif->text_newaccountmessage = lfile_get_contents("__path_program_root/file/welcome.txt");
    $notif->parent_clname = $client->getClName();
    $notif->write();
    $display = new sp_SpecialPlay(null, null, $client->getClName());
    $display->initThisDef();
    $display->parent_clname = $client->getClName();
    $display->dbaction = 'add';
    $display->write();
}
コード例 #24
0
 function changeAdminPass()
 {
     if ($this->main->nname === 'admin') {
         $newp = client::createDbPass($this->main->realpass);
         //exec("mysqladmin -u kloxo -p$oldpass password $newp 2>&1", $out, $return);
         $sql = new Sqlite(null, "client");
         //$sql->rawQuery("grant all on kloxo.* to kloxo@'localhost' identified by $newp");
         //$sql->rawQuery("grant all on kloxo.* to kloxo@'%' identified by $newp");
         $return = $sql->setPassword($newp);
         dprint("i am here <br> \n");
         dprintr($return);
         dprint("i am here <br> \n");
         if ($return) {
             log_log("admin_error", "mysql change password Failed . {$out}");
             throw new lxException("could_not_change_admin_pass", '');
         }
         $return = lfile_put_contents("__path_admin_pass", $newp);
         if (!$return) {
             log_log("admin_error", "Admin pass change failed  {$last_error}");
             throw new lxException("could_not_change_admin_pass", '');
         }
     }
 }
コード例 #25
0
ファイル: Sqlite.php プロジェクト: fluxsauce/switchboard
 /**
  * Get the SQLite PDO.
  *
  * @return \PDO
  *   Fully set up SQLite PDO, including tables.
  */
 public static function get()
 {
     static $pdo;
     if (!isset($pdo)) {
         try {
             $pdo = new \PDO('sqlite:' . Sqlite::getLocation());
             $pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
             $pdo->setAttribute(\PDO::ATTR_EMULATE_PREPARES, FALSE);
         } catch (\PDOException $e) {
             switchboard_pdo_exception_debug($e);
         }
     }
     return $pdo;
 }
コード例 #26
0
ファイル: sqlite.php プロジェクト: soar-team/kloxo
 function connect()
 {
     global $gbl, $sgbl;
     $fdbvar = "__fdb_{$this->__readserver}";
     if (!isset($gbl->{$fdbvar}) || $this->__force) {
         if (is_running_secondary()) {
             throw new lxexception("this_is_a_running_secondary_master", '', "");
         }
     }
     $user = $sgbl->__var_admin_user;
     $db = $sgbl->__var_dbf;
     $pass = getAdminDbPass();
     if ($sgbl->__var_database_type === 'mysql') {
         $gbl->{$fdbvar} = mysql_connect($this->__readserver, $user, $pass) or dprint("Could not connect to the MySql server.\n");
         mysql_select_db($db) or dprint("Could not select {$db} MySQL database.\n");
         self::$__database = 'mysql';
     } else {
         if ($sgbl->__var_database_type === 'mssql') {
             //print("$user, $pass <br> \n");
             //$gbl->$fdbvar = mssql_connect('\\.\pipe\MSSQL$LXLABS\sql\query');
             $gbl->{$fdbvar} = mssql_pconnect("{$this->__readserver},{$sgbl->__var_mssqlport}") or dprint("Could not connect to the MSSQL server.\n");
             mssql_select_db($db) or dprint("Could not select {$db} MSSQL database.\n");
             self::$__database = 'mssql';
         } else {
             try {
                 $gbl->{$fdbvar} = new PDO("sqlite:{$db}");
                 self::$__database = 'sqlite';
             } catch (PDOException $e) {
                 dprint("PDO Error: " . $e->getMessage() . "\n");
             }
         }
     }
     if (!$gbl->{$fdbvar}) {
         die("Could not open database connection.");
     }
 }
コード例 #27
0
ファイル: SqliteTest.php プロジェクト: saihe/reservation
 /**
  * Tests that cached table descriptions are saved under the sanitized key name
  *
  * @return void
  */
 public function testCacheKeyName()
 {
     Configure::write('Cache.disable', false);
     $dbName = 'db' . rand() . '$(*%&).db';
     $this->assertFalse(file_exists(TMP . $dbName));
     $db = new Sqlite(array_merge($this->Dbo->config, array('database' => TMP . $dbName)));
     $this->assertTrue(file_exists(TMP . $dbName));
     $db->execute("CREATE TABLE test_list (id VARCHAR(255));");
     $db->cacheSources = true;
     $this->assertEquals(array('test_list'), $db->listSources());
     $db->cacheSources = false;
     $fileName = '_' . preg_replace('/[^A-Za-z0-9_\\-+]/', '_', TMP . $dbName) . '_list';
     $result = Cache::read($fileName, '_cake_model_');
     $this->assertEquals(array('test_list'), $result);
     Cache::delete($fileName, '_cake_model_');
     Configure::write('Cache.disable', true);
 }
コード例 #28
0
 public function testEntireSchema()
 {
     global $IP;
     $result = Sqlite::checkSqlSyntax("{$IP}/maintenance/tables.sql");
     if ($result !== true) {
         $this->fail($result);
     }
     $this->assertTrue(true);
     // avoid test being marked as incomplete due to lack of assertions
 }
コード例 #29
0
ファイル: getnamevpsid.php プロジェクト: digideskio/hypervm
<?php

include_once "htmllib/lib/include.php";
if (!isset($argv[1])) {
    print "Need file name\n";
    exit;
}
$sq = new Sqlite(null, "vps");
$list = $sq->getTable(array("vpsid", "nname", "contactemail", "password", "rootpassword"));
foreach ($list as $l) {
    $nlist[$l['vpsid']] = $l;
}
lfile_put_serialize($argv[1], $nlist);
dprintr($nlist);
コード例 #30
0
ファイル: pserverlib.php プロジェクト: hypervm-ng/hypervm-ng
 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']}");
     }
 }