View Full Version : How does Yahoo and Amazon do this?
netline5000 09-17-2002, 12:29 PM I want each of the video and audio files to have unique id's so that users can only request files through a request script and file id. Hence users cannot know the actual location of the file and cannot request it directly.
An example of what I want to do is done by Yahoo:
http://playlist.yahoo.com/makeplaylist.dll?SID=3318212
This link opens a Real Audio file in the Real Audio plug-in.
If the user doesn't have a plugin, it loads the Save As dialog box.
As a result users cannot request the files directly because the user does not know the location of the file, as the url displayed stays the same.
Hence I want users to be able to only access the video/file directly through a script like:
http://www.myWebsite.com/getvideo.php?id=12334
How is this done or how can it be done?
daveman 09-17-2002, 12:55 PM I would guess they store all the movies in a database, not as files on the harddrive.
Earthnet 09-17-2002, 02:21 PM What you can do is put your video/audio files in a directory that is not in your web document root.
Create a database that has the file id and the filename.
So when a user goes to http://www.myWebsite.com/getvideo.php?id=12334 your script goes to the database and looks up id=12334. It then finds the file associated with the id.
Then use fopen() with fpassthru() to send the file to the user.
Check out http://www.php.net/manual/en/function.fpassthru.php for examples.
RackNine 09-17-2002, 02:32 PM Originally posted by daveman
I would guess they store all the movies in a database, not as files on the harddrive.
Be very careful with this. Earthnet's comment about a database of IDs is very good, but storing the whole file in a database can lead to server death on high-traffic sites. Basically all data will have to get pulled from one huge file before it's separated into downloadable pieces and that's nasty work for hard drives.
-Matt
Studio64 09-17-2002, 03:55 PM Originally posted by RackNine
Be very careful with this. Earthnet's comment about a database of IDs is very good, but storing the whole file in a database can lead to server death on high-traffic sites. Basically all data will have to get pulled from one huge file before it's separated into downloadable pieces and that's nasty work for hard drives.
-Matt
Not to mention the high server load.
Also keep in mind that every person downloading a file from you with this set-up must mantain a persistant DB connection w/ you to receive the file if I'm not mistaken. That alone could lead to some availablity problems do to max connections allowed.
Chr1s 09-17-2002, 04:33 PM Instead of putting it all in MySQL, you could use a simple method, which is kinda like Earthnet's said but if you can't make a directory out of the root folder you can just make like a "secret" folder inside ur root folder then use fopen( ) and headers( ) to send the file to the guy without him knowing where the file is stored and you can go even further than that, you can make a anti-leech system and stuff.
CChard 09-17-2002, 04:51 PM I have something similar I just set up.
I upload the files into my website. Then I add the location of the file (+name, +whateever) into the database.
Then when they click on a link (download.php?id=0991) it launches a script that gets the URL from the database and launches a download of it.
Chr1s 09-17-2002, 08:15 PM Using that way, visitors can easily figure out where the files are stored on your server and it seems to me that he wants to hide it from them but if he doesnt thats a good way too.
Rich2k 09-17-2002, 08:23 PM At a guess for a site that size... they just store the files directly in their database.
Very simple to do...
CChard 09-18-2002, 12:26 AM Originally posted by Chr1s
Using that way, visitors can easily figure out where the files are stored on your server and it seems to me that he wants to hide it from them but if he doesnt thats a good way too.
It dosen't give out the location (as long as you don't put the file in the main dir).
Check out mine: http://www.atlanticrail.com/file_db/listfiles.php?type=skin&order=div
netline5000 09-18-2002, 05:14 AM Thanks for all the replies.
Chr1s, what is an anti-leech system and how does one create it?
CChard, I noticed you only have zip files on your site, would your code work with Audio and Video files, including starting up the appropriate plug-in if the user has it installed?
Also what did you mean by (as long as you don't put the file in the main dir)?
Lastly a question for you all: Are all the solutions mentioned here PHP specific? Could they be implemented in Perl, ASP, JSP, and ColdFusion?
Thanks in advance
CChard 09-18-2002, 02:41 PM Well, if the file had the URL of website.com/file.zip then it wouldn't be hard for people to find the files :)
But if you put it as website/6522/file.zip then it would be harder to find the location :)
My program should work with any type of file. I havn't tested it, but it should work.
frostie 09-18-2002, 07:46 PM Is it me or has someone else actually noticed that Yahoo and Amazon use their own dll 's . They created their own special parsing files to deal with whatever it is they do, in this case retreiving info based on what is being done at the time. SO in short the answer to your question is No, you cannot do what they do, however yes you can mimic in one form or another which you appear to be doing.
James
|