aboutsummaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
Diffstat (limited to 'config')
-rw-r--r--config/squidGuard/squidguard.inc339
-rw-r--r--config/squidGuard/squidguard.xml210
-rw-r--r--config/squidGuard/squidguard_acl.xml126
-rw-r--r--config/squidGuard/squidguard_configurator.inc357
-rw-r--r--config/squidGuard/squidguard_default.xml108
-rw-r--r--config/squidGuard/squidguard_dest.xml112
-rw-r--r--config/squidGuard/squidguard_log.xml72
-rw-r--r--config/squidGuard/squidguard_rewr.xml17
-rw-r--r--config/squidGuard/squidguard_time.xml9
9 files changed, 757 insertions, 593 deletions
diff --git a/config/squidGuard/squidguard.inc b/config/squidGuard/squidguard.inc
index 025e5b50..1c681497 100644
--- a/config/squidGuard/squidguard.inc
+++ b/config/squidGuard/squidguard.inc
@@ -69,7 +69,6 @@ define('F_EXPRESSIONS', 'expressions');
define('F_DOMAINS', 'domains');
define('F_URLS', 'urls');
define('F_DISABLED', 'disabled');
-define('F_ENABLELOG', 'enablelog');
define('F_SQUIDGUARDENABLE','squidguard_enable');
define('F_BLACKLIST', 'blacklist');
@@ -147,6 +146,10 @@ function squidguard_validate_acl($post, $input_errors)
if (!sg_check_unique_name(F_ACLS, $name))
$input_errors[] = "Name '$name' already exists.";
+ # check reserved
+ if (!sg_check_reserved_name($name))
+ $input_errors[] = "Name '$name' is reserved.";
+
# check source
$sgx = array();
$sgx[F_NAME] = $post[F_NAME];
@@ -218,6 +221,10 @@ function squidguard_validate_times($post, $input_errors)
# check unique name
if (!sg_check_unique_name(F_TIMES, $name))
$input_errors[] = "Name '$name' already exists";
+
+ # check reserved
+ if (!sg_check_reserved_name($name))
+ $input_errors[] = "Name '$name' is reserved.";
}
# --- check format ---
@@ -261,6 +268,10 @@ function squidguard_validate_destination($post, $input_errors) {
# check unique name
if (!sg_check_unique_name(F_DESTINATIONS, $name))
$input_errors[] = "Name '$name' already exists";
+
+ # check reserved
+ if (!sg_check_reserved_name($name))
+ $input_errors[] = "Name '$name' is reserved.";
}
# --- check format ---
@@ -282,12 +293,16 @@ function squidguard_validate_rewrite($post, $input_errors) {
# check name
$name = trim($post[F_NAME]);
if(!empty($name)) {
- # check name format <char><symbols without space> - Ab123
- check_name_format($name, &$input_errors);
+ # check name format <char><symbols without space> - Ab123
+ check_name_format($name, &$input_errors);
- # check unique name
- if (!sg_check_unique_name(F_REWRITES, $name))
+ # check unique name
+ if (!sg_check_unique_name(F_REWRITES, $name))
$input_errors[] = "Name '$name' already exists";
+
+ # check reserved
+ if (!sg_check_reserved_name($name))
+ $input_errors[] = "Name '$name' is reserved.";
}
}
@@ -304,6 +319,8 @@ function squidguard_resync() {
$url = isset($_POST['blacklist_url']) ? $_POST['blacklist_url'] : $_GET['blacklist_url'];
$proxy = isset($_POST['blacklist_proxy']) ? $_POST['blacklist_proxy'] : $_GET['blacklist_proxy'];
+ sg_init(convert_pfxml_to_sgxml());
+
# blacklist upload
if ($submit == BLACKLIST_BTN_URL) {
if ($url)
@@ -319,8 +336,11 @@ function squidguard_resync() {
//if ($submit == APPLY_BTN) {
# write_config('Update squidGuard options.'); # store, if not 'Save' button
# перенести в validate для детектирования ошибок?
+
sg_reconfigure();
//}
+
+ squidguard_cron_install();
}
# -----------------------------------------------------------------------------
@@ -410,11 +430,6 @@ function squidguard_before_form($pkg) {
$fld = &$pkg['fields']['field'][$i];
$fld['description'] .= make_grid_general_items(); # insert to description custom controls
break;
- # GUI log
- case 'view_gui_log':
- $fld = &$pkg['fields']['field'][$i];
- $fld['description'] .= make_grid_general_items('gui_log'); # insert to description custom controls
- break;
}
$i++;
}
@@ -587,140 +602,13 @@ function squidguard_before_form_acl($pkg, $is_acl=true) {
}
# -----------------------------------------------------------------------------
-# squidguard_before_form_log
+# squidguard_before_form_log - must be deleted
# -----------------------------------------------------------------------------
define('LOGSHOW_BUFSIZE', 16384);
-function squidguard_before_form_log($pkg) {
- # ! nothing for config - only report. Possible use global $config !
- global $config;
- $i=0;
- $move_pos = 0;
- $move_step = 50;
-
- foreach($pkg['fields']['field'] as $field) {
- if ($field['fieldname'] == 'logtype') {
- $slog = '';
- $mlog = $config['installedpackages'][MODULE_LOG]['config'][0];
-
- $filename = '';
- $fld = &$pkg['fields']['field'][$i];
- $move_pos = ($move_pos) ? $move_pos : 0;
-
- switch ($mlog['logtype']) {
- case 'block_log':
- {
- $filename = SQUIDGUARD_LOGDIR . "/" . SQUIDGUARD_ACCESSBLOCK_FILE;
- $fh = '';
- if (file_exists($filename)) {
- $fh = fopen($filename, "r");
- if ($fh) {
- $fsize = filesize($filename);
- # take LOGSHOW_BUFSIZE bytes from end
- if ($fsize > LOGSHOW_BUFSIZE)
- fseek($fh, -LOGSHOW_BUFSIZE, SEEK_END);
- $s = fread($fh, LOGSHOW_BUFSIZE);
- fclose($fh);
-
- $slog .= "<tr><td colspan='7'>Block log '$filename'. Last 100:<td><tr>";
-
- $s = explode("\n", $s);
- unset($s[0]); # unset us'nt complete string
-
- $slog .= "<tr><th>Num</th><th>DateTime</th><th>IP</th><th>URL</th><th>Filter</th><th>ID</th><th>Mtd</th></tr>";
- foreach($s as $key => $vs) {
- $nkey = $move_pos + intval($key);
- $slog .= "<tr>";
- $sx = $vs;
- $sx = str_replace(array("/- -", "/-", "Request", "request","(", ")", "[", "]"), "", $sx);
- $sx = explode(" ", $sx);
-
- # formatting url
- $spos =0;
- $stmp = '';
- while($spos + 81 < strlen($sx[4])) {
- $stmp .= substr($sx[4], $spos, 81) . "<br>";
- $spos += 81;
- }
- $stmp .= substr($sx[4], $spos, strlen($sx[4]) - $spos);
- $sx[4] = $stmp;
-
- if (!empty($vs))
- $slog .= "<tr>
- <td style='vertical-align: top; white-space: nowrap;'>" . strval($nkey) . "</td>
- <td style='vertical-align: top; white-space: nowrap;'>$sx[0] $sx[1]</td>
- <td style='vertical-align: top;'>$sx[5]</td>
- <td style='vertical-align: top;'>$sx[4]</td>
- <td style='vertical-align: top;'>$sx[3]</td>
- <td style='vertical-align: top;'>$sx[2]</td>
- <td style='vertical-align: top;'>$sx[6]</td></tr>";
- }
- }
- }
-
- }
- break;
- case 'configurator_log':
- {
- $filename = SQUIDGUARD_LOGDIR . SQUIDGUARDCONF_LOGFILE;
- $slog .= "<b>$filename</b><br>";
- if (file_exists($filename)) {
- $slog .= file_get_contents($filename);
- $slog = str_replace("\n", "<br>", $slog);
- $slog = "<tr><td>$slog</td></tr>";
- }
- }
- break;
- case 'squidguard_log':
- {
- $slog .= 'squidguard_log report disabled';
-/*
- $filename = SQUIDGUARD_LOGDIR . '/squidGuard.log';
- $slog .= "<b>$filename</b><br>";
- if (file_exists($filename)) {
- $slog .= file_get_contents($filename);
- $slog = explode("\n", $slog);
- while (count($slog) > 500) array_shift($slog);
- $slog = implode("\n", $slog);
- $slog = str_replace("\n", "<br>", $slog);
- $slog = "<tr><td>$slog</td></tr>";
- }
-*/
- }
- break;
- case 'squid_config':
- {
- $filename = SQUID_CONFIGFILE;
- $slog .= "<b>$filename</b><br>";
- if (file_exists($filename)) {
- $slog .= file_get_contents($filename);
- $slog = str_replace("\n", "<br>", $slog);
- $slog = str_replace("\t", " ", $slog);
- $slog = "<tr><td>$slog</td></tr>";
- }
- }
- break;
- case 'squidguard_config':
- {
- $filename = SQUIDGUARD_WORKDIR . "/squidGuard.conf";
- $slog .= "<b>$filename</b><br>";
- if (file_exists($filename)) {
- $slog .= file_get_contents($filename);
- $slog = str_replace("\n", "<br>", $slog);
- $slog = str_replace("\t", " ", $slog);
- $slog = "<tr><td>$slog</td></tr>";
- }
- }
- break;
- } # switch
-
- $fld['description'] .=
- "<INPUT class=formbtn type=submit value='Get log' name=Submit>
- </tr><tr>
- <td colspan='2'><table width='100%' class=tabcont cellSpacing=0 cellPadding=1 border=1>$slog</table>";
- }
- $i++;
- }
+function squidguard_before_form_log($pkg)
+{
+# delete me
}
# -----------------------------------------------------------------------------
@@ -749,14 +637,6 @@ function make_grid_general_items($id = '')
$sgstate .= "<br><span style='color: #800000;'>Wait: began updating the blacklist.<br>New data will be available after some time.<br>After the upgrade, it is necessary to check the configuration.</span>";
$res .= "<tr $bg_color><td><big>SquidGuard service state: <b>$sgstate</b></big></td></tr>";
}
- elseif ($id === 'gui_log') {
- if ($squidguard_config['view_gui_log'] == 'on') {
- $log_content = sg_getlog(50);
- $log_content = str_replace("\n","<br>", $log_content);
- $res .= "<tr $bg_color><td><font size='-1'><b>Web GUI log (Latest 50)</b></font></td></tr>";
- $res .= "<tr $bg_color><td vAlign=top width='100%'><font size='-2'>$log_content</font></td></tr>";
- }
- }
$res .= "</table>";
return $res;
@@ -925,6 +805,20 @@ function sg_check_unique_name($module_id, $name, $log='') {
return $res;
}
+# -----------------------------------------------------------------------------
+# check unique name
+# -----------------------------------------------------------------------------
+function sg_check_reserved_name($name, $log='')
+{
+ $res = true;
+ $reserved = array("acl", "all", "dbhome", "default", "dest", "in-addr", "log", "logdir", "none", "pass", "rew", "src", "url", "user");
+
+ if (in_array(strtolower(trim($name)), $reserved)) {
+ $res = false;
+ }
+
+ return $res;
+}
# ------------------------------------------------------------------------------
# Install & deinstall
# ------------------------------------------------------------------------------
@@ -1011,36 +905,6 @@ function squidGuard_print_javascript() {
$javascript .= "\n</script>";
}
- if ($xml === "squidguard_src.xml") { ### will deleted ###
- $javascript .= "\n<script language='JavaScript'>";
- $javascript .= "\n<!--";
- $javascript .= "\n function on_updatecontrols() {";
- $javascript .= "\n document.iform.elements['order'].disabled = 0;";
- $javascript .= "\n document.iform.elements['order'].onfocus = on_orderfocus;";
- $javascript .= "\n }";
- $javascript .= "\n function on_orderfocus() {";
- $javascript .= "\n document.iform.elements['order'].blur();";
- $javascript .= "\n }";
- $javascript .= "\n function on_moveup() {";
- $javascript .= "\n var order = parseInt(document.iform.elements['order'].value)";
- $javascript .= "\n if (order > 0)";
- $javascript .= "\n order = order - 1;";
- $javascript .= "\n else order = 0;";
- $javascript .= "\n document.iform.elements['order'].value = order;";
- $javascript .= "\n }";
- $javascript .= "\n function on_movedown() {";
- $javascript .= "\n var order = parseInt(document.iform.elements['order'].value)";
- $javascript .= "\n if (order >= 0)";
- $javascript .= "\n order = order + 1;";
- $javascript .= "\n else order = 0;";
- $javascript .= "\n document.iform.elements['order'].value = order;";
- $javascript .= "\n }";
- $javascript .= "\n on_updatecontrols();";
- $javascript .= "\n ";
- $javascript .= "\n//-->";
- $javascript .= "\n</script>";
- }
-
print($javascript);
}
@@ -1072,8 +936,14 @@ function convert_pfxml_to_sgxml() {
$sgxml[F_ACLS] = convert_pfxml_to_sgxml_acl($config);
$sgxml[F_DEFAULT] = convert_pfxml_to_sgxml_default($config);
- # other
- $sgxml['view_gui_log'] = $pfxml['view_gui_log'];
+
+
+ # log
+ $sgxml[F_ENABLELOG] = $pfxml['enable_log'] == 'on' ? 'on' : 'off';
+ $sgxml[F_ENABLEGUILOG] = $pfxml['enable_guilog'] == 'on' ? 'on' : 'off';
+ $sgxml[F_LOGROTATION] = $pfxml['log_rotation'] == 'on' ? 'on' : 'off';
+
+ # other
$lanip = $config['interfaces']['lan']['ipaddr'];
$sgxml[F_CURRENT_LAN_IP] = $lanip;
@@ -1084,7 +954,7 @@ function convert_pfxml_to_sgxml() {
$guiprotocol = $config['system']['webgui']['protocol'];
$sgxml[F_SQUID_TRANSPARENT_MODE] = 'on';
- $sgxml[F_CURRENT_GUI_PORT] = $guiport;
+ $sgxml[F_CURRENT_GUI_PORT] = $guiport;
$sgxml[F_CURRENT_GUI_PROTO] = $guiprotocol;
} else {
unset($sgxml[F_SQUID_TRANSPARENT_MODE]);
@@ -1394,4 +1264,109 @@ function squidguard_adt_safesrch_add($rewrite_item)
return $rewrite_item;
}
+
+# get squid config list
+function squidguard_squid_conflist( )
+{
+ $fname = SQUID_CONFIGFILE;
+ $res = "";
+
+ if (file_exists( $fname ))
+ $res = file_get_contents( $fname );
+ else $res = "File '$fname' not found.";
+
+ return $res;
+}
+
+# get squidguard config list
+function squidguard_conflist( )
+{
+ $fname = SQUIDGUARD_CONFBASE_DEF . SQUIDGUARD_CONFIGFILE;
+ $res = "";
+
+ if (file_exists( $fname ))
+ $res = file_get_contents( $fname );
+ else $res = "File '$fname' not found.";
+
+ return $res;
+}
+
+# get squidguard log report
+
+define('LOGSHOW_BUFSIZE', '16384');
+
+function squidguard_logrep( $filename, $lncount, $reverse )
+{
+ $res = "";
+
+ $lncount = $lncount ? $lncount : 50;
+ $reverse = $reverse ? $reverse : false;
+
+ if (file_exists($filename)) {
+ $fh = fopen($filename, "r");
+ if ($fh) {
+ $fsize = filesize($filename);
+ # take LOGSHOW_BUFSIZE bytes from end
+ if ($fsize > LOGSHOW_BUFSIZE)
+ fseek($fh, -LOGSHOW_BUFSIZE, SEEK_END);
+ $cont = fread($fh, LOGSHOW_BUFSIZE);
+ fclose($fh);
+ }
+
+ $cont = explode( "\n", $cont );
+ $cont = array_slice($cont, -$lncount);
+
+ if ($reverse) $cont = array_reverse( $cont );
+
+ $res .= "<table class='tabcont' width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
+ $res .= "<tr><td nowrap class='listtopic' colspan='2'>Last {$lncount} entries</td></tr>\n";
+ foreach($cont as $cn) {
+ $cn = trim($cn);
+ if ($cn) {
+ $cn = explode(" ", $cn, 4);
+
+ # split strings
+ $st = str_split ($cn[3], 25);
+ $cn[3] = "";
+ foreach( $st as $s ) $cn[3] .= $s . "<wbr/>";
+
+ $res .= "<tr><td nowrap class='listlr'>{$cn[0]} {$cn[1]}</td><td class='listr'>{$cn[3]}</td></tr>";
+ }
+ }
+ $res .= "</table>";
+ }
+
+ return $res;
+}
+
+# get blacklist list
+function squidguard_blacklist_list()
+{
+ $res = "";
+ $fname = "/var/squidGuard/blacklist.files";
+
+ $res .= "<table class='tabcont' width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
+ $res .= "<tr><td class='listtopic'>Name</td><td class='listtopic'>Domains</td><td class='listtopic'>Urls</td><td class='listtopic'>Expressions</td></tr>\n";
+ if (file_exists($fname)) {
+ $cont = explode("\n", file_get_contents($fname));
+ foreach($cont as $cn) {
+ $ph = "/var/db/squidGuard/$cn";
+
+ if (file_exists($ph)) {
+ $dm = "&nbsp;";
+ $ur = "&nbsp;";
+ $ex = "&nbsp;";
+
+ if (file_exists("$ph/domains")) $dm = "domains";
+ if (file_exists("$ph/urls")) $ur = "urls";
+ if (file_exists("$ph/expressions")) $ex = "expressions";
+
+ $res .= "<tr><td class='listlr'>$cn</td><td class='listr'>$dm</td><td class='listr'>$ur</td><td class='listr'>$ex</td></tr>";
+ }
+ }
+ }
+ $res .= "</table>";
+
+ return $res;
+}
?>
diff --git a/config/squidGuard/squidguard.xml b/config/squidGuard/squidguard.xml
index 572efb97..9f0ed9fb 100644
--- a/config/squidGuard/squidguard.xml
+++ b/config/squidGuard/squidguard.xml
@@ -2,108 +2,102 @@
<!DOCTYPE packagegui SYSTEM "../schema/packages.dtd">
<?xml-stylesheet type="text/xsl" href="../xsl/package.xsl"?>
<packagegui>
- <description>Describe your package here</description>
- <requirements>Describe your package requirements here</requirements>
- <faq>Currently there are no FAQ items provided.</faq>
-
- <name>squidguardgeneral</name>
- <version>1.2.0_2</version>
- <title>Proxy filter SquidGuard: General settings</title>
- <include_file>/usr/local/pkg/squidguard.inc</include_file>
-
- <!-- Installation -->
- <menu>
- <name>Proxy filter</name>
- <tooltiptext>Modify the proxy server's filter settings</tooltiptext>
- <section>Services</section>
- <url>/pkg_edit.php?xml=squidguard.xml&amp;id=0</url>
- </menu>
-
- <tabs>
- <tab>
- <text>General settings</text>
- <url>/pkg_edit.php?xml=squidguard.xml&amp;id=0</url>
- <active/>
- </tab>
- <tab>
- <text>Default</text>
- <url>/pkg_edit.php?xml=squidguard_default.xml&amp;id=0</url>
- </tab>
- <tab>
- <text>ACL</text>
- <url>/pkg.php?xml=squidguard_acl.xml</url>
- </tab>
- <tab>
- <text>Destinations</text>
- <url>/pkg.php?xml=squidguard_dest.xml</url>
- </tab>
- <tab>
- <text>Times</text>
- <url>/pkg.php?xml=squidguard_time.xml</url>
- </tab>
- <tab>
- <text>Rewrites</text>
- <url>/pkg.php?xml=squidguard_rewr.xml</url>
- </tab>
- <tab>
- <text>Log</text>
- <url>/pkg_edit.php?xml=squidguard_log.xml&amp;id=0</url>
- </tab>
- </tabs>
-
- <service>
+ <description>Describe your package here</description>
+ <requirements>Describe your package requirements here</requirements>
+ <faq>Currently there are no FAQ items provided.</faq>
+ <name>squidguardgeneral</name>
+ <version>1.2.0_2</version>
+ <title>Proxy filter SquidGuard: General settings</title>
+ <include_file>/usr/local/pkg/squidguard.inc</include_file>
+ <!-- Installation -->
+ <menu>
+ <name>Proxy filter</name>
+ <tooltiptext>Modify the proxy server's filter settings</tooltiptext>
+ <section>Services</section>
+ <url>/pkg_edit.php?xml=squidguard.xml&amp;id=0</url>
+ </menu>
+ <tabs>
+ <tab>
+ <text>General settings</text>
+ <url>/pkg_edit.php?xml=squidguard.xml&amp;id=0</url>
+ <active/>
+ </tab>
+ <tab>
+ <text>Default</text>
+ <url>/pkg_edit.php?xml=squidguard_default.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>ACL</text>
+ <url>/pkg.php?xml=squidguard_acl.xml</url>
+ </tab>
+ <tab>
+ <text>Destinations</text>
+ <url>/pkg.php?xml=squidguard_dest.xml</url>
+ </tab>
+ <tab>
+ <text>Times</text>
+ <url>/pkg.php?xml=squidguard_time.xml</url>
+ </tab>
+ <tab>
+ <text>Rewrites</text>
+ <url>/pkg.php?xml=squidguard_rewr.xml</url>
+ </tab>
+ <tab>
+ <text>Log</text>
+ <url>/squidGuard/squidguard_log.php</url>
+ </tab>
+ </tabs>
+ <service>
<name>squidGuard</name>
<description>Proxy server filter Service</description>
<executable>squidGuard</executable>
- </service>
-
- <additional_files_needed>
+ </service>
+ <additional_files_needed>
<prefix>/usr/local/pkg/</prefix>
<chmod>0755</chmod>
<item>http://www.pfsense.org/packages/config/squidGuard/squidguard.inc</item>
- </additional_files_needed>
- <additional_files_needed>
+ </additional_files_needed>
+ <additional_files_needed>
<prefix>/usr/local/pkg/</prefix>
<chmod>0755</chmod>
<item>http://www.pfsense.org/packages/config/squidGuard/squidguard_configurator.inc</item>
- </additional_files_needed>
- <additional_files_needed>
+ </additional_files_needed>
+ <additional_files_needed>
<prefix>/usr/local/pkg/</prefix>
<chmod>0755</chmod>
<item>http://www.pfsense.org/packages/config/squidGuard/squidguard_acl.xml</item>
- </additional_files_needed>
- <additional_files_needed>
+ </additional_files_needed>
+ <additional_files_needed>
<prefix>/usr/local/pkg/</prefix>
<chmod>0755</chmod>
<item>http://www.pfsense.org/packages/config/squidGuard/squidguard_default.xml</item>
- </additional_files_needed>
- <additional_files_needed>
+ </additional_files_needed>
+ <additional_files_needed>
<prefix>/usr/local/pkg/</prefix>
<chmod>0755</chmod>
<item>http://www.pfsense.org/packages/config/squidGuard/squidguard_dest.xml</item>
- </additional_files_needed>
- <additional_files_needed>
+ </additional_files_needed>
+ <additional_files_needed>
<prefix>/usr/local/pkg/</prefix>
<chmod>0755</chmod>
<item>http://www.pfsense.org/packages/config/squidGuard/squidguard_rewr.xml</item>
- </additional_files_needed>
- <additional_files_needed>
+ </additional_files_needed>
+ <additional_files_needed>
<prefix>/usr/local/pkg/</prefix>
<chmod>0755</chmod>
<item>http://www.pfsense.org/packages/config/squidGuard/squidguard_time.xml</item>
- </additional_files_needed>
- <additional_files_needed>
- <prefix>/usr/local/pkg/</prefix>
- <chmod>0755</chmod>
- <item>http://www.pfsense.org/packages/config/squidGuard/squidguard_log.xml</item>
- </additional_files_needed>
- <additional_files_needed>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/local/www/squidGuard/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.org/packages/config/squidGuard/squidguard_log.php</item>
+ </additional_files_needed>
+ <additional_files_needed>
<prefix>/usr/local/www/</prefix>
<chmod>0755</chmod>
<item>http://www.pfsense.org/packages/config/squidGuard/sgerror.php</item>
- </additional_files_needed>
-
- <fields>
+ </additional_files_needed>
+ <fields>
<field>
<fielddescr>Enable</fielddescr>
<fieldname>squidguard_enable</fieldname>
@@ -111,6 +105,28 @@
<type>checkbox</type>
</field>
<field>
+ <fielddescr>Enable GUI log</fielddescr>
+ <fieldname>enable_guilog</fieldname>
+ <description>Check this for enable GUI log.</description>
+ <type>checkbox</type>
+ </field>
+ <field>
+ <fielddescr>Enable log</fielddescr>
+ <fieldname>enable_log</fieldname>
+ <description>Check this for enable log of the proxy filter. Usually log used for testing filter settings.</description>
+ <type>checkbox</type>
+ </field>
+ <field>
+ <fielddescr>Enable log rotation</fielddescr>
+ <fieldname>log_rotation</fieldname>
+ <description>Check this for enable daily rotate a log of the proxy filter. Use this option for limit log file size.</description>
+ <type>checkbox</type>
+ </field>
+ <field>
+ <name>Blacklist options</name>
+ <type>listtopic</type>
+ </field>
+ <field>
<fielddescr>Blacklist</fielddescr>
<fieldname>blacklist</fieldname>
<description>Check this for enable blacklist</description>
@@ -134,31 +150,25 @@
<type>input</type>
<size>100</size>
</field>
- <field>
- <fielddescr>View GUI log</fielddescr>
- <fieldname>view_gui_log</fieldname>
- <description>Check this for view GUI log</description>
- <type>checkbox</type>
- </field>
- </fields>
- <custom_add_php_command/>
- <custom_php_validation_command>
+ </fields>
+ <custom_add_php_command/>
+ <custom_php_validation_command>
squidguard_validate(&amp;$_POST, &amp;$input_errors);
- </custom_php_validation_command>
- <custom_php_command_before_form>
+ </custom_php_validation_command>
+ <custom_php_command_before_form>
squidguard_before_form(&amp;$pkg);
- </custom_php_command_before_form>
- <custom_php_after_form_command>
- squidGuard_print_javascript();
- </custom_php_after_form_command>
- <custom_php_resync_config_command>
- squidguard_resync();
- </custom_php_resync_config_command>
- <custom_php_install_command>
- squidguard_install_command();
- squidguard_resync();
- </custom_php_install_command>
- <custom_php_deinstall_command>
- squidguard_deinstall_command();
- </custom_php_deinstall_command>
+ </custom_php_command_before_form>
+ <custom_php_after_form_command>
+ squidGuard_print_javascript();
+ </custom_php_after_form_command>
+ <custom_php_resync_config_command>
+ squidguard_resync();
+ </custom_php_resync_config_command>
+ <custom_php_install_command>
+ squidguard_install_command();
+ squidguard_resync();
+ </custom_php_install_command>
+ <custom_php_deinstall_command>
+ squidguard_deinstall_command();
+ </custom_php_deinstall_command>
</packagegui> \ No newline at end of file
diff --git a/config/squidGuard/squidguard_acl.xml b/config/squidGuard/squidguard_acl.xml
index 03755b8e..04bb8553 100644
--- a/config/squidGuard/squidguard_acl.xml
+++ b/config/squidGuard/squidguard_acl.xml
@@ -2,51 +2,47 @@
<!DOCTYPE packagegui SYSTEM "../schema/packages.dtd">
<?xml-stylesheet type="text/xsl" href="../xsl/package.xsl"?>
<packagegui>
- <description>Describe your package here</description>
- <requirements>Describe your package requirements here</requirements>
- <faq>Currently there are no FAQ items provided.</faq>
-
- <name>squidguardacl</name>
- <version>none</version>
- <title>Proxy filter SquidGuard: Access Control List (ACL)</title>
- <include_file>/usr/local/pkg/squidguard.inc</include_file>
-
- <delete_string>A proxy server user has been deleted.</delete_string>
- <addedit_string>A proxy server user has been created/modified.</addedit_string>
-
- <tabs>
- <tab>
- <text>General settings</text>
- <url>/pkg_edit.php?xml=squidguard.xml&amp;id=0</url>
- </tab>
- <tab>
- <text>Default</text>
- <url>/pkg_edit.php?xml=squidguard_default.xml&amp;id=0</url>
- </tab>
- <tab>
- <text>ACL</text>
- <url>/pkg.php?xml=squidguard_acl.xml</url>
- <active/>
- </tab>
- <tab>
- <text>Destinations</text>
- <url>/pkg.php?xml=squidguard_dest.xml</url>
- </tab>
- <tab>
- <text>Times</text>
- <url>/pkg.php?xml=squidguard_time.xml</url>
- </tab>
- <tab>
- <text>Rewrites</text>
- <url>/pkg.php?xml=squidguard_rewr.xml</url>
- </tab>
- <tab>
- <text>Log</text>
- <url>/pkg_edit.php?xml=squidguard_log.xml&amp;id=0</url>
- </tab>
- </tabs>
-
- <adddeleteeditpagefields>
+ <description>Describe your package here</description>
+ <requirements>Describe your package requirements here</requirements>
+ <faq>Currently there are no FAQ items provided.</faq>
+ <name>squidguardacl</name>
+ <version>none</version>
+ <title>Proxy filter SquidGuard: Access Control List (ACL)</title>
+ <include_file>/usr/local/pkg/squidguard.inc</include_file>
+ <delete_string>A proxy server user has been deleted.</delete_string>
+ <addedit_string>A proxy server user has been created/modified.</addedit_string>
+ <tabs>
+ <tab>
+ <text>General settings</text>
+ <url>/pkg_edit.php?xml=squidguard.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>Default</text>
+ <url>/pkg_edit.php?xml=squidguard_default.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>ACL</text>
+ <url>/pkg.php?xml=squidguard_acl.xml</url>
+ <active/>
+ </tab>
+ <tab>
+ <text>Destinations</text>
+ <url>/pkg.php?xml=squidguard_dest.xml</url>
+ </tab>
+ <tab>
+ <text>Times</text>
+ <url>/pkg.php?xml=squidguard_time.xml</url>
+ </tab>
+ <tab>
+ <text>Rewrites</text>
+ <url>/pkg.php?xml=squidguard_rewr.xml</url>
+ </tab>
+ <tab>
+ <text>Log</text>
+ <url>/squidGuard/squidguard_log.php</url>
+ </tab>
+ </tabs>
+ <adddeleteeditpagefields>
<columnitem>
<fielddescr>Disabled</fielddescr>
<fieldname>disabled</fieldname>
@@ -71,9 +67,8 @@
<fielddescr>Description</fielddescr>
<fieldname>description</fieldname>
</columnitem>
- </adddeleteeditpagefields>
-
- <fields>
+ </adddeleteeditpagefields>
+ <fields>
<field>
<fielddescr>Disabled</fielddescr>
<fieldname>disabled</fieldname>
@@ -250,30 +245,29 @@
<size>100</size>
</field>
<field>
- <fielddescr>Enable log</fielddescr>
+ <fielddescr>Log</fielddescr>
<fieldname>enablelog</fieldname>
- <description>Check this for enable log.</description>
+ <description>Check this for log this item.</description>
<type>checkbox</type>
</field>
- </fields>
-
- <custom_php_validation_command>
+ </fields>
+ <custom_php_validation_command>
squidguard_validate_acl(&amp;$_POST, &amp;$input_errors);
- </custom_php_validation_command>
- <custom_php_command_before_form>
+ </custom_php_validation_command>
+ <custom_php_command_before_form>
squidguard_before_form_acl(&amp;$pkg);
- </custom_php_command_before_form>
- <custom_php_after_form_command>
+ </custom_php_command_before_form>
+ <custom_php_after_form_command>
squidGuard_print_javascript();
- </custom_php_after_form_command>
- <custom_php_resync_config_command>
+ </custom_php_after_form_command>
+ <custom_php_resync_config_command>
squidguard_resync_acl();
- </custom_php_resync_config_command>
- <custom_delete_php_command>
+ </custom_php_resync_config_command>
+ <custom_delete_php_command>
squidguard_resync_acl();
- </custom_delete_php_command>
- <custom_add_php_command>
- </custom_add_php_command>
- <custom_add_php_command_late>
- </custom_add_php_command_late>
+ </custom_delete_php_command>
+ <custom_add_php_command>
+ </custom_add_php_command>
+ <custom_add_php_command_late>
+ </custom_add_php_command_late>
</packagegui> \ No newline at end of file
diff --git a/config/squidGuard/squidguard_configurator.inc b/config/squidGuard/squidguard_configurator.inc
index 71724c90..035ab734 100644
--- a/config/squidGuard/squidguard_configurator.inc
+++ b/config/squidGuard/squidguard_configurator.inc
@@ -55,13 +55,18 @@ ini_set('max_execution_time', '3600');
ini_set('max_input_time', '3600');
ini_set('memory_limit', '100M');
+#
+# ToDo ! Must use all settings via $squidguard_config !
+# Add check names for reserved words 'none, all, default, no-ip, block'
+# Sdelat rewrite dlya smeny skachivaniya
+
# ------------------------------------------------------------------------------
# files header
# ------------------------------------------------------------------------------
define('FILES_DB_HEADER', '
# ------------------------------------------------------------------------------
# File created by squidGuard package GUI
-# (C)2006-2008 Serg Dvoriancev
+# (C)2006-2010 Serg Dvoriancev
# ------------------------------------------------------------------------------
');
@@ -107,17 +112,19 @@ define('SQUID_CONFIGFILE', '/usr/local/etc/squid/squid.conf');
define('TMP_DIR', '/var/tmp');
define('SQUIDGUARD_CONFIGFILE', '/squidGuard.conf');
-define('SQUIDGUARDCONF_LOGFILE', '/sg_configurator.log');
-define('SQUIDGUARD_ACCESSBLOCK_FILE', 'block.log');
+define('SQUIDGUARD_CONFLOGFILE', '/sg_configurator.log');
+define('SQUIDGUARD_LOGFILE', 'block.log');
define('SQUIDGUARD_CONFBASE_DEF', '/usr/local/etc/squid');
define('SQUIDGUARD_LOGDIR_DEF', '/tmp');
define('SQUIDGUARD_WORKDIR_DEF', '/usr/local/etc/squidGuard');
define('SQUIDGUARD_BINPATH_DEF', '/usr/local/bin');
-define('SQUIDGUARD_TMP', '/var/tmp/squidGuard'); # SG temp
-define('SQUIDGUARD_VAR', '/var/squidGuard'); # SG variables
+define('SQUIDGUARD_TMP', '/var/tmp/squidGuard'); # SG temp
+define('SQUIDGUARD_VAR', '/var/squidGuard'); # SG variables
define('SQUIDGUARD_STATE', '/squidGuard.state');
define('SQUIDGUARD_REBUILD', '/squidGuard.rebuild');
+define('SQUIDGUARD_SCR_LOGROTATE', '/usr/local/etc/rc.d/squidGuard_logrotate'); # Logrotate script
+
# DB home catalog contains 'Blacklist' and 'User' sub-catalogs
define('SQUIDGUARD_DBHOME_DEF', '/var/db/squidGuard');
define('SQUIDGUARD_DB_BLACKLIST', '/bl');
@@ -139,6 +146,9 @@ define('SG_INFO_FILE', '/var/squidGuard/sg_db_upd.inf');
# error_res
define('SG_ERR0', "Error! Check squidGuard configuration data.");
+# ==============================================================================
+# DEFINES
+# ==============================================================================
# redirect mode
define('RMOD_NONE', 'rmod_none');
define('RMOD_INT_ERRORPAGE', 'rmod_int');
@@ -150,11 +160,19 @@ define('RMOD_EXT_RDR', 'rmod_ext_rdr');
define('RMOD_EXT_MOVED', 'rmod_ext_mov');
define('RMOD_EXT_FOUND', 'rmod_ext_fnd');
-# GUI options
-define('SQUIDGUARD_LOG_MAXCOUNT', 500); # max log lines
+# 0-error, 1-warning; 2-info
+define('SQUIDGUARD_INFO', 2);
+define('SQUIDGUARD_WARNING', 1);
+define('SQUIDGUARD_ERROR', 0);
-# 0-all, 1-medium; 2-low
-define('SQUIDGUARD_LOG_LEVEL', 0);
+# ==============================================================================
+# OPTIONS
+# ==============================================================================
+# Log
+define('SQUIDGUARD_GUILOG_LEVEL', SQUIDGUARD_INFO); # log level
+define('SQUIDGUARD_GUILOG_MAXCOUNT', 500); # log max lines
+define('SQUIDGUARD_GUILOG_ENABLE', true); # on/off gui log - option override GUI settings
+define('SQUIDGUARD_LOG_ENABLE', true); # on/off SG log - option override GUI settings
#
define('FLT_DEFAULT_ALL', 'all');
@@ -166,6 +184,7 @@ define('OWNER_NAME', 'proxy');
# Debug
define('DEBUG_ON', 'true');
+
# ==============================================================================
# black list
# ==============================================================================
@@ -186,10 +205,6 @@ define('FLT_WAREZ', 'warez');
# ==============================================================================
# SquidGuard Configurator
# ==============================================================================
-$squidguard_config = array(); # squidGuard config array
-
-# call default init
-sg_init();
# ------------------------------------------------------------------------------
# squidguard system fields
@@ -244,6 +259,11 @@ define('F_NOTALLOWINGIP', 'notallowingip'); # not allo
define('F_USERNAME', 'username');
define('F_ORDER', 'order');
+# log
+define('F_ENABLELOG', 'enablelog');
+define('F_ENABLEGUILOG', 'enableguilog');
+define('F_LOGROTATION', 'logrotation');
+
# transparent mode
define('F_SQUID_TRANSPARENT_MODE', 'squid_transparent_mode');
define('F_CURRENT_LAN_IP', 'current_lan_ip');
@@ -251,6 +271,14 @@ define('F_CURRENT_GUI_PORT', 'current_gui_port');
define('F_CURRENT_GUI_PROTO', 'current_gui_protocol');
# ------------------------------------------------------------------------------
+# Globals
+# ------------------------------------------------------------------------------
+$squidguard_config = array(); # squidGuard config array
+
+# call default init
+sg_init();
+
+# ------------------------------------------------------------------------------
# sg_init - initialize config array
# ------------------------------------------------------------------------------
function sg_init($init = '')
@@ -265,9 +293,11 @@ function sg_init($init = '')
$squidguard_config[F_WORKDIR] = SQUIDGUARD_WORKDIR_DEF;
$squidguard_config[F_BINPATH] = SQUIDGUARD_BINPATH_DEF;
$squidguard_config[F_SQUIDCONFIGFILE] = SQUID_CONFIGFILE;
- $squidguard_config[F_PROCCESSCOUNT] = REDIRECTOR_PROCESS_COUNT;
+ $squidguard_config[F_PROCCESSCOUNT] = REDIRECTOR_PROCESS_COUNT;
} else {
- $squidguard_config = $init;
+ # copy config from $init
+ foreach($init as $key => $in)
+ $squidguard_config[$key] = $in;
}
return $squidguard_config;
@@ -286,11 +316,11 @@ function sg_load_configxml($filename)
if (!empty($xmlconf)) {
$squidguard_config = $xmlconf[F_SQUIDGUARD];
- sg_addlog("sg_load_configxml: Success update from '$filename'.", 1);
+ sg_addlog("sg_load_configxml", "Success update from '$filename'.", SQUIDGUARD_INFO);
} else
- sg_addlog("sg_load_configxml: Error, file '$filename' is empty.", 2);
+ sg_addlog("sg_load_configxml", "File '$filename' is empty.", SQUIDGUARD_ERROR);
} else
- sg_addlog("sg_load_configxml: Error, file '$filename' does not exists.", 2);
+ sg_addlog("sg_load_configxml", "File '$filename' does not exists.", SQUIDGUARD_ERROR);
}
# ------------------------------------------------------------------------------
@@ -328,9 +358,9 @@ function sg_reconfigure()
file_put_contents('/usr/local/etc/squid' . SQUIDGUARD_CONFIGFILE, $conf); # << squidGuard want config '/usr/local/etc/squid' by default
set_file_access($squidguard_config[F_WORKDIR], OWNER_NAME, 0755);
conf_mount_ro();
- sg_addlog("sg_reconfigure: save squidGuard config to '$conf_file'.", 1);
+ sg_addlog("sg_reconfigure", "Save squidGuard config to '$conf_file'.", SQUIDGUARD_INFO);
} else
- sg_addlog("sg_reconfigure: error make squidGuard config.", 2);
+ sg_addlog("sg_reconfigure", "Can't create squidGuard config.", SQUIDGUARD_ERROR);
# 4. reconfigure squid
squid_reconfigure();
@@ -361,7 +391,7 @@ function squid_reconfigure($remove_only = '')
(strpos($t_opt, REDIRECT_CHILDREN_OPT) === 0))
unset($conf[$key]);
}
- sg_addlog("squid_reconfigure: Remove old redirector options from Squid config.", 1);
+ sg_addlog("squid_reconfigure", "Remove old redirector options from Squid config.", SQUIDGUARD_INFO);
}
# add new options - if squidGuard enabled
@@ -373,7 +403,7 @@ function squid_reconfigure($remove_only = '')
$conf[] = REDIRECT_BYPASS_OPT . " on";
$conf[] = REDIRECT_CHILDREN_OPT . " " . REDIRECTOR_PROCESS_COUNT;
- sg_addlog("squid_reconfigure: Add new redirector options to Squid config.", 1);
+ sg_addlog("squid_reconfigure", "Add new redirector options to Squid config.", SQUIDGUARD_INFO);
}
# update config
@@ -400,36 +430,40 @@ function sg_check_system()
if (!file_exists($work_dir)) {
mwexec("mkdir -p $work_dir");
set_file_access($work_dir, OWNER_NAME, 0755);
- sg_addlog("sg_check_system: Create work dir '$work_dir'.", 1);
+ sg_addlog("sg_check_system", "Create work dir '$work_dir'.", SQUIDGUARD_WARNING);
}
}
- unset($work_dir);
# check log_dir & create if not exists
$log_dir = $squidguard_config[F_LOGDIR];
if (!empty($log_dir)) {
if (!file_exists($log_dir)) {
mwexec("mkdir -p $log_dir");
- sg_addlog("sg_check_system: Create log dir '$log_dir'.", 1);
+ sg_addlog("sg_check_system", "Create log dir '$log_dir'.", SQUIDGUARD_WARNING);
}
# set access right - need start any time;
# (SG possible start from console and log file will have only root access)
set_file_access($log_dir, OWNER_NAME, 0755);
}
- unset($log_dir);
# check db dir
$db_dir = $squidguard_config[F_DBHOME];
if (!empty($db_dir)) {
if (!file_exists($db_dir)) {
mwexec("mkdir -p $db_dir");
- sg_addlog("sg_check_system: Create db dir '$db_dir'.", 1);
+ sg_addlog("sg_check_system", "Create db dir '$db_dir'.", SQUIDGUARD_WARNING);
}
# set access right
set_file_access($db_dir, OWNER_NAME, 0755);
}
- unset($db_dir);
conf_mount_ro();
+
+ # logrotate
+ if (file_exists(SQUIDGUARD_SCR_LOGROTATE)) unlink(SQUIDGUARD_SCR_LOGROTATE);
+ if ($squidguard_config[F_LOGROTATION] == 'on') {
+ file_put_contents(SQUIDGUARD_SCR_LOGROTATE, sg_script_logrotate());
+ set_file_access (SQUIDGUARD_SCR_LOGROTATE, OWNER_NAME, 0755);
+ }
}
# ==============================================================================
# squidGuard DB
@@ -442,16 +476,16 @@ function sg_reconfigure_user_db()
conf_mount_rw();
$dbhome = $squidguard_config[F_DBHOME];
- sg_addlog("sg_reconfigure_user_db: Begin with '$dbhome'", 1);
+ sg_addlog("sg_reconfigure_user_db", "Begin with '$dbhome'", SQUIDGUARD_INFO);
# create user DB catalog, if not extsts
if (!file_exists($dbhome)) {
if (!mkdir($dbhome, 0755)) {
- sg_addlog("sg_reconfigure_user_db: Error create user DB directory '$dbhome'.", 2);
+ sg_addlog("sg_reconfigure_user_db", "Can't create user DB directory '$dbhome'.", SQUIDGUARD_ERROR);
return;
}
set_file_access($dbhome, OWNER_NAME, 0755);
- sg_addlog("sg_reconfigure_user_db: Create user DB directory '$dbhome'.", 1);
+ sg_addlog("sg_reconfigure_user_db", "Create user DB directory '$dbhome'.", SQUIDGUARD_INFO);
}
# update destinations to db
@@ -460,7 +494,7 @@ function sg_reconfigure_user_db()
$dst_names = Array();
$dst_list = Array();
- sg_addlog("sg_reconfigure_user_db: Add user entries", 1);
+ sg_addlog("sg_reconfigure_user_db", "Add user entries", SQUIDGUARD_INFO);
foreach($dests[F_ITEM] as $dst) {
$path = "$dbhome/" . $dst[F_NAME];
$dst_names[] = $path;
@@ -469,10 +503,10 @@ function sg_reconfigure_user_db()
# 1. check destination catalog and create them, if need
if (!file_exists($path)) {
if (!mkdir ($path, 0755)) {
- sg_addlog("sg_reconfigure_user_db: Error create dir '$path'.", 2);
+ sg_addlog("sg_reconfigure_user_db", "Can't create dir '$path'.", SQUIDGUARD_ERROR);
return;
}
- sg_addlog("sg_reconfigure_user_db: Create dir '$path'.", 1);
+ sg_addlog("sg_reconfigure_user_db", "Create dir '$path'.", SQUIDGUARD_INFO);
}
# 2. build domains file
@@ -480,7 +514,7 @@ function sg_reconfigure_user_db()
if (!empty($domains)) {
$content = trim(str_replace(" ", "\n", $domains));
file_put_contents($path . '/domains', $content);
- sg_addlog("sg_reconfigure_user_db: -- add {$dst[F_NAME]} domains '$domains';", 1);
+ sg_addlog("sg_reconfigure_user_db", "Add {$dst[F_NAME]} domains '$domains';", SQUIDGUARD_INFO);
}
unset($domains);
@@ -489,7 +523,7 @@ function sg_reconfigure_user_db()
if (!empty($urls)) {
$content = trim(str_replace(" ", "\n", $urls));
file_put_contents($path . '/urls', $content);
- sg_addlog("sg_reconfigure_user_db: -- add {$dst[F_NAME]} urls '$content';", 1);
+ sg_addlog("sg_reconfigure_user_db", "Add {$dst[F_NAME]} urls '$content';", SQUIDGUARD_INFO);
}
unset($urls);
@@ -499,7 +533,7 @@ function sg_reconfigure_user_db()
$content = trim(str_replace("|", " ", $expr)); # delete first and last unnecessary '|' symbol
$content = str_replace(" ", "|", $content);
file_put_contents($path . '/expressions', $content);
- sg_addlog("sg_reconfigure_user_db: -- add {$dst[F_NAME]} expressions '$content';", 1);
+ sg_addlog("sg_reconfigure_user_db", "Add {$dst[F_NAME]} expressions '$content';", SQUIDGUARD_INFO);
}
unset($expr);
}
@@ -510,7 +544,7 @@ function sg_reconfigure_user_db()
# 6. rebuild user db ('/var/db/squidGuard')
sg_rebuild_db("_usrdb", $dbhome, $dst_list);
} else
- sg_addlog("sg_reconfigure_user_db: Nothing. User destinations list empty.", 2);
+ sg_addlog("sg_reconfigure_user_db", "User destinations list empty.", SQUIDGUARD_WARNING);
# 7. remove unused db entries
sg_remove_unused_db_entries();
@@ -557,9 +591,9 @@ function sg_remove_unused_db_entries()
if (!empty($fd) && ($fd != ".") && ($fd != "..")) {
if (file_exists($file_fd)) {
mwexec("rm -R $file_fd");
- sg_addlog("sg_remove_unused_db_entries: Removed file '$file_fd'.", 1);
+ sg_addlog("sg_remove_unused_db_entries", "Removed file '$file_fd'.", SQUIDGUARD_INFO);
} else
- sg_addlog("sg_remove_unused_db_entries: File'$file_fd' not found.", 2);
+ sg_addlog("sg_remove_unused_db_entries", "File'$file_fd' not found.", SQUIDGUARD_ERROR);
}
}
}
@@ -586,7 +620,7 @@ function sg_rebuild_db($shtag, $rdb_dbhome, $rdb_itemslist)
# current dbhome dir
if (!empty($rdb_dbhome)) $dbhome = $rdb_dbhome;
- sg_addlog("sg_rebuild_db: Begin with path '$dbhome'.", 1);
+ sg_addlog("sg_rebuild_db", "Begin with path '$dbhome'.", SQUIDGUARD_INFO);
# define - where config will placed
$conf_path = "/tmp/squidGuard_rebuild.conf" . $shtag;
@@ -595,7 +629,7 @@ function sg_rebuild_db($shtag, $rdb_dbhome, $rdb_itemslist)
$conf = sg_create_simple_config($dbhome, $rdb_itemslist);
file_put_contents($conf_path, $conf);
set_file_access($conf_path, OWNER_NAME, 0750);
- sg_addlog("sg_rebuild_db: Create temporary config '$conf_path'.", 1);
+ sg_addlog("sg_rebuild_db", "Create temporary config '$conf_path'.", SQUIDGUARD_INFO);
# *** SH script ***
$sh_scr = Array();
@@ -617,7 +651,7 @@ function sg_rebuild_db($shtag, $rdb_dbhome, $rdb_itemslist)
set_file_access($shfile, OWNER_NAME, 0750);
# ! not background exec !
mwexec($shfile);
- sg_addlog("sg_rebuild_db: Started SH script '$shfile'.", 1);
+ sg_addlog("sg_rebuild_db", "Started SH script '$shfile'.", SQUIDGUARD_INFO);
conf_mount_ro();
}
@@ -626,15 +660,27 @@ function sg_rebuild_db($shtag, $rdb_dbhome, $rdb_itemslist)
# ------------------------------------------------------------------------------
# sg_addlog
# ------------------------------------------------------------------------------
-function sg_addlog($log, $level = 0)
+function sg_addlog($module, $log, $level = 0)
{
global $squidguard_config;
+ # log disabled
+ if ( SQUIDGUARD_GUILOG_ENABLE === false || $squidguard_config[F_ENABLEGUILOG] != 'on' ) return;
+
# log level
- if ($level < SQUIDGUARD_LOG_LEVEL) return;
+ if ($level > SQUIDGUARD_GUILOG_LEVEL) return;
+
+ if ($module) $module = "[$module]";
+
+ $leveltext = "";
+ switch($level) {
+ case SQUIDGUARD_INFO: $leveltext = ""; break;
+ case SQUIDGUARD_WARNING: $leveltext = "Warning"; break;
+ default: $leveltext = "Error"; break;
+ }
$logfile = '';
- $logfile = SQUIDGUARD_LOGDIR_DEF . SQUIDGUARDCONF_LOGFILE;
+ $logfile = SQUIDGUARD_LOGDIR_DEF . SQUIDGUARD_CONFLOGFILE;
$log_content = array();
setlocale(LC_TIME, '');
@@ -643,9 +689,9 @@ function sg_addlog($log, $level = 0)
# define logfile
if (!empty($squidguard_config)) {
if (file_exists($squidguard_config[F_LOGDIR]))
- $logfile = $squidguard_config[F_LOGDIR] . SQUIDGUARDCONF_LOGFILE;
+ $logfile = $squidguard_config[F_LOGDIR] . SQUIDGUARD_CONFLOGFILE;
} else
- $log_content[] = "$dt : " . "sg_addlog: Error: squidguard_config is empty";
+ $log_content[] = "$dt : " . "[sg_addlog] Error: squidguard_config is empty";
$tmplog = '';
if (file_exists($logfile))
@@ -654,9 +700,9 @@ function sg_addlog($log, $level = 0)
unset($tmplog);
# shrink to MAXCOUNT log entries
- $log_content[] = "$dt : $log";
- if (count($log_content) > SQUIDGUARD_LOG_MAXCOUNT)
- array_splice($log_content, 0, SQUIDGUARD_LOG_MAXCOUNT - count($log_content));
+ $log_content[] = "$dt : $module $leveltext $log";
+ if (count($log_content) > SQUIDGUARD_GUILOG_MAXCOUNT)
+ array_splice($log_content, 0, SQUIDGUARD_GUILOG_MAXCOUNT - count($log_content));
file_put_contents($logfile, implode("\n", $log_content));
}
@@ -667,11 +713,11 @@ function sg_getlog($last_entries_count)
{
global $squidguard_config;
$log_content = '';
- $logfile = SQUIDGUARD_LOGDIR_DEF . SQUIDGUARDCONF_LOGFILE;
+ $logfile = SQUIDGUARD_LOGDIR_DEF . SQUIDGUARD_CONFLOGFILE;
# define logfile
if (!empty($squidguard_config) && file_exists($squidguard_config[F_LOGDIR]))
- $logfile = $squidguard_config[F_LOGDIR] . SQUIDGUARDCONF_LOGFILE;
+ $logfile = $squidguard_config[F_LOGDIR] . SQUIDGUARD_CONFLOGFILE;
# get log last 100 entries
if (file_exists($logfile)) {
@@ -702,14 +748,14 @@ function sg_create_config()
$temp_str = '';
if(!is_array($squidguard_config) || empty($squidguard_config)) {
- sg_addlog("sg_create_config: Error squidguard config data.", 2);
+ sg_addlog("sg_create_config", "Bad squidGuard config data.", SQUIDGUARD_ERROR);
return sg_create_simple_config('', '', SG_ERR0 . " (sg_create_config: [1]).");
}
# check configuration data
if (!sg_check_config_data(&$error_res)) {
- sg_addlog("sg_create_config: Error config data. It's all error_res: \n$error_res", 2);
- sg_addlog("sg_create_config: Terminated.", 2);
+ sg_addlog("sg_create_config", "Bad config data. It's all error_res: $error_res", SQUIDGUARD_ERROR);
+ sg_addlog("sg_create_config", "Terminated.", SQUIDGUARD_ERROR);
return sg_create_simple_config('', '', SG_ERR0 . " (sg_create_config: [2]).");
}
@@ -737,7 +783,7 @@ function sg_create_config()
}
# log
$temp_str = !empty($temp_str) ? $temp_str : "Nothing.";
- sg_addlog("sg_create_config: add times: \n $temp_str", 1);
+ sg_addlog("sg_create_config", "Add times: $temp_str", SQUIDGUARD_INFO);
}
# --- Sources ---
@@ -756,7 +802,10 @@ function sg_create_config()
elseif (is_domain_valid($sr)) $sg_tag->items[] = "domain $sr";
elseif (is_username($sr)) $sg_tag->items[] = "user " . str_replace("'", "", $sr);
}
- if ($src[F_LOG]) $sg_tag->items[] = "log " . SQUIDGUARD_ACCESSBLOCK_FILE;
+
+ if ($squidguard_config[F_ENABLELOG] == 'on' ) {
+ if ($src[F_LOG]) $sg_tag->items[] = "log " . SQUIDGUARD_LOGFILE;
+ }
$sgconf[] = "";
$sgconf[] = $sg_tag->tag_text();
@@ -766,7 +815,7 @@ function sg_create_config()
}
# log
$temp_str = !empty($temp_str) ? $temp_str : "Nothing.";
- sg_addlog("sg_create_config: add sources: \n $temp_str", 1);
+ sg_addlog("sg_create_config", "Add sources: $temp_str", SQUIDGUARD_INFO);
}
# --- Blacklist ---
@@ -776,7 +825,7 @@ function sg_create_config()
if (($squidguard_config[F_BLACKLISTENABLED] === 'on') and $db_entries) {
$log_entr_added = '';
$log_entr_ignored = '';
- sg_addlog("sg_create_config: add blacklist entries", 1);
+ sg_addlog("sg_create_config", "Add blacklist entries", SQUIDGUARD_INFO);
foreach($db_entries as $key => $ent) {
$ent_state = array();
$file_dms = "{$squidguard_config[F_DBHOME]}/$ent/domains";
@@ -805,7 +854,9 @@ function sg_create_config()
if ($ent_state[F_DOMAINS]) $sg_tag->items[] = "domainlist $ent/domains";
if ($ent_state[F_EXPRESSIONS]) $sg_tag->items[] = "expressionlist $ent/expressions";
if ($ent_state[F_URLS]) $sg_tag->items[] = "urllist $ent/urls";
- $sg_tag->items[] = "log ". SQUIDGUARD_ACCESSBLOCK_FILE;
+ if ($squidguard_config[F_ENABLELOG] == 'on' ) {
+ $sg_tag->items[] = "log ". SQUIDGUARD_LOGFILE;
+ }
$sgconf[] = "";
$sgconf[] = $sg_tag->tag_text();
@@ -819,8 +870,8 @@ function sg_create_config()
}
# log 'added' and 'ignored'
- if (!empty($log_entr_added)) sg_addlog("sg_create_config: added: \n $log_entr_added \n", 1);
- if (!empty($log_entr_ignored)) sg_addlog("sg_create_config: ignored: \n $log_entr_ignored \n", 2);
+ if (!empty($log_entr_added)) sg_addlog("sg_create_config", "Added: $log_entr_added .", SQUIDGUARD_INFO);
+ if (!empty($log_entr_ignored)) sg_addlog("sg_create_config", "Ignored: $log_entr_ignored .", SQUIDGUARD_WARNING);
}
# --- Destinations ---
@@ -839,8 +890,10 @@ function sg_create_config()
$sg_tag->items[] = "urllist $dstname/urls";
if ($dst[F_RMOD] != RMOD_NONE)
$sg_tag->items[] = "redirect " . sg_redirector_base_url($dst[F_REDIRECT], $dst[F_RMOD]);
- if ($dst[F_LOG])
- $sg_tag->items[] = "log " . SQUIDGUARD_ACCESSBLOCK_FILE;
+ if ($squidguard_config[F_ENABLELOG] == 'on' ) {
+ if ($dst[F_LOG])
+ $sg_tag->items[] = "log " . SQUIDGUARD_LOGFILE;
+ }
$sgconf[] = "";
$sgconf[] = $sg_tag->tag_text();
@@ -850,7 +903,7 @@ function sg_create_config()
}
# log
$temp_str = !empty($temp_str) ? $temp_str : "Nothing.";
- sg_addlog("sg_create_config: add destinations: \n $temp_str", 1);
+ sg_addlog("sg_create_config", "Add destinations: $temp_str", SQUIDGUARD_INFO);
}
# --- Rewrites ---
@@ -866,8 +919,10 @@ function sg_create_config()
foreach ($rew[F_ITEM] as $rw)
$sg_tag->items[] = "s@{$rw[F_TARGETURL]}@{$rw[F_REPLACETO]}@{$rw[F_MODE]}";
- if ($rew[F_LOG])
- $sg_tag->items[] = "log " . SQUIDGUARD_ACCESSBLOCK_FILE;
+ if ($squidguard_config[F_ENABLELOG] == 'on' ) {
+ if ($rew[F_LOG])
+ $sg_tag->items[] = "log " . SQUIDGUARD_LOGFILE;
+ }
$sgconf[] = "";
$sgconf[] = $sg_tag->tag_text();
@@ -883,8 +938,8 @@ function sg_create_config()
}
# log
- if (!empty($log_entr_added)) sg_addlog("sg_create_config: add rewrites: success $log_entr_added", 1);
- if (!empty($log_entr_err)) sg_addlog("sg_create_config: add rewrites: error $log_entr_err", 1);
+ if (!empty($log_entr_added)) sg_addlog("sg_create_config", "Add rewrites: $log_entr_added", SQUIDGUARD_INFO);
+ if (!empty($log_entr_err)) sg_addlog("sg_create_config", "Add rewrites error $log_entr_err", SQUIDGUARD_ERROR);
}
# ----------------------------------------
@@ -923,8 +978,10 @@ function sg_create_config()
$sg_acltag->items[] = "redirect " . sg_redirector_base_url($acl[F_REDIRECT], $acl[F_RMOD]);
if ($acl[F_REWRITENAME])
$sg_acltag->items[] = "rewrite {$acl[F_REWRITENAME]}";
- if ($acl[F_LOG])
- $sg_acltag->items[] = "log " . SQUIDGUARD_ACCESSBLOCK_FILE;
+ if ($squidguard_config[F_ENABLELOG] == 'on' ) {
+ if ($acl[F_LOG])
+ $sg_acltag->items[] = "log " . SQUIDGUARD_LOGFILE;
+ }
# overtime
if ($acl[F_TIMENAME]) {
@@ -934,8 +991,10 @@ function sg_create_config()
$sg_acltag->items[] = "redirect " . sg_redirector_base_url($acl[F_OVERREDIRECT], $acl[F_RMOD]);
if ($acl[F_OVERREWRITENAME])
$sg_acltag->items[] = "rewrite {$acl[F_OVERREWRITENAME]}";
- if ($acl[F_LOG])
- $sg_acltag->items[] = "log " . SQUIDGUARD_ACCESSBLOCK_FILE;
+ if ($squidguard_config[F_ENABLELOG] == 'on' ) {
+ if ($acl[F_LOG])
+ $sg_acltag->items[] = "log " . SQUIDGUARD_LOGFILE;
+ }
}
$sg_tag->items[] = $sg_acltag;
}
@@ -943,14 +1002,14 @@ function sg_create_config()
}
# log
$log_entr_added = !empty($log_entr_added) ? $log_entr_added : "Nothing.";
- sg_addlog("sg_create_config: add ACL's: \n $log_entr_added", 1);
+ sg_addlog("sg_create_config", "Add ACL's: $log_entr_added", SQUIDGUARD_INFO);
}
# --- Default ---
$sg_tag_def = new TSgTag;
$sg_tag_def->set("default", "", "", "");
$def = $squidguard_config[F_DEFAULT];
- sg_addlog("sg_create_config: add Default", 1);
+ sg_addlog("sg_create_config", "Add Default", SQUIDGUARD_INFO);
if ($def) {
$temp_str = '';
@@ -971,16 +1030,17 @@ function sg_create_config()
$sg_tag_def->items[] = "redirect " . sg_redirector_base_url($def[F_REDIRECT], $def[F_RMOD]);
if ($def[F_REWRITENAME])
$sg_tag_def->items[] = "rewrite {$def[F_REWRITENAME]}";
- if ($def[F_LOG])
- $sg_tag_def->items[] = "log " . SQUIDGUARD_ACCESSBLOCK_FILE;
-
+ if ($squidguard_config[F_ENABLELOG] == 'on' ) {
+ if ($def[F_LOG])
+ $sg_tag_def->items[] = "log " . SQUIDGUARD_LOGFILE;
+ }
} # <- if def
else {
- $msg = "Error: ACL 'default' is empty, will use default 'block all'";
+ $msg = "ACL 'default' is empty, will use default 'block all'";
$sg_tag_def->items[] = "# $msg";
$sg_tag_def->items[] = "pass none";
$sg_tag_def->items[] = "redirect " . sg_redirector_base_url('', RMOD_INT_ERRORPAGE);
- sg_addlog("sg_create_config: $msg.", 2);
+ sg_addlog("sg_create_config", "$msg.", SQUIDGUARD_ERROR);
}
# --- ACL end ---
@@ -1014,7 +1074,7 @@ function sg_create_simple_config($blk_dbhome, $blk_destlist, $redirect_to = "404
# current dbhome dir
if (!empty($blk_dbhome)) $dbhome = $blk_dbhome;
- sg_addlog("sg_create_simple_config: Begin with dbhome='$dbhome'.", 1);
+ sg_addlog("sg_create_simple_config", "Begin with dbhome='$dbhome'.", SQUIDGUARD_INFO);
# header
$sgconf[] = CONFIG_SG_HEADER;
@@ -1038,9 +1098,9 @@ function sg_create_simple_config($blk_dbhome, $blk_destlist, $redirect_to = "404
if (!empty($tmp_s)) {
$tmp_s = implode("\n", $tmp_s);
$sgconf[] = "dest $dst {\n $tmp_s \n}\n";
- sg_addlog("sg_create_simple_config: -- added item '$dst' = '$dbhome/$dpath'.");
+ sg_addlog("sg_create_simple_config", "Added item '$dst' = '$dbhome/$dpath'.", SQUIDGUARD_INFO);
} else
- sg_addlog("sg_create_simple_config: -- ignored empty item '$dst' = '$dbhome/$dpath'.");
+ sg_addlog("sg_create_simple_config", "Ignored empty item '$dst' = '$dbhome/$dpath'.", SQUIDGUARD_WARNING);
}
}
@@ -1075,8 +1135,8 @@ function sg_redirector_base_url($rdr_info, $redirect_mode)
$errmsg = '';
if (!sg_check_redirect($redirect_mode, $rdr_info, &$errmsg)) {
$redirect_mode = RMOD_INT_ERRORPAGE;
- $rdr_info = "Redirect settings error. $errmsg Check you configuration.";
- sg_addlog("sg_redirector_base_url: ERROR: $errmsg");
+ $rdr_info = "Bad redirect settings. $errmsg Check you configuration.";
+ sg_addlog("sg_redirector_base_url", "$errmsg", SQUIDGUARD_ERROR);
}
switch($redirect_mode) {
@@ -1091,7 +1151,7 @@ function sg_redirector_base_url($rdr_info, $redirect_mode)
default: $rdr_path .= "?url=" . rawurlencode("403 $rdr_info") . REDIRECT_URL_ARGS; break;
}
- sg_addlog("sg_redirector_base_url: Select redirector base url ($rdr_path)");
+ sg_addlog("sg_redirector_base_url", "Select redirector base url ($rdr_path)", SQUIDGUARD_INFO);
return $rdr_path;
}
@@ -1376,30 +1436,30 @@ function sg_reconfigure_blacklist($source_filename, $opt = '')
$sf = trim($source_filename);
$sf_contents = '';
- sg_addlog("sg_reconfigure_blacklist: Begin with '$sf'.", 1);
+ sg_addlog("sg_reconfigure_blacklist", "Begin with '$sf'.", SQUIDGUARD_INFO);
# 1. check system
sg_check_system();
# 2. upload
if ($sf[0] === "/") { # local file - example '/tmp/blacklists.tar'
- sg_addlog("sg_reconfigure_blacklist: Update from file '$sf'.", 1);
+ sg_addlog("sg_reconfigure_blacklist", "Update from file '$sf'.", SQUIDGUARD_INFO);
if (file_exists($sf)) {
$sf_contents = file_get_contents($sf);
} else {
- sg_addlog("sg_reconfigure_blacklist: Error, file '$sf' not found.", 2);
+ sg_addlog("sg_reconfigure_blacklist", "File '$sf' not found.", SQUIDGUARD_ERROR);
return;
}
}
# from url
else {
- sg_addlog("sg_reconfigure_blacklist: Upload from url '$sf'.", 1);
+ sg_addlog("sg_reconfigure_blacklist", "Upload from url '$sf'.", SQUIDGUARD_INFO);
$sf_contents = sg_uploadfile_from_url($sf, BLK_LOCALFILE, $opt);
}
# 3. update
if (empty($sf_contents)) {
- sg_addlog("sg_reconfigure_blacklist: Error content from '$sf'.", 2);
+ sg_addlog("sg_reconfigure_blacklist", "Bad content from '$sf'.", SQUIDGUARD_ERROR);
return;
}
# save black list archive content to local file
@@ -1430,7 +1490,7 @@ function sg_update_blacklist($from_file)
$tmp_unpack_dir = SQUIDGUARD_TMP . SQUIDGUARD_BL_UNPACK;
$arc_db_dir = SQUIDGUARD_VAR . SG_BLK_ARC;
- sg_addlog("sg_update_blacklist: Begin with '$from_file'.", 1);
+ sg_addlog("sg_update_blacklist", "Begin with '$from_file'.", SQUIDGUARD_INFO);
if (file_exists($from_file)) {
# check work and DB dir's
@@ -1446,7 +1506,7 @@ function sg_update_blacklist($from_file)
# 1. unpack archive
mwexec("tar zxvf $from_file -C $tmp_unpack_dir");
set_file_access($tmp_unpack_dir, OWNER_NAME, 0755);
- sg_addlog("sg_update_blacklist: Unpack uploaded file '$from_file' -> '$tmp_unpack_dir'.", 1);
+ sg_addlog("sg_update_blacklist", "Unpack uploaded file '$from_file' -> '$tmp_unpack_dir'.", SQUIDGUARD_INFO);
# 2. copy blacklist to squidGuard base & create entries list
if (file_exists($tmp_unpack_dir)) {
@@ -1470,7 +1530,7 @@ function sg_update_blacklist($from_file)
if (file_exists($current_dbpath))
mwexec("rm -R $current_dbpath");
mwexec("mv -f {$val['path']}/ $current_dbpath");
- sg_addlog("sg_update_blacklist: Move {$val['path']}/ -> $current_dbpath.", 1);
+ sg_addlog("sg_update_blacklist", "Move {$val['path']}/ -> $current_dbpath.", SQUIDGUARD_INFO);
}
}
set_file_access($arc_db_dir, OWNER_NAME, 0755);
@@ -1490,14 +1550,14 @@ function sg_update_blacklist($from_file)
# $blklist_file = "{$squidguard_config[F_WORKDIR]}/" . SQUIDGUARD_BLK_ENTRIES;
# file_put_contents($blklist_file, implode("\n", array_keys($blk_items)));
# set_file_access ($blklist_file, OWNER_NAME, 0755);
- sg_addlog("sg_update_blacklist: Create DB entries list '$blklist_file'.", 1);
+ sg_addlog("sg_update_blacklist", "Create DB entries list '$blklist_file'.", SQUIDGUARD_INFO);
}
# make rebuild config (included all found dest items) & save to work dir
$conf_path = SQUIDGUARD_VAR . DB_REBUILD_BLK_CONF; # "/tmp/squidGuard_rebuild_blk.conf";
file_put_contents($conf_path, sg_create_simple_config($arc_db_dir, $blk_list));
set_file_access($conf_path, OWNER_NAME, 0755);
- sg_addlog("sg_update_blacklist: Create rebuild config '$conf_path'.", 1);
+ sg_addlog("sg_update_blacklist", "Create rebuild config '$conf_path'.", SQUIDGUARD_INFO);
# *** SH script ***********************************************
$sh_scr = Array();
@@ -1537,7 +1597,7 @@ function sg_update_blacklist($from_file)
# mwexec("kill `ps auxw | grep \"$shfile\" | grep -v \"grep\" | awk '{print $2}'`"); # sh script
mwexec("kill `ps auxw | grep \"squidGuard_blk_rebuild\" | grep -v \"grep\" | awk '{print $2}'`"); # squidGuard process
mwexec_bg("nice -n 5 $shfile");
- sg_addlog("sg_update_blacklist: Started sh script '$shfile'.", 1);
+ sg_addlog("sg_update_blacklist", "Started sh script '$shfile'.", SQUIDGUARD_INFO);
# clearing temp
# mwexec("rm -R $bl_temp");
@@ -1574,7 +1634,7 @@ function sg_blacklist_rebuild_db()
$workdir = $squidguard_config[F_WORKDIR];
# current dbhome and work dir's
- sg_addlog("sg_blacklist_rebuild_db: Start with path '$dbhome'.", 1);
+ sg_addlog("sg_blacklist_rebuild_db", "Start with path '$dbhome'.", SQUIDGUARD_INFO);
# make dest list
$blklist_file = "$workdir/" . SQUIDGUARD_BLK_ENTRIES;
@@ -1597,7 +1657,7 @@ function sg_uploadfile_from_url($url_file, $destination_file, $proxy = '')
{
conf_mount_rw();
# open destination file
- sg_addlog("sg_uploadfile_from_url: begin url'$url_file' proxy'$proxy'", 1);
+ sg_addlog("sg_uploadfile_from_url", "Begin url'$url_file' proxy'$proxy'", SQUIDGUARD_INFO);
$result = '';
$ch = curl_init();
@@ -1622,7 +1682,7 @@ function sg_uploadfile_from_url($url_file, $destination_file, $proxy = '')
curl_close ($ch);
if (!empty($destination_file))
file_put_contents($destination_file, $result);
- else sg_addlog("sg_uploadfile_from_url: Error upload file", 2);
+ else sg_addlog("sg_uploadfile_from_url", "Can't upload file", SQUIDGUARD_ERROR);
# for test
file_put_contents(BLK_LOCALFILE, $result);
@@ -1676,15 +1736,15 @@ function restore_arc_blacklist()
# copy arc blacklist to work DB with permissions
mwexec("cp -R -p $arc_db_dir/ $dbhome");
set_file_access($dbhome, OWNER_NAME, 0755);
- sg_addlog("restore_arc_blacklist: Restore blacklist archive from '$arc_db_dir'.", 1);
+ sg_addlog("restore_arc_blacklist", "Restore blacklist archive from '$arc_db_dir'.", SQUIDGUARD_INFO);
# copy black list file
copy($arc_blklist_file, $blklist_file);
set_file_access($blklist_file, OWNER_NAME, 0755);
- sg_addlog("restore_arc_blacklist: Restore black list file from '$arc_blklist_file' to '$blklist_file'.", 1);
+ sg_addlog("restore_arc_blacklist", "Restore black list file from '$arc_blklist_file' to '$blklist_file'.", SQUIDGUARD_INFO);
conf_mount_ro();
} else {
- sg_addlog("restore_arc_blacklist: Error, file '$arc_db_dir' or '$blklist_file' not found.", 2);
+ sg_addlog("restore_arc_blacklist", "File '$arc_db_dir' or '$blklist_file' not found.", SQUIDGUARD_ERROR);
}
}
@@ -2076,6 +2136,95 @@ function acl_remove_blacklist_items($items)
return $items;
}
+# -----------------------------------------------------------------------------
+# sg_script_logrotate
+# -----------------------------------------------------------------------------
+function sg_script_logrotate()
+{
+ global $squidguard_config;
+ $sglogname = $squidguard_config[F_LOGDIR] . "/" . SQUIDGUARD_LOGFILE;
+ $res =
+<<<EOD
+#!/bin/sh
+#
+# This file generated automaticly with SquidGuard configurator
+rm -f {$sglogname}.0
+mv -f {$sglogname} {$sglogname}.0
+EOD;
+ return $res;
+}
+
+# ------------------------------------------------------------------------------
+# squidguard_setup_cron
+# ------------------------------------------------------------------------------
+function squidguard_cron_install()
+{
+ global $squidguard_config;
+
+ $on_off = $squidguard_config[F_LOGROTATION] == 'on';
+
+ $opt = "";
+ if ($on_off) {
+ $opt = array("0", "0", "*", "*", "*", "root", "/usr/bin/nice -n20 " . SQUIDGUARD_SCR_LOGROTATE);
+ }
+ squidguard_setup_cron("squidGuard_logrotate", $opt, $on_off);
+}
+
+# ------------------------------------------------------------------------------
+# squidguard_setup_cron
+# ------------------------------------------------------------------------------
+# $options: [0]='minute', [1]='hour', [2]='mday', [3]='month', [4]='wday', [5]='who', [6]='command'
+# ------------------------------------------------------------------------------
+function squidguard_setup_cron($task_key, $options, $on_off)
+{
+ global $config;
+ $cron_item = array();
+
+ # $on_off = TRUE/FALSE - install/deinstall cron task:
+ # prepare new cron item
+ if (is_array($options)) {
+ $cron_item['minute'] = $options[0];
+ $cron_item['hour'] = $options[1];
+ $cron_item['mday'] = $options[2];
+ $cron_item['month'] = $options[3];
+ $cron_item['wday'] = $options[4];
+ $cron_item['who'] = ($options[5]) ? $options[5] : 'nobody';
+ $cron_item['command'] = $options[6];
+ }
+
+ # unset old cron task with $task_key
+ if (!empty($task_key)) {
+ $flag_cron_upd = false;
+ # delete old cron task if exists
+ if (is_array($config['cron']['item'])) {
+ foreach($config['cron']['item'] as $key => $val) {
+ if (strpos($config['cron']['item'][$key]['command'], $task_key) !== false) {
+ unset($config['cron']['item'][$key]);
+ $flag_cron_upd = true;
+ break;
+ }
+ }
+ }
+
+ # set new cron task
+ if (($on_off === true) and !empty($cron_item)) {
+ $config['cron']['item'][] = $cron_item;
+ $flag_cron_upd = true;
+ }
+
+ # write config and configure cron only if cron task modified
+ if ($flag_cron_upd === true) {
+ write_config("Installed cron task '$task_key' for 'squidGuard' package");
+ configure_cron();
+ }
+ }
+ else {
+ # ! error $name !
+ return;
+ }
+}
+
+
# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
# classes
# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
diff --git a/config/squidGuard/squidguard_default.xml b/config/squidGuard/squidguard_default.xml
index 6c9c4c95..bcb6d41b 100644
--- a/config/squidGuard/squidguard_default.xml
+++ b/config/squidGuard/squidguard_default.xml
@@ -2,48 +2,45 @@
<!DOCTYPE packagegui SYSTEM "../schema/packages.dtd">
<?xml-stylesheet type="text/xsl" href="../xsl/package.xsl"?>
<packagegui>
- <description>Describe your package here</description>
- <requirements>Describe your package requirements here</requirements>
- <faq>Currently there are no FAQ items provided.</faq>
-
- <name>squidguarddefault</name>
- <version>none</version>
- <title>Proxy filter SquidGuard: Default</title>
- <include_file>/usr/local/pkg/squidguard.inc</include_file>
-
- <tabs>
- <tab>
- <text>General settings</text>
- <url>/pkg_edit.php?xml=squidguard.xml&amp;id=0</url>
- </tab>
- <tab>
- <text>Default</text>
- <url>/pkg_edit.php?xml=squidguard_default.xml&amp;id=0</url>
- <active/>
- </tab>
- <tab>
- <text>ACL</text>
- <url>/pkg.php?xml=squidguard_acl.xml</url>
- </tab>
- <tab>
- <text>Destinations</text>
- <url>/pkg.php?xml=squidguard_dest.xml</url>
- </tab>
- <tab>
- <text>Times</text>
- <url>/pkg.php?xml=squidguard_time.xml</url>
- </tab>
- <tab>
- <text>Rewrites</text>
- <url>/pkg.php?xml=squidguard_rewr.xml</url>
- </tab>
- <tab>
- <text>Log</text>
- <url>/pkg_edit.php?xml=squidguard_log.xml&amp;id=0</url>
- </tab>
- </tabs>
-
- <fields>
+ <description>Describe your package here</description>
+ <requirements>Describe your package requirements here</requirements>
+ <faq>Currently there are no FAQ items provided.</faq>
+ <name>squidguarddefault</name>
+ <version>none</version>
+ <title>Proxy filter SquidGuard: Default</title>
+ <include_file>/usr/local/pkg/squidguard.inc</include_file>
+ <tabs>
+ <tab>
+ <text>General settings</text>
+ <url>/pkg_edit.php?xml=squidguard.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>Default</text>
+ <url>/pkg_edit.php?xml=squidguard_default.xml&amp;id=0</url>
+ <active/>
+ </tab>
+ <tab>
+ <text>ACL</text>
+ <url>/pkg.php?xml=squidguard_acl.xml</url>
+ </tab>
+ <tab>
+ <text>Destinations</text>
+ <url>/pkg.php?xml=squidguard_dest.xml</url>
+ </tab>
+ <tab>
+ <text>Times</text>
+ <url>/pkg.php?xml=squidguard_time.xml</url>
+ </tab>
+ <tab>
+ <text>Rewrites</text>
+ <url>/pkg.php?xml=squidguard_rewr.xml</url>
+ </tab>
+ <tab>
+ <text>Log</text>
+ <url>/squidGuard/squidguard_log.php</url>
+ </tab>
+ </tabs>
+ <fields>
<field>
<fielddescr>Default destination</fielddescr>
<fieldname>dest</fieldname>
@@ -120,24 +117,23 @@
<type>select</type>
</field>
<field>
- <fielddescr>Enable log</fielddescr>
+ <fielddescr>Log</fielddescr>
<fieldname>enablelog</fieldname>
- <description>Check this for enable log.</description>
+ <description>Check this for log this item.</description>
<type>checkbox</type>
</field>
- </fields>
-
- <custom_php_validation_command>
+ </fields>
+ <custom_php_validation_command>
squidguard_validate_acl(&amp;$_POST, &amp;$input_errors);
- </custom_php_validation_command>
- <custom_php_command_before_form>
+ </custom_php_validation_command>
+ <custom_php_command_before_form>
squidguard_before_form_acl(&amp;$pkg, false);
- </custom_php_command_before_form>
- <custom_php_after_form_command>
- squidGuard_print_javascript();
- </custom_php_after_form_command>
- <custom_add_php_command/>
- <custom_php_resync_config_command>
+ </custom_php_command_before_form>
+ <custom_php_after_form_command>
+ squidGuard_print_javascript();
+ </custom_php_after_form_command>
+ <custom_add_php_command/>
+ <custom_php_resync_config_command>
// squidguard_resync();
- </custom_php_resync_config_command>
+ </custom_php_resync_config_command>
</packagegui> \ No newline at end of file
diff --git a/config/squidGuard/squidguard_dest.xml b/config/squidGuard/squidguard_dest.xml
index 97f87167..bf252661 100644
--- a/config/squidGuard/squidguard_dest.xml
+++ b/config/squidGuard/squidguard_dest.xml
@@ -2,51 +2,47 @@
<!DOCTYPE packagegui SYSTEM "../schema/packages.dtd">
<?xml-stylesheet type="text/xsl" href="../xsl/package.xsl"?>
<packagegui>
- <description>Describe your package here</description>
- <requirements>Describe your package requirements here</requirements>
- <faq>Currently there are no FAQ items provided.</faq>
-
- <name>squidguarddest</name>
- <version>none</version>
- <title>Proxy filter SquidGuard: Destinations</title>
- <include_file>/usr/local/pkg/squidguard.inc</include_file>
-
- <delete_string>A proxy server user has been deleted.</delete_string>
- <addedit_string>A proxy server user has been created/modified.</addedit_string>
-
- <tabs>
- <tab>
- <text>General settings</text>
- <url>/pkg_edit.php?xml=squidguard.xml&amp;id=0</url>
- </tab>
- <tab>
- <text>Default</text>
- <url>/pkg_edit.php?xml=squidguard_default.xml&amp;id=0</url>
- </tab>
- <tab>
- <text>ACL</text>
- <url>/pkg.php?xml=squidguard_acl.xml</url>
- </tab>
- <tab>
- <text>Destinations</text>
- <url>/pkg.php?xml=squidguard_dest.xml</url>
- <active/>
- </tab>
- <tab>
- <text>Times</text>
- <url>/pkg.php?xml=squidguard_time.xml</url>
- </tab>
- <tab>
- <text>Rewrites</text>
- <url>/pkg.php?xml=squidguard_rewr.xml</url>
- </tab>
- <tab>
- <text>Log</text>
- <url>/pkg_edit.php?xml=squidguard_log.xml&amp;id=0</url>
- </tab>
- </tabs>
-
- <adddeleteeditpagefields>
+ <description>Describe your package here</description>
+ <requirements>Describe your package requirements here</requirements>
+ <faq>Currently there are no FAQ items provided.</faq>
+ <name>squidguarddest</name>
+ <version>none</version>
+ <title>Proxy filter SquidGuard: Destinations</title>
+ <include_file>/usr/local/pkg/squidguard.inc</include_file>
+ <delete_string>A proxy server user has been deleted.</delete_string>
+ <addedit_string>A proxy server user has been created/modified.</addedit_string>
+ <tabs>
+ <tab>
+ <text>General settings</text>
+ <url>/pkg_edit.php?xml=squidguard.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>Default</text>
+ <url>/pkg_edit.php?xml=squidguard_default.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>ACL</text>
+ <url>/pkg.php?xml=squidguard_acl.xml</url>
+ </tab>
+ <tab>
+ <text>Destinations</text>
+ <url>/pkg.php?xml=squidguard_dest.xml</url>
+ <active/>
+ </tab>
+ <tab>
+ <text>Times</text>
+ <url>/pkg.php?xml=squidguard_time.xml</url>
+ </tab>
+ <tab>
+ <text>Rewrites</text>
+ <url>/pkg.php?xml=squidguard_rewr.xml</url>
+ </tab>
+ <tab>
+ <text>Log</text>
+ <url>/squidGuard/squidguard_log.php</url>
+ </tab>
+ </tabs>
+ <adddeleteeditpagefields>
<columnitem>
<fielddescr>Destination name</fielddescr>
<fieldname>name</fieldname>
@@ -71,9 +67,8 @@
<fielddescr>Description</fielddescr>
<fieldname>description</fieldname>
</columnitem>
- </adddeleteeditpagefields>
-
- <fields>
+ </adddeleteeditpagefields>
+ <fields>
<field>
<fielddescr>Name</fielddescr>
<fieldname>name</fieldname>
@@ -164,10 +159,10 @@
<rows>2</rows>
</field>
<field>
- <fielddescr>Enable log</fielddescr>
+ <fielddescr>Log</fielddescr>
<fieldname>enablelog</fieldname>
<type>checkbox</type>
- <description>Check this for enable log.</description>
+ <description>Check this for log this item.</description>
</field>
<field>
<fielddescr>Description</fielddescr>
@@ -176,15 +171,14 @@
<type>input</type>
<size>90</size>
</field>
- </fields>
-
- <custom_delete_php_command/>
- <custom_php_validation_command>
+ </fields>
+ <custom_delete_php_command/>
+ <custom_php_validation_command>
squidguard_validate_destination($_POST, &amp;$input_errors);
- </custom_php_validation_command>
- <custom_php_resync_config_command>
- </custom_php_resync_config_command>
- <custom_php_after_form_command>
+ </custom_php_validation_command>
+ <custom_php_resync_config_command>
+ </custom_php_resync_config_command>
+ <custom_php_after_form_command>
squidGuard_print_javascript();
- </custom_php_after_form_command>
+ </custom_php_after_form_command>
</packagegui> \ No newline at end of file
diff --git a/config/squidGuard/squidguard_log.xml b/config/squidGuard/squidguard_log.xml
index ed3c7a9d..654c0917 100644
--- a/config/squidGuard/squidguard_log.xml
+++ b/config/squidGuard/squidguard_log.xml
@@ -5,15 +5,12 @@
<description>Describe your package here</description>
<requirements>Describe your package requirements here</requirements>
<faq>Currently there are no FAQ items provided.</faq>
-
<name>squidguardlog</name>
<version>none</version>
<title>Proxy filter SquidGuard: Log</title>
<include_file>/usr/local/pkg/squidguard.inc</include_file>
-
<delete_string>A proxy server user has been deleted.</delete_string>
<addedit_string>A proxy server user has been created/modified.</addedit_string>
-
<tabs>
<tab>
<text>General settings</text>
@@ -41,17 +38,17 @@
</tab>
<tab>
<text>Log</text>
- <url>/pkg_edit.php?xml=squidguard_log.xml&amp;id=0</url>
+ <url>/squidGuard/squidguard_log.php</url>
<active/>
</tab>
</tabs>
-
+<advanced_options>enabled</advanced_options>
<fields>
<field>
<fielddescr>Log type</fielddescr>
<fieldname>logtype</fieldname>
<description></description>
- <type>select</type>
+ <type>input</type>
<value>access_log</value>
<options>
<option><name>Blocked URL's log</name><value>block_log</value></option>
@@ -61,8 +58,67 @@
<option><name>squidGuard config</name><value>squidguard_config</value></option>
</options>
</field>
+ <field>
+ <fielddescr>Log type</fielddescr>
+ <fieldname>logtype</fieldname>
+ <description></description>
+ <type>listtopic</type>
+<name>Ext</name>
+ <value>access_log</value>
+ <options>
+ <option><name>Blocked URL's log</name><value>block_log</value></option>
+ <option><name>Configurator log</name><value>configurator_log</value></option>
+ <option><name>squidGuard log</name><value>squidguard_log</value></option>
+ <option><name>squid config</name><value>squid_config</value></option>
+ <option><name>squidGuard config</name><value>squidguard_config</value></option>
+ </options>
+ </field>
+ <field>
+ <fielddescr>Log type</fielddescr>
+ <fieldname>logtype</fieldname>
+ <description></description>
+ <type>input</type>
+ <value>access_log</value>
+ <options>
+ <option><name>Blocked URL's log</name><value>block_log</value></option>
+ <option><name>Configurator log</name><value>configurator_log</value></option>
+ <option><name>squidGuard log</name><value>squidguard_log</value></option>
+ <option><name>squid config</name><value>squid_config</value></option>
+ <option><name>squidGuard config</name><value>squidguard_config</value></option>
+ </options>
+<advancedfield/>
+ </field>
+ <field>
+ <fielddescr>Log type</fielddescr>
+ <fieldname>logtype2</fieldname>
+ <description></description>
+ <type>input</type>
+ <value>access_log</value>
+ <options>
+ <option><name>Blocked URL's log</name><value>block_log</value></option>
+ <option><name>Configurator log</name><value>configurator_log</value></option>
+ <option><name>squidGuard log</name><value>squidguard_log</value></option>
+ <option><name>squid config</name><value>squid_config</value></option>
+ <option><name>squidGuard config</name><value>squidguard_config</value></option>
+ </options>
+<advancedfield/>
+ </field>
+ <field>
+ <fielddescr>Log type</fielddescr>
+ <fieldname>logtype1</fieldname>
+ <description></description>
+ <type>input</type>
+ <value>access_log</value>
+ <options>
+ <option><name>Blocked URL's log</name><value>block_log</value></option>
+ <option><name>Configurator log</name><value>configurator_log</value></option>
+ <option><name>squidGuard log</name><value>squidguard_log</value></option>
+ <option><name>squid config</name><value>squid_config</value></option>
+ <option><name>squidGuard config</name><value>squidguard_config</value></option>
+ </options>
+<advancedfield/>
+ </field>
</fields>
-
<custom_php_command_before_form>
squidguard_before_form_log(&amp;$pkg);
</custom_php_command_before_form>
@@ -73,4 +129,4 @@
</custom_php_validation_command>
<custom_php_resync_config_command>
</custom_php_resync_config_command>
-</packagegui>
+</packagegui> \ No newline at end of file
diff --git a/config/squidGuard/squidguard_rewr.xml b/config/squidGuard/squidguard_rewr.xml
index f92a855b..4a2a71f3 100644
--- a/config/squidGuard/squidguard_rewr.xml
+++ b/config/squidGuard/squidguard_rewr.xml
@@ -5,12 +5,10 @@
<description>Describe your package here</description>
<requirements>Describe your package requirements here</requirements>
<faq>Currently there are no FAQ items provided.</faq>
-
<name>squidguardrewrite</name>
<version>none</version>
<title>Proxy filter SquidGuard: Rewrites</title>
<include_file>/usr/local/pkg/squidguard.inc</include_file>
-
<tabs>
<tab>
<text>General settings</text>
@@ -39,10 +37,9 @@
</tab>
<tab>
<text>Log</text>
- <url>/pkg_edit.php?xml=squidguard_log.xml&amp;id=0</url>
+ <url>/squidGuard/squidguard_log.php</url>
</tab>
</tabs>
-
<adddeleteeditpagefields>
<columnitem>
<fielddescr>Name</fielddescr>
@@ -53,7 +50,6 @@
<fieldname>description</fieldname>
</columnitem>
</adddeleteeditpagefields>
-
<fields>
<field>
<fielddescr>Name</fielddescr>
@@ -77,13 +73,13 @@
<fielddescr>Target URL or regular expression</fielddescr>
<fieldname>targeturl</fieldname>
<type>input</type>
- <size>45</size>
+ <size>35</size>
</rowhelperfield>
<rowhelperfield>
<fielddescr>Replace to URL</fielddescr>
<fieldname>replaceto</fieldname>
<type>input</type>
- <size>45</size>
+ <size>35</size>
</rowhelperfield>
<rowhelperfield>
<fielddescr>Opt.</fielddescr>
@@ -111,9 +107,9 @@
</rowhelper>
</field>
<field>
- <fielddescr>Enable log</fielddescr>
+ <fielddescr>Log</fielddescr>
<fieldname>enablelog</fieldname>
- <description>Check this for enable log.</description>
+ <description>Check this for log this item.</description>
<type>checkbox</type>
</field>
<field>
@@ -129,7 +125,6 @@
<size>100</size>
</field>
</fields>
-
<custom_php_after_form_command>
squidGuard_print_javascript();
</custom_php_after_form_command>
@@ -139,4 +134,4 @@
<custom_php_resync_config_command>
// squidguard_resync_rewrite();
</custom_php_resync_config_command>
-</packagegui>
+</packagegui> \ No newline at end of file
diff --git a/config/squidGuard/squidguard_time.xml b/config/squidGuard/squidguard_time.xml
index f4d7ee06..83347fad 100644
--- a/config/squidGuard/squidguard_time.xml
+++ b/config/squidGuard/squidguard_time.xml
@@ -5,15 +5,12 @@
<description>Describe your package here</description>
<requirements>Describe your package requirements here</requirements>
<faq>Currently there are no FAQ items provided.</faq>
-
<name>squidguardtime</name>
<version>none</version>
<title>Proxy filter SquidGuard: Times</title>
<include_file>/usr/local/pkg/squidguard.inc</include_file>
-
<delete_string>A proxy server user has been deleted.</delete_string>
<addedit_string>A proxy server user has been created/modified.</addedit_string>
-
<tabs>
<tab>
<text>General settings</text>
@@ -42,10 +39,9 @@
</tab>
<tab>
<text>Log</text>
- <url>/pkg_edit.php?xml=squidguard_log.xml&amp;id=0</url>
+ <url>/squidGuard/squidguard_log.php</url>
</tab>
</tabs>
-
<adddeleteeditpagefields>
<columnitem>
<fielddescr>Timename</fielddescr>
@@ -130,7 +126,6 @@
<size>80</size>
</field>
</fields>
-
<custom_php_after_form_command>
squidGuard_print_javascript();
</custom_php_after_form_command>
@@ -140,4 +135,4 @@
<custom_php_resync_config_command>
// squidguard_resync_time();
</custom_php_resync_config_command>
-</packagegui>
+</packagegui> \ No newline at end of file