开发者

PHP - Image get current URL for referring URL

Let's say I have a PHP file disguised as an image. Anyway开发者_高级运维s, I want to log all of the clicks from it and where it was clicked it.

Right now, I'm using http://www.webcheatsheet.com/PHP/get_current_page_url.php but does not help. All I get is where the image is HOSTED on. I want where the image is clicked from... like where on the web was that image found, you know?


As esqew commented, you need to check the referrer with $_SERVER['HTTP_REFERRER']. The reason that the current page URL doesn't get what you want, is because the current page would be that image script of yours.

You should note though that the client doesn't have to submit a referrer. In most cases it will, but it is not required to. Furthermore, there may not even be a referrer if the image is accessed directly.

Finally, do not rely on that referrer for any sort of security, as it can be easily changed by the client.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