tweak year/agency modifer for queries
[contractdashboard.git] / cutenews / inc / ipban.mdu
blob:a/cutenews/inc/ipban.mdu -> blob:b/cutenews/inc/ipban.mdu
<?PHP <?PHP
if($member_db[1] != 1){ msg("error", "Access Denied", "You don't have permission for this section"); } if($member_db[1] != 1){ msg("error", "Access Denied", "You don't have permission for this section"); }
// ******************************************************************************** // ********************************************************************************
// Add IP // Add IP
// ******************************************************************************** // ********************************************************************************
if($action == "add" OR $action == "quickadd") if($action == "add" OR $action == "quickadd")
{ {
if(!$add_ip){ msg("error","Error !!!","The IP can not be blank", "$PHP_SELF?mod=ipban"); } if(!$add_ip){ msg("error","Error !!!","The IP can not be blank", "$PHP_SELF?mod=ipban"); }
$all_ip = file("./data/ipban.db.php"); $all_ip = file("./data/ipban.db.php");
$exist = FALSE; $exist = FALSE;
foreach($all_ip as $ip_line) foreach($all_ip as $ip_line)
{ {
$ip_arr = explode("|", $ip_line); $ip_arr = explode("|", $ip_line);
if($ip_arr[0] == $add_ip){ $exist = TRUE; } if($ip_arr[0] == $add_ip){ $exist = TRUE; }
} }
if(!$exist) if(!$exist)
{ {
$new_ips = fopen("./data/ipban.db.php", "a"); $new_ips = fopen("./data/ipban.db.php", "a");
$add_ip = stripslashes( preg_replace(array("'\|'",), array("I",), $add_ip) ); $add_ip = stripslashes( preg_replace(array("'\|'",), array("I",), $add_ip) );
fwrite($new_ips, "$add_ip|0||\n"); fwrite($new_ips, "$add_ip|0||\n");
fclose($new_ips); fclose($new_ips);
} }
if($action == "quickadd"){ die('The IP '.$add_ip.' is now banned from commenting.'); } if($action == "quickadd"){ die('The IP '.$add_ip.' is now banned from commenting.'); }
} }
// ******************************************************************************** // ********************************************************************************
// Remove IP // Remove IP
// ******************************************************************************** // ********************************************************************************
elseif($action == "remove") elseif($action == "remove")
{ {
if(!$remove_ip){ msg("error","Error !!!","The IP can not be blank", "$PHP_SELF?mod=ipban"); } if(!$remove_ip){ msg("error","Error !!!","The IP can not be blank", "$PHP_SELF?mod=ipban"); }
$old_ips = file("./data/ipban.db.php"); $old_ips = file("./data/ipban.db.php");
$new_ips = fopen("./data/ipban.db.php", "w"); $new_ips = fopen("./data/ipban.db.php", "w");
foreach($old_ips as $old_ip_line){ foreach($old_ips as $old_ip_line){
$ip_arr = explode("|", $old_ip_line); $ip_arr = explode("|", $old_ip_line);
if($ip_arr[0] != stripslashes($remove_ip)){ if($ip_arr[0] != stripslashes($remove_ip)){
fwrite($new_ips, $old_ip_line); fwrite($new_ips, $old_ip_line);
} }
} }
fclose($new_ips); fclose($new_ips);
} }
// ******************************************************************************** // ********************************************************************************
// List all IP // List all IP
// ******************************************************************************** // ********************************************************************************
echoheader("options", "IP Blocking"); echoheader("options", "IP Blocking");
echo'<table border=0 cellpading=0 cellspacing=0 width="645" > echo'<table border=0 cellpading=0 cellspacing=0 width="645" >
<form method=post action="'.$PHP_SELF.'"> <form method=post action="'.$PHP_SELF.'">
<td width=321 height="33"> <td width=321 height="33">
<b>Block IP</b> <b>Block IP</b>
<table border=0 cellpading=0 cellspacing=0 width=379 class="panel" cellpadding="7" > <table border=0 cellpading=0 cellspacing=0 width=379 class="panel" cellpadding="7" >
<tr> <tr>
<td width=79 height="25"> <td width=79 height="25">
&nbsp;IP Address : <br>&nbsp;<br>&nbsp; &nbsp;IP Address : <br>&nbsp;<br>&nbsp;
<td width=274 height="25"> <td width=274 height="25">
<input type=text name=add_ip>&nbsp;&nbsp; <input type=submit value="Block this IP"><br> <br> <input type=text name=add_ip>&nbsp;&nbsp; <input type=submit value="Block this IP"><br> <br>
example: <i>129.32.31.44</i> or <i>129.32.*.*</i> example: <i>129.32.31.44</i> or <i>129.32.*.*</i>
</tr> </tr>
<input type=hidden name=action value=add> <input type=hidden name=action value=add>
<input type=hidden name=mod value=ipban> <input type=hidden name=mod value=ipban>
</form> </form>
</table> </table>
<tr> <tr>
<td width=654 height="11"> <td width=654 height="11">
<img height=20 border=0 src="skins/images/blank.gif" width=1> <img height=20 border=0 src="skins/images/blank.gif" width=1>
</tr><tr> </tr><tr>
<td width=654 height=14> <td width=654 height=14>
<b>Blocked IP Addresses</b> <b>Blocked IP Addresses</b>
</tr> </tr>
<tr> <tr>
<td width=654 height=1> <td width=654 height=1>
<table width=641 height=100% cellspacing=0 cellpadding=0> <table width=641 height=100% cellspacing=0 cellpadding=0>
<tr> <tr>
<td width=15 bgcolor=#F7F6F4></td> <td width=15 bgcolor=#F7F6F4></td>
<td width=260 bgcolor=#F7F6F4><u>IP</u></td> <td width=260 bgcolor=#F7F6F4><u>IP</u></td>
<td width=218 bgcolor=#F7F6F4><u>times been blocked</u></td> <td width=218 bgcolor=#F7F6F4><u>times been blocked</u></td>
<td width=140 bgcolor=#F7F6F4>&nbsp;<u>unblock</u></td> <td width=140 bgcolor=#F7F6F4>&nbsp;<u>unblock</u></td>
</tr>'; </tr>';
$all_ips = file("./data/ipban.db.php"); $all_ips = file("./data/ipban.db.php");
$i = 0; $i = 0;
foreach($all_ips as $ip_line) foreach($all_ips as $ip_line)
{ {
if(!eregi("<\?",$ip_line)) if(!eregi("<\?",$ip_line))
{ {
if($i%2 != 0){ $bg = "bgcolor=#F7F6F4"; }else{ $bg = ""; } if($i%2 != 0){ $bg = "bgcolor=#F7F6F4"; }else{ $bg = ""; }
$i++; $i++;
$ip_arr = explode("|", $ip_line); $ip_arr = explode("|", $ip_line);
$ip_arr[0] = stripslashes( preg_replace(array("'\"'", "'\''"), array("&quot;", "&#039;"), $ip_arr[0]) ); $ip_arr[0] = stripslashes( preg_replace(array("'\"'", "'\''"), array("&quot;", "&#039;"), $ip_arr[0]) );
echo" echo"
<tr $bg height=18> <tr $bg height=18>
<td></td> <td></td>
<td> <td>
<a href=\"http://www.ripe.net/perl/whois?searchtext=$ip_arr[0]\" target=_blank title=\"Get more information about this ip\">$ip_arr[0]</a> <a href=\"http://www.ripe.net/perl/whois?searchtext=$ip_arr[0]\" target=_blank title=\"Get more information about this ip\">$ip_arr[0]</a>
</td> </td>
<td>$ip_arr[1]</td> <td>$ip_arr[1]</td>
<td> <td>
<a href=\"$PHP_SELF?mod=ipban&action=remove&remove_ip=$ip_arr[0]\">[unblock]</a></td> <a href=\"$PHP_SELF?mod=ipban&action=remove&remove_ip=$ip_arr[0]\">[unblock]</a></td>
</tr> </tr>
"; ";
} }
} }
if($i == 0){ echo"<tr><td align=center colspan=5><br> &nbsp;No blocked IP's</td></tr>"; } if($i == 0){ echo"<tr><td align=center colspan=5><br> &nbsp;No blocked IP's</td></tr>"; }
echo'</table></table>'; echo'</table></table>';
echofooter(); echofooter();
?> ?>