aboutsummaryrefslogtreecommitdiffstats
path: root/config/pfblockerng/pfblockerng.php
diff options
context:
space:
mode:
Diffstat (limited to 'config/pfblockerng/pfblockerng.php')
-rw-r--r--config/pfblockerng/pfblockerng.php62
1 files changed, 35 insertions, 27 deletions
diff --git a/config/pfblockerng/pfblockerng.php b/config/pfblockerng/pfblockerng.php
index 1db36334..8c0c478d 100644
--- a/config/pfblockerng/pfblockerng.php
+++ b/config/pfblockerng/pfblockerng.php
@@ -3,7 +3,7 @@
pfBlockerNG.php
pfBlockerNG
- Copyright (C) 2014 BBcan177@gmail.com
+ Copyright (C) 2015 BBcan177@gmail.com
All rights reserved.
Based upon pfBlocker by
@@ -12,7 +12,7 @@
Hour Schedule Convertor code by
Snort Package
- Copyright (c) 2014 Bill Meeks
+ Copyright (c) 2015 Bill Meeks
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -44,9 +44,13 @@ require_once("functions.inc");
require_once("pkg-utils.inc");
require_once("globals.inc");
require_once("services.inc");
-require_once("/usr/local/pkg/pfblockerng/pfblockerng.inc");
-pfb_global();
+// Call Include File and Collect updated Global Settings
+if (in_array($argv[1], array( 'update','dc','uc','gc','cron' ))) {
+ require_once("/usr/local/pkg/pfblockerng/pfblockerng.inc");
+ pfb_global();
+}
+
// IPv6 Range to CIDR function used courtesey from:
// https://github.com/stilez/pfsense-leases/blob/50cc0fa81dba5fe91bcddaea016c245d1b8479cc/etc/inc/util.inc
@@ -147,7 +151,7 @@ $uname = posix_uname();
if ($uname['machine'] == "amd64")
ini_set('memory_limit', '256M');
-function pfb_update_check($header_url, $list_url, $url_format) {
+function pfb_update_check($header_url, $list_url, $url_format, $pfbfolder) {
global $pfb;
$pfb['cron_update'] = FALSE;
@@ -230,6 +234,12 @@ if ($argv[1] == 'dc') {
}
pfblockerng_uc_countries();
pfblockerng_get_countries();
+
+ // Remove Original Maxmind Database Files
+ @unlink_if_exists("{$pfb['dbdir']}/GeoIPCountryCSV.zip");
+ @unlink_if_exists("{$pfb['dbdir']}/GeoIPCountryWhois.csv");
+ @unlink_if_exists("{$pfb['dbdir']}/GeoIPv6.csv");
+ @unlink_if_exists("{$pfb['dbdir']}/country_continent.csv");
}
if ($argv[1] == 'uc') {
@@ -241,7 +251,7 @@ if ($argv[1] == 'gc') {
}
if ($argv[1] == 'cron') {
- $hour = date('H');
+ $hour = date('G');
$dow = date('N');
$pfb['update_cron'] = FALSE;
@@ -260,7 +270,7 @@ if ($argv[1] == 'cron') {
$sch2 = strval($shour);
for ($i=0; $i<11; $i++) {
$shour += 2;
- if ($shour > 24)
+ if ($shour >= 24)
$shour -= 24;
$sch2 .= "," . strval($shour);
}
@@ -270,7 +280,7 @@ if ($argv[1] == 'cron') {
$sch3 = strval($shour);
for ($i=0; $i<7; $i++) {
$shour += 3;
- if ($shour > 24)
+ if ($shour >= 24)
$shour -= 24;
$sch3 .= "," . strval($shour);
}
@@ -280,7 +290,7 @@ if ($argv[1] == 'cron') {
$sch4 = strval($shour);
for ($i=0; $i<5; $i++) {
$shour += 4;
- if ($shour > 24)
+ if ($shour >= 24)
$shour -= 24;
$sch4 .= "," . strval($shour);
}
@@ -290,7 +300,7 @@ if ($argv[1] == 'cron') {
$sch6 = strval($shour);
for ($i=0; $i<3; $i++) {
$shour += 6;
- if ($shour > 24)
+ if ($shour >= 24)
$shour -= 24;
$sch6 .= "," . strval($shour);
}
@@ -300,7 +310,7 @@ if ($argv[1] == 'cron') {
$sch8 = strval($shour);
for ($i=0; $i<2; $i++) {
$shour += 8;
- if ($shour > 24)
+ if ($shour >= 24)
$shour -= 24;
$sch8 .= "," . strval($shour);
}
@@ -309,7 +319,7 @@ if ($argv[1] == 'cron') {
$shour = intval(substr($pfb['hour'], 0, 2));
$sch12 = strval($shour) . ",";
$shour += 12;
- if ($shour > 24)
+ if ($shour >= 24)
$shour -= 24;
$sch12 .= strval($shour);
@@ -408,13 +418,11 @@ if ($argv[1] == 'cron') {
if ($pfb['update_cron']) {
sync_package_pfblockerng("cron");
} else {
- $log = "\n No Updates required. \n\n";
+ sync_package_pfblockerng("noupdates");
+ $log = "\n No Updates required.\n CRON PROCESS ENDED\n UPDATE PROCESS ENDED\n";
pfb_logger("{$log}","1");
}
- $log = " CRON PROCESS ENDED [ NOW ]\n";
- pfb_logger("{$log}","1");
-
# Call Log Mgmt Function
// If Update GUI 'Manual view' is selected. Last output will be missed. So sleep for 5 secs.
sleep(5);
@@ -425,7 +433,6 @@ if ($argv[1] == 'cron') {
// Function to process the downloaded Maxmind Database and format into Continent txt files.
function pfblockerng_uc_countries() {
global $g,$pfb;
- pfb_global();
$maxmind_cont = "{$pfb['dbdir']}/country_continent.csv";
$maxmind_cc4 = "{$pfb['dbdir']}/GeoIPCountryWhois.csv";
@@ -584,7 +591,6 @@ function pfblockerng_uc_countries() {
// Function to process Continent txt files and create Country ISO files and to Generate GUI XML files.
function pfblockerng_get_countries() {
global $g,$pfb;
- pfb_global();
$files = array ( "Africa" => "{$pfb['ccdir']}/Africa_v4.txt",
"Asia" => "{$pfb['ccdir']}/Asia_v4.txt",
@@ -622,7 +628,9 @@ function pfblockerng_get_countries() {
if (preg_match("/#/",$line)) {
if ($pfb['complete']) {
${'coptions' . $type}[] = $country . '-' . $isocode . ' ('. $total .') ' . ' </name><value>' . $isocode . '</value></option>';
- ${'roptions' . $type}[] = $country . '-' . $isocode . ' ('. $total .') ' . ' </name><value>' . $isocode . '</value></option>';
+ // Only collect IPv4 for Reputation Tab
+ if ($type == "4")
+ $roptions4[] = $country . '-' . $isocode . ' ('. $total .') ' . ' </name><value>' . $isocode . '</value></option>';
// Save ISO data
@file_put_contents($pfb['ccdir'] . '/' . $isocode . '_v' . $type . '.txt', $xml_data, LOCK_EX);
@@ -646,7 +654,8 @@ function pfblockerng_get_countries() {
if ($keycount == $lastkey) {
if (preg_match("/Total Networks: 0/", $line)) { continue;} // Dont Display Countries with Null Data
${'coptions' . $type}[] = $country . '-' . $isocode . ' ('. $total .') ' . ' </name><value>' . $isocode . '</value></option>';
- ${'roptions' . $type}[] = $country . '-' . $isocode . ' ('. $total .') ' . ' </name><value>' . $isocode . '</value></option>';
+ if ($type == "4")
+ $roptions4[] = $country . '-' . $isocode . ' ('. $total .') ' . ' </name><value>' . $isocode . '</value></option>';
@file_put_contents($pfb['ccdir'] . '/' . $isocode . '_v' . $type . '.txt', $xml_data, LOCK_EX);
unset($total, $xml_data);
}
@@ -687,7 +696,7 @@ $xml = <<<EOF
pfblockerng_{$cont_name}.xml
pfBlockerNG
- Copyright (C) 2014 BBcan177@gmail.com
+ Copyright (C) 2015 BBcan177@gmail.com
All rights reserved.
Based upon pfblocker for pfSense
@@ -962,13 +971,12 @@ EOF;
// Sort Countries IPv4 Alphabetically and Build XML <option> Data for Reputation Tab (IPv6 not used by ET IQRisk)
- $type = "4";
- sort(${'roptions' . $type}, SORT_STRING);
- $eoa = count(${'roptions' . $type});
+ sort($roptions4, SORT_STRING);
+ $eoa = count($roptions4);
$count = 1;
$etoptions = "";
- foreach (${'roptions' . $type} as $option4) {
+ foreach ($roptions4 as $option4) {
if ($count == 1) { $et_options .= "\t" . '<option><name>' . $option4 . "\n"; $count++; continue; }
if ($eoa == $count) {
$et_options .= "\t\t\t\t" . '<option><name>' . $option4;
@@ -993,7 +1001,7 @@ $xmlrep = <<<EOF
pfBlockerNG_Reputation.xml
pfBlockerNG
- Copyright (C) 2014 BBcan177@gmail.com
+ Copyright (C) 2015 BBcan177@gmail.com
All rights reserved.
Based upon pfblocker for pfSense
@@ -1470,6 +1478,6 @@ EOF;
pfb_logger("{$log}","3");
// Unset Arrays
- unset ($et_options, $xmlrep);
+ unset ($roptions4, $et_options, $xmlrep);
}
?> \ No newline at end of file