static function getTrafficInfo($name) { $oldtime = time() - 40 * 3600; $newtime = time(); $file = "__path_httpd_root/{$name}/stats/{$name}-custom_log"; $file = expand_real_root($file); $fp = @lfopen($file, "r"); $total = 0; dprint("\n{$file}: " . @date('Y-m-d-H-i-s', $oldtime) . " {$newtime} " . @date('Y-m-d-H-i-s', $newtime) . "\n"); if (!$fp) { dprint("File Does Not Exist:returning Zero"); return 0; } $fsize = lfilesize($file); if ($fsize <= 10) { dprint("File Size is Less Than Zero and Returning Zero:\n"); return ""; } dprint("File Size is :{$fsize}\n\n\n"); if ($fsize > 20 * 1024) { fseek($fp, -19 * 1024, SEEK_END); $line = fgets($fp); } $i = 3; $total = 0; $count = 0; while (!feof($fp)) { $count++; $line = fgets($fp); $res[] = webtraffic::apacheLogFullString($line); } $c = 0; foreach ($res as $k => $r) { $c++; if ($count - 50 > $c) { unset($res[$k]); } } $ncount = 0; foreach ($res as $r) { if (!$r['Time']) { continue; } $file = strfrom($r['Request'], " "); $file = strtil($file, "HTTP"); $time = trim($r['Time'], "[]"); $time = strtil($time, " "); $o['realtime'] = $r['realtime']; $o['time'] = $time; $o['nname'] = $ncount; $o['file'] = $file; $o['referer'] = $r['Referer']; $o['remote_host'] = $r['Remote-Host']; $out[] = $o; $ncount++; } return $out; }
function lxfile_tail($file, $getsize) { $size = lfilesize($file); $fp = lfopen($file, "r"); if (!$fp) { return null; } fseek($fp, $size - $getsize); $ret = null; while (!feof($fp)) { $ret .= fread($fp, 1024); } return $ret; }
static function getEachwebfilequota($file, $oldtime, $newtime) { global $gbl, $sgbl, $login, $ghtml; $fp = @lfopen($file, "r"); $total = 0; print "\n{$file}: " . @date('Y-m-d-H', $oldtime) . " " . @date('Y-m-d-H', $newtime) . "\n"; if (!$fp) { print "File Does Not Exist:returning Zero"; return 0; } $fsize = lfilesize($file); if ($fsize <= 10) { print "File Size is Less Than Zero and Returning Zero:\n"; return 0; } print "File Size is :{$fsize}\n\n\n"; $ret = FindRightPosition($fp, $fsize, $oldtime, $newtime, array("webtraffic", "getTimeFromString")); if ($ret < 0) { return; } print "Current Position " . ftell($fp) / $fsize * 100 . "\n"; $total = 0; $count = 0; $break = 1000; while (!feof($fp)) { $count++; $line = fgets($fp); list($time, $size) = self::apacheLogConvertString($line); if ($time > $newtime) { break; } $total += $size; if ($count > 100000) { $break = 10000; } if (!($count % $break)) { print "Count {$count} {$newtime} {$time} {$total} {$size}\n"; } } print "{$count} lines actually processed in {$file}\n"; $total = $total / (1024 * 1024); $total = round($total, 1); fclose($fp); print "Returning Total From OUT SIDE This File: {$total} \n"; return $total; }