Perl Programming
 
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 LanguagesPerl Programming

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 April 28th, 2000, 10:18 AM
Projecto EINet Projecto EINet is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 1999
Location: Seixal, Portugal
Posts: 19 Projecto EINet User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #2  
Old April 28th, 2000, 05:39 PM
freebsd
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
## 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.

Reply With Quote
  #3  
Old April 28th, 2000, 07:32 PM
Projecto EINet Projecto EINet is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 1999
Location: Seixal, Portugal
Posts: 19 Projecto EINet User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks. Thanks. And thanks again.

------------------
Projecto EINet

Reply With Quote
  #4  
Old April 29th, 2000, 09:13 AM
Projecto EINet Projecto EINet is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 1999
Location: Seixal, Portugal
Posts: 19 Projecto EINet User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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).]

Reply With Quote
  #5  
Old April 29th, 2000, 09:36 AM
freebsd
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
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.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > How to guess visitors country without DNS

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