Added security to stop right click downloading - any takers?

Nigel_Aves

Joined: 2005-07-11
Posts: 61
Posted: Tue, 2005-09-20 06:34

All,

I'm no programmer at all but I do like to try and stop people "taking" on the fly my pictures by the simple "right click - save as". To help deter people from doing this I typically (before using Gallery) added the following Java script (as a side file) and this helps to act as a deterent. I know people could still use screen captute but with the high resolution ones that would make things a lot hard.

Are there any Gallery2 programmers out there willing to do this (or something better if you know of one) as a mod (similiar set up to the incredible Add to Cart / Paypal / Buy Button). I know it's not perfect but every little bit helps.

Many Thanks

Nigel.

(This should be the one thing the user can change during setup.)

var message="I'm sorry, The Right click option on your mouse has been disabled for the download window pages. All images on this page are Copyright Nigel Aves - 2005. Please send me email of the picture name and reason for use and I will probably email you back the high quality version.";

///////////////////////////////////
function clickIE4(){
if (event.button==2){
alert(message);
return false;
}
}

function clickNS4(e){
if (document.layers||document.getElementById&&!document.all){
if (e.which==2||e.which==3){
alert(message);
return false;
}
}
}

if (document.layers){
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=clickNS4;
}
else if (document.all&&!document.getElementById){
document.onmousedown=clickIE4;
}

document.oncontextmenu=new Function("alert(message);return false")

 
RwD
RwD's picture

Joined: 2005-01-09
Posts: 383
Posted: Tue, 2005-09-20 08:48

Well, do the following:

  • Copy the file photo.tpl into "gallery2/themes/*yourtheme*/templates/local" (create dir local if it doesn't exist. photo.tpl is in the templates dir.)
  • Add the following javascript anywhere to the template
<script type="text/javascript">
    document.oncontextmenu = new Function("return false");
</script>

That disables the right click without the message (I hate the message; do you have any idea how often people accidentally right click and have to put up with some message?). You can always insert your code there if you really really really want to.

[lol]By the way, the safest way of disabling people to get your copyrighted stuff is to not put it online ;)[/lol]

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Tue, 2005-09-20 09:18
 
Nigel_Aves

Joined: 2005-07-11
Posts: 61
Posted: Wed, 2005-09-21 01:26

RwD,

