From b80a1bbd7eeaa741bb76755c30bfd7785cb0d395 Mon Sep 17 00:00:00 2001 From: "D. V. Serg" Date: Sat, 23 Feb 2008 18:38:40 +0000 Subject: Log view changes --- packages/squidGuard/squidguard.inc | 75 ++++++++++++++++++++++++-------------- 1 file changed, 47 insertions(+), 28 deletions(-) (limited to 'packages') diff --git a/packages/squidGuard/squidguard.inc b/packages/squidGuard/squidguard.inc index 2e882182..41ca4aad 100644 --- a/packages/squidGuard/squidguard.inc +++ b/packages/squidGuard/squidguard.inc @@ -691,6 +691,8 @@ function squidguard_before_form_acl($pkg, $is_acl=true) { // ----------------------------------------------------------------------------- // squidguard_before_form_log // ----------------------------------------------------------------------------- +define('LOGSHOW_BUFSIZE', 16384); + function squidguard_before_form_log($pkg) { global $config; $i=0; @@ -707,33 +709,50 @@ function squidguard_before_form_log($pkg) { if (empty($move_pos)) $move_pos = 0; if ($mlog['logtype'] == 'block_log') { - $slog .= 'block_log report disabled'; -/* $filename = SQUIDGUARD_LOGDIR . "/" . SQUIDGUARD_ACCESSBLOCK_FILE; - if (file_exists($filename)) { - $s = file_get_contents($filename); - $s = explode("\n", $s); -# while (count($s) > 500) array_shift($s); - $move_pos = count ($s) - $move_step; - if ($move_pos < 0) $move_pos = 0; - $s = array_slice($s, $move_pos, $move_step); - - $slog .= "NumDateTimeIPURLFilterIDMtd"; - foreach($s as $key => $vs) { - $nkey = $move_pos + intval($key); - $slog .= ""; - $sx = $vs; - $sx = str_replace("/- -", "", $sx); - $sx = str_replace("/-", "", $sx); - $sx = str_replace("Request", "", $sx); - $sx = str_replace("request", "", $sx); - $sx = str_replace("(", "", $sx); - $sx = str_replace(")", "", $sx); - $sx = str_replace("[", "", $sx); - $sx = str_replace("]", "", $sx); - $sx = explode(" ", $sx); - if (!empty($vs)) - $slog .= " + $fh = ''; + if (file_exists($filename)) { + $fh = fopen($filename, "r"); + if ($fh) { + $fsize = filesize($filename); + // take LOGSHOW_BUFSIZE bytes from end + if ($fsize > LOGSHOW_BUFSIZE) + fseek($fh, -LOGSHOW_BUFSIZE, SEEK_END); + $s = fread($fh, LOGSHOW_BUFSIZE); + fclose($fh); + + $slog .= "Block log '$filename'. Last 100:"; + + $s = explode("\n", $s); + unset($s[0]); // unset us'nt complete string + + $slog .= "NumDateTimeIPURLFilterIDMtd"; + foreach($s as $key => $vs) { + $nkey = $move_pos + intval($key); + $slog .= ""; + $sx = $vs; + $sx = str_replace("/- -", "", $sx); + $sx = str_replace("/-", "", $sx); + $sx = str_replace("Request", "", $sx); + $sx = str_replace("request", "", $sx); + $sx = str_replace("(", "", $sx); + $sx = str_replace(")", "", $sx); + $sx = str_replace("[", "", $sx); + $sx = str_replace("]", "", $sx); + $sx = explode(" ", $sx); + + // formatting url + $spos =0; + $stmp = ''; + while($spos + 81 < strlen($sx[4])) { + $stmp .= substr($sx[4], $spos, 81) . "
"; + $spos += 81; + } + $stmp .= substr($sx[4], $spos, strlen($sx[4]) - $spos); + $sx[4] = $stmp; + + if (!empty($vs)) + $slog .= " " . strval($nkey) . " $sx[0] $sx[1] $sx[5] @@ -741,10 +760,10 @@ function squidguard_before_form_log($pkg) { $sx[3] $sx[2] $sx[6]"; + } } -# $slog .= ""; } -*/ + } else if ($mlog['logtype'] == 'configurator_log') { -- cgit v1.2.3