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

Posted by Hugh Janus on 09/28/18 11:49

"carmen" <dddd@kkdi.cka> wrote in message
news:KU9hg.246937$P01.8300@pd7tw3no...
>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 *************
>

Would this work?

<?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") {

************* REST OF THE SCRIPT *************

die();
}
}
BANNED MESSAGE HERE

 

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

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