Results 1 to 3 of 3

Thread: IP Based Image

  1. #1
    Join Date
    Jul 2006

    IP Based Image

    Hi, i have a banner area on my website where i would like to display an image. I would like to display a different image in the banner area, depending on a users' location.

    I have 4 different images:

    01 - usa_banner.jpg (default)
    02 - europe_banner.jpg
    03 - uk_banner.jpg
    04 - australia_banner.jpg

    If a user views the site from a country outside of the top 4 areas, then i would like to display the default usa_banner.jpg image.

    I have created my site using codeigniter. What is the best way to work out the IP ranges etc. Any advice on this would be greatly appreciated. Thanks in advance...

  2. #2
    Join Date
    Nov 2012

    Lightbulb From Google and Stack Overflow

    I searched your query on Google and found a great Stack Overflow thread. In summary here is the solutions:

    You can use APIs:

    Hostinfo API:

    Or you can use a local database on your server, it does need to be updated regularly though.

    If you have money, you can use the Maxmind GeoAPI built-in to your PHP server.

    You want to check the original stack overflow thread here http://stackoverflow.com/questions/3...dress-with-php

  3. #3
    Join Date
    Jul 2010
    You shouldn't use an API when you already have existing data on your machine to do this.

    you can use apache2's mod_geoip (apt-get install apache2-mod-geoip or yum install mod_geoip.x86_64)

    then, restart apache2. and now
    nano /var/www/html/geoiptest.php
    PHP Code:
    "Country: " $country_name;
    It worked like a charm for me.

    Country: United States
    I use (, ; : -) as I please- instead of learning the English language specification: I decided to learn Scheme and Java;

Thread Information

Users Browsing this Thread

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center