Solved

PHP Get user remote domain name

Posted on 2014-03-26
3
1,243 Views
Last Modified: 2014-03-26
Hello Experts.

There is a way to get users IP using $_SERVER['REMOTE_ADDR'], etc.
But how can i get user's domain?

I have a page that returns a json response.

that page is consulted by another website using the function "file_get_contents" and that website is "www.mydomain.org".

Can i get the domain name the consulted me ("www.mydomain.org") besides his IP address?
0
Comment
Question by:justaphase
  • 2
3 Comments
 
LVL 108

Accepted Solution

by:
Ray Paseur earned 500 total points
ID: 39955805
No.  Clients do not have a domain name.  You may coincidentally be able to do a reverse IP lookup and find that some REMOTE_ADDR are associated with a domain, but it's not something that is dependable at all.  For example, which of my 32 web sites is my REMOTE_ADDR associated with?  My email is at Gmail, but so are millions of others.  It's just not information that exists in any way that you can use.
0
 
LVL 1

Author Closing Comment

by:justaphase
ID: 39955976
You're right..
That's what i'm gonna do.
Something like this:

$array = array(
"www.domain1.com" => gethostbyname("www.domain1.com")
,"www.domain2.pt" => gethostbyname("www.domain2.pt")
,"www.domain3.org" => gethostbyname("www.domain3.org")
);

while ($ip = current($array)) {
      if ($_SERVER['REMOTE_ADDR'] == $ip) echo "it's one of my clients";
      next($array);
}

Thx for the help :)
0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 39956008
Before you write that while() loop you might want to look up foreach().  Just a thought.  Thanks for the points and thanks for using EE, ~Ray
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

863 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

24 Experts available now in Live!

Get 1:1 Help Now