Reply
Old 12-30-2006, 04:08 PM Geo targetting help
DLGx's Avatar
Bleah

Posts: 180
Trades: 0
Does anyone have the code needed for geo targetting different ad codes on sites where everything is not run from the root directory?

Only code I've found requires that all your files are the root directory and just produces errors on pages located folders deeper than root.
__________________
The Corrs | MySpace Layouts | Anime Community
DLGx is offline
Reply With Quote
View Public Profile Visit DLGx's homepage!
 
 
When You Register, These Ads Go Away!
Old 12-30-2006, 04:50 PM
dadofgage's Avatar
Extreme Talker

Posts: 224
Trades: 0
You might want to check out: http://www.maxmind.com/app/geoip_country

When I used geo ip targeting, I made one include file that was called on every page - that include file did the call to the database to check to see if the IP was a US/non-US based IP and then the results were stored in a session variable.

If that session variable was set, I did not bother doing another call, since their IP was not going to change. If it wasn't then you use the include file.

Does that make sense?
dadofgage is offline
Reply With Quote
View Public Profile Visit dadofgage's homepage!
 
Old 12-30-2006, 05:11 PM
DLGx's Avatar
Bleah

Posts: 180
Trades: 0
I have got the database, it's the code to make the check work that I need. I can't code php from scratch.

All I find is this code and it doesn't work for pages that are not loaded from root because the geoip.inc file won't accept any paths. I'd have to place the geoip.inc and GeoIP.dat files in every folder of the site to make it work (in theory)


Code:
if (isset($_COOKIE["geo"])) {
    $country  = $_COOKIE['geo'];
    } else  {
    include("geoip.inc");
    $gi =  geoip_open("GeoIP.dat",GEOIP_STANDARD);
    $ip =  $_SERVER["REMOTE_ADDR"];
    $country = geoip_country_code_by_addr($gi,  $ip);
    geoip_close($gi);
    setcookie("geo", $country,  time()+15552000, "/", ".yourdomain.com", 0); //6 month  cookie
  }

Code:
<?php
if ($country == "US")
  echo 'MAIN CODE';
else
  echo 'BACKUP CODE';
?>
__________________
The Corrs | MySpace Layouts | Anime Community
DLGx is offline
Reply With Quote
View Public Profile Visit DLGx's homepage!
 
Old 12-30-2006, 11:13 PM
ghoti's Avatar
Junior Talker

Posts: 75
Trades: 0
Quote:
Originally Posted by DLGx View Post
All I find is this code and it doesn't work for pages that are not loaded from root because the geoip.inc file won't accept any paths. I'd have to place the geoip.inc and GeoIP.dat files in every folder of your site to make it work (in theory)
If you can't get that to work, you might want to try an alternative method of geo-targeting that I described at http://www.ghoti.ca/2006/11/17/ip-to...-your-traffic/
__________________
www.ghoti.ca - ghoti's place
ghoti is offline
Reply With Quote
View Public Profile Visit ghoti's homepage!
 
Old 12-31-2006, 01:02 PM
DLGx's Avatar
Bleah

Posts: 180
Trades: 0
Bit more technical, might try it out.

Wish I could get the simple method to work though.
__________________
The Corrs | MySpace Layouts | Anime Community
DLGx is offline
Reply With Quote
View Public Profile Visit DLGx's homepage!
 
Old 12-31-2006, 09:04 PM
ghoti's Avatar
Junior Talker

Posts: 75
Trades: 0
Have you contacted your web host to ask if there's a way you can get the includes to work on their server?
__________________
www.ghoti.ca - ghoti's place
ghoti is offline
Reply With Quote
View Public Profile Visit ghoti's homepage!
 
Old 01-01-2007, 06:12 AM
DLGx's Avatar
Bleah

Posts: 180
Trades: 0
Quote:
Originally Posted by ghoti View Post
Have you contacted your web host to ask if there's a way you can get the includes to work on their server?
I run unmanaged dedicated servers. The problem is with the script which just produces errors unless everything is in the same directory.
__________________
The Corrs | MySpace Layouts | Anime Community
DLGx is offline
Reply With Quote
View Public Profile Visit DLGx's homepage!
 
Old 01-01-2007, 11:09 AM
ghoti's Avatar
Junior Talker

Posts: 75
Trades: 0
If it's your own server, then you should be able to change the open_basedir settings for PHP. That's probably what's causing the errors.
__________________
www.ghoti.ca - ghoti's place
ghoti is offline
Reply With Quote
View Public Profile Visit ghoti's homepage!
 
Old 01-01-2007, 06:29 PM
DLGx's Avatar
Bleah

Posts: 180
Trades: 0
That was not it

Quote:
Originally Posted by ghoti View Post
If it's your own server, then you should be able to change the open_basedir settings for PHP. That's probably what's causing the errors.
__________________
The Corrs | MySpace Layouts | Anime Community
DLGx is offline
Reply With Quote
View Public Profile Visit DLGx's homepage!
 
Old 01-01-2007, 06:59 PM
DLGx's Avatar
Bleah

Posts: 180
Trades: 0
Think I solved it now... :thumbup:
__________________
The Corrs | MySpace Layouts | Anime Community
DLGx is offline
Reply With Quote
View Public Profile Visit DLGx's homepage!
 
Reply     « Reply to Geo targetting help
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 



Page generated in 0.15800 seconds with 13 queries