<?php
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
//$pgtitle = "Firewall: IPblo - Whitelist";
	
	require("guiconfig.inc");
	include("head.inc");

	//set the config as a global variable
	global $config;

	$global_usage = '/usr/local/www/packages/ipblocklist/global_usage';
	//$fh = fopen($global_usage, 'r');

	//phpinfo();
	

	


	
?>

<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
<?php include("fbegin.inc"); ?>
<p class="pgtitle"><?=$pgtitle?></p>
<?php if ($input_errors) print_input_errors($input_errors); ?>
<?php if ($savemsg) print_info_box($savemsg); ?>
<form method=POST action="">
<?php


//mwexec("touch countries-white.txt");
//$myFile = "countries-white.txt";
//$fh = fopen($myFile, 'a+');


?>
<br /><br />
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr><td class="tabnavtbl">
<?php
	$tab_array = array();
	$tab_array[0] = array("IP-Blocklist", false, "ipblocklist.php");
	$tab_array[1] = array("Settings", false, "settings.php");
	$tab_array[2] = array("Whitelist", true, "whitelist.php");
	$tab_array[3] = array("Interfaces", false, "ipblocklist_if.php");
	$tab_array[4] = array("Help", false, "http://doc.pfsense.org/index.php/IP_Blocklist");
	//$tab_array[5] = array("Email", false, "email.php");
	display_top_tabs($tab_array);
?>
  </td></tr>
  <tr> 
    <td>
	<div id="mainarea">
        <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
       <tr> 
	<td class="listhdrr">Whitelist</td>
    
	  </tr>
      
    <tr> 
	<td class="listlr" valign="middle">
  
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>

<span style="color:red">White lists</span> - The lists added here will be added to a whitelist
  <br/>Add List URL:

	<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="purgeip.php?line=0">Purge All</a>

<STYLE type="text/css">
   a img {border:none; }
 </STYLE>
</head>

<?php


$myFile = "wlists.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=purgeip.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>

	
</form>


</div>


</td>
</tr>
</table>
    </td>
	  
	 
    </tr>
   
  
</table>

</div>
<p> <u>Usage</u>
	<br/>
	Add direct link to list and press <img src="../../themes/nervecenter/images/icons/icon_plus.gif">
 	(Example: 
	<a href="http://iblocklist.whitacrecomputers.com/files/bt_level1.gz">Level1</a>,
	<a href="http://iblocklist.whitacrecomputers.com/files/bt_level2.gz">Level2</a>,
	<a href="http://iblocklist.whitacrecomputers.com/files/bt_level3.gz">Level3</a>)
	<br/>
	Compressed lists should have .gz extention and follows PeerBlock syntax	<br/>
	  <br/>
	  </p>
<br>

<br><br>

<p>
</p>
</td>
	</tr>
</table>
</form>
<?php include("fend.inc"); ?>
</body>
</html>