BAN IP (second try)

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Say I want to ban all IPs in the range 123.123 X X from access to some areas  
on my server. BUT at the same time allow just ONE of the IPs which relies in  
this IP-range, for example:

Is that possible through PHP? I don't want to mess up with .htaccess files  
and so on.


Re: BAN IP (second try)

John wrote:

Quoted text here. Click to load it


Why not approach this with plain strings?

$allowIP = array('' , '');

$passOK = 'Y';
if (substr($ip,0,7) == '123.123'){
  // not welcome, unless in $allowIP
  if (in_array($ip,$allowIP)){
    $passOK = 'Y';
  } else {    
    $passOK = 'N';

If you need more complex fitting of IP-addresses than just simple  
'startstring-fitting', you'll need more complex code of course.

Erwin Moller

Re: BAN IP (second try)

Thanks, excellent, just what I was looking for!!!

Honour to you!!

"Erwin Moller"  
Quoted text here. Click to load it

Site Timeline