From cf08e91af27301092ea4ef4bd96762fcd82db58c Mon Sep 17 00:00:00 2001 From: marcelloc Date: Fri, 27 Jan 2012 14:24:51 -0200 Subject: Dansguardian - First release --- config/dansguardian/dansguardian.php | 114 +++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 config/dansguardian/dansguardian.php (limited to 'config/dansguardian/dansguardian.php') diff --git a/config/dansguardian/dansguardian.php b/config/dansguardian/dansguardian.php new file mode 100644 index 00000000..8998d1f8 --- /dev/null +++ b/config/dansguardian/dansguardian.php @@ -0,0 +1,114 @@ +&1',$output,$return); + if (preg_match("/x (\w+)/",$output[0],$matches)){ + if ($matches[1] != "blacklists") + rename("./".$matches[1],"blacklists"); + read_lists(); + file_notice("Dansguardian - Blacklist applied, check site and URL access lists for categories",""); + } + else + file_notice("Dansguardian - Could not determine Blacklist extract dir. Categories not updated",""); + } + else{ + file_notice("Dansguardian - Blacklist url is invalid.",""); + } +} +function read_lists(){ + global $config,$g; + $group_type=array(); + $dir="/usr/local/etc/dansguardian/lists"; + #read dansguardian lists dirs + $groups= array("phraselists", "blacklists", "whitelists"); + #assigns know list files + $types=array('domains','urls','banned','weighted','exception','expression'); + #clean previous xml config for dansguardian lists + foreach ($groups as $group) + foreach ($types as $clean) + $config['installedpackages']['dansguardian'.$group.$clean]['config']=array(); + + #clean previous xml config for dansguardian lists + foreach ($groups as $group) + if (is_dir("$dir/$group/")){ + #read dir content and find lists + $lists= scandir("$dir/$group/"); + foreach ($lists as $list) + if (!preg_match ("/^\./",$list)){ + $category= scandir("$dir/$group/$list/"); + foreach ($category as $file) + if (!preg_match ("/^\./",$file)){ + #assign list to array + $type=split("_",$file); + print $type[0]." --- $list --- $file\n"; + if (!in_array($type[0],$group_type)) + $list_type[]=$type[0]; + $xml_group=($list=="whitelist"?"whitelists":$group); + $xml_type=($type[0]=="domains.processed"?"domains":$type[0]); + $config['installedpackages']['dansguardian'.$xml_group.$xml_type]['config'][]=array("descr"=> "$list $file","list" => $list,"file" => "$dir/$group/$list/$file"); + } + } + } + + #var_dump($config['installedpackages']['dansguardian']['config']); + #foreach ($types as $clean) + #var_dump($config['installedpackages']['dansguardianfiles'.$clean]['config']); + write_config(); +} + +if ($argv[1]=="update_lists") + read_lists(); + +if ($argv[1]=="fetch_blacklist") + fetch_blacklist(); + +?> \ No newline at end of file -- cgit v1.2.3