All pages on V1 have some script which checks to see if a file exists in the "ipban" folder which is the IP of the users browsing. If so it then blocks them.
This tool goes into the admin panel which allows you to add and remove IP bans.
In admin.php:
function ipban()
{
?><h3>Ban an IP</h3>
<form action='admin.php?action=ipbancon' method='post'>
<input type="text" name="ip" />
<input type='submit' value='BAN!' /></form>
<hr width="50%" />
[url="admin.php?action=ipbanview"][b]Click to view current IP bans[/b][/url]
<?
}
function ipbancon()
{
$filename='/home/USER NAME/public_html/ipbans/'.$_POST['ip'];
$file=fopen($filename,w) or die("Error Creating File");
fclose($file);
?>Done
[url="admin.php?action=ipbanview"][b]Back[/b][/url]<?
}
function ipbanview()
{
$dir = "/home/USER NAME/public_html/ipbans/";
?>
<h3>Viewing banned IP's</h3>
<table border="1">
<tr>
<th>
IP
</th>
<th>
Delete?
</th>
</tr><?
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
if (strlen($file)>4)
{
?>
<tr>
<td>
<? echo $file; ?>
</td>
<td>
[url="admin.php?action=ipbanremove&ip=<? echo $file; ?>"][b]Delete[/b][/url]
</td>
</tr>
<?
}
}
closedir($dh);
}
}
?></table>
[url="admin.php"][b]Back[/b][/url]
<?
}
function ipbanremove()
{
$file=$_GET['ip'];
$filepath = "/home/USER NAME/public_html/ipbans/".$file;
if (! unlink ($filepath)) {
echo "Couldn't delete file";
} else {
echo "Removed IP: ".$file;
}
?>
[url="admin.php?action=ipbanview"][b]Back[/b][/url]<?
}
You need to change the USER NAME part to your hosting username. If you use cpanel it will be that username.
Add the cases:
case 'ipban': ipban(); break;
case 'ipbancon': ipbancon(); break;
case 'ipbanview': ipbanview(); break;
case 'ipbanremove': ipbanremove(); break;
And the links
[[url='admin.php?action=ipban'][b]Ban an IP[/b][/url]]
[[url='admin.php?action=ipbanview'][b]View Banned IP's[/b][/url]]
If you don't have to code to check the ip here it is:
For the login + register pages etc:
$ip = ($_SERVER['HTTP_X_FORWARDED_FOR'])
? $_SERVER['HTTP_X_FORWARDED_FOR']
: $_SERVER['REMOTE_ADDR'];
if(file_exists('ipbans/'.$ip))
{
die("[b]<font color='red' size='+1'>Your IP has been banned, there is no way around this.</font>[/b]</body></html>");
}
Put is somewhere near the top.
In header.php put it in an appropriate place. Mine is under the crimeexp checking part:
if(file_exists('ipbans/'.$ip))
{
die("[b]<font color='red' size='+1'>Your IP has been banned, there is no way around this.</font>[/b]</body></html>");
}
It is likely you already have the IP checking code there, so check first.
It is tested and works, any problems reply to this topic.
You need to make the ipbans folder CHMOD: 777