(Some) Image Protection...Step by Step

actiont

Joined: 2004-03-01
Posts: 7
Posted: Fri, 2004-03-05 02:03

After many hours of searching here and there, forums, libraries and bookstores, I am near a conclusion on protecting pictures in Gallery. I have done all of this fully aware that someone can still press print screen or click File|Save. I'm still working on the File|Save part :)
We also prefer not to watermark our images.

A BIG Thank you to everyone on these forums who offers help to the needy newbies.
Thank you floridave and PixelPoet for your feedback and direction.

The codes below were found on this site, dynamicdrive dot com, phpbuilder dot net, and others. Please forgive me if I can't give specific credit for a chunk of code. I've pieced this together from a weeks worth of searching all over the place.

This post is long because I have compiled many things into it which I want to share because in my travels I found the same questions I was asking rolling around over and over.
How-to Disable Right-click, Disable IE6 Toolbar, Disable Caching, Redirect Printing.

Gallery v 1.3.4-pl1
PHP 4.3.3
I can't upgrade (as suggested) because my Host is a pain and I'm still new. Eventually I'll get there.

Here are my findings.
#1
In order to redirect the printer to print the home page (or anything else) instead of what is on the screen (ie: your photo), add this code under the <html> (line 27) tag in wrapper.footer.default
----------code begins below

<link rel="alternate" media="print" type="text/html" a href="http://www.example.com/index.html">

----------code ends above

#2
In order to prevent Right-click, Save as… and pop up a little message, add this code under the <body> tag (line 29) in wrapper.footer.default

---------code begins below

<script language=JavaScript>
<!--
var message="All images are copyright © 2004";
/////////////
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")
// -->
</script>

--------code ends above

#3
The following code does a few things. The first line turns off the Internet Explorer 6 pop-up toolbar in the images. The Second and Third lines tell the browser to NOT save the images in the client cache. The fourth line tells the printer to print the home page of the site if a user attempts to print the page.
Insert this code under the <head> (line 193) of view_photo.php
---------code begins below

<META HTTP-equiv="imagetoolbar" CONTENT="no">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
<link rel="alternate" media="print" type="text/html" a href="http://www.example.com/index.html">

#4
In order to prevent a user in IE 6 from dragging and dropping the image somewhere else,
Replace the <body> tag on line 332 of view_photo.php with…

--------code begins below

<body ondragstart="return false" onselectstart="return false">

---------code ends above

#5
Since our site uses frames with the gallery in the right-hand frame, we need to add some code to the frame1.html and frame2.html files in order to redirect printing if the user attempts it. The code goes below the META Tags in the <head> section of each HTML file.
--------code begins below

<link rel="alternate" media="print" type="text/html" a href="http://www.example.com/index.html">

--------code ends above

As I said at the beginning, I'm still working on stopping the File|Save from the toolbar, I may use a popup for the image with no toolbar, I'm not sure. I'm still figuring out how all of this goes together and loving every minute of it!!!

Thank you again to everyone and I hope this helps out.

Paul

 
phlambert

Joined: 2004-03-18
Posts: 2
Posted: Thu, 2004-03-18 19:53

Hi,

Thanks for posting your efforst to disallow printing. I went to the wrapper.footer.default file you specified but there were only a total of 26 lines and no html tags. So I added the html tags but still no luck. Doesn't seem to do anything. What am I missing?

Thanks

 
Gaile

Joined: 2002-07-20
Posts: 1301
Posted: Fri, 2004-03-19 04:12

There shouldn't be any html or body tags in ANY of the wrapper files, so I'm not sure what Paul is referring to there.

Possibly you could add it into the view_photo.php - but I haven't tested any of this code at all.

Any header files in the html_wrap directory add their information AFTER the </head><body> tags at the beginning of the page, and BEFORE the </body></html> tags at the end of the page. Doing this any other way can cause your site to not been seen in some browsers and will definitely cause a few errors to occur.

Sorry I can't be of more help, hopefully Paul has notification turned on and will see you are asking about his modifications.

Gaile

 
actiont

Joined: 2004-03-01
Posts: 7
Posted: Mon, 2004-03-22 14:30

phlambert,

Sorry it took me a while to reply, I was away for a few days.

I will verify my findings and get back to you.

actiont.

 
PrmseKpr

Joined: 2003-03-07
Posts: 13
Posted: Sat, 2004-03-27 00:29

I am interested in this too. ActionT: Did you find out anything?