User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 391,552 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,581 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 2233 | Replies: 6
Reply
Join Date: Oct 2005
Posts: 236
Reputation: Inny is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 5
Inny's Avatar
Inny Inny is offline Offline
Posting Whiz in Training

Auto replace hotlinked Image Javascript?

  #1  
Jan 21st, 2007
Is it possible to create a code that will automaticallly switch a hotlinked image with another e.g no_hotlinking.gif ?
AddThis Social Bookmark Button
Reply With Quote  
Join Date: May 2006
Location: New Jersey
Posts: 1,422
Reputation: stymiee is on a distinguished road 
Rep Power: 5
Solved Threads: 34
Moderator
Staff Writer
stymiee's Avatar
stymiee stymiee is offline Offline
He's No Good To Me Dead

Re: Auto replace hotlinked Image Javascript?

  #2  
Jan 21st, 2007
No. You need to use Apache's mod_rewrite for this.
John Conde
Brainyminds | Merchant Account Services | I Love Code
IT'S HERE: Merchant Accounts 101 Everything you need to know about merchant accounts!
Reply With Quote  
Join Date: Oct 2005
Posts: 236
Reputation: Inny is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 5
Inny's Avatar
Inny Inny is offline Offline
Posting Whiz in Training

Re: Auto replace hotlinked Image Javascript?

  #3  
Jan 21st, 2007
could you then perhaps use this idea, of screening an image with a transparent image so the transparency is linked/saved instead, but use the transparency to cover your entire page at a given resolution with the same effect?
Ofcourse you would need to make sure the transparency was the topmost layer of every page somehow aswell.

<DIV STYLE="background-image:url('http://www.google.com.au/intl/en_au/images/logo.gif'); background-repeat:no-repeat; padding:0px; margin:0px; width:276; height:110;">
<IMG SRC="http://i14.photobucket.com/albums/a345/Instar/please_do_not_hotlink.gif" WIDTH="276" HEIGHT="110"  BORDER="0">
</DIV>
Last edited by Inny : Jan 21st, 2007 at 2:12 pm.
Reply With Quote  
Join Date: Jul 2006
Location: Deptford, London
Posts: 936
Reputation: MattEvans has a spectacular aura about MattEvans has a spectacular aura about 
Rep Power: 5
Solved Threads: 47
Moderator
Featured Poster
MattEvans's Avatar
MattEvans MattEvans is offline Offline
Posting Shark

Re: Auto replace hotlinked Image Javascript?

  #4  
Jan 21st, 2007
You also can't stop someone probing your code to find the image link; and if they're inclined to hotlink your images; they'll probably be even more inclined to do so if they encounter lax security.

Good idea though...

I'd advise looking into some server side techniques. Quite alot of the things you've been asking about here with Javascript (cookies, redirection, dynamically generated content, referer detection [which is what you'll need for this]) are much better suited to server-side scripts and technologies.
If it only works in Internet Explorer; it doesn't work.
Reply With Quote  
Join Date: Jul 2006
Location: Deptford, London
Posts: 936
Reputation: MattEvans has a spectacular aura about MattEvans has a spectacular aura about 
Rep Power: 5
Solved Threads: 47
Moderator
Featured Poster
MattEvans's Avatar
MattEvans MattEvans is offline Offline
Posting Shark

Re: Auto replace hotlinked Image Javascript?

  #5  
Jan 21st, 2007
<DIV STYLE="background-image:url('http://www.google.com.au/intl/en_au/images/logo.gif'); background-repeat:no-repeat; padding:0px; margin:0px; width:276; height:110;">
<IMG SRC="http://i14.photobucket.com/albums/a345/Instar/please_do_not_hotlink.gif" WIDTH="276" HEIGHT="110"  BORDER="0">
</DIV>

Hehe... this code has been programmed with a hypocritic personality!

I hope you used an image hotlinked from google as an example only =P
If it only works in Internet Explorer; it doesn't work.
Reply With Quote  
Join Date: Oct 2005
Posts: 236
Reputation: Inny is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 5
Inny's Avatar
Inny Inny is offline Offline
Posting Whiz in Training

Re: Auto replace hotlinked Image Javascript?

  #6  
Jan 21st, 2007
ROFL! Give that Guy a Cigar! Well spotted! yes just an example, I wondered if anyone would pick up on that (ps if a mod could edit out that image example to save poor old googles bandwidth please do! seems my edit time is up for that post)

Reason Things I ask for doing require mainly client side is because my site is free hosted and I dont have access to the server.
Perhaps this could be gotten around. If I could ftp upload to a remote server could I use a remote example of Apache's mod_rewrite ?
I suppose the images I want to pretect would also have to be hosted on that server.....hmmm...nix that !
I thought my idea might foil the casual ripper though, maybe along with a meta tag to remove the ie image toolbar?
Be much better imo to disble right click menu's 'veiw source' somehow, and remove the browsers veiw source. ?? Probably still wouldnt stop some.
Any ideas for a client side javascript or remote php that could auto add a transparent watermark to any attached or uploaded image?
Last edited by Inny : Jan 21st, 2007 at 10:16 pm.
Reply With Quote  
Join Date: Jul 2006
Location: Deptford, London
Posts: 936
Reputation: MattEvans has a spectacular aura about MattEvans has a spectacular aura about 
Rep Power: 5
Solved Threads: 47
Moderator
Featured Poster
MattEvans's Avatar
MattEvans MattEvans is offline Offline
Posting Shark

Re: Auto replace hotlinked Image Javascript?

  #7  
Jan 21st, 2007
You only need FTP access to write .htaccess files that can contain ModRewrite directives.... But they'll only work on an Apache server. Free hosting even on Apache might have all overrides disabled; which would prevent you using anything in .htaccess files.

You could probably implement an image protector using PHP... you have the same access to the server environment variables (which would let you detect who or what is accessing your images); but you'd have to do something messy like print images to the outputstream as binary data for a real protection. I did something like that a while back in Perl, it was for uploaded image validation rather than hotlink protection, but it used that principle..

You can't disable the view source button >_< Only a browser deliberately programmed with "invoke any annoying directive a web page asks me to" functionality would support that.

There are PHP image manipulation functions built into PHP.. For watermarking:

Take the basic image manipulation parts from here:
http://www.tutorialized.com/tutorial...Creation/11645

And combine them with the loadimagefromjpg function used here:
http://www.tutorialized.com/tutorial...sing-PHP/16806
If it only works in Internet Explorer; it doesn't work.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb JavaScript / DHTML / AJAX Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 9:26 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC