You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

50 lines
2.3 KiB

<?php
require_once('../ajax_asm.php');
require_once('../php/argus/server.php');
$UID = intval( $CUser->Data['id'] );
$ACCESS = intval( $CUser->Data['access'] );
if( $CUser->Data['id'] > 1 ){
if( isset( $_GET['SESSION'] ) ) $SESID = intval( $_GET['SESSION'] ); else $SESID = 0;
if( isset( $_GET['VID'] ) ) $VID = intval( $_GET['VID'] ); else $VID = 0;
if( $SESID ){
$QS = "SELECT * FROM `sessions` WHERE `id`={$SESID}";
$RR = $DATABASE->Query( $QS );
if( count( $RR ) ){
$SD = $RR[0];
$Data['basepath'] = '/lib/controller/data/reports/'.$SD['track_id'].'/'.date("Y/m/d",intval( $SD['ts'] ));
if( file_exists( $SYSPath . $Data['basepath'] )){
$DBN = $SYSPath . $Data['basepath'] .'/report.db';
//echo $DBN;
//if( !file_exists( $DBN )) echo "Not Exist!!";
$RBASE = new SQLite_DB( $DBN );
$QS = "SELECT * FROM `videos` WHERE `session_id`={$SESID} AND `id`={$VID}";
$RR = $RBASE->Query( $QS );
$CR = $RR[0];
$NAME = $CR['uuid'] . '.'. $CR['ext'];
$filePath = $SYSPath . $Data['basepath'] . '/' . $NAME;
if( file_exists($filePath) ){
$QS = "SELECT `ms`.`short`, `mp`.`level`, `mt`.`short` as `tshort` FROM ( `metro_tracks` `mt` LEFT JOIN `metro_platforms` `mp` ON ( `mt`.`platform_id`=`mp`.`id`) ) LEFT JOIN `metro_stations` `ms` ON ( `mp`.`station_id` = `ms`.`id` ) WHERE `mt`.`id`={$SD['track_id']}";
$RR = $DATABASE->Query( $QS );
$downloadName = $RR[0]['short'].'_'.$RR[0]['level'].'_'.$RR[0]['tshort'].'_'.date("Y-m-d_H.i.s", $CR['ts'] ).'.'. $CR['ext'];
// 1. Clear any previous output buffers
if (ob_get_level()) {
ob_end_clean();
}
// 2. Set the content type (e.g., application/pdf, image/jpeg, or application/octet-stream)
header('Content-Type: application/octet-stream');
// 3. Force download and define the file name
header('Content-Disposition: attachment; filename="' . $downloadName. '"');
// 4. Provide the exact file size to show download progress
header('Content-Length: ' . filesize($filePath));
// 5. Read the file and write it directly to the output buffer
readfile($filePath);
exit;
} else {
die("Error: The requested file does not exist.");
};
};
};
};
};
?>