aboutsummaryrefslogtreecommitdiffstats
path: root/config/sarg/sarg_frame.php
diff options
context:
space:
mode:
authorMarcello Coutinho <marcellocoutinho@gmail.com>2012-05-24 17:13:31 -0300
committermarcelloc <marcellocoutinho@gmail.com>2012-05-24 17:13:31 -0300
commit3864c8951c23d691101b18911bb5e76d603e4d1b (patch)
tree2a793da9ecb0fdf855a3aea34db31400056e4712 /config/sarg/sarg_frame.php
parent0413d215d6102b9e75068564c87e368426b012c5 (diff)
downloadpfsense-packages-3864c8951c23d691101b18911bb5e76d603e4d1b.tar.gz
pfsense-packages-3864c8951c23d691101b18911bb5e76d603e4d1b.tar.bz2
pfsense-packages-3864c8951c23d691101b18911bb5e76d603e4d1b.zip
sarg - version 0.5 with reports permission inc file and no direct access to reports
Diffstat (limited to 'config/sarg/sarg_frame.php')
-rwxr-xr-xconfig/sarg/sarg_frame.php29
1 files changed, 20 insertions, 9 deletions
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