[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 934
  • Last Modified:

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

0
spap
Asked:
spap
  • 3
  • 3
  • 2
  • +3
1 Solution
 
a.marshCommented:
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
 
us111Commented:
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
higijjCommented:
0
 
manucorpCommented:
echo "visitor #1 IP:".$REMOTE_ADDR." connected from ".gesthostbyaddr($REMOTE_ADDR) at time (".date("D M j G:i:s Y").")";
0
 
spapAuthor Commented:
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
 
spapAuthor Commented:
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
 
higijjCommented:
try using this instead of gethostbyaddr

echo gethostbyname(213.249.18.67);
0
 
spapAuthor Commented:
No hiqijj it does not work. the result is the ip itself.
0
 
MoondancerCommented:
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
 
a.marshCommented:
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
 
MoondancerCommented:
Finalized by:
Moondancer
Community Support Moderator @ Experts Exchange
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 3
  • 2
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now