GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   Geo IP Question... (https://gfy.com/showthread.php?t=824528)

CurrentlySober 04-26-2008 01:18 PM

Geo IP Question...
 
How easy / simple / complicated would it be to do the following...
Surfer clicks text link:

If surfers in Europe, they see Europe page
If surfers in America, they see USA page
If surfer is 'somewhere else' the see the 'somewhere else' page'

Simple enough on paper but how simple to set up and how would I go about it?

What would I need to do to make this happen, or is it a big complicated expensive deal?
Doesn't need to be TOTALLY accurate... Just pretty much so...

Just looking for some theoretical information..

Thanks :)

psili 04-26-2008 01:26 PM

http://www.maxmind.com/app/ip-location

They have a free version of their location DB if you want free. Just find the code example of your choice on their site and you're off and running.

CurrentlySober 04-26-2008 01:57 PM

Thanks, will look into them :)

GrouchyAdmin 04-26-2008 02:16 PM

GrouchAdmin's "How to do GeoIP the proper way with minimal overhead" example

MaxMind's mod_geoip directly inserted into your webserver would be the easiest for external/programmable GeoIP support.

It'd make more sense to check the browser's language(s) of choice, than force a user of a region into a language they don't want. Let Apache handle the language, itself, then just display the runtime code (if that's what you want to do) independently with mod_geoip.

First, setup your supported languages, and priority in Apache:

Code:

AddLanguage en .en
AddLanguage fr .fr
AddLanguage es .es
AddLanguage de .de

Then, set your defaults you want to support in order of priority:
Code:

LanguagePriority en fr es de
Create multiple pages with the different languages embedded. "index.html" would be removed, and you would have "index.html.en", "index.html.fr", "index.html.es", and "index.html.de" (This also works for .php, .shtml, etc.)

Now, GeoIP's database for the country name database part, which almost mimmics the above, but uses a different format, ISO3166:

Here's some tiny little throwaway GeoIP code. It displays those tiny flags in my sig. It has very little overhead with mod_geoip, marginal with the runtime PHP library. This is an old version without eTags (caching) support. It'd be smarter to cache these into RAM than to continually read them from the disk, if you have the choice. You may use this code, if you want.

Code:

<?php
// Simple little example utlity to display a small flag based upon GeoIP data.
// by GrouchyAdmin <grouchy/at/grouchyadmin/dot/com>
//
// This example supports both mod_geoip, and the external PHP API.
// If mod_geoip is installed:
  $country = "";
  // Do we have apache_note()?
  if (function_exists('apache_note'))
    $country = strtolower(apache_note("GEOIP_COUNTRY_CODE"));
  if (empty($country)) {
    // external MaxMind PHP support
    include("./geoip.inc");
    $gi = geoip_open("./GeoIP.dat", GEOIP_STANDARD);
    $country = strtolower(geoip_country_code_by_addr($gi, $_SERVER["REMOTE_ADDR"
]));
    geoip_close($gi);
    if ($country) {
      header ("Pragma: no-cache");
      header("Expires: Mon, 26 Jul 1999 04:20:00 GMT");
      header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
      header('Cache-Control: no-store, no-cache, must-revalidate');
      header('Cache-Control: pre-check=0, post-check=0, max-age=0');
      header("Content-type: image/gif");
      if (file_exists('./'.$country.'.gif')) {
        readfile('./'.$country.'.gif');
      } else {
        // Generic 'empty' country banner.
        readfile("./00.gif");
      }
    }
  }
?>

I hope this has been helpful. Stop forcing me to read Spanish when I'm in Latin America; I have to read it all of the damn time, there! :thumbsup

CurrentlySober 04-26-2008 03:13 PM

Hey Grouch, Thanks for the reply, however it may be more technical than I need or (truthfully) understand...

Here's what I want in a simpler way of explaining it... The text link that gets clicked, is a link to a dating site... Not an AFF or similar, ie a porn type site, with phony profiles etc... Im talking a REAL DATING SITE. Mainstream... Match.com or similar...

My Idea was that if they were in Europe and clicked, they would get a European based dating site... If the surfer was in America, they get a USA based dating site... And, as an afterthought, if they were somewhere else ie China... I could just throw them somewhere else...

Its NOT about languages. Its just about getting a European person to a euro landing page and an American to a USA landing page... Thats all really...

GrouchyAdmin 04-26-2008 03:15 PM

Quote:

Originally Posted by ThatGuyInTheCorner (Post 14115776)
Its NOT about languages. Its just about getting a European person to a euro landing page and an American to a USA landing page... Thats all really...

Then you could likely bribe someone to modify the script above to redirect to a new site instead of printing a GIF. (if country = DE (German), then.. etc. Shouldn't be too difficult to have implemented for you,
either.

Catalyst 04-26-2008 04:13 PM

Yea.. this is something I have been looking at also..

how is the load on the server.. do you normally use the php mod, or perl, or what? Load on the server is not much?

GrouchyAdmin 04-26-2008 04:15 PM

Quote:

Originally Posted by Catalyst (Post 14115911)
Yea.. this is something I have been looking at also..

how is the load on the server.. do you normally use the php mod, or perl, or what? Load on the server is not much?

mod_geoip in Apache itself is going to be much faster and not have the 'recompile/load/fireoff' which is going to be slower even with a metacaching PHP service. I use that, where I can, and the PHP library where I have to. The Perl library is just about the same as the "Pure PHP" library. The load is marginal.


All times are GMT -7. The time now is 01:54 PM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123