<?php
$pgtitle = "Firewall: Countryblock - Help";
	
	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();
	

	


	
?>

<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
<?php include("fbegin.inc"); ?>
<p class="pgtitle"><?=$pgtitle?></p>



<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr><td class="tabnavtbl">
<?php
	$tab_array = array();
	$tab_array[0] = array("Countries", false, "countryblock.php");
	$tab_array[1] = array("Settings", false, "settings.php");
	$tab_array[2] = array("Whitelist", false, "whitelist.php");
	$tab_array[3] = array("Interfaces", false, "countryblock_if.php");
	$tab_array[4] = array("Help", true, "help.php");
	//$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">Help</td>
    
	  </tr>
      
    <tr> 
	<td class="listlr" valign="middle">
  
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<!---
Usage:<br><br>
Countries - Check the country that you would like to block completely.<br> 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Choose if you want to block outbound access and if you want to log attempts. <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Click "Commit Countries" to store your settings. 
<br><br>
Settings - 
Click the setting you want and save<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Block outbound blocks all outbound traffic. You will not be able to browse a website hosted in one of these countries. <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Enable Logging will log all attempted traffic in/out to any of your selected countries. Logs show in the Firewall secion
<br><br>
Whitelist - 
Add networks you don't want blocked and save<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Add a CIDR Range and press +
<br><br>
Interfaces - 
Select which interfaces to block on<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
All selected countries will be blocked from the interfaces you slected.<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
By Default all interfaces are selected.<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
It's highly recommended that you keep all interfaces selected
<br><br>
Cron Jobs - 
Setup a cron job for countryblock<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
To run countryblock as a cron job use /usr/local/etc/rc.d/countryblock.sh <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
*Before the cron job will work, countryblock must be run via the webGUI atleast once
<br><br>

<span style="color:red">Warning!</span> - Apply after every firewall change or state reset. Use at your own risk. 
--->
<a href="http://doc.pfsense.org/index.php/Country_Block">Please see wiki for help</a> or the <a href="http://forum.pfsense.org/index.php/topic,25732.0.html">Forum</a>

</div>


</td>
</tr>
</table>
    </td>
	  
	 
    </tr>
   
  
</table>
</div>
<br>
<?php 
	echo "Current Status = ";
	ob_start();
	$results = exec("pfctl -s rules | grep -c countryblock");
	ob_end_clean(); 
	if ($results > '0') echo "Running";
	else
	 echo "<span style='color:red'>NOT running</span>";
		
	//Get Errors if exists
	ob_start();
	$results = exec("tail -r errorOUT.txt");
	ob_end_clean(); 
	echo "<br/><span style='color:red'>";
	echo $results;
	echo "</span>";
	
	//Get IP Count
	echo "<br>You are blocking ";
	ob_start();
	$results = exec("pfctl -T show -t countryblock |grep -v -c Z");
	ob_end_clean();
	echo $results;
	echo " Networks";
	?>

<br><br>

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