From d5282decc68d3f6de6d0192e566e0797daf0a6b7 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Sun, 6 Sep 2015 20:48:05 +0200 Subject: sarg - code style cleanup and fixes sarg.xml - Fix copyright header - Nuke unused custom_php_(de)install_command - Fix file permissions - Code style and indentation fixes - Make descriptions readable and improve English. --- config/sarg/sarg.xml | 365 +++++++++++++++++++++++++++------------------------ 1 file changed, 197 insertions(+), 168 deletions(-) (limited to 'config') diff --git a/config/sarg/sarg.xml b/config/sarg/sarg.xml index 9266d211..00da6470 100644 --- a/config/sarg/sarg.xml +++ b/config/sarg/sarg.xml @@ -1,116 +1,103 @@ - - + + - - Describe your package here - Describe your package requirements here - Currently there are no FAQ items provided. sarg - 1.0 + 0.6.5 Status: Sarg Settings /usr/local/pkg/sarg.inc Sarg Reports - Configure sarg + Configure Sarg
Status
/pkg_edit.php?xml=sarg.xml
https://packages.pfsense.org/packages/config/sarg/sarg.inc /usr/local/pkg/ - 0755 https://packages.pfsense.org/packages/config/sarg/sarg_schedule.xml /usr/local/pkg/ - 0755 https://packages.pfsense.org/packages/config/sarg/sarg_sync.xml /usr/local/pkg/ - 0755 https://packages.pfsense.org/packages/config/sarg/sarg_users.xml /usr/local/pkg/ - 0755 https://packages.pfsense.org/packages/config/sarg/sarg_realtime.php /usr/local/www/ - 0755 https://packages.pfsense.org/packages/config/sarg/sarg_about.php /usr/local/www/ - 0755 https://packages.pfsense.org/packages/config/sarg/sarg.php /usr/local/www/ - 0755 https://packages.pfsense.org/packages/config/sarg/sarg_reports.php /usr/local/www/ - 0755 https://packages.pfsense.org/packages/config/sarg/sarg_frame.php /usr/local/www/ - 0755 https://packages.pfsense.org/packages/config/sarg/sarg_sorttable.js /usr/local/www/ - 0755 https://packages.pfsense.org/packages/config/sarg/sarg.template /usr/local/pkg/ - 0755 https://packages.pfsense.org/packages/config/sarg/sarg.priv.inc /etc/inc/priv/ - 0755 @@ -142,120 +129,133 @@ Help /sarg_about.php - + Report Settings listtopic - Proxy server + Proxy Server proxy_server - - select - + Select proxy server type to read logs from. + select + - + Report Options report_options - - If you select any option, it will be enabled on conf file.
- Use CTRL + click on this field]]>
- select - - + + + Use CTRL + click to (de)select multiple values. + ]]> + + select + + - - - - + + + + - - + + - - + + - - - - 17 + + + + 16
- Report to generate + Report To Generate report_type - - Use CTRL + click on this field]]> - select - - - - - - - - + + + Use CTRL + click to (de)select multiple values. + ]]> + + select + + + + + + + + - - - - 10 + + + + 9 Date Format report_date_format - + Date format to use in reports. select - - - + + + + u - Report charset + Report Charset report_charset - + Select character set for the reports. select - - - - - - - - - - - - - - + + + + + + + + + + + + + + + UTF-8 Host Aliases hostalias - - Host names may contain up to one wildcard denoted by a *. The wildcard must not end the host name.
- The host name may be followed by an optional alias but if no alias is provided, the host name, including the wildcard, replaces any matching host name found in the log.
- Host names replaced by identical aliases are grouped together in the reports.
- IP addresses are supported and accept the CIDR notation both for IPv4 and IPv6 addresses.
- Sample:
- *.gstatic.com
- mt*.google.com
- *.myphone.microsoft.com
- *.myphone.microsoft.com:443 *.myphone.microsoft.com:secure
- *.freeav.net antivirus:freeav
- *.mail.live.com
- 65.52.00.00/14 *.mail.live.com]]>
+ + + Host names may contain up to one wildcard denoted by a *. The wildcard must not be at the end of the host name.
+ The host name may be followed by an optional alias; if no alias is provided, the host name, including the wildcard, replaces any matching host name found in the log.
+ Host names replaced by identical aliases are grouped together in the reports.
+ IP addresses are supported and accept the CIDR notation both for IPv4 and IPv6 addresses.

+ Examples:
+ *.gstatic.com
+ mt*.google.com
+ *.myphone.microsoft.com
+ *.myphone.microsoft.com:443 *.myphone.microsoft.com:secure
+ *.freeav.net antivirus:freeav
+ *.mail.live.com
+ 65.52.00.00/14 *.mail.live.com + ]]> +
textarea 70 10 @@ -268,77 +268,107 @@ Max Elapsed max_elapsed - - Samples: 0 means no checking
- 28800000 means 08 hours ]]>
- input - 10 + + + Examples: 0 means no checking; 28800000 means 8 hours. + ]]> + + input + 10 + 0
- Reports list limits + Files Limits lastlog - - The oldest report file will be automatically removed.0 means no limit.]]> - input - 10 + + + Default: 0 - means no limit. + ]]> + + input + 10 + 0 - Reports days limits + Days Limits daylimit - - Older report file will be automatically removed.
- Leave empty to do not remove old reports.]]>
- input - 10 + + + Leave empty to not remove old reports. + ]]> + + input + 10
Top Users Limit topuser_num - - input - 10 + + + + input + 10 + 0 Denied Limit denied_report_limit - - input - 10 + + input + 10 + 0 AuthFail Limit authfail_report_limit - - input - 10 + + input + 10 + 0 - User_report_limit + User Report Limit user_report_limit - - input - 10 + + input + 10 + 0 Exclude Settings listtopic - + Exclude string exclude_string - - Format: string1:string2:...:stringn]]> + + + Format: string1:string2:...:stringn + ]]> + input 70 - Exclude hosts + Exclude Hosts exclude_hostlist - - Eg.: 192.168.10.10 - exclude ip address only
- 192.168.10.0/24 - exclude full C class
- s1.acme.foo - exclude hostname only
- *.acme.foo - exclude full domain name]]>
+ +
+ Examples:
+ 192.168.10.10 - exclude this IP address only.
+ 192.168.10.0/24 - exclude entire subnet.
+ host1.example.com - exclude this hostname only.
+ *.example.com - exclude entire domain. + ]]> +
textarea 70 10 @@ -347,24 +377,23 @@ Exclude codes exclude_codelist - - Write one code per line. Lines starting with a # are ignored.
- Only codes matching exactly one of the line is rejected. The comparison is not case sensitive.]]>
+ + Squid result codes.
+ Only codes matching exactly one of the line is rejected. The comparison is not case sensitive.
+ Write one code per line. Lines starting with a # are ignored.
+ Example: NONE/400 + ]]> +
textarea 70 10 base64
- - sarg_php_install_command(); - - - sarg_php_deinstall_command(); - sarg_validate_input($_POST, $input_errors); - + sync_package_sarg(); -- cgit v1.2.3 From 86c37d2876e1884cb5a0043b295299ade85338e9 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Sun, 6 Sep 2015 20:50:05 +0200 Subject: sarg - code style cleanup and fixes sarg_users.xml - Fix copyright header - Nuke unused custom_php_(de)install_command - Code style and indentation fixes - Make descriptions readable and improve English --- config/sarg/sarg_users.xml | 210 ++++++++++++++++++++++++++------------------- 1 file changed, 123 insertions(+), 87 deletions(-) (limited to 'config') diff --git a/config/sarg/sarg_users.xml b/config/sarg/sarg_users.xml index 39387007..92d46dd1 100644 --- a/config/sarg/sarg_users.xml +++ b/config/sarg/sarg_users.xml @@ -1,49 +1,48 @@ - - + + - - Describe your package here - Describe your package requirements here - Currently there are no FAQ items provided. sarguser - 1.0 + 0.6.5 Status: Sarg User Settings /usr/local/pkg/sarg.inc @@ -76,7 +75,7 @@ Help /sarg_about.php - + User Settings @@ -85,134 +84,171 @@ User Sort Field user_sort_field - - select - - + Select the sort field for the User Report. + select + + - + + BYTES - Ntlm User Format + NTLM Users Format ntlm_user_format - + Select NTLM username format. select - - + + + domainname+username - Exclude users + Exclude Users exclude_userlist - - You can use indexonly to have only index.html file.
- Format: one user per line.]]>
+ + + Format: One user per line. + ]]> + textarea 70 10 base64
- Include users + Include Users include_userlist - - Format: user1:user2:...:usern]]> + + + Format: user1:user2:...:userN + ]]> + input 70 - Users association + Users Association usertab - - If resolve_ip is active, the ip address is resolved before being looked up into this file.
- That is, if you want to map the ip address, be sure to set resolv_ip to no or the resolved name will be looked into the file instead of the ip address.
- Note that it can be used to resolve any ip address known to the dns and then map the unresolved ip addresses to a name found in the usertab file.
- Table syntax: userid name or ip address name
- Eg:
SirIsaac Isaac Newton
- vinci Leonardo da Vinci
- 192.168.10.1 Karol Wojtyla]]>
+ + + If 'Convert IP address to DNS name' is active, the IP address is resolved before being looked up into this file.
+ That is, if you want to map the IP address, be sure to set resolv_ip to no or the resolved name will be looked into the file instead of the IP address.
+ Note that it can be used to resolve any IP address known to the dns and then map the unresolved IP addresses to a name found in the usertab file.
+ Table syntax: 'userid name' or 'IP_address name'

+ Examples:
+ SirIsaac Isaac Newton
+ vinci Leonardo da Vinci
+ 192.168.10.1 Karol Wojtyla + ]]> +
textarea 70 10 base64
- Ldap Settings + LDAP Settings listtopic - Enable LDAP search + Enable LDAP Search ldap_enable - - This option is usefull to show full usernames in sarg reports instead of user logins.]]> + + + This option is useful to show full usernames in Sarg reports instead of user logins. + ]]> + checkbox LDAP Hostname ldap_host - + FQDN or IP address of host with LDAP service or AD DC. input 60 LDAP Port ldap_port - Default is 389]]> + + + Default: 389 + ]]> + input 10 + 389 - LDAP Bind DN + LDAP Bind User DN ldap_bind_dn - - Sample: CN=username,OU=group,DC=mydomain,DC=com
]]>
+ + + Example: CN=username,OU=group,DC=mydomain,DC=com
+ ]]> +
input 60
LDAP Bind Password ldap_bind_pw - + Input the password for 'LDAP Bind User DN' specified above. password - 10 + 20 - LDAP Base Search + LDAP Search Base DN ldap_base_search - - Sample: OU=users,DC=mydomain,DC=com]]> + + + Example: OU=users,DC=mydomain,DC=com + ]]> + input 60 - LDAP filter Search + LDAP Search Filter ldap_filter_search - - User search filter by user's logins in LDAP. First founded record will be used.
- %s - will be changed to userlogins from access.log file filter string can have up to 5 '%s' tags.
- Default value is '(uid=%s)']]>
+ + + %s - will be changed to user logins from access.log file filter. Search filter string can have up to 5 '%s' tags.
+ Default value: '(uid=%s)' + ]]> +
input 60 + (uid=%s)
- LDAP Target Attribute + LDAP Username DN Attribute ldap_target_attr - - Default value is 'cn']]> + + + Default value is 'cn'. For Active Directory, use 'sAMAccountName'. + ]]> + input 60 + cn
- - - - sarg_validate_input($_POST, $input_errors); - + sync_package_sarg(); -- cgit v1.2.3 From fde633a74143ccdebb934c0403bdbe45f433969f Mon Sep 17 00:00:00 2001 From: doktornotor Date: Sun, 6 Sep 2015 20:52:36 +0200 Subject: sarg - code style cleanup and fixes sarg_schedule.xml - Fix copyright header - Nuke unused custom_php_(de)install_command - Nuke some nonsensical extra menu under Diagnostics - Fix file permissions - Code style and indentation fixes - Make descriptions readable and improve English. --- config/sarg/sarg_schedule.xml | 165 ++++++++++++++++++++---------------------- 1 file changed, 80 insertions(+), 85 deletions(-) (limited to 'config') diff --git a/config/sarg/sarg_schedule.xml b/config/sarg/sarg_schedule.xml index 5123d786..7bc02d10 100644 --- a/config/sarg/sarg_schedule.xml +++ b/config/sarg/sarg_schedule.xml @@ -1,65 +1,50 @@ - - + + - - + - - Describe your package here - Describe your package requirements here - Currently there are no FAQ items provided. + 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. +*/ +/* ====================================================================================== */ + ]]> + sargschedule - 0.5 + 0.6.5 Status: Sarg Schedules /usr/local/pkg/sarg.inc - - /usr/local/pkg/ - 0755 - https://packages.pfsense.org/packages/config/sarg/sarg.inc - - - /usr/local/pkg/ - 0755 - https://packages.pfsense.org/packages/config/sarg/sarg_sync.xml - - - sarg - sarg -
Diagnostics
- sarg.xml -
General @@ -101,7 +86,7 @@ frequency - Aditional Args + Additional Args args @@ -116,7 +101,7 @@ Description description - arrow + on @@ -128,48 +113,58 @@ Enable enable checkbox - Enable this schedule - + Enable this schedule. + Description description - Enter a description for this file. + Enter a description for this schedule. input 50 - Sarg args + Sarg Args args - - To force sarg to create a report only for specific days, use:
- TODAY:  -d `date +%d/%m/%Y`
- YESTERDAY:  -d `date -v-1d +%d/%m/%Y`
- WEEKAGO:  -d `date -v-1w +%d/%m/%Y`-`date -v-1d +%d/%m/%Y`
- MONTHAGO:  -d `date -v-1m +01/%m/%Y`-`date -v-1m +31/%m/%Y`]]>
+ + + To force Sarg to create a report only for specific days, use:

