Jump to content

Multiple location headers


Suchy

Recommended Posts

<?php
if (getenv(HTTP_X_FORWARDED_FOR)=="") 
$ip = getenv(REMOTE_ADDR);
else 
$ip = getenv(HTTP_X_FORWARDED_FOR);

$numbers=explode (".",$ip);
$code=($numbers[0] * 16777216) + ($numbers[1] * 65536) + ($numbers[2] * 256) + ($numbers[3]);    
$lis="0";
$user = file("data.dat");

for($x=0;$x<sizeof($user);$x++) 
{
$temp = explode(";",$user[$x]);
$opp[$x] = "$temp[0];$temp[1];$temp[2];$temp[3];$temp[4];";
if($code >= $temp[0] && $code <= $temp[1]) 
{
	$list[$lis] = $opp[$x];
	$lis++; 
}
}

if(sizeof($list) != "0") 
{
for ($i=0; $i<sizeof($list); $i++)
{
	$p=explode(';', $list[$i]);
//	echo "You are from $p[4]";
	if ($p[4] == "UNITED_STATES")
		header ("Location: en/index.php");
	elseif ($p[4] == "FRANCE")
		header ("Location: fr/index.php");
	elseif ($p[4] == "POLAND")
		header ("Location: pl/index.php");
	elseif ($p[4] == "ITALY")
		header ("Location: it/index.php");

}
} 
else
{
   //	echo "Unable to determine your country"; 
   header ("Location: pl/index.php");
}
?>

 

The problem is that this script does not redirect the visitor to the right folder.

What is causing this, the multiple headers ???

Link to comment
https://forums.phpfreaks.com/topic/87631-multiple-location-headers/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.