View Full Version : PHP Question

12-30-2005, 11:42 AM
I'm having some trouble getting a PHP code that directs you to a file without you seeing where the file is beeing downloaded from.

The URL is: www.mysite.com/getfile.php?id=9C435A9678EFF6235C543
While the location is: www.mysite.com/files/song.mp3

I'm merely using it to link to mp3's and videos, so I'm not looking for a huge code or anything.

Now I know it has something to do with md5 decoding and the location urls being inserted into a MySQL database, but I can't find anything (simple enough).

So any php-nerds willing to help me?

Here's my e-mail/msn if it's too complicated to explain over here: tijsvanleur@gmail.com

12-30-2005, 11:50 AM
maybe it's a hash table?

12-30-2005, 03:01 PM
I have absolutely no idea... I was hoping someone would have a script that I could just install and use.

12-30-2005, 03:36 PM
i think the basic idea is that you take the urls to your files (www.mysite.com/files/song.mp3) and throw them through md5 or some other hash function to get some 'random' string (9C435A9678EFF6235C543). you do that to all the urls, and put them in a table (could be a database) keyed on the hash. your getfile.php script will take it's argument (?id=9C435A9678EFF6235C543), look that string up in the hash table (/database) to get the file's url, and then serve that up. details--i have no idea. i've never used php. but that's the general idea, i think. i guess the real important part is when you serve up the file, how to make sure the user can't get that url from the download.

12-30-2005, 03:59 PM
Yeah, I got that. But the problem is who to work that out into a PHP script. It's the detailed part I have trouble with.

Btw, you use a Mac right? Could you do a favor for me? Ah.. I'll just send you a PM.

12-30-2005, 04:02 PM
i don't, i use linux on x86 usually, sometimes windows (if i'm downloading or gaming).

12-30-2005, 04:10 PM
Oh well.. could you do the same thing, except on Linux?