Michelle Konzack wrote:
Hello Eric,
Am 2009-01-04 14:33:37, schrieb Eric Butera:
On Sun, Jan 4, 2009 at 1:39 PM, Michelle Konzack
<linux4michelle@xxxxxxxxxxxxxxx> wrote:
----[ '/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);
}
------------------------------------------------------------------------
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.
Since I have encountered that fncUserUpdate() is writing the Test-Logfile
(even with wrong value) I am now puzzeling arround, because I was
thinking, if I am in the loop
while ( !feof($HANDLER) ) {
$CUR_SIZE+=$BUFFER;
echo fread($HANDLER, $BUFFER);
}
and the user intreeupt the transfer, the script would never reach
fncUserUpdate($user, 'downloads', $file, $CUR_SIZE, $FSIZE);
which WAS writing the Test-Logfile while beeing interrupted...
I have checked with phpsysinfo() but there are no settings like
ignore_user_abort
and
connection_status
The above two are functions, not settings.
Here are the links:
http://us.php.net/ignore_user_abort
http://us.php.net/connection_status
<SNIP>
function fncPushBinary($type='show', $file, $mime='') {
ignore_user_abort();
$BUFFER=1024;
$HANDLER=fopen($file, r);
$CUR_SIZE=0;
while ( !feof($HANDLER) ) {
# Check to see if the connection been aborted, or if it timed out.
# Plus, record the reason it was disconnected.
if ( ( $reason = connection_status() ) != CONNECTION_NORMAL ) {
RecordDownloadAmount($CUR_SIZE, $reason);
exit;
}
$CUR_SIZE+=$BUFFER;
echo fread($HANDLER, $BUFFER);
}
fclose($HANDLER);
fncUserUpdate($user, 'downloads', $file, $CUR_SIZE, $FSIZE);
exit();
}
</SNIP>
Something like the above should do the trick. Just create a function
called RecordDownloadAmount() (call it whatever you want really) and
have it log the information that you want stored about the download,
then kill the script. should be that simple really...
Not I have replaced the fncUserUpdate() with the original function for
the PostgreSQL and MySQL database and it is just executed and the script
run up to the end... weird!
Thanks, Greetings and nice Day/Evening
Michelle Konzack
Systemadministrator
24V Electronic Engineer
Tamay Dogan Network
Debian GNU/Linux Consultant
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php