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


PHP mysql_squid_builder::CreateUserSizeRTT_day方法代码示例

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


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

示例1: build

function build()
{
    if (!function_exists("IsPhysicalAddress")) {
        include_once dirname(__FILE__) . "/ressources/class.templates.inc";
    }
    $unix = new unix();
    $file_duration = "/etc/squid3/squid.durations.ini";
    $file_quotas_day = "/etc/squid3/squid.quotasD.ini";
    $file_quotas_hour = "/etc/squid3/squid.quotasH.ini";
    $php5 = $unix->LOCATE_PHP5_BIN();
    $nohup = $unix->find_program("nohup");
    $sql = "SELECT * FROM webfilters_quotas";
    $q = new mysql_squid_builder();
    $results = $q->QUERY_SQL($sql);
    $array = array();
    while ($ligne = mysql_fetch_assoc($results)) {
        $duration = $ligne["duration"];
        $xtype = $ligne["xtype"];
        $value = $ligne["value"];
        $array[$duration][$xtype][$value] = $ligne["maxquota"] * 1024 * 1000;
        if ($GLOBALS["VERBOSE"]) {
            echo "duration[{$duration}]: {$xtype} ({$value}) = {$array[$duration][$xtype][$value]} (bytes)\n";
        }
    }
    if (count($array) == 0) {
        @unlink($file_duration);
    } else {
        @file_put_contents($file_duration, serialize($array));
    }
    $table = "UserSizeD_" . date("Ymd");
    if (!$q->TABLE_EXISTS($table)) {
        $q->CreateUserSizeRTT_day($table);
        shell_exec("{$nohup} {$php5} /usr/share/artica-postfix/exec.squid.php --build-schedules >/dev/null 2>&1 &");
    }
    $sql = "SELECT uid,ipaddr,hostname,account,MAC,SUM(size) as size FROM `{$table}` GROUP BY uid,ipaddr,hostname,account,MAC";
    $results = $q->QUERY_SQL($sql);
    $array = array();
    while ($ligne = mysql_fetch_assoc($results)) {
        $array["ipaddr"][$ligne["ipaddr"]] = $ligne["size"];
        $array["uid"][$ligne["uid"]] = $ligne["size"];
        $array["hostname"][$ligne["hostname"]] = $ligne["size"];
        $array["MAC"][$ligne["MAC"]] = $ligne["size"];
        if ($GLOBALS["VERBOSE"]) {
            $sizeM = $ligne["size"] / 1024 / 1000;
            echo date("l d") . ": {$ligne["MAC"]},{$ligne["uid"]},{$ligne["ipaddr"]} = {$ligne["size"]} ({$sizeM} M)\n";
        }
    }
    @file_put_contents($file_quotas_day, serialize($array));
    $array = array();
    $sql = "SELECT DAY(zDate) as tday,HOUR(zDate) as thour,uid,ipaddr,hostname,account,MAC,SUM(size) as size FROM `UserSizeRTT` \nGROUP BY uid,ipaddr,hostname,account,MAC,tday,thour HAVING tday=DAY(NOW()) AND thour=HOUR(NOW())";
    $results = $q->QUERY_SQL($sql);
    $array = array();
    while ($ligne = mysql_fetch_assoc($results)) {
        if ($GLOBALS["VERBOSE"]) {
            $sizeM = $ligne["size"] / 1024 / 1000;
            echo "{$ligne["thour"]}h: {$ligne["MAC"]},{$ligne["uid"]},{$ligne["ipaddr"]} = {$ligne["size"]} ({$sizeM} M)\n";
        }
        $array["ipaddr"][$ligne["ipaddr"]] = $ligne["size"];
        $array["uid"][$ligne["uid"]] = $ligne["size"];
        $array["hostname"][$ligne["hostname"]] = $ligne["size"];
        $array["MAC"][$ligne["MAC"]] = $ligne["size"];
    }
    @file_put_contents($file_quotas_hour, serialize($array));
    MacToUid();
}
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:65,代码来源:exec.squid.quotasbuild.php

示例2: UserSizeRTT_oldfiles

