>>,Mounts,>>>,>>>,Ejects,>>>,>>>,Inserts\n"); fwrite($handle, ",,Max,Avg,Total,Max,Avg,Total,Max,Avg,Total\n"); fwrite($handle, "Date and Time,Log Lib,Sec,Sec,Count,Sec,Sec,Count,Sec,Sec,Count\n"); fclose($handle); $size = filesize($temp_file); unlink($temp_file); //file name $fileName='/home/embedded/library/CoreService/dat/library_stats.csv'; if (file_exists($fileName)) { $size = $size + filesize($fileName); header("Pragma: "); header("Cache-Control: "); header("Content-Type: csv/plain"); header("Content-Length: $size"); header('Content-Disposition: attachment; filename="' . basename($fileName) . '"'); header("Content-Location: $fileName"); header("Cache-Control: private"); $handle = fopen($fileName, "r"); if ($handle = fopen($fileName, 'rb')) { $i=0; while(!feof($handle) and (connection_status()==0)) { if($i==0) { error_log("Add headers to library_stats.csv"); print("Library Statistics,,,,,,,,,,\n"); print(",,,,,,,,,,\n"); print(",,,,,,,,,,\n"); print("Hourly Summary,,Residency,>>>,Mounts,>>>,>>>,Ejects,>>>,>>>,Inserts\n"); print(",,Max,Avg,Total,Max,Avg,Total,Max,Avg,Total\n"); print("Date and Time,Log Lib,Sec,Sec,Count,Sec,Sec,Count,Sec,Sec,Count\n"); } else { print(fread($handle, 1024*1)); } flush(); $i++; } } error_log("Uploading library_stats.csv"); fclose($handle); return; } else // file does not exist just download the headers { header("Pragma: "); header("Cache-Control: "); header("Content-Type: csv/plain"); header("Content-Length: $size"); header('Content-Disposition: attachment; filename="' . basename($fileName) . '"'); header("Content-Location: $fileName"); header("Cache-Control: private"); if(connection_status()==0) { error_log("Add headers to blank library_stats.csv"); print("Library Statistics,,,,,,,,,,\n"); print(",,,,,,,,,,\n"); print(",,,,,,,,,,\n"); print("Hourly Summary,,Residency,>>>,Mounts,>>>,>>>,Ejects,>>>,>>>,Inserts\n"); print(",,Max,Avg,Total,Max,Avg,Total,Max,Avg,Total\n"); print("Date and Time,Log Lib,Sec,Sec,Count,Sec,Sec,Count,Sec,Sec,Count\n"); flush(); } error_log("Uploading blank library_stats.csv"); fclose($handle); return; } ?>