aboutsummaryrefslogtreecommitdiffstats
path: root/config/dansguardian/dansguardian.php
diff options
context:
space:
mode:
authorMarcello Coutinho <marcellocoutinho@gmail.com>2013-01-29 15:58:04 -0200
committermarcelloc <marcellocoutinho@gmail.com>2013-01-29 15:58:04 -0200
commit5d3183341f3289c5a7d70a1f584e5e6b5364736b (patch)
tree4609bfe8b4765ec379dbd1d29ff22f2baada7525 /config/dansguardian/dansguardian.php
parent6eb7ddf66bf8f40a8981a25353bc8a99558eefcd (diff)
downloadpfsense-packages-5d3183341f3289c5a7d70a1f584e5e6b5364736b.tar.gz
pfsense-packages-5d3183341f3289c5a7d70a1f584e5e6b5364736b.tar.bz2
pfsense-packages-5d3183341f3289c5a7d70a1f584e5e6b5364736b.zip
dansguardian - package version 0.1.7. Gui improvements, 2.1 support, pcre fix ,dansguardian 2.12.0.3 and more
Diffstat (limited to 'config/dansguardian/dansguardian.php')
-rw-r--r--config/dansguardian/dansguardian.php49
1 files changed, 33 insertions, 16 deletions
diff --git a/config/dansguardian/dansguardian.php b/config/dansguardian/dansguardian.php
index 675db6c7..d4dcf46c 100644
--- a/config/dansguardian/dansguardian.php
+++ b/config/dansguardian/dansguardian.php
@@ -4,7 +4,7 @@
/*
dansguardian.php
part of pfSense (http://www.pfSense.com)
- Copyright (C) 2012 Marcello Coutinho
+ Copyright (C) 2012-2013 Marcello Coutinho
All rights reserved.
*/
@@ -13,7 +13,7 @@
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright notice,
+ 1. Redistributions of source code MUST retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
@@ -38,25 +38,40 @@ require_once("/etc/inc/functions.inc");
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($log_notice=true) {
global $config,$g;
$url=$config['installedpackages']['dansguardianblacklist']['config'][0]['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),$output,$return);
+ if ($log_notice==true){
+ print "file download start..";
+ unlink_if_exists("/usr/local/pkg/blacklist.tgz");
+ exec("/usr/bin/fetch -o /usr/local/pkg/blacklist.tgz ".escapeshellarg($url),$output,$return);
+ }
+ else{
+ #install process
+ if (file_exists("/usr/local/pkg/blacklist.tgz")){
+ update_output_window("Found previous blacklist database, skipping download...");
+ $return=0;
+ }
+ else{
+ update_output_window("Fetching blacklist");
+ download_file_with_progress_bar($url, "/usr/local/pkg/blacklist.tgz");
+ if (file_exists("/usr/local/pkg/blacklist.tgz"))
+ $return=0;
+ }
+ }
if ($return == 0) {
- chdir ("/usr/local/etc/dansguardian/lists");
+ chdir (DANSGUARDIAN_DIR . "/etc/dansguardian/lists");
if (is_dir ("blacklists.old"))
- exec ('rm -rf /usr/local/etc/dansguardian/lists/blacklists.old');
+ exec ('rm -rf '.DANSGUARDIAN_DIR . '/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)) {
+ exec('/usr/bin/tar -xvzf /usr/local/pkg/blacklist.tgz 2>&1',$output,$return);
+ if (preg_match("/x\W+(\w+)/",$output[1],$matches)) {
if ($matches[1] != "blacklists")
rename("./".$matches[1],"blacklists");
- read_lists();
+ read_lists($log_notice);
}
else {
file_notice("Dansguardian - Could not determine Blacklist extract dir. Categories not updated","");
@@ -67,13 +82,14 @@ function fetch_blacklist() {
}
}
else {
- file_notice("Dansguardian - Blacklist url is invalid.","");
+ if (!empty($url))
+ file_notice("Dansguardian - Blacklist url is invalid.","");
}
}
-function read_lists(){
+function read_lists($log_notice=true){
global $config,$g;
$group_type=array();
- $dir="/usr/local/etc/dansguardian/lists";
+ $dir=DANSGUARDIAN_DIR . "/etc/dansguardian/lists";
#read dansguardian lists dirs
$groups= array("phraselists", "blacklists", "whitelists");
#assigns know list files
@@ -136,7 +152,8 @@ function read_lists(){
$edit_file=preg_replace('/size.19/','size>5',$edit_file);
file_put_contents("/usr/local/pkg/dansguardian_".$edit_xml."_acl.xml",$edit_file,LOCK_EX);
}
- file_notice("Dansguardian - Blacklist applied, check site and URL access lists for categories","");
+ if($log_notice==true)
+ file_notice("Dansguardian - Blacklist applied, check site and URL access lists for categories","");
#foreach($config['installedpackages'] as $key => $values)
# if (preg_match("/dansguardian(phrase|black|white)lists/",$key))
# print "$key\n";