function UserSizeRTT_oldfiles()
{
    if (!($handle = opendir("/var/log/artica-postfix/squid-RTTSize"))) {
        ufdbguard_admin_events("Fatal: /var/log/artica-postfix/squid-RTTSize no such directory", __FUNCTION__, __FILE__, __LINE__, "stats");
        return;
    }
    $q = new mysql_squid_builder();
    $classParse = new squid_tail();
    $CurrentFile = date("YmdH");
    if ($GLOBALS["VERBOSE"]) {
        echo __FUNCTION__ . ":: scanning /var/log/artica-postfix/squid-RTTSize\n";
    }
    while (false !== ($filename = readdir($handle))) {
        if ($filename == ".") {
            continue;
        }
        if ($filename == "..") {
            continue;
        }
        if ($filename == $CurrentFile) {
            continue;
        }
        $targetFile = "/var/log/artica-postfix/squid-RTTSize/{$filename}";
        if ($GLOBALS["VERBOSE"]) {
            echo __FUNCTION__ . ":: {$targetFile}\n";
        }
        $time = filemtime($targetFile);
        $tablesuffix = date("Ymd", $time);
        $tablename = "UserSizeD_{$tablesuffix}";
        if (!$q->CreateUserSizeRTT_day($tablename)) {
            ufdbguard_admin_events("{$tablename}: Query failed {$q->mysql_error}", __FUNCTION__, __FILE__, __LINE__, "stats");
            return;
        }
        $RTTSIZEARRAY = unserialize(@file_get_contents($targetFile));
        $Hour = date('H', $time);
        $date = date("Y-m-d H:00:00", $time);
        //$sql="INSERT IGNORE INTO `$tablename` (`zMD5`,`uid`,`zdate`,
        //`ipaddr`,`hostname`,`account`,`MAC`,`UserAgent`,`size`,`hits`,`hour`) VALUES ".@implode(",", $rows);
        if (count($RTTSIZEARRAY["UID"]) > 0) {
            $f = array();
            $prefix = "INSERT IGNORE INTO `{$tablename}` (`zMD5`,`zdate`,`uid`,`size`,`hits`,`hour`) VALUES ";
            while (list($username, $array) = each($RTTSIZEARRAY["UID"])) {
                $hits = $array["HITS"];
                $size = $array["SIZE"];
                $md5 = md5("{$username}{$date}{$Hour}");
                echo $username . " HITS:{$hits} SIZE:{$size}\n";
                $f[] = "('{$md5}','{$date}','{$username}','{$size}','{$hits}','{$Hour}')";
            }
            if (count($f) > 0) {
                $q->QUERY_SQL($prefix . @implode(",", $f));
                if (!$q->ok) {
                    ufdbguard_admin_events("Fatal: {$q->mysql_error}\n", __FUNCTION__, __FILE__, __LINE__, "stats");
                    return;
                }
            }
        }
        if (count($RTTSIZEARRAY["IP"]) > 0) {
            $f = array();
            $prefix = "INSERT IGNORE INTO `{$tablename}` (`zMD5`,`zdate`,`ipaddr`,`hostname`,`size`,`hits`,`hour`) VALUES ";
            while (list($ip, $array) = each($RTTSIZEARRAY["IP"])) {
                $hits = $array["HITS"];
                $size = $array["SIZE"];
                $md5 = md5("{$ip}{$date}{$Hour}");
                $hostname = $classParse->GetComputerName($ip);
                echo $ip . "/{$hostname} HITS:{$hits} SIZE:{$size}\n";
                $f[] = "('{$md5}','{$date}','{$ip}','{$hostname}','{$size}','{$hits}','{$Hour}')";
            }
            if (count($f) > 0) {
                $q->QUERY_SQL($prefix . @implode(",", $f));
                if (!$q->ok) {
                    ufdbguard_admin_events("Fatal: {$q->mysql_error}\n", __FUNCTION__, __FILE__, __LINE__, "stats");
                    return;
                }
            }
        }
        if (count($RTTSIZEARRAY["MAC"]) > 0) {
            $f = array();
            $prefix = "INSERT IGNORE INTO `{$tablename}` (`zMD5`,`zdate`,`MAC`,`size`,`hits`,`hour`) VALUES ";
            while (list($mac, $array) = each($RTTSIZEARRAY["MAC"])) {
                $hits = $array["HITS"];
                $size = $array["SIZE"];
                $md5 = md5("{$mac}{$date}{$Hour}");
                echo "{$mac} HITS:{$hits} SIZE:{$size}\n";
                $f[] = "('{$md5}','{$date}','{$mac}','{$size}','{$hits}','{$Hour}')";
            }
            if (count($f) > 0) {
                $q->QUERY_SQL($prefix . @implode(",", $f));
                if (!$q->ok) {
                    ufdbguard_admin_events("Fatal: {$q->mysql_error}\n", __FUNCTION__, __FILE__, __LINE__, "stats");
                    return;
                }
            }
        }
        @unlink($targetFile);
    }
}
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:96,代码来源:exec.squid-searchwords.php

