0) { conf_mount_rw(); $ent = array(); if ($_POST['enable'] == 1) { //echo "enabled"; $config['installedpackages']['countryblock_settings']['config'][0]['enable'] = 1; //touch countries-white.txt to fix bug exec("touch /usr/local/www/packages/countryblock/countries-white.txt"); //Process list by downloading and extracting $myFile = "countries.txt"; $fileContents = file_get_contents($myFile); $lines = explode(PHP_EOL, $fileContents); //Remove DIR lists to eliminate duplates exec("rm -R lists"); //Process each list URL, Extract, and put in DIR lists exec("mkdir lists"); foreach ($lines as $line) { //echo("fetch -o lists http://www.countryipblocks.net/e_country_data/{$line}_cidr.txt"); exec("fetch -o lists/temp http://www.countryipblocks.net/e_country_data/{$line}_cidr.txt"); exec("cat lists/temp >> lists/countries.txt"); $filename = basename($line); //Extract list //exec("gzip -d lists/$filename"); } //Prep pfctl mwexec("rm lists/temp"); //mwexec("touch lists/ipfw.ipfw"); //Now clear ipfw, and process each list to ipfw commands mwexec("sh execute.sh"); } else { //echo "disabled"; $config['installedpackages']['countryblock_settings']['config'][0]['enable'] = 0; //Clear Lists mwexec("pfctl -t countryblock -T kill"); mwexec("rm -R /usr/local/www/packages/countryblock/lists"); mwexec("sed -i -e '/countryblock/d' /tmp/rules.debug"); mwexec("pfctl -o basic -f /tmp/rules.debug"); //Clear errorOUT.txt mwexec("rm errorOUT.txt"); } //write_config(); //services_dnsmasq_configure(); sleep(1); $savemsg_cb = "Country Block settings have been saved/updated. "; conf_mount_ro(); } ?>
Firewall: Country Block