From 4fc28f4f28f865773def1cebb722e6fa952a00a4 Mon Sep 17 00:00:00 2001 From: dvserg Date: Mon, 3 Jan 2011 00:39:03 +0300 Subject: squidGuard change blacklist --- config/squidGuard/squidguard.inc | 162 ++++++++++++++++++--------------------- 1 file changed, 75 insertions(+), 87 deletions(-) (limited to 'config/squidGuard/squidguard.inc') diff --git a/config/squidGuard/squidguard.inc b/config/squidGuard/squidguard.inc index 12e52e35..5d78b0da 100644 --- a/config/squidGuard/squidguard.inc +++ b/config/squidGuard/squidguard.inc @@ -1,7 +1,7 @@ $dst[F_NAME], 'upt_value'=>$acls_up[$dst[F_NAME]], 'ovt_value'=>$acls_over[$dst[F_NAME]], 'description'=>$dst[F_DESCRIPTION]); + } } # Blacklist if ($squidguard_config[F_BLACKLISTENABLED] === 'on') { $blk_entries = sg_entries_blacklist(); if (!empty($blk_entries)) { - foreach($blk_entries as $dst) + foreach($blk_entries as $dst) { $dest_items[] = array ('name'=>$dst, 'upt_value'=>$acls_up[$dst], 'ovt_value'=>$acls_over[$dst], 'description'=>''); + } } } @@ -601,16 +590,6 @@ function squidguard_before_form_acl($pkg, $is_acl=true) { } } -# ----------------------------------------------------------------------------- -# squidguard_before_form_log - must be deleted -# ----------------------------------------------------------------------------- -define('LOGSHOW_BUFSIZE', 16384); - -function squidguard_before_form_log($pkg) -{ -# delete me -} - # ----------------------------------------------------------------------------- # make_grid_general_items # ----------------------------------------------------------------------------- @@ -649,7 +628,7 @@ function make_grid_blacklist() { $res = ''; # button 'Upload URL' and button 'Restore last blacklist' $res = "
"; - $res .= " "; + $res .= " "; return $res; } @@ -677,11 +656,13 @@ function make_grid_controls($type, $items, $enable_overtime = true) { $x = 0; } - $name = $item['name']; + $name = trim($item['name']); $upt_val = $item['upt_value']; $ovt_val = $item['ovt_value']; $description = $item['description']; + if (!$name) continue; # skip empty + $sel = "selected=\"selected\""; $upt_A = $upt_B = $upt_C = $upt_D = ''; switch($upt_val) { @@ -707,7 +688,7 @@ function make_grid_controls($type, $items, $enable_overtime = true) { $tbl .= "$description [$name]"; $tbl .= "access"; $tbl .= ""; - if (substr_count($name, "all") === 0) { + if ($name !== "all"/*substr_count($name, "all") === 0*/) { $tbl .= ""; - $tbl .= ""; + $tbl .= ""; $tbl .= ""; $tbl .= ""; } @@ -745,13 +726,13 @@ function make_grid_controls($type, $items, $enable_overtime = true) { if (!empty($tbl)) { $color = 'style="background-color: #dddddd;"'; $thdr = ''; - $hdr1up = "Destination rules"; - $hdr1ov = "Destination rules in overtime"; + $hdr1up = "Destination Categories"; + $hdr1ov = "Destination Categories in overtime"; $hds3 = "ACCESS: 'whitelist' - always pass; 'deny' - block; 'allow' - pass, if not blocked."; if ($enable_overtime) { $thdr .= "$hds3"; $thdr .= "$hdr1up$hdr1ov"; - $thdr .= "If 'Time' not defined, this ruleset will be ignored"; + $thdr .= "If 'Time' not defined, this is column will be ignored."; # formatting $thdr .= ""; } @@ -765,9 +746,9 @@ function make_grid_controls($type, $items, $enable_overtime = true) { $res .= " $thdr $tbl
"; $rstyle = ""; - $ha = "
" . + $ha = "
" . "" . - "Destination ruleset (click) " . + "Destination Categories (click) " . " " . "" . "" . @@ -811,7 +792,7 @@ function sg_check_unique_name($module_id, $name, $log='') { 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"); + $reserved = array("acl", "all", "allow", "dbhome", "default", "dest", "in-addr", "log", "logdir", "none", "pass", "rew", "src", "url", "user"); if (in_array(strtolower(trim($name)), $reserved)) { $res = false; @@ -829,13 +810,18 @@ function squidguard_install_command() { sg_check_system(); # generate squidGuard blacklist entries file (check with squidGuard PORT) - conf_mount_rw(); - $entries = array("ads", "aggressive", "audio-video", "drugs", "gambling", "hacking", - "mail", "porn", "proxy", "violence", "warez"); - file_put_contents(SQUIDGUARD_WORKDIR . SQUIDGUARD_BLK_ENTRIES, implode("\n", $entries)); +# conf_mount_rw(); + $blklist_file = SQUIDGUARD_WORKDIR . SQUIDGUARD_BLK_ENTRIES; + + # рассмотреть вариант слияния examples базы и существующей в системе + if (!file_exists($blklist_file)) { + # if blacklist not exists, then copy default db from samples +# $entries = array("ads", "aggressive", "audio-video", "drugs", "gambling", "hacking", "mail", "porn", "proxy", "violence", "warez"); +# file_put_contents($blklist_file, implode("\n", $entries)); + } set_file_access(SQUIDGUARD_WORKDIR, OWNER_NAME, 0755); set_file_access(SQUIDGUARD_DBHOME, OWNER_NAME, 0755); - conf_mount_ro(); +# conf_mount_ro(); sg_reconfigure(); } @@ -845,12 +831,14 @@ function squidguard_deinstall_command() { # remove entries from squid config squid_reconfigure('remove redirector options'); + # Note: When you reinstall should remain Database + # remove package and his depends - mwexec("pkg_delete squidGuard-1.2.0_1"); - mwexec("rm -rf " . SQUIDGUARD_WORKDIR); + #mwexec("pkg_delete squidGuard-1.2.0_1"); + #mwexec("rm -rf " . SQUIDGUARD_WORKDIR); # i known't, really need delete blacklist base? - mwexec("rm -rf " . SQUIDGUARD_DBHOME); - mwexec("/bin/rm -f " . SQUIDGUARD_CONFBASE . "/squidGuard*"); + #mwexec("rm -rf " . SQUIDGUARD_DBHOME); + #mwexec("/bin/rm -f " . SQUIDGUARD_CONFBASE . "/squidGuard*"); } # ------------------------------------------------------------------------------ @@ -1281,13 +1269,13 @@ function squidguard_squid_conflist( ) # get squidguard config list function squidguard_conflist( ) { - $fname = SQUIDGUARD_CONFBASE_DEF . SQUIDGUARD_CONFIGFILE; + $fname = SQUIDGUARD_CONFBASE . SQUIDGUARD_CONFIGFILE; $res = ""; if (file_exists( $fname )) $res = file_get_contents( $fname ); else $res = "File '$fname' not found."; - + return $res; } -- cgit v1.2.3