|
|
|
|
![]() ![]() |
Oct 8 2005, 01:26 PM
Post
#1
|
|
|
Premium Member Group: Members Posts: 209 Joined: 7-October 05 From: Đà Nẵng City - Việt Nam Member No.: 8,966 |
THIS ARTICLE IS FOR PHP CODERS
Have you ever wondered where you visitor is? This can be done with some very simple lines of code. Intro: the basic of this technique is to detect the visitor's IP address. After that we can process it for information about the location. In PHP, there's a environment var that's called REMOTE_ADDR. It contain the client's IP address. The code is as following CODE <?php $clientIP=getenv("REMOTE_ADDR"); echo $clientIP; ?> Now, you know the visitor's IP. What next. You have to process it to know where you visitor is (too easy, right?). For example An IP begin with 222.252 is from Vietnam An IP begin with 250.234 is from US You'll need a list for that.( I don't have it here.) Good luck ! |
|
|
|
Oct 9 2005, 07:24 AM
Post
#2
|
|
|
the Q Group: [HOSTED] Posts: 1,022 Joined: 13-July 05 From: Lithuania, Vilnius Member No.: 7,059 |
yea, good article
CODE $_SERVER["HTTP_X_FORWARDED_FOR"]; $_SERVER["HTTP_CLIENT_IP"]; |
|
|
|
Oct 9 2005, 08:03 AM
Post
#3
|
|
|
Veteran Nut Group: Members Posts: 527 Joined: 4-October 05 From: UK Member No.: 8,895 |
Is amnesia an airborn disease, because it is spreading like wild-fire. People are forgetting a lot. And PureHeart, please go to the best lengths to complete a tutorial, so far you have showed something that I, as a PHP dunce can do. Quatrux, your post was slightly confusing.
The list I believe can be dynamically generated at the time of the first execution of the script. I believe it is the first three numbers that defines the place. Although I am not sure. Alternatively, if you have some kind of login system, that holds users details then you can just use PHP to access the database and cross-reference the IP with the member. |
|
|
|
Oct 10 2005, 12:03 AM
Post
#4
|
|
|
Member [ Level 1 ] Group: Members Posts: 35 Joined: 28-February 05 From: Danang City - Vietnam Member No.: 2,823 |
Thanks for the article, PureHeart.
But guys, do you know where can I find a such list of country. I may need a database to begin. |
|
|
|
Oct 21 2005, 08:33 PM
Post
#5
|
|
|
Wheeeeeeee! Group: Members Posts: 245 Joined: 19-October 05 From: DG, Belgium Member No.: 9,200 |
Hej!
I think this was a pretty useless article, since this is only one simply PHP command, everyone can figure THAT out. But it is a more complex science about which I don't know much. This Page shows that you can find out much more (even though they located me wrong :-/) A database (a simple google search did it...), I found here: ip.ludost.net It is updated daily and "on your own risk" but it's free and huge. They post the IP and afterwards the country code (The real names for country codes, you can find here: Country-Codes) Hope this helps! Would be nice if you posted your code when you're finished, that would make a REAL How-To! I don't need it because I think most stats supply this data (anonymously – better) anyway. peace out, ruben |
|
|
|
![]() ![]() |
Similar Topics
|
Lo-Fi Version | Time is now: 5th September 2008 - 06:38 AM |