С този скрипт ще можете да блокирате не желани ип адреси.
Трябва да създадете файл с име .htaccess и да добавите този текст в него:
<Files 403.shtml>
order allow,deny
allow from all
</Files>
Demo:
form.php
zapis.php
edit.php
open.php
Трябва да създадете файл с име .htaccess и да добавите този текст в него:
<Files 403.shtml>
order allow,deny
allow from all
</Files>
Demo:
form.php
Код:
<html>
<head>
<title>Бан система</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
<style>
body {
background: #F5F5F5;
}
body,input,textarea,table {
font-size: 12px;
font-family: verdana, serif;
color: black;
}
input,textarea {
text-indent : 2px;
background: rgb(245,245,245);
border: 2px rgb(220,220,220) solid;
}
a:hover,a:active {
text-decoration: underline overline;
}
a:visited {
color: #707070;
}
.tabstyle {
border-style: solid;
border: solid 2px;
border-color:#DCDCDC #DFDFDF;
}
.tdstyle {
background: rgb(240,240,240);
}
</style>
</head>
<body >
<table width="55%" class="tabstyle" align="center" cellpadding="4" cellspacing="0">
<tr>
<td bgcolor="#E6E6E6"><b>Бан система</b></td>
</tr>
<tr>
<td class="tdstyle"><br><center>
<FORM action=zapis.php method=post >
<b>IP Адрес:</b>
<INPUT name=ip>
<INPUT TYPE=submit value=Блокирай> <br><br><br>
<?php
$file= file("ban.inc");
$n=count($file);
echo '<table border="0" class="a" align="center" >
<tr> <td><b>Блокирани:</b></td>
';
for ($i=0; $i<$n;$i++)
{
$line = explode ("&",$file[$i] );
echo '
<tr>
<td ><b>'.$line[0].'</b> <b>Дата:</b>'.$line[1].'</td><td > <b>IP:</b>'.$line[2].'</td>
</tr>';
}
?>
</table><br><br>
<a href=open.php>Редактирай</a><br> <br></center>
</td>
</tr>
<tr>
<td bgcolor="#E6E6E6"><b><center>Powered by <A href="http://web-tourist.net" target=_blank>web-tourist.net</A></center></b></td>
</tr>
</table>
</body>
</html>
zapis.php
Код:
<html>
<head>
<title>Бан система</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
</head>
<body>
<?php
$vreme=date("d F Y, H:i");
$ip=$_POST[ip];
if(!eregi('^[0-9.]+$',$ip))
{echo '
<html>
<head>
<title>Бан система</title>
<META HTTP-EQUIV="Refresh" CONTENT="2; URL=form.php">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
<style>
body {
background: #F5F5F5;
font-size: 12px;
font-family: verdana, serif;
color: black;
}
</style>
</head>
<body>
<center><b>НЕ сте въвели коректен IP -адрес</b></center>
</body>
</html>';
exit;}
$ip=stripslashes($ip);
$text="\n"."deny from ".$ip;
$fp = fopen (".htaccess" ,"a");
fwrite($fp, $text );
fclose($fp);
if (file_exists("nomer_ban.inc"))
{
$fp = fopen ("nomer_ban.inc" ,"r");
$nomer= fgets($fp,999);
fclose($fp);
$nomer=$nomer+1;
$fp = fopen ("nomer_ban.inc" ,"w");
fwrite($fp, $nomer);
fclose($fp);
}
else
{$nomer=1;
$fp = fopen ("nomer_ban.inc" ,"w");
fwrite($fp, $nomer);
fclose($fp);
}
$ip=stripslashes($ip);
$text=$nomer.'&'.$vreme.'&'.$ip. " \n" ;
$fp = fopen ("ban.inc" ,"a");
fwrite($fp, $text );
fclose($fp);
echo '
<html>
<head>
<title>Бан система</title>
<META HTTP-EQUIV="Refresh" CONTENT="2; URL=form.php">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
<style>
body {
background: #F5F5F5;
font-size: 12px;
font-family: verdana, serif;
color: black;
}
</style>
</head>
<body>
<center><b>Данните са добавени!</b></center>
</body>
</html>';
?>
</body>
</html>
edit.php
Код:
<html>
<head>
<title>Бан система</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
</head>
<body>
<?php
$text=$HTTP_POST_VARS['write'];
$text=stripslashes($text);
$fp = fopen (".htaccess" ,"w");
fwrite($fp, $text );
fclose($fp);
echo '
<html>
<head>
<title>Бан система</title>
<META HTTP-EQUIV="Refresh" CONTENT="2; URL=form.php">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
<style>
body {
background: #F5F5F5;
font-size: 12px;
font-family: verdana, serif;
color: black;
}
</style>
</head>
<body>
<center><b>Успешно махнахте бан!</b></center>
</body>
</html>';
?>
</body>
</html>
open.php
Код:
<html>
<head>
<title>Бан система</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
<style>
body {
background: #F5F5F5;
}
body,input,textarea,table {
font-size: 12px;
font-family: verdana, serif;
color: black;
}
input,textarea {
text-indent : 2px;
background: rgb(245,245,245);
border: 2px rgb(220,220,220) solid;
}
a:hover,a:active {
text-decoration: underline overline;
}
a:visited {
color: #707070;
}
.tabstyle {
border-style: solid;
border: solid 2px;
border-color:#DCDCDC #DFDFDF;
}
.tdstyle {
background: rgb(240,240,240);
}
</style>
</head>
<body>
<table width="55%" class="tabstyle" align="center" cellpadding="4" cellspacing="0">
<tr>
<td bgcolor="#E6E6E6"><b>Бан система</b></td>
</tr>
<tr>
<td class="tdstyle"><center><br>
<?php
$fp = fopen (".htaccess" ,"r");
$file= fread($fp,10000);
echo'<form method="post" action="edit.php" >
<TEXTAREA name="write" COLS=70 ROWS=15 > ';
echo $file;
echo
'</TEXTAREA> <br><br>
<INPUT TYPE=SUBMIT VALUE="Едит">
</FORM>';
?> </center>
</td>
</tr>
<tr>
<td bgcolor="#E6E6E6"><b><center>Powered by <A href="http://web-tourist.net" target=_blank>web-tourist.net</A></center></b></td>
</tr>
</table>
</body>
</html>