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


PHP unix::is_socket方法代码示例

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


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

示例1: dump

function dump()
{
    $unix = new unix();
    if (!$unix->is_socket("/var/run/syslogdb.sock")) {
        return false;
    }
    $bd = @mysql_connect(":/var/run/syslogdb.sock", "root");
    if (!$bd) {
        return;
    }
    $ok = @mysql_select_db("syslogs", $bd);
    $results = QUERY_SQLZ("SELECT storeid,filename FROM accesslogs");
    if (!$results) {
        return false;
    }
    while ($ligne = mysql_fetch_assoc($results)) {
        $storeid = $ligne["storeid"];
        $filename = $ligne["filename"];
        if (!export_storeid_access($storeid, $filename)) {
            continue;
        }
    }
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:23,代码来源:exec.mysql-syslog-purge.php

示例2: unix

    $GLOBALS["VERBOSE"] = true;
    ini_set('display_errors', 1);
    ini_set('error_reporting', E_ALL);
    ini_set('error_prepend_string', null);
    ini_set('error_append_string', null);
}
include_once "{$dirname}/ressources/class.templates.inc";
include_once "{$dirname}/ressources/class.users.menus.inc";
include_once "{$dirname}/ressources/class.squid.inc";
include_once "{$dirname}/ressources/class.status.inc";
include_once "{$dirname}/ressources/class.artica.graphs.inc";
include_once "{$dirname}/ressources/class.mysql.syslogs.inc";
if ($GLOBALS["AS_ROOT"]) {
    include_once "/usr/share/artica-postfix/framework/class.unix.inc";
    $unix = new unix();
    if (!$unix->is_socket("/var/run/mysqld/articadb.sock")) {
        die;
    }
}
if (!$GLOBALS["AS_ROOT"]) {
    $users = new usersMenus();
    if (!$users->AsWebStatisticsAdministrator) {
        die("Permission denied");
    }
}
if ($argv[1] == "squid-status-stats") {
    squid_status_stats();
    exit;
}
if (isset($_GET["status"])) {
    status();
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:31,代码来源:squid.traffic.statistics.php

示例3: RestoreFromBackup

function RestoreFromBackup($backuppath)
{
    $unix = new unix();
    $PidRestore = "/etc/artica-postfix/pids/zarafaRestore.pid";
    $rm = $unix->find_program("rm");
    $pid = $unix->get_pid_from_file($PidRestore);
    if ($unix->process_exists($pid, basename(__FILE__))) {
        $time = $unix->PROCCESS_TIME_MIN($pid);
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: Restore Task Already running PID {$pid} since {$time}mn\n";
        }
        return;
    }
    $pid = $unix->PIDOF_PATTERN("exec.zarafa-db.php --restorefrom");
    if ($pid != getmypid()) {
        if ($unix->process_exists($pid)) {
            $time = $unix->PROCCESS_TIME_MIN($pid);
            if ($GLOBALS["OUTPUT"]) {
                echo "Starting......: " . date("H:i:s") . " [INIT]: Restore Task Already running PID {$pid} since {$time}mn\n";
            }
            return;
        }
    }
    $mysql = $unix->find_program("mysql");
    $pid = $unix->PIDOF_PATTERN("{$mysql}\\s+.*?--socket=/var/run/mysqld/zarafa-db.sock.*?database=zarafa");
    if ($unix->process_exists($pid)) {
        $time = $unix->PROCCESS_TIME_MIN($pid);
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: Restore Task Already running PID {$pid} since {$time}mn\n";
        }
        return;
    }
    @file_put_contents($PidRestore, getmypid());
    $sock = new sockets();
    $SourceDir = dirname($backuppath);
    $WORKDIR = $sock->GET_INFO("ZarafaDedicateMySQLWorkDir");
    if ($WORKDIR == null) {
        $WORKDIR = "/home/zarafa-db";
    }
    if (is_file("{$SourceDir}/ldap.ldif")) {
        RestoreFromBackup_progress("{restore_ldap_database}", 10);
        RestoreFromBackup_ldap("{$SourceDir}/ldap.ldif");
    }
    $unix = new unix();
    if (!is_file($backuppath)) {
        echo "Action: `{$backuppath}` no such file: ABORT!\n";
        RestoreFromBackup_progress("{failed}", 100);
        return;
    }
    echo "Action: Removing Zarafa Database MySQL client `{$mysql}`....\n";
    RestoreFromBackup_progress("Removing Zarafa Database", 30);
    $cmd = "{$mysql} --socket=/var/run/mysqld/zarafa-db.sock --protocol=socket --user=root --batch --debug-info --database=zarafa --execute=\"DROP DATABASE zarafa\" 2>&1";
    $results = array();
    exec("{$cmd}", $results);
    while (list($num, $ligne) = each($results)) {
        echo "MySQL: (Delete Database) {$ligne}\n";
    }
    RestoreFromBackup_progress("Removing all content", 32);
    if (is_dir("{$WORKDIR}/data/zarafa")) {
        recursive_remove_directory("{$WORKDIR}");
    }
    RestoreFromBackup_progress("Restarting MySQL service (recovery)", 40);
    echo "Action: Restarting MySQL service...\n";
    echo "Action: Stopping MySQL service...\n";
    stop(true);
    echo "Action: Starting MySQL service (InnoDB recovery mode)...\n";
    start(true, true);
    while (list($num, $ligne) = each($results)) {
        echo "Service: {$ligne}\n";
    }
    sleep(5);
    $ZARAFADB_PID = ZARAFADB_PID();
    if (!$unix->process_exists($ZARAFADB_PID)) {
        RestoreFromBackup_progress("Failed to restart dedicated MySQL", 100);
        return;
    }
    RestoreFromBackup_progress("Stopping Zarafa server", 43);
    @unlink("/tmp/zarafa-upgrade-lock");
    shell_exec("/etc/init.d/zarafa-server stop --force");
    $pid = XZARAFA_SERVER_PID();
    if ($unix->process_exists($pid)) {
        $kill = $unix->find_program("kill");
        unix_system_kill_force($pid);
    }
    RestoreFromBackup_progress("Restarting MySQL service (normal)", 45);
    echo "Action: Restarting MySQL service...\n";
    echo "Action: Stopping MySQL service...\n";
    stop(true);
    echo "Action: Starting MySQL service (InnoDB normal mode)...\n";
    start(true, false);
    while (list($num, $ligne) = each($results)) {
        echo "Service: {$ligne}\n";
    }
    sleep(2);
    $ZARAFADB_PID = ZARAFADB_PID();
    if (!$unix->process_exists($ZARAFADB_PID)) {
        RestoreFromBackup_progress("Failed to restart dedicated MySQL", 100);
        return;
    }
    if (!$unix->is_socket("/var/run/mysqld/zarafa-db.sock")) {
//.........这里部分代码省略.........
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:101,代码来源:exec.zarafa-db.php

示例4: start


//.........这里部分代码省略.........
        return;
    }
    $unix->CreateUnixUser("postfix", "postfix");
    $php5 = $unix->LOCATE_PHP5_BIN();
    $EnableCyrusImap = $sock->GET_INFO("EnableCyrusImap");
    if (!is_numeric($EnableCyrusImap)) {
        $EnableCyrusImap = 1;
    }
    $DisableMessaging = intval($sock->GET_INFO("DisableMessaging"));
    $DisableIMAPVerif = intval($sock->GET_INFO("DisableIMAPVerif"));
    if ($DisableIMAPVerif == 0) {
        if (is_file("{$zarafaBin}")) {
            if ($GLOBALS["OUTPUT"]) {
                echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Zarafa is installed, aborting\n";
            }
            stop(true);
            return;
        }
    }
    if ($EnableCyrusImap == 0) {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} service disabled (see EnableCyrusImap)\n";
        }
        return;
    }
    if ($DisableMessaging == 1) {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} service disabled (see DisableMessaging)\n";
        }
        return;
    }
    if (!is_file('/usr/bin/cyradm')) {
        $cyradm = $unix->CYRADM_PATH();
        if (is_file($cyradm)) {
            shell_exec("/bin/ln -s {$cyradm} /usr/bin/cyradm");
        }
    }
    if (is_file('/usr/share/artica-postfix/exec.imapd.conf.php')) {
        shell_exec("{$php5} /usr/share/artica-postfix/exec.imapd.conf.php >/dev/null 2>&1");
    }
    if (!is_file('/etc/artica-postfix/cyrus.check.time')) {
        shell_exec("/usr/share/artica-postfix/bin/artica-install --cyrus-rights >/dev/null 2>&1");
    }
    shell_exec("{$php5} /usr/share/artica-postfix/exec.check-cyrus-account.php --check-adms");
    $sysctl = $unix->find_program("sysctl");
    $echo = $unix->find_program("echo");
    $nohup = $unix->find_program("nohup");
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} service\n";
    }
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Check permissions\n";
    }
    CheckPermissions();
    BuildConfig();
    $params[] = "{$nohup} {$Masterbin}";
    $params[] = "-M /etc/cyrus.conf";
    $params[] = "-C /etc/imapd.conf";
    $params[] = "-p /var/run/cyrmaster.pid -d >/dev/null 2>&1 &";
    $cmd = @implode(" ", $params);
    shell_exec($cmd);
    for ($i = 1; $i < 5; $i++) {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Waiting {$i}/5\n";
        }
        sleep(1);
        $pid = PID_NUM();
        if ($unix->process_exists($pid)) {
            break;
        }
    }
    $pid = PID_NUM();
    if ($unix->process_exists($pid)) {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Success PID {$pid}\n";
        }
        $lmtpsocket = "/var/spool/postfix/var/run/cyrus/socket/lmtp";
        for ($i = 1; $i < 5; $i++) {
            if ($unix->is_socket($lmtpsocket)) {
                if ($GLOBALS["OUTPUT"]) {
                    echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Waiting socket success..\n";
                }
                $unix->chown_func("postfix", "postfix", "/var/spool/postfix/var/run");
                $unix->chown_func("postfix", "postfix", "{$lmtpsocket}");
                break;
            }
            if ($GLOBALS["OUTPUT"]) {
                echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Waiting socket {$i}/5\n";
            }
            sleep(1);
        }
    } else {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Failed\n";
        }
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} {$cmd}\n";
        }
    }
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:101,代码来源:exec.cyrus-imapd.php

