note 85950 added to function.fread
| From: | hachimuto at osu1 dot php dot net | Date: | Fri, 26 Sep 2008 00:42:50 +0000 |
| Subject: | note 85950 added to function.fread | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-144721@lists.php.net to get a copy of this message | ||
HELLO CODERS.
I'm newbie to php and would like to show you a script that do:
*Download files from server.(implemanted)
*Support resume function.(implemanted)
*Determine the speed of download.(implemanted)
*Link protection(not yet and that's what I want to learn from you if you like.)
I explain the last feature:the server generates a link only "valid for this ip who requested it
.the link looks alike something : http://host/downloadit.o-n.php?idx=f7b1424c46ed6705879b2497c6453aaa
&file=yogui-cours-complet-php.zip
the server support resume,so multiple ranges requests,the same ip could download one more time with
this link.Now we need to prevent this from happening using something like this :
if($range["start"]!=$dbtikt["down_range"]){//IF4446
//IF THE CLIENT DIDN'T REQUESTED THE CORRECT RANGE.
exit();
//WE REFUSE THIS RANGE.
}//IF4446
now some tips ii learned:
=>to allow download of big files you must add code set_time_limit(0);
=>you must proccess the connection abort using ignore_user_abort(true),this means your script
will continue executing when the user disconnects from server.
so you could use if(connection_aborted()){do something} to perform finshing tasks.
=>don't put any thing before <?php code ?>,to avoid header already sent errors,or
simply turn on output buffer to prevent php from sending any output until you call flush functions.
=>to provide a limiting speed mechanism,i read always 32*speed bytes from file ,flush it and wait
a partical time using usleep(round((1000000*32)/1024)) and its working.
----
Server IP: 69.147.83.197
Probable Submitter: 41.251.117.221
----
Manual Page -- http://www.php.net/manual/en/function.fread.php
Edit -- https://master.php.net/note/edit/85950
Del: integrated -- https://master.php.net/note/delete/85950/integrated
Del: useless -- https://master.php.net/note/delete/85950/useless
Del: bad code -- https://master.php.net/note/delete/85950/bad+code
Del: spam -- https://master.php.net/note/delete/85950/spam
Del: non-english -- https://master.php.net/note/delete/85950/non-english
Del: in docs -- https://master.php.net/note/delete/85950/in+docs
Del: other reasons-- https://master.php.net/note/delete/85950
Reject -- https://master.php.net/note/reject/85950
Search -- https://master.php.net/manage/user-notes.php