当前位置: 首页>>代码示例>>PHP>>正文


PHP unix::MYSQL_DATA_DIR方法代码示例

本文整理汇总了PHP中unix::MYSQL_DATA_DIR方法的典型用法代码示例。如果您正苦于以下问题:PHP unix::MYSQL_DATA_DIR方法的具体用法?PHP unix::MYSQL_DATA_DIR怎么用?PHP unix::MYSQL_DATA_DIR使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在unix的用法示例。


在下文中一共展示了unix::MYSQL_DATA_DIR方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: inject_extracted_attach

function inject_extracted_attach($filepath)
{
    if ($GLOBALS["VERBOSE"]) {
        echo "Injecting {$filepath}\n";
    }
    $unix = new unix();
    $MYSQL_DATA_DIR = $unix->MYSQL_DATA_DIR();
    if (!is_dir($MYSQL_DATA_DIR)) {
        @mkdir($MYSQL_DATA_DIR, 0755, true);
        @chown($MYSQL_DATA_DIR, "mysql");
        @chgrp($MYSQL_DATA_DIR, "mysql");
    }
    $basename = basename($filepath);
    $tempfile = "{$MYSQL_DATA_DIR}/{$basename}";
    $last_modified = filemtime($filepath);
    $filetime = date("Y-m-d H:i:s", $last_modified);
    $filesize = $unix->file_size($filepath);
    @copy($filepath, $tempfile);
    @chmod($tempfile, 0777);
    $q = new mysql_mimedefang_builder();
    $sql = "SELECT `filename` FROM `storage` WHERE `filename`='{$basename}'";
    $ligne = mysql_fetch_array($q->QUERY_SQL($sql));
    if (strlen(trim($ligne["filename"])) > 0) {
        if ($GLOBALS["VERBOSE"]) {
            echo "Skipped {$basename}, already exists in database\n";
        }
        @unlink($filepath);
        return;
    }
    $sql = "INSERT INTO `storage` (`filename`,`filetime`,`filesize`,`filedata`) VALUES ('{$basename}','{$filetime}','{$filesize}',LOAD_FILE('{$filepath}'))";
    $q->QUERY_SQL($sql);
    if (!$q->ok) {
        system_admin_events("Fatal: {$q->mysql_error}.", __FUNCTION__, __FILE__, __LINE__, "postfix");
        $returned = false;
    } else {
        $returned = true;
        @unlink($filepath);
    }
    @unlink($tempfile);
    return $returned;
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:41,代码来源:exec.mimedefang.mysql.php

示例2: mvdb

function mvdb($database, $encpath)
{
    $GLOBALS["LOGSDB"] = $database;
    $logFile = "/usr/share/artica-postfix/ressources/logs/web/empty-{$GLOBALS["LOGSDB"]}.txt";
    @unlink($logFile);
    if ($database == null) {
        ouputz("No database set", __LINE__);
        return;
    }
    $unix = new unix();
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    $pid = @file_get_contents($pidfile);
    if ($unix->process_exists($pid)) {
        ouputz("already running PID:{$pid}", __LINE__);
        return;
    }
    $t = time();
    @file_put_contents($pidfile, getmypid());
    $MYSQL_DATA_DIR = $unix->MYSQL_DATA_DIR();
    $path = base64_decode($encpath);
    if (!is_link("{$MYSQL_DATA_DIR}/{$database}")) {
        $original_path = "{$MYSQL_DATA_DIR}/{$database}";
    } else {
        $original_path = readlink("{$MYSQL_DATA_DIR}/{$database}");
    }
    if ($original_path == null) {
        ouputz("original_path is null, aborting ", __LINE__);
        return;
    }
    if ($path == "{$MYSQL_DATA_DIR}/{$database}") {
        ouputz("{$path} cannot be the original path `{$MYSQL_DATA_DIR}/{$database}`", __LINE__);
        return;
    }
    if ($path == "{$original_path}") {
        ouputz("{$path} cannot be the same path `{$original_path}`", __LINE__);
        return;
    }
    $chattr = $unix->find_program("chattr");
    $cp = $unix->find_program("cp");
    $mv = $unix->find_program("mv");
    $ln = $unix->find_program("ln");
    $rm = $unix->find_program("rm");
    $chmod = $unix->find_program("chmod");
    $chown = $unix->find_program("chown");
    @mkdir($path, 0755, true);
    ouputz("[0%] Mark {$MYSQL_DATA_DIR}/{$database}/* as read only", __LINE__);
    exec2("{$chattr} -R +i {$MYSQL_DATA_DIR}/{$database}");
    ouputz("[5%] copy {$MYSQL_DATA_DIR}/{$database}/* to {$path}/", __LINE__);
    exec2("{$cp} -rf \"{$MYSQL_DATA_DIR}/{$database}/\"* \"{$path}/\"");
    ouputz("[15%] Mark {$path}/* as write", __LINE__);
    exec2("{$chattr} -R -i \"{$path}\"");
    if (is_dir("{$MYSQL_DATA_DIR}/{$database}-bak")) {
        exec2("{$chattr} -R -i {$MYSQL_DATA_DIR}/{$database}-bak");
        exec2("{$rm} -rf \"{$MYSQL_DATA_DIR}/{$database}-bak\"");
    }
    ouputz("[35%] move {$MYSQL_DATA_DIR}/{$database} to {$MYSQL_DATA_DIR}/{$database}-bak", __LINE__);
    exec2("{$chattr} -R -i \"{$MYSQL_DATA_DIR}/{$database}\"");
    exec2("{$mv} \"{$MYSQL_DATA_DIR}/{$database}\" \"{$MYSQL_DATA_DIR}/{$database}-bak\"");
    if (!is_dir("{$MYSQL_DATA_DIR}/{$database}-bak")) {
        ouputz("move {$MYSQL_DATA_DIR}/{$database} to {$MYSQL_DATA_DIR}/{$database}-bak failed, roolback", __LINE__);
        exec2("{$chattr} -R -i \"{$MYSQL_DATA_DIR}/{$database}\"");
        return;
    }
    ouputz("[55%] link {$path} to {$MYSQL_DATA_DIR}/{$database}");
    exec2("{$ln} -s \"{$path}\" \"{$MYSQL_DATA_DIR}/{$database}\"");
    ouputz("[75%] remove {$MYSQL_DATA_DIR}/{$database}-bak ", __LINE__);
    exec2("{$chattr} -R -i \"{$MYSQL_DATA_DIR}/{$database}-bak\"");
    exec2("{$rm} -rf \"{$MYSQL_DATA_DIR}/{$database}-bak\"");
    if ($original_path != "{$MYSQL_DATA_DIR}/{$database}") {
        exec2("{$rm} -rf \"{$original_path}\"");
    }
    ouputz("[85%] Apply permissions on {$path}", __LINE__);
    exec2("{$chmod} -R 0755 {$path}");
    exec2("{$chown} -R mysql:mysql {$path}");
    @unlink("/usr/share/artica-postfix/ressources/logs/web/squidlogs.stats");
    ouputz("[100%] Task finish took " . $unix->distanceOfTimeInWords($t, time(), true), __LINE__);
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:77,代码来源:exec.mysql.mvdb.php

示例3: clean_events

function clean_events()
{
    $q = new mysql();
    $unix = new unix();
    $rm = $unix->find_program("rm");
    $nohup = $unix->find_program("nohup");
    $TABLES = $q->LIST_TABLES_EVENTS_SYSTEM();
    while (list($tablename, $line) = each($TABLES)) {
        echo "DROP {$tablename}\n";
        $q->QUERY_SQL("DROP TABLE `{$tablename}`", "artica_events");
    }
    $datadir = $unix->MYSQL_DATA_DIR();
    shell_exec("{$rm} -f {$datadir}/artica_events/*.BAK");
    if (is_dir("{$datadir}/syslogstore")) {
        $q->DELETE_DATABASE("syslogstore");
        shell_exec("{$rm} -f {$datadir}/syslogstore/*.BAK");
    }
    $files = $unix->DirFiles("{$datadir}/artica_events", "TaskSq[0-9]+\\.MYI");
    while (list($file, $line) = each($files)) {
        $file = str_replace(".MYI", "", $file);
        $q->QUERY_SQL("DROP TABLE `{$file}`", "artica_events");
    }
    $q->QUERY_SQL("TRUNCATE TABLE `nmap_events`", "artica_events");
    $q->QUERY_SQL("TRUNCATE TABLE `nmap_events`", "artica_events");
    $q->QUERY_SQL("TRUNCATE TABLE `avgreports`", "artica_events");
    $q->QUERY_SQL("TRUNCATE TABLE `events`", "artica_events");
    $q->QUERY_SQL("TRUNCATE TABLE `dhcpd_logs`", "artica_events");
    $q->QUERY_SQL("TRUNCATE TABLE `update_events`", "artica_events");
    shell_exec("{$nohup} /etc/init.d/mysql restart --framework=" . __FILE__ . " >/dev/null 2>&1 &");
    shell_exec($unix->LOCATE_PHP5_BIN() . " /usr/share/artica-postfix/exec.mysql.start.php --engines --verbose --framework=" . __FILE__ . " 2>&1 &");
}
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:31,代码来源:exec.mysql.start.php

示例4: database_path

function database_path()
{
    $unix = new unix();
    $MYSQL_DATA_DIR = $unix->MYSQL_DATA_DIR();
    $database = base64_decode($_GET["database-path"]);
    if (!is_link("{$MYSQL_DATA_DIR}/{$database}")) {
        echo "<articadatascgi>" . base64_encode("{$MYSQL_DATA_DIR}/{$database}") . "</articadatascgi>";
        return;
    }
    echo "<articadatascgi>" . base64_encode(readlink("{$MYSQL_DATA_DIR}/{$database}")) . "</articadatascgi>";
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:11,代码来源:mysql.php

示例5: ufdbguard_recompile_missing_dbs

function ufdbguard_recompile_missing_dbs()
{
    $sock = new sockets();
    $EnableRemoteStatisticsAppliance = $sock->GET_INFO("EnableRemoteStatisticsAppliance");
    if (!is_numeric($EnableRemoteStatisticsAppliance)) {
        $EnableRemoteStatisticsAppliance = 0;
    }
    if ($EnableRemoteStatisticsAppliance == 1) {
        return;
    }
    $unix = new unix();
    $MYSQL_DATA_DIR = $unix->MYSQL_DATA_DIR();
    $touch = $unix->find_program("touch");
    @mkdir("/var/lib/squidguard", 0755, true);
    $q = new mysql_squid_builder();
    $sql = "SELECT table_name as c FROM information_schema.tables WHERE table_schema = 'squidlogs' AND table_name LIKE 'category_%'";
    $results = $q->QUERY_SQL($sql);
    while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) {
        $table = $ligne["c"];
        if (!preg_match("#^category_(.+)#", $table, $re)) {
            continue;
        }
        $categoryname = $re[1];
        echo "Starting......: " . date("H:i:s") . " Webfiltering service {$table} -> {$categoryname}\n";
        if (!is_file("/var/lib/squidguard/{$categoryname}/domains")) {
            @mkdir("/var/lib/squidguard/{$categoryname}", 0755, true);
            $sql = "SELECT LOWER(pattern) FROM {$ligne["c"]} WHERE enabled=1 AND pattern REGEXP '[a-zA-Z0-9\\_\\-]+\\.[a-zA-Z0-9\\_\\-]+' ORDER BY pattern INTO OUTFILE '{$table}.temp' FIELDS OPTIONALLY ENCLOSED BY 'n'";
            $q->QUERY_SQL($sql);
            if (!is_file("{$MYSQL_DATA_DIR}/squidlogs/{$table}.temp")) {
                echo "Starting......: " . date("H:i:s") . " Webfiltering service {$MYSQL_DATA_DIR}/squidlogs/{$table}.temp no such file\n";
                continue;
            }
            echo "Starting......: " . date("H:i:s") . " Webfiltering service {$MYSQL_DATA_DIR}/squidlogs/{$table}.temp done...\n";
            @copy("{$MYSQL_DATA_DIR}/squidlogs/{$table}.temp", "/var/lib/squidguard/{$categoryname}/domains");
            @unlink("{$MYSQL_DATA_DIR}/squidlogs/{$table}.temp");
            echo "Starting......: " . date("H:i:s") . " Webfiltering service UFDBGUARD_COMPILE_SINGLE_DB(/var/lib/squidguard/{$categoryname}/domains)\n";
            UFDBGUARD_COMPILE_SINGLE_DB("/var/lib/squidguard/{$categoryname}/domains");
        } else {
            echo "Starting......: " . date("H:i:s") . " Webfiltering service /var/lib/squidguard/{$categoryname}/domains OK\n";
        }
        if (!is_file("/var/lib/squidguard/{$categoryname}/expressions")) {
            shell_exec("{$touch} /var/lib/squidguard/{$categoryname}/expressions");
        }
    }
    build();
    if (is_file("/etc/init.d/ufdb")) {
        echo "Starting......: " . date("H:i:s") . " Webfiltering service reloading service\n";
        ufdbguard_admin_events("Service will be reloaded", __FUNCTION__, __FILE__, __LINE__, "config");
        build_ufdbguard_HUP();
    }
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:51,代码来源:exec.squidguard.php

示例6: _repair_database

function _repair_database($database)
{
    $q = new mysql();
    $sql = "SHOW TABLES";
    $results = $q->QUERY_SQL($sql, "squidlogs");
    $unix = new unix();
    $MYSQL_DATA_DIR = $unix->MYSQL_DATA_DIR();
    $time1 = time();
    $myisamchk = $unix->find_program("myisamchk");
    $mysqlcheck = $unix->find_program("mysqlcheck");
    $myisamchk = $unix->find_program("myisamchk");
    $pgrep = $unix->find_program("pgrep");
    exec("{$pgrep} -l -f \"{$myisamchk}\"", $results);
    while (list($index, $line) = each($results)) {
        if (preg_match("#pgrep#", $line)) {
            continue;
        }
        if (preg_match("#^[0-9]+\\s+#", $line)) {
            writelogs("{$line} already executed", @implode("\r\n", $results), __FUNCTION__, __FILE__, __LINE__);
            return;
        }
    }
    $mysqlcheck_logs = null;
    $sql = "SHOW TABLES";
    $results = $q->QUERY_SQL($sql, $database);
    if (!$q->ok) {
        system_admin_events("Maintenance on database {$database} failed {$q->mysql_error}", __FUNCTION__, __FILE__, __LINE__, "mysql-error");
        return;
    }
    if (mysql_num_rows($results) == 0) {
        system_admin_events("Maintenance on database {$database} aborting, no table stored", __FUNCTION__, __FILE__, __LINE__, "mysql-error");
        return;
    }
    $user = $q->mysql_admin;
    $ty[] = " --user={$user}";
    if ($q->mysql_password != null) {
        $ty[] = "--password={$q->mysql_password}";
    }
    $BLACKS["events_waits_current"] = true;
    $BLACKS["events_waits_history"] = true;
    $BLACKS["events_waits_history_long"] = true;
    $BLACKS["cond_instances"] = true;
    $BLACKS["events_waits_summary_by_instance"] = true;
    $BLACKS["events_waits_summary_by_thread_by_event_name"] = true;
    $BLACKS["events_waits_summary_global_by_event_name"] = true;
    $BLACKS["file_instances"] = true;
    $BLACKS["file_summary_by_event_name"] = true;
    $BLACKS["file_summary_by_instance"] = true;
    $BLACKS["mutex_instances"] = true;
    $BLACKS["performance_timers"] = true;
    $BLACKS["rwlock_instances"] = true;
    $BLACKS["setup_consumers"] = true;
    $BLACKS["setup_instruments"] = true;
    $BLACKS["setup_timers"] = true;
    $BLACKS["threads"] = true;
    $BLACKS["schema"] = true;
    $credentials = @implode(" ", $ty);
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        $table = $ligne["Tables_in_{$database}"];
        if (isset($BLACKS[$table])) {
            continue;
        }
        $tt = time();
        if (is_file($mysqlcheck)) {
            exec("{$mysqlcheck}{$credentials} -r {$database} {$table} 2>&1", $mysqlcheck_array);
            $mysqlcheck_logs = $mysqlcheck_logs . "\n{$mysqlcheck} on {$table}:\n" . @implode("\n", $mysqlcheck_array);
            unset($mysqlcheck_array);
        }
        echo $table . "\n";
        if (is_file($myisamchk)) {
            shell_exec("{$myisamchk} --safe-recover --force {$MYSQL_DATA_DIR}/{$database}/{$table}");
        } else {
            $q->REPAIR_TABLE($database, $table);
        }
        $q->QUERY_SQL("OPTIMIZE table {$table}", "{$database}");
        $time_duration = distanceOfTimeInWords($tt, time());
        $p[] = "{$database}/{$table} {$time_duration}";
    }
    $t2 = time();
    $time_duration = distanceOfTimeInWords($time1, $t2);
    system_admin_events("Maintenance on database {$database} done: took {$time_duration}\nOperations has be proceed on \n" . @implode("\n", $p) . "\nmysqlchecks results:\n{$mysqlcheck_logs}", __FUNCTION__, __FILE__, __LINE__, "mysql");
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:82,代码来源:exec.mysql.build.php

示例7: repair_all

function repair_all()
{
    $unix = new unix();
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    $timefile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
    if ($GLOBALS["VERBOSE"]) {
        echo "repair_all Loading done...\nTimeFile:{$timefile}\n";
    }
    $unix = new unix();
    if (system_is_overloaded()) {
        mysql_admin_events("Overloaded system, aborting task", __FILE__, __LINE__);
        return;
    }
    $pid = @file_get_contents($pidfile);
    if (!$GLOBALS["FORCE"]) {
        if ($pid < 100) {
            $pid = null;
        }
        if ($unix->process_exists($pid, basename(__FILE__))) {
            if ($GLOBALS["VERBOSE"]) {
                echo "Already executed pid {$pid}\n";
            }
            return;
        }
        $timeexec = $unix->file_time_min($timefile);
        if ($timeexec < 120) {
            if ($GLOBALS["VERBOSE"]) {
                echo "{$timeexec} <> 120...\n";
            }
            return;
        }
    }
    $q = new mysql();
    $myisamchk = $unix->find_program("myisamchk");
    $sql = "SHOW TABLE STATUS FROM `artica_backup`";
    $q = new mysql();
    $MYSQL_DATA_DIR = $unix->MYSQL_DATA_DIR();
    $results = $q->QUERY_SQL($sql, "artica_backup");
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        $TableName = $ligne["Name"];
        $ligne2 = mysql_fetch_array($q->QUERY_SQL("ANALYZE TABLE {$TableName}", "artica_backup"));
        $comment = $ligne["Comment"];
        echo "{$TableName}: {$ligne2["Msg_type"]} - {$ligne2["Msg_text"]} ({$comment})\n{$myisamchk} --safe-recover {$MYSQL_DATA_DIR}/artica_backup/{$TableName}.MYI\n";
        if ($TableName == "squid_caches_center") {
            $ligne2["Msg_type"] = "error";
        }
        if ($ligne2["Msg_type"] == "error") {
            if (is_file("{$MYSQL_DATA_DIR}/artica_backup/{$TableName}.MYI")) {
                mysql_admin_events("Repair: {$MYSQL_DATA_DIR}/artica_backup/{$TableName}.MYI", __FUNCTION__, __FILE__, __LINE__);
                shell_exec("{$myisamchk} --safe-recover {$MYSQL_DATA_DIR}/artica_backup/{$TableName}.MYI");
            }
            continue;
        }
        echo "{$TableName} -> {$comment}\n";
        if (trim($comment) == null) {
            continue;
        }
    }
    $sql = "SHOW TABLE STATUS FROM `artica_events`";
    $results = $q->QUERY_SQL($sql, "artica_events");
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        $TableName = $ligne["Name"];
        $comment = $ligne["Comment"];
        $ligne2 = mysql_fetch_array($q->QUERY_SQL("ANALYZE TABLE {$TableName}", "artica_events"));
        $comment = $ligne["Comment"];
        echo "{$TableName}: {$ligne2["Msg_type"]} - {$ligne2["Msg_text"]} ({$comment})\n";
        if ($ligne2["Msg_type"] == "error") {
            if (is_file("{$MYSQL_DATA_DIR}/artica_events/{$TableName}.MYI")) {
                mysql_admin_events("Repair: {$MYSQL_DATA_DIR}/artica_events/{$TableName}.MYI", __FUNCTION__, __FILE__, __LINE__);
                shell_exec("{$myisamchk} --safe-recover {$MYSQL_DATA_DIR}/artica_events/{$TableName}.MYI");
            }
            continue;
        }
        if (trim($comment) == null) {
            continue;
        }
        if (preg_match("#Incorrect key file for table#", $comment)) {
            if (is_file("{$MYSQL_DATA_DIR}/artica_events/{$TableName}.MYI")) {
                mysql_admin_events("Repair: {$MYSQL_DATA_DIR}/artica_events/{$TableName}.MYI", __FUNCTION__, __FILE__, __LINE__);
                shell_exec("{$myisamchk} --safe-recover {$MYSQL_DATA_DIR}/artica_events/{$TableName}.MYI");
            }
        }
    }
    $sock = new sockets();
    $WORKDIR = $sock->GET_INFO("SquidStatsDatabasePath");
    if ($WORKDIR == null) {
        $WORKDIR = "/opt/squidsql";
    }
    if (is_dir($WORKDIR)) {
        $q = new mysql_squid_builder();
        $sql = "SHOW TABLE STATUS FROM `squidlogs`";
        $results = $q->QUERY_SQL($sql);
        while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
            $TableName = trim($ligne["Name"]);
            if ($TableName == null) {
                continue;
            }
            $comment = $ligne["Comment"];
            $ligne2 = mysql_fetch_array($q->QUERY_SQL("ANALYZE TABLE {$TableName}", "squidlogs"));
            if ($ligne2["Msg_type"] == "error") {
//.........这里部分代码省略.........
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:101,代码来源:exec.mysql.optimize.php

示例8: remove_database

function remove_database()
{
    $q = new mysql();
    $unix = new unix();
    $sock = new sockets();
    $ZarafaDedicateMySQLServer = $sock->GET_INFO("ZarafaDedicateMySQLServer");
    if (!is_numeric($ZarafaDedicateMySQLServer)) {
        $ZarafaDedicateMySQLServer = 0;
    }
    if ($ZarafaDedicateMySQLServer == 1) {
        shell_exec($unix->LOCATE_PHP5_BIN() . " /usr/share/artica-postfix/exec.zarafa-db.php --remove-database");
        return;
    }
    $MYSQL_DATA_DIR = $unix->MYSQL_DATA_DIR();
    $q->DELETE_DATABASE("zarafa");
    if (!$q->ok) {
        echo "Error while removing zarafa database...{$q->mysql_error}\n";
        return;
    }
    if (!is_dir($MYSQL_DATA_DIR)) {
        echo "Failed to locate {$MYSQL_DATA_DIR}\n";
        return;
    }
    if (is_file("/etc/artica-postfix/ZARFA_FIRST_INSTALL")) {
        @unlink("/etc/artica-postfix/ZARFA_FIRST_INSTALL");
    }
    $kill = $unix->find_program("kill");
    $pidof = $unix->find_program("pidof");
    $zarafa_server = $unix->find_program("zarafa-server");
    shell_exec("{$kill} -9 `{$pidof} {$zarafa_server}` >/dev/null 2>&1");
    echo "Starting zarafa..............: remove {$MYSQL_DATA_DIR}/ib_logfile*\n";
    shell_exec("/bin/rm -f {$MYSQL_DATA_DIR}/ib_logfile*");
    shell_exec("/bin/rm -f {$MYSQL_DATA_DIR}/ibdata*");
    echo "Starting zarafa..............: remove {$MYSQL_DATA_DIR}/zarafa*\n";
    shell_exec("/bin/rm -rf {$MYSQL_DATA_DIR}/zarafa");
    echo "Starting zarafa..............: restart MySQL\n";
    mysql_admin_mysql(1, "Restarting MySQL service...", null, __FILE__, __LINE__);
    shell_exec("/etc/init.d/mysql restart --force --framework=" . __FILE__ . " >/tmp/zarafa_removedb 2>&1");
    echo "Starting zarafa..............: restart Zarafa server\n";
    shell_exec("/etc/init.d/zarafa-server restart >>/tmp/zarafa_removedb 2>&1");
    $unix->send_email_events("Success removing zarafa databases", "removed {$MYSQL_DATA_DIR}/ib_logfile*\nremoved {$MYSQL_DATA_DIR}/ibdata*\nremoved {$MYSQL_DATA_DIR}/zarafa\n\n" . @file_get_contents("/tmp/zarafa_removedb"), "mailbox");
}
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:42,代码来源:exec.zarafa.build.stores.php

示例9: rebuild_database

function rebuild_database($nollop = false)
{
    $unix = new unix();
    $MYSQL_DATA_DIR = $unix->MYSQL_DATA_DIR();
    echo "Starting......: " . date("H:i:s") . " PowerDNS destroy database and recreate it\n";
    $q = new mysql();
    $q->DELETE_DATABASE("powerdns");
    $rm = $unix->find_program("rm");
    if (is_dir("{$MYSQL_DATA_DIR}/powerdns")) {
        echo "Starting......: " . date("H:i:s") . " PowerDNS removing {$MYSQL_DATA_DIR}/powerdns\n";
        shell_exec("{$rm} -rf {$MYSQL_DATA_DIR}/powerdns");
    }
    checkMysql($nollop);
    shell_exec("/etc/init.d/artica-postfix restart pdns");
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:15,代码来源:exec.pdns.php

示例10: start


//.........这里部分代码省略.........
    @mkdir($WORKDIR, 0755, true);
    $mysqlserv = new mysql_services();
    $mysqlserv->WORKDIR = $WORKDIR;
    $mysqlserv->MYSQL_PID_FILE = "/var/run/squid-db.pid";
    $mysqlserv->MYSQL_SOCKET = "/var/run/mysqld/squid-db.sock";
    $mysqlserv->SERV_NAME = $SERV_NAME;
    $mysqlserv->TokenParams = "SquidDBTuningParameters";
    $mysqlserv->INSTALL_DATABASE = true;
    $mysqlserv->MYSQL_BIN_DAEMON_PATH = $unix->find_program("mysqld");
    //$mysqlserv->MYSQL_ERRMSG=$GLOBALS["MYSQL_ERRMSG"];
    $mysqlserv->InnoDB = false;
    $cmdline = $mysqlserv->BuildParams();
    $CREATEDB = false;
    if (!is_file("{$WORKDIR}/my.cnf")) {
        @file_put_contents("{$WORKDIR}/my.cnf", "\n");
    }
    if (!is_file("{$WORKDIR}/bin/my_print_defaults")) {
        $my_print_defaults = $unix->find_program("my_print_defaults");
        shell_exec("{$lnbin} -s {$my_print_defaults} {$WORKDIR}/bin/my_print_defaults");
    }
    if (!is_file("{$WORKDIR}/data/mysql/user.MYD")) {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$SERV_NAME} Installing defaults databases, Please Wait...\n";
        }
        install_db($WORKDIR);
        $CREATEDB = true;
    }
    $topCopyMysql["host.frm"] = true;
    $topCopyMysql["host.MYD"] = true;
    $topCopyMysql["host.MYI"] = true;
    $topCopyMysql["servers.frm"] = true;
    $topCopyMysql["servers.MYD"] = true;
    $topCopyMysql["servers.MYI"] = true;
    $MYSQL_DATA_DIR = $unix->MYSQL_DATA_DIR();
    $topCopyMysqlForce["tables_priv.frm"] = true;
    $topCopyMysqlForce["tables_priv.MYD"] = true;
    $topCopyMysqlForce["tables_priv.MYI"] = true;
    $topCopyMysqlForce["columns_priv.frm"] = true;
    $topCopyMysqlForce["columns_priv.MYD"] = true;
    $topCopyMysqlForce["columns_priv.MYI"] = true;
    $topCopyMysqlForce["procs_priv.frm"] = true;
    $topCopyMysqlForce["procs_priv.MYD"] = true;
    $topCopyMysqlForce["procs_priv.MYI"] = true;
    $topCopyMysqlForce["plugin.frm"] = true;
    $topCopyMysqlForce["plugin.MYD"] = true;
    $topCopyMysqlForce["plugin.MYI"] = true;
    $topCopyMysqlForce["user.frm"] = true;
    $topCopyMysqlForce["user.MYD"] = true;
    $topCopyMysqlForce["user.MYI"] = true;
    $topCopyMysqlForce["db.frm"] = true;
    $topCopyMysqlForce["db.MYD"] = true;
    $topCopyMysqlForce["db.MYI"] = true;
    $ToCopyForce = false;
    while (list($filename, $ligne) = each($topCopyMysql)) {
        if (!is_file("{$WORKDIR}/data/mysql/{$filename}")) {
            $ToCopyForce = true;
            if (is_file("{$MYSQL_DATA_DIR}/mysql/{$filename}")) {
                if ($GLOBALS["OUTPUT"]) {
                    echo "Starting......: " . date("H:i:s") . " [INIT]: Installing {$filename}\n";
                }
                @copy("{$MYSQL_DATA_DIR}/mysql/{$filename}", "{$WORKDIR}/data/mysql/{$filename}");
                $CREATEDB = true;
            }
        }
    }
    while (list($filename, $ligne) = each($topCopyMysqlForce)) {
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:67,代码来源:exec.squid-db.php

示例11: build_report


//.........这里部分代码省略.........
            $familysite = $q->GetFamilySites($sitename);
            if (!isset($GLOBALS["CATEGORY"][$sitename])) {
                $GLOBALS["CATEGORY"][$sitename] = $q->GET_CATEGORIES($sitename);
            }
            $category = $GLOBALS["CATEGORY"][$sitename];
            $source = addslashes($ligne["source"]);
            $zDate = $ligne["zDate"];
            $size = $ligne["size"];
            $hits = $ligne["hits"];
            $category = addslashes($category);
            $f[] = "('{$md5}','{$sitename}','{$familysite}','{$source}','{$zDate}','{$size}','{$hits}','{$category}')";
        }
        if (count($f) == 0) {
            continue;
        }
        $q->QUERY_SQL($prefix . @implode(",", $f));
        if (!$q->ok) {
            ufdbguard_admin_events("{$q->mysql_error}", __FUNCTION__, __FILE__, __LINE__, "reports");
            return;
        }
        if (system_is_overloaded(__FILE__)) {
            sleep(5);
        }
    }
    if ($rp->csv == 1) {
        SaveCSV($ID);
    }
    $LIST_TABLES_BLOCKED = $q->LIST_TABLES_BLOCKED();
    $prefix = "INSERT IGNORE INTO {$tableBlock} (`zMD5`,`zDate`,`hits`,`website`,`category`,`rulename`,`event`,`why`,`explain`,`blocktype`,`{$rp->userfield}`) VALUES ";
    while (list($sourcetable, $ligne) = each($LIST_TABLES_BLOCKED)) {
        $c++;
        if ($GLOBALS["VERBOSE"]) {
            echo "Parsing {$sourcetable}\n";
        }
        $sql = $rp->BuildQueryBlock($sourcetable);
        if (!$q->FIELD_EXISTS("{$sourcetable}", "uid")) {
            $q->QUERY_SQL("ALTER TABLE `{$sourcetable}` ADD `uid` VARCHAR( 128 ) NOT NULL ,ADD INDEX ( `uid` )");
        }
        $results = $q->QUERY_SQL($sql);
        if (!$q->ok) {
            ufdbguard_admin_events("{$q->mysql_error}\n{$sql}", __FUNCTION__, __FILE__, __LINE__, "reports");
            return;
        }
        if (mysql_num_rows($results) == 0) {
            continue;
        }
        $purc = round($c / $counttables, 2) * 100;
        progress($purc, $ID);
        $f = array();
        while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
            $zMD5 = md5(serialize($ligne));
            $sitename = $ligne["sitename"];
            $category = $ligne["category"];
            if ($category == null) {
                if (!isset($GLOBALS["CATEGORY"][$sitename])) {
                    $GLOBALS["CATEGORY"][$sitename] = $q->GET_CATEGORIES($sitename);
                }
                $category = $GLOBALS["CATEGORY"][$sitename];
            }
            $source = addslashes($ligne["source"]);
            $zDate = $ligne["zDate"];
            $hits = $ligne["hits"];
            $rulename = $ligne["rulename"];
            $event = $ligne["event"];
            $why = $ligne["why"];
            $explain = $ligne["explain"];
            $blocktype = $ligne["blocktype"];
            $category = addslashes($category);
            $f[] = "('{$zMD5}','{$zDate}','{$hits}','{$sitename}','{$category}','{$rulename}','{$event}','{$why}','{$explain}','{$blocktype}','{$source}')";
        }
        if (system_is_overloaded(__FILE__)) {
            sleep(5);
        }
    }
    $myisamchk = $unix->find_program("myisamchk");
    $myisampack = $unix->find_program("myisampack");
    $mysql_data = $unix->MYSQL_DATA_DIR();
    echo "OPTIMIZE TABLE {$tableBlock}\n";
    $q->QUERY_SQL("OPTIMIZE TABLE {$tableBlock}");
    echo "OPTIMIZE TABLE {$tablename}\n";
    $q->QUERY_SQL("OPTIMIZE TABLE {$tablename}");
    echo "LOCK TABLE {$tablename}\n";
    $q->QUERY_SQL("LOCK TABLE {$tablename} WRITE");
    echo "LOCK TABLE {$tableBlock}\n";
    $q->QUERY_SQL("LOCK TABLE {$tableBlock} WRITE");
    $q->QUERY_SQL("FLUSH TABLE {$tableBlock}");
    $q->QUERY_SQL("FLUSH TABLE {$tablename}");
    echo "myisamchk {$tablename}\n";
    shell_exec("{$myisamchk} -cFU {$mysql_data}/squidlogs/{$tablename}.MYI");
    echo "myisamchk {$tableBlock}\n";
    shell_exec("{$myisamchk} -cFU {$mysql_data}/squidlogs/{$tableBlock}.MYI");
    echo "myisampack {$tablename}\n";
    shell_exec("{$myisampack} -f {$mysql_data}/squidlogs/{$tablename}.MYI");
    echo "myisampack {$tableBlock}\n";
    shell_exec("{$myisampack} -f {$mysql_data}/squidlogs/{$tableBlock}.MYI");
    $q->QUERY_SQL("FLUSH TABLE {$tablename}");
    $q->QUERY_SQL("FLUSH TABLE {$tableBlock}");
    $rp->set_duration($unix->distanceOfTimeInWords($t, time(), true));
    progress(100, $ID);
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:101,代码来源:exec.squid.reports.php

示例12: Dumpimport

function Dumpimport($innodb_file_pertable = 0)
{
    system_admin_events("Create pointer to block Artica ", __FUNCTION__, __FILE__, __LINE__, "mysql");
    @mkdir("/home/mysqldump", 0755, true);
    $tmpfile = "/home/mysqldump/all-database.sql";
    $tmpError = "/home/mysqldump/all-database.errors";
    $t1 = time();
    $sock = new sockets();
    $sock->SET_INFO("DisableMySqlTemp", 0);
    $unix = new unix();
    $q = new mysql();
    $mysql_admin = $q->mysql_admin;
    $MYSQL_DATA_DIR = $unix->MYSQL_DATA_DIR();
    if (trim($mysql_admin) == null) {
        system_admin_events("Error, unable to get mysql_admin credentials", __FUNCTION__, __FILE__, __LINE__, "mysql");
        die;
    }
    if (!is_file($tmpfile)) {
        system_admin_events("Error, {$tmpfile} no such file", __FUNCTION__, __FILE__, __LINE__, "mysql");
        die;
    }
    $password = $q->mysql_password;
    if ($password != null) {
        $passwordcmdline = " --password={$password}";
    }
    $mysqlbin = $unix->find_program("mysql");
    if (!is_file($mysqlbin)) {
        system_admin_events("Error, mysqldump no such binary, aborting", __FUNCTION__, __FILE__, __LINE__, "mysql");
        die;
    }
    $BaseDir = $MYSQL_DATA_DIR;
    $files = $unix->DirFiles($BaseDir);
    system_admin_events("Info, stopping mysql", __FUNCTION__, __FILE__, __LINE__, "mysql");
    @file_put_contents("/etc/artica-postfix/mysql.stop", time());
    shell_exec("/etc/init.d/artica-postfix stop mysql");
    while (list($index, $line) = each($files)) {
        $fsize = FormatBytes($unix->file_size("{$BaseDir}/{$line}"));
        if (preg_match("#ib_logfile#", $line)) {
            system_admin_events("Info, removing {$BaseDir}/{$line}", __FUNCTION__, __FILE__, __LINE__, "mysql");
            @unlink("/{$BaseDir}/{$line}");
            $deleted[] = $line . ": {$fsize}";
            continue;
        }
        if (preg_match("#ibdata#", $line)) {
            system_admin_events("Info, removing {$BaseDir}/{$line}", __FUNCTION__, __FILE__, __LINE__, "mysql");
            @unlink("/{$BaseDir}/{$line}");
            $deleted[] = $line . ": {$fsize}";
            continue;
        }
        $skipped[] = $line . ": {$fsize}";
    }
    if ($innodb_file_pertable == 1) {
        system_admin_events("Info, innodb_file_per_table is enabled", __FUNCTION__, __FILE__, __LINE__, "mysql");
        $sock->SET_INFO("InnodbFilePerTable", 1);
        $php5 = $unix->LOCATE_PHP5_BIN();
        shell_exec("{$php5} " . dirname(__FILE__) . "/exec.mysql.build.php");
        system_admin_events("Deleting, ibdata1,ib_logfile0,ib_logfile1 is enabled", __FUNCTION__, __FILE__, __LINE__, "mysql");
        @unlink("{$MYSQL_DATA_DIR}/ibdata1");
        @unlink("{$MYSQL_DATA_DIR}/ib_logfile0");
        @unlink("{$MYSQL_DATA_DIR}/ib_logfile1");
    }
    @unlink("/etc/artica-postfix/mysql.stop");
    system_admin_events("Info, Cleaning Mysql directory: delete files\n" . @implode($deleted, "\n") . "Skipped files:\n" . @implode($skipped, "\n"), __FUNCTION__, __FILE__, __LINE__, "mysql");
    system_admin_events("Info, starting mysql", __FUNCTION__, __FILE__, __LINE__, "mysql");
    exec("/etc/init.d/artica-postfix start mysql 2>&1", $results);
    system_admin_events("Info, starting mysql done\n" . @implode("\n", $results), __FUNCTION__, __FILE__, __LINE__, "mysql");
    unset($results);
    system_admin_events("Stamp artica to not trying to inject to mysql", __FUNCTION__, __FILE__, __LINE__, "mysql");
    sleep(2);
    for ($i = 0; $i < 50; $i++) {
        $q = new mysql();
        $sleep = true;
        if (!$q->DATABASE_EXISTS("artica_backup")) {
            $sleep = true;
        }
        $pid = @file_get_contents("/var/run/mysqld/mysqld.pid");
        if ($unix->process_exists($pid)) {
            echo "MySQL server running PID {$pid}\n";
            $sleep = false;
        } else {
            $sleep = true;
        }
        if ($sleep) {
            echo "Sleeping 1s pid:{$pid} not running, artica_backup not available...\n";
            continue;
        }
        break;
    }
    if (!$unix->process_exists($pid)) {
        $pid = @file_get_contents("/var/run/mysqld/mysqld.pid");
        echo "MySQL server not running...\n";
        system_admin_events("Task aborted, MySQL did not running...", __FUNCTION__, __FILE__, __LINE__, "mysql");
        return;
    }
    $t = time();
    @unlink($tmpError);
    $cmd = "{$mysqlbin} --batch --force --user={$mysql_admin}{$passwordcmdline} < {$tmpfile} >{$tmpError} 2>&1";
    if ($GLOBALS["VERBOSE"]) {
        echo "{$cmd}\n";
    }
//.........这里部分代码省略.........
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:101,代码来源:mysqldefrag.php


注:本文中的unix::MYSQL_DATA_DIR方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。