示例5: FreeMem

function FreeMem($aspid = false, $SwapOffOn = array())
{
    $unix = new unix();
    if (!$aspid) {
        $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
        $pid = @file_get_contents($pidfile);
        if ($unix->process_exists($pid, basename(__FILE__))) {
            if ($GLOBALS["VERBOSE"]) {
                echo "Already executed pid {$pid}\n";
            }
            return;
        }
    }
    if (count($SwapOffOn) == 0) {
        $sock = new sockets();
        $SwapOffOn = unserialize(base64_decode($sock->GET_INFO("SwapOffOn")));
        if (!is_numeric($SwapOffOn["AutoMemWatchdog"])) {
            $SwapOffOn["AutoMemWatchdog"] = 1;
        }
        if (!is_numeric($SwapOffOn["AutoMemPerc"])) {
            $SwapOffOn["AutoMemPerc"] = 90;
        }
        if (!is_numeric($SwapOffOn["AutoMemInterval"])) {
            $SwapOffOn["AutoMemInterval"] = 180;
        }
    }
    $text[] = "Configuration was:";
    $text[] = "--------------------------------------";
    $text[] = "Free memory when Swap exceed {$SwapOffOn["AutoMemPerc"]}%";
    $text[] = "Watchdog scanning interval: each {$SwapOffOn["AutoMemInterval"]}mn";
    if (isset($SwapOffOn["CURRENT"])) {
        $text[] = $SwapOffOn["CURRENT"];
    }
    $text[] = $unix->ps_mem_report();
    $TOTAL_MEMORY_MB_FREE = $unix->TOTAL_MEMORY_MB_FREE();
    $text[] = "{$TOTAL_MEMORY_MB_FREE}MB before operation";
    $sync = $unix->find_program("sync");
    $sysctl = $unix->find_program("sysctl");
    $squid = $unix->LOCATE_SQUID_BIN();
    shell_exec($sync);
    shell_exec("{$sysctl} -w vm.drop_caches=3");
    shell_exec($sync);
    shell_exec("/etc/init.d/apache2 restart");
    if (is_file("/etc/init.d/ssh")) {
        shell_exec("/etc/init.d/ssh restart");
    }
    if ($unix->is_socket("/var/run/mysqld/mysqld.sock")) {
        $q = new mysql();
        $q->EXECUTE_SQL("RESET QUERY CACHE;");
    }
    if ($unix->is_socket("/var/run/mysqld/squid-db.sock")) {
        $q = new mysql_squid_builder();
        $q->EXECUTE_SQL("RESET QUERY CACHE;");
    }
    $TOTAL_MEMORY_MB_FREE2 = $unix->TOTAL_MEMORY_MB_FREE();
    $text[] = "{$TOTAL_MEMORY_MB_FREE2}MB After operation";
    $TOTAL_MEMORY_MB = $TOTAL_MEMORY_MB_FREE2 - $TOTAL_MEMORY_MB_FREE;
    $text[] = "{$TOTAL_MEMORY_MB}MB restored";
    $FINAL_TEXT = @implode("\n", $text);
    system_admin_events("Free memory operation has been executed - {$TOTAL_MEMORY_MB}MB restored\n{$FINAL_TEXT}", __FUNCTION__, __FILE__, __LINE__);
    if (is_file($squid)) {
        squid_admin_mysql(1, "Swap exceed rule: Free memory operation has been executed - {$TOTAL_MEMORY_MB}MB restored", $FINAL_TEXT, __FILE__, __LINE__);
    }
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:64,代码来源:exec.swap-monitor.php

示例6: start

function start($aspid = false)
{
    $unix = new unix();
    $sock = new sockets();
    $Masterbin = $unix->find_program("clamd");
    if (!is_file($Masterbin)) {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, clamd not installed\n";
        }
        return;
    }
    if (!$aspid) {
        $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
        $pid = $unix->get_pid_from_file($pidfile);
        if ($unix->process_exists($pid, basename(__FILE__))) {
            $time = $unix->PROCCESS_TIME_MIN($pid);
            if ($GLOBALS["OUTPUT"]) {
                echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Already Artica task running PID {$pid} since {$time}mn\n";
            }
            return;
        }
        @file_put_contents($pidfile, getmypid());
    }
    $pid = PID_NUM();
    if ($unix->process_exists($pid)) {
        $timepid = $unix->PROCCESS_TIME_MIN($pid);
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Service already started {$pid} since {$timepid}Mn...\n";
        }
        return;
    }
    $EnableClamavDaemon = $sock->EnableClamavDaemon();
    if ($EnableClamavDaemon == 0) {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} service disabled (see sock->EnableClamavDaemon)\n";
        }
        return;
    }
    $php5 = $unix->LOCATE_PHP5_BIN();
    $nohup = $unix->find_program("nohup");
    $aa_complain = $unix->find_program('aa-complain');
    if (is_file($aa_complain)) {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} add clamd Profile to AppArmor..\n";
        }
        shell_exec("{$aa_complain} {$Masterbin} >/dev/null 2>&1");
    }
    @mkdir("/var/clamav", 0755, true);
    @mkdir("/var/run/clamav", 0755, true);
    @mkdir("/var/lib/clamav", 0755, true);
    @mkdir("/var/log/clamav", 0755, true);
    $unix->chown_func("clamav", "clamav", "/var/clamav");
    $unix->chown_func("clamav", "clamav", "/var/run/clamav");
    $unix->chown_func("clamav", "clamav", "/var/lib/clamav");
    $unix->chown_func("clamav", "clamav", "/var/log/clamav");
    $clamd_version = clamd_version();
    $cmd = "{$nohup} {$Masterbin} --config-file=/etc/clamav/clamd.conf >/dev/null 2>&1 &";
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} service version {$clamd_version}\n";
    }
    shell_exec($cmd);
    for ($i = 1; $i < 5; $i++) {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} waiting {$i}/5\n";
        }
        sleep(1);
        $pid = PID_NUM();
        if ($unix->process_exists($pid)) {
            break;
        }
    }
    $pid = PID_NUM();
    if ($unix->process_exists($pid)) {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Success PID {$pid}\n";
        }
        sleep(1);
        for ($i = 1; $i < 5; $i++) {
            if ($unix->is_socket("/var/run/clamav/clamav.sock")) {
                if ($GLOBALS["OUTPUT"]) {
                    echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Apply permissions on clamav.sock\n";
                }
                @chmod("/var/run/clamav/clamav.sock", 0777);
                break;
            } else {
                if ($GLOBALS["OUTPUT"]) {
                    echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} waiting for socket... {$i}/4\n";
                }
                sleep(1);
            }
        }
        if ($unix->is_socket("/var/run/clamav/clamav.sock")) {
            if ($GLOBALS["OUTPUT"]) {
                echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Apply permissions on clamav.sock\n";
            }
            @chmod("/var/run/clamav/clamav.sock", 0777);
        } else {
            if ($GLOBALS["OUTPUT"]) {
                echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} socket failed\n";
            }
