| |
puccavn Noogle

Joined: 12 Apr 2005
1021.15 GC$
Items
|
Posted: Thu May 05, 2005 11:51 pm Post subject: PHP IP Ban |
|
|
|
1. What it does
IP banning someone from your site will effectivly stop all access they have to your website. Make sure you ban wisely
2. The Code
The code is fairly simple, we will set the $banned variable using an array. It is here were we will enter IP address we wish to ban. Then, using the global variable $REMOTE_ADDR to give us the user's IP address, we can check if it is in the $banned array. If not, we let them carry on. If it is found in the $banned array, using the die() fuction, we can remove all access to the site from that IP.
<?php
$banned = array("1.1.1.1", "2.2.2.2", "3.3.3.3");
(in_array("$REMOTE_ADDR", $banned_addresses)) {
die("You have been banned from this site");
}
?>
3. Adding the ban filter
Save the above into ban.php or similar, then include it on all the pages you want it to be effective on, using the include() fuction.
Please contact us if you enjoyed this tutorial, or find any typos, etc |
|
| Back to top |
|
|
Sponsored Links
|
Posted: 5 Dec 2008 10:18 am Post subject: Advertisements |
|
|
|
|
|
|
| Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Host your free forums with Invision Plus.net forum web hosting with your own subdomain.
alexisBlue v1.2 // Theme Created By: Andrew Charron // Icons in Part By: Travis Carden
|
|
|
|
|