1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
<?PHP
if($member_db[1] != 1){ msg("error", "Access Denied", "You don't have permission for this section"); }
// ********************************************************************************
// Add IP
// ********************************************************************************
if($action == "add" OR $action == "quickadd")
{
if(!$add_ip){ msg("error","Error !!!","The IP can not be blank", "$PHP_SELF?mod=ipban"); }
$all_ip = file("./data/ipban.db.php");
$exist = FALSE;
foreach($all_ip as $ip_line)
{
$ip_arr = explode("|", $ip_line);
if($ip_arr[0] == $add_ip){ $exist = TRUE; }
}
if(!$exist)
{
$new_ips = fopen("./data/ipban.db.php", "a");
$add_ip = stripslashes( preg_replace(array("'\|'",), array("I",), $add_ip) );
fwrite($new_ips, "$add_ip|0||\n");
fclose($new_ips);
}
if($action == "quickadd"){ die('The IP '.$add_ip.' is now banned from commenting.'); }
}
// ********************************************************************************
// Remove IP
// ********************************************************************************
elseif($action == "remove")
{
if(!$remove_ip){ msg("error","Error !!!","The IP can not be blank", "$PHP_SELF?mod=ipban"); }
$old_ips = file("./data/ipban.db.php");
$new_ips = fopen("./data/ipban.db.php", "w");
foreach($old_ips as $old_ip_line){
$ip_arr = explode("|", $old_ip_line);
if($ip_arr[0] != stripslashes($remove_ip)){
fwrite($new_ips, $old_ip_line);
}
}
fclose($new_ips);
}
// ********************************************************************************
// List all IP
// ********************************************************************************
echoheader("options", "IP Blocking");
echo'<table border=0 cellpading=0 cellspacing=0 width="645" >
<form method=post action="'.$PHP_SELF.'">
<td width=321 height="33">
<b>Block IP</b>
<table border=0 cellpading=0 cellspacing=0 width=379 class="panel" cellpadding="7" >
<tr>
<td width=79 height="25">
IP Address : <br> <br>
<td width=274 height="25">
<input type=text name=add_ip> <input type=submit value="Block this IP"><br> <br>
example: <i>129.32.31.44</i> or <i>129.32.*.*</i>
</tr>
<input type=hidden name=action value=add>
<input type=hidden name=mod value=ipban>
</form>
</table>
<tr>
<td width=654 height="11">
<img height=20 border=0 src="skins/images/blank.gif" width=1>
</tr><tr>
<td width=654 height=14>
<b>Blocked IP Addresses</b>
</tr>
<tr>
<td width=654 height=1>
<table width=641 height=100% cellspacing=0 cellpadding=0>
<tr>
<td width=15 bgcolor=#F7F6F4></td>
<td width=260 bgcolor=#F7F6F4><u>IP</u></td>
<td width=218 bgcolor=#F7F6F4><u>times been blocked</u></td>
<td width=140 bgcolor=#F7F6F4> <u>unblock</u></td>
</tr>';
$all_ips = file("./data/ipban.db.php");
$i = 0;
foreach($all_ips as $ip_line)
{
if(!eregi("<\?",$ip_line))
{
if($i%2 != 0){ $bg = "bgcolor=#F7F6F4"; }else{ $bg = ""; }
$i++;
$ip_arr = explode("|", $ip_line);
$ip_arr[0] = stripslashes( preg_replace(array("'\"'", "'\''"), array(""", "'"), $ip_arr[0]) );
echo"
<tr $bg height=18>
<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>
</td>
<td>$ip_arr[1]</td>
<td>
<a href=\"$PHP_SELF?mod=ipban&action=remove&remove_ip=$ip_arr[0]\">[unblock]</a></td>
</tr>
";
}
}
if($i == 0){ echo"<tr><td align=center colspan=5><br> No blocked IP's</td></tr>"; }
echo'</table></table>';
echofooter();
?>
|