//.........这里部分代码省略.........
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:101,代码来源:exec.clamd.php

示例7: SERVICE_START


//.........这里部分代码省略.........
    $socket = "/var/run/mysqld/mysqld.sock";
    $mysql_user = "mysql";
    @mkdir("/var/run/mysqld", 0755, true);
    @mkdir("/var/log/mysql", 0755, true);
    @mkdir($datadir, 0755, true);
    $dirs = $unix->dirdir("/var/lib/mysql");
    while (list($num, $directory) = each($dirs)) {
        echo "Starting......: " . date("H:i:s") . " MySQL, apply permissions on " . basename($directory) . "\n";
        $unix->chown_func("mysql", "mysql", "{$directory}/*");
    }
    $bind_address = ' --bind-address=127.0.0.1';
    $bind_address2 = "127.0.0.1";
    if ($MysqlBinAllAdresses == 1) {
        $bind_address2 = 'All (0.0.0.0)';
        $bind_address = ' --bind-address=0.0.0.0';
    }
    echo "Starting......: " . date("H:i:s") . " MySQL Pid path.......:{$pid_file}\n";
    echo "Starting......: " . date("H:i:s") . " datadir..............:{$datadir}\n";
    echo "Starting......: " . date("H:i:s") . " Log error............:{$MySQLLOgErrorPath}\n";
    echo "Starting......: " . date("H:i:s") . " socket...............:{$socket}\n";
    echo "Starting......: " . date("H:i:s") . " user.................:{$mysql_user}\n";
    echo "Starting......: " . date("H:i:s") . " LOGS ENABLED.........:{$EnableMysqlLog}\n";
    echo "Starting......: " . date("H:i:s") . " Daemon...............:{$mysqlbin}\n";
    echo "Starting......: " . date("H:i:s") . " Bind address.........:{$bind_address2}\n";
    echo "Starting......: " . date("H:i:s") . " Temp Dir.............:{$MySqlTmpDir}\n";
    echo "Starting......: " . date("H:i:s") . " innodb_force_recovery:{$innodb_force_recovery}\n";
    mysql_admin_mysql(1, "Starting MySQL service...", null, __FILE__, __LINE__);
    echo "Starting......: " . date("H:i:s") . " Settings permissions..\n";
    @mkdir("/var/run/mysqld", 0755, true);
    $unix->chown_func($mysql_user, $mysql_user, "/var/run/mysqld");
    $unix->chown_func($mysql_user, $mysql_user, "/var/log/mysql");
    $unix->chown_func($mysql_user, $mysql_user, $datadir);
    $unix->chown_func($mysql_user, $mysql_user, "{$datadir}/*");
    if ($unix->is_socket("/var/run/mysqld/mysqld.sock")) {
        @unlink("/var/run/mysqld/mysqld.sock");
    }
    if (is_file('/var/run/mysqld/mysqld.err')) {
        @unlink('/var/run/mysqld/mysqld.err');
    }
    if (is_file("/var/run/mysqld/mysqld.pid")) {
        $unix->chown_func($mysql_user, $mysql_user, "/var/run/mysqld/mysqld.pid");
    }
    if ($MysqlRemoveidbLogs == 1) {
        shell_exec('/bin/mv /var/lib/mysql/ib_logfile* /tmp/');
        $sock->SET_INFO('MysqlRemoveidbLogs', '0');
    }
    $logpathstring = " --log-error={$MySQLLOgErrorPath}";
    if ($EnableMysqlLog == 1) {
        $logpathstring = " --log=/var/log/mysql.log --log-slow-queries=/var/log/mysql-slow-queries.log --log-error={$MySQLLOgErrorPath} --log-warnings";
    }
    $toTouch[] = "/var/log/mysql-slow-queries.log";
    $toTouch[] = "/var/log/mysql.error";
    $toTouch[] = "/var/log/mysql.log";
    $toTouch[] = "/var/log/mysql.warn";
    while (list($num, $filename) = each($toTouch)) {
        if (!is_file($filename)) {
            @file_put_contents($filename, "#\n");
        }
        $unix->chown_func($mysql_user, $mysql_user, $filename);
    }
    echo "Starting......: " . date("H:i:s") . " MySQL Checking : {$datadir}/mysql/host.frm\n";
    if (!is_file("{$datadir}/mysql/host.frm")) {
        if (is_file($mysql_install_db)) {
            echo "Starting......: " . date("H:i:s") . " MySQL Installing default databases\n";
            shell_exec("{$mysql_install_db} --datadir=\"{$datadir}\"");
        }
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:67,代码来源:exec.mysql.start.php

示例8: restore_squidlogs

function restore_squidlogs($sourceDir)
{
    if (!($handle = opendir("{$sourceDir}/squidlogs"))) {
        echo "Failed open {$sourceDir}/squidlogs\n";
        return;
    }
    $password = null;
    $unix = new unix();
    if (!$unix->is_socket("/var/run/mysqld/squid-db.sock")) {
        system_admin_events("Error,/var/run/mysqld/squid-db.sock no such socket", __FUNCTION__, __FILE__, __LINE__);
        return false;
    }
    $sock = new sockets();
    $gunzip = $unix->find_program("gunzip");
    $mysql = $unix->find_program("mysql");
    $BLACKLIST = array();
    $nice = $unix->EXEC_NICE();
    $q = new mysql_squid_builder();
    $sock = new sockets();
    $BackupArticaRestoreNetwork = intval($sock->GET_INFO("BackupArticaRestoreNetwork"));
    if ($GLOBALS["NOT_RESTORE_NETWORK"]) {
        $BackupArticaRestoreNetwork = 0;
    }
    if ($BackupArticaRestoreNetwork == 0) {
        $BLACKLIST["dns_servers.gz"] = true;
        $BLACKLIST["dnsmasq_records.gz"] = true;
    }
    if ($q->mysql_password != null) {
        $password = " -p" . $unix->shellEscapeChars($q->mysql_password);
    }
    $prefix = trim("{$mysql} --force -S /var/run/mysqld/squid-db.sock -u {$q->mysql_admin}{$password} squidlogs");
    while (false !== ($filename = readdir($handle))) {
        if ($filename == ".") {
            continue;
        }
        if ($filename == "..") {
            continue;
        }
        if (isset($BLACKLIST[$filename])) {
            continue;
        }
        $SourceFile = "{$sourceDir}/squidlogs/{$filename}";
        if (is_dir($SourceFile)) {
            continue;
        }
        echo "Restoring Proxy database/{$filename}\n";
        $cmd = trim("{$nice} {$gunzip} -c {$SourceFile} |{$prefix}");
        system($cmd);
    }
}
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:50,代码来源:exec.backup.artica.php

示例9: Checks

function Checks()
{
    $GLOBALS["NORELOAD"] = true;
    $unix = new unix();
    if (!is_file("/usr/lib/x86_64-linux-gnu/autofs/lookup_ldap.so")) {
        build_progress_rs("{install} autofs-ldap", 15);
        $unix->DEBIAN_INSTALL_PACKAGE("autofs-ldap");
    }
    if (!is_file("/usr/lib/x86_64-linux-gnu/autofs/lookup_ldap.so")) {
        build_progress_rs("{install} autofs-ldap {failed}", 110);
        return;
    }
    if (!$unix->is_socket("/var/run/slapd/slapd.sock")) {
        build_progress_rs("{restarting_service} OpenLDAP", 15);
        system("/etc/init.d/slapd restart");
    } else {
        if ($GLOBALS["PROGRESS"]) {
            build_progress_rs("{restarting_service} OpenLDAP", 15);
            system("/etc/init.d/slapd restart");
        }
    }
    $curlftpfs = $unix->find_program("curlftpfs");
    $fusermount = $unix->find_program("fusermount");
    if (is_file($curlftpfs)) {
        if (!is_file("/sbin/mount.curl")) {
            build_progress_rs("/sbin/mount.curl", 15);
            $curlftpfsZ[] = "#! /bin/sh";
            $curlftpfsZ[] = "{$curlftpfs} \$1 \$2 -o \$5,disable_eprt";
            $curlftpfsZ[] = "";
            @file_put_contents("/sbin/mount.curl", @implode("\n", $curlftpfsZ));
            @chmod("/sbin/mount.curl", 0755);
        }
        if (!is_file("/sbin/umount.curl")) {
            build_progress_rs("/sbin/umount.curl", 15);
            $curlftpfsZ = array();
            $curlftpfsZ[] = "#! /bin/sh";
            $curlftpfsZ[] = "{$fusermount} -u \$1";
            $curlftpfsZ[] = "";
            @file_put_contents("/sbin/umount.curl", @implode("\n", $curlftpfsZ));
            @chmod("/sbin/umount.curl", 0755);
        }
    }
    $ldap = new clladp();
    $data = "<?xml version=\"1.0\" ?>\n         <autofs_ldap_sasl_conf\n                 usetls=\"no\"\n                 tlsrequired=\"no\"\n                 authrequired=\"yes\"\n                 authtype=\"PLAIN\"\n                 user=\"{$ldap->ldap_admin}\"\n                 secret=\"{$ldap->ldap_password}\"\n         />";
    @file_put_contents("/etc/autofs_ldap_auth.conf", $data);
    if (is_file("/etc/autofs_ldap_auth.conf")) {
        @chmod("/etc/autofs_ldap_auth.conf", 0600);
        @chown("/etc/autofs_ldap_auth.conf", "root");
        @chgrp("/etc/autofs_ldap_auth.conf", "root");
    }
    build_progress_rs("{checking_configuration}", 15);
    $auto = new autofs();
    build_progress_rs("{checking_configuration}", 20);
    autofs_default();
    build_progress_rs("{checking_configuration}", 25);
    Autocount();
    build_progress_rs("{checking_configuration}", 30);
    davfs();
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:59,代码来源:exec.AutoFS.php

示例10: start


//.........这里部分代码省略.........
            echo "fuser: ->\"{$line}\"\n";
        }
        if (preg_match("#tcp:\\s+(.+)#", $line, $re)) {
            $FUSERS = explode(" ", $re[1]);
        }
    }
    if (count($FUSERS) > 0) {
        while (list($key, $pid) = each($FUSERS)) {
            $pid = trim($pid);
            if (!is_numeric($pid)) {
                continue;
            }
            if ($GLOBALS["OUTPUT"]) {
                echo "Starting......: " . date("H:i:s") . " [INIT]: killing {$pid} PID that listens 80\n";
            }
            unix_system_kill_force($pid);
        }
    }
    exec("{$fuser} 443/tcp 2>&1", $results);
    while (list($key, $line) = each($results)) {
        if ($GLOBALS["VERBOSE"]) {
            echo "fuser: ->\"{$line}\"\n";
        }
        if (preg_match("#tcp:\\s+(.+)#", $line, $re)) {
            $FUSERS = explode(" ", $re[1]);
        }
    }
    if (count($FUSERS) > 0) {
        while (list($key, $pid) = each($FUSERS)) {
            $pid = trim($pid);
            if (!is_numeric($pid)) {
                continue;
            }
            if ($GLOBALS["OUTPUT"]) {
                echo "Starting......: " . date("H:i:s") . " [INIT]: killing {$pid} PID that listens 443\n";
            }
            unix_system_kill_force($pid);
        }
    }
    $php5 = $unix->LOCATE_PHP5_BIN();
    if ($unix->is_socket("/var/run/nginx-authenticator.sock")) {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: Remove authenticator socket\n";
        }
        @unlink("/var/run/nginx-authenticator.sock");
    }
    if (is_file("/var/run/nginx-authenticator.sock")) {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: Remove authenticator socket\n";
        }
        @unlink("/var/run/nginx-authenticator.sock");
    }
    nginx_mime_types();
    $EnableArticaInNGINX = $sock->GET_INFO("EnableArticaInNGINX");
    if (!is_numeric($EnableArticaInNGINX)) {
        $EnableArticaInNGINX = 0;
    }
    @unlink("/etc/nginx/conf.d/default.conf");
    if ($EnableArticaInNGINX == 1) {
        build_default_asArtica();
    }
    $cmd = "{$nginx} -c /etc/nginx/nginx.conf";
    if ($GLOBALS["VERBOSE"]) {
        echo "{$cmd}\n";
    }
    shell_exec($cmd);
    for ($i = 0; $i < 6; $i++) {
        $pid = PID_NUM();
        if ($unix->process_exists($pid)) {
            break;
        }
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: Nginx service waiting {$i}/6...\n";
        }
        sleep(1);
    }
    $pid = PID_NUM();
    if ($unix->process_exists($pid)) {
        nginx_admin_mysql(2, "Nginx Web service success to start [action=info]", null, __FILE__, __LINE__);
        @unlink($GLOBALS["pidStampReload"]);
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: Nginx service Success service started pid:{$pid}...\n";
        }
        $php5 = $unix->LOCATE_PHP5_BIN();
        shell_exec("{$nohup} {$php5} /usr/share/artica-postfix/exec.php-fpm.php --start >/dev/null 2>&1 &");
        shell_exec("{$nohup} {$php} /usr/share/artica-postfix/exec.nginx.wizard.php --avail-status --force >/dev/null 2>&1 &");
        return;
    }
    nginx_admin_mysql(0, "Nginx Web service failed to start [action=info]", null, __FILE__, __LINE__);
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: Nginx service failed...\n";
    }
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: {$cmd}\n";
    }
    $cmd = "{$nohup} {$php5} /usr/share/artica-postfix/exec.web-community-filter.php --register-lic >/dev/null 2>&1 &";
    if ($GLOBALS["VERBOSE"]) {
        echo "{$cmd}\n";
    }
}
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:101,代码来源:exec.nginx.php

