New Posts
Welcome guest, is this your first visit?
  • Login:
TruePoker.eu Affiliate Program
+ Reply to Thread
Results 1 to 6 of 6
  1. #1
    Senior Member
    My Status
     

    Add as a friend
    Join Date
    Nov 2008
    Location
    England
    Posts
    1,452
    Blog Entries
    3
    Feedback Score
    31 (100%)

    Default Geo Targetting with PHP

    Hi there,

    I'm looking to do a bit of basic Geo Targetting in a straight forward PHP site (so no WP plugins allowed).

    I've been trying to get an idea of the functions that I'm going to need by looking through PHP.net.

    I've come across the function geoip_country_name_by_name()

    Is this going to do the job correctly for me though? Or should I be using another function to determine's a vistor's geographical location.

    Also, is it possible to tell a user's operating system through PHP as well?

    Cheers,
    DropBox - Backup and Synch your files for free across PC, Mac and Mobile.
    Get an extra 250MB when you register with the link above
    The largest collection of professional WP themes - for just $20 a pop!

  2. #2
    Formerly TPB
    My Status
     

    Add as a friend
    Join Date
    Nov 2008
    Location
    Wales
    Posts
    664
    Feedback Score
    16 (100%)

    Default

    Quote Originally Posted by TheShortStack View Post
    Hi there,

    I'm looking to do a bit of basic Geo Targetting in a straight forward PHP site (so no WP plugins allowed).

    I've been trying to get an idea of the functions that I'm going to need by looking through PHP.net.

    I've come across the function geoip_country_name_by_name()

    Is this going to do the job correctly for me though? Or should I be using another function to determine's a vistor's geographical location.
    I'm pretty sure you need to use a database (like Maxmind) along with some PHP to use geotargeting, not just PHP on its own.

    I'm not great with PHP though so I can't expand on that.

    Quote Originally Posted by TheShortStack View Post
    Also, is it possible to tell a user's operating system through PHP as well?
    This is what I started with:

    Detect operating system from user agent string (PHP Code) • Geekpedia

  3. #3
    Senior Member
    My Status
     

    Add as a friend
    Join Date
    Nov 2008
    Location
    USA
    Posts
    395
    Blog Entries
    1
    Feedback Score
    42 (100%)

    Default

    As far as I know you can get the IP (I used function getip() in my script) from your visitor, but then have to find location from that.

    I used:
    IP address geolocation SQL database :: IPInfoDB

    I created a geo-target script for a dating site banner. I did this many months back, and decided not to use the code.

    I dont remember clearly how I did it.


    I am currently selling high quality PR3 Permanents Blog Posts on a 5 year old poker site!

  4. #4
    #!/usr/bin/mikebrad
    My Status
     

    Add as a friend
    Join Date
    Nov 2008
    Location
    USA
    Posts
    622
    Feedback Score
    8 (100%)

    Default

    On maxmind's webste, download GeoIP.dat and geoip.inc. Since you already named one of their functions, I'll assume you did this already.

    To get the country code (US, CAN, UK, etc), use the following code:

    PHP Code:
    $gi geoip_open("/your/absolute/path/to/GeoIP.dat",GEOIP_STANDARD);
    global 
    $country;
    $country geoip_country_code_by_addr($gi$_SERVER['REMOTE_ADDR']);
    geoip_close($gi); 
    The variable $country will contain the country code.

    From there, you just use a simple if statement like:

    PHP Code:
    if ($country == 'US') {
    //US ONLY
    } elseif ($country == 'UK') {
    //UK ONLY
    } else {
    //EVERYONE ELSE


  5. #5
    Senior Member
    My Status
     

    Add as a friend
    Join Date
    Nov 2008
    Location
    England
    Posts
    1,452
    Blog Entries
    3
    Feedback Score
    31 (100%)

    Default

    Thanks guys - I'll give it a go
    DropBox - Backup and Synch your files for free across PC, Mac and Mobile.
    Get an extra 250MB when you register with the link above
    The largest collection of professional WP themes - for just $20 a pop!

  6. #6
    Senior Member
    My Status
     

    Add as a friend
    Join Date
    Nov 2008
    Location
    England
    Posts
    1,452
    Blog Entries
    3
    Feedback Score
    31 (100%)

    Default

    Ok, quick question about this.

    Mike, when you say I need to put my absolute path to the GeoIP.dat - how does that work.

    If the .dat file is installed on the root of onlinepoker.com, and I'm trying to insert the code into /include/header.php how does that translate into the PHP code?

    Should the code read:
    PHP Code:
    $gi geoip_open("../GeoIP.dat",GEOIP_STANDARD); 
    Any thoughts or suggestions would be really welcome given that that code seems to be giving me an error message
    DropBox - Backup and Synch your files for free across PC, Mac and Mobile.
    Get an extra 250MB when you register with the link above
    The largest collection of professional WP themes - for just $20 a pop!


 

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. Specific Event Targetting
    By doovde in forum Sportsbook Affiliate Forum
    Replies: 1
    Last Post: 02-12-2010, 08:50 AM
  2. Carribean Poker Worth Targetting?
    By PokerFelts in forum New Affiliate Questions & Answers
    Replies: 7
    Last Post: 11-04-2009, 10:51 PM
  3. Geo Targetting plugin for WP
    By TheShortStack in forum Wordpress - Web Design - Coding - Technical
    Replies: 2
    Last Post: 02-02-2009, 06:48 AM
  4. How do I test my Geo Targetting?
    By TheShortStack in forum General Poker Affiliate Forum
    Replies: 17
    Last Post: 01-06-2009, 11:59 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Powered by vBulletin® Version 4.1.5
Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.
SEO by vBSEO 3.6.0
Affiliate Program Consultant
Live threads provided by AJAX Threads (Lite) - vBulletin Mods & Addons Copyright © 2012 DragonByte Technologies Ltd. Runs best on HiVelocity Hosting.