Esempio n. 1
0
#!/usr/bin/php -q
<?php 
require_once "/usr/share/alternc/panel/class/config_nochk.php";
global $db;
echo "\n---------------------------\n Generating size-cache for web accounts\n\n";
exec("/usr/lib/alternc/quota_get_all", $list_quota_tmp);
$list_quota = array();
foreach ($list_quota_tmp as $qt) {
    $qt = explode(" ", $qt);
    $list_quota[$qt[0]] = array('used' => $qt[1], 'quota' => $qt[2]);
}
if ($db->query("SELECT uid,login FROM membres;")) {
    $db2 = new DB_system();
    while ($db->next_record()) {
        if (isset($list_quota[$db->f('uid')])) {
            $qu = $list_quota[$db->f('uid')];
            $db2->query("INSERT OR REPLACE INTO size_web SET uid='" . intval($db->f('uid')) . "',size='" . intval($qu['used']) . "';");
            echo $db->f('login') . " (" . $qu['used'] . " B)\n";
        }
    }
}
echo "\n---------------------------\n Generating size-cache for MySQL databases\n\n";
// We get all hosts on which sql users' DB are
$r = mysql_query("select * from db_servers;");
$tab = array();
while ($c = mysql_fetch_array($r)) {
    $tab = $mysql->get_dbus_size($c["name"], $c["host"], $c["login"], $c["password"], $c["client"]);
    echo "++ Processing " . $c["name"] . " ++\n";
    foreach ($tab as $dbname => $size) {
        $db->query("REPLACE INTO size_db SET db='" . $dbname . "',size='{$size}';");
        echo "   {$dbname} done ({$size} B) \n";
Esempio n. 2
0
$queryList = array("mysql -u {$user} --password='******' -e 'DROP DATABASE IF EXISTS {$database} '", "mysql -u {$user} --password='******' -e 'CREATE DATABASE {$database}'", "mysql -u {$user} --password='******' {$database} < " . __DIR__ . "/../install/mysql.sql");
foreach ($queryList as $exec_command) {
    exec($exec_command, $output, $return_var);
    if ($return_var) {
        throw new \Exception("[!] Mysql exec error : {$exec_command} \n Error : \n " . print_r($output, true));
    }
}
echo "*** In progress: mysql.sql imported\n";
global $db;
global $cuid;
global $variables;
global $err;
global $mem;
global $admin;
global $mysql;
global $ftp;
global $quota;
global $db;
$db = new \DB_system($user, $database, $password);
$db->connect();
$cuid = 0;
$variables = new \m_variables();
$mem = new \m_mem();
$err = new \m_err();
$authip = new \m_authip();
$hooks = new \m_hooks();
$bro = new \m_bro();
$admin = new \m_admin();
$mysql = new \m_mysql();
$ftp = new \m_ftp();
$quota = new \m_quota();