Reply to Re: BAN IP (second try)

Your name:

Reply:


Posted by John on 05/22/06 12:59

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

Honour to you!!


"Erwin Moller"
<since_humans_read_this_I_am_spammed_too_much@spamyourself.com> wrote in
message news:4471890c$0$31639$e4fe514c@news.xs4all.nl...
> John wrote:
>
>> 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: 123.123.123.12
>>
>> Is that possible through PHP? I don't want to mess up with .htaccess
>> files
>> and so on.
>>
>> Code?
>
> Hi,
>
> Why not approach this with plain strings?
>
> $ip = SERVER['REMOTE_ADDR'];
> $allowIP = array('123.123.123.12' , '123.123.123.115');
>
> $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.
>
> Regards,
> Erwin Moller

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация