PDA

View Full Version : protecting files.


utinaeniduin
01-03-2007, 05:40 AM
ok i feel like there is a very easy way to do this, but i am missing it. all i want to do is not allow files to be directly downloaded or accessed. I have an mp3 player on my site, but it is very important that my users can't download the files to their computer. The flash mp3 player uses a cgi script and when accessed shows you a src= var in the url. so anyone with a bit of no-how could find my files. I have tried password protecting the directory, but when i access my mp3 player it asks for authentication.

_Aerospace_Eng_
01-03-2007, 08:43 AM
Try disabling hotlinking of mp3 files. You can do this by creating a .htaccess file in the root directory of your site. First though you'll need to figure out if you host supports this. If you use CPanel to control the settings of your site then you probably have a hotlinking link already and all you have to do is add the mp3 extension.

Benji1012
01-03-2007, 04:23 PM
You could play the music using quicktime - that way no one can download the file - unless they are pro users - which many people are not

Spudhead
01-03-2007, 05:03 PM
Don't put your mp3's in a folder in your web root? Put them up above it.

mlseim
01-03-2007, 05:37 PM
Put the MP3 files in your "cgi-bin" ... that might work.

EDIT: I just tried it with my free FlashPlayer, and it did not work.

EDIT AGAIN ...

I figured out a way to eliminate hot linking. They can still listen to the MP3,
and they can save it on their PC if they wish, but they can't see where it
is stored ... thus, they can't hot link to it.

I'm using a free MP3 Flash Player, with a PHP script to mask the URL.

Here is the test site:

http://www.catpin.com/streaming.php

(You can view the HTML source code to see that)


Here is the PHP script for masking:


<?php
$code = "ac_dc";
$fileHandle = './myhiddendirectory/'.$code.'_j7T4E5.mp3'; // gets it from a spot that you can't access via a browser
header('HTTP/1.1 200 OK');
header('Date: ' . date("D M j G:i:s T Y"));
header('Last-Modified: ' . date("D M j G:i:s T Y"));
header("Content-Type: audio/mp3");
header("Content-Length: " . (string)(filesize($fileHandle)) );
header("Content-Transfer-Encoding: Binary");
header('Content-Disposition: attachment; filename="'.$code.'_j7T4E5.mp3"' );
readfile($fileHandle);
?>


.