示例3: UserSizeD_REPAIR

function UserSizeD_REPAIR($day)
{
    $time = strtotime("{$day} 00:00:00");
    $sourcetable = date("Ymd", $time) . "_hour";
    $q = new mysql_squid_builder();
    if (!$q->TABLE_EXISTS($sourcetable)) {
        if ($GLOBALS["VERBOSE"]) {
            echo "<strong>Fatal!:</strong> {$sourcetable} no such table\n";
        }
        return;
    }
    $tablename = "UserSizeD_" . date("Ymd", $time);
    if (!$q->CreateUserSizeRTT_day($tablename)) {
        if ($GLOBALS["VERBOSE"]) {
            echo "<strong>Fatal!:{$tablename}</strong> Query failed {$q->mysql_error}\n";
        }
        ufdbguard_admin_events("{$tablename}: Query failed {$q->mysql_error}", __FUNCTION__, __FILE__, __LINE__, "stats");
        return;
    }
    $prefix = "INSERT IGNORE INTO `{$tablename}` (`zMD5`,`uid`,`zdate`,\n\t`ipaddr`,`hostname`,`account`,`MAC`,`UserAgent`,`size`,`hits`,`hour`) VALUES ";
    $sql = "SELECT client,hostname,account,hour,MAC,SUM(size) as size,SUM(hits) as hits,uid FROM {$sourcetable}\n\tGROUP BY client,hostname,account,hour,MAC,uid";
    $results = $q->QUERY_SQL($sql);
    if (!$q->ok) {
        if ($GLOBALS["VERBOSE"]) {
            echo "<strong>Fatal!:</strong> {$q->mysql_error}\n";
        }
        return;
    }
    $total = mysql_num_rows($results);
    if ($total == 0) {
        events_tail("UserSizeD_REPAIR({$day}) Fatal!:No row for {$sourcetable}\n");
        return;
    }
    $de = 0;
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        $de++;
        $zMD5 = md5(serialize($ligne));
        $uid = addslashes($ligne["uid"]);
        $hostname = addslashes($ligne["hostname"]);
        $f[] = "('{$zMD5}','{$uid}','{$day}','{$ligne["client"]}','{$hostname}','{$ligne["account"]}','{$ligne["MAC"]}','','{$ligne["size"]}','{$ligne["hits"]}','{$ligne["hour"]}')";
        if (count($f) > 500) {
            $dep = round($de / $total * 100, 2);
            events_tail("UserSizeD_REPAIR({$day}) {$de}/{$total} ({$dep})");
            $q->QUERY_SQL($prefix . @implode(",", $f));
            if (!$q->ok) {
                events_tail("UserSizeD_REPAIR({$day}) Fatal! {$q->mysql_error}");
                return;
            }
            $f = array();
        }
    }
    if (count($f) > 0) {
        $q->QUERY_SQL($prefix . @implode(",", $f));
        if (!$q->ok) {
            if ($GLOBALS["VERBOSE"]) {
                echo "<strong>Fatal!:</strong> {$q->mysql_error}\n";
            }
            return;
        }
        $f = array();
    }
    if ($GLOBALS["VERBOSE"]) {
        echo "<strong>SUCCESS: {$tablename}</strong>\n";
    }
}
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:65,代码来源:exec.squid.stats.php


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