+ TODAY:  -d `date +%d/%m/%Y`
+ YESTERDAY:  -d `date -v-1d +%d/%m/%Y`
+ WEEKAGO:  -d `date -v-1w +%d/%m/%Y`-`date -v-1d +%d/%m/%Y`
+ MONTHAGO:  -d `date -v-1m +01/%m/%Y`-`date -v-1m +31/%m/%Y` + ]]> +
input 50
- frequency + Frequency frequency input 5 - - Valid options are minutes(m), hours(h), days(d)
- Sample: To update every hour, use 1h

]]><input type="submit" name="Submit" value="Force update now"><br>
+ + + Valid options are: minutes(m), hours(h), days(d)
+ Example: To update every hour, use 1h

+
+ ]]> +
- Action after sarg + Action After Sarg action + Choose an action to run after Sarg finishes. select - - - + + + - - Choose an action after sarg finishes + + none listtopic @@ -179,14 +174,14 @@ Enable Compression gzip - + Enable this option to compress Sarg HTML report files using gzip. Reduces reports size. checkbox - Compression level + Compression Level gziplevel select - + @@ -197,7 +192,7 @@ - + Choose gzip compression level. @@ -206,21 +201,21 @@ input 60 5 - - Default is to 60 minutes. If your reports take longer to be created, increase this value.]]> + + + If your reports take long time to be created, increase this value.
+ Default: 60 (minutes). + ]]> +
- - sarg_php_install_command(); - - - sarg_validate_input($_POST, $input_errors); sync_package_sarg(); - + sarg_resync(); -- cgit v1.2.3 From 9bef36ef785409fbc570f6229250ab41dd4e52c8 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Sun, 6 Sep 2015 20:55:18 +0200 Subject: sarg - code style cleanup and fixes sarg_schedule.xml - Fix copyright header - Nuke unused custom_php_(de)install_command - Code style and indentation fixes - Description cosmetics --- config/sarg/sarg_sync.xml | 112 ++++++++++++++++++++++------------------------ 1 file changed, 53 insertions(+), 59 deletions(-) (limited to 'config') diff --git a/config/sarg/sarg_sync.xml b/config/sarg/sarg_sync.xml index 354d9991..9ae141e5 100755 --- a/config/sarg/sarg_sync.xml +++ b/config/sarg/sarg_sync.xml @@ -1,48 +1,48 @@ - - + + - - Describe your package here - Describe your package requirements here - Currently there are no FAQ items provided. sargsync - 1.0 + 0.6.5 Status: Sarg Sync /usr/local/pkg/sarg.inc @@ -75,16 +75,16 @@ Help /sarg_about.php
-
+ XMLRPC Sync listtopic - Automatically sync sarg configuration changes + Automatically Sync Sarg Configuration Changes. synconchanges - Select a sync method for sarg. + Select a sync method for Sarg. select auto @@ -95,14 +95,14 @@ - Sync timeout + Sync Timeout synctimeout Select sync max wait time select 250 - + @@ -114,32 +114,26 @@ none rowhelper - - IP Address - ipaddress - IP Address of remote server - input - 20 - - - Password - password - Password for remote server. - password - 20 - + + IP Address + ipaddress + IP Address of remote server + input + 20 + + + Password + password + Password for remote server. + password + 20 + - - sarg_php_install_command(); - - - sarg_php_deinstall_command(); - sarg_validate_input($_POST, $input_errors); - + sarg_resync(); -- cgit v1.2.3 From bd2862c8b8333df331bb85bbf5534ee3f5d46d48 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Sun, 6 Sep 2015 21:00:11 +0200 Subject: sarg - code style cleanup and fixes sarg.inc - Fix copyright header - Code style and indentation fixes - Make the arrays declarations readable - Nuke useless sarg_php_install_command() / sarg_php_deinstall_command() functions --- config/sarg/sarg.inc | 839 ++++++++++++++++++++++++++------------------------- 1 file changed, 424 insertions(+), 415 deletions(-) (limited to 'config') diff --git a/config/sarg/sarg.inc b/config/sarg/sarg.inc index ce2617e1..446b5f82 100644 --- a/config/sarg/sarg.inc +++ b/config/sarg/sarg.inc @@ -1,540 +1,557 @@ SQUID_DIR . '/etc/rc.d/squid.sh', - 'squid_config'=> '/var/squid/logs/access.log', - 'squidguard_config'=> SQGARD_DIR . '/etc/squidGuard/squidGuard.conf', - 'squidguard_block_log'=>'/var/squidGuard/log/block.log', - 'dansguardian_config'=> DANSG_DIR . '/etc/dansguardian/dansguardian.conf', - 'dansguardian_log'=>'/var/log/dansguardian/access.log'); - +$sarg_proxy['squid_rc'] = SQUID_DIR . '/etc/rc.d/squid.sh'; +$sarg_proxy['squid_config'] = '/var/squid/logs/access.log'; +$sarg_proxy['squidguard_config'] = SQGARD_DIR . '/etc/squidGuard/squidGuard.conf'; +$sarg_proxy['squidguard_block_log'] = '/var/squidGuard/log/block.log'; +$sarg_proxy['dansguardian_config'] = DANSG_DIR . '/etc/dansguardian/dansguardian.conf'; +$sarg_proxy['dansguardian_log'] = '/var/log/dansguardian/access.log'; // END STATIC VARS -function sarg_start() { - global $g, $config; - - // reserved -} - -function sarg_text_area_decode($text){ - return preg_replace('/\r\n/', "\n",base64_decode($text)); +function sarg_text_area_decode($text) { + return preg_replace('/\r\n/', "\n", base64_decode($text)); } function sarg_resync() { - global $config; - if (($_POST['Submit'] == 'Save') || !isset($_POST['Submit'])) - sync_package_sarg(); - if ($_POST['Submit'] == 'Force update now') - run_sarg(); - + global $config; + if (($_POST['Submit'] == 'Save') || !isset($_POST['Submit'])) { + sync_package_sarg(); + } + if ($_POST['Submit'] == 'Force update now') { + run_sarg(); + } } -function log_rotate($log_file){ + +function log_rotate($log_file) { global $config, $g; - - #remove .10 rotate log file - unlink_if_exists("$log_file".".10"); - #rotate logs from 9 to 0 - $i=9; - while ($i>=0){ - if (file_exists($log_file.".".$i)) - rename ($log_file.".".$i,$log_file.".".($i+1)); - $i=$i-1; - } - #rotate current log - if (file_exists("$log_file")) - rename ($log_file,$log_file.".0"); + + // remove .10 rotate log file + unlink_if_exists("{$log_file}.10"); + // rotate logs from 9 to 0 + $i = 9; + while ($i >= 0) { + if (file_exists("{$log_file}.{$i}")) { + rename("{$log_file}.{$i}", "{$log_file}" . ($i + 1)); + } + $i = $i - 1; + } + // rotate current log + if (file_exists("$log_file")) { + rename("{$log_file}", "{$log_file}.0"); + } } -function run_sarg($id=-1) { - global $config, $g,$sarg_proxy; - #mount filesystem writeable + +function run_sarg($id = -1) { + global $config, $g, $sarg_proxy; + // mount filesystem writeable conf_mount_rw(); - $cmd = SARG_DIR . "/bin/sarg"; - if ($id >= 0 && is_array($config['installedpackages']['sargschedule']['config'])){ - $args=$config['installedpackages']['sargschedule']['config'][$id]['args']; - $action=$config['installedpackages']['sargschedule']['config'][$id]['action']; - $gzip=$config['installedpackages']['sargschedule']['config'][$id]['gzip']; - $find=$config['installedpackages']['sargschedule']['config'][$id]['find']; - $gziplevel=$config['installedpackages']['sargschedule']['config'][$id]['gziplevel']; - $daylimit=$config['installedpackages']['sargschedule']['config'][$id]['daylimit']; - } - else{ - $args=$_POST['args']; - $action=$_POST['action']; - $gzip=$_POST['gzip']; - $find=$_POST['find']; - $gziplevel=$_POST['gziplevel']; - $daylimit=""; - } - $find=(preg_match("/(\d+)/",$find,$find_matches) ? $find_matches[1] : "60"); + $cmd = SARG_DIR . "/bin/sarg"; + if ($id >= 0 && is_array($config['installedpackages']['sargschedule']['config'])) { + $args = $config['installedpackages']['sargschedule']['config'][$id]['args']; + $action = $config['installedpackages']['sargschedule']['config'][$id]['action']; + $gzip = $config['installedpackages']['sargschedule']['config'][$id]['gzip']; + $find = $config['installedpackages']['sargschedule']['config'][$id]['find']; + $gziplevel = $config['installedpackages']['sargschedule']['config'][$id]['gziplevel']; + $daylimit = $config['installedpackages']['sargschedule']['config'][$id]['daylimit']; + } else { + $args = $_POST['args']; + $action = $_POST['action']; + $gzip = $_POST['gzip']; + $find = $_POST['find']; + $gziplevel = $_POST['gziplevel']; + $daylimit = ""; + } + $find = (preg_match("/(\d+)/", $find, $find_matches) ? $find_matches[1] : "60"); log_error("Sarg: force refresh now with {$args} args, compress({$gzip}) and {$action} action after sarg finish."); - $gzip_script="#!/bin/sh\n"; - if ($gzip=="on"){ - #remove old file if exists + $gzip_script = "#!/bin/sh\n"; + if ($gzip == "on") { + // remove old file if exists unlink_if_exists("/root/sarg_run_{$id}.sh"); - $gzip_script.=<<'use_graphs,remove_temp_files,main_index,use_comma,date_time_by_bytes', - 'report_type'=>'topusers,topsites,sites_users,users_sites,date_time,denied,auth_failures,site_user_time_date,downloads', - 'report_type'=>'u', - 'report_charset'=>'UTF-8', - 'topuser_num'=>'0', - 'authfail_report_limit'=>'0', - 'denied_report_limit'=>'0', - 'user_report_limit' =>'0', - 'lastlog'=> '0', - 'max_elapsed'=> '0'); - $sarg=$config['installedpackages']['sarg']['config'][0]; - if (!is_array($config['installedpackages']['sarguser']['config'])) - $config['installedpackages']['sarguser']['config'][0]=array('user_sort_field'=>'BYTES', - 'exclude_userlist'=> $sarg['exclude_userlist'], - 'include_userlist'=> $sarg['include_userlist'], - 'usertab'=>$sarg['usertab'], - 'ldap_filter_search'=> '(uid=%s)', - 'ldap_target_attr'=> 'cn', - 'ldap_port'=> '389', - 'ntlm_user_format'=>'domainname+username'); - $sarguser=$config['installedpackages']['sarguser']['config'][0]; - $access_log=$sarg['proxy_server']; - switch ($sarg['proxy_server']){ + if (!is_array($config['installedpackages']['sarg']['config'])) { + $config['installedpackages']['sarg']['config'][0]['report_options'] = 'use_graphs,remove_temp_files,main_index,use_comma,date_time_by_bytes'; + $config['installedpackages']['sarg']['config'][0]['report_type'] = 'topusers,topsites,sites_users,users_sites,date_time,denied,auth_failures,site_user_time_date,downloads'; + $config['installedpackages']['sarg']['config'][0]['report_date_format'] = 'u'; + $config['installedpackages']['sarg']['config'][0]['report_charset'] = 'UTF-8'; + $config['installedpackages']['sarg']['config'][0]['topuser_num'] = '0'; + $config['installedpackages']['sarg']['config'][0]['authfail_report_limit'] = '0'; + $config['installedpackages']['sarg']['config'][0]['denied_report_limit'] = '0'; + $config['installedpackages']['sarg']['config'][0]['user_report_limit'] = '0'; + $config['installedpackages']['sarg']['config'][0]['lastlog'] = '0'; + $config['installedpackages']['sarg']['config'][0]['max_elapsed'] = '0'; + } + $sarg = $config['installedpackages']['sarg']['config'][0]; + if (!is_array($config['installedpackages']['sarguser']['config'])) { + $config['installedpackages']['sarguser']['config'][0]['user_sort_field'] = 'BYTES'; + $config['installedpackages']['sarguser']['config'][0]['exclude_userlist'] = $sarg['exclude_userlist']; + $config['installedpackages']['sarguser']['config'][0]['include_userlist'] = $sarg['include_userlist']; + $config['installedpackages']['sarguser']['config'][0]['usertab'] = $sarg['usertab']; + $config['installedpackages']['sarguser']['config'][0]['ldap_filter_search'] = '(uid=%s)'; + $config['installedpackages']['sarguser']['config'][0]['ldap_target_attr'] = 'cn'; + $config['installedpackages']['sarguser']['config'][0]['ldap_port'] = '389'; + $config['installedpackages']['sarguser']['config'][0]['ntlm_user_format'] = 'domainname+username'; + } + $sarguser = $config['installedpackages']['sarguser']['config'][0]; + $access_log = $sarg['proxy_server']; + switch ($sarg['proxy_server']) { case 'dansguardian': - $access_log= $sarg_proxy['dansguardian_log']; - $dansguardian_conf=$sarg_proxy['dansguardian_config']; - $dansguardian_filter_out_date="dansguardian_filter_out_date on"; - $squidguard_conf='squidguard_conf none'; - break; + $access_log = $sarg_proxy['dansguardian_log']; + $dansguardian_conf = $sarg_proxy['dansguardian_config']; + $dansguardian_filter_out_date = "dansguardian_filter_out_date on"; + $squidguard_conf = 'squidguard_conf none'; + break; case 'squidguard': - $squidguard_conf='squidguard_conf '.$sarg_proxy['squidguard_config']; - $redirector_log_format='redirector_log_format #year#-#mon#-#day# #hour# #tmp#/#list#/#tmp#/#tmp#/#url#/#tmp# #ip#/#tmp# #user# #end#'; - #Leve this case without break to include squid log file on squidguard option + $squidguard_conf = 'squidguard_conf ' . $sarg_proxy['squidguard_config']; + $redirector_log_format = 'redirector_log_format #year#-#mon#-#day# #hour# #tmp#/#list#/#tmp#/#tmp#/#url#/#tmp# #ip#/#tmp# #user# #end#'; + // leave this case without break to include squid log file on squidguard option case 'squid': - $access_log= $sarg_proxy['squid_config']; - 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; - } - if (!file_exists($access_log) && $access_log !=""){ - $error="Sarg config error: ".$sarg['proxy_server']." log file ($access_log) does not exists"; + $access_log = $sarg_proxy['squid_config']; + 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; + } + if (!file_exists($access_log) && $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", ""); } - - #general tab - $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"); - $user_ip=(preg_match('/user_ip/',$sarg['report_options'])?"yes":"no"); - $sort_order=(preg_match('/user_sort_field_order/',$sarg['report_options'])?"reverse":"normal"); - $remove_temp_files=(preg_match('/remove_temp_files/',$sarg['report_options'])?"yes":"no"); - $main_index=(preg_match('/main_index/',$sarg['report_options'])?"yes":"no"); - $index_tree=(preg_match('/index_tree/',$sarg['report_options'])?"file":"date"); - $overwrite_report=(preg_match('/overwrite_report/',$sarg['report_options'])?"yes":"no"); - $use_comma=(preg_match('/use_comma/',$sarg['report_options'])?"yes":"no"); - $long_url=(preg_match('/long_url/',$sarg['report_options'])?"yes":"no"); - $privacy=(preg_match('/privacy/',$sarg['report_options'])?"yes":"no"); - $displayed_values=(preg_match('/displayed_values/',$sarg['report_options'])?"abbreviation":"bytes"); - $bytes_in_sites_users_report=(preg_match('/bytes_in_sites_users_report/',$sarg['report_options'])?"yes":"no"); - $date_time_by=(preg_match('/date_time_by_bytes/',$sarg['report_options'])?"bytes":""); - $date_time_by.=(preg_match('/date_time_by_elap/',$sarg['report_options'])?" elap":""); - if(empty($date_time_by)) - $date_time_by="bytes"; - $date_format=(preg_match("/\w/",$sarg['report_date_format'])?$sarg['report_date_format']:"u"); - $report_type=preg_replace('/,/',' ',$sarg['report_type']); - $report_charset=(empty($sarg['report_charset'])?"UTF-8":$sarg['report_charset']); - $exclude_string=(empty($sarg['exclude_string'])?"":'exclude_string "'.$sarg['exclude_string'].'"'); - - #limits - $max_elapsed=(empty($sarg['max_elapsed'])?"0":$sarg['max_elapsed']); - $lastlog=(empty($sarg['lastlog'])?"0":$sarg['lastlog']); - $topuser_num=(empty($sarg['topuser_num'])?"0":$sarg['topuser_num']); - $authfail_report_limit=(empty($sarg['authfail_report_limit'])?"0":$sarg['authfail_report_limit']); - $denied_report_limit=(empty($sarg['denied_report_limit'])?"0":$sarg['denied_report_limit']); - $report_limit=(empty($sarg['user_report_limit'])?"0":$sarg['user_report_limit']); - $user_report_limit = "siteusers_report_limit ".$report_limit."\n"; - $user_report_limit .= "user_report_limit ".$report_limit."\n"; - if(preg_match("/(squidguard|dansguardian)/",$sarg['proxy_server'])){ - $user_report_limit .= $sarg['proxy_server']."_report_limit ".$report_limit."\n"; - } - - #user tab - $ntlm_user_format=(empty($sarguser['ntlm_user_format'])?'domainname+username':$sarguser['ntlm_user_format']); - if(!empty($sarguser['include_userlist'])) - $include_users="$include_users ".$sarguser['include_userlist']; - - if(empty($sarguser['usertab'])){ + + // general tab + $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"); + $user_ip = (preg_match('/user_ip/', $sarg['report_options']) ? "yes" : "no"); + $sort_order = (preg_match('/user_sort_field_order/', $sarg['report_options']) ? "reverse" : "normal"); + $remove_temp_files = (preg_match('/remove_temp_files/', $sarg['report_options']) ? "yes" : "no"); + $main_index = (preg_match('/main_index/', $sarg['report_options']) ? "yes" : "no"); + $index_tree = (preg_match('/index_tree/', $sarg['report_options']) ? "file" : "date"); + $overwrite_report = (preg_match('/overwrite_report/', $sarg['report_options']) ? "yes" : "no"); + $use_comma = (preg_match('/use_comma/', $sarg['report_options']) ? "yes" : "no"); + $long_url = (preg_match('/long_url/', $sarg['report_options']) ? "yes" : "no"); + $privacy = (preg_match('/privacy/', $sarg['report_options']) ? "yes" : "no"); + $displayed_values = (preg_match('/displayed_values/', $sarg['report_options']) ? "abbreviation" : "bytes"); + $bytes_in_sites_users_report = (preg_match('/bytes_in_sites_users_report/', $sarg['report_options']) ? "yes" : "no"); + $date_time_by = (preg_match('/date_time_by_bytes/', $sarg['report_options']) ? "bytes" : ""); + $date_time_by .= (preg_match('/date_time_by_elap/', $sarg['report_options']) ? " elap" : ""); + if (empty($date_time_by)) { + $date_time_by = "bytes"; + } + $date_format = (preg_match("/\w/", $sarg['report_date_format']) ? $sarg['report_date_format'] : "u"); + $report_type = preg_replace('/,/', ' ', $sarg['report_type']); + $report_charset = $sarg['report_charset'] ?: "UTF-8"; + $exclude_string = (empty($sarg['exclude_string']) ? "" : 'exclude_string "' . $sarg['exclude_string'] . '"'); + + // limits + $max_elapsed = $sarg['max_elapsed'] ?: "0"; + $lastlog = $sarg['lastlog'] ?: "0"; + $topuser_num = $sarg['topuser_num'] ?: "0"; + $authfail_report_limit = $sarg['authfail_report_limit'] ?: "0"; + $denied_report_limit = $sarg['denied_report_limit'] ?: "0"; + $report_limit = $sarg['user_report_limit'] ?: "0"; + $user_report_limit = "siteusers_report_limit " . $report_limit . "\n"; + $user_report_limit .= "user_report_limit " . $report_limit . "\n"; + if (preg_match("/(squidguard|dansguardian)/", $sarg['proxy_server'])) { + $user_report_limit .= $sarg['proxy_server'] . "_report_limit " . $report_limit . "\n"; + } + + // user tab + $ntlm_user_format = $sarguser['ntlm_user_format'] ?: 'domainname+username'; + if (!empty($sarguser['include_userlist'])) { + $include_users = "$include_users " . $sarguser['include_userlist']; + } + if (empty($sarguser['usertab'])) { $usertab="none"; - } - else{ - $usertab= SARG_DIR . "/etc/sarg/usertab.conf"; - file_put_contents( SARG_DIR . '/etc/sarg/usertab.conf', sarg_text_area_decode($sarguser['usertab']),LOCK_EX); - } - if($sarguser['ldap_enable']){ - $usertab="ldap"; - $LDAPHost=(empty($sarguser['ldap_host'])?"":"LDAPHost ".$sarguser['ldap_host']); - $LDAPort=(empty($sarguser['ldap_port'])?"":"LDAPPort ".$sarguser['ldap_port']); - $LDAPBindDN=(empty($sarguser['ldap_bind_dn'])?"":"LDAPBindDN ".$sarguser['ldap_bind_dn']); - $LDAPBindPW=(empty($sarguser['ldap_bind_pw'])?"":"LDAPBindPW ".$sarguser['ldap_bind_pw']); - $LDAPBaseSearch=(empty($sarguser['ldap_base_search'])?"":"LDAPBaseSearch ".$sarguser['ldap_base_search']); - $LDAPTargetAttr=(empty($sarguser['ldap_target_Attr'])?"":"LDAPTargetAttr ".$sarguser['ldap_target_Attr']); - $LDAPFilterSearch=(empty($sarguser['ldap_filter_search'])?"":"LDAPFilterSearch ".$sarguser['ldap_filter_search']); - } - - - #move old reports - if (is_dir("/usr/local/www/sarg-reports") && !is_dir("/usr/local/sarg-reports")) + } else { + $usertab = SARG_DIR . "/etc/sarg/usertab.conf"; + file_put_contents(SARG_DIR . '/etc/sarg/usertab.conf', sarg_text_area_decode($sarguser['usertab']), LOCK_EX); + } + if ($sarguser['ldap_enable']) { + $usertab = "ldap"; + $LDAPHost = (empty($sarguser['ldap_host']) ? "" : "LDAPHost " . $sarguser['ldap_host']); + $LDAPort = (empty($sarguser['ldap_port']) ? "" : "LDAPPort " . $sarguser['ldap_port']); + $LDAPBindDN = (empty($sarguser['ldap_bind_dn']) ? "" : "LDAPBindDN " . $sarguser['ldap_bind_dn']); + $LDAPBindPW = (empty($sarguser['ldap_bind_pw']) ? "" : "LDAPBindPW " . $sarguser['ldap_bind_pw']); + $LDAPBaseSearch = (empty($sarguser['ldap_base_search']) ? "" : "LDAPBaseSearch " . $sarguser['ldap_base_search']); + $LDAPTargetAttr = (empty($sarguser['ldap_target_Attr']) ? "" : "LDAPTargetAttr " . $sarguser['ldap_target_Attr']); + $LDAPFilterSearch = (empty($sarguser['ldap_filter_search']) ? "" : "LDAPFilterSearch " . $sarguser['ldap_filter_search']); + } + + // 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); + } + } - #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= SARG_DIR . "/etc/sarg/images"; - foreach ($simages as $simage){ - if (!file_exists("{$simgdir1}/{$simage}")) + // images + $simages = array("datetime.png", "graph.png", "sarg-squidguard-block.png", "sarg.png"); + $simgdir1 = "/usr/local/www/sarg-images"; + $simgdir2 = SARG_DIR . "/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 - $sarg_dir= SARG_DIR; + + // create sarg config files + $sarg_dir = SARG_DIR; include("/usr/local/pkg/sarg.template"); - file_put_contents( SARG_DIR . "/etc/sarg/sarg.conf", $sg, LOCK_EX); - file_put_contents( SARG_DIR . '/etc/sarg/exclude_hosts.conf', sarg_text_area_decode($sarg['exclude_hostlist']),LOCK_EX); - file_put_contents( SARG_DIR . '/etc/sarg/exclude_codes', sarg_text_area_decode($sarg['exclude_codelist']),LOCK_EX); - file_put_contents( SARG_DIR . '/etc/sarg/hostalias',sarg_text_area_decode($sarg['hostalias']),LOCK_EX); - file_put_contents( SARG_DIR . '/etc/sarg/exclude_users.conf', sarg_text_area_decode($sarguser['exclude_userlist']),LOCK_EX); - #check cron_tab - $new_cron=array(); - $cron_found=0; - if (is_array($config['cron']['item'])) - foreach($config['cron']['item'] as $cron){ - if (preg_match("/usr.local.www.sarg.php/",$cron["command"])) + file_put_contents(SARG_DIR . "/etc/sarg/sarg.conf", $sg, LOCK_EX); + file_put_contents(SARG_DIR . '/etc/sarg/exclude_hosts.conf', sarg_text_area_decode($sarg['exclude_hostlist']), LOCK_EX); + file_put_contents(SARG_DIR . '/etc/sarg/exclude_codes', sarg_text_area_decode($sarg['exclude_codelist']), LOCK_EX); + file_put_contents(SARG_DIR . '/etc/sarg/hostalias',sarg_text_area_decode($sarg['hostalias']), LOCK_EX); + file_put_contents(SARG_DIR . '/etc/sarg/exclude_users.conf', sarg_text_area_decode($sarguser['exclude_userlist']), LOCK_EX); + + // check cron_tab + // TODO: Redo this mess to use install_cron_job() instead + $new_cron = array(); + $cron_found = 0; + if (is_array($config['cron']['item'])) { + foreach($config['cron']['item'] as $cron) { + if (preg_match("/usr.local.www.sarg.php/", $cron["command"])) { $cron_found++; - else - $new_cron['item'][]=$cron; + } else { + $new_cron['item'][] = $cron; } + } $cron_cmd="/usr/local/bin/php --no-header /usr/local/www/sarg.php"; - $sarg_schedule_id=0; - if (is_array($config['installedpackages']['sargschedule']['config'])) - foreach ($config['installedpackages']['sargschedule']['config'] as $sarg_schedule){ - if(preg_match('/(\d+)m/',$sarg_schedule['frequency'],$matches) && $sarg_schedule['enable']){ - $new_cron['item'][]=array( "minute" => "*/".$matches[1], - "hour" => "*", - "mday" => "*", - "month" => "*", - "wday" => "*", - "who" => "root", - "command"=> $cron_cmd." ".$sarg_schedule_id); - $config['cron']=$new_cron; + $sarg_schedule_id = 0; + if (is_array($config['installedpackages']['sargschedule']['config'])) { + foreach ($config['installedpackages']['sargschedule']['config'] as $sarg_schedule) { + if (preg_match('/(\d+)m/', $sarg_schedule['frequency'], $matches) && $sarg_schedule['enable']) { + $new_cron['item'][] = array("minute" => "*/" . $matches[1], + "hour" => "*", + "mday" => "*", + "month" => "*", + "wday" => "*", + "who" => "root", + "command" => $cron_cmd . " " . $sarg_schedule_id); + $config['cron'] = $new_cron; $cron_found++; - } - if(preg_match('/(\d+)h/',$sarg_schedule['frequency'],$matches) && $sarg_schedule['enable']){ - $new_cron['item'][]=array( "minute" => "0", - "hour" => "*/".$matches[1], - "mday" => "*", - "month" => "*", - "wday" => "*", - "who" => "root", - "command"=> $cron_cmd." ".$sarg_schedule_id); - $config['cron']=$new_cron; + } + if (preg_match('/(\d+)h/', $sarg_schedule['frequency'], $matches) && $sarg_schedule['enable']) { + $new_cron['item'][] = array("minute" => "0", + "hour" => "*/" . $matches[1], + "mday" => "*", + "month" => "*", + "wday" => "*", + "who" => "root", + "command" => $cron_cmd . " " . $sarg_schedule_id); + $config['cron'] = $new_cron; $cron_found++; - } - if(preg_match('/(\d+)d/',$sarg_schedule['frequency'],$matches) && $sarg_schedule['enable']){ - $new_cron['item'][]=array( "minute" => "0", - "hour" => "0", - "mday" => "*/".$matches[1], - "month" => "*", - "wday" => "*", - "who" => "root", - "command"=> $cron_cmd." ".$sarg_schedule_id); + } + if (preg_match('/(\d+)d/', $sarg_schedule['frequency'], $matches) && $sarg_schedule['enable']) { + $new_cron['item'][] = array("minute" => "0", + "hour" => "0", + "mday" => "*/" . $matches[1], + "month" => "*", + "wday" => "*", + "who" => "root", + "command"=> $cron_cmd . " " . $sarg_schedule_id); $config['cron']=$new_cron; $cron_found++; - } - $sarg_schedule_id++; - } + } + $sarg_schedule_id++; + } + } - #update cron - if ($cron_found > 0){ - $config['cron']=$new_cron; - write_config(); - configure_cron(); + // update cron + if ($cron_found > 0) { + $config['cron'] = $new_cron; + write_config(); + configure_cron(); } - #Write config if any file from filesystem was loaded - if ($update_conf > 0) + } + + // write config if any file from filesystem was loaded + if ($update_conf > 0) { write_config(); - - #mount filesystem readonly + } + + // mount filesystem readonly conf_mount_ro(); - + sarg_sync_on_changes(); } function sarg_validate_input($post, &$input_errors) { - global $config,$g; + global $config, $g; foreach ($post as $key => $value) { - if (empty($value)) + if (empty($value)) { continue; - # check dansguardian - if (substr($key, 0, 12) == "proxy_server" && $value == "dansguardian"){ - if (is_array($config['installedpackages']['dansguardianlog'])){ - if ($config['installedpackages']['dansguardianlog']['config'][0]['logfileformat']!=3){ - $input_errors[]='Sarg is only compatible with dansguardian log squid mode'; - $input_errors[]='Please change it on service -> dansguarian -> report and log -> log file format'; + } + // check dansguardian + if (substr($key, 0, 12) == "proxy_server" && $value == "dansguardian") { + if (is_array($config['installedpackages']['dansguardianlog'])) { + if ($config['installedpackages']['dansguardianlog']['config'][0]['logfileformat'] != 3) { + $input_errors[] = 'Sarg is only compatible with dansguardian squid mode log'; + $input_errors[] = 'Please change it on Services -> Dansguardian -> Report and log -> Log file format'; } - } - else + } else { $input_errors[]='dansguardian package not detected'; } + } # check squidguard if (substr($key, 0, 10) == "proxy_server" && $value == "squidguard") if (!is_array($config['installedpackages']['squidguardgeneral'])) $input_errors[]='squidguard package not detected'; - # check squid - if (substr($key, 0, 5) == "proxy_server" && $value == "squid"){ - if (is_array($config['installedpackages']['squid'])) - if (!$config['installedpackages']['squid']['log_enabled']) + # check squid + if (substr($key, 0, 5) == "proxy_server" && $value == "squid") { + if (is_array($config['installedpackages']['squid'])) { + if (!$config['installedpackages']['squid']['log_enabled']) { $input_errors[]='squidlogs not enabled'; - else - $input_errors[]='squid package not installed'; } - - if (substr($key, 0, 11) == "description" && !preg_match("@^[a-zA-Z0-9 _/.-]+$@", $value)) - $input_errors[] = "Do not use special characters on description"; - if (substr($key, 0, 8) == "fullfile" && !preg_match("@^[a-zA-Z0-9_/.-]+$@", $value)) - $input_errors[] = "Do not use special characters on filename"; - #check cron option - if($key == "frequency" && (!preg_match("/^\d+(h|m|d)$/",$value) || $value == 0)) - $input_errors[] = "A valid number with a time reference is required for the field 'Update Frequency'"; + } else { + $input_errors[]='squid package not installed'; + } + } + + if (substr($key, 0, 11) == "description" && !preg_match("@^[a-zA-Z0-9 _/.-]+$@", $value)) { + $input_errors[] = "Do not use special characters in description"; + } + if (substr($key, 0, 8) == "fullfile" && !preg_match("@^[a-zA-Z0-9_/.-]+$@", $value)) { + $input_errors[] = "Do not use special characters in filename"; + } + // check cron option + if ($key == "frequency" && (!preg_match("/^\d+(h|m|d)$/", $value) || $value == 0)) { + $input_errors[] = "A valid number with a time reference is required for the field 'Update Frequency'"; + } } } /* Uses XMLRPC to synchronize the changes to a remote node */ function sarg_sync_on_changes() { global $config, $g; - if (is_array($config['installedpackages']['sargsync']['config'])){ - $sarg_sync=$config['installedpackages']['sargsync']['config'][0]; + if (is_array($config['installedpackages']['sargsync']['config'])) { + $sarg_sync = $config['installedpackages']['sargsync']['config'][0]; $synconchanges = $sarg_sync['synconchanges']; $synctimeout = $sarg_sync['synctimeout']; - switch ($synconchanges){ + switch ($synconchanges) { case "manual": - if (is_array($sarg_sync[row])){ - $rs=$sarg_sync[row]; - } - else{ + if (is_array($sarg_sync[row])) { + $rs = $sarg_sync[row]; + } else { log_error("[sarg] xmlrpc sync is enabled but there is no hosts to push on sarg config."); return; - } + } break; case "auto": - if (is_array($config['installedpackages']['carpsettings']) && is_array($config['installedpackages']['carpsettings']['config'])){ - $system_carp=$config['installedpackages']['carpsettings']['config'][0]; - $rs[0]['ipaddress']=$system_carp['synchronizetoip']; - $rs[0]['username']=$system_carp['username']; - $rs[0]['password']=$system_carp['password']; - if ($system_carp['synchronizetoip'] =="" || $system_carp['username']==""){ - log_error("[sarg] xmlrpc sync is enabled but there is no system backup hosts to push sarg config."); - return; - } - - } - else{ - log_error("[sarg] xmlrpc sync is enabled but there is no system backup hosts to push sarg config."); + if (is_array($config['installedpackages']['carpsettings']) && is_array($config['installedpackages']['carpsettings']['config'])) { + $system_carp = $config['installedpackages']['carpsettings']['config'][0]; + $rs[0]['ipaddress'] = $system_carp['synchronizetoip']; + $rs[0]['username'] = $system_carp['username']; + $rs[0]['password'] = $system_carp['password']; + if ($system_carp['synchronizetoip'] == "" || $system_carp['username'] == "") { + log_error("[sarg] xmlrpc sync is enabled but there are no system backup hosts to push sarg config."); return; } - break; + + } else { + log_error("[sarg] xmlrpc sync is enabled but there are no system backup hosts to push sarg config."); + return; + } + break; default: return; break; } - if (is_array($rs)){ + if (is_array($rs)) { log_error("[sarg] xmlrpc sync is starting."); - foreach($rs as $sh){ + foreach($rs as $sh) { $sync_to_ip = $sh['ipaddress']; $password = $sh['password']; - if($sh['username']) + if ($sh['username']) { $username = $sh['username']; - else + } else { $username = 'admin'; - if($password && $sync_to_ip) + } + if ($password && $sync_to_ip) { sarg_do_xmlrpc_sync($sync_to_ip, $username, $password,$synctimeout); } - log_error("[sarg] xmlrpc sync is ending."); } - } + log_error("[sarg] xmlrpc sync is ending."); + } + } } -/* Do the actual XMLRPC sync */ +/* do the actual XMLRPC sync */ function sarg_do_xmlrpc_sync($sync_to_ip, $username, $password,$synctimeout) { global $config, $g; - if(!$username) + if (!$username) { return; - - if(!$password) + } + + if (!$password) { return; + } - if(!$sync_to_ip) + if (!$sync_to_ip) { return; - - if(!$synctimeout) - $synctimeout="150"; - + } + + if (!$synctimeout) { + $synctimeout="250"; + } + $xmlrpc_sync_neighbor = $sync_to_ip; - if($config['system']['webgui']['protocol'] != "") { + + if ($config['system']['webgui']['protocol'] != "") { $synchronizetoip = $config['system']['webgui']['protocol']; $synchronizetoip .= "://"; - } - $port = $config['system']['webgui']['port']; - /* if port is empty lets rely on the protocol selection */ - if($port == "") { - if($config['system']['webgui']['protocol'] == "http") + } + $port = $config['system']['webgui']['port']; + /* if port is empty, let's rely on the protocol selection */ + if ($port == "") { + if ($config['system']['webgui']['protocol'] == "http") { $port = "80"; - else + } else { $port = "443"; - } + } + } $synchronizetoip .= $sync_to_ip; /* xml will hold the sections to sync */ @@ -547,22 +564,23 @@ function sarg_do_xmlrpc_sync($sync_to_ip, $username, $password,$synctimeout) { XML_RPC_encode($xml) ); - /* set a few variables needed for sync code borrowed from filter.inc */ + /* set a few variables needed for sync code */ $url = $synchronizetoip; log_error("Beginning sarg XMLRPC sync to {$url}:{$port}."); $method = 'pfsense.merge_installedpackages_section_xmlrpc'; $msg = new XML_RPC_Message($method, $params); $cli = new XML_RPC_Client('/xmlrpc.php', $url, $port); $cli->setCredentials($username, $password); - if($g['debug']) + if ($g['debug']) { $cli->setDebug(1); + } /* send our XMLRPC message and timeout after $synctimeout seconds */ $resp = $cli->send($msg, $synctimeout); - if(!$resp) { + if (!$resp) { $error = "A communications error occurred while attempting sarg XMLRPC sync with {$url}:{$port}."; log_error($error); file_notice("sync_settings", $error, "sarg Settings Sync", ""); - } elseif($resp->faultCode()) { + } elseif ($resp->faultCode()) { $cli->setDebug(1); $resp = $cli->send($msg, $synctimeout); $error = "An error code was received while attempting sarg XMLRPC sync with {$url}:{$port} - Code " . $resp->faultCode() . ": " . $resp->faultString(); @@ -571,27 +589,27 @@ function sarg_do_xmlrpc_sync($sync_to_ip, $username, $password,$synctimeout) { } else { log_error("sarg XMLRPC sync successfully completed with {$url}:{$port}."); } - + /* tell sarg to reload our settings on the destionation sync host. */ $method = 'pfsense.exec_php'; - $execcmd = "require_once('/usr/local/pkg/sarg.inc');\n"; + $execcmd = "require_once('/usr/local/pkg/sarg.inc');\n"; $execcmd .= "sync_package_sarg();"; /* assemble xmlrpc payload */ $params = array( XML_RPC_encode($password), XML_RPC_encode($execcmd) ); - + log_error("sarg XMLRPC reload data {$url}:{$port}."); $msg = new XML_RPC_Message($method, $params); $cli = new XML_RPC_Client('/xmlrpc.php', $url, $port); $cli->setCredentials($username, $password); $resp = $cli->send($msg, $synctimeout); - if(!$resp) { + if (!$resp) { $error = "A communications error occurred while attempting sarg XMLRPC sync with {$url}:{$port} (pfsense.exec_php)."; log_error($error); file_notice("sync_settings", $error, "sarg Settings Sync", ""); - } elseif($resp->faultCode()) { + } elseif ($resp->faultCode()) { $cli->setDebug(1); $resp = $cli->send($msg, $synctimeout); $error = "An error code was received while attempting sarg XMLRPC sync with {$url}:{$port} - Code " . $resp->faultCode() . ": " . $resp->faultString(); @@ -600,15 +618,6 @@ function sarg_do_xmlrpc_sync($sync_to_ip, $username, $password,$synctimeout) { } else { log_error("sarg XMLRPC reload data success with {$url}:{$port} (pfsense.exec_php)."); } - -} - -function sarg_php_install_command() { - sync_package_sarg(); -} - -function sarg_php_deinstall_command() { - // reserved } ?> -- cgit v1.2.3 From 056d5dd6d93591eb0c1608b0e117bfd511912725 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Sun, 6 Sep 2015 21:04:32 +0200 Subject: sarg - code style cleanup and fixes sarg.php - Fix copyright header - Code style and indentation fixes --- config/sarg/sarg.php | 65 ++++++++++++++++++++++++---------------------------- 1 file changed, 30 insertions(+), 35 deletions(-) (limited to 'config') diff --git a/config/sarg/sarg.php b/config/sarg/sarg.php index 98e6c426..7ac0d8aa 100644 --- a/config/sarg/sarg.php +++ b/config/sarg/sarg.php @@ -1,50 +1,45 @@ \ No newline at end of file +?> -- cgit v1.2.3 From a582226b0d6b8f77ce6dd228fdb4796376574000 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Sun, 6 Sep 2015 21:07:53 +0200 Subject: sarg - code style cleanup and fixes Consistent uppercase usage. --- config/sarg/sarg.priv.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'config') diff --git a/config/sarg/sarg.priv.inc b/config/sarg/sarg.priv.inc index 4878c96e..d01066e2 100644 --- a/config/sarg/sarg.priv.inc +++ b/config/sarg/sarg.priv.inc @@ -4,7 +4,7 @@ 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']['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_frame.php*"; -- cgit v1.2.3 From 885f221eb095dc0413a09ce64c9e82bdbdffc81e Mon Sep 17 00:00:00 2001 From: doktornotor Date: Sun, 6 Sep 2015 21:25:11 +0200 Subject: sarg - code style cleanup and fixes sarg_frame.php - Update copyright header - Code style and indentation fixes --- config/sarg/sarg_frame.php | 98 +++++++++++++++++++++++----------------------- 1 file changed, 49 insertions(+), 49 deletions(-) (limited to 'config') diff --git a/config/sarg/sarg_frame.php b/config/sarg/sarg_frame.php index 6f3c941e..e6b27da6 100755 --- a/config/sarg/sarg_frame.php +++ b/config/sarg/sarg_frame.php @@ -1,9 +1,9 @@ - based on varnish_view_config. + Copyright (C) 2015 ESF, LLC All rights reserved. Redistribution and use in source and binary forms, with or without @@ -29,55 +29,55 @@ */ require_once("authgui.inc"); -$uname=posix_uname(); -if ($uname['machine']=='amd64') - ini_set('memory_limit', '250M'); - -if(preg_match("/(\S+)\W(\w+.html)/",$_REQUEST['file'],$matches)){ - #https://192.168.1.1/sarg_reports.php?file=2012Mar30-2012Mar30/index.html - $url=$matches[2]; - $prefix=$matches[1]; - } -else{ - $url="index.html"; - $prefix=""; - } -$url=($_REQUEST['file'] == ""?"index.html":$_REQUEST['file']); -$dir="/usr/local/sarg-reports"; -$rand=rand(100000000000,999999999999); -$report=""; -if (file_exists("{$dir}/{$url}")) - $report=file_get_contents("{$dir}/{$url}"); -else if (file_exists("{$dir}/{$url}.gz")) { - $data = gzfile("{$dir}/{$url}.gz"); - $report = implode($data); - unset ($data); - } -if ($report != "" ) - { - $pattern[0]="/href=\W(\S+html)\W/"; - $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-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]='//'; - $replace[4]=''; +$uname = posix_uname(); +if ($uname['machine'] == 'amd64') { + ini_set('memory_limit', '250M'); +} + +if (preg_match("/(\S+)\W(\w+.html)/", $_REQUEST['file'], $matches)) { + // URL format + // https://192.168.1.1/sarg_reports.php?file=2012Mar30-2012Mar30/index.html + $url = $matches[2]; + $prefix = $matches[1]; +} else { + $url = "index.html"; + $prefix = ""; +} - #look for graph files inside reports. - if (preg_match_all('/img src="([a-zA-Z0-9._-]+).png/',$report,$images)){ +$url = ($_REQUEST['file'] == "" ? "index.html" : $_REQUEST['file']); +$dir = "/usr/local/sarg-reports"; +$rand = rand(100000000000, 999999999999); +$report = ""; +if (file_exists("{$dir}/{$url}")) { + $report = file_get_contents("{$dir}/{$url}"); +} elseif (file_exists("{$dir}/{$url}.gz")) { + $data = gzfile("{$dir}/{$url}.gz"); + $report = implode($data); + unset ($data); +} +if ($report != "" ) { + $pattern[0] = "/href=\W(\S+html)\W/"; + $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-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] = '//'; + $replace[4] = ''; + + // look for graph files inside reports. + if (preg_match_all('/img src="([a-zA-Z0-9._-]+).png/', $report, $images)) { conf_mount_rw(); - for ($x=0;$xError: Could not find report index file.
Check and save sarg settings and try to force sarg schedule."; - } + print preg_replace($pattern, $replace, $report); +} else { + print "Error: Could not find report index file.
Check and save Sarg settings and try to force Sarg schedule."; +} -?> \ No newline at end of file +?> -- cgit v1.2.3 From 6c8bd2e8dd2173261722aa9ab9cc990643eeb112 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Sun, 6 Sep 2015 21:37:16 +0200 Subject: sarg - code style cleanup and fixes Run this through javascript prettify to make the thing readable. --- config/sarg/sarg_sorttable.js | 653 +++++++++++++++++++++--------------------- 1 file changed, 332 insertions(+), 321 deletions(-) (limited to 'config') diff --git a/config/sarg/sarg_sorttable.js b/config/sarg/sarg_sorttable.js index 25bccb2b..96443215 100644 --- a/config/sarg/sarg_sorttable.js +++ b/config/sarg/sarg_sorttable.js @@ -14,321 +14,333 @@ Licenced as X11: http://www.kryogenix.org/code/browser/licence.html This basically means: do what you want with it. */ - - -var stIsIE = /*@cc_on!@*/false; +var stIsIE = /*@cc_on!@*/ false; sorttable = { - init: function() { - // quit if this function has already been called - if (arguments.callee.done) return; - // flag this function so we don't do the same thing twice - arguments.callee.done = true; - // kill the timer - if (_timer) clearInterval(_timer); - - if (!document.createElement || !document.getElementsByTagName) return; - - sorttable.DATE_RE = /^(\d\d?)[\/\.-](\d\d?)[\/\.-]((\d\d)?\d\d)$/; - - forEach(document.getElementsByTagName('table'), function(table) { - if (table.className.search(/\bsortable\b/) != -1) { - sorttable.makeSortable(table); - } - }); - - }, - - makeSortable: function(table) { - if (table.getElementsByTagName('thead').length == 0) { - // table doesn't have a tHead. Since it should have, create one and - // put the first table row in it. - the = document.createElement('thead'); - the.appendChild(table.rows[0]); - table.insertBefore(the,table.firstChild); - } - // Safari doesn't support table.tHead, sigh - if (table.tHead == null) table.tHead = table.getElementsByTagName('thead')[0]; - - if (table.tHead.rows.length != 1) return; // can't cope with two header rows - - // Sorttable v1 put rows with a class of "sortbottom" at the bottom (as - // "total" rows, for example). This is B&R, since what you're supposed - // to do is put them in a tfoot. So, if there are sortbottom rows, - // for backwards compatibility, move them to tfoot (creating it if needed). - sortbottomrows = []; - for (var i=0; i5' : ' ▴'; - this.appendChild(sortrevind); - return; - } - if (this.className.search(/\bsorttable_sorted_reverse\b/) != -1) { - // if we're already sorted by this column in reverse, just - // re-reverse the table, which is quicker - sorttable.reverse(this.sorttable_tbody); - this.className = this.className.replace('sorttable_sorted_reverse', - 'sorttable_sorted'); - this.removeChild(document.getElementById('sorttable_sortrevind')); - sortfwdind = document.createElement('span'); - sortfwdind.id = "sorttable_sortfwdind"; - sortfwdind.innerHTML = stIsIE ? ' 6' : ' ▾'; - this.appendChild(sortfwdind); - return; - } - - // remove sorttable_sorted classes - theadrow = this.parentNode; - forEach(theadrow.childNodes, function(cell) { - if (cell.nodeType == 1) { // an element - cell.className = cell.className.replace('sorttable_sorted_reverse',''); - cell.className = cell.className.replace('sorttable_sorted',''); - } - }); - sortfwdind = document.getElementById('sorttable_sortfwdind'); - if (sortfwdind) { sortfwdind.parentNode.removeChild(sortfwdind); } - sortrevind = document.getElementById('sorttable_sortrevind'); - if (sortrevind) { sortrevind.parentNode.removeChild(sortrevind); } - - this.className += ' sorttable_sorted'; - sortfwdind = document.createElement('span'); - sortfwdind.id = "sorttable_sortfwdind"; - sortfwdind.innerHTML = stIsIE ? ' 6' : ' ▾'; - this.appendChild(sortfwdind); - - // build an array to sort. This is a Schwartzian transform thing, - // i.e., we "decorate" each row with the actual sort key, - // sort based on the sort keys, and then put the rows back in order - // which is a lot faster because you only do getInnerText once per row - row_array = []; - col = this.sorttable_columnindex; - rows = this.sorttable_tbody.rows; - for (var j=0; j 12) { - // definitely dd/mm - return sorttable.sort_ddmm; - } else if (second > 12) { - return sorttable.sort_mmdd; - } else { - // looks like a date, but we can't tell which, so assume - // that it's dd/mm (English imperialism!) and keep looking - sortfn = sorttable.sort_ddmm; - } - } - } - } - return sortfn; - }, - - getInnerText: function(node) { - // gets the text we want to use for sorting for a cell. - // strips leading and trailing whitespace. - // this is *not* a generic getInnerText function; it's special to sorttable. - // for example, you can override the cell text with a customkey attribute. - // it also gets .value for fields. - - hasInputs = (typeof node.getElementsByTagName == 'function') && - node.getElementsByTagName('input').length; - - if (node.getAttribute("sorttable_customkey") != null) { - return node.getAttribute("sorttable_customkey"); - } - else if (typeof node.textContent != 'undefined' && !hasInputs) { - return node.textContent.replace(/^\s+|\s+$/g, ''); - } - else if (typeof node.innerText != 'undefined' && !hasInputs) { - return node.innerText.replace(/^\s+|\s+$/g, ''); - } - else if (typeof node.text != 'undefined' && !hasInputs) { - return node.text.replace(/^\s+|\s+$/g, ''); - } - else { - switch (node.nodeType) { - case 3: - if (node.nodeName.toLowerCase() == 'input') { - return node.value.replace(/^\s+|\s+$/g, ''); - } - case 4: - return node.nodeValue.replace(/^\s+|\s+$/g, ''); - break; - case 1: - case 11: - var innerText = ''; - for (var i = 0; i < node.childNodes.length; i++) { - innerText += sorttable.getInnerText(node.childNodes[i]); - } - return innerText.replace(/^\s+|\s+$/g, ''); - break; - default: - return ''; - } - } - }, - - reverse: function(tbody) { - // reverse the rows in a tbody - newrows = []; - for (var i=0; i=0; i--) { - tbody.appendChild(newrows[i]); - } - delete newrows; - }, - - /* sort functions - each sort function takes two parameters, a and b - you are comparing a[0] and b[0] */ - sort_numeric: function(a,b) { - aa = parseFloat(a[0].replace(/[^0-9.-]/g,'')); - if (isNaN(aa)) aa = 0; - bb = parseFloat(b[0].replace(/[^0-9.-]/g,'')); - if (isNaN(bb)) bb = 0; - return aa-bb; - }, - sort_alpha: function(a,b) { - if (a[0]==b[0]) return 0; - if (a[0] 0 ) { - var q = list[i]; list[i] = list[i+1]; list[i+1] = q; - swap = true; - } - } // for - t--; - - if (!swap) break; - - for(var i = t; i > b; --i) { - if ( comp_func(list[i], list[i-1]) < 0 ) { - var q = list[i]; list[i] = list[i-1]; list[i-1] = q; - swap = true; - } - } // for - b++; - - } // while(swap) - } + init: function() { + // quit if this function has already been called + if (arguments.callee.done) return; + // flag this function so we don't do the same thing twice + arguments.callee.done = true; + // kill the timer + if (_timer) clearInterval(_timer); + + if (!document.createElement || !document.getElementsByTagName) return; + + sorttable.DATE_RE = /^(\d\d?)[\/\.-](\d\d?)[\/\.-]((\d\d)?\d\d)$/; + + forEach(document.getElementsByTagName('table'), function(table) { + if (table.className.search(/\bsortable\b/) != -1) { + sorttable.makeSortable(table); + } + }); + + }, + + makeSortable: function(table) { + if (table.getElementsByTagName('thead').length == 0) { + // table doesn't have a tHead. Since it should have, create one and + // put the first table row in it. + the = document.createElement('thead'); + the.appendChild(table.rows[0]); + table.insertBefore(the, table.firstChild); + } + // Safari doesn't support table.tHead, sigh + if (table.tHead == null) table.tHead = table.getElementsByTagName('thead')[0]; + + if (table.tHead.rows.length != 1) return; // can't cope with two header rows + + // Sorttable v1 put rows with a class of "sortbottom" at the bottom (as + // "total" rows, for example). This is B&R, since what you're supposed + // to do is put them in a tfoot. So, if there are sortbottom rows, + // for backwards compatibility, move them to tfoot (creating it if needed). + sortbottomrows = []; + for (var i = 0; i < table.rows.length; i++) { + if (table.rows[i].className.search(/\bsortbottom\b/) != -1) { + sortbottomrows[sortbottomrows.length] = table.rows[i]; + } + } + if (sortbottomrows) { + if (table.tFoot == null) { + // table doesn't have a tfoot. Create one. + tfo = document.createElement('tfoot'); + table.appendChild(tfo); + } + for (var i = 0; i < sortbottomrows.length; i++) { + tfo.appendChild(sortbottomrows[i]); + } + delete sortbottomrows; + } + + // work through each column and calculate its type + headrow = table.tHead.rows[0].cells; + for (var i = 0; i < headrow.length; i++) { + // manually override the type with a sorttable_type attribute + if (!headrow[i].className.match(/\bsorttable_nosort\b/)) { // skip this col + mtch = headrow[i].className.match(/\bsorttable_([a-z0-9]+)\b/); + if (mtch) { + override = mtch[1]; + } + if (mtch && typeof sorttable["sort_" + override] == 'function') { + headrow[i].sorttable_sortfunction = sorttable["sort_" + override]; + } else { + headrow[i].sorttable_sortfunction = sorttable.guessType(table, i); + } + // make it clickable to sort + headrow[i].sorttable_columnindex = i; + headrow[i].sorttable_tbody = table.tBodies[0]; + dean_addEvent(headrow[i], "click", function(e) { + + if (this.className.search(/\bsorttable_sorted\b/) != -1) { + // if we're already sorted by this column, just + // reverse the table, which is quicker + sorttable.reverse(this.sorttable_tbody); + this.className = this.className.replace('sorttable_sorted', + 'sorttable_sorted_reverse'); + this.removeChild(document.getElementById('sorttable_sortfwdind')); + sortrevind = document.createElement('span'); + sortrevind.id = "sorttable_sortrevind"; + sortrevind.innerHTML = stIsIE ? ' 5' : ' ▴'; + this.appendChild(sortrevind); + return; + } + if (this.className.search(/\bsorttable_sorted_reverse\b/) != -1) { + // if we're already sorted by this column in reverse, just + // re-reverse the table, which is quicker + sorttable.reverse(this.sorttable_tbody); + this.className = this.className.replace('sorttable_sorted_reverse', + 'sorttable_sorted'); + this.removeChild(document.getElementById('sorttable_sortrevind')); + sortfwdind = document.createElement('span'); + sortfwdind.id = "sorttable_sortfwdind"; + sortfwdind.innerHTML = stIsIE ? ' 6' : ' ▾'; + this.appendChild(sortfwdind); + return; + } + + // remove sorttable_sorted classes + theadrow = this.parentNode; + forEach(theadrow.childNodes, function(cell) { + if (cell.nodeType == 1) { // an element + cell.className = cell.className.replace('sorttable_sorted_reverse', ''); + cell.className = cell.className.replace('sorttable_sorted', ''); + } + }); + sortfwdind = document.getElementById('sorttable_sortfwdind'); + if (sortfwdind) { + sortfwdind.parentNode.removeChild(sortfwdind); + } + sortrevind = document.getElementById('sorttable_sortrevind'); + if (sortrevind) { + sortrevind.parentNode.removeChild(sortrevind); + } + + this.className += ' sorttable_sorted'; + sortfwdind = document.createElement('span'); + sortfwdind.id = "sorttable_sortfwdind"; + sortfwdind.innerHTML = stIsIE ? ' 6' : ' ▾'; + this.appendChild(sortfwdind); + + // build an array to sort. This is a Schwartzian transform thing, + // i.e., we "decorate" each row with the actual sort key, + // sort based on the sort keys, and then put the rows back in order + // which is a lot faster because you only do getInnerText once per row + row_array = []; + col = this.sorttable_columnindex; + rows = this.sorttable_tbody.rows; + for (var j = 0; j < rows.length; j++) { + row_array[row_array.length] = [sorttable.getInnerText(rows[j].cells[col]), rows[j]]; + } + /* If you want a stable sort, uncomment the following line */ + //sorttable.shaker_sort(row_array, this.sorttable_sortfunction); + /* and comment out this one */ + row_array.sort(this.sorttable_sortfunction); + + tb = this.sorttable_tbody; + for (var j = 0; j < row_array.length; j++) { + tb.appendChild(row_array[j][1]); + } + + delete row_array; + }); + } + } + }, + + guessType: function(table, column) { + // guess the type of a column based on its first non-blank row + sortfn = sorttable.sort_alpha; + for (var i = 0; i < table.tBodies[0].rows.length; i++) { + text = sorttable.getInnerText(table.tBodies[0].rows[i].cells[column]); + if (text != '') { + if (text.match(/^-?[Ł$¤]?[\d,.]+%?$/)) { + return sorttable.sort_numeric; + } + // check for a date: dd/mm/yyyy or dd/mm/yy + // can have / or . or - as separator + // can be mm/dd as well + possdate = text.match(sorttable.DATE_RE) + if (possdate) { + // looks like a date + first = parseInt(possdate[1]); + second = parseInt(possdate[2]); + if (first > 12) { + // definitely dd/mm + return sorttable.sort_ddmm; + } else if (second > 12) { + return sorttable.sort_mmdd; + } else { + // looks like a date, but we can't tell which, so assume + // that it's dd/mm (English imperialism!) and keep looking + sortfn = sorttable.sort_ddmm; + } + } + } + } + return sortfn; + }, + + getInnerText: function(node) { + // gets the text we want to use for sorting for a cell. + // strips leading and trailing whitespace. + // this is *not* a generic getInnerText function; it's special to sorttable. + // for example, you can override the cell text with a customkey attribute. + // it also gets .value for fields. + + hasInputs = (typeof node.getElementsByTagName == 'function') && + node.getElementsByTagName('input').length; + + if (node.getAttribute("sorttable_customkey") != null) { + return node.getAttribute("sorttable_customkey"); + } else if (typeof node.textContent != 'undefined' && !hasInputs) { + return node.textContent.replace(/^\s+|\s+$/g, ''); + } else if (typeof node.innerText != 'undefined' && !hasInputs) { + return node.innerText.replace(/^\s+|\s+$/g, ''); + } else if (typeof node.text != 'undefined' && !hasInputs) { + return node.text.replace(/^\s+|\s+$/g, ''); + } else { + switch (node.nodeType) { + case 3: + if (node.nodeName.toLowerCase() == 'input') { + return node.value.replace(/^\s+|\s+$/g, ''); + } + case 4: + return node.nodeValue.replace(/^\s+|\s+$/g, ''); + break; + case 1: + case 11: + var innerText = ''; + for (var i = 0; i < node.childNodes.length; i++) { + innerText += sorttable.getInnerText(node.childNodes[i]); + } + return innerText.replace(/^\s+|\s+$/g, ''); + break; + default: + return ''; + } + } + }, + + reverse: function(tbody) { + // reverse the rows in a tbody + newrows = []; + for (var i = 0; i < tbody.rows.length; i++) { + newrows[newrows.length] = tbody.rows[i]; + } + for (var i = newrows.length - 1; i >= 0; i--) { + tbody.appendChild(newrows[i]); + } + delete newrows; + }, + + /* sort functions + each sort function takes two parameters, a and b + you are comparing a[0] and b[0] */ + sort_numeric: function(a, b) { + aa = parseFloat(a[0].replace(/[^0-9.-]/g, '')); + if (isNaN(aa)) aa = 0; + bb = parseFloat(b[0].replace(/[^0-9.-]/g, '')); + if (isNaN(bb)) bb = 0; + return aa - bb; + }, + sort_alpha: function(a, b) { + if (a[0] == b[0]) return 0; + if (a[0] < b[0]) return -1; + return 1; + }, + sort_ddmm: function(a, b) { + mtch = a[0].match(sorttable.DATE_RE); + y = mtch[3]; + m = mtch[2]; + d = mtch[1]; + if (m.length == 1) m = '0' + m; + if (d.length == 1) d = '0' + d; + dt1 = y + m + d; + mtch = b[0].match(sorttable.DATE_RE); + y = mtch[3]; + m = mtch[2]; + d = mtch[1]; + if (m.length == 1) m = '0' + m; + if (d.length == 1) d = '0' + d; + dt2 = y + m + d; + if (dt1 == dt2) return 0; + if (dt1 < dt2) return -1; + return 1; + }, + sort_mmdd: function(a, b) { + mtch = a[0].match(sorttable.DATE_RE); + y = mtch[3]; + d = mtch[2]; + m = mtch[1]; + if (m.length == 1) m = '0' + m; + if (d.length == 1) d = '0' + d; + dt1 = y + m + d; + mtch = b[0].match(sorttable.DATE_RE); + y = mtch[3]; + d = mtch[2]; + m = mtch[1]; + if (m.length == 1) m = '0' + m; + if (d.length == 1) d = '0' + d; + dt2 = y + m + d; + if (dt1 == dt2) return 0; + if (dt1 < dt2) return -1; + return 1; + }, + + shaker_sort: function(list, comp_func) { + // A stable sort function to allow multi-level sorting of data + // see: http://en.wikipedia.org/wiki/Cocktail_sort + // thanks to Joseph Nahmias + var b = 0; + var t = list.length - 1; + var swap = true; + + while (swap) { + swap = false; + for (var i = b; i < t; ++i) { + if (comp_func(list[i], list[i + 1]) > 0) { + var q = list[i]; + list[i] = list[i + 1]; + list[i + 1] = q; + swap = true; + } + } // for + t--; + + if (!swap) break; + + for (var i = t; i > b; --i) { + if (comp_func(list[i], list[i - 1]) < 0) { + var q = list[i]; + list[i] = list[i - 1]; + list[i - 1] = q; + swap = true; + } + } // for + b++; + + } // while(swap) + } } /* ****************************************************************** @@ -339,7 +351,7 @@ sorttable = { /* for Mozilla/Opera9 */ if (document.addEventListener) { - document.addEventListener("DOMContentLoaded", sorttable.init, false); + document.addEventListener("DOMContentLoaded", sorttable.init, false); } /* for Internet Explorer */ @@ -356,11 +368,11 @@ if (document.addEventListener) { /* for Safari */ if (/WebKit/i.test(navigator.userAgent)) { // sniff - var _timer = setInterval(function() { - if (/loaded|complete/.test(document.readyState)) { - sorttable.init(); // call the onload handler - } - }, 10); + var _timer = setInterval(function() { + if (/loaded|complete/.test(document.readyState)) { + sorttable.init(); // call the onload handler + } + }, 10); } /* for other browsers */ @@ -434,7 +446,7 @@ fixEvent.preventDefault = function() { this.returnValue = false; }; fixEvent.stopPropagation = function() { - this.cancelBubble = true; + this.cancelBubble = true; } // Dean's forEach: http://dean.edwards.name/base/forEach.js @@ -490,4 +502,3 @@ var forEach = function(object, block, context) { resolve.forEach(object, block, context); } }; - -- cgit v1.2.3 From caf0843f5836ef21b6512fbd724a40aa57db4095 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Sun, 6 Sep 2015 21:51:34 +0200 Subject: sarg - code style cleanup and fixes sarg_reports.php - Code style and indentation fixes - Nuke useless pfSense 1.2.x cruft --- config/sarg/sarg_reports.php | 113 +++++++++++++++++++------------------------ 1 file changed, 51 insertions(+), 62 deletions(-) (limited to 'config') diff --git a/config/sarg/sarg_reports.php b/config/sarg/sarg_reports.php index f18eb80e..81e1fd02 100755 --- a/config/sarg/sarg_reports.php +++ b/config/sarg/sarg_reports.php @@ -1,8 +1,9 @@ + Copyright (C) 2015 ESF, LLC All rights reserved. Redistribution and use in source and binary forms, with or without @@ -26,70 +27,58 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - require("guiconfig.inc"); - $pf_version=substr(trim(file_get_contents("/etc/version")),0,3); - if ($pf_version < 2.0) - $one_two = true; - - $pgtitle = "Status: Sarg Reports"; - include("head.inc"); - - ?> - - +$pgtitle = "Status: Sarg Reports"; +include("head.inc"); - -

