diff options
author | Marcello Coutinho <marcellocoutinho@gmail.com> | 2012-05-24 17:13:31 -0300 |
---|---|---|
committer | marcelloc <marcellocoutinho@gmail.com> | 2012-05-24 17:13:31 -0300 |
commit | 3864c8951c23d691101b18911bb5e76d603e4d1b (patch) | |
tree | 2a793da9ecb0fdf855a3aea34db31400056e4712 | |
parent | 0413d215d6102b9e75068564c87e368426b012c5 (diff) | |
download | pfsense-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
-rw-r--r-- | config/sarg/sarg.inc | 23 | ||||
-rw-r--r-- | config/sarg/sarg.priv.inc | 12 | ||||
-rw-r--r-- | config/sarg/sarg.template | 2 | ||||
-rw-r--r-- | config/sarg/sarg.xml | 5 | ||||
-rwxr-xr-x | config/sarg/sarg_frame.php | 29 | ||||
-rwxr-xr-x | config/sarg/sarg_reports.php | 1 | ||||
-rw-r--r-- | config/sarg/sarg_schedule.xml | 3 | ||||
-rw-r--r-- | pkg_config.8.xml | 8 | ||||
-rw-r--r-- | pkg_config.8.xml.amd64 | 8 |
9 files changed, 69 insertions, 22 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> diff --git a/pkg_config.8.xml b/pkg_config.8.xml index 917e0c5a..467c0830 100644 --- a/pkg_config.8.xml +++ b/pkg_config.8.xml @@ -550,10 +550,10 @@ <category>Network Report</category> <config_file>http://www.pfsense.com/packages/config/sarg/sarg.xml</config_file> <pkginfolink>http://forum.pfsense.org/index.php/topic,47765.0.html</pkginfolink> - <depends_on_package_base_url>http://e-sac.siteseguro.ws/packages/8/All/</depends_on_package_base_url> - <depends_on_package>sarg-2.3.2.tbz</depends_on_package> - <version>2.3.2 pkg v.0.4.2_1</version> - <status>beta</status> + <depends_on_package_base_url>http://files.pfsense.org/packages/8/All/</depends_on_package_base_url> + <depends_on_package>sarg-2.3.2_2.tbz</depends_on_package> + <version>2.3.2 pkg v.0.5</version> + <status>RC1</status> <required_version>2.0</required_version> <configurationfile>sarg.xml</configurationfile> <build_port_path>/usr/ports/www/sarg</build_port_path> diff --git a/pkg_config.8.xml.amd64 b/pkg_config.8.xml.amd64 index d2d38aae..6f721cc4 100644 --- a/pkg_config.8.xml.amd64 +++ b/pkg_config.8.xml.amd64 @@ -636,10 +636,10 @@ <category>Network Report</category> <config_file>http://www.pfsense.com/packages/config/sarg/sarg.xml</config_file> <pkginfolink>http://forum.pfsense.org/index.php/topic,47765.0.html</pkginfolink> - <depends_on_package_base_url>http://e-sac.siteseguro.ws/packages/amd64/8/All/</depends_on_package_base_url> - <depends_on_package>sarg-2.3.2.tbz</depends_on_package> - <version>2.3.2 pkg v.0.4.2_1</version> - <status>beta</status> + <depends_on_package_base_url>http://files.pfsense.org/packages/amd64/8/All/</depends_on_package_base_url> + <depends_on_package>sarg-2.3.2_2.tbz</depends_on_package> + <version>2.3.2 pkg v.0.5</version> + <status>RC1</status> <required_version>2.0</required_version> <configurationfile>sarg.xml</configurationfile> <build_port_path>/usr/ports/www/sarg</build_port_path> |