From 13877cb7190125e35bb4e467f0fe827d10334503 Mon Sep 17 00:00:00 2001 From: Marcello Coutinho Date: Wed, 19 Sep 2012 12:05:33 -0300 Subject: sarg - add missing sarg.inc changes to 0.6.1 --- config/sarg/sarg.inc | 66 +++++++++++++++++++++++++++++++++++----------------- 1 file changed, 45 insertions(+), 21 deletions(-) (limited to 'config/sarg/sarg.inc') diff --git a/config/sarg/sarg.inc b/config/sarg/sarg.inc index 2560fb76..a6dbb081 100644 --- a/config/sarg/sarg.inc +++ b/config/sarg/sarg.inc @@ -31,17 +31,28 @@ POSSIBILITY OF SUCH DAMAGE. */ /* ========================================================================== */ - +$pf_version=substr(trim(file_get_contents("/etc/version")),0,3); +if ($pf_version > 2.0){ + define('SARG_DIR', '/usr/pbi/sarg-' . php_uname("m")); + define('SQUID_DIR', '/usr/pbi/squid-' . php_uname("m")); + define('DANSG_DIR', '/usr/pbi/dansguardian-' . php_uname("m")); + } +else{ + define('SARG_DIR', '/usr/local'); + define('SQUID_DIR', '/usr/local'); + define('DANSG_DIR', '/usr/local'); +} + $uname=posix_uname(); if ($uname['machine']=='amd64') ini_set('memory_limit', '250M'); // STATIC VARS -$sarg_proxy=array( 'squid_rc'=>'/usr/local/etc/rc.d/squid.sh', - 'squid_config'=>'/var/squid/logs/access.log', - 'squidguard_config'=>'/usr/local/etc/squidGuard/squidGuard.conf', +$sarg_proxy=array( 'squid_rc'=> SQUID_DIR . '/etc/rc.d/squid.sh', + 'squid_config'=> '/var/squid/logs/access.log', + 'squidguard_config'=> SARG_DIR . '/etc/squidGuard/squidGuard.conf', 'squidguard_block_log'=>'/var/squidGuard/log/block.log', - 'dansguardian_config'=>'/usr/local/etc/dansguardian/dansguardian.conf', + 'dansguardian_config'=> DANSG_DIR . '/etc/dansguardian/dansguardian.conf', 'dansguardian_log'=>'/var/log/dansguardian/access.log'); // END STATIC VARS @@ -84,13 +95,14 @@ function run_sarg($id=-1) { global $config, $g,$sarg_proxy; #mount filesystem writeable conf_mount_rw(); - $cmd = "/usr/local/bin/sarg"; + $cmd = SARG_DIR . "/bin/sarg"; if ($id >= 0 && is_array($config['installedpackages']['sargschedule']['config'])){ $args=$config['installedpackages']['sargschedule']['config'][$id]['args']; $action=$config['installedpackages']['sargschedule']['config'][$id]['action']; $gzip=$config['installedpackages']['sargschedule']['config'][$id]['gzip']; $find=$config['installedpackages']['sargschedule']['config'][$id]['find']; $gziplevel=$config['installedpackages']['sargschedule']['config'][$id]['gziplevel']; + $daylimit=$config['installedpackages']['sargschedule']['config'][$id]['daylimit']; } else{ $args=$_POST['args']; @@ -98,14 +110,15 @@ function run_sarg($id=-1) { $gzip=$_POST['gzip']; $find=$_POST['find']; $gziplevel=$_POST['gziplevel']; + $daylimit=""; } $find=(preg_match("/(\d+)/",$find,$find_matches) ? $find_matches[1] : "60"); log_error("Sarg: force refresh now with {$args} args, compress({$gzip}) and {$action} action after sarg finish."); + $gzip_script="#!/bin/sh\n"; if ($gzip=="on"){ #remove old file if exists unlink_if_exists("/root/sarg_run_{$id}.sh"); - $gzip_script=<<