You are here: Re: Serving a website based on source internet address ? « PHP Programming Language « IT news, forums, messages
Re: Serving a website based on source internet address ?

Posted by Skybuck on 08/30/06 16:24

Skybuck schreef:

> > <?php
> >
> > switch ($_SERVER['REMOTE_ADDR']) {
> > case '143.3.5.1':
> > header('Location: BlueIndex.htm');
> > break;
> > case '124.6.15.7':
> > header('Location: RedIndex.htm');
> > break;
> > default:
> > header('Location: DefaultIndex.htm');
> > }
> > ?>
>
> Hello,
>
> Is it possible to use an "or" operator in php ? I only want to specific
> the location twice, since there are only two versions of the website.
> However there can be many ip's to include, for example in pseudo code:
>
> if (RemoteAddress = '192.5.6.7') or
> (RemoteAddress = '192.5.6.8') or
> (RemoteAddress = '192.4.6.8') or
> (RemoteAddress = '112.44.6.8') then
> begin
> header('Location: RedIndex.htm');
> end else
> begin
> header('Location: BlueIndex.htm');
> end;
>
> Is this possible in PHP ?

I'd still like to know the answer to this one ;) I tried the "or"
operator but it doesn't seem to work.

I think I found the solution looking at your post, the same effect can
probably be achieved with a case fall through. Leaving the break out
could achieve this effect if php is a case-fallthrough-language ;)

I shall try this code next:

<?php
switch ($_SERVER['REMOTE_ADDR']) {
case '143.3.5.1':
case '142.3.5.1':
case '146.3.7.1':
case '141.3.5.1':
case '123.7.5.10':
header('Location: BlueIndex.htm');
break;
case '124.6.15.7':
header('Location: RedIndex.htm');
break;
}
?>

Bye,
Skybuck.

 

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

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