mirror of
https://github.com/DanielnetoDotCom/YouPHPTube
synced 2025-10-03 01:39:24 +02:00
Update
This commit is contained in:
parent
8392310423
commit
7e2e69cf2e
1 changed files with 21 additions and 14 deletions
|
@ -8,7 +8,7 @@ _session_write_close();
|
||||||
require_once $global['systemRootPath'] . 'objects/functions.php';
|
require_once $global['systemRootPath'] . 'objects/functions.php';
|
||||||
require_once $global['systemRootPath'] . 'plugin/AVideoPlugin.php';
|
require_once $global['systemRootPath'] . 'plugin/AVideoPlugin.php';
|
||||||
|
|
||||||
if(!empty($isStandAlone)){
|
if (!empty($isStandAlone)) {
|
||||||
$folder = preg_replace('/[^0-9a-z_-]/i', '', $_REQUEST['folder']);
|
$folder = preg_replace('/[^0-9a-z_-]/i', '', $_REQUEST['folder']);
|
||||||
$file = preg_replace('/[^0-9a-z_.-]/i', '', $_REQUEST['file']);
|
$file = preg_replace('/[^0-9a-z_.-]/i', '', $_REQUEST['file']);
|
||||||
$path = "{$global['systemRootPath']}videos/$folder/$file";
|
$path = "{$global['systemRootPath']}videos/$folder/$file";
|
||||||
|
@ -30,28 +30,28 @@ if (empty($_GET['file'])) {
|
||||||
_error_log("XSENDFILE GET file not found ");
|
_error_log("XSENDFILE GET file not found ");
|
||||||
die('GET file not found');
|
die('GET file not found');
|
||||||
}
|
}
|
||||||
if($_GET['file']=='index.mp3'){
|
if ($_GET['file'] == 'index.mp3') {
|
||||||
$url = parse_url($_SERVER["REQUEST_URI"]);
|
$url = parse_url($_SERVER["REQUEST_URI"]);
|
||||||
$paths = Video::getPaths($url["path"]);
|
$paths = Video::getPaths($url["path"]);
|
||||||
$path = "{$paths['path']}index.mp3";
|
$path = "{$paths['path']}index.mp3";
|
||||||
$file = "{$paths["relative"]}index.mp3";
|
$file = "{$paths["relative"]}index.mp3";
|
||||||
$path_parts = pathinfo($file);
|
$path_parts = pathinfo($file);
|
||||||
//var_dump(__LINE__, $file, $path, $paths);
|
//var_dump(__LINE__, $file, $path, $paths);
|
||||||
}else if($_GET['file']=='index.mp4'){
|
} else if ($_GET['file'] == 'index.mp4') {
|
||||||
$url = parse_url($_SERVER["REQUEST_URI"]);
|
$url = parse_url($_SERVER["REQUEST_URI"]);
|
||||||
$paths = Video::getPaths($url["path"]);
|
$paths = Video::getPaths($url["path"]);
|
||||||
$path = "{$paths['path']}index.mp4";
|
$path = "{$paths['path']}index.mp4";
|
||||||
$file = "{$paths["relative"]}index.mp4";
|
$file = "{$paths["relative"]}index.mp4";
|
||||||
$path_parts = pathinfo($file);
|
$path_parts = pathinfo($file);
|
||||||
//var_dump(__LINE__, $file, $path, $paths);
|
//var_dump(__LINE__, $file, $path, $paths);
|
||||||
}else if($_GET['file']=='index_offline.mp4'){
|
} else if ($_GET['file'] == 'index_offline.mp4') {
|
||||||
$url = parse_url($_SERVER["REQUEST_URI"]);
|
$url = parse_url($_SERVER["REQUEST_URI"]);
|
||||||
$paths = Video::getPaths($url["path"]);
|
$paths = Video::getPaths($url["path"]);
|
||||||
$path = "{$paths['path']}index_offline.mp4";
|
$path = "{$paths['path']}index_offline.mp4";
|
||||||
$file = "{$paths["relative"]}index_offline.mp4";
|
$file = "{$paths["relative"]}index_offline.mp4";
|
||||||
$path_parts = pathinfo($file);
|
$path_parts = pathinfo($file);
|
||||||
//var_dump($paths);exit;
|
//var_dump($paths);exit;
|
||||||
}else{
|
} else {
|
||||||
$path_parts = pathinfo($_GET['file']);
|
$path_parts = pathinfo($_GET['file']);
|
||||||
$file = $path_parts['basename'];
|
$file = $path_parts['basename'];
|
||||||
}
|
}
|
||||||
|
@ -87,21 +87,28 @@ if ($file == "configuration.php") {
|
||||||
_error_log("XSENDFILE Can't read this configuration ");
|
_error_log("XSENDFILE Can't read this configuration ");
|
||||||
forbiddenPage("Can't read this");
|
forbiddenPage("Can't read this");
|
||||||
}
|
}
|
||||||
if(!empty($_REQUEST['cacheDownload'])){
|
if (!empty($_REQUEST['cacheDownload'])) {
|
||||||
$file = preg_replace('/[^0-9a-z_\.]/i', '', $_GET['file']);
|
$file = preg_replace('/[^0-9a-z_\.]/i', '', $_GET['file']);
|
||||||
$relativePath = "cache/download/";
|
$relativePath = "cache/download/";
|
||||||
$path = getVideosDir().$relativePath.$file;
|
$path = getVideosDir() . $relativePath . $file;
|
||||||
$_GET['download'] = 1;
|
$_GET['download'] = 1;
|
||||||
_error_log("cacheDownload: $path");
|
_error_log("cacheDownload: $path");
|
||||||
}else{
|
} else {
|
||||||
$path = Video::getPathToFile($file);
|
$path = Video::getPathToFile($file);
|
||||||
$folder = preg_replace('/[^a-z0-9_-]/i', '', @$_GET['folder']);
|
$folder = preg_replace('/[^a-z0-9_-]/i', '', @$_GET['folder']);
|
||||||
if(!file_exists($path) && !empty($folder)){
|
if (!file_exists($path) && !empty($folder)) {
|
||||||
$file = str_replace("videos/{$folder}/", '', $file);
|
$file = str_replace("videos/{$folder}/", '', $file);
|
||||||
$path = "{$global['systemRootPath']}videos/{$folder}/{$file}";
|
$path = "{$global['systemRootPath']}videos/{$folder}/{$file}";
|
||||||
}
|
}
|
||||||
//var_dump($path, $file, $_GET);exit;
|
//var_dump($path, $file, $_GET);exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!file_exists($path)) {
|
||||||
|
if (preg_match('/.mp4/', $file)) {
|
||||||
|
$path = str_replace($file, 'index.mp4', $path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//header('Content-Type: application/json');var_dump(__LINE__, $_SERVER["REQUEST_URI"], $file, $path);exit;
|
//header('Content-Type: application/json');var_dump(__LINE__, $_SERVER["REQUEST_URI"], $file, $path);exit;
|
||||||
//header('Content-Type: application/json');var_dump($advancedCustom->doNotUseXsendFile);
|
//header('Content-Type: application/json');var_dump($advancedCustom->doNotUseXsendFile);
|
||||||
if (file_exists($path)) {
|
if (file_exists($path)) {
|
||||||
|
@ -119,14 +126,14 @@ if (file_exists($path)) {
|
||||||
|
|
||||||
$quoted = preg_replace('/[^a-z0-9_.-]/i', '', $quoted);
|
$quoted = preg_replace('/[^a-z0-9_.-]/i', '', $quoted);
|
||||||
|
|
||||||
if(empty($quoted)){
|
if (empty($quoted)) {
|
||||||
$quoted = 'undefinedName';
|
$quoted = 'undefinedName';
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!preg_match('/\.'.$path_parts['extension'].'$/i', $quoted)){
|
if (!preg_match('/\.' . $path_parts['extension'] . '$/i', $quoted)) {
|
||||||
$quoted = "{$quoted}.{$path_parts['extension']}";
|
$quoted = "{$quoted}.{$path_parts['extension']}";
|
||||||
}
|
}
|
||||||
|
|
||||||
//var_dump(__LINE__, $quoted, $path_parts);exit;
|
//var_dump(__LINE__, $quoted, $path_parts);exit;
|
||||||
//header('Content-Type: application/json');var_dump($quoted);exit;
|
//header('Content-Type: application/json');var_dump($quoted);exit;
|
||||||
header('Content-Description: File Transfer');
|
header('Content-Description: File Transfer');
|
||||||
|
@ -165,5 +172,5 @@ if (file_exists($path)) {
|
||||||
}
|
}
|
||||||
die();
|
die();
|
||||||
} else {
|
} else {
|
||||||
_error_log("XSENDFILE ERROR: Not exists path={$path} file={$file} ". json_encode($_GET));
|
_error_log("XSENDFILE ERROR: Not exists path={$path} file={$file} " . json_encode($_GET));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue