Advertisement

Free Geo IP Script : For Specific pages for countries

 (Read 7156 times)

Admin

  • Administrator
  • Hero Member
  • *****
  • Posts: 1549
    • The Jucktion
This php script is a simple geo ip redirect script to direct the people from different countries to different pages (translated or targeted) to get more loyal visitors.

Instructions:
1. Save the quoted text as index.php (MAKE SURE ITS .PHP)

2. Create the files indexu.htm, indexa.htm, indexd.htm, indexg.htm, indexc.htm, indexr.htm put these in the same folder. The source code is very simple to read and understand how it works. US, AU, DE, GB, CA are the country codes, Default is for all the rest of the countries. (Could set a toolbar PPI offer to these or something)

3. Create Double meta refreshes or simple redirects on all these index*.htm to country specific offers.

Code: [Select]
<?

$apirl = 'http://nl.ae/iptocapi.php?type=1&ip='.$_SERVER['REMOTE_ADDR'];
$country = $apiresp = file_get_contents($apirl);

function gotopage($pageurl){

if(strpos($pageurl,'http://')===0){
header('Location:'.$pageurl); exit;
} else {
$boom = explode($_SERVER['SCRIPT_NAME'],$_SERVER['REQUEST_URI']);
$url = $boom[0].'/'.$pageurl;
header('Location:'.$pageurl); exit;
}

}

switch($country){

case 'US': gotopage('indexu.htm'); break;
case 'AU': gotopage('indexa.htm'); break;
case 'DE': gotopage('indexd.htm'); break;
case 'GB': gotopage('indexg.htm'); break;
case 'CA': gotopage('indexc.htm'); break;

}

$apirl = 'http://api.hostip.info/country.php?ip='.$_SERVER['REMOTE_ADDR'];
$country = $apiresp = file_get_contents($apirl);

switch($country){

case 'US': gotopage('indexu.htm'); break;
case 'AU': gotopage('indexa.htm'); break;
case 'DE': gotopage('indexd.htm'); break;
case 'GB': gotopage('indexg.htm'); break;
case 'CA': gotopage('indexc.htm'); break;

default: gotopage('indexr.htm');

}

?>

credits to the author