<?php
$banned_ip = array();
$banned_ip[] = '*.*.*.**1';
$banned_ip[] = '*.*.*.**2';
$banned_ip[] = '*.*.*.**3';
$banned_ip[] = '*.*.*.**4';
foreach($banned_ip as $banned) {
$ip = $_SERVER['REMOTE_ADDR'];
if($ip == $banned){
echo "Error 04, Banned.";
exit();
}
}
//blah
?>
Has anyone written anything better? Just wrote this up, excuse me if its been done before but it works for me.
If I were you I would write all of the wanted ipbans to a textfile. And then a code that would let you ban new ips from a webpage as opposed to having to login to my ftp and editing my file every time you find another fucker.
&Edited
Or MySQL. Just a thought.
Mysql would be the same thing with extra code...
<?
if (ereg("IP Here",$REMOTE_ADDR))
{
echo "your banned ."; exit(); }
?>
Hmmm, I'll Right you a Script.
<?php $db="HelloWorld"; //MySQL Database here$username="Admin"; //MySQL Username$password="JohnSmith"; //MySQL Password@mysql_connect('localhost', $username, $password);@mysql_select_db($db);$ip=$_SERVER['REMOTE_ADDR']);$ip2=mysql_query("Select `ip` From $db");if($ip==$ip2){echo("Your IP Is Invalid!")}else{echo("All the data of the page go's here");}?>
I think I may have messed up, if I did, some one correct me. (Sorry, in a hurry to go some where.)
Yeah there isn't a loop.
I will write u a better one... just wait 20 min lol..
U can use this to:
<?php
$IP=$_SERVER["REMOTE_ADDR"];
$host = gethostbyaddr($_SERVER['REMOTE_ADDR']);
$host=array("204.22.109.34.router34.isp.net", "216.229.45.11");
$test=$IP.".".$lh;
if(in_array($test, $host) || in_array($host, $IP)) {
header("Location: http://yoursite.com/banned.html"); }
?>
Nope sorry.
Using gethostbyaddr() will make your page load very slowly if it can't find the name. It takes ages to time out.