function change_date_popup(){ $q=new mysql_squid_builder(); $tables=$q->LIST_TABLES_HOURS_TEMP(); while (list ($table, $none) = each ($tables) ){ if(!preg_match("#squidhour_([0-9]+)#",$table,$re)){events_repair("No match `$table` abort... L: ".__LINE__);continue;} $hour=$re[1]; $year=substr($hour,0,4); $month=substr($hour,4,2); $day=substr($hour,6,2); $hour=substr($hour,8,2); $time=strtotime("$year-$month-$day $hour:00:00"); } }
function table_heures_enretard(){ $tpl=new templates(); $page=CurrentPageName(); $q=new mysql_squid_builder(); $CurrentHourTable="squidhour_".date("YmdH"); if($GLOBALS["VERBOSE"]){echo "Find hours tables...\n";} $tables=$q->LIST_TABLES_HOURS_TEMP(); $c=0; $t=time(); $CountDeTable=0; while (list ($table, $none) = each ($tables) ){ if($table==$CurrentHourTable){if($GLOBALS["VERBOSE"]){echo "SKIP `$table`\n";}continue;} if(!preg_match("#squidhour_([0-9]+)#",$table,$re)){continue;} $hour=$re[1]; $year=substr($hour,0,4); $month=substr($hour,4,2); $day=substr($hour,6,2); $tt[$table]=true; } if(!is_array($tt)){return null;} $CountDeTable=count($tt); if($CountDeTable>0){ $sock=new sockets(); $time=$sock->getFrameWork("squid.php?squidhour-repair-exec=yes"); if(is_numeric($time)){ $title=$tpl->javascript_parse_text("{squidhour_not_scanned} {running} {$time}Mn"); $title=str_replace("%s", $CountDeTable, $title); $title=str_replace("%", $CountDeTable, $title); return Paragraphe32("noacco:$title ",'launch_squidhour_explain' ,"blur()","wait-clock.gif"); } $launch_squidhour_explain=$tpl->_ENGINE_parse_body("{launch_squidhour_explain}"); $title=$tpl->javascript_parse_text("{squidhour_not_scanned}"); $title=str_replace("%s", $CountDeTable, $title); $title=str_replace("%", $CountDeTable, $title); return Paragraphe32("noacco:$title","$launch_squidhour_explain" ,"Loadjs('$page?squidhour-js=yes')","Database32-red.png"); } }
function remove_memory_tables() { $q = new mysql_squid_builder(); $QUEUE = $q->LIST_TABLES_HOURS_TEMP(); while (list($tablename, $FINAL_ARRAY) = each($QUEUE)) { echo "removing {$tablename}\n"; $q->QUERY_SQL("DROP TABLE {$tablename}"); } }
function UPDATE_HOURS_IP($IP, $name) { if (!$GLOBALS["UPDATE"]) { return; } $q = new mysql_squid_builder(); $LIST_TABLES_HOURS_TEMP = $q->LIST_TABLES_HOURS_TEMP(); while (list($tablename, $ligne) = each($LIST_TABLES_HOURS_TEMP)) { $q->QUERY_SQL("UPDATE {$tablename} SET `uid`='{$name}' WHERE `client`='{$IP}'"); } }
function clean_empty_tables() { $unix = new unix(); ///etc/artica-postfix/pids/exec.squid.stats.hours.php.clean_empty_tables.time $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid"; $timefile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time"; if ($GLOBALS["VERBOSE"]) { echo "Time File: {$timefile}\n"; } $pid = @file_get_contents($pidfile); if ($GLOBALS["FORCE"]) { ToSyslog("macscan(): Executed in --force mode"); } 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"; } ToSyslog("clean_empty_tables(): already executed pid {$pid}"); return; } $timeexec = $unix->file_time_min($timefile); if ($timeexec < 30) { return; } $mypid = getmypid(); @file_put_contents($pidfile, $mypid); } @unlink($timefile); @file_put_contents($timefile, time()); $q = new mysql_squid_builder(); $TABLES = $q->LIST_TABLES_HOURS_TEMP(); $current = "squidhour_" . date("YmdH"); while (list($tablename, $none) = each($TABLES)) { if ($tablename == $current) { continue; } if ($q->COUNT_ROWS($tablename) > 0) { continue; } $q->QUERY_SQL("DROP TABLE `{$tablename}`"); } $TABLES = $q->LIST_TABLES_SIZEHOURS(); $current = "sizehour_" . date("YmdH"); while (list($tablename, $none) = each($TABLES)) { if ($tablename == $current) { continue; } if ($q->COUNT_ROWS($tablename) > 0) { continue; } $q->QUERY_SQL("DROP TABLE `{$tablename}`"); } $TABLES = $q->LIST_TABLES_dansguardian_events(); $current = " dansguardian_events_" . date("Ymd"); while (list($tablename, $none) = each($TABLES)) { if ($tablename == $current) { continue; } if ($q->COUNT_ROWS($tablename) > 0) { continue; } $q->QUERY_SQL("DROP TABLE `{$tablename}`"); } }