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


PHP unix::distanceOfTimeInWords方法代码示例

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


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

示例1: restart_lighttpd

function restart_lighttpd()
{
    $t = time();
    exec("/etc/init.d/artica-webinterface restart 2>&1", $results);
    $unix = new unix();
    $took = $unix->distanceOfTimeInWords($t, time());
    system_admin_events("Restart Web interface service done took:{$took}\n" . @implode("\n", $results), __FUNCTION__, __FILE__, __LINE__, "system");
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:8,代码来源:exec.lighttpd.nets.php

示例2: start

function start()
{
    $pidtime = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
    $pidFile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    $unix = new unix();
    $pid = $unix->get_pid_from_file($pidFile);
    if ($unix->process_exists($pid)) {
        return;
    }
    @file_put_contents($pidFile, getmypid());
    $time = $unix->file_time_min($pidtime);
    if ($time < 5) {
        return;
    }
    @file_put_contents($pidtime, time());
    $free = $unix->find_program("free");
    $echo = $unix->find_program("echo");
    $sync = $unix->find_program("sync");
    $swapoff = $unix->find_program("swapoff");
    $swapon = $unix->find_program("swapon");
    exec("{$free} 2>&1", $results);
    $used = 0;
    $total = 0;
    while (list($num, $ligne) = each($results)) {
        if (preg_match("#Swap:\\s+([0-9]+)\\s+([0-9]+)\\s+([0-9]+)#", $ligne, $re)) {
            $total = $re[1];
            $used = $re[2];
        }
    }
    if (!is_numeric($total)) {
        return;
    }
    if ($total == 0) {
        return;
    }
    if ($used == 0) {
        return;
    }
    if ($total == $used) {
        return;
    }
    $tot1 = $used / $total;
    $tot1 = $tot1 * 100;
    if ($GLOBALS["VERBOSE"]) {
        echo "Swap:{$used}/{$total} - {$tot1}\n";
    }
    $perc = round($tot1);
    if ($GLOBALS["VERBOSE"]) {
        echo "Swap:{$used}/{$total} {$perc}%\n";
    }
    $t = time();
    $GLOBALS["ALL_SCORES"]++;
    shell_exec("{$swapoff} -a && {$swapon} -a");
    $usedTXT = FormatBytes($used);
    $report = $unix->ps_mem_report();
    $distance = $unix->distanceOfTimeInWords($t, time(), true);
    squid_admin_mysql(0, "System swap exceed rule: {$perc}%", "Used {$usedTXT}\nSystem cache was flushed took {$distance}\nThis means you did have enough memory for this computer.\n{$report}", __FILE__, __LINE__);
}
开发者ID:articatech,项目名称:artica,代码行数:58,代码来源:exec.squid.swapoff.php

示例3: mailboxes_ou_lang

function mailboxes_ou_lang($ou)
{
    $unix = new unix();
    $sock = new sockets();
    $t = time();
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    $unix = new unix();
    $me = basename(__FILE__);
    if ($unix->process_exists(@file_get_contents($pidfile), $me)) {
        if ($GLOBALS["VERBOSE"]) {
            echo " --> Already executed.. " . @file_get_contents($pidfile) . " aborting the process\n";
        }
        system_admin_events("--> Already executed.. " . @file_get_contents($pidfile) . " aborting the process", __FUNCTION__, __FILE__, __LINE__, "zarafa");
        die;
    }
    @file_put_contents($pidfile, getmypid());
    $oumd5 = md5(strtolower(trim($ou)));
    $OuDefaultLang = $sock->GET_INFO("zarafaMBXLang{$oumd5}");
    if ($OuDefaultLang == null) {
        system_admin_events("`{$ou}` no such default language, aborting", __FUNCTION__, __FILE__, __LINE__, "zarafa");
        return;
    }
    $ldap = new clladp();
    $members = $ldap->hash_users_ou($ou);
    $CountMembers = count($members);
    system_admin_events("{$ou} {$CountMembers} to change to {$OuDefaultLang}", __FUNCTION__, __FILE__, __LINE__, "zarafa");
    $c = 0;
    while (list($uid, $name) = each($members)) {
        $ct = new user($uid);
        if ($ct->zarafaMbxLang == null) {
            $ct->SaveZarafaMbxLang($OuDefaultLang);
            $c++;
            $sock->getFrameWork("cmd.php?zarafa-admin=yes");
            $sock->getFrameWork("zarafa.php?zarafa-user-create-store={$uid}&lang={$OuDefaultLang}");
            $sock->getFrameWork("zarafa.php?foldersnames=yes&uid={$uid}&lang={$OuDefaultLang}");
        }
    }
    $took = $unix->distanceOfTimeInWords($t, time(), true);
    system_admin_events("{$ou} {$c}/{$CountMembers} changed to {$OuDefaultLang} done took: {$took}", __FUNCTION__, __FILE__, __LINE__, "zarafa");
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:40,代码来源:exec.zarafa-migrate.php

示例4: Compile

function Compile()
{
    $unix = new unix();
    $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;
    }
    $t = time();
    $q = new mysql_squid_builder();
    echo "**** LIST_TABLES_CATEGORIES_PERSO *****\n";
    $tablescat = $q->LIST_TABLES_CATEGORIES_PERSO();
    $source_dir = "/home/artica/categories_perso";
    if (count($tablescat) == 0) {
        echo "tablescat = 0\n";
        return;
    }
    $i = 0;
    while (list($tablename, $ligne) = each($tablescat)) {
        if (preg_match("#^categoryuris#", $tablename)) {
            continue;
        }
        $COUNT_ROWS = $q->COUNT_ROWS($tablename);
        if ($COUNT_ROWS == 0) {
            continue;
        }
        echo " **** {$tablename} {$COUNT_ROWS} ITEMS *****\n";
        $Dir = "{$source_dir}/{$tablename}";
        @mkdir("{$Dir}", 0777, true);
        echo "{$tablename}: Building {$Dir}/domains";
        @unlink("{$Dir}/domains");
        @chmod("{$Dir}/domains", 0777);
        $sql = "SELECT pattern FROM {$tablename} WHERE enabled=1 ORDER BY pattern INTO OUTFILE '{$Dir}/domains' LINES TERMINATED BY '\n';";
        $q->QUERY_SQL($sql);
        if (!$q->ok) {
            echo "{$tablename}: {$q->mysql_error}\n";
            continue;
        }
        $handle = @fopen("{$Dir}/domains", "r");
        if (!$handle) {
            echo "Failed to open file {$Dir}/domains\n";
            continue;
        }
        $DestDB = "{$Dir}/domains.db";
        @unlink($DestDB);
        $db_desttmp = dba_open($DestDB, "n", "db4");
        if (!$db_desttmp) {
            echo "Unable to Create {$DestDB}\n";
            continue;
        }
        dba_close($db_desttmp);
        $db_dest = dba_open($DestDB, "w", "db4");
        @chmod($DestDB, 0777);
        if (!$db_dest) {
            echo "Unable to open for `writing` \"{$DestDB}\"\n";
            continue;
        }
        while (!feof($handle)) {
            $www = trim(fgets($handle, 4096));
            $www = trim(str_replace('"', "", $www));
            if ($www == null) {
                continue;
            }
            $www = strtolower($www);
            if (!dba_insert("{$www}", "yes", $db_dest)) {
                echo "dba_insert({$www},yes... false\n";
                continue;
            }
        }
        $i++;
        dba_close($db_dest);
        @fclose($handle);
        @unlink("{$Dir}/domains");
    }
    stats_admin_events(2, "1%) {$i} Personal tables compiled took:" . $unix->distanceOfTimeInWords($t, time()), null, __FILE__, __LINE__);
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:79,代码来源:exec.squid.compile_category_perso.php

示例5: tables_hours

function tables_hours()
{
    $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 "timefile={$timefile}\n";
    }
    $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;
        }
        $timeexec = $unix->file_time_min($timefile);
        if ($timeexec < 60) {
            if ($GLOBALS["VERBOSE"]) {
                echo "Only each 60mn - current {$timeexec}mn, use --force to bypass\n";
            }
            return;
        }
        $mypid = getmypid();
        @file_put_contents($pidfile, $mypid);
    }
    @unlink($timefile);
    @file_put_contents($timefile, time());
    $sock = new sockets();
    $GLOBALS["Q"] = new mysql_squid_builder();
    $prefix = date("YmdH");
    $currenttable = "ngixattck_{$prefix}";
    if ($GLOBALS["VERBOSE"]) {
        echo "Current Table: {$currenttable}\n";
    }
    $tablesBrutes = $GLOBALS["Q"]->LIST_TABLES_NGINX_BLOCKED_RT();
    while (list($tablename, $none) = each($tablesBrutes)) {
        if ($tablename == $currenttable) {
            if ($GLOBALS["VERBOSE"]) {
                echo "Skip table: {$tablename}\n";
            }
            continue;
        }
        $t = time();
        if ($GLOBALS["VERBOSE"]) {
            echo "_table_hours_perform({$tablename})\n";
        }
        if (_table_hours_perform($tablename)) {
            $took = $unix->distanceOfTimeInWords($t, time());
            if ($GLOBALS["VERBOSE"]) {
                echo "Remove table: {$tablename}\n";
            }
            $GLOBALS["Q"]->QUERY_SQL("DROP TABLE `{$tablename}`");
            if (system_is_overloaded()) {
                ufdbguard_admin_events("Fatal: Overloaded system: {$GLOBALS["SYSTEM_INTERNAL_LOAD"]} sleeping stopping function", __FUNCTION__, __FILE__, __LINE__, "stats");
                return true;
            }
        }
    }
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:64,代码来源:exec.nginx.stats.hours.php

