19 Feb, 2003
Disable right clicking and protecting your images with php
Posted by: Jennifer In: Bookmarks
The post below brought up some questions about how to protect your site/images, etc. One request was to prevent right clicking. So here's a script that does that: Disable Right Clicking. (Please note: that script is not "fool-proof" – there IS a fairly easy way around it). Also requested was a way to prevent images from being downloaded or linked to directly. I haven't tried this out (I will tonight) but I found this script that may do the trick: php script that protects your images.
If it works, I'll post the "demo" link here so you can see them in action. (If it doesn't – then I'll either yank this post or keep it up if there's some useful commentary)
Update: Ok, it works, sort of. You won't have people linking to your images directly, they can't type the image path directly into their browser… BUT they CAN download the image if they get past the right-clicking thing…
Here's a demo
Update 2: Jason came up with a better way (see comments of this post) Rather than disabling right clicking, make a table of one cell the same size as your image, with a 1 pix transparent gif, set to the same size as the image. place the image in the background of the cell by using the php script above: background="chimage.php?image=file.gif". Modify the chimage.php script (get the full code from the link above) as such: Look for this line: if (empty($referrer) || isreferrerokay( $referrer, $validprefixes )) { and change it to this: if (isreferrerokay( $referrer, $validprefixes )) {. Here's a demo of that.