Solved

checking image for hotlinking

Posted on 2004-10-08
7
271 Views
Last Modified: 2008-02-01
i'm triyng to write something that will check if image is hotlinkable...
i've found some JavaScript solutions, but i want to write it in php...
is it possible?
and how?
0
Comment
Question by:svsvsv4
  • 4
  • 2
7 Comments
 
LVL 7

Expert Comment

by:petoskey-001
ID: 12258589
Here is an excellent article on the topic.  PHP and Mod_Rewrite.  What I really like about this solution is that it not only stops people from viewing the image, it also redirects them to your website proper if they try viewing the image directly in their address bar.

http://www.alistapart.com/articles/hotlinking/
0
 

Author Comment

by:svsvsv4
ID: 12259069
no, i meant that i want to check if remote image is hotlinkable...
0
 
LVL 7

Expert Comment

by:petoskey-001
ID: 12259083
So... you have a list of image url's and you want to find out which ones you can link to remotely?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 7

Expert Comment

by:petoskey-001
ID: 12259100
Why not just try to load the image in your browser?  How many images to you have to link to?
0
 

Author Comment

by:svsvsv4
ID: 12259180
i'm trying to make a script that will check big list of images...
0
 
LVL 7

Expert Comment

by:petoskey-001
ID: 12259246
I see, that's what I thought.  Well I'm going to sign off on this one then.  Hotlinking uses other people's bandwidth without their permission.  Even if you have some valid reason the solution could be used to steal bandwidth from lots of people.  I don't agree with the practice and won't be part of a solution that's posted so publicly.  Sorry.
0
 
LVL 27

Accepted Solution

by:
Diablo84 earned 500 total points
ID: 12260348
I Concur.

However giving you the benefit of the doubt, as this may be used for a moral reason, such as testing if images on a server you are are in control of are correctly proteced, i will point you in the right direction.

There is no flawless method that comes to mind because some servers send an alternative file (such as a "hotlinking prohibited" image in place of the requested one) however for those that just deny you access to the file you can attempt to read it with file_get_contents or fsockopen. If they return true then the file is readible, if they return false then they could not connect to the file - so either it does not exist or it is hotlink protected.

eg.

if (@file_get_contents("http://somedomain.com/someimage.jpg")) echo "Image Found";
else echo "Could not connect to Image";

Some relevant manual links: http://www.php.net/manual/en/function.file-get-contents.php OR http://www.php.net/manual/en/function.fsockopen.php

And that is as much information as i intend to share on this one.

Please DO NOT leech other people bandwidth, if that is indeed the motive behind this script. Bandwidth costs people money and its a giant pain in ar... wallet if another site drains away your resources. The last site that leeched an image from my domain returned the next day to find out that i had replaced it on my server with a 2000*2000px transparent gif which needless to say rendered their page pretty useless.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
This article discusses how to create an extensible mechanism for linked drop downs.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now