function xstart() { $Directory = "/home/artica-postfix/squid/StatsApplicance/BEREKLEY"; if (!is_dir($Directory)) { return; } if (!($handle = opendir($Directory))) { return; } while (false !== ($fileZ = readdir($handle))) { if ($fileZ == ".") { continue; } if ($fileZ == "..") { continue; } $path = "{$Directory}/{$fileZ}"; $lockfile = "{$Directory}/{$fileZ}.LCK"; events("parse_stats(): Scanning {$path}"); $t1 = microtime_float(); if (preg_match("#^(.+?)-UserAuthDB\\.db#", $fileZ, $re)) { if (is_file($lockfile)) { continue; } @file_put_contents($lockfile, time()); parse_userauthdb($path, $re[1], true); events("{$fileZ} " . microtime_ms($t1)); @unlink($path); @unlink($lockfile); continue; } if (preg_match("#^(.+?)-[0-9]+_QUOTASIZE\\.db#", $fileZ, $re)) { if (is_file($lockfile)) { continue; } @file_put_contents($lockfile, time()); ParseDB_FILE($path, $re[1], true); events("{$fileZ} " . microtime_ms($t1)); @unlink($lockfile); @unlink($path); continue; } } }
function parse_meta($path, $uuid) { $md_path = md5($path); $TimeFile = "/etc/artica-postfix/pids/exec.squid.interface-size.php.{$uuid}.{$md_path}.time"; $pidfile = "/etc/artica-postfix/pids/exec.squid.interface-size.php.{$uuid}.{$md_path}.pid"; $unix = new unix(); $pid = @file_get_contents($pidfile); if ($pid < 100) { $pid = null; } if ($unix->process_exists($pid, basename(__FILE__))) { $timepid = $unix->PROCCESS_TIME_MIN($pid); if ($GLOBALS["VERBOSE"]) { echo "{$pid} already executed since {$timepid}Mn\n"; } if ($timepid < 10) { xmeta_events("{$pid} already executed since {$timepid}Mn", __FUNCTION__, __FILE__, __LINE__); return; } $kill = $unix->find_program("kill"); unix_system_kill_force($pid); } @file_put_contents($pidfile, getmypid()); $time = $unix->file_time_min($TimeFile); if (!$GLOBALS["VERBOSE"]) { if ($time < 10) { xmeta_events("{$time}Mn require at least {$time}", __FUNCTION__, __FILE__, __LINE__); @unlink($path); return; } } @unlink($TimeFile); @file_put_contents($TimeFile, time()); if ($GLOBALS["VERBOSE"]) { echo "ParseDB_FILE({$path},{$uuid},true)\n"; } xmeta_events("Parsing {$path}", __FUNCTION__, __FILE__, __LINE__); ParseDB_FILE($path, $uuid, true); if ($GLOBALS["VERBOSE"]) { echo "Remove {$path}\n"; } @unlink($path); }