aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcello Coutinho <marcellocoutinho@gmail.com>2012-09-17 17:09:24 -0300
committermarcelloc <marcellocoutinho@gmail.com>2012-09-17 17:09:24 -0300
commit19363da375ade3bfdb0fbba97fd27a009eccd520 (patch)
tree89e5b8c3996052e81629a5ced7015ce01c4e2af8
parent8c44f779ee7806ac816f028d7323cda77168bee8 (diff)
downloadpfsense-packages-19363da375ade3bfdb0fbba97fd27a009eccd520.tar.gz
pfsense-packages-19363da375ade3bfdb0fbba97fd27a009eccd520.tar.bz2
pfsense-packages-19363da375ade3bfdb0fbba97fd27a009eccd520.zip
sarg - fixes for pfsense 2.1 dirs and realtime tab
-rw-r--r--config/sarg/sarg.xml17
-rwxr-xr-xconfig/sarg/sarg_queue.php241
-rwxr-xr-xconfig/sarg/sarg_realtime.php32
-rw-r--r--pkg_config.8.xml4
-rw-r--r--pkg_config.8.xml.amd644
5 files changed, 37 insertions, 261 deletions
diff --git a/config/sarg/sarg.xml b/config/sarg/sarg.xml
index 75694601..bac42dd6 100644
--- a/config/sarg/sarg.xml
+++ b/config/sarg/sarg.xml
@@ -18,7 +18,7 @@
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice,
+ 1. Redistributions of source code MUST retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
@@ -88,11 +88,6 @@
<chmod>0755</chmod>
</additional_files_needed>
<additional_files_needed>
- <item>http://www.pfsense.org/packages/config/sarg/sarg_queue.php</item>
- <prefix>/usr/local/www/</prefix>
- <chmod>0755</chmod>
- </additional_files_needed>
- <additional_files_needed>
<item>http://www.pfsense.org/packages/config/sarg/sarg_reports.php</item>
<prefix>/usr/local/www/</prefix>
<chmod>0755</chmod>
@@ -280,7 +275,7 @@
<size>10</size>
</field>
<field>
- <fielddescr>Reports limits</fielddescr>
+ <fielddescr>Reports list limits</fielddescr>
<fieldname>lastlog</fieldname>
<description><![CDATA[How many reports files must be keept in reports directory.<br>
The oldest report file will be automatically removed.0 means no limit.]]></description>
@@ -288,6 +283,14 @@
<size>10</size>
</field>
<field>
+ <fielddescr>Reports days limits</fielddescr>
+ <fieldname>daylimit</fieldname>
+ <description><![CDATA[How many days reports files must be keept in reports directory.<br>
+ Older report file will be automatically removed.0 means no limit.]]></description>
+ <type>input</type>
+ <size>10</size>
+ </field>
+ <field>
<fielddescr>Top Users Limit</fielddescr>
<fieldname>topuser_num</fieldname>
<description><![CDATA[How many users in topsites report. 0 = no limit]]></description>
diff --git a/config/sarg/sarg_queue.php b/config/sarg/sarg_queue.php
deleted file mode 100755
index 8b8329a5..00000000
--- a/config/sarg/sarg_queue.php
+++ /dev/null
@@ -1,241 +0,0 @@
-<?php
-/*
- sarg_queue.php
- part of pfSense (http://www.pfsense.com/)
- Copyright (C) 2012 Marcello Coutinho <marcellocoutinho@gmail.com>
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
-*/
-
-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;
-
- $pgtitle = "Status: Postfix Mail Queue";
- include("head.inc");
-
- ?>
- <body link="#0000CC" vlink="#0000CC" alink="#0000CC">
- <?php include("fbegin.inc"); ?>
-
- <?php if($one_two): ?>
- <p class="pgtitle"><?=$pgtitle?></font></p>
- <?php endif; ?>
-
- <?php if ($savemsg) print_info_box($savemsg); ?>
-
- <form action="sarg_realtimex.php" method="post">
-
- <div id="mainlevel">
- <table width="100%" border="0" cellpadding="0" cellspacing="0">
- <tr><td>
- <?php
- $tab_array = array();
- $tab_array[] = array(gettext("Settings"), false, "/pkg_edit.php?xml=sarg.xml&id=0");
- $tab_array[] = array(gettext("View Report"), false, "/sarg-reports/");
- $tab_array[] = array(gettext("Realtime"), true, "/sarg_real_time.php");
- $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);
- ?>
- </td></tr>
- <tr>
- <td>
- <div id="mainarea">
- <table class="tabcont" width="100%" border="0" cellpadding="8" cellspacing="0">
- <tr><td></td></tr>
- <tr>
- <td colspan="2" valign="top" class="listtopic"><?=gettext("Sarg Realtime"); ?></td></tr>
- <tr>
- <td width="22%" valign="top" class="vncell"><?=gettext("Log command: ");?></td>
- <td width="78%" class="vtable">
- <select name="drop3" id="cmd">
- <option value="sarg" selected="selected">Sarg Realtime</option>
- </select><br><?=gettext("Select queue command to run.");?></td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncell"><?=gettext("update frequency: ");?></td>
- <td width="78%" class="vtable">
- <select name="drop3" id="updatef">
- <option value="1">01 second</option>
- <option value="3" selected="selected">03 seconds</option>
- <option value="5">05 seconds</option>
- <option value="15">15 Seconds</option>
- <option value="30">30 Seconds</option>
- <option value="60">One minute</option>
- <option value="1">Never</option>
- </select><br><?=gettext("Select how often queue cmd will run.");?></td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncell"><?=gettext("Report Types: ");?></td>
- <td width="78%" class="vtable">
- <select name="drop3" id="qshape" multiple="multiple" size="5">
- <option value="GET" selected="selected">GET</option>
- <option value="PUT" selected="selected">PUT</option>
- <option value="CONNECT" selected="selected">CONNECT</option>
- <option value="ICP_QUERY">ICP_QUERY</option>
- <option value="POST">POST</option>
- </select><br><?=gettext("Which records must be in realtime report.");?></td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncell"><?=gettext("unauthenticated_records: ");?></td>
- <td width="78%" class="vtable">
- <select name="drop3" id="qtype">
- <option value="show" selected>show</option>
- <option value="hide">hide</option>
- </select><br><?=gettext("What to do with unauthenticated records in realtime report.");?></td>
- </tr>
-
- <tr>
- <td width="22%" valign="top"></td>
- <td width="78%"><input name="Submit" type="button" class="formbtn" id="run" value="<?=gettext("show log");?>" onclick="get_queue('mailq')"><div id="search_help"></div></td>
- </table>
- </div>
- </td>
- </tr>
- </table>
- <br>
- <div>
- <table class="tabcont" width="100%" border="0" cellpadding="8" cellspacing="0">
- <tr>
- <td class="tabcont" >
- <div id="file_div"></div>
-
- </td>
- </tr>
- </table>
- </div>
- </div>
- </form>
- <script type="text/javascript">
- function loopSelected(id)
- {
- var selectedArray = new Array();
- var selObj = document.getElementById(id);
- var i;
- var count = 0;
- for (i=0; i<selObj.options.length; i++) {
- if (selObj.options[i].selected) {
- selectedArray[count] = selObj.options[i].value;
- count++;
- }
- }
- return(selectedArray);
- }
-
- function get_queue(loop) {
- //prevent multiple instances
- if ($('run').value=="show log" || loop== 'running'){
- $('run').value="running...";
- $('search_help').innerHTML ="<br><strong>You can change options while running.<br>To Stop seach, change update frequency to Never.</strong>";
- var q_args=loopSelected('qshape');
- var pars = 'cmd='+$('cmd').options[$('cmd').selectedIndex].value;
- var pars = pars + '&qshape='+q_args;
- var pars = pars + '&type='+$('qtype').options[$('qtype').selectedIndex].value;
- var url = "/sarg_queue.php";
- var myAjax = new Ajax.Request(
- url,
- {
- method: 'post',
- parameters: pars,
- onComplete: activitycallback_queue_file
- });
- }
- }
- function activitycallback_queue_file(transport) {
- $('file_div').innerHTML = transport.responseText;
- var update=$('updatef').options[$('updatef').selectedIndex].value * 1000;
- if (update > 1000){
- setTimeout('get_queue("running")', update);
- }
- else{
- $('run').value="show log";
- $('search_help').innerHTML ="";
- }
- }
- </script>
- <?php
- include("fend.inc");
- }
- ?>
- </body>
- </html>
diff --git a/config/sarg/sarg_realtime.php b/config/sarg/sarg_realtime.php
index 0b8b2cc5..218d924c 100755
--- a/config/sarg/sarg_realtime.php
+++ b/config/sarg/sarg_realtime.php
@@ -27,7 +27,17 @@
POSSIBILITY OF SUCH DAMAGE.
*/
-require("guiconfig.inc");
+$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"));
+else
+ define('SARG_DIR', '/usr/local');
+
+$uname=posix_uname();
+if ($uname['machine']=='amd64')
+ ini_set('memory_limit', '250M');
+
+
function get_cmd(){
global $config,$g;
#print $_REQUEST['type'];
@@ -53,14 +63,14 @@ function get_cmd(){
if($update_config > 0){
write_config();
#write changes to sarg_file
- $sarg_config=file_get_contents('/usr/local/etc/sarg/sarg.conf');
+ $sarg_config=file_get_contents(SARG_DIR . '/etc/sarg/sarg.conf');
$pattern[0]='/realtime_types\s+[A-Z,,]+/';
$replace[0]="realtime_types ".$_REQUEST['qshape'];
$pattern[1]='/realtime_unauthenticated_records\s+\w+/';
$replace[1]="realtime_unauthenticated_records ".$_REQUEST['type'];
- file_put_contents('/usr/local/etc/sarg/sarg.conf', preg_replace($pattern,$replace,$sarg_config),LOCK_EX);
+ file_put_contents(SARG_DIR . '/etc/sarg/sarg.conf', preg_replace($pattern,$replace,$sarg_config),LOCK_EX);
}
- exec("/usr/local/bin/sarg -r", $sarg);
+ exec(SARG_DIR ."/bin/sarg -r",$sarg);
$pattern[0]="/<?(html|head|style)>/";
$replace[0]="";
$pattern[1]="/header_\w/";
@@ -73,7 +83,6 @@ function get_cmd(){
$replace[4]='cellspacing="0"';
$pattern[5]="/sarg/";
$replace[5]='cellspacing="0"';
-
foreach ($sarg as $line){
if (preg_match("/<.head>/",$line))
$print ="ok";
@@ -84,9 +93,12 @@ function get_cmd(){
}
if ($_REQUEST['cmd']!=""){
+ require_once("authgui.inc");
+ require_once("functions.inc");
get_cmd();
}
else{
+ require("guiconfig.inc");
$pfSversion = str_replace("\n", "", file_get_contents("/etc/version"));
if(strstr($pfSversion, "1.2"))
$one_two = true;
@@ -104,7 +116,7 @@ else{
<?php if ($savemsg) print_info_box($savemsg); ?>
- <form action="postfix_view_config.php" method="post">
+ <form action="sarg_realtime.php" method="post">
<div id="mainlevel">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
@@ -204,21 +216,23 @@ else{
}
return(selectedArray);
}
-
function get_queue(loop) {
//prevent multiple instances
if ($('run').value=="show log" || loop== 'running'){
$('run').value="running...";
$('search_help').innerHTML ="<br><strong>You can change options while running.<br>To Stop seach, change update frequency to Never.</strong>";
+ var axel = Math.random() + "";
+ var num = axel * 1000000000000000000;
var q_args=loopSelected('qshape');
var pars = 'cmd='+$('cmd').options[$('cmd').selectedIndex].value;
var pars = pars + '&qshape='+q_args;
+ var pars = pars + '&prevent='+num;
var pars = pars + '&type='+$('qtype').options[$('qtype').selectedIndex].value;
- var url = "/sarg_queue.php";
+ var url = "/sarg_realtime.php";
var myAjax = new Ajax.Request(
url,
{
- method: 'post',
+ method: 'get',
parameters: pars,
onComplete: activitycallback_queue_file
});
diff --git a/pkg_config.8.xml b/pkg_config.8.xml
index 2f7635d4..87f58b84 100644
--- a/pkg_config.8.xml
+++ b/pkg_config.8.xml
@@ -672,8 +672,8 @@
<depends_on_package>sarg-2.3.2_2.tbz</depends_on_package>
<depends_on_package>gd-2.0.35_7,1.tbz</depends_on_package>
<depends_on_package_pbi>sarg-2.3.2_5-i386.pbi</depends_on_package_pbi>
- <version>2.3.2 pkg v.0.6</version>
- <status>RC1</status>
+ <version>2.3.2 pkg v.0.6.1</version>
+ <status>RC2</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 77d6546f..940d50a0 100644
--- a/pkg_config.8.xml.amd64
+++ b/pkg_config.8.xml.amd64
@@ -659,8 +659,8 @@
<depends_on_package>sarg-2.3.2_2.tbz</depends_on_package>
<depends_on_package>gd-2.0.35_7,1.tbz</depends_on_package>
<depends_on_package_pbi>sarg-2.3.2_5-amd64.pbi</depends_on_package_pbi>
- <version>2.3.2 pkg v.0.6</version>
- <status>RC1</status>
+ <version>2.3.2 pkg v.0.6.1</version>
+ <status>RC2</status>
<required_version>2.0</required_version>
<configurationfile>sarg.xml</configurationfile>
<build_port_path>/usr/ports/www/sarg</build_port_path>