Need a cloaking script or help from a coder

Status
Not open for further replies.

erifdekciw

New member
May 3, 2008
2,144
51
0
Rating - 100%
5   0   0
I need someone who knows what there doing with php who can explain to me how to use this code and implement it to my specifications or either help me build one from scratch if this code i got doesn't do what i want it to do.

PM me for more info.
 


ok i got this code off bhw and now i need to know how to use it.

<?php
if ($_SERVER["HTTP_X_FORWARDED"])
{
$ip = $_SERVER["HTTP_X_FORWARDED"];
}
elseif ($_SERVER["HTTP_FORWARDED_FOR"])
{
$ip = $_SERVER["HTTP_FORWARDED_FOR"];
}
elseif ($_SERVER["HTTP_FORWARDED"])
{
$ip = $_SERVER["HTTP_FORWARDED"];
}
elseif ($_SERVER["HTTP_X_FORWARDED"])
{
$ip = $_SERVER["HTTP_X_FORWARDED"];
}
else
{
$ip = $_SERVER["REMOTE_ADDR"];
}

$geo = unserialize(file_get_contents('http://www.geoplugin.net/php.gp?ip='.$ip));
$city = $geo['geoplugin_city'];

switch($city)
{
case "Dallas": <redirect to your targetted city page>;
break;

default: <redirect everyone else to this page>;
break;
}
?>

ive created a php page with this code in it and nothing else. how do i use it properly?

i've tried changing the city and puttin a url in the redirect to your targetted page line but when i upload it and go to the site the page lists a parse error on line 28 which is the case "Dallas": line.

how do i fix this and am i doing this correctly? do i need to have anything else on my page? 25$ for someone can help me figure this out.
 
Hey here, hope his helps you out ...

PHP:
// this records your visiting surfer's IP address ...
$checkip = $_SERVER['REMOTE_ADDR'];

// or you could debug by using ... $checkip = "72.167.115.223"; ... which is my IP address that returned the sample data below


// for debugging purposes, this grabs the data but not in the form of an array, we will echo this to see all the variables available we can use
$geoData = file_get_contents('http://www.geoplugin.net/php.gp?ip='.$checkip);

// output the data to debug
echo $geoData."<br /><br />";

// for me the data below was output ...
/*
a:14:{s:14:"geoplugin_city";s:10:"Scottsdale";s:16:"geoplugin_region";s:2:"AZ";s:18:"geoplugin_areaCode";s:3:"480";s:17:"geoplugin_dmaCode";s:3:"753";s:21:"geoplugin_countryCode";s:2:"US";s:21:"geoplugin_countryName";s:13:"United States";s:23:"geoplugin_continentCode";s:2:"NA";s:18:"geoplugin_latitude";s:13:"33.6119003296";s:19:"geoplugin_longitude";s:14:"-111.890701294";s:20:"geoplugin_regionCode";s:2:"AZ";s:20:"geoplugin_regionName";s:7:"Arizona";s:22:"geoplugin_currencyCode";s:3:"USD";s:24:"geoplugin_currencySymbol";s:5:"$";s:27:"geoplugin_currencyConverter";d:1;}
*/

// lets grab the data a second time, but this time combine it into an array 
$geo = unserialize(file_get_contents('http://www.geoplugin.net/php.gp?ip='.$checkip));

// out of all the data returned, this isolates the city
$city = $geo['geoplugin_city'];

// lets go one step further and also grab the country which is found in the debugging code returned above
$country = $geo['geoplugin_countryCode'];

// spitting it all out ...
echo "I am a visitor from $country country, from the city of $city";
Paste the above into a blank page and hopefully you can reason out how to use the data. Cheers.
 
Last edited:
  • Like
Reactions: erifdekciw
Next you want to do something with the data ... the former script used a switch which is kind of crazy, what they expect you to do insert a list of every city in the world for the switch? What I would do is something a little more like this ...
PHP:
$dashCity = str_replace(" ","-",$city);
Header( "Location: http://".$_SERVER["HTTP_HOST"]."/$dashCity/" );
The above code would redirect your visitors to your page for that city. Assuming that was a Dallas page it would look like www.example.com/Dallas/ ... the str_replace puts dashes in there for cities with two words. Or you could have done it Header( "Location: http://".$_SERVER["HTTP_HOST"]."/?city=$dashCity/" ); many options

Hope this helps, cheers.
 
Status
Not open for further replies.