vinpkl Posted October 8, 2009 Share Posted October 8, 2009 hi all i am start work on a music selling website in PHP. normally when we listen to music mp3 file it gets saved in temporary files of the browser from where people can save it. how can i stop the files from getting downloaded in the temp folder of browser. Please everybody tell your opinion otherwise it would be difuclt to start project. i m new to this kind of situation. vineet Quote Link to comment https://forums.phpfreaks.com/topic/176921-stop-music-files-from-downloading/ Share on other sites More sharing options...
MadTechie Posted October 8, 2009 Share Posted October 8, 2009 Technically for something to play on your PC it needs to "downloaded" the media so users could save anything your site supplies, your best and simplest solution is to only allow sample downloads Quote Link to comment https://forums.phpfreaks.com/topic/176921-stop-music-files-from-downloading/#findComment-932828 Share on other sites More sharing options...
vinpkl Posted October 8, 2009 Author Share Posted October 8, 2009 hi Madtechie This is a good idea. If didnt find anyother solution then i have to follow it. vineet Technically for something to play on your PC it needs to "downloaded" the media so users could save anything your site supplies, your best and simplest solution is to only allow sample downloads Quote Link to comment https://forums.phpfreaks.com/topic/176921-stop-music-files-from-downloading/#findComment-932838 Share on other sites More sharing options...
MadTechie Posted October 8, 2009 Share Posted October 8, 2009 No options will be 100%, I could always set my PC to record from my Mic and Play from speaker and connect the ports together.. (that's low-tech but you get the idea) however.. it maybe worth looking into media steaming server, however that can be captured but is a little harder then just grabbing from temp, If you had to play a full MP3 and wanted to "reduce" the risk.. then maybe try getting a flash MP3 player The have the flash player, play a MP3 that's parsed via a PHP script, the PHP script loads the files from a folder outside the public domain and requites a token sent from the flash player so the flash player would load a file like getMP3.php?file=madtechie.mp3&token=465f7846abce the getMP3.php will check the token with the session, then generate a new token and then open the MP3 from its folder Quote Link to comment https://forums.phpfreaks.com/topic/176921-stop-music-files-from-downloading/#findComment-932841 Share on other sites More sharing options...
vinpkl Posted October 8, 2009 Author Share Posted October 8, 2009 Hi madTechie I dont know much about flash player But you mean to say that the mp3 folder should not be inside root folder and flash player will look for an id of that mp3 file. i didnt understand the token. is it ID of the mp3 file. vineet The have the flash player, play a MP3 that's parsed via a PHP script, the PHP script loads the files from a folder outside the public domain and requites a token sent from the flash player so the flash player would load a file like getMP3.php?file=madtechie.mp3&token=465f7846abce the getMP3.php will check the token with the session, then generate a new token and then open the MP3 from its folder Quote Link to comment https://forums.phpfreaks.com/topic/176921-stop-music-files-from-downloading/#findComment-932846 Share on other sites More sharing options...
MadTechie Posted October 8, 2009 Share Posted October 8, 2009 okay.. just say you have 3 files on your server Hello1.mp3, Hello2.mp3 & Hello3.mp3 ie / /Hello1.mp3 /public_html/ /public_html/tester.php /public_html/Hello2.mp3 /public_html/tester/ /public_html/tester/Hello3.mp3 now to play Hello2.mp3 you do http://domain.com/Hello2.mp3 and to play Hello3.mp3 you do http://domain.com/tester/Hello2.mp3 but you can't play Hello1.mp3 as its not in the public folder.. Right ? But if tester.php was <?php header("contents-type: audio/mp3"); readfile('/Hello1.mp3'); ?> then opening tester.php would infact open Hello1.mp3 but with the bonus of PHP being in control.. so no direct downloads As for the token.. just say we goto page1.php and on page 1 we have a <?php session_start(); $_SESSION['token'] = md5(uniqid(mt_rand(), true)); echo "tester.php?file=madtechie.mp3&token=465f7846abce"; ?> and tester.php checks the token like this <?php session_start(); if($_GET['token'] != $_SESSION['token']) die("ERROR"); $_SESSION['token'] = "VOID"; //remove token we are done header("contents-type: audio/mp3"); readfile('/'.$_GET['file']);//YOUR NEED TO FILTER $_GET['file'] ?> Now if the token is different then we get nothing Quote Link to comment https://forums.phpfreaks.com/topic/176921-stop-music-files-from-downloading/#findComment-932852 Share on other sites More sharing options...
vinpkl Posted October 8, 2009 Author Share Posted October 8, 2009 hi MadTechie thanks for explanation. but this script will prevent only direct downloading from url. that i understood. but if the token is corect then still the song will get download in temp folder and user can save it. Or with flash player the songs doesnt get downloaded in temp folder. Am i correct. vineet Quote Link to comment https://forums.phpfreaks.com/topic/176921-stop-music-files-from-downloading/#findComment-932869 Share on other sites More sharing options...
MadTechie Posted October 8, 2009 Share Posted October 8, 2009 Flash could open the file as a resource for so the flash player will be downloaded but the resource will remain in mostly memory. Quote Link to comment https://forums.phpfreaks.com/topic/176921-stop-music-files-from-downloading/#findComment-932880 Share on other sites More sharing options...
xsist10 Posted October 8, 2009 Share Posted October 8, 2009 Another option is to provide a lower quality mp3 as a preview of the higher quality one. That way the listener gets a feel for the music, but won't really get a crystal clear sound. Possible settings: High quality: 192 kbit/s Sample/preview quality: 96 kbit/s Quote Link to comment https://forums.phpfreaks.com/topic/176921-stop-music-files-from-downloading/#findComment-932883 Share on other sites More sharing options...
MadTechie Posted October 8, 2009 Share Posted October 8, 2009 Totally agree with you xsist10, simplest solution is to only allow sample downloads but i would also trim the song to 30 seconds Quote Link to comment https://forums.phpfreaks.com/topic/176921-stop-music-files-from-downloading/#findComment-932886 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.