From 8b82d761829b11b4fb8b884ae4e4d20e48d14f86 Mon Sep 17 00:00:00 2001 From: DanielnetoDotCom Date: Thu, 10 Jun 2021 17:07:52 -0300 Subject: [PATCH] https://github.com/WWBN/AVideo/issues/5287 --- .htaccess | 1 + xsendfile.php | 18 ++++++++++++++++-- xtest.txt | 1 + 3 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 xtest.txt diff --git a/.htaccess b/.htaccess index d86f7df..62ca8e5 100644 --- a/.htaccess +++ b/.htaccess @@ -39,6 +39,7 @@ Options All -Indexes RewriteRule ^videos/([A-Za-z0-9-_.]+(/[A-Za-z0-9-_.]+)?([^!#$&'()*+,:;=?@[\]]+(\.(m3u8\.mp4)))) xsendfile.php?playHLSasMP4=1&file=$1 [QSA] RewriteRule ^videos/([A-Za-z0-9-_.]+(/[A-Za-z0-9-_.]+)?([^!#$&'()*+,:;=?@[\]]+(\.(mp4|webm|m3u8|mp3|ogg)))) xsendfile.php?file=$1 [QSA] RewriteRule ^videos/([A-Za-z0-9-_.]+/[A-Za-z0-9-_.].key)$ xsendfile.php?file=$1 [QSA] + RewriteRule ^test$ xsendfile.php?test=1 [QSA] diff --git a/xsendfile.php b/xsendfile.php index f58f459..e9d1781 100644 --- a/xsendfile.php +++ b/xsendfile.php @@ -4,6 +4,20 @@ require_once './functions.php'; session_write_close(); +if ($_GET['test']) { + $path = getcwd().'/xtest.txt'; + header('Content-Description: File Transfer'); + header('Content-Disposition: attachment; filename=successtest.txt'); + header('Content-Transfer-Encoding: binary'); + header('Connection: Keep-Alive'); + header('Expires: 0'); + header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); + header('Pragma: public'); + header("X-Sendfile: {$path}"); + header('Content-Length: ' . filesize($path)); + exit; +} + if (empty($_GET['file'])) { error_log("XSENDFILE GET file not found "); die('GET file not found'); @@ -78,13 +92,13 @@ header('Pragma: public'); } else if (!empty($_GET['playHLSasMP4'])) { playHLSasMP4($path); - } + } header("X-Sendfile: {$path}"); if (empty($_GET['download'])) { header("Content-type: " . mime_content_type($path)); } header('Content-Length: ' . filesize($path)); die(); -}else { +} else { error_log("XSENDFILE ERROR: Not exists {$path} = " . json_encode($path_parts)); } diff --git a/xtest.txt b/xtest.txt new file mode 100644 index 0000000..cf171c5 --- /dev/null +++ b/xtest.txt @@ -0,0 +1 @@ +Your XSend File is working \ No newline at end of file