function searchwords_hour($aspid = false) { if (isset($GLOBALS["searchwords_hour_executed"])) { return true; } $GLOBALS["searchwords_hour_executed"] = true; $unix = new unix(); $GLOBALS["Q"] = new mysql_squid_builder(); $pidtime = "/etc/artica-postfix/pids/exec.squid-searchwords.php.searchwords_hour.time"; if ($GLOBALS["VERBOSE"]) { echo "PidTime: {$pidtime}\n"; } $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid"; $pid = @file_get_contents($pidfile); $myfile = basename(__FILE__); if ($unix->process_exists($pid, $myfile)) { ufdbguard_admin_events("{$pid} already running, aborting", __FUNCTION__, __FILE__, __LINE__, "stats"); return; } $timeP = $unix->file_time_min($pidtime); if ($timeP < 30) { events("Main::Line: " . __LINE__ . " 30Mn minimal current: {$timeP}mn-> DIE - {$pidtime}"); die; } @unlink($pidtime); @file_put_contents($pidtime, time()); @file_put_contents($pidfile, getmypid()); $currenttable = "searchwords_" . date("YmdH"); if (!isset($GLOBALS["Q"])) { $GLOBALS["Q"] = new mysql_squid_builder(); } $LIST_TABLES_SEARCHWORDS_HOURS = $GLOBALS["Q"]->LIST_TABLES_SEARCHWORDS_HOURS(); while (list($num, $tablename) = each($LIST_TABLES_SEARCHWORDS_HOURS)) { if ($tablename == $currenttable) { if ($GLOBALS["VERBOSE"]) { echo "{$tablename} -> {$currenttable} >skip\n"; } continue; } if ($GLOBALS["VERBOSE"]) { echo "{$tablename} -> {$currenttable}\n"; } if (searchwords_hour_to_day($tablename)) { $GLOBALS["Q"]->QUERY_SQL("DROP TABLE {$tablename}"); } } hour_SearchWordTEMP(); $mysqladmin = $unix->find_program("mysqladmin"); shell_exec("{$mysqladmin} -u root -S /var/run/mysqld/squid-db.sock flush-tables >/dev/null 2>&1 &"); }
exit; } if ($argv[1] == '--thumbs-sites') { thumbnail_query(); exit; } if ($argv[1] == '--thumbs-alexa') { thumbnail_alexa($argv[2], $argv[3]); exit; } if ($argv[1] == '--thumbs-parse') { thumbnail_parse(); exit; } if ($argv[1] == '--searchwords-hour') { hour_SearchWordTEMP(); die; } if ($argv[1] == '--scan-hours') { scan_hours(); die; } if ($argv[1] == '--scan-months') { scan_months(); die; } if ($argv[1] == '--tables-days') { table_days(); die; } if ($argv[1] == '--summarize-days') {