Jump to content
xisto Community
iwuvcookies

Music In Php i dont get how this works

Recommended Posts

Ok i went to a site to listen to music and instead of giving me some file with a mp3 extention they have .php with an id #. Like this....

 

www.music.mcgill.ca/~ich/classes/mumt614/similarity/MariahCareyThankGod.mp3

 

i was wondering how would a person do this and what's the purpose of it? is it like for safety reasons?

Share this post


Link to post
Share on other sites

PHP itself cannot generate music on the fly - not to my knowledge. First of all, the link that you are referring does not work due to massive hotlinking, but if it works, then it would first call the file (or script) "to_download.php". Then, the script would take the id number and find the corresponding .mp3 file for you to download. That's how it would work.

Share this post


Link to post
Share on other sites

i was wondering how would a person do this and what's the purpose of it? is it like for safety reasons?

Yes it's a security measure to make sure people can only d/l from the site (usually after having paid) and not via FTP or whatever. If you were paying for MP3s, this would stop you passing the direct link to the file on to your friends so that they could then d/l it (although you could still just send them the file yourself).

Share this post


Link to post
Share on other sites

There are a number of ways in which such a system can work, and a number of reasons for using it. Some of the more common reasons are for security, as has been mentioned, but also for tracking purposes - it's more practical to store the number of times a file has been accessed through a tracking script than look through a log file to count the access attempts.The ways in which it can work vary. It can be a unique file ID corrosponding to only that file which will then be looked up in the database, but that is more likely to be for tracking purposes than security reasons. If it was for security, it would more likely be a session hash or something else that uniquely identified you and the file you were seeking, rather than a simple file ID. So anyway, after the file is located, it will usually do one of two things: i) Redirect you to the location of the actual file (eg. header('Location: /file.mp3')), or ii) Get the contents of the file and send it to you directly. The latter is more commonly used in situations where security is a priority; if you are redirected to a direct download point, then you can obviously just use that URL again later and not have to go through the initial process.Hope that helps.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.