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

My New Year Gift for BHW - Geo redirect script with blank referrer option...

Discussion in 'Black Hat SEO' started by xLoKuMx, Dec 31, 2010.

  1. xLoKuMx

    xLoKuMx Jr. VIP Jr. VIP Premium Member

    Joined:
    Jun 24, 2009
    Messages:
    173
    Likes Received:
    137
    Hi everyone!

    I started learning PHP a week ago and coded some easy scripts for myself to gain experience. One of them is my New Year Gift for BHW.

    I read it a lot, people searching for a geo targeting script. So I think that it'll be of use for some of you... :)

    If you want to use it as it is, you only have to download the complete package below, edit the settings.php and upload it to your server. That's it.


    settings.php
    PHP:
    <?php

    // Enter your affiliate links for different countries below.
    // A list of country codes can be found here:
    // http://www.maxmind.com/app/iso3166

    $afflink = array(
        
    'DE' => "http://www.whatismyreferrer.com/?=DE",
        
    'US' => "http://www.whatismyreferrer.com/?=US",
        
    'SE' => "http://www.whatismyreferrer.com/?=SE"
        
    );
        
    // Enter the URL where all the other countries will be redirected.

    $other "http://www.whatismyreferrer.com/?=other";

    // Do you want to blank the referrer? Yes = true ; No = false

    $blank false;

    // If the referrer cannot be blanked, visitors will go here.

    $whitehat "http://www.whatismyreferrer.com/?=notblank";

    ?>
    index.php
    PHP:
    <?php

    include("settings.php");

    // Check country code by IP
    if (!$blank == true) {
    include(
    "geoip.inc");
    $gi geoip_open("GeoIP.dat",GEOIP_STANDARD);
    $ip $_SERVER["REMOTE_ADDR"];
    $country geoip_country_code_by_addr($gi$ip);
    geoip_close($gi);
    }

    if (
    $blank == true) {
        echo 
    "<meta http-equiv=\"refresh\" content=\"0;url=goto.php\">";
        exit;
    } else {
        foreach(
    $afflink as $key=>$value) {
            if (
    $key == $country) {
                
    header("Location: " $afflink[$country]);
                exit;
            }
        }
    }

    header("Location: " $other);
    exit;

    ?>
    goto.php
    PHP:
    <?php

    include("settings.php");

    // Check country code by IP
    include("geoip.inc");
    $gi geoip_open("GeoIP.dat",GEOIP_STANDARD);
    $ip $_SERVER["REMOTE_ADDR"];
    $country geoip_country_code_by_addr($gi$ip);
    geoip_close($gi);

    $referer $_SERVER['HTTP_REFERER'];
    if (
    $referer == "") {
        foreach(
    $afflink as $key=>$value) {
            if (
    $key == $country) {
                echo 
    "<meta http-equiv=\"refresh\"content=\"0;url=" $afflink[$country] . "\">";
                exit;
            }
        }
        echo 
    "<meta http-equiv=\"refresh\"content=\"0;url=" $other "\">";
        exit;
    } else {
        echo 
    "<meta http-equiv=\"refresh\"content=\"0;url=" $whitehat "\">";
        exit;
    }

    ?>
    Additionally you need GeoIP.dat and geoip.inc:

    Code:
    http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
    Code:
    http://geolite.maxmind.com/download/geoip/api/php/geoip.inc
    Download the complete package including all script files and the geo database here:

    Code:
    http://www.mirrorcreator.com/files/BZZB6SHO/geoscript.rar_links
    Virus scan
    Code:
    http://vscan.novirusthanks.org/analysis/9678b71bc3a1d4f1aca11e1f25069819/Z2Vvc2NyaXB0LXJhcg==/
     
    • Thanks Thanks x 16
  2. xLoKuMx

    xLoKuMx Jr. VIP Jr. VIP Premium Member

    Joined:
    Jun 24, 2009
    Messages:
    173
    Likes Received:
    137
    135 views and no feedback or thanks. :(

    Maybe I sould've posted it today, where everyone has a hangover... :D

    BTW, HAPPY NEW YEAR EVERYONE!
     
    • Thanks Thanks x 1
  3. LurkaLot

    LurkaLot Registered Member

    Joined:
    Apr 24, 2007
    Messages:
    83
    Likes Received:
    4
    thanks for the share man, i'm one of those guys who went out last night but didnt drink.

    i guess everyone else is still in their bed lol
     
  4. Devesh

    Devesh Junior Member

    Joined:
    Oct 2, 2009
    Messages:
    174
    Likes Received:
    17
    Occupation:
    Software Engineer
    Location:
    the world u know
    Home Page:
    Thanks man for this. Bumping you back.
     
  5. smartalex4

    smartalex4 Junior Member

    Joined:
    Jun 5, 2009
    Messages:
    163
    Likes Received:
    57
    This looks like something I should look into using....Thanks for sharing (and yes I am not one of those recovering from a hangover this morning) :)
     
  6. Mrnewbie

    Mrnewbie Regular Member Premium Member

    Joined:
    Mar 8, 2009
    Messages:
    488
    Likes Received:
    730
    Gender:
    Male
    Location:
    NY
    Great share + I think all of us have been looking for this because we have such different traffic(different countries) so this comes in handy. Thanks for putting in the effort and time as I know this most have been a lot to do. Happy New Year to you and rep given!
     
  7. tobeto

    tobeto Junior Member

    Joined:
    Apr 10, 2010
    Messages:
    171
    Likes Received:
    19
    Thanky for sharing, it is a good and useful script.
     
  8. loxllxol

    loxllxol Newbie

    Joined:
    Aug 1, 2010
    Messages:
    34
    Likes Received:
    4
    Awesome script!! Does the maxmind file have to be updated every month? Also, where in your site's file structure do you have to place the maxmind files?
     
  9. xLoKuMx

    xLoKuMx Jr. VIP Jr. VIP Premium Member

    Joined:
    Jun 24, 2009
    Messages:
    173
    Likes Received:
    137
    If you want, you can download it every month, but there's not changing anything with the big countries, so I don't do it.

    The database goes to the same folder as the other files.

    You can download the complete package here:
    Code:
    http://www.mirrorcreator.com/files/BZZB6SHO/geoscript.rar_links
     
  10. fercpa

    fercpa Newbie

    Joined:
    Aug 28, 2010
    Messages:
    1
    Likes Received:
    0
    can you make the offers rotating?
    like we can promote 10 different networks using the same offers?
     
  11. drstew

    drstew Jr. VIP Jr. VIP Premium Member

    Joined:
    Nov 5, 2008
    Messages:
    533
    Likes Received:
    148
    Gender:
    Male
    Location:
    DownUnder
    Home Page:
    I agree, ability to rotate offers would be very good.

    specify your country and a list of the following offers to rotate for example.

    Also it would be good if when redirecting it does a 301 redirect (I think that's the one). E.g. when it redirects it keeps the domain you're hosting the script on in the browser URL.

    Thanks.
     
    Last edited: Aug 12, 2011
  12. flyingvulture

    flyingvulture Registered Member

    Joined:
    Jun 26, 2011
    Messages:
    76
    Likes Received:
    10
    hey, does It work with city wise geo redirection? thanks,
     
  13. tqpchris

    tqpchris Junior Member

    Joined:
    May 27, 2008
    Messages:
    102
    Likes Received:
    34
    Hey great share and thank you for making it so easy for those of us who don't code.

    If you have any other useful toys like this, I'd love to buy some from you if you think they are "necessary tools" to your marketing
     
  14. The Best SEO Hosting

    The Best SEO Hosting Newbie

    Joined:
    Nov 8, 2010
    Messages:
    3
    Likes Received:
    0
    Home Page:
    Cool share!