HTML/PHP show IMG based on location

HI guys/gals,

I like to add some personal touches to a welcome image on our mediawiki site, and have the welcome be displayed in the, presumed, language of the visitor.

Standard would be English, but if the IP or browser or OS is set to be in India, I want to display the message in Urdu for example... Or if South Afrika than I want the SA Afrikaans image to show.

Anyone have some idea on how to accomplish this using simple code?

What web server are you running? Apache2?

If running Apache, you can install the GeoIP Apache API.

Hi,
Thank you for the kind reply,

Yes its an HTTPD (Apache2) server.

I see that using this package I could rewrite some stuff,
but how would I change a simple

<img src="usaimage" alt="usa image"  />

And apply geo coding to it

if
geo code is USA display <img src="usaimage" alt="usa image"  />
if
geo code is INDIA display <img src="indiaimage" alt="india image"  />

Did you look at the examples in the link provided?

In PHP, you would do something like:

$country_code = apache_note("GEOIP_COUNTRY_CODE");

if($country_code == 'US')
    $image = '/images/usimage.jpg';
elseif($country_code == 'IN')
    $image = '/images/india.image.jpg';
else
    $image = '/images/default.jpg';

If you want to embed PHP in your HTML, you can search the web on how to do this.

Wow,
I must have missed that, its exactly what I need!
Thank you so much Neo!

You are welcome!

There is plenty of info and examples here.

Pure PHP README:

[quote]
Requirements

None (only the 'GeoIP.dat' file is needed). To download a free GeoIP Standard Country
database, go to

http://maxmind.com/download/geoip/database/

Install

Just place the 'geoip.inc' file somewhere according to the 'include_path' directive of
your 'php.ini' file, or just place it in the same directory as your PHP scripts.

Usage

Gets country name by hostname :

include("geoip.inc");

$gi = geoip_open("/usr/local/share/GeoIP/GeoIP.dat",GEOIP_STANDARD);

echo geoip_country_code_by_addr($gi, "24.24.24.24") . "\t" .
geoip_country_name_by_addr($gi, "24.24.24.24") . "\n";
echo geoip_country_code_by_addr($gi, "80.24.24.24") . "\t" .
geoip_country_name_by_addr($gi, "80.24.24.24") . "\n";

geoip_close($gi);

Memory Caching:
To enable memory caching, pass GEOIP_SHARED_MEMORY or
GEOIP_MEMORY_CACHE to the second argument of geoip_open

For GEOIP_SHARED_MEMORY, requires php >= 4.0.4,
and --enable-shmop passed at configure time, see
http://us2.php.net/manual/en/ref.shmop.php
In addition, you should call geoip_load_shared_mem
before calling geoip_open. See sample_city.php for an
example of shared memory caching.

Working with PHP5.
geoip_country_code_by_addr should work
with PHP.