Please login or register. Welcome to the Studio, guest!


Quick Links:


newBookmarkLockedFalling

Boag

Boag Avatar
Yo Yo Ma!

**
Official Member

65


September 2005
This script, basically, will stop a user viewing a page of your site if you add their IP to the list at the top, just paste this code at the top of every page of your site or save it as banned.php and put:

<?php include("banned.php"); ?>

at the top of every page.

<?php
$banned_ip = array();
$banned_ip[] = '111.111.111.111';
$banned_ip[] = '111.111.111.112';
$banned_ip[] = '111.111.111.113';
$banned_ip[] = '111.111.111.114';

foreach($banned_ip as $banned) {
$ip = $_SERVER['REMOTE_ADDR'];
if($ip == $banned){
echo "You have been banned!";
exit();

}
}
?>



Chris

Chris Avatar

******
Head Coder

19,519


June 2005
Personally, it'd be easier to use "die('You have been banned!');" :P But echo then exit() work fine.

Nate

Nate Avatar

**
Official Member

85


July 2007
What does die() do?
End the document?

Chris

Chris Avatar

******
Head Coder

19,519


June 2005
Ends all PHP script after it from exicuting I believe.

Kai

Kai Avatar

**
Official Member

66


September 2005
die() would end everything. HTML included, i believe.

die() also takes in an optional parameter, which allows you to post a message.
Religion should be put back in its place - beneath man, not above him.

newBookmarkLockedFalling