Jump to content
xisto Community
Sign in to follow this  
PureHeart

Where's Your Visitor? THIS ARTICLE IS FOR PHP CODERS

Recommended Posts

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

 

<?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 !

Share this post


Link to post
Share on other sites

yea, good article :mellow: 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:

$_SERVER["HTTP_X_FORWARDED_FOR"];$_SERVER["HTTP_CLIENT_IP"];

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.