Script show ads by country

Discussion in 'Scripts' started by Bosxs, Nov 20, 2007.

  1. #1
    Hi all,

    I need a script, that would show ads by country.. If visitor is from USA - it shows one ad, if UK - other etc...

    Someone know or have it?
     
    Bosxs, Nov 20, 2007 IP
  2. JeffHood

    JeffHood Peon

    Messages:
    27
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Hello. The solution is pretty simple and it just requires two third-party php files:

    http://www.maxmind.com/app/geoip_country (download the geolite country binary format)
    http://www.maxmind.com/download/geoip/api/php (download geoip.inc)

    And the code is simple as well:
    <?php
    
    	include("geoip.inc");
    	$geofile = geoip_open("GeoIP.dat", GEOIP_STANDARD);
    	$country = geoip_country_code_by_addr($geofile, $_SERVER['REMOTE_ADDR']);
    	geoip_close($geofile);
    	
    	switch($country){
    		
    		case "US":{
    			$html = "usa ad code here";
    		}break;
    
    		case "GB":{
    			$html = "uk ad code here";
    		}break;
    		
    	}
    	
    	echo "Ads: $html";
    ?>
    PHP:
    Tested and it works as of thirty seconds ago. Let me know if you need more help!
     
    JeffHood, Nov 20, 2007 IP
  3. Bosxs

    Bosxs Peon

    Messages:
    487
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks for you, I will try now
    EDIT:
    I try and this work :)
    Thanks
     
    Bosxs, Nov 20, 2007 IP