diff options
author | Ermal Luçi <ermal.luci@gmail.com> | 2013-01-21 02:50:56 -0800 |
---|---|---|
committer | Ermal Luçi <ermal.luci@gmail.com> | 2013-01-21 02:50:56 -0800 |
commit | ccad75f5ffdd83bc1cc90b9d4fe027bc52900480 (patch) | |
tree | 96fa01e242e24dc3217eac742f7a1478cdf58a62 | |
parent | 29206bf8a5dbbfa5c2fae939cddd9eb6580b67eb (diff) | |
parent | 7953f4305d0d5e843dc75371f48fc62c6a636d51 (diff) | |
download | pfsense-packages-ccad75f5ffdd83bc1cc90b9d4fe027bc52900480.tar.gz pfsense-packages-ccad75f5ffdd83bc1cc90b9d4fe027bc52900480.tar.bz2 pfsense-packages-ccad75f5ffdd83bc1cc90b9d4fe027bc52900480.zip |
Merge pull request #332 from rjcrowder/master
Fix to not remove blacklists if the fetch fails
-rw-r--r-- | config/dansguardian/dansguardian.php | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/config/dansguardian/dansguardian.php b/config/dansguardian/dansguardian.php index 8571e1b7..675db6c7 100644 --- a/config/dansguardian/dansguardian.php +++ b/config/dansguardian/dansguardian.php @@ -39,28 +39,34 @@ require_once("/etc/inc/pkg-utils.inc"); require_once("/etc/inc/globals.inc"); require_once("/usr/local/pkg/dansguardian.inc"); -function fetch_blacklist(){ +function fetch_blacklist() { global $config,$g; $url=$config['installedpackages']['dansguardianblacklist']['config'][0]['url']; - if (is_url($url)){ + if (is_url($url)) { conf_mount_rw(); print "file download start.."; unlink_if_exists("/usr/local/etc/dansguardian/lists/blacklist.tgz"); - exec("/usr/bin/fetch -o /usr/local/etc/dansguardian/lists/blacklist.tgz ".escapeshellarg($url)); - chdir ("/usr/local/etc/dansguardian/lists"); - if (is_dir ("blacklists.old")) - exec ('rm -rf /usr/local/etc/dansguardian/lists/blacklists.old'); - rename("blacklists","blacklists.old"); - exec('/usr/bin/tar -xvzf /usr/local/etc/dansguardian/lists/blacklist.tgz 2>&1',$output,$return); - if (preg_match("/x\W+(\w+)/",$output[0],$matches)){ - if ($matches[1] != "blacklists") - rename("./".$matches[1],"blacklists"); - read_lists(); + exec("/usr/bin/fetch -o /usr/local/etc/dansguardian/lists/blacklist.tgz ".escapeshellarg($url),$output,$return); + if ($return == 0) { + chdir ("/usr/local/etc/dansguardian/lists"); + if (is_dir ("blacklists.old")) + exec ('rm -rf /usr/local/etc/dansguardian/lists/blacklists.old'); + rename("blacklists","blacklists.old"); + exec('/usr/bin/tar -xvzf /usr/local/etc/dansguardian/lists/blacklist.tgz 2>&1',$output,$return); + if (preg_match("/x\W+(\w+)/",$output[0],$matches)) { + if ($matches[1] != "blacklists") + rename("./".$matches[1],"blacklists"); + read_lists(); } - else - file_notice("Dansguardian - Could not determine Blacklist extract dir. Categories not updated",""); - } - else{ + else { + file_notice("Dansguardian - Could not determine Blacklist extract dir. Categories not updated",""); + } + } + else { + file_notice("Dansguardian - Could not fetch blacklists from url",""); + } + } + else { file_notice("Dansguardian - Blacklist url is invalid.",""); } } |