Prevent logos and images from web page

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
yasin
Forum Newbie
Posts: 1
Joined: Tue Mar 07, 2006 12:15 am
Location: Lahore
Contact:

Prevent logos and images from web page

Post by yasin »

Hi

how a logos or images of a website can be prevented from downloading.Please tell me methods which i have to follow.
mickd
Forum Contributor
Posts: 397
Joined: Tue Jun 21, 2005 9:05 am
Location: Australia

Post by mickd »

I do not think that is possible. No matter what, the user will have to download the output onto their computer to view it, including images.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

mickd wrote:I do not think that is possible. No matter what, the user will have to download the output onto their computer to view it, including images.
Actually, you can prevent them from being linked to or dispayed on other webistes by using hotlink protection. I think it's available as module under apache but if you have CPanel access you should be able to set that up from there.

You can't stop people visiting your site and taking them from there though.... if you want to display them on a webpage they will be downloaded in any case so that the browser can display them.
Grim...
DevNet Resident
Posts: 1445
Joined: Tue May 18, 2004 5:32 am
Location: London, UK

Post by Grim... »

Not cheap, but it does the job - stops everything except a screen capture: http://www.artistscope.com/secure_image/
User avatar
jayshields
DevNet Resident
Posts: 1912
Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England

Post by jayshields »

Couldn't you use PHP with header() to output the image?

Just put all your images in a directory tree like 'you/wont/guess/this/' and then have MySQL store the filename and a random id. Have the script like image.php?random_id=whatever and regenerate a new ID for it each time.

That's what I'm going to use in my upcoming project to prevent hotlinking, seems OK to me?
guided1
Forum Newbie
Posts: 3
Joined: Thu Mar 09, 2006 8:13 am
Location: Cape town, South Africa

Post by guided1 »

hot linking? what's that?

Is that where other people link directly to your images?

if so... you can fix that with a .htaccess (assuming apache ofcourse...)

Options +FollowSymlinks
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?your-url\.com/ [nc]
RewriteRule .*\.(gif|jpg|png)$ http://your-url.com/img/porn-pic.gif [nc]

this will only allow requests from your domain to view images...
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

guided1 wrote:hot linking? what's that?

Is that where other people link directly to your images?

if so... you can fix that with a .htaccess (assuming apache ofcourse...)

Options +FollowSymlinks
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?your-url\.com/ [nc]
RewriteRule .*\.(gif|jpg|png)$ http://your-url.com/img/porn-pic.gif [nc]

this will only allow requests from your domain to view images...
Yeah that's what I was referring to ;) Never actually thought it was as simple as a rewrite but it makes perfect sense.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

jayshields wrote:Couldn't you use PHP with header() to output the image?

Just put all your images in a directory tree like 'you/wont/guess/this/' and then have MySQL store the filename and a random id. Have the script like image.php?random_id=whatever and regenerate a new ID for it each time.

That's what I'm going to use in my upcoming project to prevent hotlinking, seems OK to me?
Wha? You can still download them... the only difference is the filename used to access them. It would be very easily by-passed.
User avatar
jayshields
DevNet Resident
Posts: 1912
Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England

Post by jayshields »

Sorry, I missed the point slightly, you can always download the image, because it's been sent to the browser, I can't imagine how that thing Grim... posted would work, even though print screen would get around it anyway...

I just posted my idea to stop hot linking, didn't realise it was so easy in Apache, but you need mod_rewrite enabled don't you? Since I'm on a shared host I doubt it could be enabled if it's off...
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

jayshields wrote:Sorry, I missed the point slightly, you can always download the image, because it's been sent to the browser, I can't imagine how that thing Grim... posted would work, even though print screen would get around it anyway...

I just posted my idea to stop hot linking, didn't realise it was so easy in Apache, but you need mod_rewrite enabled don't you? Since I'm on a shared host I doubt it could be enabled if it's off...
I think the thing Grim... posted was an applet of some sort... it's not actually an image, it's rendered using some sort of secure plugin rather than the browser...
Post Reply