Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #12249
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news-1.dfn.de!news.dfn.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail |
|---|---|
| From | Arno Welzel <usenet@arnowelzel.de> |
| Newsgroups | comp.lang.php, alt.php |
| Subject | Re: recognize country |
| Date | Sun, 15 Dec 2013 15:22:45 +0100 |
| Lines | 87 |
| Message-ID | <52ADBB35.5080504@arnowelzel.de> (permalink) |
| References | <125kyzt66kwku$.q6ywosnout0r.dlg@40tude.net> <461fsbu98jld.1vftfxn0dl3dg.dlg@40tude.net> <l8irus$dsf$1@dont-email.me> <10m4kg1lqaghb$.1qos4ncc1tq11$.dlg@40tude.net> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Content-Transfer-Encoding | 7bit |
| X-Trace | individual.net QtWLEzAaS8jhRQljjt4VhgHlKRJgzn+gs5EamSLG1wmeO4Vtuv |
| Cancel-Lock | sha1:+wDgGq+9xQ7FLC14MVXTA4bPnv0= |
| User-Agent | Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 |
| In-Reply-To | <10m4kg1lqaghb$.1qos4ncc1tq11$.dlg@40tude.net> |
| X-Enigmail-Version | 1.6 |
| Xref | csiph.com comp.lang.php:12249 |
Cross-posted to 2 groups.
Show key headers only | View raw
nawfer, 2013-12-15 11:34:
>>> GeoIP.
>>
>> Which is just as accurate as any other IP-based location service. IOW,
>> not very.
>
> but is a online service or one php array or both
> ?
>
>
> but isn't stable the ip of the nations?
> example
> 50.xxx.xxx.xxx to 100.xxx.xxx.xxx all ip nation A
> 101.xxx.xxx.xxx to 150.xxx.xxx.xxx all ip nation B
> 151.xxx.xxx.xxx to 200.xxx.xxx.xxx all ip nation C
No - it does not work that way.
> ok the ip inner nations ip can't be accurate and can to change, but between
> nation is table (every range is assigned at only one nation)?
No.
IP ranges are assigned to providers - and providers can operate in
multiple countries. And by the way - there is also IPv6.
But you still did not answer what you want to achieve.
If you want to handle different languages, you should better use the
Accept-Language header oft the browser - and even then the visitor
should be able to manually select the language, just in case the browser
does not send an Accept-Language header at all or there is no "known"
language in the list of accepted languages.
Also see: <http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html>
And for example - if you have content in English, French in Italian and
you want to deliver it depending on the users browser settings (yes, the
quality value of each language is ignored, since literally all browsers
send the preferred languages in the order of preference):
<?php
// This is the list of languages we support
$knownlanguages = { 'en', 'fr', 'it' };
// This is the active language in which the content
// is being served - 'en' by default
$activelanguage = 'en';
// Build an array of languages based on the Accept-Language
// header the browser sends
$languages = explode(',', preg_replace('/(;q=\d+.\d+)/i',
'', getenv('HTTP_ACCEPT_LANGUAGE')));
// Now go through the list and check if the browser
// supports any of "our" languages
foreach ($languages as $language) {
if (in_array($language, $knownlanguages)) {
// Language is known, then use this and stop
// checking the remaining entries
$activelanguage = $language;
break;
}
}
// Now $activelanguage contains one of our supported
// languages which is also accepted by the browser
?>
BTW: You can see this in action on my private site
<http://arnowelzel.de>. The code is not identical, but very similar. The
site will redirect to the English or German version depending on what
language the browsers prefers or defaults to German if no "known"
language was given. However it is always possible to change the language
using the "language" links in the header.
--
Arno Welzel
http://arnowelzel.de
http://de-rec-fahrrad.de
Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
recognize country nawfer <novalidsforspam@alt.al> - 2013-12-14 14:43 +0100
Re: recognize country Jerry Stuckle <jstucklex@attglobal.net> - 2013-12-14 08:58 -0500
Re: recognize country nawfer <novalidsforspam@alt.al> - 2013-12-15 11:16 +0100
Re: recognize country Jerry Stuckle <jstucklex@attglobal.net> - 2013-12-15 08:37 -0500
Re: recognize country The Natural Philosopher <tnp@invalid.invalid> - 2013-12-14 15:27 +0000
Re: recognize country Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2013-12-14 10:32 -0500
Re: recognize country Christoph Michael Becker <cmbecker69@arcor.de> - 2013-12-14 19:55 +0100
Re: recognize country Jerry Stuckle <jstucklex@attglobal.net> - 2013-12-14 14:52 -0500
Cross-Posting (was: recognize country) Christoph Michael Becker <cmbecker69@arcor.de> - 2013-12-14 21:57 +0100
Re: Cross-Posting Jerry Stuckle <jstucklex@attglobal.net> - 2013-12-14 16:20 -0500
Re: Cross-Posting Christoph Michael Becker <cmbecker69@arcor.de> - 2013-12-14 23:25 +0100
Re: Cross-Posting Jerry Stuckle <jstucklex@attglobal.net> - 2013-12-14 17:36 -0500
Re: Cross-Posting Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-12-14 22:38 +0100
Re: Cross-Posting Christoph Michael Becker <cmbecker69@arcor.de> - 2013-12-14 23:31 +0100
Re: Cross-Posting Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-12-14 23:55 +0100
Re: Cross-Posting Jerry Stuckle <jstucklex@attglobal.net> - 2013-12-14 18:08 -0500
Re: Cross-Posting Christoph Michael Becker <cmbecker69@arcor.de> - 2013-12-15 00:35 +0100
Re: Cross-Posting Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-12-15 01:13 +0100
Re: recognize country richard <noreply@example.com> - 2013-12-14 18:56 -0500
Re: recognize country Jerry Stuckle <jstucklex@attglobal.net> - 2013-12-14 19:09 -0500
Re: recognize country nawfer <novalidsforspam@alt.al> - 2013-12-15 11:34 +0100
Re: recognize country "J.O. Aho" <user@example.net> - 2013-12-15 11:59 +0100
Re: recognize country Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-12-15 12:05 +0100
Re: recognize country Doug Miller <doug_at_milmac_dot_com@example.com> - 2013-12-15 12:51 +0000
Re: recognize country Jerry Stuckle <jstucklex@attglobal.net> - 2013-12-15 08:49 -0500
Re: recognize country Tim Streater <timstreater@greenbee.net> - 2013-12-15 13:13 +0000
Re: recognize country Jerry Stuckle <jstucklex@attglobal.net> - 2013-12-15 08:50 -0500
Re: recognize country Arno Welzel <usenet@arnowelzel.de> - 2013-12-15 15:22 +0100
Re: recognize country The Natural Philosopher <tnp@invalid.invalid> - 2013-12-15 15:35 +0000
Re: recognize country Evan Platt <evan@theobvious.espphotography.com.invalid> - 2013-12-14 21:35 -0800
Re: recognize country Doug Miller <doug_at_milmac_dot_com@example.com> - 2013-12-15 12:42 +0000
Re: recognize country Denis McMahon <denismfmcmahon@gmail.com> - 2013-12-15 15:21 +0000
csiph-web