Deliver php include based on IP?

Discussion in 'PHP' started by I. Brian, Apr 16, 2006.

  1. #1
    I'm looking to deliver ads based on whether the user's country is:

    1. USA
    2. UK
    3. Anything else

    I wondered if it's possible to use a PHP script to deliver one of 3 includes files based on the visitor's IP?

    Many thanks for any replies.
     
    I. Brian, Apr 16, 2006 IP
  2. onlyican.com

    onlyican.com Peon

    Messages:
    206
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You would need to get a list of IP2Countries

    Then owrk from that
     
    onlyican.com, Apr 16, 2006 IP
  3. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,334
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #3
    Do you already have a geotargetting database?
     
    digitalpoint, Apr 16, 2006 IP
  4. I. Brian

    I. Brian Business consultant

    Messages:
    810
    Likes Received:
    59
    Best Answers:
    1
    Trophy Points:
    145
    #4
    Not yet - starting from scratch on this. :)

    ADDED: ust been suggested I look at something like phpadsnew, which apparently has this already set up. Will play7 around with it. :)
     
    I. Brian, Apr 17, 2006 IP
  5. Lordo

    Lordo Well-Known Member

    Messages:
    2,082
    Likes Received:
    58
    Best Answers:
    0
    Trophy Points:
    190
    #5
    Lordo, Apr 17, 2006 IP
  6. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,334
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #6
    Well once you know the country (via geotargetting database), the include part is cake. For example maybe you have the user's country set as a variable of $country thanks to geotargetting. You can have an include within logic, so it could work like so:

    switch ($country) {
    case 'USA':
    	include ('usa_file.php');
    	break;
    case 'UK':
    	include ('uk_file.php');
    	break;
    default:
    	include ('all_others_file.php');
    }
    PHP:
     
    digitalpoint, Apr 17, 2006 IP
  7. I. Brian

    I. Brian Business consultant

    Messages:
    810
    Likes Received:
    59
    Best Answers:
    1
    Trophy Points:
    145
    #7
    That's great - many thanks for that. :)
     
    I. Brian, Apr 18, 2006 IP
  8. quaffapint

    quaffapint Active Member

    Messages:
    299
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    58
    #8
    Just in case you're interested I am looking for testers for a new GeoTargeting ad management script I created, as shown in this post...

    http://forums.digitalpoint.com/showthread.php?t=75962

    ...It's not meant to compete with PHPAdsNew, but instead be much simpler and provide some basic features like GeoTargeting.

    -Matt
     
    quaffapint, Apr 18, 2006 IP