aboutsummaryrefslogtreecommitdiffstats
path: root/config/squid-reverse
diff options
context:
space:
mode:
authorMarcello Coutinho <marcellocoutinho@gmail.com>2012-05-07 18:48:50 -0300
committermarcelloc <marcellocoutinho@gmail.com>2012-05-07 18:48:50 -0300
commit97ca4a44ae840344dd9cae135ac3835dbfed6ec9 (patch)
tree4a3923bd2a389678ff658104ca91f28396f672f9 /config/squid-reverse
parente65bbe0559a2c0080dd30863df6c7011c78e4be4 (diff)
downloadpfsense-packages-97ca4a44ae840344dd9cae135ac3835dbfed6ec9.tar.gz
pfsense-packages-97ca4a44ae840344dd9cae135ac3835dbfed6ec9.tar.bz2
pfsense-packages-97ca4a44ae840344dd9cae135ac3835dbfed6ec9.zip
squid3 - fix xml rpc sync call
Diffstat (limited to 'config/squid-reverse')
-rw-r--r--config/squid-reverse/squid.inc2
-rw-r--r--config/squid-reverse/squid.xml2
-rw-r--r--config/squid-reverse/squid_monitor.php329
-rw-r--r--config/squid-reverse/squid_monitor_data.php325
4 files changed, 353 insertions, 305 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 @@
</custom_php_validation_command>
<custom_php_resync_config_command>
squid_resync();
- exec("/bin/rm -f /usr/local/etc/rc.d/squid");
+ unlink_if_exists("/usr/local/etc/rc.d/squid");
</custom_php_resync_config_command>
<custom_php_install_command>
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 @@
-<?php
-/* $Id$ */
-/* ========================================================================== */
-/*
- squid_monitor.php
- part of pfSense (http://www.pfSense.com)
- Copyright (C) 2012 ccesario @ pfsense forum
- All rights reserved.
-
-/* ========================================================================== */
-/*
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
- */
-/* ========================================================================== */
-
-
-require_once("/etc/inc/util.inc");
-require_once("/etc/inc/functions.inc");
-require_once("/etc/inc/pkg-utils.inc");
-require_once("/etc/inc/globals.inc");
-
-require_once("guiconfig.inc");
-
-
-
-$pfSversion = str_replace("\n", "", file_get_contents("/etc/version"));
-if(strstr($pfSversion, "1.2"))
- $one_two = true;
-
-$pgtitle = "Status: Proxy Monitor";
-include("head.inc");
-?>
-
-<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
-<?php include("fbegin.inc"); ?>
-
-<?php if($one_two): ?>
-<p class="pgtitle"><?=$pgtitle?></font></p>
-<?php endif; ?>
-
-<?php if ($savemsg) print_info_box($savemsg); ?>
-
-<!-- Function to call squid logs -->
-<script language="JavaScript">
- function ShowLog(content,url,program)
- {
- var v_maxlines = $('maxlines').getValue();
- var v_strfilter = $('strfilter').getValue();
- var pars = 'maxlines='+escape(v_maxlines) + '&strfilter=' + escape(v_strfilter) + '&program=' + escape(program);
- new Ajax.Updater(content,url, {
- method: 'post',
- parameters: pars,
- onSuccess: function() {
- window.setTimeout( ShowLog(content,url,program), 100 );
- }
- });
- }
-
-
-</script>
-
-
-<table width="100%" border="0" cellpadding="0" cellspacing="0">
- <tr>
- <td id="mainarea">
- <div class="tabcont">
- <div id="param">
- <form id="paramsForm" name="paramsForm" method="post">
- <table width="100%" border="0" cellpadding=5" cellspacing="0">
- <tr>
- <td width="15%" valign="top" class="vncell"><?php echo "Max lines:"; ?></td>
- <td width="85%" class="vtable">
- <select name="maxlines" id="maxlines">
- <option value="5">5 lines</option>
- <option value="10" selected="selected">10 lines</option>
- <option value="15">15 lines</option>
- <option value="20">20 lines</option>
- <option value="25">25 lines</option>
- <option value="30">30 lines</option>
- </select>
- <br/>
- <span class="vexpl">
- <?php echo "Max. lines to be displayed."; ?>
- </span>
- </td>
- </tr>
- <tr>
- <td width="15%" valign="top" class="vncell"><?php echo "String filter:"; ?></td>
- <td width="85%" class="vtable">
- <input name="strfilter" type="text" class="formfld unknown" id="strfilter" size="50" value="">
- <br/>
- <span class="vexpl">
- <?php echo "Enter the string filter: eg. username or ip addr or url."; ?>
- </span>
- </td>
- </tr>
- </table>
- </form>
- </div>
-
- <form>
- <table width="100%" border="0" cellpadding="0" cellspacing="0">
- <tr>
- <td colspan="2" valign="top" class="listtopic">
- <center>
- Squid Proxy
- </center>
- </td>
- </tr>
- <tr>
- <td>
- <table iD="squidView" width="100%" border="0" cellpadding="0" cellspacing="0">
- <script language="JavaScript">
- ShowLog('squidView', 'squid_monitor_data.php','squid');
- </script>
- </table>
- </td>
- </tr>
- <tr>
- <td colspan="2" valign="top" class="listtopic">
- <center>
- SquidGuard
- </center>
- </td>
- </tr>
- <tr>
- <td>
- <table id="sguardView" width="100%" border="0" cellpadding="5" cellspacing="0">
- <script language="JavaScript">
- ShowLog('sguardView', 'squid_monitor_data.php','sguard');
- </script>
- </table>
- </td>
- </tr>
- </table>
- </form>
- </div>
- </td>
- </tr>
-</table>
-
-<?php
-include("fend.inc");
-?>
-
-</body>
-</html>
-
+<?php
+/* $Id$ */
+/* ========================================================================== */
+/*
+ squid_monitor.php
+ part of pfSense (http://www.pfSense.com)
+ Copyright (C) 2012 ccesario @ pfsense forum
+ All rights reserved.
+
+/* ========================================================================== */
+/*
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+ */
+/* ========================================================================== */
+
+require_once("/etc/inc/util.inc");
+require_once("/etc/inc/functions.inc");
+require_once("/etc/inc/pkg-utils.inc");
+require_once("/etc/inc/globals.inc");
+require_once("guiconfig.inc");
+
+$pfSversion = str_replace("\n", "", file_get_contents("/etc/version"));
+if(strstr($pfSversion, "1.2"))
+ $one_two = true;
+
+$pgtitle = "Status: Proxy Monitor";
+include("head.inc");
+?>
+
+<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
+
+<?php include("fbegin.inc"); ?>
+
+<?php if($one_two): ?>
+
+ <p class="pgtitle"><?=$pgtitle?></font></p>
+
+<?php endif; ?>
+
+<?php if ($savemsg) print_info_box($savemsg); ?>
+
+<!-- Function to call programs logs -->
+<script language="JavaScript">
+ function showLog(content,url,program)
+ {
+ new PeriodicalExecuter(function(pe) {
+ new Ajax.Updater(content, url, {
+ method: 'post',
+ asynchronous: true,
+ evalScripts: true,
+ parameters: { maxlines: $('maxlines').getValue(),
+ strfilter: $('strfilter').getValue(),
+ program: program }
+ })
+ }, 1)
+ }
+</script>
+
+
+<div id="mainarea" style="padding-top: 0px; padding-bottom: 0px; ">
+ <form id="paramsForm" name="paramsForm" method="post">
+ <table class="tabcont" width="100%" border="0" cellspacing="0" cellpadding="6">
+ <tbody>
+ <tr>
+ <td width="22%" valign="top" class="vncellreq">Max lines:</td>
+ <td width="78%" class="vtable">
+ <select name="maxlines" id="maxlines">
+ <option value="5">5 lines</option>
+ <option value="10" selected="selected">10 lines</option>
+ <option value="15">15 lines</option>
+ <option value="20">20 lines</option>
+ <option value="25">25 lines</option>
+ <option value="30">30 lines</option>
+ </select>
+ <br/>
+ <span class="vexpl">
+ Max. lines to be displayed.
+ </span>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncellreq">String filter:</td>
+ <td width="78%" class="vtable">
+ <input name="strfilter" type="text" class="formfld search" id="strfilter" size="50" value="">
+ <br/>
+ <span class="vexpl">
+ Enter the string filter: eg. username or ip addr or url.
+ </span>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ </form>
+
+ <!-- Squid Table -->
+ <table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tbody>
+ <tr>
+ <td>
+ <table class="tabcont" width="100%" border="0" cellspacing="0" cellpadding="0">
+ <tr>
+ <td colspan="6" class="listtopic"><center><?=gettext("Squid Logs"); ?><center></td>
+ </tr>
+ <tbody id="squidView">
+ <script language="JavaScript">
+ // Call function to show squid log
+ showLog('squidView', 'squid_monitor_data.php','squid');
+ </script>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+
+ <!-- SquidGuard Table -->
+ <table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tbody>
+ <tr>
+ <td>
+ <table class="tabcont" width="100%" border="0" cellspacing="0" cellpadding="0">
+ <tr>
+ <td colspan="5" class="listtopic"><center><?=gettext("SquidGuard Logs"); ?><center></td>
+ </tr>
+ <tbody id="sguardView">
+ <script language="JavaScript">
+ // Call function to show squidGuard log
+ showLog('sguardView', 'squid_monitor_data.php','sguard');
+ </script>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+</div>
+
+<?php
+include("fend.inc");
+?>
+
+</body>
+</html>
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 @@
-<?php
-/* $Id$ */
-/* ========================================================================== */
-/*
- squid_monitor_data.php
- part of pfSense (http://www.pfSense.com)
- Copyright (C) 2012 ccesario @ pfsense forum
- All rights reserved.
-
-/* ========================================================================== */
-/*
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
- */
-/* ========================================================================== */
-if ($_POST) {
- switch (strtolower($_POST['program'])) {
- case 'squid':
- showSquid();
- break;
- case 'sguard';
- showSGuard();
- break;
- }
-}
-
-
-
-// Show Squid Logs
-function showSquid() {
- echo "<tr>";
- echo "<td class=\"listhdrr\">Date</td>";
- echo "<td class=\"listhdrr\">IP</td>";
- echo "<td class=\"listhdrr\">Status</td>";
- echo "<td class=\"listhdrr\">Address</td>";
- echo "<td class=\"listhdrr\">User</td>";
- echo "<td class=\"listhdrr\">Destination</td>";
- echo "</tr>";
-
- // 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/","<spam style='color:red'>$filter</spam>",$logline);
-
- echo "<tr>\n";
- echo "<td class=\"listr\">".date("d/m/y H:i:s",$logline[0])."</td>\n";
- echo "<td class=\"listr\">".$logline[2]."</td>\n";
- echo "<td class=\"listr\">".$logline[3]."</td>\n";
- echo "<td class=\"listr\" nowrap>".$logline[6]."</td>\n";
- echo "<td class=\"listr\">".$logline[7]."</td>\n";
- echo "<td class=\"listr\">".$logline[8]."</td>\n";
- echo "</tr>\n";
- }
-}
-
-// Show SquidGuard Logs
-function showSGuard() {
-
-
- echo "<tr>";
- echo "<td class=\"listhdrr\">Date</td>";
- echo "<td class=\"listhdrr\">Hour</td>";
- echo "<td class=\"listhdrr\">ACL</td>";
- echo "<td class=\"listhdrr\">Address</td>";
- echo "<td class=\"listhdrr\">Host</td>";
- echo "<td class=\"listhdrr\">User</td>";
- echo "</tr>";
-
-
- // 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/","<spam style='color:red'>$filter</spam>",$logline);
-
- echo "<tr>\n";
- echo "<td class=\"listr\">".$logline[0]."</td>\n";
- echo "<td class=\"listr\">".$logline[1]."</td>\n";
- echo "<td class=\"listr\">".$logline[3]."</td>\n";
- echo "<td class=\"listr\">".$logline[4]."</td>\n";
- echo "<td class=\"listr\">".$logline[5]."</td>\n";
- echo "<td class=\"listr\">".$logline[6]."</td>\n";
- echo "</tr>\n";
- }
-}
-
-?>
+<?php
+/* $Id$ */
+/* ========================================================================== */
+/*
+ squid_monitor.php
+ part of pfSense (http://www.pfSense.com)
+ Copyright (C) 2012 ccesario @ pfsense forum
+ All rights reserved.
+
+/* ========================================================================== */
+/*
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+ */
+/* ========================================================================== */
+
+# ------------------------------------------------------------------------------
+# Defines
+# ------------------------------------------------------------------------------
+require_once("guiconfig.inc");
+
+# ------------------------------------------------------------------------------
+# Requests
+# ------------------------------------------------------------------------------
+if ($_POST) {
+ # Actions
+ switch (strtolower($_POST['program'])) {
+ case 'squid':
+ showSquid();
+ break;
+ case 'sguard';
+ showSGuard();
+ break;
+ }
+}
+
+# ------------------------------------------------------------------------------
+# Functions
+# ------------------------------------------------------------------------------
+
+// From SquidGuard Package
+function html_autowrap($cont)
+{
+ # split strings
+ $p = 0;
+ $pstep = 25;
+ $str = $cont;
+ $cont = '';
+ for ( $p = 0; $p < strlen($str); $p += $pstep ) {
+ $s = substr( $str, $p, $pstep );
+ if ( !$s ) break;
+ $cont .= $s . "<wbr/>";
+ }
+ return $cont;
+}
+
+
+// Show Squid Logs
+function showSquid() {
+ // Define log file
+ $squid_log='/var/squid/logs/access.log';
+
+ echo "<tr valign=\"top\">\n";
+ echo "<td class=\"listhdrr\">".gettext("Date")."</td>\n";
+ echo "<td class=\"listhdrr\">".gettext("IP")."</td>\n";
+ echo "<td class=\"listhdrr\">".gettext("Status")."</td>\n";
+ echo "<td class=\"listhdrr\">".gettext("Address")."</td>\n";
+ echo "<td class=\"listhdrr\">".gettext("User")."</td>\n";
+ echo "<td class=\"listhdrr\">".gettext("Destination")."</td>\n";
+ echo "</tr>\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","<spam><font color='red'>$filter</font></span>",$logline);
+
+
+ echo "<tr valign=\"top\">\n";
+ echo "<td class=\"listlr\" nowrap>{$logline[0]} {$logline[1]}</td>\n";
+ echo "<td class=\"listr\">{$logline[3]}</td>\n";
+ echo "<td class=\"listr\">{$logline[4]}</td>\n";
+ echo "<td class=\"listr\" width=\"*\">{$logline[7]}</td>\n";
+ echo "<td class=\"listr\">{$logline[8]}</td>\n";
+ echo "<td class=\"listr\">{$logline_dest[1]}</td>\n";
+ echo "</tr>\n";
+ }
+}
+
+// Show SquidGuard Logs
+function showSGuard() {
+ // Define log file
+ $sguard_log='/var/squidGuard/log/block.log';
+
+ echo "<tr valign=\"top\">\n";
+ echo "<td class=\"listhdrr\">".gettext("Date-Time")."</td>\n";
+ echo "<td class=\"listhdrr\">".gettext("ACL")."</td>\n";
+ echo "<td class=\"listhdrr\">".gettext("Address")."</td>\n";
+ echo "<td class=\"listhdrr\">".gettext("Host")."</td>\n";
+ echo "<td class=\"listhdrr\">".gettext("User")."</td>\n";
+ echo "</tr>\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/","<spam><font color='red'>$filter</font></span>",$logline);
+
+ echo "<tr>\n";
+ echo "<td class=\"listlr\" nowrap>{$logline[0]} {$logline[1]}</td>\n";
+ echo "<td class=\"listr\">{$logline[3]}</td>\n";
+ echo "<td class=\"listr\" width=\"*\">{$logline[4]}</td>\n";
+ echo "<td class=\"listr\">{$logline[5]}</td>\n";
+ echo "<td class=\"listr\">{$logline[6]}</td>\n";
+ echo "</tr>\n";
+ }
+}
+
+?>