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

Geo-Targeted URLS?

Discussion in 'Black Hat SEO' started by blackxxxer, Jan 1, 2009.

  1. blackxxxer

    blackxxxer BANNED BANNED

    Joined:
    Oct 29, 2008
    Messages:
    137
    Likes Received:
    57
    Does anyone know of or have a script that geo-targets url's by country? I need something that will detect the ip/country & send the user to a URL based off country?

    Thanks
     
  2. cyklotrial

    cyklotrial Regular Member

    Joined:
    Oct 13, 2008
    Messages:
    248
    Likes Received:
    82
    Location:
    Wonderland
    Use the power of SEARCH button... :p

    My script....
    one among many on this forum
    PHP:
    <?php 

    // Get country code corresponding to an IP address 



    function get_country_code ($ip) {

    $c curl_init();

    curl_setopt($cCURLOPT_URL"http://www.topwebhosts.org/whois/index.php?query=$ip");//otwieramy Å‚acze ze strona

    curl_setopt($cCURLOPT_HEADER1);

    curl_setopt($cCURLOPT_VERBOSE1);

    curl_setopt($cCURLOPT_RETURNTRANSFER,1);

    curl_setopt($cCURLOPT_USERAGENT'Mozilla/5.0 (X11; U; Linux i686;pl; rv:1.8.0.3) Gecko/20060426 Firefox/1.5.0.3');

    curl_setopt($cCURLOPT_ENCODING'gzip');

    curl_setopt($cCURLOPT_ENCODING'deflate');

    curl_setopt($cCURLOPT_ENCODING'');

    curl_setopt($cCURLOPT_FOLLOWLOCATION1);

    $page curl_exec($c);

    $code explode('country',$page);

    $code explode(':',$code[1]);

    $code explode('admin-c:',$code[1]);

    $country_code=trim($code[0],"admin-c:");

    return 
    $country_code;

    }

    // Detect user's IP address

    $user_ip $_SERVER["REMOTE_ADDR"];



    // COUNTRY CODE, eg. us, fr, vn

    $country_code get_country_code($user_ip);



    switch(
    $country_code)

        {

            case 
    'US':

                
    //redirect to US page            

                
    break;

            case 
    'UK':

                
    //redirect to FR page            

                
    break;

            case 
    'CAN':

                
    //redirect to CAN page            

                
    break;

            case 
    'AUS':

                
    //redirect to AUS page            

                
    break;

    //etc...etc...etc here you can ad more countries 

            
    default://other coutries

                //default redirect

        
    }





    ?>

     
    • Thanks Thanks x 1
  3. indexyoursite

    indexyoursite Jr. VIP Jr. VIP Premium Member

    Joined:
    Nov 19, 2008
    Messages:
    262
    Likes Received:
    219
    Occupation:
    Day Job: Latin Lover
    Location:
    I´ll check my GPS & tell you
    Download and use ip2nation.com Mysql database and scripts, they are free. Also you can use openads it's an open source ad management application.:yield:
     
    • Thanks Thanks x 1
  4. trophaeum

    trophaeum Senior Member

    Joined:
    Dec 21, 2007
    Messages:
    1,189
    Likes Received:
    706
    maxmind.com - PURCHASE their geoip country db, its the ONLY accurate database, then use http://pear.php.net/package/Net_GeoIP to do lookups
     
    • Thanks Thanks x 1
  5. fatboy

    fatboy Elite Member

    Joined:
    Aug 13, 2008
    Messages:
    1,618
    Likes Received:
    3,227
    Occupation:
    Retired
    Location:
    Old Peoples Home
    • Thanks Thanks x 1
  6. xiphre

    xiphre Regular Member

    Joined:
    Jun 9, 2007
    Messages:
    290
    Likes Received:
    84
    Location:
    EU
    Yeah use Maxmind. There is a free, not as acurate as the paid one, but still worth a shot.
     
    • Thanks Thanks x 1
  7. zone69

    zone69 Junior Member

    Joined:
    Nov 24, 2008
    Messages:
    196
    Likes Received:
    1,290
    I use maxmind with the free geolite db which is quite accurate and updated monthly. You could always buy the commercial db if you needed to and use the same code. The only thing that would change is the binary db you download.

    I have posted a script already as well as instructions here already :


    http://www.blackhatworld.com/blackh...ne-code-me-php-geo-targetting.html#post410382


    Personally I would not use geotargetting code where you cannot keep the db locally as you introduce a dependency of an external http call to get the results and this could fail. Just another thing that can fail. This is just my opinion.

    Hope this helps!
     
    • Thanks Thanks x 1
  8. sikx

    sikx Registered Member

    Joined:
    Jan 4, 2009
    Messages:
    65
    Likes Received:
    166
    Location:
    Germany
    Home Page:
    Code:
    http://nytemarez.com/geofiltering-the-right-way/
     
    • Thanks Thanks x 1
  9. zone69

    zone69 Junior Member

    Joined:
    Nov 24, 2008
    Messages:
    196
    Likes Received:
    1,290
    I'd prefer to not use a mysql db for geofiltering since it would mean importing data every month into a db AND would make it a much bigger pain in the ass to move to other servers. Using the method I posted with a binary db file you could just copy the files to another server for a working solution.

    Each to their own, I guess.

    BTW, not sure you should be promoting your new blog on your 1st post with a live link!
     
    • Thanks Thanks x 2
  10. sikx

    sikx Registered Member

    Joined:
    Jan 4, 2009
    Messages:
    65
    Likes Received:
    166
    Location:
    Germany
    Home Page:
    With binary files (even with PEAR) you are making access incredibly slow compared to a well-indexed database table. Also I don't find it very hard to setup a cronjob which basically imports the new database everyday. If you setup a UNIQUE-constraint on start_ip and end_ip you will have no problems importing it in less than 30 secs. Don't know about you, but for my solution I needed very quick data access, especially since I'm getting alot of hits everyday.
     
    • Thanks Thanks x 1
  11. blackxxxer

    blackxxxer BANNED BANNED

    Joined:
    Oct 29, 2008
    Messages:
    137
    Likes Received:
    57
    Thanks everyone for the help. Thanks given to all.
     
  12. helaughs

    helaughs Registered Member

    Joined:
    Nov 26, 2008
    Messages:
    98
    Likes Received:
    19
    Yeah I use maxmind's commercial DB, considering the amount of money that is at stake $15/month for accurate country codes is well worth it to me.
     
  13. trophaeum

    trophaeum Senior Member

    Joined:
    Dec 21, 2007
    Messages:
    1,189
    Likes Received:
    706
    http://pecl.php.net/package/geoip if you need as fast as possible, there is nothing faster (not even sql queries) to get the data from the maxmind stuff
     
    • Thanks Thanks x 1