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.

54 lines
2.5 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <?php
  2. require_once('../ajax_asm.php');
  3. require_once('../php/argus/server.php');
  4. $UID = intval( $CUser->Data['id'] );
  5. $ACCESS = intval( $CUser->Data['access'] );
  6. if( $CUser->Data['id'] > 1 ){
  7. if( isset( $_GET['SESSION'] ) ) $SESID = intval( $_GET['SESSION'] ); else $SESID = 0;
  8. if( isset( $_GET['SIDE'] ) ) $SIDE = $_GET['SIDE']; else $SIDE = 'L';
  9. if( $SESID ){
  10. $QS = "SELECT * FROM `media_composer_queue` WHERE `session_id`={$SESID}";
  11. $RR = $DATABASE->Query( $QS );
  12. if( count( $RR ) ){
  13. $SD = $RR[0];
  14. if( $SIDE == 'L' ){
  15. $Data['basepath'] = '/lib/controller/data/composed_videos/'.$SD['uuid'].'_L.mp4';
  16. } else {
  17. $Data['basepath'] = '/lib/controller/data/composed_videos/'.$SD['uuid'].'_R.mp4';
  18. }
  19. $filePath = $SYSPath . $Data['basepath'];
  20. if( file_exists( $filePath )){
  21. //$DBN = $SYSPath . $Data['basepath'] .'/report.db';
  22. //echo $DBN;
  23. //if( !file_exists( $DBN )) echo "Not Exist!!";
  24. //$RBASE = new SQLite_DB( $DBN );
  25. //$QS = "SELECT * FROM `videos` WHERE `session_id`={$SESID} AND `id`={$VID}";
  26. //$RR = $RBASE->Query( $QS );
  27. //$CR = $RR[0];
  28. //$NAME = $CR['uuid'] . '.'. $CR['ext'];
  29. //$filePath = $SYSPath . $Data['basepath'] . '/' . $NAME;
  30. //if( file_exists($filePath) ){
  31. //$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']}";
  32. //$RR = $DATABASE->Query( $QS );
  33. $downloadName = 'some_name_that_must_be_corrected.mp4';//$RR[0]['short'].'_'.$RR[0]['level'].'_'.$RR[0]['tshort'].'_'.date("Y-m-d_H.i.s", $CR['ts'] ).'.'. $CR['ext'];
  34. // 1. Clear any previous output buffers
  35. if (ob_get_level()) {
  36. ob_end_clean();
  37. }
  38. // 2. Set the content type (e.g., application/pdf, image/jpeg, or application/octet-stream)
  39. header('Content-Type: application/octet-stream');
  40. // 3. Force download and define the file name
  41. header('Content-Disposition: attachment; filename="' . $downloadName. '"');
  42. // 4. Provide the exact file size to show download progress
  43. header('Content-Length: ' . filesize($filePath));
  44. // 5. Read the file and write it directly to the output buffer
  45. readfile($filePath);
  46. exit;
  47. //} else {
  48. // die("Error: The requested file does not exist.");
  49. //};
  50. };
  51. };
  52. };
  53. };
  54. ?>