function firewall_finish($t) { global $__firewall_ip_stats, $__current_ip_stat; $ip = $_SERVER["REMOTE_ADDR"]; $stats = getIpStats(); $stat = $stats->fetch($ip); if ($stat === FALSE) { $stat = new IpStat($ip); $exists = FALSE; } else { $exists = TRUE; } $stat->access_count++; $imei = imei(); $pid = pid(false); if ($imei !== null) { $stat->imei = $imei; } if ($pid !== null) { $stat->pid = $pid; } $stat->url = $_SERVER["REQUEST_URI"]; $now = microtime(true); if ($stat->last_time) { $elapsed = $now - $stat->last_time; if ($elapsed >= 5) { $elapsed = 5; } $stat->frequency = $stat->frequency * (5 - $elapsed) / 5 + 1; } $stat->last_time = $now; $stat->execute_time += $t; $stats->store($ip, $stat, $exists); }
/** * Collect snipes data */ function snipes() { $snipes = array(); foreach (glob(DATADIR . '/*.txt') as $file) { $data = file($file, FILE_IGNORE_NEW_LINES); $name = trim($data[0], '# '); $log = DATADIR . '/' . hashname($name) . '.log'; $items = array(); foreach ($data as $line) { // Ignore empty and comment lines if ('' == ($line = preg_replace('~^\\s*#.*~m', '', $line))) { continue; } $items[] = explode(' ', $line)[0]; } $snipes[$name] = array('name' => $name, 'data' => implode(PHP_EOL, $data), 'items' => $items, 'pid' => pid($name), 'log' => is_file($log) ? utf8_encode(trim(file_get_contents($log))) : ''); } ksort($snipes); return $snipes; }
function ttest() { return $this->f(pid('arg1'), pid('arg2')); }
function ttest() { return f(pid('arg1'), pid('arg2')); }