Welcome Guest ( Log In | Register )



 
Reply to this topicStart new topic
> Where's Your Visitor?, THIS ARTICLE IS FOR PHP CODERS
PureHeart
post Oct 8 2005, 01:26 PM
Post #1


Premium Member
Group Icon

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 !

Go to the top of the page
 
+Quote Post
Quatrux
post Oct 9 2005, 07:24 AM
Post #2


the Q
Group Icon

Group: [HOSTED]
Posts: 1,022
Joined: 13-July 05
From: Lithuania, Vilnius
Member No.: 7,059



yea, good article biggrin.gif making yourself a database of ips.. I think databases like that already exist, but why not connect to other site match and get a reply which country it is, it makes the execution slower, but.. like connecting to ripe.net or what is their address, I forgot. Also people coul't be using proxy, so you could use:

CODE

$_SERVER["HTTP_X_FORWARDED_FOR"];
$_SERVER["HTTP_CLIENT_IP"];
Go to the top of the page
 
+Quote Post
twitch
post Oct 9 2005, 08:03 AM
Post #3


Veteran Nut
Group Icon

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.
Go to the top of the page
 
+Quote Post
NguyenVanThoai
post Oct 10 2005, 12:03 AM
Post #4


Member [ Level 1 ]
Group Icon

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.
Go to the top of the page
 
+Quote Post
ruben
post Oct 21 2005, 08:33 PM
Post #5


Wheeeeeeee!
Group Icon

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
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Dns Warns Of Pharming Attacks(5)
  2. Dedicated Coders Needed(1)
  3. A Great Article For The Criticising Linux Newbies(13)
  4. Coders Funny Phrases(6)
  5. Know Of Any Site Visitor Live Reporter(1)
  6. Do You Know Of Any Good Free WAP Enabled Forum(18)
  7. JavaScript: A Welcome To Visitors Script(8)
  8. Article On Concurrency In Java(0)
  9. Blog Software Or Content Management System(7)
  10. Wisetome.com(0)
  11. Visitor Hit Counter Script?(7)
  12. An Article On Basics Of Western Classical Music(5)
  13. Coders Wanted(7)
  14. Raptor Vs Raid(3)
  15. Ant And Larvae(6)
  1. "Command Prompt"(5)
  2. Bulletproof HTML: 37 Steps To Perfect Markup(4)
  3. Geese Formation(9)
  4. Internet Explorer 7 Vs Firefox 2(15)
  5. Windows Vista(17)
  6. Article On Rss(4)
  7. Ajax + Php + Sql = Simply Superb! ( With Visitor Tracking )(10)
  8. Ajax+php+sql=simply Superb!(with Visitor Tracking) :: Section 2 (retrive Values From Database And Dynamic Update!)(2)
  9. Internet Marketing Strategy Article(0)
  10. Fox With Feather(0)
  11. Coders Needed To Help On A Bulletin Board System (BBS)(4)
  12. How To Call A Dll From Delphi(0)
  13. Easy Visitor Counter(3)


 



- Lo-Fi Version Time is now: 5th September 2008 - 06:38 AM