From 97ca4a44ae840344dd9cae135ac3835dbfed6ec9 Mon Sep 17 00:00:00 2001 From: Marcello Coutinho Date: Mon, 7 May 2012 18:48:50 -0300 Subject: squid3 - fix xml rpc sync call --- config/squid-reverse/squid.inc | 2 +- config/squid-reverse/squid.xml | 2 +- config/squid-reverse/squid_monitor.php | 329 ++++++++++++++-------------- config/squid-reverse/squid_monitor_data.php | 325 +++++++++++++++------------ pkg_config.8.xml | 2 +- pkg_config.8.xml.amd64 | 2 +- 6 files changed, 355 insertions(+), 307 deletions(-) diff --git a/config/squid-reverse/squid.inc b/config/squid-reverse/squid.inc index b6386eaa..66f7e51c 100644 --- a/config/squid-reverse/squid.inc +++ b/config/squid-reverse/squid.inc @@ -1826,7 +1826,7 @@ function squid_do_xmlrpc_sync($sync_to_ip, $username, $password) { /* tell squid to reload our settings on the destionation sync host. */ $method = 'pfsense.exec_php'; $execcmd = "require_once('/usr/local/pkg/squid.inc');\n"; - $execcmd .= "sync_package_squid();"; + $execcmd .= "squid_resync();"; /* assemble xmlrpc payload */ $params = array( XML_RPC_encode($password), diff --git a/config/squid-reverse/squid.xml b/config/squid-reverse/squid.xml index 764011ea..2a7771b3 100644 --- a/config/squid-reverse/squid.xml +++ b/config/squid-reverse/squid.xml @@ -408,7 +408,7 @@ squid_resync(); - exec("/bin/rm -f /usr/local/etc/rc.d/squid"); + unlink_if_exists("/usr/local/etc/rc.d/squid"); update_status("Checking Squid cache... One moment please..."); diff --git a/config/squid-reverse/squid_monitor.php b/config/squid-reverse/squid_monitor.php index cbcc8918..d8f5240b 100644 --- a/config/squid-reverse/squid_monitor.php +++ b/config/squid-reverse/squid_monitor.php @@ -1,167 +1,162 @@ - - - - - - -

- - - - - - - - - - - - -
-
-
-
- - - - - - - - - -
- -
- - - -
- -
- - - -
-
-
- -
- - - - - - - - - - - - - -
-
- Squid Proxy -
-
- - -
-
-
- SquidGuard -
-
- - -
-
-
-
-
- - - - - - + + + + + + + + +

+ + + + + + + + + +
+
+ + + + + + + + + + + +
Max lines: + +
+ + Max. lines to be displayed. + +
String filter: + +
+ + Enter the string filter: eg. username or ip addr or url. + +
+
+ + + + + + + + +
+ + + + + + + +
+
+ + + + + + + + +
+ + + + + + + +
+
+
+ + + + + diff --git a/config/squid-reverse/squid_monitor_data.php b/config/squid-reverse/squid_monitor_data.php index 46280446..0e9d900a 100644 --- a/config/squid-reverse/squid_monitor_data.php +++ b/config/squid-reverse/squid_monitor_data.php @@ -1,136 +1,189 @@ -"; - echo "Date"; - echo "IP"; - echo "Status"; - echo "Address"; - echo "User"; - echo "Destination"; - echo ""; - - // Get Data from form post - $lines = $_POST['maxlines']; - $filter = $_POST['strfilter']; - - if ($filter != "") { - $exprfilter = "| grep -i $filter"; - } else { - $exprfilter = ""; - } - - // TODO FIX: - // Remove the hard link (maybe, get from config) - // - exec("tail -r -n $lines /var/squid/logs/access.log $exprfilter",$logarr); - - foreach ($logarr as $logent) { - $logline = preg_split("/\s+/", $logent); - - if ($filter != "") - $logline = preg_replace("/$filter/","$filter",$logline); - - echo "\n"; - echo "".date("d/m/y H:i:s",$logline[0])."\n"; - echo "".$logline[2]."\n"; - echo "".$logline[3]."\n"; - echo "".$logline[6]."\n"; - echo "".$logline[7]."\n"; - echo "".$logline[8]."\n"; - echo "\n"; - } -} - -// Show SquidGuard Logs -function showSGuard() { - - - echo ""; - echo "Date"; - echo "Hour"; - echo "ACL"; - echo "Address"; - echo "Host"; - echo "User"; - echo ""; - - - // Get Data from form post - $lines = $_POST['maxlines']; - $filter = $_POST['strfilter']; - - if ($filter != "") { - $exprfilter = "| grep -i $filter"; - } else { - $exprfilter = ""; - } - - // TODO FIX: - // Remove the hard link (maybe, get from config) - // - exec("tail -r -n $lines /var/squidGuard/log/block.log $exprfilter",$logarr); - - foreach ($logarr as $logent) { - $logline = preg_split("/\s+/", $logent); - - if ($filter != "") - $logline = preg_replace("/$filter/","$filter",$logline); - - echo "\n"; - echo "".$logline[0]."\n"; - echo "".$logline[1]."\n"; - echo "".$logline[3]."\n"; - echo "".$logline[4]."\n"; - echo "".$logline[5]."\n"; - echo "".$logline[6]."\n"; - echo "\n"; - } -} - -?> +"; + } + return $cont; +} + + +// Show Squid Logs +function showSquid() { + // Define log file + $squid_log='/var/squid/logs/access.log'; + + echo "\n"; + echo "".gettext("Date")."\n"; + echo "".gettext("IP")."\n"; + echo "".gettext("Status")."\n"; + echo "".gettext("Address")."\n"; + echo "".gettext("User")."\n"; + echo "".gettext("Destination")."\n"; + echo "\n"; + + // Get Data from form post + $lines = $_POST['maxlines']; + $filter = $_POST['strfilter']; + + + // Get logs based in filter expression + if($filter != "") { + exec("tail -r -n $lines $squid_log | php -q parser_squid_log.php | grep -i ". escapeshellarg(htmlspecialchars($filter)), $logarr); + } + else { + exec("tail -r -n $lines $squid_log | php -q parser_squid_log.php", $logarr); + } + + // Print lines + foreach ($logarr as $logent) { + // Split line by space delimiter + $logline = preg_split("/\s+/", $logent); + + // Apply date format to first line + //$logline[0] = date("d.m.Y H:i:s",$logline[0]); + + // Word wrap the URL + $logline[7] = htmlentities($logline[7]); + $logline[7] = html_autowrap($logline[7]); + + // Remove /(slash) in destination row + $logline_dest = preg_split("/\//", $logline[9]); + + // Apply filter and color + // Need validate special chars + if ($filter != "") + $logline = preg_replace("/$filter/i","$filter",$logline); + + + echo "\n"; + echo "{$logline[0]} {$logline[1]}\n"; + echo "{$logline[3]}\n"; + echo "{$logline[4]}\n"; + echo "{$logline[7]}\n"; + echo "{$logline[8]}\n"; + echo "{$logline_dest[1]}\n"; + echo "\n"; + } +} + +// Show SquidGuard Logs +function showSGuard() { + // Define log file + $sguard_log='/var/squidGuard/log/block.log'; + + echo "\n"; + echo "".gettext("Date-Time")."\n"; + echo "".gettext("ACL")."\n"; + echo "".gettext("Address")."\n"; + echo "".gettext("Host")."\n"; + echo "".gettext("User")."\n"; + echo "\n"; + + // Get Data from form post + $lines = $_POST['maxlines']; + $filter = $_POST['strfilter']; + + // Get logs based in filter expression + if($filter != "") { + exec("tail -r -n $lines $sguard_log | grep -i ". escapeshellarg(htmlspecialchars($filter)), $logarr); + } + else { + exec("tail -r -n $lines $sguard_log", $logarr); + } + + + // Print lines + foreach ($logarr as $logent) { + // Split line by space delimiter + $logline = preg_split("/\s+/", $logent); + + // Apply time format + $logline[0] = date("d.m.Y", strtotime($logline[0])); + + // Word wrap the URL + $logline[4] = htmlentities($logline[4]); + $logline[4] = html_autowrap($logline[4]); + + + // Apply filter color + // Need validate special chars + if ($filter != "") + $logline = preg_replace("/$filter/","$filter",$logline); + + echo "\n"; + echo "{$logline[0]} {$logline[1]}\n"; + echo "{$logline[3]}\n"; + echo "{$logline[4]}\n"; + echo "{$logline[5]}\n"; + echo "{$logline[6]}\n"; + echo "\n"; + } +} + +?> diff --git a/pkg_config.8.xml b/pkg_config.8.xml index 83b88a99..9ffbd881 100644 --- a/pkg_config.8.xml +++ b/pkg_config.8.xml @@ -1010,7 +1010,7 @@ http://forum.pfsense.org/index.php/topic,48347.0.html http://www.squid-cache.org/ Network - 3.1.19 pkg 2.0.5 + 3.1.19 pkg 2.0.5_1 beta 2.0 marcellocoutinho@gmail.com fernando@netfilter.com.br seth.mos@dds.nl mfuchs77@googlemail.com jimp@pfsense.org diff --git a/pkg_config.8.xml.amd64 b/pkg_config.8.xml.amd64 index 6cc195b5..6af156e5 100644 --- a/pkg_config.8.xml.amd64 +++ b/pkg_config.8.xml.amd64 @@ -118,7 +118,7 @@ http://forum.pfsense.org/index.php/topic,48347.0.html http://www.squid-cache.org/ Network - 3.1.19 pkg 2.0.5 + 3.1.19 pkg 2.0.5_1 beta 2.0 fernando@netfilter.com.br seth.mos@dds.nl mfuchs77@googlemail.com jimp@pfsense.org -- cgit v1.2.3