this is my code...
..........
$file="/home/user/test.rar";
$fd = @fopen ($file, "rb");
header("Cache-control: private\n");
..............
header("Content-Transfer-Encoding: binary\n");
register_shutdown_function('TrafficLogs');
$orgsizepos= ftell($fd);
while(!feof($fd)) {
echo fread($fd, 4096);
$numFilesizecnt=ftell($fd)-$orgsizepos;
}
}
function TrafficLogs() {
global $numFilesizecnt,$dbname,$dbhost, $sqluser, $sqlpass,$tbl_DL_Logs,$file,$REMOTE_ADDR;
$link2 = @mysql_connect($dbhost, $sqluser, $sqlpass) or die ();
if ($numFilesizecnt != 0) {
$tbl_DL_Logs = "DL_Logs"; //¶¨ÒåÏÂÔØ Log ±í
$log_query="INSERT INTO $tbl_DL_Logs (ip,file, size) VALUES ('$REMOTE_ADDR', '$file', '$numFilesizecnt')";
@mysql_db_query($dbname,$log_query,$link2);
}
@mysql_close($link2);
unset($link2);
}
===========
i need know user get how much traffic....so i have set $numFilesizecnt.....
but ..... example: test.rar = 20MB. if i download test.rar just 900KB..then click "cancel" button. the TrafficLogs will always logs $numFilesizecnt = 20MB.....
why???????????