I have some code that is called from with other files, using readfile so there is no referer etc.

To authenticate that the request is where it should be from, the php is passed a calling url as part of it parameters.

The idea is that I can then check the calling IP is from the correct machine. This works fine in most cases, however on some machines (I'm guessing VPS) the Server address is not what the DNS returns even though the domain name is hosted on that PC.

Here is my code.

$ip = gethostbyname($domain);

if ($ip != $_SERVER["REMOTE_ADDR"])
{	echo "URL does not match requesting IP address<br>\n";
	echo "$domain - $ip<br>\n";
	echo $_SERVER["REMOTE_ADDR"]."<br>\n";

In theory the REMOTE_ADDR and the IP returned from gethostbyname should match but they don't anybody any ideas how to get round this?

try these line and see what you get?


$hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']) ;


best of luck with the job.

Surely on a shared serverm that would just give you the name of the shared server, not the domain name that is calling you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.