I tried this tonight and no matter what, I could not get it to work (I'm using the "Matrix" theme). I even tried copying those lines of java directly into photo.tpl (no local directory) with no success. I checked all the the way down to ensure that Matrix was the theme. Any ideas?

Valient,

I looked at the Patches you suggested and it was a tad over my head. It looked like it was changing one of the "master files" and to be honest I don't like doing that as it is probably beyond my cut and paste scope!

Many thanks to you both ....

Nigel.

 
RwD
RwD's picture

Joined: 2005-01-09
Posts: 383
Posted: Wed, 2005-09-21 06:49

I have no idea which browser you are using. This works for both of the browsers I can test with; IE6 and FF1.0.6.

The top of my photo.tpl when I test this looks like this:

{*
 * $Revision: 1.6 $
 * If you want to customize this file, do not edit it directly since future upgrades
 * may overwrite it.  Instead, copy it into a new directory called "local" and edit that
 * version.  Gallery will look for that file first and use it if it exists.
 *}
<script type="text/javascript">document.oncontextmenu = new Function("return false");</script>

You should check your browser to see which broser you are using and verify you altered a file called "gallery2/themes/matrix/templates/local/photo.tpl"

ps
Older brosers might require the language attribute inside the script element:
<script language="javascript" type="text/javascript">

 
gilrim

Joined: 2005-08-28
Posts: 32
Posted: Wed, 2005-09-21 10:34

a couple of ideas explored earlyer [even tho this won't stop people from just grabbing the image from the browser cache]:

* add another layer, containing a transparent 1x1px gif stretched to the same size as the real image, above the image.
* to attemt to remove the image from cache, you could modify apache to set the image non-cachable (usually used for images from webcams and such).

 
fryfrog

Joined: 2002-10-30
Posts: 3236
Posted: Wed, 2005-09-21 15:46

Another option is a good watermark, IMHO this is the best option. You still have the issue of "view source" pretty much requiring the image path to be there unless you use CSS some how... and then you can view the CSS.

Also, I hate right click disable scripts. I think they suck. I especially hate the ones that pop up a stupid message that says "right click disabled". DUH, thanks I couldn't figure that out on my own. Also, now I can't use any of my favorite right click options like open in new window... so instead of bothering with your "protected" site I just close it.

Disabling right click only stops the most retarded of "image thiefs" but it pisses off everyone that visits your site. Just say no to disabling right click and use something more sophisticated like a watermark that advertises for your site instead!

Like Gallery? Appreciate my help? Think I'm an asshole? Make your point by donating to the Gallery project! Or maybe just visit my website.

 
Nigel_Aves

Joined: 2005-07-11
Posts: 61
Posted: Wed, 2005-09-21 16:38

Rwd,

Using the latest Explorer, Firefox and Mozilla for testing. No matter what I tried (and I did excatly the same as you suggested) it did not work.

I am using "watermarking" so maybe I'll stick with that but I did not want to put the watermark right in the middle of the image (that annoys me as much as "fryfrogs" announcement at disabling right click.)

gilrim,

I'll have a look at this idea over the weekend, sounds interesting. Also, providing disabling cache only works with images then that will not hurt performance to much as the only images needed to be re-loaded would be the thumbnails.

fryfrog,

You'd be surprised how many can not work out that right click has been disabled. I used to have no message and actually recieved emails from people asking why they could not save my images because they had tried on a number of images! So I added the message, emailed one of the original complainers and they wrote thanking me saying that at least now they understood! LOL ... goes to prove that "you can not please all the etc etc ........."

All,

What is so F^%$ed up about it all is that the real problem here are the browser developers. On one hand you have the mighty MicroSofty yelling and screaming about digitial rights and copyrighted material, lets become a bum buddy with Sony to stop illegal downloading of music and video and on and on ... and then they produce browsers that allow saving and printing right in their own interfaces. Now that is the Duhhhhhhhhh. General rule of thumb on the internet is that all images are copyrighted unless explicitly stated.

The whole thing should have been reversed ages ago where I could add a line of code to the html to allow downloading! It's like the tele-marketers, why did they need a "do not call list", would it not have been better to produce a "please call list" :) .... Now those scumbags have found away of calling cell phones and making you pay for the entire call! (make sure your cell phones are on the no call list)

Rant Over .... I know this forum should not be for ranting .....

Nigel.

P.S. fryfrog, your no asshole (or as us Brits would say arsehole) ...

 
mgeisler

Joined: 2005-09-18
Posts: 23
Posted: Sat, 2005-09-24 01:23
Nigel_Aves wrote:
What is so F^%$ed up about it all is that the real problem here are the browser developers. On one hand you have the mighty MicroSofty yelling and screaming about digitial rights and copyrighted material, lets become a bum buddy with Sony to stop illegal downloading of music and video and on and on ... and then they produce browsers that allow saving and printing right in their own interfaces. Now that is the Duhhhhhhhhh.

Uhh... I'm sorry, but do you have any idea of how the Internet works?

The whole idea of preventing people from saving things from the Internet is totally flawed: you simply have to make up your mind: either you give people the data or you keep the data for yourself. You cannot do both at the same time!

Don't try to do the impossible, instead add watermarks to your images and serve only middle-sized photos.

 
Nigel_Aves

Joined: 2005-07-11
Posts: 61
Posted: Sat, 2005-09-24 01:56

Just amazing how many rude people there are, especially in forums ... shame really.

I'm assuming that "mgeisler" must be one of the bum buddies I mentioned because we all know how well the words security and Microsoft go together, looking back at their last 4 operating systems that I've used. (I missed ME thank God).

Oh well, life goes on, let's not try to fix the problem or even make a start or even have a real discussion, let's just keep our front doors open and let anyone take what they want. That seems to be the general concensus of people who seem to be developers on Gallery (mgeisler and fryfrog).

And before anyone mentions "watermarking" again, I do use them, they work well.

Nigel.

 
mgeisler

Joined: 2005-09-18
Posts: 23
Posted: Sat, 2005-09-24 08:40
Nigel_Aves wrote:
Just amazing how many rude people there are, especially in forums ... shame really.

I'm assuming that "mgeisler" must be one of the bum buddies I mentioned because we all know how well the words security and Microsoft go together, looking back at their last 4 operating systems that I've used. (I missed ME thank God).

I didn't mean to be rude, I was just surprised about your statements... First, for once this problem has nothing to do with Microsoft and their lack of security --- here it's really not their fault :-) I use Linux and Firefox myself, so I'm no "bum boddy" with MS.

The problem is that you cannot control what happens with your image data when it has left your server: when it reaches the browser then it's free to do with the data as it sees fit. You can suggest that it does not cache the image, but you cannot force it to obey your request.

That's my point: there can be no "magic keyword" which will force every browser on the planet to deny users when they try to right-click on the image and save it --- I might have written my browser myself and maybe I deliberately designed it not to obey this rule.

I hope you see what I mean now: when the cat (when the image has left your server) is out it's too late to catch it.

Martin Geisler
http://mgeisler.net/

 
Nigel_Aves

Joined: 2005-07-11
Posts: 61
Posted: Sat, 2005-09-24 15:00

I nearly did not come back to this topic !!! But let me also appologize I was some what miffed at your statement, especially the internet one :)

