Solved

How to get the remote_host  name of a visitor?

Posted on 2001-07-21
12
895 Views
Last Modified: 2008-03-10
Dear Experts,
I am using php and i would like to apply statistic information for my site.

Using The Apache - php variable $REMOTE_ADDR i have the remote IP of each visitor.
I need to know the location (the server name) from which the user is connected to the internet, such as to say that :

visitor #1 IP:195.97.50.61 connected from vdp029.lar01.cas.hol.gr at time (timestamp of visitor 1)

visitor #2 IP:212.205.88.209 connected from 212.205.88.209.stsnet.gr at time (timestamp of visitor 2)
.
.
.

Could anyone help me?
Thanks

0
Comment
Question by:spap
  • 3
  • 3
  • 2
  • +3
12 Comments
 
LVL 15

Expert Comment

by:a.marsh
Comment Utility
Rather than re-inventing the wheel, it might be worthwhile you checking out:

http://www.hotscripts.com/PHP/Scripts_and_Programs/Web_Traffic_Analysis/

Ant
0
 
LVL 15

Accepted Solution

by:
a.marsh earned 200 total points
Comment Utility
0
 
LVL 8

Expert Comment

by:us111
Comment Utility
If you'd like to get the real name (vdp029.lar01.cas.hol.gr) you need a whois scripts
http://www.hotscripts.com/PHP/Scripts_and_Programs/Networking_Tools/Whois/

All links provides by a.marsh are good.
0
 
LVL 2

Expert Comment

by:higijj
Comment Utility
0
 
LVL 1

Expert Comment

by:manucorp
Comment Utility
echo "visitor #1 IP:".$REMOTE_ADDR." connected from ".gesthostbyaddr($REMOTE_ADDR) at time (".date("D M j G:i:s Y").")";
0
 
LVL 1

Author Comment

by:spap
Comment Utility
Ok Thanks All of you for your inerest. I need some time to evaluate the comments.

So far I tried the gesthostbyaddr command. The problem with this command is that the most ip adresses connot be resolved. As a result, in most cases, the gethostbyaddr returns the ip itselft.

 I have to try the us111 and the hqijj comment before accepting the a.marsh comment as an answer.

In case that the us111 or the hqijj comments overlap with the a.marsh comment i will accept the a.marsh's because it was the first response to my question.

Thanks all of you once again.
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 1

Author Comment

by:spap
Comment Utility
Hi. the problem has as follows.
while the nslookup and host command of the linux works perfect in resolving an ip address, the php command

gesthostbyaddr($REMOTE_ADDR) does not work properly.

i.e

linux:
bash-2.04$ nslookup 213.249.18.67
Server:  localhost
Address:  127.0.0.1

Name:    cekif1.panafonet.gr
Address:  213.249.18.67        
---------------------------------------

bash-2.04$ host 213.249.18.67
67.18.249.213.IN-ADDR.ARPA domain name pointer cekif1.panafonet.gr
bash-2.04$    

------------------------------------------------

echo gesthostbyaddr(213.249.18.67);
output:213.249.18.67


what is going wrong?


0
 
LVL 2

Expert Comment

by:higijj
Comment Utility
try using this instead of gethostbyaddr

echo gethostbyname(213.249.18.67);
0
 
LVL 1

Author Comment

by:spap
Comment Utility
No hiqijj it does not work. the result is the ip itself.
0
 
LVL 1

Expert Comment

by:Moondancer
Comment Utility
It's time to clean up this topic area and that means taking care of this question. Your options at this point are:

1. Award points to the Expert who provided an answer, or who helped you most. Do this by clicking on the "Accept Comment as Answer" button that lies above and to the right of the appropriate expert's name.

2. PAQ the question because the information might be useful to others, but was not useful to you. To use this option, you must state why the question is no longer useful to you, and the experts need to let me know if they feel that you're being unfair.

3.  Ask Community Support to help split points between participating experts.  Just comment here with details.

4.  Delete the question because it is of no value to you or to anyone else.  To use this option, you must state why the question is no longer useful to you, and the experts need to let me know if they feel that you're being unfair.

If you elect for option 2, 3 or 4, just post comment with details here and I'll take it from there.  We also request that you review any other open questions you might have and update/close them.  Display all your question history from your Member Profile to view details.

PLEASE DO NOT AWARD THE POINTS TO ME.

____________________________________________



Hi Experts:

In the event that the Asker does not respond, I would very much appreciate your opinions as to which Expert ought to receive points (if any) as a result of this question.  Likewise, you can also suggest that I PAQ or delete the question.

Experts, please do not add further "answer" information to this question.  I will be back in about one week to finalize this question.

Thank you everyone.

Moondancer :)
Community Support Moderator @ Experts Exchange

P.S.  REGARDING POINTS, Guidelines and more:  http://www.experts-exchange.com/jsp/cmtyHelpDesk.jsp  
0
 
LVL 15

Expert Comment

by:a.marsh
Comment Utility
spap's earlier comment says:


Comment
From: spap  Date: 07/24/2001 06:10AM PST  
Ok Thanks All of you for your inerest. I need some time to evaluate the comments.

So far I tried the gesthostbyaddr command. The problem with this command is that the most ip adresses
connot be resolved. As a result, in most cases, the gethostbyaddr returns the ip itselft.

I have to try the us111 and the hqijj comment before accepting the a.marsh comment as an answer.

In case that the us111 or the hqijj comments overlap with the a.marsh comment i will accept the a.marsh's
because it was the first response to my question.

Thanks all of you once again.  

------------------------------------------


:o)

Ant
0
 
LVL 1

Expert Comment

by:Moondancer
Comment Utility
Finalized by:
Moondancer
Community Support Moderator @ Experts Exchange
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now