Home Forum Search Contact Us Advertise
Pages: [1]   Go Down
  Print  
Tutorial: IP Banning  (Read 2348 times)
*

Offline Offline

Posts: 49
T$0.00

View Profile WWW
« on: April 20, 2007, 12:16:13 AM »


New Tutorial has been published in PHP:

IP Banning
Learn how to ban a single IP or multiple IP addresses from accessing your website.

Please click here to view the Tutorial. This thread is for comments and discussion about the submitted Tutorial.
Logged

Resident bot of Templora.com.
*


Offline Offline

Posts: 86
T$10218.00

View Profile WWW
« Reply #1 on: June 22, 2007, 09:08:02 PM »

There was a small error in the code that i used in the Tutorial. This has now been fixed. Thanks to Mark for letting me know.

If anyone had tried this without getting the result, i advice to try this new updated code.

Logged

Darkman
Temploran Admin
*

Offline Offline

Posts: 1
T$0.00

View Profile
« Reply #2 on: February 12, 2008, 07:09:31 AM »

There is also a shorter way:

Code:
<?php 

// The ip addresses to be banned separated by |
$ban "34.43.97.31|86.53.73.27|41.107.14.621";

// Store current user's IP in a variable
$visitor $_SERVER['REMOTE_ADDR'];

// Split the IPs using |
$list explode("|"$ban);
if(
in_array($visitor$list)) {
   die(
"You are banned from this site");
}

?>


Also note, that this wont always work. Not because your code is wrong, but some people have a dynamic IP so it wont always be the same. Another case of when it wont work is if the user is using a Proxy.
Logged
*

Offline Offline

Posts: 4
T$34.00

View Profile
« Reply #3 on: May 11, 2010, 12:32:40 AM »

Great tutorial . learnt a lot from this. Thanks once again.
____________________________________________

Chairs
Logged
*

Offline Offline

Posts: 6
T$50.00

View Profile
« Reply #4 on: June 15, 2010, 10:52:18 AM »

never seen such a descriptive and educative tutorial on such an important topic. its amazing how such an important matter has escaped the attention of professionals for so long.
Proofreading
SEO Copywriting
Logged
Pages: [1]   Go Up
  Print  
« previous next »
 
Jump to: