ip sensitve ads

Discussion in 'Publisher Network' started by mydomainoffer, Aug 19, 2007.

  1. #1
    has anybody have a script to display yahoo ad for US traffic and adsense for other region...

    thanks
     
    mydomainoffer, Aug 19, 2007 IP
  2. Dentman

    Dentman Peon

    Messages:
    410
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #2
    yeah very good idea to use... may it be against TOS?
     
    Dentman, Aug 19, 2007 IP
  3. PoemofQuotes

    PoemofQuotes Peon

    Messages:
    637
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    0
    #3
    It is not against the TOS, they actually want you to use one. Download MaxMind GeoIP lite for free. Then write a simple script like:

    <?
    $ip = $_SERVER['REMOTE_ADDR'];
    include("geoip.inc");
    
    $gi = geoip_open(dirname(__FILE__)."/GeoIP.dat",GEOIP_STANDARD);
    
    if (geoip_country_code_by_addr($gi, $ip) != US) {
    $rand = rand(4,5);
    }
    
    else {
    $rand = rand(3,4);
    $place = "US";
    }
    
    geoip_close($gi);
    
    ?>
    Code (markup):
    Just include that file in your header.php
     
    PoemofQuotes, Aug 19, 2007 IP
  4. decodethis

    decodethis Well-Known Member

    Messages:
    436
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    128
    #4
    That's almost the exact script I use (I use GeoIP as well). It's free and pretty easy to set up. I actually use php includes to insert my ads, making it fairly easy to change whenever I want. I added a USE_YAHOO constant in my headed that I can toggle whenever the YPN "shuts down" so I can go with Adsense ads for all traffic with just changing one setting.

    I've been using it for over a year pretty flawlessly.
     
    decodethis, Aug 20, 2007 IP
  5. decodethis

    decodethis Well-Known Member

    Messages:
    436
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    128
    #5
    Here's mine:
    
    <?php 
    
    //Check if an IP address has been submitted, or get the surfer's IP address 
    
    if(isset($_GET["ipAddress"])) 
    	$addr=$_GET["ipAddress"]; 
    else { 
    	// Get the surfer's ip address 
    	$addr = getenv("REMOTE_ADDR"); 
    } 
    //Do the MaxMind geotargeting database lookup 
    //
    require_once("geo/geoip.inc"); 
    $gi = geoip_open("geo/GeoIP.dat",GEOIP_STANDARD); 
    $country = geoip_country_name_by_addr($gi, $addr); 
    $countryCode = geoip_country_code_by_addr($gi, $addr); 
    geoip_close($gi); 
    // Display the Ad based on Country Code 
    if (USE_YAHOO) {
    	if ($countryCode == "US" || $countryCode == "") { 
    		// display Yahoo Ad 
    		include("geo/yahoo_content_block.inc"); } 
    	else { 
    		// display Google Ad 
    		include("geo/google_content_block.inc"); 
    	} 
    }
    else
    {
    	include("geo/google_content_block.inc");
    }
    ?>
    
    PHP:
    USE_YAHOO is a global flag I can toggle to turn off YPN ads 100% site-wide.
     
    decodethis, Aug 20, 2007 IP
  6. PoemofQuotes

    PoemofQuotes Peon

    Messages:
    637
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Nice idea decodethis.
     
    PoemofQuotes, Aug 20, 2007 IP
  7. mydomainoffer

    mydomainoffer Guest

    Messages:
    460
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #7
    i love this community; thanks for sharing the script i will try it out.

    thanks again.
     
    mydomainoffer, Aug 20, 2007 IP