Dynamic IP banner

This is guide mostly for website tools and code, for example CMS or registration scripts.
There can also be tools.

Moderators: osRose dev team, ospRose dev team, osiRose dev team, Moderators

Dynamic IP banner

Postby Rifke on Sun Sep 09, 2007 4:39 pm

  1.  
  2. <?php
  3. $IP[] = '192.*.*.*';       
  4. $IP[] = '192.168.*.*';
  5. $IP[] = '192.168.1.*';     
  6. $IP[] = '192.168.1.100';   
  7. $IP[] = '*.*.*.*';         
  8.  
  9. $IPadres = $_SERVER['REMOTE_ADDR'];
  10. foreach( $IP as $pointer => $blip) {
  11.     $pattern = str_replace('.','\.',$blip);
  12.     $pattern = str_replace('*','(.*)',$pattern);
  13.    
  14.     if ( ereg($pattern, $IPadres)) {
  15.       //Your error message
  16.         die('Banned o.O');
  17.     } else {
  18.         // Your normal content
  19.     }
  20. }
  21. ?>
  22.  

This is quite dangerous. You can block your own access if you set it worng. Not to mention the whole world :).

It's rather simple. And IP is in the order of xxx.xxx.xxx.xxx

with dynamic IP the last xxx do change most of the time. So you could set a range block on those.

You'll add an the ip like 127.014.154.* . It will block all ip that are in the area of 127.014.154.0-255. At least it should.


  1.  
  2. Blocked: 192.168.1.100 -> IPblock:192.*.*.*
  3. Blocked: 192.168.1.100 -> IPblock:192.168.*.*
  4. Blocked: 192.168.1.100 -> IPblock:192.168.1.*
  5. Blocked: 192.168.1.100 -> IPblock:192.168.1.100
  6. Blocked: 192.168.1.100 -> IPblock:*.*.*.*
  7.  
Rifke
Pero pero
Pero pero
 
Posts: 719
Joined: Thu Aug 09, 2007 3:01 pm
Location: Belgium

Re: Dynamic IP banner

Postby blacksnow on Tue Sep 11, 2007 6:56 am

thx, its helpful
blacksnow
Pomic
Pomic
 
Posts: 81
Joined: Sat Aug 25, 2007 6:35 am


Return to PHP / Web Guides, Scripts and tools.

Who is online

Users browsing this forum: No registered users and 8 guests