Quote:
The problem is that you cannot control what happens with your image data when it has left your server:

We actually have no disagreements on this. My point is the browser / server development groups have made it dead easy, there is no road block at all. So you have companies like Microsoft who say one thing about music / video (must be protected at all costs and another when it comes to images). Gallery2 has done a good job by hiding the images out of the http path but after the image has been served it all falls down.

If I have time this weekend I'll play around with the idea of layers and using transparent image in front. Should at least keep me out of trouble!

I also need to read up on Apache and cache usage. From what I read last night it does the reverse but I noticed a section on stopping caches being made but I don't think that was on a user level.

Take Care,

Nigel.

 
mgeisler

Joined: 2005-09-18
Posts: 23
Posted: Sat, 2005-09-24 15:48
Nigel_Aves wrote:
I nearly did not come back to this topic !!! But let me also appologize I was some what miffed at your statement, especially the internet one :)

Quote:
The problem is that you cannot control what happens with your image data when it has left your server:

We actually have no disagreements on this.

Great! Using whatever tricks you can pull off to (try and) stop people from saving your images is of course your choice --- I just wanted to clear up that those tricks cannot work 100%.

Martin Geisler
http://mgeisler.net/

 
smartdroid

Joined: 2005-11-24
Posts: 4
Posted: Thu, 2005-12-01 14:05

this worked great except I put the script into the theme.tpl - is there any reason i would want to put this in the album.tpl? I felt that by placing it the script into the theme.tpl prototection for the whole site would result. Thank you for the help. I also added the META tag to disable IE image toolbar

Quote:
<meta http-equiv="imagetoolbar" content="no">

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Thu, 2005-12-01 17:04

theme.tpl should be fine too.

 
EricInHouston

Joined: 2003-06-11
Posts: 14
Posted: Sat, 2007-05-12 17:16
Quote:
Well, do the following:

1. Copy the file photo.tpl into "gallery2/themes/*yourtheme*/templates/local" (create dir local if it doesn't exist. photo.tpl is in the templates dir.)
2. Add the following javascript anywhere to the template

<script type="text/javascript">
document.oncontextmenu = new Function("return false");
</script>

That disables the right click without the message (I hate the message; do you have any idea how often people accidentally right click and have to put up with some message?). You can always insert your code there if you really really really want to.

[lol]By the way, the safest way of disabling people to get your copyrighted stuff is to not put it online ;)[/lol]

By "anywhere to the template" do you mean inside the photo.tpl file I just copied? Not clear on which file you're referring to when you say "template".

For example, for the Matrix template, would I add it to /gallery2/themes/matrix/templates/local/photo.tpl ? Cause it's not working.

 
derickson

Joined: 2006-04-13
Posts: 32
Posted: Mon, 2007-05-21 14:03

RwD,

I added this to my pages and it works,

<script type="text/javascript">document.oncontextmenu = new Function("return false");</script>

but if I want a message how do I add that.

 
kckong

Joined: 2007-07-06
Posts: 21
Posted: Wed, 2007-07-18 12:39

Works great folks.

Now, might anyone have script to disable drag n drop?

 
MyWebsiteAdviser

Joined: 2007-04-12
Posts: 46
Posted: Tue, 2007-08-14 19:15

Hi Derickson,

You can get full script here.

Alex,
Read more about photo sharing.

 
jawwoody

Joined: 2008-01-14
Posts: 7
Posted: Tue, 2008-01-15 07:22

<body oncontextmenu="return false;">

this little scripy disables right click and the keyboard
hope it helps

 
AndyGalaxy

Joined: 2008-01-28
Posts: 2
Posted: Mon, 2008-01-28 00:36
Quote:
I nearly did not come back to this topic !!!

Quote:
those tricks cannot work 100%

You and Nigel_Aves crack me up...

 
AndyGalaxy

Joined: 2008-01-28
Posts: 2
Posted: Mon, 2008-01-28 00:39
Quote:
this little scripy disables right click and the keyboard

Most sensible post in this whole thread.

 
mortalkanga

Joined: 2009-08-21
Posts: 9
Posted: Sat, 2009-08-22 06:37

I added the script to photo.tpl and it still doesn't work?

http://www.ultraimagephotography.com.au/gallery/main.php?g2_itemId=4210