You are here: Re: Tweaking a script « All PHP « IT news, forums, messages
Re: Tweaking a script

Posted by Jerry Stuckle on 09/28/41 11:49

carmen wrote:
> I came across this free script on the net that compares the IP address of a
> surfer to a list (1.list). If there is a match, the surfer gets the message
> banned. If there is no match, the rest of the php script runs.
>
> Is there an easy way to tweak the file so that
> 1. If there is a match of the surfers IP address to one in the list
> (1.list), rather then get a banned message, the rest of the php script runs.
> 2. If the surfers IP address does not match any of the IP address in the
> list (1.list), then instead of echo 'banned'; the surfer is redirected to
> another webpage.
>
> Thank you
>
> <?php
> $IP = $_SERVER['REMOTE_ADDR'];
> $IP_array = file('../info/1.list');
> $IP_array = str_replace("\n", "", $IP_array);
> $IP_array = str_replace("\r", "", $IP_array);
> foreach ($IP_array as $IP_test) {
> if (substr_count($IP, $IP_test) != "0") {
>
> echo 'banned';
>
> die();
> }
> }
> ************* REST OF THE SCRIPT *************
>
>

Are you using Apache? If so - just use their configuration directives - either
in httpd.conf or .htaccess.

Much easier to use the correct tool for the job.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

 

Navigation:

[Reply to this 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

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