[PHP] Simple IP Ban

CrzYMikE

Member
Reputation
0
PHP:
<?php
$ips=array("127.0.0.1",
"IP",
"IP",
"IP");

foreach ($ips as $ip)
{
	if($_SERVER['REMOTE_IP']==$ip)
	{
		exit("You got banned!")
	}
}
?>

I'm sure someone will find use of this.
 
RE: Simple IP Ban

Didn't somebody already post this? I may be wrong.
 
RE: Simple IP Ban

God said:
Didn't somebody already post this? I may be wrong.

I don't think so...
Came up with this a while back, felt like posting it... o.0
 
RE: Simple IP Ban

Just do something like...

PHP:
<?php

$ip[] = "127.0.0.1";
$ip[] = "";

foreach($ip as $ips){
if(in_array($_SERVER['REMOTE_ADDR'], $ips))
die("banned");

}
?>
 
RE: Simple IP Ban

Maybe this could be useful to prevent your site being DDoSed.

Thanks!
 
Back
Top