diff options
Diffstat (limited to 'config/sarg')
-rw-r--r-- | config/sarg/sarg.inc | 10 | ||||
-rwxr-xr-x | config/sarg/sarg_frame.php | 33 | ||||
-rwxr-xr-x | config/sarg/sarg_reports.php | 60 |
3 files changed, 25 insertions, 78 deletions
diff --git a/config/sarg/sarg.inc b/config/sarg/sarg.inc index c21d700d..3d04ce15 100644 --- a/config/sarg/sarg.inc +++ b/config/sarg/sarg.inc @@ -133,12 +133,20 @@ function sync_package_sarg() { break; case 'squid': $access_log='/var/squid/logs/access.log'; + if (is_array($config['installedpackages']['squid']['config'])) + if (file_exists($config['installedpackages']['squid']['config'][0]['log_dir']. '/access.log')) + $access_log = $config['installedpackages']['squid']['config'][0]['log_dir']. '/access.log'; break; case 'squidguard': $access_log='/var/squid/logs/access.log'; break; } - + if (!file_exists($access_log)){ + $error="Sarg config error: ".$sarg['proxy_server']." log file ($access_log) does not exists"; + log_error($error); + file_notice("Sarg", $error, "Sarg Settings", ""); + } + $graphs=(preg_match('/use_graphs/',$sarg['report_options'])?"yes":"no"); $anonymous_output_files=(preg_match('/anonymous_output_files/',$sarg['report_options'])?"yes":"no"); $resolve_ip=(preg_match('/resolve_ip/',$sarg['report_options'])?"yes":"no"); diff --git a/config/sarg/sarg_frame.php b/config/sarg/sarg_frame.php index 96b8c92f..5838e36b 100755 --- a/config/sarg/sarg_frame.php +++ b/config/sarg/sarg_frame.php @@ -38,22 +38,19 @@ else{ $prefix=""; } $url=($_REQUEST['file'] == ""?"index.html":$_REQUEST['file']); -$report=file_get_contents("/usr/local/www/sarg-reports/".$url); -/*$pattern[0]="/header_\w/"; -$replace[0]="listtopic"; -$pattern[1]="/class=.data./"; -$replace[1]='class="listlr"'; -$pattern[2]="/cellpadding=.\d./"; -$replace[2]='cellpadding="0"'; -$pattern[3]="/cellspacing=.\d./"; -$replace[3]='cellspacing="0"'; -$pattern[4]="/sarg/"; -$replace[4]='cellspacing="0"'; -*/ -$pattern[0]="/href=\W(\S+html)\W/"; -$replace[0]="href=/sarg_frame.php?file=$prefix/$1"; -$pattern[1]='/img src="(\w+\.\w+)/'; -$replace[1]='img src="/sarg-reports'.$prefix.'/$1'; - -print preg_replace($pattern,$replace,$report); +if (file_exists("/usr/local/www/sarg-reports/".$url)) + { + $report=file_get_contents("/usr/local/www/sarg-reports/".$url); + $pattern[0]="/href=\W(\S+html)\W/"; + $replace[0]="href=/sarg_frame.php?file=$prefix/$1"; + $pattern[1]='/img src="(\w+\.\w+)/'; + $replace[1]='img src="/sarg-reports'.$prefix.'/$1'; + $pattern[2]='@img src="([.a-z/]+)/(\w+\.\w+)@'; + $replace[2]='img src="/sarg-reports'.$prefix.'/$1/$2'; + print preg_replace($pattern,$replace,$report); + } +else{ + print "<pre>Error: Could not find report index file.<br>Check sarg settings and try to force sarg schedule."; + } + ?>
\ No newline at end of file diff --git a/config/sarg/sarg_reports.php b/config/sarg/sarg_reports.php index 9eee5302..bad7ba05 100755 --- a/config/sarg/sarg_reports.php +++ b/config/sarg/sarg_reports.php @@ -28,64 +28,7 @@ */ require("guiconfig.inc"); -function get_cmd(){ - global $config,$g; - if ($_REQUEST['cmd'] =='sarg'){ - - #Check report xml info - if (!is_array($config['installedpackages']['sargrealtime'])){ - $config['installedpackages']['sargrealtime']['config'][0]['realtime_types']= ""; - $config['installedpackages']['sargrealtime']['config'][0]['realtime_users']= ""; - } - #Check report http actions to show - if ($config['installedpackages']['sargrealtime']['config'][0]['realtime_types'] != $_REQUEST['qshape']){ - $config['installedpackages']['sargrealtime']['config'][0]['realtime_types']= $_REQUEST['qshape']; - $update_config++; - } - - #Check report users show - if ($config['installedpackages']['sargrealtime']['config'][0]['realtime_users'] != $_REQUEST['qtype']){ - $config['installedpackages']['sargrealtime']['config'][0]['realtime_users']= $_REQUEST['qtype']; - $update_config++; - } - - if($update_config > 0){ - write_config; - #write changes to sarg_file - $sarg_config=file_get_contents('/usr/local/etc/sarg/sarg.conf'); - $pattern[0]='/realtime_types\s+[A-Z,,]+/'; - $pattern[1]='/realtime_unauthenticated_records\s+\w+/'; - $replace[0]="realtime_types ".$_REQUEST['qshape']; - $replace[1]="realtime_unauthenticated_records ".$_REQUEST['qtype']; - file_put_contents('/usr/local/etc/sarg/sarg.conf', preg_replace($pattern,$replace,$sarg_config),LOCK_EX); - } - exec("/usr/local/bin/sarg -r", $sarg); - $patern[0]="/<?(html|head|style)>/"; - $replace[0]=""; - $patern[1]="/header_\w/"; - $replace[1]="listtopic"; - $patern[2]="/class=.data./"; - $replace[2]='class="listlr"'; - $patern[3]="/cellpadding=.\d./"; - $replace[3]='cellpadding="0"'; - $patern[4]="/cellspacing=.\d./"; - $replace[4]='cellspacing="0"'; - $patern[5]="/sarg/"; - $replace[5]='cellspacing="0"'; - - foreach ($sarg as $line){ - if (preg_match("/<.head>/",$line)) - $print ="ok"; - if ($print =="ok" && !preg_match("/(sarg realtime|Auto Refresh)/i",$line)) - print preg_replace($patern,$replace,$line); - } - } -} -if ($_REQUEST['cmd']!=""){ - get_cmd(); - } -else{ $pfSversion = str_replace("\n", "", file_get_contents("/etc/version")); if(strstr($pfSversion, "1.2")) $one_two = true; @@ -103,7 +46,7 @@ else{ <?php if ($savemsg) print_info_box($savemsg); ?> - <form action="postfix_view_config.php" method="post"> + <form> <div id="mainlevel"> <table width="100%" border="0" cellpadding="0" cellspacing="0"> @@ -139,7 +82,6 @@ else{ </form> <?php include("fend.inc"); - } ?> </body> </html> |