aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xconfig/countryblock-dev/countryblock.inc20
-rw-r--r--config/countryblock-dev/countryblock.php2
2 files changed, 15 insertions, 7 deletions
diff --git a/config/countryblock-dev/countryblock.inc b/config/countryblock-dev/countryblock.inc
index 7f526895..732396be 100755
--- a/config/countryblock-dev/countryblock.inc
+++ b/config/countryblock-dev/countryblock.inc
@@ -33,7 +33,7 @@ require_once("util.inc");
require_once("functions.inc");
require_once("pkg-utils.inc");
require_once("globals.inc");
-
+
function cb_text_area_decode($text){
return preg_replace('/\r\n/', "\n",base64_decode($text));
}
@@ -71,7 +71,8 @@ function sync_package_countryblock() {
$ips="";
foreach ($cb_files as $iso){
if ($iso <> ""){
- $ips.=file_get_contents('/usr/local/pkg/countryblock/'.$iso.'.txt');
+ if (file_exists('/usr/local/pkg/countryblock/'.$iso.'.txt'))
+ $ips.=file_get_contents('/usr/local/pkg/countryblock/'.$iso.'.txt');
}
}
#create all ip block lists based on gui
@@ -94,7 +95,9 @@ function sync_package_countryblock() {
"type"=> "urltable",
"detail"=> "DO NOT EDIT THIS ALIAS");
#force alias file update
- file_put_contents('/var/db/aliastables/Countryblock.txt',$ips, LOCK_EX);
+ if (! is_dir('/var/db/aliastables/'))
+ mkdir ('/var/db/aliastables/',0755);
+ file_put_contents('/var/db/aliastables/Countryblock.txt',$ips, LOCK_EX);
}
if (cb_text_area_decode($countryblock_config['whitelist']) != ""){
#create or reaply alias
@@ -106,9 +109,12 @@ function sync_package_countryblock() {
"type"=> "urltable",
"detail"=> "DO NOT EDIT THIS ALIAS");
#force alias file update
- file_put_contents('/var/db/aliastables/CountryblockWL.txt',cb_text_area_decode($countryblock_config['whitelist']), LOCK_EX);
+ if (! is_dir('/var/db/aliastables/'))
+ mkdir ('/var/db/aliastables/',0755);
+ file_put_contents('/var/db/aliastables/CountryblockWL.txt',cb_text_area_decode($countryblock_config['whitelist']), LOCK_EX);
}
- foreach($aliases as $cbalias){
+ if (is_array($aliases))
+ foreach($aliases as $cbalias){
if (! preg_match("/Countryblock.*list/",$cbalias['descr']))
$new_aliases[]= $cbalias;
}
@@ -206,7 +212,7 @@ function sync_package_countryblock() {
if ($rule['interface'] <> $last_iface){
$last_iface = $rule['interface'];
#apply countryblock rules if enabled
- if ($config['installedpackages']['countryblock']['config'][0]['enable_cb'] == "on")
+ if ($config['installedpackages']['countryblock']['config'][0]['enable_cb'] == "on" && is_array(${$rule['interface']}))
foreach (${$rule['interface']} as $cb_rules)
$new_rules[]=$cb_rules;
}
@@ -367,7 +373,7 @@ function countryblock_do_xmlrpc_sync($sync_to_ip, $password) {
} elseif($resp->faultCode()) {
$cli->setDebug(1);
$resp = $cli->send($msg, "250");
- $error = "An error code was received while attempting countryblock XMLRPC sync with {$url}:{$port} - Code " . $resp->faultCode() . ": " . $resp->faultString();
+ $error = "An error code was received while attempting countryblock XMLRPC exec with {$url}:{$port} - Code " . $resp->faultCode() . ": " . $resp->faultString();
log_error($error);
file_notice("sync_settings", $error, "countryblock Settings Sync", "");
} else {
diff --git a/config/countryblock-dev/countryblock.php b/config/countryblock-dev/countryblock.php
index 96822e12..5d0f825a 100644
--- a/config/countryblock-dev/countryblock.php
+++ b/config/countryblock-dev/countryblock.php
@@ -49,6 +49,8 @@ foreach ($files as $cont => $file){
${$ISOCode}.=$line."\n";
}
}
+#save last country networks
+file_put_contents($cdir.'/'.$ISOCode.'.txt',${$ISOCode},LOCK_EX);
$cont_name= preg_replace("/ /","",$cont);
$cont_name_lower= strtolower($cont_name);
#file_put_contents($cdir.'/'.$cont_name.'.txt',$ips,LOCK_EX);