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_configurator.inc | 170 +++++++++++++------------- 1 file changed, 88 insertions(+), 82 deletions(-) (limited to 'config/squidGuard/squidguard_configurator.inc') diff --git a/config/squidGuard/squidguard_configurator.inc b/config/squidGuard/squidguard_configurator.inc index 035ab734..5c90d307 100644 --- a/config/squidGuard/squidguard_configurator.inc +++ b/config/squidGuard/squidguard_configurator.inc @@ -1,7 +1,7 @@ $in) @@ -340,7 +338,7 @@ function sg_save_configxml($filename) function sg_reconfigure() { global $squidguard_config; - $conf_file = SQUIDGUARD_LOGDIR_DEF . SQUIDGUARD_CONFIGFILE; + $conf_file = SQUIDGUARD_LOGDIR . SQUIDGUARD_CONFIGFILE; # 1. check system sg_check_system(); @@ -680,7 +678,7 @@ function sg_addlog($module, $log, $level = 0) } $logfile = ''; - $logfile = SQUIDGUARD_LOGDIR_DEF . SQUIDGUARD_CONFLOGFILE; + $logfile = SQUIDGUARD_LOGDIR . SQUIDGUARD_CONFLOGFILE; $log_content = array(); setlocale(LC_TIME, ''); @@ -713,7 +711,7 @@ function sg_getlog($last_entries_count) { global $squidguard_config; $log_content = ''; - $logfile = SQUIDGUARD_LOGDIR_DEF . SQUIDGUARD_CONFLOGFILE; + $logfile = SQUIDGUARD_LOGDIR . SQUIDGUARD_CONFLOGFILE; # define logfile if (!empty($squidguard_config) && file_exists($squidguard_config[F_LOGDIR])) @@ -920,7 +918,7 @@ function sg_create_config() $sg_tag->items[] = "s@{$rw[F_TARGETURL]}@{$rw[F_REPLACETO]}@{$rw[F_MODE]}"; if ($squidguard_config[F_ENABLELOG] == 'on' ) { - if ($rew[F_LOG]) + if ($rew[F_LOG]) $sg_tag->items[] = "log " . SQUIDGUARD_LOGFILE; } @@ -1485,8 +1483,8 @@ function sg_update_blacklist($from_file) { global $squidguard_config; conf_mount_rw(); - $dbhome = SQUIDGUARD_DBHOME_DEF; - $workdir = SQUIDGUARD_WORKDIR_DEF; + $dbhome = SQUIDGUARD_DBHOME; + $workdir = SQUIDGUARD_WORKDIR; $tmp_unpack_dir = SQUIDGUARD_TMP . SQUIDGUARD_BL_UNPACK; $arc_db_dir = SQUIDGUARD_VAR . SG_BLK_ARC; @@ -1571,7 +1569,7 @@ function sg_update_blacklist($from_file) # copy temp db to '/var/db/squidGuard (-R - recursive; -p - copy access rights) # '$bl_temp_dbhome/' - slash in end of path - copy only dir content (not self dir) $sh_scr[] = "cp -R -p $arc_db_dir/ $dbhome"; - $sh_scr[] = "cp -f -p $blklist_file " . SQUIDGUARD_WORKDIR_DEF; + $sh_scr[] = "cp -f -p $blklist_file " . SQUIDGUARD_WORKDIR; # set DB owner and right access $sh_scr[] = "chown -R -v " . OWNER_NAME . " $dbhome"; $sh_scr[] = "chmod -R -v 0755 $dbhome"; @@ -1615,7 +1613,7 @@ function sg_entries_blacklist() global $squidguard_config; $contents = ''; - $fl = SQUIDGUARD_WORKDIR_DEF . SQUIDGUARD_BLK_ENTRIES; + $fl = SQUIDGUARD_WORKDIR . SQUIDGUARD_BLK_ENTRIES; if (file_exists($squidguard_config[F_WORKDIR])) $fl = $squidguard_config[F_WORKDIR] . SQUIDGUARD_BLK_ENTRIES; if (file_exists($fl)) @@ -1726,23 +1724,31 @@ function scan_dir($dir) function restore_arc_blacklist() { global $squidguard_config; - $dbhome = SQUIDGUARD_DBHOME_DEF; - $blklist_file = SQUIDGUARD_WORKDIR_DEF . SQUIDGUARD_BLK_ENTRIES; - $arc_db_dir = SQUIDGUARD_VAR . SG_BLK_ARC; + $dbhome = SQUIDGUARD_DBHOME; + $blklist_file = SQUIDGUARD_WORKDIR . SQUIDGUARD_BLK_ENTRIES; + $arc_db_dir = SQUIDGUARD_DBSAMPLE; $arc_blklist_file = SQUIDGUARD_VAR . SQUIDGUARD_BLK_ENTRIES; if (file_exists($arc_db_dir) and file_exists($arc_blklist_file)) { - conf_mount_rw(); +# conf_mount_rw(); # 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'.", SQUIDGUARD_INFO); - # copy black list file - copy($arc_blklist_file, $blklist_file); + $blklist = ""; + $files = scan_dir("$arc_db_dir/"); + foreach ($files as $fl) { + $blklist .= $fl . "\n"; + } + file_put_contents($blklist_file, $blklist); set_file_access($blklist_file, OWNER_NAME, 0755); - sg_addlog("restore_arc_blacklist", "Restore black list file from '$arc_blklist_file' to '$blklist_file'.", SQUIDGUARD_INFO); - conf_mount_ro(); + + # 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'.", SQUIDGUARD_INFO); +# conf_mount_ro(); } else { sg_addlog("restore_arc_blacklist", "File '$arc_db_dir' or '$blklist_file' not found.", SQUIDGUARD_ERROR); } @@ -2143,7 +2149,7 @@ function sg_script_logrotate() { global $squidguard_config; $sglogname = $squidguard_config[F_LOGDIR] . "/" . SQUIDGUARD_LOGFILE; - $res = + $res = <<