I’ve got some file on
I’ve got another file on
And inside this 2nd one I call 1st one this way
www.aaa.com/file.php to get url of site that has called it.
Is it possible?
www.aaa.com/file.php -> it gets
www.another.com calls it -> it gets
Something like ‘who’ve called me from another server and what server was it?’
Actually, no, as it isn’t as obvious as Captain Payalytic said it was, here is how to do it.
$referer = "http://abc.info"; $opts = array( 'http'=>array( 'header'=>array("Referer: $referer\r\n") ) ); $context = stream_context_create($opts); file_put_contents($img, file_get_contents($node_img, false, $context));
After getting a headache on the official doc, not saying a word about referers, I finally did a classic search on the web and immediately found this. Hooray!
EDIT: The doc says
header should be a string though ( http://be2.php.net/manual/en/context.http.php ). One should check if it works with an array too.
Alternatively you should also be able to retrieve the domain’s name from the IP of the request received. (Not always though)
You could also use
You need to pass the referrer as an argument to
It is not possible for the second server to get the original referrer otherwise.
See http://php.net/manual/en/function.file-get-contents.php where you will find out about get_headers() and $http_response_header.