/
banner.inc
153 lines (142 loc) · 3.42 KB
/
banner.inc
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<?
global $IPfile;
$IPfile = $_SERVER["DOCUMENT_ROOT"]."\\bannedlist.txt";
function printform(){
?>
<html>
<Head>
<title>
IP Banner
</title>
</head>
<body bgcolor="#E60000">
<form name=form1 action="<?=$_SERVER["PHP_SELF"]; ?>?ipbanmode=admin" method=post>
<table align=center>
<tr>
<th colspan=2 align=center>
Administration
</th>
</tr>
<td>
Username:
</td>
<td>
<input type=text name="username" size=20>
</td>
</tr>
<td>
Password:
</td>
<td>
<input type=password size=20 name=password>
</td>
</tr>
<tr>
<td align=center>
<input type=submit value=Submit>
</td>
<td align=center>
<input type=reset value=Reset>
</td>
</tr>
</table>
</form>
</body>
</html>
<?
}
function isvalid($s){
return ($s==md5("Adam"."passw0rd"));
}
function readips(){
global $IPfile;
clearstatcache();
$file = fopen($IPfile,"r+");
$bannedIps = explode("|",fread($file,filesize($IPfile)));
fclose($file);
return $bannedIps;
}
function RemoveArrayItem($ar,$n){
$ar2 = array();
foreach($ar as $k => $s){
if ($k!=$n) {array_push($ar2,$s);}
}
return $ar2;
}
function rewritefile($data){
global $IPfile;
$file= fopen($IPfile,"w+");
fwrite($file,implode("|",$data));
fclose($file);
}
function writeip($ip1,$ip2,$ip3,$ip4){
global $IPfile;
$file= fopen($IPfile,"a+");
clearstatcache();
if (filesize($IPfile)!=0){
fwrite($file,"|".$ip1.".".$ip2.".".$ip3.".".$ip4);
}
else
{
fwrite($file,$ip1.".".$ip2.".".$ip3.".".$ip4);
}
fclose($file);
}
function displayIPS(){
global $IPfile;
$ips = readips();
clearstatcache();
if (filesize($IPfile)!=0){
echo "<table>\n";
foreach($ips as $key => $s){
echo "<tr><td><input type=button onclick=\"dodelete('".$key."');\" value=\"Delete\"></td><td>".$s."</td></tr>";
}
echo "</table>\n";
}
else
{
echo "There currently aren't any banned IP's in the Banned IP File protocol.\n<br>";
}
}
function actionpage(){
?>
<html>
<Head>
<title>
IP Banner
</title>
<script>
<!--
function dodelete(val){
document.form1.delindex.value=val;
document.form1.submit();
}
function correct(ID){
if (((window.event.keyCode>=48)&&(window.event.keyCode<=57))|| (window.event.keyCode==13)){
window.event.returnValue=true;
}
else{
if (window.event.keyCode==46){
document.getElementById(ID).focus();
}
window.event.returnValue=false;
}
}
-->
</script>
</head>
<body bgcolor="#0099FF">
<form name=form1 action="<?=$_SERVER["PHP_SELF"]; ?>?ipbanmode=delete" method=post>
<input type=hidden value="" name=delindex>
<? displayIPS(); ?>
<br>
</form>
<form name=form2 action="<?=$_SERVER["PHP_SELF"]; ?>?ipbanmode=add" method=post>
<input type=text MAXLENGTH=3 onkeypress="correct('IP2');" value="" ID=IP1 name=ip1 size=3><b><font size=+5>.</font></b><input type=text MAXLENGTH=3 onkeypress="correct('IP3');" value="" ID=IP2 name=ip2 size=3><b><font size=+5>.</font></b><input type=text MAXLENGTH=3 onkeypress="correct('IP4');" value="" ID=IP3 name=ip3 size=3><b><font size=+5>.</font></b><input type=text MAXLENGTH=3 onkeypress="correct('IP5');" value="" ID=IP4 name=ip4 size=3> <input type=submit value=add id=IP5>
</form>
<input type=button value=Logout onclick="window.location='<?=$_SERVER["PHP_SELF"]; ?>?ipbanmode=logout'"
</body>
</html>
<?
}
?>