phpfail
Regular Member
- Aug 21, 2011
- 236
- 107
This is the PHP code needed to geo-target your traffic. It must be installed onto a web page with a .php extension:
You can then call to the visitor with:
Code:
[LEFT][COLOR=#007700][FONT=monospace]function [/FONT][/COLOR][COLOR=#0000BB][FONT=monospace]visitorCountry[/FONT][/COLOR][COLOR=#007700][FONT=monospace](){
[/FONT][/COLOR][COLOR=#0000BB][FONT=monospace]$ip [/FONT][/COLOR][COLOR=#007700][FONT=monospace]= [/FONT][/COLOR][COLOR=#0000BB][FONT=monospace]getenv[/FONT][/COLOR][COLOR=#007700][FONT=monospace]([/FONT][/COLOR][COLOR=#DD0000][FONT=monospace]'REMOTE_ADDR'[/FONT][/COLOR][COLOR=#007700][FONT=monospace]);
[/FONT][/COLOR][COLOR=#0000BB][FONT=monospace]$d [/FONT][/COLOR][COLOR=#007700][FONT=monospace]= [/FONT][/COLOR][COLOR=#0000BB][FONT=monospace]file_get_contents[/FONT][/COLOR][COLOR=#007700][FONT=monospace]([/FONT][/COLOR][COLOR=#DD0000][FONT=monospace]"http://www.ipinfodb.com/ip_query_country.php?ip=[/FONT][/COLOR][COLOR=#0000BB][FONT=monospace]$ip[/FONT][/COLOR][COLOR=#DD0000][FONT=monospace]&output=xml"[/FONT][/COLOR][COLOR=#007700][FONT=monospace]);
[/FONT][/COLOR][COLOR=#FF8000][FONT=monospace]//Use backup server if cannot make a connection
[/FONT][/COLOR][COLOR=#007700][FONT=monospace]if (![/FONT][/COLOR][COLOR=#0000BB][FONT=monospace]$d[/FONT][/COLOR][COLOR=#007700][FONT=monospace]){
[/FONT][/COLOR][COLOR=#0000BB][FONT=monospace]$backup [/FONT][/COLOR][COLOR=#007700][FONT=monospace]= [/FONT][/COLOR][COLOR=#0000BB][FONT=monospace]file_get_contents[/FONT][/COLOR][COLOR=#007700][FONT=monospace]([/FONT][/COLOR][COLOR=#DD0000][FONT=monospace]"http://backup.ipinfodb.com/ip_query.php?ip=[/FONT][/COLOR][COLOR=#0000BB][FONT=monospace]$ip[/FONT][/COLOR][COLOR=#DD0000][FONT=monospace]&output=xml"[/FONT][/COLOR][COLOR=#007700][FONT=monospace]);
[/FONT][/COLOR][COLOR=#0000BB][FONT=monospace]$answer [/FONT][/COLOR][COLOR=#007700][FONT=monospace]= new [/FONT][/COLOR][COLOR=#0000BB][FONT=monospace]SimpleXMLElement[/FONT][/COLOR][COLOR=#007700][FONT=monospace]([/FONT][/COLOR][COLOR=#0000BB][FONT=monospace]$backup[/FONT][/COLOR][COLOR=#007700][FONT=monospace]);
if (![/FONT][/COLOR][COLOR=#0000BB][FONT=monospace]$backup[/FONT][/COLOR][COLOR=#007700][FONT=monospace]) return [/FONT][/COLOR][COLOR=#0000BB][FONT=monospace]false[/FONT][/COLOR][COLOR=#007700][FONT=monospace]; [/FONT][/COLOR][COLOR=#FF8000][FONT=monospace]// Failed to open connection
[/FONT][/COLOR][COLOR=#007700][FONT=monospace]}else{
[/FONT][/COLOR][COLOR=#0000BB][FONT=monospace]$answer [/FONT][/COLOR][COLOR=#007700][FONT=monospace]= new [/FONT][/COLOR][COLOR=#0000BB][FONT=monospace]SimpleXMLElement[/FONT][/COLOR][COLOR=#007700][FONT=monospace]([/FONT][/COLOR][COLOR=#0000BB][FONT=monospace]$d[/FONT][/COLOR][COLOR=#007700][FONT=monospace]);
}
return [/FONT][/COLOR][COLOR=#0000BB][FONT=monospace]$answer[/FONT][/COLOR][COLOR=#007700][FONT=monospace]->[/FONT][/COLOR][COLOR=#0000BB][FONT=monospace]CountryCode[/FONT][/COLOR][COLOR=#007700][FONT=monospace];
} [/FONT][/COLOR][/LEFT]
You can then call to the visitor with:
Code:
[LEFT][COLOR=#0000BB][FONT=monospace]$geolocation [/FONT][/COLOR][COLOR=#007700][FONT=monospace]= [/FONT][/COLOR][COLOR=#0000BB][FONT=monospace]visitorCountry[/FONT][/COLOR][COLOR=#007700][FONT=monospace]();
if ([/FONT][/COLOR][COLOR=#0000BB][FONT=monospace]$geolocation[/FONT][/COLOR][COLOR=#007700][FONT=monospace]==[/FONT][/COLOR][COLOR=#DD0000][FONT=monospace]"US"[/FONT][/COLOR][COLOR=#007700][FONT=monospace]){[/FONT][/COLOR][COLOR=#0000BB][FONT=monospace]header[/FONT][/COLOR][COLOR=#007700][FONT=monospace]([/FONT][/COLOR][COLOR=#DD0000][FONT=monospace]"location:http://www.UStrafficpage.com/"[/FONT][/COLOR][COLOR=#007700][FONT=monospace]);exit;}
if ([/FONT][/COLOR][COLOR=#0000BB][FONT=monospace]$geolocation[/FONT][/COLOR][COLOR=#007700][FONT=monospace]==[/FONT][/COLOR][COLOR=#DD0000][FONT=monospace]"GB"[/FONT][/COLOR][COLOR=#007700][FONT=monospace]){[/FONT][/COLOR][COLOR=#0000BB][FONT=monospace]header[/FONT][/COLOR][COLOR=#007700][FONT=monospace]([/FONT][/COLOR][COLOR=#DD0000][FONT=monospace]"location:http://www.GBtrafficpage.com/"[/FONT][/COLOR][COLOR=#007700][FONT=monospace]);exit;}[/FONT][/COLOR][/LEFT]