示例11: IS_APP_SQUIDDB_INSTALLED

function IS_APP_SQUIDDB_INSTALLED()
{
    $unix = new unix();
    if ($unix->is_socket("/var/run/mysqld/squid-db.sock")) {
        writelogs_framework("/var/run/mysqld/squid-db.sock socket OK", __FUNCTION__, __FILE__, __LINE__);
        echo "<articadatascgi>TRUE</articadatascgi>";
        return;
    }
    writelogs_framework("/var/run/mysqld/squid-db.sock socket FALSE", __FUNCTION__, __FILE__, __LINE__);
    if (is_dir("/opt/squidsql/data/squidlogs")) {
        writelogs_framework("/opt/squidsql/data/squidlogs OK", __FUNCTION__, __FILE__, __LINE__);
        echo "<articadatascgi>TRUE</articadatascgi>";
        return;
    }
    writelogs_framework("/opt/squidsql/data/squidlogs no such dir", __FUNCTION__, __FILE__, __LINE__);
    echo "<articadatascgi>FALSE</articadatascgi>";
}
开发者ID:articatech,项目名称:artica,代码行数:17,代码来源:squid.php

示例12: build_phpmyadmin

function build_phpmyadmin()
{
    if (!is_dir("/usr/share/phpmyadmin/themes")) {
        echo "[INFO] phpmyadmin not detected\n";
    }
    $unix = new unix();
    $hostname = $unix->hostname_g();
    $blowfish_secret = md5($hostname);
    echo "[INFO] Starting building phpmyadmin\n";
    $f[] = "<?php";
    $f[] = "/* vim: set expandtab sw=4 ts=4 sts=4: */";
    $f[] = "/**";
    $f[] = " * phpMyAdmin sample configuration, you can use it as base for";
    $f[] = " * manual configuration. For easier setup you can use setup/";
    $f[] = " *";
    $f[] = " * All directives are explained in documentation in the doc/ folder";
    $f[] = " * or at <http://docs.phpmyadmin.net/>.";
    $f[] = " *";
    $f[] = " * @package PhpMyAdmin";
    $f[] = " */";
    $f[] = "";
    $f[] = "/*";
    $f[] = " * This is needed for cookie based authentication to encrypt password in";
    $f[] = " * cookie";
    $f[] = " */";
    $f[] = "\$cfg['blowfish_secret'] = '{$blowfish_secret}'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */";
    $f[] = "";
    $f[] = "/*";
    $f[] = " * Servers configuration";
    $f[] = " */";
    $f[] = "\$i = 0;";
    $f[] = "";
    $f[] = "/*";
    $f[] = " * First server";
    $f[] = " */";
    $f[] = "/* Authentication type */";
    $f[] = "/* Server parameters */";
    $f[] = "\$i++;";
    $f[] = "\$cfg['Servers'][\$i]['auth_type'] = 'cookie';";
    $f[] = "\$cfg['Servers'][\$i]['verbose'] = 'Local MySQL';";
    $f[] = "\$cfg['Servers'][\$i]['socket'] = '/var/run/mysqld/mysqld.sock';";
    $f[] = "\$cfg['Servers'][\$i]['host'] = 'localhost';";
    $f[] = "\$cfg['Servers'][\$i]['connect_type'] = 'socket';";
    $f[] = "\$cfg['Servers'][\$i]['compress'] = false;";
    $f[] = "\$cfg['Servers'][\$i]['AllowNoPassword'] = true;";
    $f[] = "\$cfg['Servers'][\$i]['nopassword'] = true;";
    $f[] = "\$cfg['Servers'][\$i]['AllowRoot'] = true;";
    $f[] = "\$cfg['Servers'][\$i]['AllowNoPasswordRoot'] = true;";
    if ($unix->is_socket("/var/run/mysqld/squid-db.sock")) {
        $f[] = "\$i++;";
        $f[] = "\$cfg['Servers'][\$i]['auth_type'] = 'cookie';";
        $f[] = "\$cfg['Servers'][\$i]['verbose'] = 'Proxy MySQL Statistics';";
        $f[] = "\$cfg['Servers'][\$i]['socket'] = '/var/run/mysqld/squid-db.sock';";
        $f[] = "\$cfg['Servers'][\$i]['host'] = 'localhost';";
        $f[] = "\$cfg['Servers'][\$i]['connect_type'] = 'socket';";
        $f[] = "\$cfg['Servers'][\$i]['compress'] = false;";
        $f[] = "\$cfg['Servers'][\$i]['AllowNoPassword'] = true;";
        $f[] = "\$cfg['Servers'][\$i]['nopassword'] = true;";
        $f[] = "\$cfg['Servers'][\$i]['AllowRoot'] = true;";
        $f[] = "\$cfg['Servers'][\$i]['AllowNoPasswordRoot'] = true;";
    }
    $f[] = "";
    $f[] = "/*";
    $f[] = " * phpMyAdmin configuration storage settings.";
    $f[] = " */";
    $f[] = "";
    $f[] = "\$i++;";
    $f[] = "/* User used to manipulate with storage */";
    $f[] = "// \$cfg['Servers'][\$i]['controlhost'] = '';";
    $f[] = "// \$cfg['Servers'][\$i]['controlport'] = '';";
    $f[] = "// \$cfg['Servers'][\$i]['controluser'] = 'pma';";
    $f[] = "// \$cfg['Servers'][\$i]['controlpass'] = 'pmapass';";
    $f[] = "";
    $f[] = "/* Storage database and tables */";
    $f[] = "\$cfg['Servers'][\$i]['pmadb'] = 'phpmyadmin';";
    $f[] = "\$cfg['Servers'][\$i]['bookmarktable'] = 'pma__bookmark';";
    $f[] = "\$cfg['Servers'][\$i]['relation'] = 'pma__relation';";
    $f[] = "\$cfg['Servers'][\$i]['table_info'] = 'pma__table_info';";
    $f[] = "\$cfg['Servers'][\$i]['table_coords'] = 'pma__table_coords';";
    $f[] = "\$cfg['Servers'][\$i]['pdf_pages'] = 'pma__pdf_pages';";
    $f[] = "\$cfg['Servers'][\$i]['column_info'] = 'pma__column_info';";
    $f[] = "\$cfg['Servers'][\$i]['history'] = 'pma__history';";
    $f[] = "\$cfg['Servers'][\$i]['table_uiprefs'] = 'pma__table_uiprefs';";
    $f[] = "\$cfg['Servers'][\$i]['tracking'] = 'pma__tracking';";
    $f[] = "\$cfg['Servers'][\$i]['designer_coords'] = 'pma__designer_coords';";
    $f[] = "\$cfg['Servers'][\$i]['userconfig'] = 'pma__userconfig';";
    $f[] = "\$cfg['Servers'][\$i]['recent'] = 'pma__recent';";
    $f[] = "\$cfg['Servers'][\$i]['favorite'] = 'pma__favorite';";
    $f[] = "\$cfg['Servers'][\$i]['users'] = 'pma__users';";
    $f[] = "\$cfg['Servers'][\$i]['usergroups'] = 'pma__usergroups';";
    $f[] = "\$cfg['Servers'][\$i]['navigationhiding'] = 'pma__navigationhiding';";
    $f[] = "\$cfg['Servers'][\$i]['savedsearches'] = 'pma__savedsearches';";
    $f[] = "/* Contrib / Swekey authentication */";
    $f[] = "// \$cfg['Servers'][\$i]['auth_swekey_config'] = '/etc/swekey-pma.conf';";
    $f[] = "";
    $f[] = "/*";
    $f[] = " * End of servers configuration";
    $f[] = " */";
    $f[] = "";
    $f[] = "/*";
//.........这里部分代码省略.........
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:101,代码来源:exec.phpmyadmin.php

示例13: start

function start($aspid = false)
{
    $unix = new unix();
    $scriptlog = null;
    if ($GLOBALS["BYSCRIPT"]) {
        $scriptlog = " by init.d script";
    }
    if (is_file("/etc/artica-postfix/FROM_ISO")) {
        if ($unix->file_time_min("/etc/artica-postfix/FROM_ISO") < 1) {
            return;
        }
    }
    if (!$aspid) {
        $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
        $pid = $unix->get_pid_from_file($pidfile);
        if ($unix->process_exists($pid, basename(__FILE__))) {
            $time = $unix->PROCCESS_TIME_MIN($pid);
            if ($GLOBALS["OUTPUT"]) {
                echo "Starting......: " . date("H:i:s") . " [INIT]: Already Artica task running PID {$pid} since {$time}mn\n";
            }
            return;
        }
        @file_put_contents($pidfile, getmypid());
    }
    $pid = LIGHTTPD_PID();
    @mkdir("/usr/share/artica-postfix/ressources/web", 0755, true);
    if (!is_dir("/usr/share/artica-postfix/ressources/web")) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: Framework service Warning !!! /usr/share/artica-postfix/ressources/web (permission denied !)\n";
    }
    if ($unix->process_exists($pid)) {
        if (!$unix->is_socket("/usr/share/artica-postfix/ressources/web/framework.sock")) {
            if ($GLOBALS["OUTPUT"]) {
                echo "Starting......: " . date("H:i:s") . " [INIT]: Framework service framework.sock no such socket, stop framework\n";
            }
            stop(true);
        } else {
            $timepid = $unix->PROCCESS_TIME_MIN($pid);
            if ($GLOBALS["OUTPUT"]) {
                echo "Starting......: " . date("H:i:s") . " [INIT]: Framework Service already started {$pid} since {$timepid}Mn...\n";
            }
            return;
        }
    }
    $nohup = $unix->find_program("nohup");
    $php5 = $unix->LOCATE_PHP5_BIN();
    $lighttpd_bin = $unix->find_program("lighttpd");
    if (!is_file($lighttpd_bin)) {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: Framework service lighttpd not found..\n";
        }
        return;
    }
    @mkdir("/var/run/lighttpd", 0755, true);
    $cmd = "{$nohup} {$php5} /usr/share/artica-postfix/exec.web-community-filter.php --register-lic >/dev/null 2>&1 &";
    if ($GLOBALS["VERBOSE"]) {
        echo "{$cmd}\n";
    }
    shell_exec($cmd);
    buildConfig();
    $cmd = "{$lighttpd_bin} -f /etc/artica-postfix/framework.conf";
    if ($GLOBALS["VERBOSE"]) {
        echo "{$cmd}\n";
    }
    shell_exec($cmd);
    for ($i = 0; $i < 6; $i++) {
        $pid = LIGHTTPD_PID();
        if ($unix->process_exists($pid)) {
            if (!$unix->is_socket("/usr/share/artica-postfix/ressources/web/framework.sock")) {
                if ($GLOBALS["OUTPUT"]) {
                    echo "Starting......: " . date("H:i:s") . " [INIT]: Framework service waiting framework.sock\n";
                }
            } else {
                break;
            }
        }
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: Framework service waiting {$i}/6...\n";
        }
        sleep(1);
    }
    $pid = LIGHTTPD_PID();
    if ($unix->process_exists($pid)) {
        FrmToSyslog("Success service started pid:{$pid}{$scriptlog}");
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: Framework service apply permissions on framework.sock\n";
        }
        @chmod("/usr/share/artica-postfix/ressources/web/framework.sock", 0777);
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: Framework service apply permissions on Settings direcotry\n";
        }
        $unix->chmod_alldirs(0755, "/etc/artica-postfix/settings/Daemons/*");
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: Framework Success service started pid:{$pid}...\n";
        }
    } else {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: Framework service failed...\n";
        }
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$cmd}\n";
//.........这里部分代码省略.........
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:101,代码来源:exec.framework.php

