aboutsummaryrefslogtreecommitdiffstats
path: root/config/countryblock
diff options
context:
space:
mode:
authorTom Schaefer <tom@tomschaefer.org>2010-07-25 15:20:41 -0400
committerTom Schaefer <tom@tomschaefer.org>2010-07-25 15:20:41 -0400
commit0e9d556a1c497f9f3bf52e710447541325d69ec6 (patch)
treea521c6f28d06edf38f05394e7523e48af54945e9 /config/countryblock
parent7bcc2b400314dff7235bb635a9968d04d2e7df76 (diff)
downloadpfsense-packages-0e9d556a1c497f9f3bf52e710447541325d69ec6.tar.gz
pfsense-packages-0e9d556a1c497f9f3bf52e710447541325d69ec6.tar.bz2
pfsense-packages-0e9d556a1c497f9f3bf52e710447541325d69ec6.zip
countryblock - adding two missing files
Diffstat (limited to 'config/countryblock')
-rw-r--r--config/countryblock/purge.tmp26
-rw-r--r--config/countryblock/whitelist.tmp213
2 files changed, 239 insertions, 0 deletions
diff --git a/config/countryblock/purge.tmp b/config/countryblock/purge.tmp
new file mode 100644
index 00000000..81d16a7c
--- /dev/null
+++ b/config/countryblock/purge.tmp
@@ -0,0 +1,26 @@
+<?php
+$line = $_GET["line"];
+
+//echo("$line");
+//exec("more lists.txt > temp_lists.txt");
+if ($line == 0) {
+ exec("rm countries-white.txt");
+ } else {
+ exec("sed $line'd' countries-white.txt > temp_countries-white.txt");
+ }
+exec("more temp_countries-white.txt > countries-white.txt");
+exec("rm temp_countries-white.txt");
+
+
+?>
+<html>
+<HEAD>
+<SCRIPT language="JavaScript">
+<!--
+window.parent.location="whitelist.php";
+//-->
+</SCRIPT>
+</HEAD>
+
+
+</html> \ No newline at end of file
diff --git a/config/countryblock/whitelist.tmp b/config/countryblock/whitelist.tmp
new file mode 100644
index 00000000..46e26608
--- /dev/null
+++ b/config/countryblock/whitelist.tmp
@@ -0,0 +1,213 @@
+<?php
+
+ // TomSchaefer.org countryblock package 2010
+ //
+ // Notes: Find: ^(.*)$
+ // Replace: ob_start();\n$results = exec("cat countries-white.txt | grep XX");\nob_end_clean();\n\tif ($results == 'XX')\n\t\techo "\1";\n\telse\n\t\techo "\1";\n
+ //
+ //
+ //
+ //
+ require_once('config.inc');
+ require("guiconfig.inc");
+ include("head.inc");
+
+ //set the config as a global variable
+ global $config;
+
+ $global_usage = '/usr/local/www/packages/countryblock/global_usage';
+ //$fh = fopen($global_usage, 'r');
+
+ //phpinfo();
+
+
+
+
+?><head>
+<?php include("fbegin.inc"); ?>
+<style type="text/css">
+<!--
+.white {
+ text-align: center;
+}
+-->
+</style>
+
+
+
+
+
+<p class="pgtitle">Firewall: Country Block - Whitelist</p>
+<form method=POST action="">
+ <?php
+
+
+mwexec("touch countries-white.txt");
+//$myFile = "countries-white.txt";
+//$fh = fopen($myFile, 'a+');
+
+
+?>
+
+
+<script type="text/javascript" src="jquery.min.js"></script>
+
+
+
+<style type="text/css">
+
+a img {border:none; }
+
+</style>
+<!--<span class="tabcont">-->
+<?php if ($savemsg_cb) print_info_box($savemsg_cb);
+ //if ($output) print_info_box($output,$output2);
+ echo($output);
+ echo($output2);
+ ?>
+</span>
+
+</head>
+<br><br>
+
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+
+<tr>
+ <td class="tabcont" >
+ <a href="countryblock.php" target="_parent"><img src="../../themes/nervecenter/images/icons/icon_alias_url_reload.gif" ALT="Manual" ALIGN=RIGHT></a>
+</form>
+
+ <form action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" method="post">
+ <p>
+ Enter the CIDR Range you would like to whitlist</p>
+ <p><form method="post" action="">
+<input name="content" type="text" />
+<input type="image" src="../../themes/nervecenter/images/icons/icon_plus.gif" value="submit">
+<a href="purge.php?line=0">Purge All</a>
+
+<STYLE type="text/css">
+ a img {border:none; }
+ </STYLE>
+</head>
+
+<?php
+
+function delLineFromFile($fileName, $lineNum){
+// check the file exists
+ if(!is_writable($fileName))
+ {
+ // print an error
+ print "The file $fileName is not writable";
+ // exit the function
+ exit;
+ }
+ else
+ {
+ // read the file into an array
+ $arr = file($fileName);
+ }
+
+ // the line to delete is the line number minus 1, because arrays begin at zero
+ $lineToDelete = $lineNum-1;
+
+ // check if the line to delete is greater than the length of the file
+ if($lineToDelete > sizeof($arr))
+ {
+ // print an error
+ print "You have chosen a line number, <b>[$lineNum]</b>, higher than the length of the file.";
+ // exit the function
+ exit;
+ }
+
+ //remove the line
+ unset($arr["$lineToDelete"]);
+
+ // open the file for reading
+ if (!$fp = fopen($fileName, 'w+'))
+ {
+ // print an error
+ print "Cannot open file ($fileName)";
+ // exit the function
+ exit;
+ }
+
+ // if $fp is valid
+ if($fp)
+ {
+ // write the array to the file
+ foreach($arr as $line) { fwrite($fp,$line); }
+
+ // close the file
+ fclose($fp);
+ }
+
+echo "done";
+}
+
+
+$myFile = "countries-white.txt";
+$content = $_REQUEST['content'];
+$fh = fopen($myFile, 'a+');
+fwrite($fh, $content);
+if (strlen($content) > 1) {
+ fwrite($fh, "\n");
+ } else {
+}
+fclose($fh);
+
+
+//echo (filesize($myFile));
+if (filesize($myFile) > 1) {
+ //$fh = fopen($myFile, 'r');
+ //$theData = fread($fh, filesize($myFile));
+ //fclose($fh);
+ echo "<br/> Current List(s): <br/>";
+ // Get the whole file into a single string
+ $fileContents = file_get_contents($myFile);
+
+ // Explode the file contents string by each line
+ $lines = explode(PHP_EOL, $fileContents); // Replace PHP_EOL with "\r\n" or "\n" or "\r" if you like
+
+ // Iterate through each line and do what you need with it
+
+ foreach ($lines as $line) {
+ $i++;
+ echo "<a href=purge.php?line=$i style='border-style: none'><img src='../../themes/nervecenter/images/icons/icon_x.gif'></a>";
+ echo " ";
+ echo $line;
+ //echo "";
+ // echo $i;
+ echo "<br/>";
+
+ }
+
+
+ //echo $theData;
+
+
+}
+echo "<br/><br/>";
+
+
+
+
+?></p>
+
+ <p> <u>Usage</u>
+ <br/>
+ Enter a CIDR range for the Address you wish to whitlist. <br/>
+ Example: 192.168.1.0/24
+ <br/><br/>
+ </p>
+</form>
+<br/>
+</div>
+</td>
+</tr>
+</table>
+</form>
+
+<?php include("fend.inc"); ?>
+
+</body>
+</html> \ No newline at end of file