Mobile app version of vmapp.org
Login or Join
Kevin317

: How to check if someone is using my website resources? How can I check whether someone is using the resources hosted on my website? I have a website (coded in PHP) and I have uploaded a

@Kevin317

Posted in: #Images #Php #Url #WebDevelopment

How can I check whether someone is using the resources hosted on my website?

I have a website (coded in PHP) and I have uploaded a few images there. I want to know who is using those images on other sites. Normally, the people use image URL to access and display images from my website.

I don't need the code, just need some guidelines. If you can give me some pseudo code, that's appreciated too :P

EDIT:
Seeing the responses, I feel that my question was't well-versed, so to rephrase:


I need the PHP code to check who is using images hosted on my site


Is this possible in PHP? If yes, what should be the algorithm for it? Any coding guidelines?

10.03% popularity Vote Up Vote Down


Login to follow query

More posts by @Kevin317

3 Comments

Sorted by latest first Latest Oldest Best

 

@LarsenBagley505

This guide goes over protecting your sites resources using PHP
safalra.com/programming/php/prevent-hotlinking/

10% popularity Vote Up Vote Down


 

@Rambettina238

There is no way to find out any information about requests made directly to images hosted on your site using PHP. Since the image served up statically, no PHP script is executed.

You could keep all your images outside your webroot, and load them all through a PHP script that:


Checks the query string to figure out which image to serve
Makes sure the image exists
Outputs a suitable content-type header
Outputs a suitable set of cache control headers
Reads the image data and outputs it


It would also have to deal with If-Modified-Since requests and so on. (So this would be a lot of effort to get right).

Once that was done, you could log any of the information in $_SERVER, including $_SERVER['HTTP_REFERER'] which would tell you the URL of a website linking to or embedding your image (providing the user of the browser did nothing to conceal the referrer header).

You are really much better off just getting the referer information from your webserver's logs.

10% popularity Vote Up Vote Down


 

@Deb1703797

You can log the referer:

$_SERVER['HTTP_REFERER'];


But please note that this is added by the client and can be overridden. But it should give you some indication to how your site is used.

You can also use something like google analytics to track the users.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme