hi.. everyone..
what i want to do is I want to give users a download link only if he is logged in.
I mean to say. say..
if the link is http://somedomailn.net/samplevideo.avi
then if once the user logged and gets the link.
he can pass it to any of his friend who is not registered member of my site(not even related to my site) then that friend can download the video.
I have 2 ways in my mind.
1. the file name should be variable( this is a bad. and stupid method)
2. instead of giving the user download link. I will give him link to a php script which will interface between user and file. I mean that script will act like a proxy for the file. and checks if the session variables(for login) are set. and if set then streams the file(which is some where on server) other wise says that you are not logged in.
advantages: problem is solved. and download accelerators cannot be used.(since its my script which is splitting the file into chunks and sending. so speed is controlled by me. am i right???)
disadvantages: inceasing load on my server. my server's cpu has to do a lot of work
no my questions are..
1. How to implement my second idea using php. any tutorial?? or links?? pls..
2. Are there any other methods?? through which this can be done.
3. How does the rapidshare/gmail work?? (because problem is same..)
4. In my 2nd method does really download accelerators are disabled???
how this can be implemented using php???
Moderator: General Moderators
1. Send download header()s. Read the file: file_get_contents() or readfile().
2. Many other methods. HTTP Message Digest, for example. Your second example is probably the most practical way of going about your problem, though.
3. Not familiar with that.
4. I'd imagine download accelerators/managers would not be affected, because a download is a download. Just because you're sending it through a script doesn't make it different than a direct download.
Other thoughts:
I'm not sure reading a file to a client will use that much cpu. (I know file_get_contents() has support for memory mapping techniques). If anything, it will be your bandwidth that will be eaten up. (this is just a guess, i've never tested it).
2. Many other methods. HTTP Message Digest, for example. Your second example is probably the most practical way of going about your problem, though.
3. Not familiar with that.
4. I'd imagine download accelerators/managers would not be affected, because a download is a download. Just because you're sending it through a script doesn't make it different than a direct download.
Other thoughts:
I'm not sure reading a file to a client will use that much cpu. (I know file_get_contents() has support for memory mapping techniques). If anything, it will be your bandwidth that will be eaten up. (this is just a guess, i've never tested it).
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Re: how this can be implemented using php???
1. You use a script file that checks that the user is logged (a boolean value that you put in the session), that filename that the script uses exists http://www.php.net/manual/en/function.file-exists.php, use basename http://www.php.net/manual/en/function.basename.php then readfile(path) then put the headersclaws wrote: I have 2 ways in my mind.
1. the file name should be variable( this is a bad. and stupid method)
2. instead of giving the user download link. I will give him link to a php script which will interface between user and file. I mean that script will act like a proxy for the file. and checks if the session variables(for login) are set. and if set then streams the file(which is some where on server) other wise says that you are not logged in.
advantages: problem is solved. and download accelerators cannot be used.(since its my script which is splitting the file into chunks and sending. so speed is controlled by me. am i right???)
Some browsers ignore or misread content headers so check in each one the mechanism.
A few links
search this forum
http://www.goodphptutorials.com/track/205
http://www.hotscripts.com if you want a script done by someone else