TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 01-15-2008, 03:46 AM   #1 (permalink)
The Acquainted
Inquisitive 
 
Join Date: Jul 2005
Location: UK
Posts: 121
Thanks: 41
Brook is on a distinguished road
Default How to protect hot linking of video downloads?

I am thinking about offering video downloads - but how can you protect people linking to the files directly to download them? (Eg someone posting a link to the mpeg's url on a different site).

Can you use the hotlinking tool that's built into cpanel? Or would it require something more custom?

What would be even better is to have the videos on another domain, and some kind of protection system that checks to see the request for the video came from a specific domina.

Eg, have the main site in root: mysite.com and have the videos in vids.mysite.com and only accept the request for the video if the request was reffered from a link on the main site (mysite.com).

Sounds complicated doesn't it!
__________________
PS3 Forums on GameSlurp - the site for gaming fans!
Brook is offline  
Reply With Quote
Old 01-15-2008, 03:54 AM   #2 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

Just make a call using the Flash player to a PHP script which tells it which domain it's on along with some other details that pertain to your server. It's not 100% secure but it's sufficient! Considering there are a million and one details you could use to check it's your server. Make the call relative to the current domain though, and also die gracefully if the response is a 404.

Furthermore, consider creating a little promotional video that you could play instead of the actual video if the video resides on a site other than yours. If they're silly enough not to check the video after they've embedded, you've got yourself some free advertising!

You don't even need to place the videos on a sub-domain for this little trick to work if you don't want to.
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
The Following 2 Users Say Thank You to Wildhoney For This Useful Post:
Brook (09-20-2008), EyeDentify (01-15-2008)
Old 01-15-2008, 04:43 PM   #3 (permalink)
The Acquainted
Inquisitive 
 
Join Date: Jul 2005
Location: UK
Posts: 121
Thanks: 41
Brook is on a distinguished road
Default

Thanks WH - although I was thinking more along the lines of actual downloads of mpegs, i.e. 'right click and save as'

Any ideas on that?

Cheers,
__________________
PS3 Forums on GameSlurp - the site for gaming fans!
Brook is offline  
Reply With Quote
Old 01-15-2008, 05:30 PM   #4 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

Hmm interesting. You can't stop them from downloading the video to their hard-disks, but you could prevent them from hotlinking to the video on your website - if that's what you mean.
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
Old 01-15-2008, 05:52 PM   #5 (permalink)
Orc
The Prestige
 
Orc's Avatar
 
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
Orc is on a distinguished road
Default

Quote:
Originally Posted by Wildhoney View Post
Hmm interesting. You can't stop them from downloading the video to their hard-disks, but you could prevent them from hotlinking to the video on your website - if that's what you mean.
What about a certain coded message inside? :S Data that responds to certain Protocols? I'm just confusing myself >.< But surely you could! Though it might just make the Flash Player slow.
Orc is offline  
Reply With Quote
The Following User Says Thank You to Orc For This Useful Post:
Brook (09-20-2008)
Old 01-15-2008, 07:33 PM   #6 (permalink)
Wizard
Top Contributor 
 
Village Idiot's Avatar
 
Join Date: Sep 2007
Posts: 1,299
Thanks: 17
Village Idiot is on a distinguished road
Default

Have a script that makes a call to a location below the web root. Or you can .htaccess it to deny all, leaving your server the only thing that can access it. I could be wrong,. but I believe there is no way to download a file that is below the web root unless the script has it do so.
__________________

Village Idiot is offline  
Reply With Quote
The Following User Says Thank You to Village Idiot For This Useful Post:
Brook (09-20-2008)
Old 01-15-2008, 07:39 PM   #7 (permalink)
Alan @ CIT
Member of the Month
The Frequenter
Member of the Month Top Contributor 
 
Alan @ CIT's Avatar
 
Join Date: Apr 2005
Location: South UK
Posts: 483
Thanks: 51
Alan @ CIT is on a distinguished road
Default

Quote:
Originally Posted by Village Idiot View Post
I could be wrong,. but I believe there is no way to download a file that is below the web root unless the script has it do so.
Indeed, if the file is outside of the webroot then it couldn't be accessed except by a script on the server (assuming the script had permission to get out of the webroot).

Alan.
Send a message via MSN to Alan @ CIT
Alan @ CIT is offline  
Reply With Quote
The Following User Says Thank You to Alan @ CIT For This Useful Post:
Brook (09-20-2008)
Old 01-15-2008, 07:48 PM   #8 (permalink)
Wizard
Top Contributor 
 
Village Idiot's Avatar
 
Join Date: Sep 2007
Posts: 1,299
Thanks: 17
Village Idiot is on a distinguished road
Default

Quote:
Originally Posted by Alan @ CIT View Post
Indeed, if the file is outside of the webroot then it couldn't be accessed except by a script on the server (assuming the script had permission to get out of the webroot).

Alan.
Even most shared hosts give you access one directory below the web root (public_html on most servers)
__________________

Village Idiot is offline  
Reply With Quote
Old 01-16-2008, 05:09 AM   #9 (permalink)
The Acquainted
Inquisitive 
 
Join Date: Jul 2005
Location: UK
Posts: 121
Thanks: 41
Brook is on a distinguished road
Default

Thanks guys that's very helpful.

This site has some kind of system where a temporary link to the video is generated: gamer syde dot com (all one word) which then expires after a short while.

I wonder how they are doing it?
__________________
PS3 Forums on GameSlurp - the site for gaming fans!
Brook is offline  
Reply With Quote
Old 01-16-2008, 09:49 AM   #10 (permalink)
The Acquainted
 
EyeDentify's Avatar
 
Join Date: Nov 2007
Location: Sweden
Posts: 106
Thanks: 13
EyeDentify is on a distinguished road
Default

Well.... lets say they do something along these lines:

1. You go and click on a download link on the site

2. when a download request is triggerd, a script generates a download link wich links to a file outside webroot. In the form that its a script that picks up the file and then triggers a download window in the browser when clicked like "download.php?id=2323". When clicked it should check that the ID is still valid for download and then proceed with download or remove the link and then display an errror.

3. When a succesfull download is done the link will only survive for a set amount of time then "die" in other words become invalid.


Wich means that you make sure the script that generates a download link checks to see that the request comes from a script on your site and not from the outside. And make a check in the script that "picks up" the download.

Hope this thoughts are usefull.

Good Luck.

/EyeDentify
__________________
Of course the whole point of a doomsday machine, would have been lost if you keep it a secret.
EyeDentify is offline  
Reply With Quote
The Following User Says Thank You to EyeDentify For This Useful Post:
Brook (09-20-2008)
Old 01-16-2008, 08:08 PM   #11 (permalink)
The Acquainted
Inquisitive 
 
Join Date: Jul 2005
Location: UK
Posts: 121
Thanks: 41
Brook is on a distinguished road
Default

Thanks ED, that seems like a logical way of doing it... now... just gotta get my head round the coding part of it lol.

I'm sure I'll post for more help when I come round to doing it * !*
__________________
PS3 Forums on GameSlurp - the site for gaming fans!
Brook is offline  
Reply With Quote
Old 01-16-2008, 08:28 PM   #12 (permalink)
The Addict
Top Contributor Good Samaritan 
 
Join Date: Jan 2008
Location: USA
Posts: 217
Thanks: 16
RobertK is on a distinguished road
Default

I'll give you a hint. The script has to do with a combination of readfile(), and header()---beyond the referrer check of course. The reason we suggest you store the downloads outside the root html directory is so that no one can directly link to those files.

To take the first example from the PHP manual, and fix it a bit:
PHP Code:
<?php
// We'll be outputting a PDF
header('Content-type: application/pdf');

// It will be called downloaded.pdf
header('Content-Disposition: attachment; filename="downloaded.pdf"');

// The filesize, so progress bars show up right
header('Content-length: '.filesize('original.pdf'));

// The PDF source is in original.pdf
readfile('original.pdf');
?>
Betcha already can think of how to use stuff like this.
__________________
Programmers are in a race with the Universe to create bigger and better idiot-proof programs, while the Universe is trying to create bigger and better idiots. So far the Universe is winning. - Rich Cook
RobertK is offline  
Reply With Quote
The Following 2 Users Say Thank You to RobertK For This Useful Post:
Brook (09-20-2008), EyeDentify (01-23-2008)
Old 01-16-2008, 09:45 PM   #13 (permalink)
The Acquainted
Inquisitive 
 
Join Date: Jul 2005
Location: UK
Posts: 121
Thanks: 41
Brook is on a distinguished road
Default

Thanks Robert - I think I need to do a lot more reading up
__________________
PS3 Forums on GameSlurp - the site for gaming fans!
Brook is offline  
Reply With Quote
Old 09-20-2008, 04:18 PM   #14 (permalink)
The Acquainted
Inquisitive 
 
Join Date: Jul 2005
Location: UK
Posts: 121
Thanks: 41
Brook is on a distinguished road
Default

Hey guys - would any of you consider doing this as a paid job? I don't trust my php skills to do it for a live site tbh!
__________________
PS3 Forums on GameSlurp - the site for gaming fans!
Brook is offline  
Reply With Quote
Old 09-22-2008, 12:01 PM   #15 (permalink)
The Contributor
 
buggabill's Avatar
 
Join Date: Jan 2008
Location: Maine, USA
Posts: 92
Thanks: 2
buggabill is on a distinguished road
Default

Hi Brook. Take a look at this thread. I found a pretty nice script to do what you are looking for.
__________________
-- Bill
"Why is it drug addicts and computer aficionados are both called users?" -Clifford Stoll
buggabill is offline  
Reply With Quote
The Following User Says Thank You to buggabill For This Useful Post:
Brook (09-22-2008)
Old 09-22-2008, 07:40 PM   #16 (permalink)
The Acquainted
Inquisitive 
 
Join Date: Jul 2005
Location: UK
Posts: 121
Thanks: 41
Brook is on a distinguished road
Default

Thanks Bill, will check it out!
__________________
PS3 Forums on GameSlurp - the site for gaming fans!
Brook is offline  
Reply With Quote
Old 09-23-2008, 02:38 AM   #17 (permalink)
Wizard
Top Contributor 
 
Village Idiot's Avatar
 
Join Date: Sep 2007
Posts: 1,299
Thanks: 17
Village Idiot is on a distinguished road
Default

If that does not work, I may be interested in doing this for you. Send me a PM if you wish to speak with me about this project. I've written a script much like this before.
__________________

Village Idiot is offline  
Reply With Quote
Old 09-24-2008, 01:30 PM   #18 (permalink)
The Wanderer
 
Nielsk's Avatar
 
Join Date: Aug 2008
Posts: 5
Thanks: 0
Nielsk is on a distinguished road
Default

Hotlink could be bypassed with curl, when you set up the referer to the same website the apache will still parse it.
Nielsk is offline  
Reply With Quote
Reply



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

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 08:07 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design