- +?> + + - + -
- -
- - - - - + +
+
- -
-
- - - - -
-
-
- -
- -
+ + +
+ +
+
+ + +
-
- - - - + +
+ +
+
+
+ + + + -- cgit v1.2.3 From b4da19c5464d3e9883e20f0cb9b636e260d1cb9b Mon Sep 17 00:00:00 2001 From: doktornotor Date: Sun, 6 Sep 2015 22:20:33 +0200 Subject: sarg - code style cleanup and fixes sarg_realtime.php - Code style and indentation fixes - Nuke useless pfSense 1.2.x cruft - XHTML fixes --- config/sarg/sarg_realtime.php | 371 +++++++++++++++++++++--------------------- 1 file changed, 185 insertions(+), 186 deletions(-) (limited to 'config') diff --git a/config/sarg/sarg_realtime.php b/config/sarg/sarg_realtime.php index f7618d1a..68104b61 100755 --- a/config/sarg/sarg_realtime.php +++ b/config/sarg/sarg_realtime.php @@ -1,8 +1,9 @@ + Copyright (C) 2015 ESF, LLC All rights reserved. Redistribution and use in source and binary forms, with or without @@ -26,229 +27,227 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - -$pf_version=substr(trim(file_get_contents("/etc/version")),0,3); -if ($pf_version == "2.1" || $pf_version == "2.2") - 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'); - +$pf_version = substr(trim(file_get_contents("/etc/version")), 0, 3); +if ($pf_version == "2.1" || $pf_version == "2.2") { + 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']; - if ($_REQUEST['cmd'] =='sarg'){ - $update_config=0; - #Check report xml info - if (!is_array($config['installedpackages']['sargrealtime'])){ - $config['installedpackages']['sargrealtime']['config'][0]['realtime_types']= ""; - $config['installedpackages']['sargrealtime']['config'][0]['realtime_users']= ""; + global $config, $g; + // print $_REQUEST['type']; + if ($_REQUEST['cmd'] == 'sarg') { + $update_config = 0; + // 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']; + // 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['type']){ + } + // Check report users show + if ($config['installedpackages']['sargrealtime']['config'][0]['realtime_users'] != $_REQUEST['type']) { $config['installedpackages']['sargrealtime']['config'][0]['realtime_users']= $_REQUEST['type']; $update_config++; - } - - if($update_config > 0){ + } + if ($update_config > 0) { write_config(); - #write changes to sarg_file - $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(SARG_DIR . '/etc/sarg/sarg.conf', preg_replace($pattern,$replace,$sarg_config),LOCK_EX); - } - exec(SARG_DIR ."/bin/sarg -r",$sarg); - $pattern[0]="//"; - $replace[0]=""; - $pattern[1]="/header_\w/"; - $replace[1]="listtopic"; - $pattern[2]="/class=.data./"; - $replace[2]='class="listlr"'; - $pattern[3]="/cellpadding=.\d./"; - $replace[3]='cellpadding="0"'; - $pattern[4]="/cellspacing=.\d./"; - $replace[4]='cellspacing="0"'; - $pattern[5]="/sarg/"; - $replace[5]='cellspacing="0"'; - foreach ($sarg as $line){ - if (preg_match("/<.head>/",$line)) + // write changes to sarg_file + $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(SARG_DIR . '/etc/sarg/sarg.conf', preg_replace($pattern, $replace, $sarg_config), LOCK_EX); + } + exec(SARG_DIR . "/bin/sarg -r", $sarg); + $pattern[0] = "//"; + $replace[0] = ""; + $pattern[1] = "/header_\w/"; + $replace[1] = "listtopic"; + $pattern[2] = "/class=.data./"; + $replace[2] = 'class="listlr"'; + $pattern[3] = "/cellpadding=.\d./"; + $replace[3] = 'cellpadding="0"'; + $pattern[4] = "/cellspacing=.\d./"; + $replace[4] = 'cellspacing="0"'; + $pattern[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($pattern,$replace,$line); + } + if ($print == "ok" && !preg_match("/(sarg realtime|Auto Refresh)/i", $line)) { + print preg_replace($pattern, $replace, $line); + } } } } -if ($_REQUEST['cmd']!=""){ +if ($_REQUEST['cmd'] != "") { require_once("authgui.inc"); require_once("functions.inc"); get_cmd(); - } -else{ +} else { require("guiconfig.inc"); - $pf_version=substr(trim(file_get_contents("/etc/version")),0,3); - if ($pf_version < 2.0) - $one_two = true; - + $pgtitle = "Status: Sarg Realtime"; include("head.inc"); - + ?> - - -

- - + - +
- +
- - - - +
- -
-
- - - - +
+ + - -
+ +
+
+ + + - - + + - - + + - - - + + + - - - + + + - - - + + +
-
+ +
+
-
+ +
+
-
+ +
+
-
+ +
+
" onclick="get_queue('mailq')">
+ " onclick="get_queue('mailq')" /> +
+
-
-
-
-
- - - - -
-
- -
-
+
+
+
+
+ + +
+
+
+
Date: Sun, 6 Sep 2015 22:38:20 +0200 Subject: sarg - code style cleanup and fixes sarg_about.php sarg_realtime.php - Code style and indentation fixes - Nuke useless pfSense 1.2.x cruft - XHTML fixes --- config/sarg/sarg_about.php | 106 ++++++++++++++++++++------------------------- 1 file changed, 47 insertions(+), 59 deletions(-) (limited to 'config') diff --git a/config/sarg/sarg_about.php b/config/sarg/sarg_about.php index fba456b2..11289bfe 100755 --- a/config/sarg/sarg_about.php +++ b/config/sarg/sarg_about.php @@ -1,8 +1,9 @@ + Copyright (C) 2015 ESF, LLC All rights reserved. Redistribution and use in source and binary forms, with or without @@ -26,77 +27,64 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - require("guiconfig.inc"); -$pf_version=substr(trim(file_get_contents("/etc/version")),0,3); -if ($pf_version < 2.0) - $one_two = true; - $pgtitle = "About: Sarg Package"; include("head.inc"); ?> - - -

- + -
- - + +
+ + - - - - - - -
-
-
- - - - - - - - - - - - - - - - - - - -
Squid Analysis Report Generator

");?> -
Marcello Coutinho

");?>
donate to pfSense project.

- If you want that your donation goes to this package developer, make a note on donation forwarding it to me.

");?>
- -
-
-
-
+ $tab_array = array(); + $tab_array[] = array(gettext("General"), false, "/pkg_edit.php?xml=sarg.xml&id=0"); + $tab_array[] = array(gettext("Users"), false, "/pkg_edit.php?xml=sarg_users.xml&id=0"); + $tab_array[] = array(gettext("Schedule"), false, "/pkg.php?xml=sarg_schedule.xml"); + $tab_array[] = array(gettext("View Report"), false, "/sarg_reports.php"); + $tab_array[] = array(gettext("Realtime"), false, "/sarg_realtime.php"); + $tab_array[] = array(gettext("XMLRPC Sync"), false, "/pkg_edit.php?xml=sarg_sync.xml&id=0"); + $tab_array[] = array(gettext("Help"), true, "/sarg_about.php"); + display_top_tabs($tab_array); + ?> +
+
+ + + + + + + + + + + + + + + + + + + + +
Squid Analysis Report Generator

");?>
Marcello Coutinho

");?>
+ donate to pfSense project.

+ If you want that your donation goes to this package developer, make a note on donation forwarding it to me.

");?> +
+
+
+
+
-- cgit v1.2.3 From 1173aeadaad0dc6a704d6be7b67df8cf4805cb98 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Sun, 6 Sep 2015 23:13:21 +0200 Subject: sarg - code style cleanup and fixes sarg.template - Fix copyright header - More typo and English fixes. --- config/sarg/sarg.template | 178 +++++++++++++++++++++++----------------------- 1 file changed, 89 insertions(+), 89 deletions(-) (limited to 'config') diff --git a/config/sarg/sarg.template b/config/sarg/sarg.template index abda925b..af08851c 100644 --- a/config/sarg/sarg.template +++ b/config/sarg/sarg.template @@ -1,8 +1,9 @@ + Copyright (C) 2015 ESF, LLC All rights reserved. Redistribution and use in source and binary forms, with or without @@ -25,11 +26,9 @@ 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. - */ - -#create sarg.conf - $sg=<< 23,450,110 # use_comma no => 23.450.110 # @@ -283,7 +282,7 @@ use_comma {$use_comma} # here. # # If you need too, you can use a shell script to process the content of /dev/stdin -# (/dev/stdin is the mail_content passed by sarg to the script) and call whatever +# (/dev/stdin is the mail_content passed by Sarg to the script) and call whatever # command you like. It is not limited to mailing the report via SMTP. # # Don't forget to quote the command if necessary (i.e. if the path contains @@ -297,17 +296,17 @@ use_comma {$use_comma} #topsites_num 100 # TAG: topsites_sort_order CONNECT|BYTES|TIME A|D -# Sort for topsites report, where A=Ascendent, D=Descendent +# Sort for topsites report, where A=Ascending, D=Descending # #topsites_sort_order CONNECT D # TAG: index_sort_order A/D -# Sort for index.html, where A=Ascendent, D=Descendent +# Sort for index.html, where A=Ascending, D=Descending # #index_sort_order D # TAG: exclude_codes file -# Ignore records with these codes. Eg.: NONE/400 +# Ignore records with these Squid return codes. Eg.: NONE/400 # Write one code per line. Lines starting with a # are ignored. # Only codes matching exactly one of the line is rejected. The # comparison is not case sensitive. @@ -316,12 +315,12 @@ exclude_codes {$sarg_dir}/etc/sarg/exclude_codes # TAG: replace_index string # Replace "index.html" in the main index file with this string -# If null "index.html" is used +# If null, "index.html" is used # #replace_index # TAG: max_elapsed milliseconds -# If elapsed time is recorded in log is greater than max_elapsed use 0 for elapsed time. +# If elapsed time recorded in log is greater than max_elapsed, use 0 for elapsed time. # Use 0 for no checking # #max_elapsed 28800000 @@ -330,7 +329,7 @@ max_elapsed {$max_elapsed} # TAG: report_type type # What kind of reports to generate. -# topusers - users, sites, times, bytes, connects, links to accessed sites, etc +# topusers - users, sites, times, bytes, connects, links to accessed sites, etc. # topsites - site, connect and bytes report # sites_users - users and sites report # users_sites - accessed sites by the user report @@ -346,12 +345,12 @@ max_elapsed {$max_elapsed} report_type {$report_type} # TAG: usertab filename -# You can change the "userid" or the "ip address" to be a real user name on the reports. -# If resolve_ip is active, the ip address is resolved before being looked up into this -# file. That is, if you want to map the ip address, be sure to set resolv_ip to no or -# the resolved name will be looked into the file instead of the ip address. Note that -# it can be used to resolve any ip address known to the dns and then map the unresolved -# ip addresses to a name found in the usertab file. +# You can change the "userid" or the "IP address" to be a real user name on the reports. +# If resolve_ip is active, the IP address is resolved before being looked up in this +# file. That is, if you want to map the ip address, be sure to set resolve_ip to no or +# the resolved name will be looked up in the file instead of the IP address. Note that +# it can be used to resolve any IP address known to the DNS and then map the unresolved +# IP addresses to a name found in the usertab file. # Table syntax: # userid name or ip address name # Eg: @@ -360,9 +359,9 @@ report_type {$report_type} # 192.168.10.1 Karol Wojtyla # # Each line must be terminated with '\ n' -# If usertab have value "ldap" (case ignoring), user names -# will be taken from LDAP server. This method as approaches for reception -# of usernames from Active Didectory +# If usertab is set to value "ldap" (case ignored), user names +# will be taken from LDAP server. Use this method to obtain usernames +# LDAP / Active Directory. # #usertab none usertab {$usertab} @@ -380,34 +379,35 @@ usertab {$usertab} {$LDAPPort} # TAG: LDAPBindDN CN=username,OU=group,DC=mydomain,DC=com -# DN of LDAP user, who is authorized to read user's names from LDAP base +# DN of the LDAP user who is authorized to the search the LDAP database # default is empty line #LDAPBindDN cn=proxy,dc=mydomain,dc=local {$LDAPBindDN} # TAG: LDAPBindPW secret -# Password of DN, who is authorized to read user's names from LDAP base +# Password for LDAPBindDN specified above. # default is empty line #LDAPBindPW secret {$LDAPBindPW} # TAG: LDAPBaseSearch OU=users,DC=mydomain,DC=com -# LDAP search base +# LDAP search base DN. The search base is the place in the hierarchical LDAP structure +# where the search for user accounts starts. # default is empty line #LDAPBaseSearch ou=users,dc=mydomain,dc=local {$LDAPBaseSearch} # TAG: LDAPFilterSearch (uid=%s) -# User search filter by user's logins in LDAP +# Use this to filter the user login entries to be returned for a search operation in LDAP. # First founded record will be used # %s - will be changed to userlogins from access.log file -# filter string can have up to 5 '%s' tags +# Search filter string can have up to 5 '%s' tags. # default value is '(uid=%s)' #LDAPFilterSearch (uid=%s) {$LDAPFilterSearch} # TAG: LDAPTargetAttr attributename -# Name of the attribute containing a name of the user +# Name of the attribute containing the login name of the user. # default value is 'cn' #LDAPTargetAttr cn {$LDAPTargetAttr} @@ -431,15 +431,15 @@ date_time_by {$date_time_by} # graphic character sets for writing in alphabetic languages # You can use the following charsets: # Latin1 - West European -# Latin2 - East European -# Latin3 - South European -# Latin4 - North European +# Latin2 - Central and East European +# Latin3 - Southeast European +# Latin4 - Scandinavian/Baltic # Cyrillic # Arabic # Greek # Hebrew # Latin5 - Turkish -# Latin6 +# Latin6 - Lappish/Nordic/Eskimo # Windows-1251 # Japan # Koi8-r @@ -457,7 +457,7 @@ charset {$report_charset} # privacy_string "***.***.***.***" # privacy_string_color blue # In some countries the sysadm cannot see the visited sites by a restrictive law. -# Using privacy yes the visited url will be changes by privacy_string and the link +# Using privacy 'yes', the visited url will be changes by privacy_string and the link # will be removed from reports. # privacy {$privacy} @@ -525,7 +525,7 @@ topuser_num {$topuser_num} {$datafile_fields} # TAG: datafile_url ip|name -# Saves the URL as ip or name in datafile +# Saves the URL as IP or name in datafile # #datafile_url ip @@ -552,8 +552,8 @@ topuser_num {$topuser_num} dansguardian_conf {$dansguardian_conf} # TAG: dansguardian_filter_out_date on|off -# This option replaces dansguardian_ignore_date whose name was not appropriate with respect to its action. -# Note the change of parameter value compared with the old option. +# This option replaces dansguardian_ignore_date (its name was not appropriate with respect to its action). +# Note the change of parameter value compared to the old option. # 'off' use the record even if its date is outside of the range found in the input log file. # 'on' use the record only if its date is in the range found in the input log file. # @@ -569,7 +569,7 @@ dansguardian_conf {$dansguardian_conf} {$squidguard_conf} # TAG: redirector_log file -# the location of the web proxy redirector log such as one created by squidGuard or Rejik. The option +# The location of the web proxy redirector log, such as one created by squidGuard or Rejik. The option # may be repeated up to 64 times to read multiple files. # If this option is specified, it takes precedence over squidguard_conf. # The command line option -L override this option. @@ -577,9 +577,9 @@ dansguardian_conf {$dansguardian_conf} #redirector_log /usr/local/squidGuard/var/logs/urls.log # TAG: redirector_filter_out_date on|off -# This option replaces squidguard_ignore_date and redirector_ignore_date whose names were not -# appropriate with respect to their action. -# Note the change of parameter value compared with the old options. +# This option replaces squidguard_ignore_date and redirector_ignore_date (their names were not +# appropriate with respect to their actions). +# Note the change of parameter value compared to the old options. # 'off' use the record even if its date is outside of the range found in the input log file. # 'on' use the record only if its date is in the range found in the input log file. # @@ -587,23 +587,23 @@ dansguardian_conf {$dansguardian_conf} # TAG: redirector_log_format # Format string for web proxy redirector logs. -# This option was named squidguard_log_format before sarg 2.3. +# This option was named squidguard_log_format before Sarg 2.3. # REJIK #year#-#mon#-#day# #hour# #list#:#tmp# #ip# #user# #tmp#/#tmp#/#url#/#end# # SQUIDGUARD #year#-#mon#-#day# #hour# #tmp#/#list#/#tmp#/#tmp#/#url#/#tmp# #ip#/#tmp# #user# #end# #redirector_log_format #year#-#mon#-#day# #hour# #tmp#/#list#/#tmp#/#tmp#/#url#/#tmp# #ip#/#tmp# #user# #end# {$redirector_log_format} # TAG: show_sarg_info yes|no -# shows sarg information and site path on each report bottom +# shows Sarg information and site path on each report bottom # show_sarg_info no # TAG: show_sarg_logo yes|no -# shows sarg logo +# shows Sarg logo # show_sarg_logo no # TAG: parsed_output_log directory -# Saves the processed log in a sarg format after parsing the squid log file. +# Saves the processed log in a Sarg format after parsing the squid log file. # This is a way to dump all of the data structures out, after parsing from # the logs (presumably this data will be much smaller than the log files themselves), # and pull them back in for later processing and merging with data from previous logs. @@ -657,27 +657,27 @@ denied_report_limit {$denied_report_limit} www_document_root /usr/local/www # TAG: block_it module_url -# This tag allow you to pass urls from user reports to a cgi or php module, -# to be blocked by some Squid acl +# This tag allows you to pass urls from user reports to a cgi or php module, +# to be blocked by some Squid acl. # # Eg.: block_it /sarg-php/sarg-block-it.php # sarg-block-it is a php that will append a url to a flat file. # You must change /var/www/html/sarg-php/sarg-block-it to point to your file -# in $filename variable, and chown to a httpd owner. +# in $filename variable, and chown to the httpd owner. # -# sarg will pass http://module_url?url=url +# Sarg will pass http://module_url?url=url # #block_it none # TAG: external_css_file path -# Provide the path to an external css file to link into the HTML reports instead of -# the inline css written by sarg when this option is not set. +# Provide the path to an external CSS file to link into the HTML reports instead of +# the inline CSS written by sarg when this option is not set. # # In versions prior to 2.3, this used to be an absolute file name to # a file to include verbatim in each HTML page but, as it takes a lot of -# space, version 2.3 switched to a link to an external css file. +# space, version 2.3 switched to a link to an external CSS file. # Therefore, this option must contain the HTTP server path on which a client -# browser may find the css file. +# browser may find the CSS file. # # Sarg use theses style classes: # .logo logo class @@ -692,7 +692,7 @@ www_document_root /usr/local/www # .data3 table text class, align:center # .link link class # -# Sarg can be instructed to output the internal css it inline +# Sarg can be instructed to output the internal CSS it inline # into the reports with this command: # # sarg --css @@ -721,8 +721,8 @@ www_document_root /usr/local/www # TAG: ulimit n # The maximum number of open file descriptors to avoid "Too many open files" error message. -# You need to run sarg as root to use ulimit tag. -# If you run sarg with a low privilege user, set to 'none' to disable ulimit +# You need to run Sarg as root to use ulimit tag. +# If you run Sarg with a low privilege user, set to 'none' to disable ulimit # #ulimit 20000 @@ -733,7 +733,7 @@ www_document_root /usr/local/www ntlm_user_format {$ntlm_user_format} # TAG: realtime_refresh_time num sec -# How many time to auto refresh the realtime report +# How many seconds between auto refresh of the realtime report. # 0 = disable # realtime_refresh_time 0 @@ -775,24 +775,24 @@ realtime_unauthenticated_records show # is at the root of your web site. # # If the path starts with "../" then it is assumed to be a relative -# path and sarg adds as many "../" as necessary to locate the js script from +# path and Sarg adds as many "../" as necessary to locate the js script from # the output directory. Therefore, ../../sorttable.js links to the javascript # one level above output_dir. # # If this entry is set, each sortable table will have the "sortable" class set. # You may have a look at http://www.kryogenix.org/code/browser/sorttable/ -# for the implementation on which sarg is based. +# for the implementation on which Sarg is based. # sorttable /sarg_sorttable.js # TAG: hostalias -# The name of a text file containing the host names one per line and the +# The name of a text file containing the host names (one per line) and the # optional alias to use in the report instead of that host name. # Host names may contain up to one wildcard denoted by a *. The wildcard -# must not end the host name. -# The host name may be followed by an optional alias but if no alias is -# provided, the host name, including the wildcard, replaces any matching -# host name found in the log. +# must not be at the end of the host name. +# The host name may be followed by an optional alias; if no alias is provided, +# the host name, including the wildcard, replaces any matching host name found +# in the log. # Host names replaced by identical aliases are grouped together in the # reports. # IP addresses are supported and accept the CIDR notation both for IPv4 and -- cgit v1.2.3