示例6: repair_action

function repair_action($database, $tablename, $expl)
{
    $unix = new unix();
    $q = new mysql();
    if (preg_match("#Can.*?t find file#", $expl)) {
        system_admin_events("{$tablename} is destroyed, remove it..", __FUNCTION__, __FILE__, __LINE__);
        echo "Removing table {$database}/{$tablename}\n";
        $q->DELETE_TABLE($tablename, $database);
        return;
    }
    if (preg_match("#is marked as crashed#", $expl)) {
        $results = array();
        $t = time();
        if (is_file("/var/lib/mysql/{$database}/{$tablename}.TMD")) {
            @copy("/var/lib/mysql/{$database}/{$tablename}.TMD", "/var/lib/mysql/{$database}/{$tablename}.TMD-" . time());
            @unlink("/var/lib/mysql/{$database}/{$tablename}.TMD");
        }
        $myisamchk = $unix->find_program("myisamchk");
        $cmd = "{$myisamchk} -r /var/lib/mysql/{$database}/{$tablename}.MYI";
        if ($GLOBALS["VERBOSE"]) {
            echo "{$cmd}\n";
        }
        exec($cmd, $results);
        $took = $unix->distanceOfTimeInWords($t, time());
        system_admin_events("{$tablename} repaired took: {$took}", @implode("\r\n", $results), __FUNCTION__, __FILE__, __LINE__);
        return;
    }
    if ($GLOBALS["VERBOSE"]) {
        echo "{$tablename} nothing to do...\n";
    }
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:31,代码来源:exec.mysql.clean.php

示例7: restore_id

function restore_id($storeid)
{
    $unix = new unix();
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".{$storeid}.pid";
    $pid = @file_get_contents("{$pidfile}");
    if ($unix->process_exists($pid, basename(__FILE__))) {
        events("Process {$pid} already exists...aborting");
        die;
    }
    @file_put_contents($pidfile, getmypid());
    include_once dirname(__FILE__) . "/ressources/class.mysql.syslogs.inc";
    $sock = new sockets();
    $SargOutputDir = $sock->GET_INFO("SargOutputDir");
    if ($SargOutputDir == null) {
        $SargOutputDir = "/var/www/html/squid-reports";
    }
    $sarg_bin = $unix->find_program("sarg");
    if (!is_file($sarg_bin)) {
        sarg_admin_events("Fatal, unable to locate sarg binary, aborting...", __FUNCTION__, __FILE__, __LINE__, "sarg");
        return;
    }
    $bzip2 = $unix->find_program("bzip2");
    $gunzip = $unix->find_program("gunzip");
    $TempDir = "/home/artica-extract-temp";
    @mkdir($TempDir, 0777);
    @chown($TempDir, "mysql");
    @chdir($TempDir, "mysql");
    if (!is_file("/etc/squid3/sarg.conf")) {
        buildconf();
    }
    $q = new mysql_storelogs();
    $ligne = @mysql_fetch_array($q->QUERY_SQL("SELECT filename FROM files_info WHERE storeid='{$storeid}'"));
    $filename = $ligne["filename"];
    events("Extracting infos from {$filename}");
    $EnableSyslogDB = @file_get_contents("/etc/artica-postfix/settings/Daemons/EnableSyslogDB");
    if (!is_numeric($EnableSyslogDB)) {
        $EnableSyslogDB = 0;
    }
    if ($EnableSyslogDB == 0) {
        events("Extracting infos from {$filename} failed, SyslogDB is not enabled");
        return;
    }
    $q = new mysql_storelogs();
    $sql = "SELECT filecontent INTO DUMPFILE '{$TempDir}/{$filename}' FROM files_store WHERE ID = '{$storeid}'";
    $q->QUERY_SQL($sql);
    if (!$q->ok) {
        events("Failed!!! {$q->mysql_error}", 100);
        return;
    }
    $file_extension = file_extension($filename);
    progress("Extract {$filename} extension: {$file_extension}", 5);
    $newtFile = $filename . ".log";
    if ($file_extension == "bz2") {
        $cmdline = "{$bzip2} -d \"{$TempDir}/{$filename}\" -c >\"{$TempDir}/{$newtFile}.log\" 2>&1";
        exec($cmdline, $results);
    }
    if ($file_extension == "gz") {
        $cmdline = "{$gunzip} -d \"{$TempDir}/{$filename}\" -c >\"{$TempDir}/{$newtFile}.log\" 2>&1";
    }
    if ($cmdline != null) {
        exec($cmdline, $results);
        progress("Extract done " . @implode(" ", $results), 7);
    } else {
        if (!@copy("{$TempDir}/{$filename}", "{$TempDir}/{$newtFile}.log")) {
            progress("Failed!!! Copy error", 100);
            return;
        }
    }
    @unlink("{$TempDir}/{$filename}");
    if (!is_file("{$TempDir}/{$newtFile}.log")) {
        progress("Failed!!! {$TempDir}/{$newtFile}.log error no such file", 100);
        return;
    }
    $t = time();
    sargToFile("{$TempDir}/{$newtFile}.log");
    progress("{$filename} ({$storeid}) done " . $unix->distanceOfTimeInWords($t, time()));
    backup();
}
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:78,代码来源:exec.sarg.php

示例8: exec2

function exec2($cmd)
{
    $t = time();
    $unix = new unix();
    ouputz("Please wait... Executing a new task...", __LINE__);
    ouputz($cmd, __LINE__);
    exec($cmd . " 2>&1", $results);
    while (list($pattern, $line) = each($results)) {
        ouputz($line, __LINE__);
    }
    ouputz("Success took " . $unix->distanceOfTimeInWords($t, time(), true), __LINE__);
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:12,代码来源:exec.mysql.mvdb.php

示例9: logrotate

function logrotate()
{
    $unix = new unix();
    $sock = new sockets();
    $BackupMailLogPath = $sock->GET_INFO("BackupMailLogPath");
    $BackupMailLogMaxTimeCompressed = $sock->GET_INFO("BackupMailLogMaxTimeCompressed");
    if (!is_numeric($BackupMailLogMaxTimeCompressed)) {
        $BackupMailLogMaxTimeCompressed = 10080;
    }
    if ($BackupMailLogPath == null) {
        $BackupMailLogPath = "/home/logrotate_backup";
    }
    $du = $unix->find_program("du");
    $gzip = $unix->find_program("gzip");
    @mkdir("{$BackupMailLogPath}", true, 660);
    if (!is_dir("{$BackupMailLogPath}")) {
        $unix->send_email_events("PostFinder:Error while creating {$BackupMailLogPath}");
        return;
    }
    $nice = $unix->EXEC_NICE();
    $timestart = time();
    $log = array();
    foreach (glob("{$BackupMailLogPath}/*.log") as $filename) {
        $timefile = $unix->file_time_min($filename);
        $basename = basename($filename);
        if ($GLOBALS["VERBOSE"]) {
            echo "{$basename}: {$timefile} minutes (need {$BackupMailLogMaxTimeCompressed} minutes)\n";
        }
        if ($timefile > $BackupMailLogMaxTimeCompressed) {
            $targetgzip = "{$BackupMailLogPath}/{$basename}.gz";
            $cmd = trim("{$nice}{$gzip} -c {$filename} >{$targetgzip}");
            if ($GLOBALS["VERBOSE"]) {
                echo "{$cmd}\n";
            }
            $time = time();
            shell_exec($cmd);
            if (is_file($targetgzip)) {
                $ev = "{$basename} -> {$targetgzip} " . $unix->distanceOfTimeInWords($time, time());
                if ($GLOBALS["VERBOSE"]) {
                    echo "{$ev}\n";
                }
                $log[] = $ev;
                @unlink($filename);
            }
        }
    }
    $strings = null;
    exec("{$du} -h -s {$BackupMailLogPath}", $results);
    $strings = @implode("", $results);
    if (preg_match("#^(.+?)\\s+#", $strings, $re)) {
        $final_size = $re[1];
    }
    @file_put_contents("/usr/share/artica-postfix/ressources/logs/postfinder.dirsize.txt", $final_size);
    @chmod("/usr/share/artica-postfix/ressources/logs/postfinder.dirsize.txt", 777);
    if (count($log) > 0) {
        $unix->send_email_events("Postfinder: Directory size: {$strings} - " . count($log) . " maillog compressed (" . $unix->distanceOfTimeInWords($timestart, time()) . ")", "Directory: {$BackupMailLogPath}\n" . @implode("\n", $log), "postfix");
    }
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:58,代码来源:exec.postfix.finder.php

示例10: updatev2_manu

function updatev2_manu()
{
    $sock = new sockets();
    $unix = new unix();
    $t = time();
    $GLOBALS["TEMP_PATH"] = $unix->TEMP_DIR();
    $ManualArticaDBPath = $sock->GET_INFO("ManualArticaDBPath");
    $ArticaDbReplicate = $sock->GET_INFO("ArticaDbReplicate");
    if ($ManualArticaDBPath == null) {
        $ManualArticaDBPath = "/home/manualupdate/articadb.tar.gz";
    }
    $ArticaDBPath = $sock->GET_INFO("ArticaDBPath");
    if ($ArticaDBPath == null) {
        $ArticaDBPath = "/opt/articatech";
    }
    if (!is_numeric($ArticaDbReplicate)) {
        $ArticaDbReplicate = 0;
    }
    $tar = $unix->find_program("tar");
    updatev2_progress(80, "{installing}...");
    if ($GLOBALS["VERBOSE"]) {
        echo "uncompressing {$ManualArticaDBPath}\n";
    }
    @mkdir($ArticaDBPath, 0755, true);
    updatev2_progress(85, "{stopping_service}...");
    shell_exec("/etc/init.d/artica-postfix stop articadb");
    updatev2_progress(95, "{extracting_package}...");
    shell_exec("{$tar} -xf {$ManualArticaDBPath} -C {$ArticaDBPath}/");
    updatev2_progress(96, "{cleaning}...");
    if ($ArticaDbReplicate == 1) {
        @copy("/usr/share/artica-postfix/ressources/logs/web/cache/CATZ_ARRAY", "/home/articatechdb.version");
        @copy("{$ManualArticaDBPath}", "/home/articadb.tar.gz");
        @chmod("/home/articadb.tar.gz", 0755);
        @chmod("/home/articatechdb.version", 0755);
    }
    @unlink($ManualArticaDBPath);
    updatev2_progress(89, "{starting_service}...");
    if ($GLOBALS["VERBOSE"]) {
        echo "starting Articadb\n";
    }
    shell_exec("/etc/init.d/artica-postfix start articadb");
    updatev2_progress(90, "{checking}");
    $q = new mysql();
    if (!$q->DATABASE_EXISTS("catz")) {
        updatev2_progress(95, "Removing old database catz");
        $q->DELETE_DATABASE("catz");
    }
    updatev2_progress(99, "{finish}");
    $took = $unix->distanceOfTimeInWords($t, time());
    $LOCAL_VERSION = @file_get_contents("{$ArticaDBPath}/VERSION");
    squid_admin_mysql(2, "New Artica Database statistics {$LOCAL_VERSION} updated took:{$took}", "");
    // ufdbguard_admin_events("New Artica Database statistics $LOCAL_VERSION updated took:$took.",__FUNCTION__,__FILE__,__LINE__,"ufbd-artica");
    updatev2_progress(100, "{done}");
    $q->QUERY_SQL("TRUNCATE TABLE `catztemp`");
    $nohup = $unix->find_program("nohup");
    $php5 = $unix->LOCATE_PHP5_BIN();
    $cmd = trim("{$nohup} {$php5} /usr/share/artica-postfix/exec.squid.visited.sites.php --schedule-id={$GLOBALS["SCHEDULE_ID"]} >/dev/null 2>&1 &");
    shell_exec($cmd);
    return true;
}
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:60,代码来源:exec.squid.blacklists.php

示例11: compile

function compile()
{
    if (!ifMustBeExecuted()) {
        WriteMyLogs("No make sense to execute this script...", __FUNCTION__, __FILE__, __LINE__);
        if ($GLOBALS["VERBOSE"]) {
            echo "No make sense to execute this script...\n";
        }
        die;
    }
    $ufdb = new compile_ufdbguard();
    $q = new mysql_squid_builder();
    $unix = new unix();
    $t = time();
    $myFile = basename(__FILE__);
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    $unix = new unix();
    $ufdbGenTable = $unix->find_program("ufdbGenTable");
    if (!is_file($ufdbGenTable)) {
        return;
    }
    $pid = @file_get_contents($pidfile);
    $getmypid = $GLOBALS["MYPID"];
    if (!$GLOBALS["FORCE"]) {
        if ($unix->process_exists($pid, $myFile)) {
            $timePid = $unix->PROCCESS_TIME_MIN($pid);
            ufdbguard_admin_events("Already executed PID:{$pid}, since {$timePid}Mn die() ", __FUNCTION__, __FILE__, __LINE__, "Toulouse DB");
            die;
        }
    }
    $Conversion = $q->TLSE_CONVERTION();
    $workdir = "/var/lib/ftpunivtlse1fr";
    $c = 0;
    while (list($directory, $line) = each($Conversion)) {
        $c++;
        $ufdb->UfdbGenTable("{$workdir}/{$directory}", $directory);
        $unix->chown_func("squid", "squid", "{$workdir}/{$directory}");
    }
    ufdbguard_admin_events("Compiling {$c} databases done, took:" . $unix->distanceOfTimeInWords($t, time(), true), __FUNCTION__, __FILE__, __LINE__, "Toulouse DB");
    $unix = new unix();
    $php5 = $unix->LOCATE_PHP5_BIN();
    shell_exec("{$php5} /usr/share/artica-postfix/exec.squidguard.php --build schedule-id={$GLOBALS["SCHEDULE_ID"]}");
}
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:42,代码来源:exec.update.squid.tlse.php

示例12: execBackup

function execBackup()
{
    $unix = new unix();
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    $pid = $unix->get_pid_from_file($pidfile);
    if ($unix->process_exists($pid)) {
        $TTL = $unix->PROCESS_TTL($pid);
        if ($TTL < 240) {
            return;
        }
        $kill = $unix->find_program("kill");
        unix_system_kill_force($pid);
    }
    @file_put_contents($pidfile, getmypid());
    $hostname = $unix->hostname_g();
    $sock = new sockets();
    $BackupArticaBackUseNas = intval($sock->GET_INFO("BackupArticaBackUseNas"));
    $BackupArticaBackLocalFolder = intval($sock->GET_INFO("BackupArticaBackLocalFolder"));
    $BackupArticaBackLocalDir = $sock->GET_INFO("BackupArticaBackLocalDir");
    if ($BackupArticaBackLocalDir == null) {
        $BackupArticaBackLocalDir = "/home/artica/backup";
    }
    if ($BackupArticaBackUseNas == 0) {
        if ($BackupArticaBackLocalFolder == 0) {
            progress(100, "No destination defined");
        }
    }
    progress(10, "{mounting}");
    if ($BackupArticaBackUseNas == 1) {
        if (!TestNas()) {
            system_admin_events("Mounting NAS filesystem report false", __FUNCTION__, __FILE__, __LINE__);
            progress(100, "{disabled}");
            return;
        }
    }
    $t = time();
    $mountPoint = "/mnt/BackupArticaBackNAS";
    $Workdir = "{$mountPoint}/{$hostname}/system-backup/" . date("Y-m-d-H");
    if ($BackupArticaBackLocalFolder == 1) {
        $Workdir = "{$BackupArticaBackLocalDir}/{$hostname}/system-backup/" . date("Y-m-d-H");
    }
    @mkdir($Workdir, 0755, true);
    progress(20, "{backup_ldap}");
    backup_ldap($Workdir);
    progress(30, "{backup_artica_settings}");
    backup_artica_settings($Workdir);
    progress(60, "{backup_artica_database}");
    backup_mysql_artica_backup($Workdir);
    progress(70, "{backup_proxy_databases}");
    backup_mysql_artica_squidlogs($Workdir);
    @file_put_contents("{$Workdir}/BKVERSION.txt", time());
    @file_put_contents("{$Workdir}/DURATION.txt", $unix->distanceOfTimeInWords($t, time(), true));
    progress(90, "{backup_done}");
    if ($BackupArticaBackLocalFolder == 0) {
        $mount = new mount("/var/log/artica-postfix/backup.debug");
        $mountPoint = "/mnt/BackupArticaBackNAS";
        if ($mount->ismounted($mountPoint)) {
            $mount->umount($mountPoint);
        }
    }
    progress(100, "{done}");
}
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:62,代码来源:exec.backup.artica.php

示例13: Parse

function Parse($filename)
{
    $t1 = time();
    $unix = new unix();
    $workfile = $filename;
    $stampfile = "{$filename}.last";
    if (is_file($stampfile)) {
        $LastScannLine = intval(@file_get_contents($stampfile));
    }
    $handle = @fopen($workfile, "r");
    if (!$handle) {
        events("Fopen failed on {$workfile}");
        return false;
    }
    if ($LastScannLine > 0) {
        fseek($handle, $LastScannLine, SEEK_SET);
    }
    while (!feof($handle)) {
        //1444514181;www.safe-demo.com;46.4.32.75;200;1;42354
        $buffer = trim(fgets($handle));
        if ($buffer == null) {
            continue;
        }
        $ARRAY = explode(";", $buffer);
        $TIME = $ARRAY[0];
        $SITENAME = $ARRAY[1];
        $IPADDR = $ARRAY[2];
        if ($IPADDR == "127.0.0.1") {
            continue;
        }
        $HTTP_CODE = $ARRAY[3];
        $RQS = $ARRAY[4];
        $SIZE = $ARRAY[5];
        $TIME_HOUR = date("Y-m-d H:00:00", $TIME);
        $KEYMD5 = md5("{$TIME_HOUR}{$SITENAME}");
        $KEYMD5FULL = md5("{$TIME_HOUR}{$SITENAME}{$IPADDR}{$HTTP_CODE}");
        if (!isset($GENERIC[$KEYMD5]["SIZE"])) {
            $GENERIC[$KEYMD5]["DATE"] = $TIME_HOUR;
            $GENERIC[$KEYMD5]["INFLUX_TIME"] = TimeToInflux($TIME);
            $GENERIC[$KEYMD5]["SIZE"] = intval($SIZE);
            $GENERIC[$KEYMD5]["RQS"] = intval($RQS);
            $GENERIC[$KEYMD5]["SITENAME"] = $SITENAME;
        } else {
            $GENERIC[$KEYMD5]["SIZE"] = $GENERIC[$KEYMD5]["SIZE"] + $SIZE;
            $GENERIC[$KEYMD5]["RQS"] = $GENERIC[$KEYMD5]["RQS"] + $RQS;
        }
        if (!isset($FULL[$KEYMD5FULL]["SIZE"])) {
            $FULL[$KEYMD5FULL]["DATE"] = $TIME_HOUR;
            $FULL[$KEYMD5FULL]["INFLUX_TIME"] = QueryToUTC(strtotime($TIME_HOUR), true);
            $FULL[$KEYMD5FULL]["SIZE"] = intval($SIZE);
            $FULL[$KEYMD5FULL]["RQS"] = intval($RQS);
            $FULL[$KEYMD5FULL]["SITENAME"] = $SITENAME;
            $FULL[$KEYMD5FULL]["IPADDR"] = $IPADDR;
            $FULL[$KEYMD5FULL]["HTTP_CODE"] = $HTTP_CODE;
        } else {
            $FULL[$KEYMD5FULL]["SIZE"] = $GENERIC[$KEYMD5]["SIZE"] + $SIZE;
            $FULL[$KEYMD5FULL]["RQS"] = $GENERIC[$KEYMD5]["RQS"] + $RQS;
        }
        if (count($GENERIC) > 500) {
            if (!DUMP_GENERIC($GENERIC)) {
                return;
            }
            $GENERIC = array();
        }
        if (count($FULL) > 500) {
            if (!DUMP_FULL($FULL)) {
                return;
            }
            $FULL = array();
        }
    }
    if (count($GENERIC) > 0) {
        if (!DUMP_GENERIC($GENERIC)) {
            return;
        }
    }
    if (count($FULL) > 0) {
        if (!DUMP_FULL($FULL)) {
            return;
        }
        $FULL = array();
    }
    $took = $unix->distanceOfTimeInWords($t1, time(), true);
    apache_admin_mysql(2, "Success injecting data from " . basename($workfile) . " took:{$took}", null, __FILE__, __LINE__);
    @unlink($workfile);
}
开发者ID:articatech,项目名称:artica,代码行数:86,代码来源:exec.apache.hour.php

示例14: refresh_ticket

function refresh_ticket($nopid = false)
{
    $unix = new unix();
    $sock = new sockets();
    $users = new usersMenus();
    $t = time();
    $timefile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    $pid = $unix->get_pid_from_file($pidfile);
    if ($unix->process_exists($pid, basename(__FILE__))) {
        $timeExec = intval($unix->PROCCESS_TIME_MIN($pid));
        writelogs("Process {$pid} already exists since {$timeExec}Mn", __FUNCTION__, __FILE__, __LINE__);
        if ($timeExec > 5) {
            $kill = $unix->find_program("kill");
            system_admin_events("killing old pid {$pid} (already exists since {$timeExec}Mn)", __FUNCTION__, __FILE__, __LINE__);
            unix_system_kill_force($pid);
        } else {
            return;
        }
    }
    $EnableKerbAuth = intval($sock->GET_INFO("EnableKerbAuth"));
    if ($EnableKerbAuth == 0) {
        system_admin_events("EnableKerbAuth is disabled, aborting", __FUNCTION__, __FILE__, __LINE__);
        return;
    }
    if (!$users->SAMBA_INSTALLED) {
        system_admin_events("Samba is not installed, aborting", __FUNCTION__, __FILE__, __LINE__);
        return;
    }
    $net = $unix->find_program("net");
    $msktutil = $unix->find_program("msktutil");
    $cmdline = "{$net} rpc changetrustpw -d 3 2>&1";
    exec($cmdline, $results);
    if (!is_file($msktutil)) {
        $results[] = "msktutil no such binary...";
        $took = $unix->distanceOfTimeInWords($t, time(), true);
        system_admin_events("Update kerberos done took:{$took}\n" . @implode("\n", $results), __FUNCTION__, __FILE__, __LINE__);
        return;
    }
    $myNetBiosName = $unix->hostname_simple();
    $msktutil_version = msktutil_version();
    if ($msktutil == 3) {
        $cmd = "{$msktutil} --update --verbose --computer-name {$myNetBiosName}";
    }
    if ($msktutil == 4) {
        $cmd = "{$msktutil} --auto-update --verbose --computer-name {$myNetBiosName}";
    }
    $results[] = $cmd;
    exec($cmd . " 2>&1", $results);
    $took = $unix->distanceOfTimeInWords($t, time(), true);
    system_admin_events("Update kerberos done took:{$took}\n" . @implode("\n", $results), __FUNCTION__, __FILE__, __LINE__);
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:52,代码来源:exec.kerbauth.php

示例15: nightly


//.........这里部分代码省略.........
    $EnableArticaMetaClient = intval($sock->GET_INFO("EnableArticaMetaClient"));
    if ($EnableArticaMetaClient == 1) {
        echo "Starting......: " . date("H:i:s") . " Nightly builds using Artica Meta console\n";
        system("{$nohup} {$php5} /usr/share/artica-postfix/exec.artica-meta-client.php --artica-updates >/dev/null 2>&1 &");
        die;
    }
    echo "Starting......: " . date("H:i:s") . " Nightly builds checking an official release first\n";
    if (update_release()) {
        return;
    }
    $nightly = trim(strtolower($ini->_params["AUTOUPDATE"]["nightlybuild"]));
    if ($nightly == 1) {
        $nightly = "yes";
    }
    if ($GLOBALS["FORCE"]) {
        $nightly = "yes";
    }
    if ($GLOBALS["FORCE_NIGHTLY"]) {
        $nightly = "yes";
    }
    if ($nightly != 'yes') {
        echo "Starting......: " . date("H:i:s") . " Nightly builds feature is disabled [{$nightly}]\n";
        @file_put_contents("/usr/share/artica-postfix/ressources/logs/web/download_progress", 100);
        return;
    }
    if ($ini->_params["AUTOUPDATE"]["autoinstall"] == 1) {
        $ini->_params["AUTOUPDATE"]["autoinstall"] = "yes";
    }
    if (trim($ini->_params["AUTOUPDATE"]["autoinstall"]) == null) {
        $ini->_params["AUTOUPDATE"]["autoinstall"] = "yes";
    }
    if ($ini->_params["AUTOUPDATE"]["autoinstall"] != "yes") {
        $autoinstall = false;
    }
    @file_put_contents("/usr/share/artica-postfix/download_progress", 0);
    $MyCurrentVersion = GetCurrentVersion();
    echo "Starting......: " . date("H:i:s") . " Current version: {$MyCurrentVersion}\n";
    $Lastest = trim(strtolower($GLOBALS["lastest-nightly"]));
    echo "Starting......: " . date("H:i:s") . " Nightly builds version \"{$Lastest}\" on repository\n";
    $MyNextVersion = intval(str_replace(".", "", $Lastest));
    echo "Starting......: " . date("H:i:s") . " nightly builds Cur:{$MyCurrentVersion}, Next:{$MyNextVersion}\n";
    if ($MyNextVersion == $MyCurrentVersion) {
        echo "Starting......: " . date("H:i:s") . " nightly builds {$MyCurrentVersion}/{$MyNextVersion} \"Up to date - Same version\"\n";
        @file_put_contents("/usr/share/artica-postfix/download_progress", 100);
        return;
    }
    if ($MyCurrentVersion > $MyNextVersion) {
        echo "Starting......: " . date("H:i:s") . " nightly builds {$MyCurrentVersion}/{$MyNextVersion} \"Up to date - Most updated\"\n";
        @file_put_contents("/usr/share/artica-postfix/download_progress", 100);
        return;
    }
    $t1 = time();
    _artica_update_event(2, "nightly builds Downloading new version {$Lastest}", null, __FILE__, __LINE__);
    echo "Starting......: " . date("H:i:s") . " nightly builds Downloading new version {$Lastest}, please wait\n";
    events("Downloading new version {$Lastest}");
    $uri = "{$MAIN_URI}/nightbuilds/artica-{$Lastest}.tgz";
    $ArticaFileTemp = "{$tmpdir}/{$Lastest}/artica-{$Lastest}.tgz";
    @mkdir("{$tmpdir}/{$Lastest}", 0755, true);
    $curl = new ccurl($uri);
    $curl->Timeout = 2400;
    $curl->WriteProgress = true;
    $curl->ProgressFunction = "nightly_progress";
    $t = time();
    if (!$curl->GetFile($ArticaFileTemp)) {
        _artica_update_event(0, "nightly builds Unable to download latest nightly build with error {$curl->error}", null, __FILE__, __LINE__);
        events("Unable to download latest nightly build with error {$curl->error}");
        system_admin_events("Unable to download latest nightly build with error {$curl->error}", __FUNCTION__, __FILE__, __LINE__, "artica-update");
        @unlink($ArticaFileTemp);
        return;
    }
    $took = $unix->distanceOfTimeInWords($t, time(), true);
    _artica_update_event(2, "artica-{$Lastest}.tgz download, took {$took}", null, __FILE__, __LINE__);
    system_admin_events("artica-{$Lastest}.tgz download, took {$took}", __FUNCTION__, __FILE__, __LINE__, "artica-update");
    events("artica-{$Lastest}.tgz download, took {$took}");
    $size = @filesize($ArticaFileTemp);
    $size = FormatBytes($size / 1024, true);
    ArticaMeta_nightly($ArticaFileTemp);
    echo "Starting......: " . date("H:i:s") . " nightly builds took {$took}\n";
    if (!$GLOBALS["FORCE"]) {
        if ($autoinstall == false) {
            _artica_update_event(2, "artica-latest.tgz will be stored in /root", null, __FILE__, __LINE__);
            @copy("{$ArticaFileTemp}", "/root/artica-latest.tgz");
            @unlink($ArticaFileTemp);
            _artica_update_event(1, "Nightly builds New Artica update v.{$Lastest} ({$size}) waiting order", null, __FILE__, __LINE__);
            system_admin_events("New Artica update v.{$Lastest} waiting your order", __FUNCTION__, __FILE__, __LINE__, "artica-update");
            return;
        } else {
        }
    }
    events("Now, installing the newest version in {$ArticaFileTemp} package...");
    $size = @filesize($ArticaFileTemp);
    $size = FormatBytes($size / 1024, true);
    if (!install_package($ArticaFileTemp, $Lastest)) {
        events("Install package Failed...");
        return false;
    }
    events("New Artica update v.{$Lastest}");
    _artica_update_event(1, "Nightly builds New Artica update v.{$Lastest} ({$size})", null, __FILE__, __LINE__);
    system_admin_events("New Artica update v.{$Lastest}", __FUNCTION__, __FILE__, __LINE__, "artica-update");
}
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:101,代码来源:exec.nightly.php


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