Jump to content

Need Help with IP redirecting please


486974

Recommended Posts

Hi all,

I am trying to add this script to a calendar availability button so if the user is in the UK it redirects to the UK pound calendar and if you are in the USA/Canada it goes to the USA dollar calendar and anywhere else in the world goes to the default calendar which is the UK pound one i have tried with header but can only get one url to work. The section of code i have highlighted in bold is where we think the problem is Please help

 

<?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("http://www.disneysvacationvillarentals.net/data.dat");
[b]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++; 
}
{[/b]
}
if(sizeof($list) != "0") {
for ($i=0; $i<sizeof($list); $i++){
$p=explode(';', $list[$i]);
switch ( $p[4] )
{
case 'UNITED KINGDOM'  : ("http://www.rentalsystems.com/advert_price.asp?ref=51648&rag=47967B&rcam=ownerweb/");
             break;
case 'United States'  : ("http://www.rentalsystems.com/advert_price.asp?ref=51646&rag=47967B&rcam=ownerweb/");
             break;
case 'Canada'  : ("http://www.rentalsystems.com/advert_price.asp?ref=51646&rag=47967B&rcam=ownerweb/");
             break;
default : ("http://www.rentalsystems.com/advert_price.asp?ref=51648&rag=47967B&rcam=ownerweb/");
             break;
}
}
}else{echo "Unable to determine your country"; }

?>

Link to comment
https://forums.phpfreaks.com/topic/101973-need-help-with-ip-redirecting-please/
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.