A LIST Apart: For People Who Make Websites

No. 185

Discuss: Smarter Image Hotlinking Prevention

Pages

 1 2 3 >  Last »

1 Error?

When I click the final link to the “nicely formatted image” it only showed the credit line the first time – on all subsequent visits it only showed the image as it normally would. This was in Firefox .9.

posted at 12:24 pm on July 13, 2004 by Mark H.

2 Not working

In Opera 7.52 with referrer logging turned on, the last page only shows the credit line (even after reload). With referrer logging turned on, it only shows the picture (as in only the picture – not a html page).

Regardless, the article gets the idea across :)

posted at 12:39 pm on July 13, 2004 by Svein A.

3 Not working (correction)

I meant to say:
With referrer logging turned OFF, it only shows the picture (as in only the picture – not a html page).

posted at 12:40 pm on July 13, 2004 by Svein A.

4 IE and Opera

Testing in IE 6 and Opera 7.52, the “Nope, guess not” page does have a broken image at the end.

Svein, I didn’t know Opera could disable refer logging. Good to know. Thanks.

posted at 12:48 pm on July 13, 2004 by Brian

5 Mozilla

For got to mention, while Mark is correct in regards to the way Firefox is displaying the page, Mozilla 1.7 and the latest K-Meleon (which is essentially a modified Mozilla 1.5.) Display the last page as intended (or as I believe was intended).

posted at 12:51 pm on July 13, 2004 by Brian

6 Saved time...

I had been researching the finer points of this over the last day or so (casually) when your post appeared on my RssReader.

All of the posts worked will for me in Firefox .9, IE6 and the RssReader preview pane.

I will be implementing this for my clients in the next version of my CMS. Thanks!

posted at 12:54 pm on July 13, 2004 by Jason Wassing

7 A Few Suggestions

The link at the end of the section titled “Where do we go from here?” should be [img]http://www.yoursite.com/showpic.php?pic=yourimage.gif[/img].

I’d also like to point out that since PHP 4.2.0 register globals is OFF by default and thus using $pic alone will not get you the results you expect; try using $_GET[“pic”] instead.

posted at 12:54 pm on July 13, 2004 by Ed

8 browser cache

Hmm, after reading some of the above comments I trying refressing the final, html page and everything seems fine. Then I closed the tab (in Firefox) and clicked on the link in the article again. This time I got the image only (no HTML). I then closed that tab, cleared the browser’s cache and clicked on the link in the article again. Ahha, I see the HTML page again.

So apparently, when a user first clicks on the link, it works as intended, but on any subsequant visits, the browser first checks the cache for an image by that name (remember, with mod_rewrite we never change the url as we would with a redirect so the browser doesn’t know the difference) and if it finds it, the image is displayed from cache without the HTML. Only when no such image is found is a request made which then triggers this script.

Personaly, I realy don’t see this as a big problem, as the hotlink has already been interupted, but I wonder if this could be avoided by telling the browser not to cache the image (with additional headers).

posted at 01:02 pm on July 13, 2004 by waylman

9 Why .jpg-Extension?

I donīt see why the file extension of the PHP generated page has to be “.jpg” – it is neither a JPEG nor is the content “type image/jpeg”. If you present the user a HTML page, donīt confuse him by obfuscating the original file type.

Anyway, I like the idea behind your article though. Thanks!

posted at 01:10 pm on July 13, 2004 by Lars

10 RE: A Few Suggestions

Ed,
No the link as it appears in the article it correct. That is the point of the rewrite rule. When someone links directly to your image from their site, they are redirected to [img]http://www.yoursite.com/showpic.php?pic=yourimage.gif[/img]. This redirect is transparent to the user and the browser as it is all handled on the server. I would suggest rereading the article.

However, you do have a point with the register globals thing. That could present a problem to some.

posted at 01:11 pm on July 13, 2004 by waylman

Pages

 1 2 3 >  Last »

Discussion Closed

New comments are not being accepted, but you are welcome to explore what people said before we closed the door.

Got something to say?

Discuss this article. We reserve the right to delete flames, trolls, and wood nymphs.

Create a new account or sign in below if you’d like to leave a comment.

Remember me

Forgot your password?

Subscribe to this article's comments: RSS (what’s this?)