本文整理汇总了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"]}"));
}
}
示例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"]}'");
}
}