PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 27th, 2012, 09:42 AM
oo7ml oo7ml is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2011
Posts: 189 oo7ml User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 h 55 m 34 sec
Reputation Power: 2
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...

Reply With Quote
  #2  
Old December 27th, 2012, 11:30 AM
Jacques1's Avatar
Jacques1 Jacques1 is online now
pollyanna
Click here for more information.
 
Join Date: Jul 2012
Location: Germany
Posts: 1,855 Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 1 Day 16 h 16 m 32 sec
Reputation Power: 813
Hi,

your friend Google will tell you everything you need to know. Just search for "ip location" or "geolocation".

PHP even has an extension for this, but I don't know how it works and how good it is.

Reply With Quote
  #3  
Old December 27th, 2012, 12:35 PM
navnav's Avatar
navnav navnav is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Location: Oxford, United Kingdom
Posts: 40 navnav User rank is Private First Class (20 - 50 Reputation Level)navnav User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Day 2 h 18 m 23 sec
Reputation Power: 1
Send a message via Skype to navnav
If you do decide to use a 'IP To Location' API, don't do it during page requests. If for whatever reason the API fails to respond, you'll be keeping your users waiting. And that's not cool.

Do it through AJAX. Perform the page request as normal and then have JS/JQuery make an AJAX request to your server, where your server talks to the API. Or even better, if the API supports JSONP and does not require any kind of auth, do it all through the client and the API. Meaning, your server can kick back and do nothing xD

Either way, I would advise not to perform an API requests during a page request. You could end up annoying a lot of users without even realising.

Reply With Quote
  #4  
Old December 27th, 2012, 01:59 PM
oo7ml oo7ml is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2011
Posts: 189 oo7ml User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 h 55 m 34 sec
Reputation Power: 2
Hi NavNav, thanks for your reply... can you elaborate on what you mean, thanks in advance

Reply With Quote
  #5  
Old December 27th, 2012, 04:47 PM
navnav's Avatar
navnav navnav is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Location: Oxford, United Kingdom
Posts: 40 navnav User rank is Private First Class (20 - 50 Reputation Level)navnav User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Day 2 h 18 m 23 sec
Reputation Power: 1
Send a message via Skype to navnav
Quote:
Originally Posted by oo7ml
Hi NavNav, thanks for your reply... can you elaborate on what you mean, thanks in advance


Well, an 'IP To location' API is just a small web service that has access to a large DB of IP addresses and their geo location data (country, city, ect ect).

Developers can use the API by simply passing an IP address to it, and having the API return the geo data of that IP.

So we can take our visitors IP, pass it to the API and it will return the geo data for that IP (meaning, we will know where the user is based (the country and city).

There's loads of them out there. Most are free, but some may charge.

What I was saying in my previous post was that if you do use this method to trace a user by IP, don't do it during page requests.

When using a web service API, you're making HTTP requests and you're waiting for those requests to come back with a response. If the API you're requesting is running slow for whatever reason, your HTTP request will take a while to complete. So, if you make the HTTP request (talk to the API) during a page request and the API is having a bad day (running rather slow), your user will be kept waiting as the page request will not proceed until the HTTP request is complete. So you're basically having your site/app's performance depend on that API.

So, that's why you shouldn't do it. Instead, do not talk to the API during page requests but do it after the page request is complete, with JS and AJAX.

Simply have your page(s) make AJAX requests to your server from the client side (users machine). It will request a script on your server which then talks to the API (makes the appropriate HTTP requests) and returns the response. Then you can have JS change/load the specific image, based on the response.

Reply With Quote
  #6  
Old December 28th, 2012, 09:04 AM
oo7ml oo7ml is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2011
Posts: 189 oo7ml User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 h 55 m 34 sec
Reputation Power: 2
Ok cool, thanks, that makes perfect sense

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > IP Based Image

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap