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


PHP mysql_squid_builder::CreateHourTable方法代码示例

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


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

示例1: repair_from_sources_tables

function repair_from_sources_tables()
{
    $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 "time: {$timefile}\n";
    }
    $pid = @file_get_contents($pidfile);
    if (!$GLOBALS["VERBOSE"]) {
        if (!$GLOBALS["FORCE"]) {
            if ($unix->process_exists($pid, basename(__FILE__))) {
                if ($GLOBALS["VERBOSE"]) {
                    echo "Already executed pid {$pid}\n";
                }
                return;
            }
            if ($pid < 100) {
                $pid = null;
            }
            $mypid = getmypid();
            @file_put_contents($pidfile, $mypid);
        }
    }
    if ($GLOBALS["FORCE_TIME"]) {
        $timeexec = $unix->file_time_min($timefile);
        if ($timeexec < 240) {
            return;
        }
    }
    @unlink($timefile);
    @file_put_contents($timefile, time());
    $Prefix = "/usr/share/artica-postfix";
    $php5 = $unix->LOCATE_PHP5_BIN();
    $nohup = $unix->find_program("nohup");
    $EXEC_NICE = $unix->EXEC_NICE();
    $q = new mysql_squid_builder();
    $C = 0;
    $array = $q->LIST_TABLES_dansguardian_events();
    $current = "dansguardian_events_" . date("Ymd");
    while (list($tablename, $none) = each($array)) {
        if ($tablename == $current) {
            continue;
        }
        $time = $q->TIME_FROM_DANSGUARDIAN_EVENTS_TABLE($tablename);
        $xtime = date("Y-m-d", $time);
        $hour_table = date("Ymd", $time) . "_hour";
        $member_table = date("Ymd", $time) . "_members";
        $SUM_SOURCE = $q->COUNT_ROWS($tablename);
        if ($SUM_SOURCE == 0) {
            continue;
        }
        $SUM_DEST = $q->COUNT_ROWS($hour_table);
        $PERC = $SUM_DEST / $SUM_SOURCE * 100;
        $PERC = intval($PERC);
        echo "{$xtime}] {$SUM_SOURCE} - {$SUM_DEST} = {$PERC}% - {$tablename}\n";
        if ($PERC < 5) {
            if (!$q->CreateHourTable($hour_table)) {
                echo "{$xtime}] {$tablename} unable to create {$hour_table}\n";
                continue;
            }
            _repair_from_sources_tables($tablename, $hour_table);
            $q->QUERY_SQL("UPDATE tables_day SET `totalsize`='0',`requests`=0,`MembersCount`=0,`month_flow`=0,weekdone=0,weekbdone=0 WHERE tablename='{$tablename}'");
            $C++;
        }
        $ligne1 = mysql_fetch_array($q->QUERY_SQL("SELECT SUM(hits) as hits FROM {$tablename}"));
        if (!$q->ok) {
            echo $q->mysql_error;
        }
        $SumDehits_src = $ligne1["hits"];
        $ligne1 = mysql_fetch_array($q->QUERY_SQL("SELECT SUM(hits) as hits FROM {$member_table}"));
        $SumDehits_dest = $ligne1["hits"];
        $PERC = $SumDehits_dest / $SumDehits_src * 100;
        $PERC = intval($PERC);
        echo "{$xtime}] {$SumDehits_src} - {$SumDehits_dest} = {$PERC}% - {$member_table}\n";
        if ($PERC < 90) {
            if (!$q->CreateMembersDayTable($hour_table)) {
                echo "{$xtime}] {$tablename} unable to create {$hour_table}\n";
                continue;
            }
            _repair_members_sources_tables($tablename, $member_table);
            $C++;
        }
    }
    if ($C > 0) {
        shell_exec(trim("{$EXEC_NICE} {$php5} {$Prefix}/exec.squid.stats.totals.php --repair --byschedule --schedule-id={$GLOBALS["SCHEDULE_ID"]}"));
    }
}
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:88,代码来源:exec.squid.stats.repair.php

示例2: clients_hours

function clients_hours($nopid = false)
{
    if ($GLOBALS["VERBOSE"]) {
        echo "L.[" . __LINE__ . "]: processing clients_hours()\n";
    }
    if (isset($GLOBALS["clients_hours_executed"])) {
        if ($GLOBALS["VERBOSE"]) {
            echo "clients_hours():: Already executed\n";
        }
        return true;
    }
    $GLOBALS["clients_hours_executed"] = true;
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    $unix = new unix();
    if (!$nopid) {
        $pid = @file_get_contents($pidfile);
        if ($unix->process_exists($pid, basename(__FILE__))) {
            writelogs("Already executed pid:{$pid}", __FUNCTION__, __FILE__, __LINE__);
            return;
        }
        $mypid = getmypid();
        @file_put_contents($pidfile, $mypid);
    }
    $currenttable = "dansguardian_events_" . date('Ymd');
    $next_table = date('Ymd') . "_hour";
    echo "L.[" . __LINE__ . "]:_clients_hours_perfom({$currenttable},{$next_table})\n";
    _clients_hours_perfom($currenttable, $next_table);
    $q = new mysql_squid_builder();
    $sql = "SELECT DATE_FORMAT(zDate,'%Y%m%d') as suffix,tablename FROM tables_day WHERE Hour=0";
    $results = $q->QUERY_SQL($sql);
    if (!$q->ok) {
        events_tail("{$q->mysql_error}");
        return;
    }
    $num_rows = mysql_num_rows($results);
    if ($num_rows == 0) {
        if ($GLOBALS["VERBOSE"]) {
            echo "clients_hours():: No datas " . __FUNCTION__ . " " . __LINE__ . "\n";
        }
        return;
    }
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        $next_table = $ligne["suffix"] . "_hour";
        if (!$q->CreateHourTable($next_table)) {
            events_tail("Failed to create {$next_table}");
            return;
        }
        if (!_clients_hours_perfom($ligne["tablename"], $next_table)) {
            events_tail("Failed to process {$ligne["tablename"]} to {$next_table}");
            return;
        }
        $q->QUERY_SQL("UPDATE tables_day SET `Hour`=1 WHERE tablename='{$ligne["tablename"]}'");
    }
}
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:54,代码来源:exec.squid.stats.central.php


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