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

Free Geo Redirection Script, Works with Banners and Redirects

Discussion in 'Making Money' started by Corrupt, Jan 10, 2012.

  1. Corrupt

    Corrupt BANNED BANNED

    Joined:
    Sep 15, 2011
    Messages:
    805
    Likes Received:
    412
    Fluff:
    A member here recently asked for a geo-redirection script, which redirects the user to a different CPA offer based on his country. I was using a similar approach for displaying different banners on a site based on geolocation, so I offered to modify the script for his purpose and give it to him. I also realized that a lot of people suffer with this aspect of Internet Marketing. They either don't know how to, or ignore geo-targeting, so decided to share this simple script here.

    Non-Fluff:
    Geo-targeting can increase your income by monetizing the traffic not meant for your default country.
    We all know that most of the CPA offers are targeted for the USA, and if even 80% of our traffic is from the USA, we'll lose out on the 20% traffic that can easily be monetized with appropriate offers. So, we use geo-targeting to display different offers from country to country.

    What this script does:
    It either displays different CPA offers on a webpage for different countries, or redirects the user to different offers for different countries. All the instructions on how to use it are enclosed in a readme.txt file.

    Download Link:
    Code:
    http://www.mediafire.com/download.php?v2ufzo83vlwchvn


    Virus Scan(0/43):
    Code:
    http://www.virustotal.com/file-scan/report.html?id=f4a7dd9b25e74dd47c75b61289b814975a7af8b7e4154d2ed7e035a8aa8387c6-1326224559
    I tried ending this thread quickly before alcohol got the better of me, so forgive me for being quick.
    I'll probably make a better version of this script as soon as I have the time, and share it here, right now I'm busy with lots of pending work due to exams.
    If you have any questions, please post them in this thread and I will resolve them here, so it can benefit other members as well.
     
    • Thanks Thanks x 19
  2. Madruga

    Madruga Senior Member

    Joined:
    Mar 16, 2011
    Messages:
    915
    Likes Received:
    1,506
    Occupation:
    IM & Enjoying Life
    Location:
    Europe
    [​IMG]

    I was that member haha =) Really appreciating this, it surely does complete the project I was working on since.. since. I will check it out in a few moments, will let you know if I managed it correctly or not :)

    Repped + Thx
     
    • Thanks Thanks x 2
  3. ForDummies

    ForDummies Newbie

    Joined:
    Dec 5, 2009
    Messages:
    5
    Likes Received:
    9
    Hey Corrupt,

    For the script to work, you need to remove the tab "\t" that's added to the CountryCode variable returned by the geoip script. Otherwise the string comparison won't work and all traffic will be treated as international.

    This means line 9 of index.php should be:
    Code:
    $CountryCode = geoip_country_code_by_addr($gi, $IP);
    Also, there's a lot of unnecessary whitespace in the index.php file that's caused by putting everything within separate <?php ?> tags. It caused issues on my web server, and I presume it will with other peoples' servers as well. PHP short tags are also used, which are not universally supported.

    I would suggest removing all extraneous <?php ?> tags and using php echo for reproducing plain text.

    Here's my updated index.php code:
    Code:
    <?php
    
    $IP = $_SERVER["REMOTE_ADDR"];
    
    include("geo/geoip.inc");
    
    $gi = geoip_open("geo/GeoIP.dat", GEOIP_MEMORY_CACHE);
    
    $CountryCode = geoip_country_code_by_addr($gi, $IP);
    geoip_close($gi);
    
    // ****DO NOT TOUCH ABOVE THIS LINE.******
    //***Consult the Readme if you aren't sure what you're doing****
    
    if ($CountryCode=="US"){
    
        //US offers go here
        
    }
    
    //Add or remove these else if statements depending on which countries you have offers for
    
        else if($CountryCode=="GB")
        {
            //UK offers go here
        } 
        
        else if($CountryCode=="AU")
        {
            //AU offers go here
        } 
        
        else if($CountryCode=="DE")
        {
            //DE offers go here
        }
    
    else {
    
        //Change this to reflect your international offers for country codes not listed above
        echo 'INTERNATIONAL OFFERS GO HERE';
    }
    
    ?>
    
     
    • Thanks Thanks x 9
  4. Madruga

    Madruga Senior Member

    Joined:
    Mar 16, 2011
    Messages:
    915
    Likes Received:
    1,506
    Occupation:
    IM & Enjoying Life
    Location:
    Europe
    I hope this will work too, seems fixed every here and there
     
  5. Corrupt

    Corrupt BANNED BANNED

    Joined:
    Sep 15, 2011
    Messages:
    805
    Likes Received:
    412
    [7:43:11 AM] Corrupt: Thanks for fixing up the \t issue
    [7:43:17 AM] Corrupt: As for the excessive php tags
    [7:43:40 AM] Corrupt: I changed the original script to include more tags to make it easier for the guys to add new offers
    [7:43:57 AM] Corrupt: Otherwise I had it in a compact form on my own installation



    @Madruga,
    If you need any help setting it up, add me on Skype.
     
    • Thanks Thanks x 1
  6. Madruga

    Madruga Senior Member

    Joined:
    Mar 16, 2011
    Messages:
    915
    Likes Received:
    1,506
    Occupation:
    IM & Enjoying Life
    Location:
    Europe
    Gathering right now an amount of offers :] Thank you for your help once again.
     
  7. eunicemartinez_21

    eunicemartinez_21 Senior Member

    Joined:
    Oct 8, 2009
    Messages:
    801
    Likes Received:
    202
    Hey bro sent you a message... Hope you got it... Thanks
     
  8. Corrupt

    Corrupt BANNED BANNED

    Joined:
    Sep 15, 2011
    Messages:
    805
    Likes Received:
    412
    Replied
     
  9. Ayomav

    Ayomav Regular Member

    Joined:
    Nov 23, 2011
    Messages:
    250
    Likes Received:
    19
    Hello,

    Where it says - US offers goes here.

    Do I need to put it like this

    //<?php header('Location: http://usoffer.com'); ?>

    Or like this

    //http://usoffer.com

    Thanks
     
  10. Corrupt

    Corrupt BANNED BANNED

    Joined:
    Sep 15, 2011
    Messages:
    805
    Likes Received:
    412
    The first one is correct, but remove the //
    Put it like:
    <?php header('Location: http://usoffer.com%27%29;/ ?>
     
    • Thanks Thanks x 1
  11. Jeffdeaf

    Jeffdeaf Newbie

    Joined:
    Jan 3, 2012
    Messages:
    20
    Likes Received:
    2
    Occupation:
    IM
    Location:
    Holland
    I'm having some trouble getting this to work..

    It's sending all traffic to catchall international offer, even when I defined other country codes, and I also deleted the "|t" argument.

    Somebody help please :D


    Thank you for the share!

    -edit-
    I would PM you, but I have less then 15 posts....
     
  12. Corrupt

    Corrupt BANNED BANNED

    Joined:
    Sep 15, 2011
    Messages:
    805
    Likes Received:
    412
    Paste your code here in code tags, remove the offer urls though
     
  13. Jeffdeaf

    Jeffdeaf Newbie

    Joined:
    Jan 3, 2012
    Messages:
    20
    Likes Received:
    2
    Occupation:
    IM
    Location:
    Holland
    That was fast :D

    Code:
    <?php
    
    
    $IP = $_SERVER["REMOTE_ADDR"];
    
    
    include("geo/geoip.inc");
    
    
    $gi = geoip_open("geo/GeoIP.dat", GEOIP_MEMORY_CACHE);
    
    
    $CountryCode = geoip_country_code_by_addr($gi, $IP);
    geoip_close($gi);
    
    
    // ****DO NOT TOUCH ABOVE THIS LINE.******
    //***Consult the Readme if you aren't sure what you're doing****
    
    
    if ($CountryCode=="US"){
    
    
    header('Location: /mt/13b4v264b4z213s254w2/'); 
    
    }
    
    
    //Add or remove these else if statements depending on which countries
    
    
    else if($CountryCode=="UK")
    {
    //UK offers go here
    header('Location: /mt/13b4v264b4z213s254w2/'); 
    } 
    
        else if($CountryCode=="CA")
    {
    //CA offers go here
    header('Location: /mt/13b4v264b4z213s254w2/'); 
    } 
    else if($CountryCode=="AU")
    {
    //AU offers go here
    header('Location: /mt/13b4v264b4z213s254w2/'); 
    } 
    
    else if($CountryCode=="DE")
    {
    //DE offers go here
    header('Location: /mt/13b4v264b4z213s254w2/'); 
    }
    else if($CountryCode=="IE")
    {
    //IE offers go here
    header('Location: /mt/13b4v264b4z213s254w2/'); 
    }
         else if($CountryCode=="NZ")
    {
    //NZ offers go here
    header('Location: /mt/13b4v264b4z213s254w2/'); 
    }
         else if($CountryCode=="FR")
    {
    //FR offers go here
    header('Location: /mt/13b4v264b4z213s254w2/'); 
    }
         else if($CountryCode=="BE")
    {
    //BE offers go here
    header('Location: /mt/w2b4333494z213s254w2/'); 
    } 
             else if($CountryCode=="CH")
    {
    //CH offers go here
    header('Location: /mt/033443a464z213s254w2/'); 
    } 
                 else if($CountryCode=="AT")
    {
    //AT offers go here
    header('Location: /mt/03344384f4z213s254w2/'); 
    } 
                     else if($CountryCode=="NL")
    {
    //NL offers go here
    header('Location: /mt/x25423c4e4z213s254w2/'); 
    } 
                         else if($CountryCode=="PL")
    {
    //PL offers go here
    header('Location: /mt/1384138494z213s254w2/'); 
    } 
                             else if($CountryCode=="NO")
    {
    //NO offers go here
    header('Location: /mt/z2a4z254a4z213s254w2/'); 
    } 
        
                             else if($CountryCode=="FI")
    {
    //FI offers go here
    header('Location: /mt/z2a4z254a4z213s254w2/'); 
    } 
                                 else if($CountryCode=="DK")
    {
    //DK offers go here
    header('Location: /mt/z2a4z254a4z213s254w2/'); 
    } 
                                 else if($CountryCode=="SE")
    {
    //SE offers go here
    header('Location: /mt/z2a4z254a4z213s254w2/'); 
    } 
                                     else if($CountryCode=="SA")
    {
    //SE offers go here
    header('Location: /mt/x254333474z213s254w2/'); 
    } 
                                         else if($CountryCode=="IN")
    {
    //SE offers go here
    header('Location: /mt/x25423c4f4z213s254w2/'); 
    } 
    else {
    
    
    //Change this to reflect your international offers for country codes not listed above
    
        
    header('Location: /trafficoptimizer/index.php?toid=70506&r=lc356993'); /* Stuur de browser naar */
    }
    
    
    ?>
    
     
  14. Corrupt

    Corrupt BANNED BANNED

    Joined:
    Sep 15, 2011
    Messages:
    805
    Likes Received:
    412
    Just to be sure, did you check using proxies?
     
  15. Jeffdeaf

    Jeffdeaf Newbie

    Joined:
    Jan 3, 2012
    Messages:
    20
    Likes Received:
    2
    Occupation:
    IM
    Location:
    Holland
    I'm not on proxies but good suggestion :)

    -edit-

    the other code is not the problem

    the ip's aren't catched and redirected accordingly..
     
    Last edited: May 8, 2012
  16. Corrupt

    Corrupt BANNED BANNED

    Joined:
    Sep 15, 2011
    Messages:
    805
    Likes Received:
    412
    Did you copy paste all the files properly? Do it again, except the index/redirect.php script. Don't change the directory strucutre.
     
  17. swiftinirox

    swiftinirox Newbie

    Joined:
    Jun 14, 2012
    Messages:
    3
    Likes Received:
    0
    Hi Corrupt I have the same issue. I am getting the International Offers even when I go through a U.S. based proxy.

    ( I haven't even set up banners- I am just testing it).

    Also, I can't get your include to work- it just shows blank space.


    Here is my code:



    include("geo/geoip.inc");


    $gi = geoip_open("geo/GeoIP.dat", GEOIP_MEMORY_CACHE);


    $CountryCode = geoip_country_code_by_addr($gi, $IP);
    geoip_close($gi);


    // ****DO NOT TOUCH ABOVE THIS LINE.******
    //***Consult the Readme if you aren't sure what you're doing****


    if ($CountryCode=="US"){


    echo 'US OFFERS GO HERE';
    }


    //Add or remove these else if statements depending on which countries you have offers for


    else if($CountryCode=="GB")
    {
    //UK offers go here
    }

    else if($CountryCode=="AU")
    {
    //AU offers go here
    }

    else if($CountryCode=="DE")
    {
    //DE offers go here
    }


    else {


    //Change this to reflect your international offers for country codes not listed above
    echo 'INTERNATIONAL OFFERS GO HERE';
    }


    ?>
     
  18. Corrupt

    Corrupt BANNED BANNED

    Joined:
    Sep 15, 2011
    Messages:
    805
    Likes Received:
    412
    Put your US Proxy IP address here and see what location it gives you: http://www.maxmind.com/app/lookup_city

    PM me your Skype id.
     
  19. swiftinirox

    swiftinirox Newbie

    Joined:
    Jun 14, 2012
    Messages:
    3
    Likes Received:
    0
    Thanks for the quick response

    After a reboot it miraculously works

    would give you my SK id but cannot PM you --if you want gimme yours

    The only think I cannot get going is the include- when I try to include the first script from a second it renders blank--suggestions???
     
  20. swiftinirox

    swiftinirox Newbie

    Joined:
    Jun 14, 2012
    Messages:
    3
    Likes Received:
    0
    In case anybody is interested, I was able to implementing this thing for banners using an iframe.

    Thanks again Corrupt and Ayomav for the code cleanup !!!!!!!!!!!!