aboutsummaryrefslogtreecommitdiffstats
path: root/config/sarg
diff options
context:
space:
mode:
Diffstat (limited to 'config/sarg')
-rw-r--r--config/sarg/sarg.inc23
-rw-r--r--config/sarg/sarg.priv.inc12
-rw-r--r--config/sarg/sarg.template2
-rw-r--r--config/sarg/sarg.xml5
-rwxr-xr-xconfig/sarg/sarg_frame.php29
-rwxr-xr-xconfig/sarg/sarg_reports.php1
-rw-r--r--config/sarg/sarg_schedule.xml3
7 files changed, 61 insertions, 14 deletions
diff --git a/config/sarg/sarg.inc b/config/sarg/sarg.inc
index 2bcd4115..0927b164 100644
--- a/config/sarg/sarg.inc
+++ b/config/sarg/sarg.inc
@@ -139,6 +139,9 @@ function sync_package_sarg() {
if (!preg_match("/\w+/",$_POST['__csrf_magic']))
return;
}
+ #check pkg.php sent a sync request
+
+
$update_conf=0;
#mount filesystem writeable
conf_mount_rw();
@@ -246,12 +249,26 @@ function sync_package_sarg() {
$LDAPFilterSearch=(empty($sarguser['ldap_filter_search'])?"":"LDAPFilterSearch ".$sarguser['ldap_filter_search']);
}
- #dirs
- $dirs=array("/usr/local/www/sarg-reports");
+
+ #move old reports
+ if (is_dir("/usr/local/www/sarg-reports") && !is_dir("/usr/local/sarg-reports"))
+ rename("/usr/local/www/sarg-reports","/usr/local/sarg-reports");
+
+ #check dirs
+ $dirs=array("/usr/local/sarg-reports","/usr/local/www/sarg-images","/usr/local/www/sarg-images/temp");
foreach ($dirs as $dir)
if (!is_dir($dir))
mkdir ($dir,0755,true);
-
+
+ #images
+ $simages=array("datetime.png","graph.png","sarg-squidguard-block.png","sarg.png");
+ $simgdir1="/usr/local/www/sarg-images";
+ $simgdir2="/usr/local/etc/sarg/images";
+ foreach ($simages as $simage){
+ if (!file_exists("{$simgdir1}/{$simage}"))
+ copy("{$simgdir2}/{$simage}","{$simgdir1}/{$simage}");
+ }
+
//log_error($_POST['__csrf_magic']." sarg log:". $access_log);
#create sarg config files
include("/usr/local/pkg/sarg.template");
diff --git a/config/sarg/sarg.priv.inc b/config/sarg/sarg.priv.inc
new file mode 100644
index 00000000..2de21519
--- /dev/null
+++ b/config/sarg/sarg.priv.inc
@@ -0,0 +1,12 @@
+<?php
+
+global $priv_list;
+
+$priv_list['page-status-sarg-reports'] = array();
+$priv_list['page-status-sarg-reports']['name'] = "WebCfg - Status: Sarg reports";
+$priv_list['page-status-sarg-reports']['descr'] = "Allow access to sarg reports page.";
+$priv_list['page-status-sarg-reports']['match'] = array();
+$priv_list['page-status-sarg-reports']['match'][] = "sarg_reports.php*";
+$priv_list['page-status-sarg-reports']['match'][] = "sarg_realtime.php*";
+
+?> \ No newline at end of file
diff --git a/config/sarg/sarg.template b/config/sarg/sarg.template
index affcdfc2..41c2b2cf 100644
--- a/config/sarg/sarg.template
+++ b/config/sarg/sarg.template
@@ -149,7 +149,7 @@ graphs {$graphs}
# The reports will be saved in that directory
# sarg -o dir
#
-output_dir /usr/local/www/sarg-reports
+output_dir /usr/local/sarg-reports
# TAG: anonymous_output_files yes/no
# Use anonymous file and directory names in the report. If it is set to
diff --git a/config/sarg/sarg.xml b/config/sarg/sarg.xml
index f1ce5d93..75694601 100644
--- a/config/sarg/sarg.xml
+++ b/config/sarg/sarg.xml
@@ -112,6 +112,11 @@
<prefix>/usr/local/pkg/</prefix>
<chmod>0755</chmod>
</additional_files_needed>
+ <additional_files_needed>
+ <item>http://www.pfsense.org/packages/config/sarg/sarg.priv.inc</item>
+ <prefix>/etc/inc/priv/</prefix>
+ <chmod>0755</chmod>
+ </additional_files_needed>
<tabs>
<tab>
<text>General</text>
diff --git a/config/sarg/sarg_frame.php b/config/sarg/sarg_frame.php
index 73e3a469..13235b21 100755
--- a/config/sarg/sarg_frame.php
+++ b/config/sarg/sarg_frame.php
@@ -38,21 +38,32 @@ else{
$prefix="";
}
$url=($_REQUEST['file'] == ""?"index.html":$_REQUEST['file']);
-if (file_exists("/usr/local/www/sarg-reports/".$url))
+$dir="/usr/local/sarg-reports";
+$rand=rand(100000000000,999999999999);
+if (file_exists("{$dir}/{$url}"))
{
- $report=file_get_contents("/usr/local/www/sarg-reports/".$url);
+ $report=file_get_contents("{$dir}/{$url}");
$pattern[0]="/href=\W(\S+html)\W/";
- $replace[0]="href=/sarg_frame.php?prevent=".rand(100000000000,999999999999)."&file=$prefix/$1";
- $pattern[1]='/img src="(\w+\.\w+)/';
- $replace[1]='img src="/sarg-reports'.$prefix.'/$1';
+ $replace[0]="href=/sarg_frame.php?prevent=".$rand."&file=$prefix/$1";
+ $pattern[1]='/img src="\S+\W([a-zA-Z0-9.-]+.png)/';
+ $replace[1]='img src="/sarg-images/$1';
$pattern[2]='@img src="([.a-z/]+)/(\w+\.\w+)@';
- $replace[2]='img src="/sarg-reports'.$prefix.'/$1/$2';
- $pattern[3]='/<head>/';
- $replace[3]='<head><META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE"><META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">';
+ $replace[2]='img src="/sarg-images'.$prefix.'/$1/$2';
+ $pattern[3]='/img src="([a-zA-Z0-9.-_]+).png/';
+ $replace[3]='img src="/sarg-images/temp/$1.'.$rand.'.png';
+ $pattern[4]='/<head>/';
+ $replace[4]='<head><META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE"><META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">';
+
+ #look for graph files inside reports.
+ if (preg_match_all('/img src="([a-zA-Z0-9._-]+).png/',$report,$images)){
+ for ($x=0;$x<count($images[1]);$x++){
+ copy("{$dir}/{$prefix}/{$images[1][$x]}.png","/usr/local/www/sarg-images/temp/{$images[1][$x]}.{$rand}.png");
+ }
+ }
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.";
+ print "<pre>Error: Could not find report index file.<br>Check and save 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 b64e9966..b1792312 100755
--- a/config/sarg/sarg_reports.php
+++ b/config/sarg/sarg_reports.php
@@ -61,6 +61,7 @@ require("guiconfig.inc");
$tab_array[] = array(gettext("XMLRPC Sync"), false, "/pkg_edit.php?xml=sarg_sync.xml&id=0");
$tab_array[] = array(gettext("Help"), false, "/pkg_edit.php?xml=sarg_about.php");
display_top_tabs($tab_array);
+ exec('rm -f /usr/local/www/sarg-images/temp/*');
?>
</td></tr>
<tr>
diff --git a/config/sarg/sarg_schedule.xml b/config/sarg/sarg_schedule.xml
index 3d065a7a..15527701 100644
--- a/config/sarg/sarg_schedule.xml
+++ b/config/sarg/sarg_schedule.xml
@@ -111,7 +111,8 @@
<columnitem>
<fielddescr>Description</fielddescr>
<fieldname>description</fieldname>
- </columnitem>
+ </columnitem>
+ <movable>arrow</movable>
</adddeleteeditpagefields>
<fields>
<field>