CodeIgniter Forums
Get the URL of a HotLinked image - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forum-21.html)
+--- Thread: Get the URL of a HotLinked image (/thread-6676.html)



Get the URL of a HotLinked image - El Forum - 03-07-2008

[eluser]tank6b[/eluser]
Hi All,

Thanks to the great community here I have managed to solve one issue, now I have other one:
How I can know the url that is hotlinking a image I'm serving inside CI.

So the image I'm serving like this
http://ellislab.com/forums/viewthread/73281/

Now I want to know what pages are displaying the image.

Thanks in advanced


Get the URL of a HotLinked image - El Forum - 03-07-2008

[eluser]webthink[/eluser]
You want to know the referring url is for the image? You can use $_SERVER['HTTP_REFERER'] Have I understood?


Get the URL of a HotLinked image - El Forum - 03-07-2008

[eluser]tank6b[/eluser]
$_SERVER[’HTTP_REFERER’] will only work if the page was visited via a click but not if it is a direct visit.


Get the URL of a HotLinked image - El Forum - 03-07-2008

[eluser]webthink[/eluser]
so if it is set you record the referrer and if it isn't you know there is no referrer so there is nothing to record. I guess I'm not really sure what the issue is.


Get the URL of a HotLinked image - El Forum - 03-07-2008

[eluser]tank6b[/eluser]
The images will be hotlinked from my site, that's why I have to keep track of where they are been displayed.

Referer will only be set if the page was visited via other page, when you jup to a link from the address bar directly no referer will be set as far as I know.


Get the URL of a HotLinked image - El Forum - 03-07-2008

[eluser]webthink[/eluser]
You have a controller which is responsible for file-reading the images and then serves the image data via the header correct? and presumably you have links on other pages which point to that page. If I understand you correctly you're interested in knowing which links are being clicked to access you image serving script. So in the image serving controller you check HTTP_REFERER and if it's set you have the referring page to do what you want with. If it isn't you know that an attempt was made to access the page directly.

Perhaps a better description of your requirements would help.