Link to home
Start Free TrialLog in
Avatar of spap
spap

asked on

How to get the remote_host name of a visitor?

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

Avatar of a.marsh
a.marsh

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
ASKER CERTIFIED SOLUTION
Avatar of a.marsh
a.marsh

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
echo "visitor #1 IP:".$REMOTE_ADDR." connected from ".gesthostbyaddr($REMOTE_ADDR) at time (".date("D M j G:i:s Y").")";
Avatar of spap

ASKER

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.
Avatar of spap

ASKER

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?


try using this instead of gethostbyaddr

echo gethostbyname(213.249.18.67);
Avatar of spap

ASKER

No hiqijj it does not work. the result is the ip itself.
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:  https://www.experts-exchange.com/jsp/cmtyHelpDesk.jsp  
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
Finalized by:
Moondancer
Community Support Moderator @ Experts Exchange