Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

checking image for hotlinking

Posted on 2004-10-08
7
Medium Priority
?
280 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 1000 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

These days socially coordinated efforts have turned into a critical requirement for enterprises.
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

670 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