示例14: start

function start()
{
    $unix = new unix();
    $pidfile = "/var/run/squid-stats-central.pid";
    $timefile = $GLOBALS["TIMEFILE"];
    $sock = new sockets();
    if (!$unix->is_socket("/var/run/mysqld/squid-db.sock")) {
        stats_admin_events(0, "MySQL server not ready, delay task...", null, __FILE__, __LINE__);
        $unix->THREAD_COMMAND_SET($unix->LOCATE_PHP5_BIN() . " " . __FILE__);
        die;
    }
    $WizardStatsApplianceDisconnected = intval($sock->GET_INFO("WizardStatsApplianceDisconnected"));
    if ($WizardStatsApplianceDisconnected == 1) {
        $export_stamp = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".EXPORT.time";
        $export_time = $unix->file_time_min($export_stamp);
        if ($export_time > 60) {
            start_export();
            export_push();
            @unlink($export_stamp);
            @file_put_contents($export_stamp, time());
        }
        die;
    }
    if (!$GLOBALS["NOTIME"]) {
        @unlink($timefile);
        @file_put_contents($timefile, time());
    }
    stats_admin_events(2, " **** STARTING Statistics Engine ****", null, __FILE__, __LINE__);
    percentage("**** STARTING Statistics Engine ****", 0);
    percentage("**** Importing tables ****", 2);
    start_import(true);
    $sock->SQUID_DISABLE_STATS_DIE();
    $pid = @file_get_contents($pidfile);
    if (!$GLOBALS["FORCE"]) {
        if ($pid < 100) {
            $pid = null;
        }
        $unix = new unix();
        if ($unix->process_exists($pid, basename(__FILE__))) {
            if ($GLOBALS["VERBOSE"]) {
                echo "Already executed pid {$pid}\n";
            }
            return;
        }
        $mypid = getmypid();
        @file_put_contents($pidfile, $mypid);
    }
    $DisableArticaProxyStatistics = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/DisableArticaProxyStatistics"));
    if ($DisableArticaProxyStatistics == 1) {
        percentage("{disabled}", 100);
        stats_admin_events(1, "100%) Statistics are disabled");
        StampDone(1000, "Statistics are disabled");
        return;
    }
    @unlink("/var/run/squid-stats-central.stop");
    if (!$GLOBALS["NOTIME"]) {
        @unlink($timefile);
        @file_put_contents($timefile, time());
    }
    $tSource = time();
    $php5 = $unix->LOCATE_PHP5_BIN();
    $nohup = $unix->find_program("nohup");
    $EXEC_NICE = $unix->EXEC_NICE();
    $Prefix = "/usr/share/artica-postfix";
    $q = new mysql_squid_builder();
    $GLOBALS["Q"] = $q;
    @mkdir("/home/artica/categories_databases", 0755, true);
    $unix->chmod_func(0755, "/home/artica/categories_databases/*");
    $unix->chmod_func(0755, "/home/artica/categories_perso/*");
    if (!StampOK(5)) {
        percentage("Reloading categories Daemon...", 2);
        shell_exec("/etc/init.d/ufdbcat reload");
    }
    $t = time();
    if (!StampOK(10)) {
        percentage("Purge old days", 1);
        shell_exec(trim("{$EXEC_NICE} {$php5} {$Prefix}/exec.squidlogs.purge.php"));
        stats_admin_events(2, "1%) Purge days took:" . $unix->distanceOfTimeInWords($t, time()), null, __FILE__, __LINE__);
        StampDone(10, "Purge old days");
    }
    if (!StampOK(20)) {
        percentage("Compile personal tables...", 2);
        shell_exec(trim("{$EXEC_NICE} {$php5} {$Prefix}/exec.squid.compile_category_perso.php"));
        Step2();
        StampDone(20, "Compile personal tables");
    }
    $t = time();
    if (!StampOK(30)) {
        percentage("Running Quota day", 2);
        shell_exec(trim("{$EXEC_NICE} {$php5} {$Prefix}/exec.squid.stats.quotaday.php"));
        stats_admin_events(2, "2%) Quota day executed took:" . $unix->distanceOfTimeInWords($t, time()), null, __FILE__, __LINE__);
        StampDone(30, "Running Quota day");
    }
    if (SquidStatisticsTasksOverTime()) {
        stats_admin_events(1, "Statistics overtime... Aborting", null, __FILE__, __LINE__);
        return;
    }
    if (!StampOK(40)) {
        percentage("Running Youtube Hours", 2);
        shell_exec(trim("{$EXEC_NICE} {$php5} {$Prefix}/exec.squid.stats.youtube.days.php --schedule-id={$GLOBALS["SCHEDULE_ID"]}"));
//.........这里部分代码省略.........
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:101,代码来源:exec.squid.stats.central.php

示例15: start

function start($aspid = false)
{
    $sock = new sockets();
    $unix = new unix();
    $GLOBALS["CLASS_UNIX"] = $unix;
    if (!$aspid) {
        $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
        $pid = $unix->get_pid_from_file($pidfile);
        if ($unix->process_exists($pid, basename(__FILE__))) {
            $time = $unix->PROCCESS_TIME_MIN($pid);
            if ($GLOBALS["OUTPUT"]) {
                echo "Starting......: " . date("H:i:s") . " [INIT]: Already task running PID {$pid} since {$time}mn\n";
            }
            return;
        }
        @file_put_contents($pidfile, getmypid());
    }
    $MailArchiverEnabled = $sock->GET_INFO("MailArchiverEnabled");
    $MailArchiverToMySQL = $sock->GET_INFO("MailArchiverToMySQL");
    $MailArchiverToMailBox = $sock->GET_INFO("MailArchiverToMailBox");
    $MailArchiverMailBox = $sock->GET_INFO("MailArchiverMailBox");
    $MailArchiverUsePerl = $sock->GET_INFO("MailArchiverUsePerl");
    if (!is_numeric($MailArchiverEnabled)) {
        $MailArchiverEnabled = 0;
    }
    if (!is_numeric($MailArchiverToMySQL)) {
        $MailArchiverToMySQL = 1;
    }
    if (!is_numeric($MailArchiverUsePerl)) {
        $MailArchiverUsePerl = 1;
    }
    if ($GLOBALS["VERBOSE"]) {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: VERBOSE MODE\n";
        }
    }
    if ($MailArchiverEnabled == 0) {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: Mail Archiver is disabled...\n";
        }
        return;
    }
    if ($MailArchiverUsePerl == 0) {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: Mail Archiver (Perl method) is disabled...\n";
        }
        return;
    }
    $pid = mailarchive_pid();
    if ($unix->process_exists($pid)) {
        $time = $unix->PROCCESS_TIME_MIN($pid);
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: Mail Archiver (Perl method) already running pid {$pid} since {$time}mn...\n";
        }
        return;
    }
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: Mail Archiver (Perl method)...\n";
    }
    $usersMenus = new usersMenus();
    $OS = $usersMenus->LinuxDistriCode;
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: Mail Archiver (Perl method) on {$OS}...\n";
    }
    if ($OS == "DEBIAN" or $OS == "UBUNTU") {
        CheckPerlDebian();
    }
    $mhonarc = $unix->find_program("mhonarc");
    if (!is_file($mhonarc)) {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: Mail Archiver (Perl method) failed mhonarc not such binary !!!\n";
        }
        return;
    }
    $nohup = $unix->find_program("nohup");
    @mkdir("/var/spool/mail-rtt-backup", 0755, true);
    @mkdir("/var/run/maildump", 0777, true);
    @unlink("/var/run/maildump/maildump.socket");
    $cmd = "{$nohup} /usr/share/artica-postfix/bin/milter_archiver.pl >/dev/null 2>&1 &";
    shell_exec($cmd);
    for ($i = 0; $i < 5; $i++) {
        sleep(1);
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: Mail Archiver (Perl method) waiting {$i}/5...\n";
        }
        $pid = mailarchive_pid();
        if ($unix->process_exists($pid)) {
            if ($GLOBALS["OUTPUT"]) {
                echo "Starting......: " . date("H:i:s") . " [INIT]: Mail Archiver (Perl method) Success running with pid {$pid}...\n";
            }
            break;
        }
    }
    $pid = mailarchive_pid();
    if ($unix->process_exists($pid)) {
        for ($i = 0; $i < 5; $i++) {
            if ($unix->is_socket("/var/run/maildump/maildump.socket")) {
                if ($GLOBALS["OUTPUT"]) {
                    echo "Starting......: " . date("H:i:s") . " [INIT]: Mail Archiver permission on maildump.socket done\n";
                }
//.........这里部分代码省略.........
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:101,代码来源:exec.mailarchiver.php


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