BrianVS
12-28-2008, 05:06 PM
SO.... just when I thought I designed the perfect music player, since the links to the playlists were almost entirely used inside the swf file, which most people won't know how to access, I realized that people can still download entire songs off my site using realplayer. I know there is no foolproof way to stop people from stealing audio and video files, but I'd at least like to have a level of security so that people can't just click "download using realplayer" and instantly have the track.
Anyone have any ideas or methods for how they attempt to prevent leechers?
I found this method on longtailvideo.com
Pretty Simple
Sorry had some unnecessary code in my past post.
Here is the better one
Create two directories - one that has the mp3 files lets call this directory "music" and has a .htaccess with one line it in
deny from all
Put all your mp3 files in there - they cannot be directly downloaded due to the htacess deny rule
They create the other directory say "player" with the swf file and the index.php as follows:
<?php
$fileonly=$_GET['param'];
$fileonly=str_ireplace("..","",$fileonly);
$fileonly=str_ireplace("/","",$fileonly);
$fileonly=str_ireplace(" ","_",$fileonly);
?>
<embed
src="mediaplayer.swf"
width="640"
height="480"
allowscriptaccess="always"
allowfullscreen="true"
autostart="true"
flashvars="file=get.php?param=<?php echo $fileonly; ?>&showstop=true&autostart=true&bufferlength=3"
/>
</p>
Place the mediplayer.swf file in this directory
Create another file in this same directory that streams the file called get.php
<?php
$fileonly=$_GET['param'];
$file="../music/".$fileonly;
header('Cache-Control: no-cache');
header('Cache-Control: no-store');
header('Pragma: no-cache');
header('Content-Type: audio/x-mp3');
header('Content-Length: ' . filesize($file));
$fh = fopen($file,"rb");
while (!feof($fh)) { print(fread($fh, filesize($file))); }
fclose($fh);
?>
Now you can just link to your mp3s as http://hostnamewhatever.com/player/index.php?param=mymusicfilename.mp3
All set.
I tried that but couldn't get it to work. Also, I'm looking for something that would work for an entire xspf playlist, not just a single mp3.
Anyone have any ideas or methods for how they attempt to prevent leechers?
I found this method on longtailvideo.com
Pretty Simple
Sorry had some unnecessary code in my past post.
Here is the better one
Create two directories - one that has the mp3 files lets call this directory "music" and has a .htaccess with one line it in
deny from all
Put all your mp3 files in there - they cannot be directly downloaded due to the htacess deny rule
They create the other directory say "player" with the swf file and the index.php as follows:
<?php
$fileonly=$_GET['param'];
$fileonly=str_ireplace("..","",$fileonly);
$fileonly=str_ireplace("/","",$fileonly);
$fileonly=str_ireplace(" ","_",$fileonly);
?>
<embed
src="mediaplayer.swf"
width="640"
height="480"
allowscriptaccess="always"
allowfullscreen="true"
autostart="true"
flashvars="file=get.php?param=<?php echo $fileonly; ?>&showstop=true&autostart=true&bufferlength=3"
/>
</p>
Place the mediplayer.swf file in this directory
Create another file in this same directory that streams the file called get.php
<?php
$fileonly=$_GET['param'];
$file="../music/".$fileonly;
header('Cache-Control: no-cache');
header('Cache-Control: no-store');
header('Pragma: no-cache');
header('Content-Type: audio/x-mp3');
header('Content-Length: ' . filesize($file));
$fh = fopen($file,"rb");
while (!feof($fh)) { print(fread($fh, filesize($file))); }
fclose($fh);
?>
Now you can just link to your mp3s as http://hostnamewhatever.com/player/index.php?param=mymusicfilename.mp3
All set.
I tried that but couldn't get it to work. Also, I'm looking for something that would work for an entire xspf playlist, not just a single mp3.