473,396 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Serving a website based on source internet address ?

Hello,

Based on the source internet address a different version of the website
should be presented/served to the user/browser.

I would like to keep the script as simple as possible and it should
replace the index.php.

The script could look something like this in pseudo code:

if SourceAddress = '143.3.5.1' then
begin
ShowBlueWebsite; // load/show BlueIndex.htm
end else
if SourceAddress = '124.5.15.7' then
begin
ShowRedWebsite; // load/show RedIndex.htm
end;

Is this possible with php ?

Bye,
Skybuck.

Aug 29 '06 #1
5 1288
Skybuck wrote:
Hello,

Based on the source internet address a different version of the website
should be presented/served to the user/browser.

I would like to keep the script as simple as possible and it should
replace the index.php.

The script could look something like this in pseudo code:

if SourceAddress = '143.3.5.1' then
begin
ShowBlueWebsite; // load/show BlueIndex.htm
end else
if SourceAddress = '124.5.15.7' then
begin
ShowRedWebsite; // load/show RedIndex.htm
end;

Is this possible with php ?

Bye,
Skybuck.
Sure.

<?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');
}
?>

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Aug 29 '06 #2
<?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 ?

Bye,
Skybuck.

Aug 30 '06 #3

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.

Aug 30 '06 #4
Skybuck wrote:
>><?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 ?

Bye,
Skybuck.
Did you try looking this up in the manual?

Yes, it is possible - see
http://www.php.net/manual/en/languag...rs.logical.php.

But your problem is in how your if statement is constructed. See
http://www.php.net/manual/en/languag...-structures.if
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Aug 30 '06 #5
"Jerry Stuckle" <js*******@attglobal.netwrote in message
news:E8******************************@comcast.com. ..
Skybuck wrote:
><?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 ?

Bye,
Skybuck.

Did you try looking this up in the manual?

Yes, it is possible - see
http://www.php.net/manual/en/languag...rs.logical.php.

But your problem is in how your if statement is constructed. See
http://www.php.net/manual/en/languag...-structures.if
>
How about 'in_array()'?

$ip_arr = array('192.5.6.7',
'192.5.6.8',
'192.4.6.8',
'112.44.6.8'
);
if (in_array($_SERVER['REMOTE_ADDR'], $ip_arr))
{
header('Location: RedIndex.htm');
}
else
{
header('Location: BlueIndex.htm');
}

.... not sure if you need to use the full domain name in the header function
or not.

Norm
Aug 30 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: john Q | last post by:
I found a PHP based email obfuscator for use in websites, where the source HTML (PHP, actually) file doesn't contain the actual email address in the Mailto tag, but generates it and that...
11
by: Bozo Schmozo | last post by:
Greetings! I've searched groups.google.com already to see if I can determine if using PHP/MySQL (if needed) for a web site I wish to develop. As the subject indicated, it will be a content...
10
by: JP Bless | last post by:
Hi all, I have a database Access/MSDE and would like to have a website so users can search the data and update some records/fields through the website.... And I have high speed internet...
21
by: Nicholas Sherlock | last post by:
Hey all, People on my website register to be allowed access to certain downloads. I store these files above the document root so that they can't be accessed by Apache (Only from PHP). I wrote a...
3
by: Navodit | last post by:
Hi I have a problem in which I am not sure if Javascript can or should be used. If anyone can throw light on this it wd be great : Basically I am working on the development of a database where...
3
by: Navodit | last post by:
Hi I have a very basic question regd retrieving information from website using a scripting language: Basically I am working on the development of a database where a user enters an address...
2
by: Skybuck | last post by:
Hello, Based on the source internet address a different version of the website should be presented/served to the user/browser. For example in pseudo code: if SourceAddress = '143.3.5.1'...
2
by: Skybuck | last post by:
Hello, Based on the source internet address a different version of the website should be presented/served to the user/browser. For example in pseudo code: if SourceAddress = '143.3.5.1'...
1
by: Skybuck | last post by:
Hello, Based on the source internet address a different version of the website should be presented/served to the user/browser. For example in pseudo code: if SourceAddress = '143.3.5.1'...
6
by: Mandar | last post by:
Hi, I have written some code in C# to programmatically create a website and an application pool. Both seems to be getting created alright with whatever settings I have applied. However, when I...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.