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

Cloaking only U.S. Visitors

Discussion in 'Cloaking and Content Generators' started by paperchaser, Nov 6, 2008.

  1. paperchaser

    paperchaser Guest

    Just wondering if its possible to cloak via geographical location?

    I need to show one version of the site to US visitors, and the real version of the site to all other visitors.

    Is this possible? Any help is greatly appreciated, thanks!
     
  2. frostbyte

    frostbyte Registered Member

    Joined:
    Nov 7, 2007
    Messages:
    56
    Likes Received:
    19
    Yup, that's possible, simply download the ip-to-country database here

    Code:
    http://ip-to-country.webhosting.info/downloads/ip-to-country.csv.zip
    
    and manipulate the data to retrieve all US IPs. Once you have the list of IPs, you can just input them into your cloaker's IP list.

    PS. Handbook for the database can be found here

    Code:
    http://ip-to-country.webhosting.info/node/view/12
    
     
  3. fatboy

    fatboy Elite Member

    Joined:
    Aug 13, 2008
    Messages:
    1,618
    Likes Received:
    3,227
    Occupation:
    Retired
    Location:
    Old Peoples Home
    You can easily do it on the fly using a bit of PHP, if your hosting accepts fopen (I can do it a different way if needed):

    PHP:

    <?php
        $user_ip 
    $_SERVER["REMOTE_ADDR"];
        
    $handle_cc fopen("http://maychu.net/ip/code/".$user_ip'r'); 
        
    $country_code fgets($handle_cc128); 
        
    fclose($handle_cc);

        switch(
    $country_code)
        {
            case 
    "US":        header("Location: http://Your_American_page");
                                  break;

          default:              
    header("Location: http://Where_the_rest_of_the_visitors_go");
                                  break;
    }


    ?>

    That should do ya!
     
  4. tekg0r

    tekg0r Junior Member

    Joined:
    Nov 9, 2008
    Messages:
    109
    Likes Received:
    11
    keep some way of recording false entries in those DBs. IPs change around quite a bit and no list is ever perfect. On the whole they work well though ;)
     
  5. anderson

    anderson Registered Member

    Joined:
    Nov 8, 2008
    Messages:
    85
    Likes Received:
    9
    Hi,

    If you are serious there is this payed service i use www.ip2location.com
    Updates every month.

    Good luck
     
  6. drkenneth

    drkenneth Executive VIP

    Joined:
    Nov 13, 2008
    Messages:
    285
    Likes Received:
    176
    Occupation:
    Developer/Entrepreneur
    Location:
    USA
    http://www.hostip.info/ has a SQL database of IP->location you can download for free which is updated daily. I would definitely recommend a local database lookup as opposed to connecting to a remote site as it will be significantly faster and wont be relying on a 3rd party's stability.



    This site: http://www.maxmind.com/app/products
    also has some very reasonable prices increasing with the specificity of the queries. It's only $50/site license if you just want the country.
     
    Last edited: Dec 2, 2008
  7. zone69

    zone69 Junior Member

    Joined:
    Nov 24, 2008
    Messages:
    196
    Likes Received:
    1,290
    I use maxmind with the Lite DB which is free and it's quite accurate. I think they say something like 99.5% and you can update your db monthly on the 1st of the month at the same url below. I just use a cron job to wget the file, and unpack it into place on the 2nd of the month to be up to date.

    First grab the binary GeoLiteIP country db from here:

    Code:
    #Site URL
    http://www.maxmind.com/app/geolitecountry
    Direct Link to Binary DB
    http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
    
    Then grab the php functions required:
    Code:
    http://geolite.maxmind.com/download/geoip/api/php/geoip.inc
    
    So not you have a file called geoip.inc which has all the functions and when unzipped you have GeoIP.dat which is the binary db. Simply shove those onto your web server and use this for your index.php. The below handles Canada, U.S. and U.K but can be expanded to handle any country very easily.

    PHP:
    <?php


    include("geoip.inc");


    $ip=$_SERVER['REMOTE_ADDR'];

    $gi geoip_open("GeoIP.dat",GEOIP_STANDARD);



    // Uncomment if you want country code
    //$country_code = geoip_country_code_by_addr($gi, "$ip");



    // Get Country Code based on source IP
    $country geoip_country_name_by_addr($gi"$ip");


    /* For testing which country uncomment next line
    and it will display the country and then simply add
    a case statement for that country
    */

    //echo "Country is: $country";



    switch($country)
        {
            case 
    "United States":        header("Location: http://Your_American_page");
                                  break;
            case 
    "Canada":
                              
    header("Location: http://Your_Canadian_Page");
                                  break;
            case 
    "United Kingdom":
                              
    header("Location: http://Your_U.K._Page");
                                  break;

          default:              
    header("Location: http://Where_the_rest_of_the_visitors_go");
                                  break;
    }

    geoip_close($gi);

    ?>
    Hope this helps out someone and much as this forum is helping me!