1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

geotarget script

Discussion in 'General Scripting Chat' started by appleman, Jan 4, 2010.

  1. appleman

    appleman Regular Member

    Joined:
    Oct 30, 2009
    Messages:
    358
    Likes Received:
    97
    hey looking for a geotarget script I can implement easily on a html page...
    Just need visitors from U.S. to be sent to one page while everyone else goes to a different page..
    willing to pay small amount if you someone can tweak it out or whatever is needed...ive seen some scripts around but they dont look easy
     
  2. showboytridin

    showboytridin Regular Member

    Joined:
    Sep 5, 2009
    Messages:
    348
    Likes Received:
    714
    Location:
    127.0.0.1
    You need a database with ips and use some code to detect the country and then redirect.

    This one is free and updated:

    Code:
    http://software77.net/geo-ip/
    You will need something like PHP for this.
     
  3. n2zen

    n2zen Regular Member

    Joined:
    Sep 27, 2009
    Messages:
    269
    Likes Received:
    70
    Go to maxmind and download the free geolite country binary database:
    Go to their php api folder - get geoip.inc - upload those two file onto your server

    Save the following as whatever.php you want, changing the include and path line below it to suit.

    PHP:
    <?php
    include("pathorsubdirectoryifrequired/geoip.inc");
    $gi geoip_open("/home/youraccount/public_html/subdir1/subdir2/GeoIP.dat",GEOIP_STANDARD);
    $rmt getenv("REMOTE_ADDR");
    $record geoip_country_code_by_addr($gi,$rmt);
    if (
    $record="US") {
      
    $goto "http://www.yankeedoodle.com/";
    }
    else {
      
    $goto "http://www.someothersite.com/";
    }
    header("Location: $goto");
    ?>
    Finally, if you're not familiar with how to include php inside html, check out: