|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
Hi,
Some times when someone comes to our site we couldnīt get a DNS counterpart for their IP number . But we need it to give them country related news first and global news latter on our home page . There's a place or a way to know from IP numbers where is the server contacting us located . ------------------ Projecto EINet |
|
#2
|
|||
|
|||
|
## host should give the value of $ENV{'REMOTE_HOST'}, otherwise, it will use $ENV{'REMOTE_ADDR'}
## so in this example, $host is the host while $ip is for $ENV{'REMOTE_ADDR'} in short form $ip = $ENV{'REMOTE_ADDR'}; $n = `nslookup $ip | grep Name`; chop($n); $host = substr($n, rindex($n, " ")+1); if ($host eq "") { $host=$ENV{'REMOTE_ADDR'}; } >>But we need it to give them country related news first and global news latter on our home page There are two ways you should do. You can download and install this http://www.perl.com/CPAN-local/modules/by-module/Net/Net-Country-0.1.tar.gz If your site is hosted at someone's server, you can simply place this Country.pm under any subdirectory of your account. For example: /html/your_account/libdata/Net/Country.pm Next, put the following line in your script: use lib "/html/your_account/libdata"; use Net::Country; If you will install Net-Country on your own server, the lib path should be in your path, so you don't need to use the "use lib..." line. The other way is to use http://www.apache.org/docs/mod/mod_mime.html#addlanguage . Also take a look at ENV{'ACCEPT_LANGUAGE'}, but it might not give you a value. |
|
#3
|
|||
|
|||
|
Thanks. Thanks. And thanks again.
------------------ Projecto EINet |
|
#4
|
|||
|
|||
|
Another quest yet.
Does the IP number mean anything or is in any way related with the country where the server is? There's a place where I can get more info about the logic of IP numbers are created. Thanks ------------------ Projecto EINet [This message has been edited by Projecto EINet (edited April 29, 2000).] |
|
#5
|
|||
|
|||
|
No, you are on your own. You need to create a huge db to keep track of that. Country.pm helps you determine the country of a $ENV{'REMOTE_HOST'} based on the right-most prefix delimited by a decimal.
For example, 'somehost.foo.bar.it' -> from Italy. Luckily, there probably aren't any international ISP or your result will be meaningless. You should combine the $ENV{'ACCPET_LANGUAGE'} and http://www.apache.org/docs/mod/mod_negotiation.html#languagepriority plus Country.pm to get a better handle to your case. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Perl Programming > How to guess visitors country without DNS |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|