Re: [PHP] Re: How to count transfered kBytes in File-Download



On Sun, Jan 4, 2009 at 1:39 PM, Michelle Konzack
<linux4michelle@xxxxxxxxxxxxxxx> wrote:
Hi Jim... ;-)

The code:

----[ '/usr/share/tdphp-vserver/includes/02_functions.inc' ]------------
function fncPushBinary($type='show', $file, $mime='') {
<snip>
$BUFFER=1024;

$HANDLER=fopen($file, r);

$CUR_SIZE=0;
while ( !feof($HANDLER) ) {
$CUR_SIZE+=$BUFFER;
echo fread($HANDLER, $BUFFER);
}
fclose($HANDLER);

fncUserUpdate($user, 'downloads', $file, $CUR_SIZE, $FSIZE);
exit();
<snip>
}

function fncUserUpdate($user, $type, $file, $cur_size, $file_size) {
echo "What The Hell Is Going On Here?\n";
$HANDLER=fopen('/tmp/fncUserUpdate.log', a);
$DATE=date("r");
fwrite($HANDLER, "$DATE $user $file $cur_size $file_size\n");
fclose($HANDLER);
}
------------------------------------------------------------------------

is working without any errors, but in my log I get every time:

----[ '/tmp/fncUserUpdate.log' ]----------------------------------------
Sun, 04 Jan 2009 18:48:51 +0100 dummy /var/www/customers/konzack/CONFIG_musica.tamay-dogan.net/music/Iran/Arian_Band_-_Bi_To_Ba_To.jpg
Sun, 04 Jan 2009 18:49:44 +0100 dummy /var/www/customers/konzack/CONFIG_musica.tamay-dogan.net/music/Iran/Arian_Band_-_Bi_To_Ba_To.jpg
Sun, 04 Jan 2009 18:53:22 +0100 dummy /var/www/customers/konzack/CONFIG_musica.tamay-dogan.net/music/Iran/Arian_Band_-_Bi_To_Ba_To.jpg
------------------------------------------------------------------------

which is a little bit weird, since I have downloaded the files with
'wget' and interrupted the transfer.

Speek, the $CUR_SIZE is always the filesize rounded up (1kByte) but NOT
the actual downloaded partial size, which is, what I want...

Any sugestions?

Thanks, Greetings and nice Day/Evening
Michelle Konzack
Systemadministrator
24V Electronic Engineer
Tamay Dogan Network
Debian GNU/Linux Consultant


--
Linux-User #280138 with the Linux Counter, http://counter.li.org/
##################### Debian GNU/Linux Consultant #####################
<http://www.tamay-dogan.net/> <http://www.can4linux.org/>
Michelle Konzack Apt. 917 ICQ #328449886
+49/177/9351947 50, rue de Soultz MSN LinuxMichi
+33/6/61925193 67100 Strasbourg/France IRC #Debian (irc.icq.com)



Maybe a combination of ignore_user_abort & connection_status will get
you what you need. This way the user doesn't make the script die, but
you can keep checking to make sure the connection is active. If not,
update that db and exit out. I've never attempted anything like this,
so I don't really have any concrete answers for you.
.



Relevant Pages