I've got some file on www.aaa.com/file.php
I've got another file on www.saveme.com/file2.php
And inside this 2nd one I call 1st one this way file_get_contents('www.aaa.com/file.php');
I want www.aaa.com/file.php
to get url of site that has called it.
Is it possible?
www.lol.com
calls www.aaa.com/file.php
-> it gets www.lol.pl
www.another.com
calls it -> it gets www.another.com
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));
Source: http://thuannvn.blogspot.be/2011/12/how-to-set-referer-in-php.html
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 curl
too.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With