mirror of
https://github.com/DanielnetoDotCom/YouPHPTube
synced 2025-10-03 09:49:28 +02:00
Add a caller timer
This commit is contained in:
parent
2c07a7705e
commit
dc9aec5bbe
9 changed files with 605 additions and 550 deletions
|
@ -504,8 +504,9 @@ abstract class ObjectYPT implements ObjectInterface
|
||||||
if (empty($getCachesProcessed)) {
|
if (empty($getCachesProcessed)) {
|
||||||
$getCachesProcessed = [];
|
$getCachesProcessed = [];
|
||||||
}
|
}
|
||||||
|
//if($name=='getVideosURL_V2video_220721204450_v21b7'){var_dump($name);exit;}
|
||||||
$cachefile = self::getCacheFileName($name, false);
|
$cachefile = self::getCacheFileName($name, false);
|
||||||
//var_dump($cachefile);//exit;
|
//if($name=='getVideosURL_V2video_220721204450_v21b7'){var_dump($cachefile);exit;}//exit;
|
||||||
self::setLastUsedCacheFile($cachefile);
|
self::setLastUsedCacheFile($cachefile);
|
||||||
//_error_log('getCache: cachefile '.$cachefile);
|
//_error_log('getCache: cachefile '.$cachefile);
|
||||||
if (!empty($_getCache[$name])) {
|
if (!empty($_getCache[$name])) {
|
||||||
|
|
|
@ -386,7 +386,7 @@ function safeString($text, $strict = false) {
|
||||||
if ($strict) {
|
if ($strict) {
|
||||||
$text = filter_var($text, FILTER_SANITIZE_STRING);
|
$text = filter_var($text, FILTER_SANITIZE_STRING);
|
||||||
//$text = cleanURLName($text);
|
//$text = cleanURLName($text);
|
||||||
}
|
}
|
||||||
$text = trim($text);
|
$text = trim($text);
|
||||||
return $text;
|
return $text;
|
||||||
}
|
}
|
||||||
|
@ -1332,7 +1332,9 @@ function getVideosURL_V2($fileName, $recreateCache = false) {
|
||||||
|
|
||||||
$TimeLog1 = "getVideosURL_V2($fileName) empty recreateCache";
|
$TimeLog1 = "getVideosURL_V2($fileName) empty recreateCache";
|
||||||
TimeLogStart($TimeLog1);
|
TimeLogStart($TimeLog1);
|
||||||
$files = object_to_array(ObjectYPT::getCache($cacheName, $lifetime, true));
|
//var_dump($cacheName, $lifetime);exit;
|
||||||
|
$cache = ObjectYPT::getCache($cacheName, $lifetime, true);
|
||||||
|
$files = object_to_array($cache);
|
||||||
if (is_array($files)) {
|
if (is_array($files)) {
|
||||||
//_error_log("getVideosURL_V2: do NOT recreate lifetime = {$lifetime}");
|
//_error_log("getVideosURL_V2: do NOT recreate lifetime = {$lifetime}");
|
||||||
$preg_match_url = addcslashes(getCDN(), "/") . "videos";
|
$preg_match_url = addcslashes(getCDN(), "/") . "videos";
|
||||||
|
@ -2396,7 +2398,7 @@ function getTagIfExists($relativePath) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getImageTagIfExists($relativePath, $title='', $id='', $style='', $class='img img-responsive', $lazyLoad=false) {
|
function getImageTagIfExists($relativePath, $title = '', $id = '', $style = '', $class = 'img img-responsive', $lazyLoad = false) {
|
||||||
global $global;
|
global $global;
|
||||||
$relativePathOriginal = $relativePath;
|
$relativePathOriginal = $relativePath;
|
||||||
$relativePath = getRelativePath($relativePath);
|
$relativePath = getRelativePath($relativePath);
|
||||||
|
@ -2404,83 +2406,83 @@ function getImageTagIfExists($relativePath, $title='', $id='', $style='', $class
|
||||||
$wh = '';
|
$wh = '';
|
||||||
if (file_exists($file)) {
|
if (file_exists($file)) {
|
||||||
// check if there is a thumbs
|
// check if there is a thumbs
|
||||||
if(!preg_match('/_thumbsV2.jpg/', $file)){
|
if (!preg_match('/_thumbsV2.jpg/', $file)) {
|
||||||
$thumbs = str_replace('.jpg', '_thumbsV2.jpg', $file);
|
$thumbs = str_replace('.jpg', '_thumbsV2.jpg', $file);
|
||||||
if(file_exists($thumbs)){
|
if (file_exists($thumbs)) {
|
||||||
$file = $thumbs;
|
$file = $thumbs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$file = createWebPIfNotExists($file);
|
$file = createWebPIfNotExists($file);
|
||||||
|
|
||||||
$url = getURL(getRelativePath($file));
|
$url = getURL(getRelativePath($file));
|
||||||
$image_info = getimagesize($file);
|
$image_info = getimagesize($file);
|
||||||
$wh = $image_info[3];
|
$wh = $image_info[3];
|
||||||
} else if (isValidURL($relativePathOriginal)) {
|
} else if (isValidURL($relativePathOriginal)) {
|
||||||
$url = $relativePathOriginal;
|
$url = $relativePathOriginal;
|
||||||
} else {
|
} else {
|
||||||
return '<!-- invalid URL '.$relativePathOriginal.' -->';
|
return '<!-- invalid URL ' . $relativePathOriginal . ' -->';
|
||||||
}
|
}
|
||||||
if(empty($title)){
|
if (empty($title)) {
|
||||||
$title = basename($relativePath);
|
$title = basename($relativePath);
|
||||||
}
|
}
|
||||||
$title = safeString($title);
|
$title = safeString($title);
|
||||||
$img = "<img style=\"{$style}\" alt=\"{$title}\" title=\"{$title}\" id=\"{$id}\" class=\"{$class}\" {$wh} ";
|
$img = "<img style=\"{$style}\" alt=\"{$title}\" title=\"{$title}\" id=\"{$id}\" class=\"{$class}\" {$wh} ";
|
||||||
if($lazyLoad){
|
if ($lazyLoad) {
|
||||||
if(is_string($lazyLoad)){
|
if (is_string($lazyLoad)) {
|
||||||
$loading = getURL($lazyLoad);
|
$loading = getURL($lazyLoad);
|
||||||
}else{
|
} else {
|
||||||
$loading = getURL('view/img/loading-gif.png');
|
$loading = getURL('view/img/loading-gif.png');
|
||||||
}
|
}
|
||||||
$img .= " src=\"{$loading}\" data-src=\"{$url}\" ";
|
$img .= " src=\"{$loading}\" data-src=\"{$url}\" ";
|
||||||
}else{
|
} else {
|
||||||
$img .= " src=\"{$url}\" ";
|
$img .= " src=\"{$url}\" ";
|
||||||
}
|
}
|
||||||
$img .= "/>";
|
$img .= "/>";
|
||||||
|
|
||||||
return $img;
|
return $img;
|
||||||
}
|
}
|
||||||
|
|
||||||
function createWebPIfNotExists($path){
|
function createWebPIfNotExists($path) {
|
||||||
if(version_compare(PHP_VERSION, '8.0.0') < 0 || !file_exists($path)){
|
if (version_compare(PHP_VERSION, '8.0.0') < 0 || !file_exists($path)) {
|
||||||
return $path;
|
return $path;
|
||||||
}
|
}
|
||||||
$extension = pathinfo($path, PATHINFO_EXTENSION);
|
$extension = pathinfo($path, PATHINFO_EXTENSION);
|
||||||
if($extension!=='jpg'){
|
if ($extension !== 'jpg') {
|
||||||
return $path;
|
return $path;
|
||||||
}
|
}
|
||||||
$nextGenPath = str_replace('.jpg', '_jpg.webp', $path);
|
$nextGenPath = str_replace('.jpg', '_jpg.webp', $path);
|
||||||
|
|
||||||
if(!file_exists($nextGenPath)){
|
if (!file_exists($nextGenPath)) {
|
||||||
convertImage($path, $nextGenPath, 70);
|
convertImage($path, $nextGenPath, 70);
|
||||||
}
|
}
|
||||||
return $nextGenPath;
|
return $nextGenPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getVideoImagewithHoverAnimation($relativePath, $relativePathHoverAnimation='', $title=''){
|
function getVideoImagewithHoverAnimation($relativePath, $relativePathHoverAnimation = '', $title = '') {
|
||||||
$id = uniqid();
|
$id = uniqid();
|
||||||
$img = getImageTagIfExists($relativePath, $title, "thumbsJPG{$id}", '', 'thumbsJPG img img-responsive').PHP_EOL;
|
$img = getImageTagIfExists($relativePath, $title, "thumbsJPG{$id}", '', 'thumbsJPG img img-responsive') . PHP_EOL;
|
||||||
if(!empty($relativePathHoverAnimation) && empty($_REQUEST['noImgGif'])){
|
if (!empty($relativePathHoverAnimation) && empty($_REQUEST['noImgGif'])) {
|
||||||
$img .= getImageTagIfExists($relativePathHoverAnimation, $title, "thumbsGIF{$id}", 'position: absolute; top: 0;', 'thumbsGIF img img-responsive ', true).PHP_EOL;
|
$img .= getImageTagIfExists($relativePathHoverAnimation, $title, "thumbsGIF{$id}", 'position: absolute; top: 0;', 'thumbsGIF img img-responsive ', true) . PHP_EOL;
|
||||||
}
|
}
|
||||||
return '<div class="thumbsImage">'.$img.'</div>';
|
return '<div class="thumbsImage">' . $img . '</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
function getRelativePath($path){
|
function getRelativePath($path) {
|
||||||
global $global;
|
global $global;
|
||||||
$relativePath = '';
|
$relativePath = '';
|
||||||
$parts = explode('view/img/', $path);
|
$parts = explode('view/img/', $path);
|
||||||
|
|
||||||
if(!empty($parts[1])){
|
if (!empty($parts[1])) {
|
||||||
$relativePath = 'view/img/'.$parts[1];
|
$relativePath = 'view/img/' . $parts[1];
|
||||||
}
|
}
|
||||||
if(empty($relativePath)){
|
if (empty($relativePath)) {
|
||||||
$parts = explode('videos/', $path);
|
$parts = explode('videos/', $path);
|
||||||
if(!empty($parts[1])){
|
if (!empty($parts[1])) {
|
||||||
$relativePath = 'videos/'.$parts[1];
|
$relativePath = 'videos/' . $parts[1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(empty($relativePath)){
|
if (empty($relativePath)) {
|
||||||
$relativePath = $path;
|
$relativePath = $path;
|
||||||
}
|
}
|
||||||
$parts2 = explode('?', $relativePath);
|
$parts2 = explode('?', $relativePath);
|
||||||
|
@ -3495,7 +3497,7 @@ function rrmdir($dir) {
|
||||||
}
|
}
|
||||||
if (rmdir($dir)) {
|
if (rmdir($dir)) {
|
||||||
return true;
|
return true;
|
||||||
} else if(is_dir($dir)){
|
} else if (is_dir($dir)) {
|
||||||
_error_log('rrmdir: could not delete folder ' . $dir);
|
_error_log('rrmdir: could not delete folder ' . $dir);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -5168,16 +5170,20 @@ function isValidURLOrPath($str, $insideCacheOrTmpDirOnly = true) {
|
||||||
_error_log('isValidURLOrPath return false (is php file) ' . $str);
|
_error_log('isValidURLOrPath return false (is php file) ' . $str);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$cacheDir = "{$global['systemRootPath']}videos/";
|
if (
|
||||||
if (str_starts_with($absolutePath, $absolutePathTmp) || str_starts_with($absolutePath, '/var/www/') || str_starts_with($absolutePath, $absolutePathCache)) {
|
str_starts_with($absolutePath, $absolutePathTmp) ||
|
||||||
|
str_starts_with($absolutePath, '/var/www/') ||
|
||||||
|
str_starts_with($absolutePath, $absolutePathCache) ||
|
||||||
|
str_starts_with($absolutePath, $global['systemRootPath']) ||
|
||||||
|
str_starts_with($absolutePath, getVideosDir())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
_error_log('isValidURLOrPath return false not valid absolute path 1 ' . $absolutePath);
|
//_error_log('isValidURLOrPath return false not valid absolute path 1 ' . $absolutePath);
|
||||||
_error_log('isValidURLOrPath return false not valid absolute path 2 ' . $absolutePathTmp);
|
//_error_log('isValidURLOrPath return false not valid absolute path 2 ' . $absolutePathTmp);
|
||||||
_error_log('isValidURLOrPath return false not valid absolute path 3 ' . $absolutePathCache);
|
//_error_log('isValidURLOrPath return false not valid absolute path 3 ' . $absolutePathCache);
|
||||||
}
|
}
|
||||||
//_error_log('isValidURLOrPath return false '.$str);
|
//_error_log('isValidURLOrPath return false '.$str);
|
||||||
return false;
|
return false;
|
||||||
|
@ -5843,6 +5849,7 @@ function _json_encode($object) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function _json_decode($object) {
|
function _json_decode($object) {
|
||||||
|
global $global;
|
||||||
if (empty($object)) {
|
if (empty($object)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -6696,69 +6703,6 @@ function playHLSasMP4($filepath) {
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
function m3u8ToMP4($input) {
|
|
||||||
$videosDir = getVideosDir();
|
|
||||||
$outputfilename = str_replace($videosDir, "", $input);
|
|
||||||
$parts = explode("/", $outputfilename);
|
|
||||||
$resolution = Video::getResolutionFromFilename($input);
|
|
||||||
$outputfilename = $parts[0] . "_{$resolution}_.mp4";
|
|
||||||
$outputpath = "{$videosDir}cache/downloads/{$outputfilename}";
|
|
||||||
$msg = '';
|
|
||||||
$error = true;
|
|
||||||
make_path($outputpath);
|
|
||||||
if (empty($outputfilename)) {
|
|
||||||
$msg = "downloadHLS: empty outputfilename {$outputfilename}";
|
|
||||||
_error_log($msg);
|
|
||||||
return ['error' => $error, 'msg' => $msg];
|
|
||||||
}
|
|
||||||
_error_log("downloadHLS: m3u8ToMP4($input)");
|
|
||||||
//var_dump(!preg_match('/^http/i', $input), filesize($input), preg_match('/.m3u8$/i', $input));
|
|
||||||
$ism3u8 = preg_match('/.m3u8$/i', $input);
|
|
||||||
if (!preg_match('/^http/i', $input) && (filesize($input) <= 10 || $ism3u8)) { // dummy file
|
|
||||||
$filepath = escapeshellcmd(pathToRemoteURL($input, true, true));
|
|
||||||
if ($ism3u8 && !preg_match('/.m3u8$/i', $filepath)) {
|
|
||||||
$filepath = addLastSlash($filepath) . 'index.m3u8';
|
|
||||||
}
|
|
||||||
|
|
||||||
$token = getToken(60);
|
|
||||||
$filepath = addQueryStringParameter($filepath, 'globalToken', $token);
|
|
||||||
} else {
|
|
||||||
$filepath = escapeshellcmd($input);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (is_dir($filepath)) {
|
|
||||||
$filepath = addLastSlash($filepath) . 'index.m3u8';
|
|
||||||
}
|
|
||||||
|
|
||||||
$outputpath = escapeshellcmd($outputpath);
|
|
||||||
if (!file_exists($outputpath)) {
|
|
||||||
$command = get_ffmpeg() . " -allowed_extensions ALL -y -i \"{$filepath}\" -c:v copy -c:a copy -bsf:a aac_adtstoasc -strict -2 {$outputpath}";
|
|
||||||
$msg1 = "downloadHLS: Exec Command ({$command})";
|
|
||||||
_error_log($msg1);
|
|
||||||
//var_dump($outputfilename, $command, $_GET, $filepath);exit;
|
|
||||||
exec($command . " 2>&1", $output, $return);
|
|
||||||
if (!empty($return)) {
|
|
||||||
$msg2 = "downloadHLS: ERROR 1 " . implode(PHP_EOL, $output);
|
|
||||||
_error_log($msg2);
|
|
||||||
|
|
||||||
$command = get_ffmpeg() . " -y -i \"{$filepath}\" -c:v copy -c:a copy -bsf:a aac_adtstoasc -strict -2 {$outputpath}";
|
|
||||||
//var_dump($outputfilename, $command, $_GET, $filepath);exit;
|
|
||||||
exec($command . " 2>&1", $output, $return);
|
|
||||||
if (!empty($return)) {
|
|
||||||
$msg3 = "downloadHLS: ERROR 2 " . implode(PHP_EOL, $output);
|
|
||||||
$finalMsg = $msg1 . PHP_EOL . $msg2 . PHP_EOL . $msg3;
|
|
||||||
_error_log($msg3);
|
|
||||||
return ['error' => $error, 'msg' => $finalMsg];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$msg = "downloadHLS: outputpath already exists ({$outputpath})";
|
|
||||||
_error_log($msg);
|
|
||||||
}
|
|
||||||
$error = false;
|
|
||||||
return ['error' => $error, 'msg' => $msg, 'path' => $outputpath, 'filename' => $outputfilename];
|
|
||||||
}
|
|
||||||
|
|
||||||
function getSocialModal($videos_id, $url = "", $title = "") {
|
function getSocialModal($videos_id, $url = "", $title = "") {
|
||||||
global $global;
|
global $global;
|
||||||
$video['id'] = $videos_id;
|
$video['id'] = $videos_id;
|
||||||
|
@ -6886,6 +6830,123 @@ function get_ffmpeg($ignoreGPU = false) {
|
||||||
return $ffmpeg . $complement;
|
return $ffmpeg . $complement;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function convertVideoFileWithFFMPEG($fromFileLocation, $toFileLocation, $try = 0) {
|
||||||
|
$localFileLock = getVideosDir() . "{$relativeFilename}.lock";
|
||||||
|
if (file_exists($localFileLock)) {
|
||||||
|
_error_log('convertVideoFileWithFFMPEG: download from CDN There is a process running for ' . $localFile);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
make_path($toFileLocation);
|
||||||
|
file_put_contents($localFileLock, time());
|
||||||
|
$fromFileLocationEscaped = escapeshellarg($fromFileLocation);
|
||||||
|
$toFileLocationEscaped = escapeshellarg($toFileLocation);
|
||||||
|
|
||||||
|
$format = pathinfo($toFileLocation, PATHINFO_EXTENSION);
|
||||||
|
|
||||||
|
if ($format == 'mp3') {
|
||||||
|
switch ($try) {
|
||||||
|
case 0:
|
||||||
|
$command = get_ffmpeg() . " -i \"{$fromFileLocation}\" -c:a libmp3lame \"{$toFileLocation}\"";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
switch ($try) {
|
||||||
|
case 0:
|
||||||
|
$command = get_ffmpeg() . " -i {$fromFileLocationEscaped} -c copy {$toFileLocationEscaped}";
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
$command = get_ffmpeg() . " -allowed_extensions ALL -y -i {$fromFileLocationEscaped} -c:v copy -c:a copy -bsf:a aac_adtstoasc -strict -2 {$toFileLocationEscaped}";
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
$command = get_ffmpeg() . " -y -i {$fromFileLocationEscaped} -c:v copy -c:a copy -bsf:a aac_adtstoasc -strict -2 {$toFileLocationEscaped}";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
$progressFile = getConvertVideoFileWithFFMPEGProgressFilename($toFileLocation);
|
||||||
|
$progressFileEscaped = escapeshellarg($progressFile);
|
||||||
|
$command .= " 1> {$progressFileEscaped} 2>&1";
|
||||||
|
_error_log("convertVideoFileWithFFMPEG try[{$try}]: " . $command);
|
||||||
|
session_write_close();
|
||||||
|
_mysql_close();
|
||||||
|
exec($command, $output, $return);
|
||||||
|
_session_start();
|
||||||
|
_mysql_connect();
|
||||||
|
_error_log("convertVideoFileWithFFMPEG try[{$try}] output: " . json_encode($output));
|
||||||
|
|
||||||
|
unlink($localFileLock);
|
||||||
|
|
||||||
|
return ['return'=> $return, 'output'=>$output, 'command'=>$command, 'fromFileLocation'=>$fromFileLocation, 'toFileLocation'=>$toFileLocation, 'progressFile'=>$progressFile];
|
||||||
|
}
|
||||||
|
|
||||||
|
function m3u8ToMP4($input) {
|
||||||
|
$videosDir = getVideosDir();
|
||||||
|
$outputfilename = str_replace($videosDir, "", $input);
|
||||||
|
$parts = explode("/", $outputfilename);
|
||||||
|
$resolution = Video::getResolutionFromFilename($input);
|
||||||
|
$outputfilename = $parts[0] . "_{$resolution}_.mp4";
|
||||||
|
$outputpath = "{$videosDir}cache/downloads/{$outputfilename}";
|
||||||
|
$msg = '';
|
||||||
|
$error = true;
|
||||||
|
if (empty($outputfilename)) {
|
||||||
|
$msg = "downloadHLS: empty outputfilename {$outputfilename}";
|
||||||
|
_error_log($msg);
|
||||||
|
return ['error' => $error, 'msg' => $msg];
|
||||||
|
}
|
||||||
|
_error_log("downloadHLS: m3u8ToMP4($input)");
|
||||||
|
//var_dump(!preg_match('/^http/i', $input), filesize($input), preg_match('/.m3u8$/i', $input));
|
||||||
|
$ism3u8 = preg_match('/.m3u8$/i', $input);
|
||||||
|
if (!preg_match('/^http/i', $input) && (filesize($input) <= 10 || $ism3u8)) { // dummy file
|
||||||
|
$filepath = pathToRemoteURL($input, true, true);
|
||||||
|
if ($ism3u8 && !preg_match('/.m3u8$/i', $filepath)) {
|
||||||
|
$filepath = addLastSlash($filepath) . 'index.m3u8';
|
||||||
|
}
|
||||||
|
|
||||||
|
$token = getToken(60);
|
||||||
|
$filepath = addQueryStringParameter($filepath, 'globalToken', $token);
|
||||||
|
} else {
|
||||||
|
$filepath = escapeshellcmd($input);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_dir($filepath)) {
|
||||||
|
$filepath = addLastSlash($filepath) . 'index.m3u8';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!file_exists($outputpath)) {
|
||||||
|
var_dump($filepath, $outputpath);exit;
|
||||||
|
$return = convertVideoFileWithFFMPEG($filepath, $outputpath);
|
||||||
|
var_dump($return);exit;
|
||||||
|
if (empty($return)) {
|
||||||
|
$msg3 = "downloadHLS: ERROR 2 " . implode(PHP_EOL, $output);
|
||||||
|
$finalMsg = $msg1 . PHP_EOL . $msg2 . PHP_EOL . $msg3;
|
||||||
|
_error_log($msg3);
|
||||||
|
return ['error' => $error, 'msg' => $finalMsg];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$msg = "downloadHLS: outputpath already exists ({$outputpath})";
|
||||||
|
_error_log($msg);
|
||||||
|
}
|
||||||
|
$error = false;
|
||||||
|
return ['error' => $error, 'msg' => $msg, 'path' => $outputpath, 'filename' => $outputfilename];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function getConvertVideoFileWithFFMPEGProgressFilename($toFileLocation) {
|
||||||
|
$progressFile = $toFileLocation . '.log';
|
||||||
|
return $progressFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
function convertVideoToDownlaodProgress($toFileLocation) {
|
||||||
|
$progressFile = getConvertVideoFileWithFFMPEGProgressFilename($toFileLocation);
|
||||||
|
return parseFFMPEGProgress($progressFile);
|
||||||
|
}
|
||||||
|
|
||||||
function get_php() {
|
function get_php() {
|
||||||
global $global;
|
global $global;
|
||||||
$php = 'php ';
|
$php = 'php ';
|
||||||
|
@ -8020,20 +8081,21 @@ function getCDNOrURL($url, $type = 'CDN', $id = 0) {
|
||||||
|
|
||||||
function replaceCDNIfNeed($url, $type = 'CDN', $id = 0) {
|
function replaceCDNIfNeed($url, $type = 'CDN', $id = 0) {
|
||||||
$cdn = getCDN($type, $id);
|
$cdn = getCDN($type, $id);
|
||||||
if(!empty($_GET['debug'])){
|
if (!empty($_GET['debug'])) {
|
||||||
$obj = AVideoPlugin::getDataObject('Blackblaze_B2');
|
$obj = AVideoPlugin::getDataObject('Blackblaze_B2');
|
||||||
var_dump($url, $type, $id, $cdn, $obj->CDN_Link);exit;
|
var_dump($url, $type, $id, $cdn, $obj->CDN_Link);
|
||||||
|
exit;
|
||||||
}
|
}
|
||||||
if (empty($cdn)) {
|
if (empty($cdn)) {
|
||||||
if($type == 'CDN_B2'){
|
if ($type == 'CDN_B2') {
|
||||||
$obj = AVideoPlugin::getDataObject('Blackblaze_B2');
|
$obj = AVideoPlugin::getDataObject('Blackblaze_B2');
|
||||||
if(isValidURL($obj->CDN_Link)){
|
if (isValidURL($obj->CDN_Link)) {
|
||||||
$basename = basename($url);
|
$basename = basename($url);
|
||||||
return addLastSlash($obj->CDN_Link).$basename;
|
return addLastSlash($obj->CDN_Link) . $basename;
|
||||||
}
|
}
|
||||||
}else if($type == 'CDN_S3'){
|
} else if ($type == 'CDN_S3') {
|
||||||
$obj = AVideoPlugin::getDataObject('AWS_S3');
|
$obj = AVideoPlugin::getDataObject('AWS_S3');
|
||||||
if(isValidURL($obj->CDN_Link)){
|
if (isValidURL($obj->CDN_Link)) {
|
||||||
$cdn = $obj->CDN_Link;
|
$cdn = $obj->CDN_Link;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8041,7 +8103,7 @@ function replaceCDNIfNeed($url, $type = 'CDN', $id = 0) {
|
||||||
return $url;
|
return $url;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return str_replace(parse_url($url, PHP_URL_HOST), parse_url($cdn, PHP_URL_HOST), $url);
|
return str_replace(parse_url($url, PHP_URL_HOST), parse_url($cdn, PHP_URL_HOST), $url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9065,17 +9127,17 @@ function deleteInvalidImage($filepath) {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* add the twitterjs if the link is present
|
* add the twitterjs if the link is present
|
||||||
* @param string $text
|
* @param string $text
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function addTwitterJS($text){
|
function addTwitterJS($text) {
|
||||||
if(preg_match('/href=.+twitter.com.+ref_src=.+/', $text)){
|
if (preg_match('/href=.+twitter.com.+ref_src=.+/', $text)) {
|
||||||
if(!preg_match('/platform.twitter.com.widgets.js/', $text)){
|
if (!preg_match('/platform.twitter.com.widgets.js/', $text)) {
|
||||||
$text .= '<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>';
|
$text .= '<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $text;
|
return $text;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3349,10 +3349,11 @@ if (!class_exists('Video')) {
|
||||||
return $__getPaths[$videoFilename];
|
return $__getPaths[$videoFilename];
|
||||||
}
|
}
|
||||||
$cleanVideoFilename = self::getCleanFilenameFromFile($videoFilename);
|
$cleanVideoFilename = self::getCleanFilenameFromFile($videoFilename);
|
||||||
|
//var_dump($videoFilename, $path,$cleanVideoFilename);
|
||||||
$videosDir = self::getStoragePath();
|
$videosDir = self::getStoragePath();
|
||||||
|
|
||||||
$path = addLastSlash("{$videosDir}{$cleanVideoFilename}");
|
$path = addLastSlash("{$videosDir}{$cleanVideoFilename}");
|
||||||
|
|
||||||
$path = fixPath($path);
|
$path = fixPath($path);
|
||||||
if ($createDir) {
|
if ($createDir) {
|
||||||
make_path(addLastSlash($path));
|
make_path(addLastSlash($path));
|
||||||
|
@ -3371,11 +3372,16 @@ if (!class_exists('Video')) {
|
||||||
$videosDir = self::getStoragePath();
|
$videosDir = self::getStoragePath();
|
||||||
$videoFilename = str_replace($videosDir, '', $videoFilename);
|
$videoFilename = str_replace($videosDir, '', $videoFilename);
|
||||||
$paths = Video::getPaths($videoFilename, $createDir);
|
$paths = Video::getPaths($videoFilename, $createDir);
|
||||||
if (preg_match('/index.m3u8$/', $videoFilename)) {
|
//var_dump($paths);
|
||||||
|
if (preg_match('/index.(m3u8|mp4)$/', $videoFilename)) {
|
||||||
$paths['path'] = rtrim($paths['path'], DIRECTORY_SEPARATOR);
|
$paths['path'] = rtrim($paths['path'], DIRECTORY_SEPARATOR);
|
||||||
|
$paths['path'] = rtrim($paths['path'], '/');
|
||||||
|
$videoFilename = str_replace($paths['relative'], '', $videoFilename);
|
||||||
$videoFilename = str_replace($paths['filename'], '', $videoFilename);
|
$videoFilename = str_replace($paths['filename'], '', $videoFilename);
|
||||||
}
|
}
|
||||||
return "{$paths['path']}{$videoFilename}";
|
$newPath = addLastSlash($paths['path']). "{$videoFilename}";
|
||||||
|
//var_dump($newPath);
|
||||||
|
return $newPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getURLToFile($videoFilename, $createDir = false) {
|
public static function getURLToFile($videoFilename, $createDir = false) {
|
||||||
|
@ -3511,9 +3517,11 @@ if (!class_exists('Video')) {
|
||||||
}
|
}
|
||||||
$filename = fixPath($filename);
|
$filename = fixPath($filename);
|
||||||
$filename = str_replace(getVideosDir(), '', $filename);
|
$filename = str_replace(getVideosDir(), '', $filename);
|
||||||
if (preg_match('/videos[\/\\\]([^\/\\\]+)[\/\\\].*index.m3u8$/', $filename, $matches)) {
|
if (preg_match('/videos[\/\\\]([^\/\\\]+)[\/\\\].*index.(m3u8|mp4|mp3)$/', $filename, $matches)) {
|
||||||
|
//var_dump($filename, $matches);
|
||||||
return $matches[1];
|
return $matches[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
$search = ['_Low', '_SD', '_HD', '_thumbsV2', '_thumbsSmallV2', '_thumbsSprit', '_roku', '_portrait', '_portrait_thumbsV2', '_portrait_thumbsSmallV2', '_thumbsV2_jpg', '_spectrum', '_tvg', '.notfound'];
|
$search = ['_Low', '_SD', '_HD', '_thumbsV2', '_thumbsSmallV2', '_thumbsSprit', '_roku', '_portrait', '_portrait_thumbsV2', '_portrait_thumbsSmallV2', '_thumbsV2_jpg', '_spectrum', '_tvg', '.notfound'];
|
||||||
|
|
||||||
if (!empty($global['langs_codes_values_withdot']) && is_array($global['langs_codes_values_withdot'])) {
|
if (!empty($global['langs_codes_values_withdot']) && is_array($global['langs_codes_values_withdot'])) {
|
||||||
|
|
|
@ -1,272 +1,266 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once $global['systemRootPath'] . 'plugin/Plugin.abstract.php';
|
require_once $global['systemRootPath'] . 'plugin/Plugin.abstract.php';
|
||||||
require_once $global['systemRootPath'] . 'plugin/CDN/Storage/CDNStorage.php';
|
require_once $global['systemRootPath'] . 'plugin/CDN/Storage/CDNStorage.php';
|
||||||
|
|
||||||
class CDN extends PluginAbstract
|
class CDN extends PluginAbstract
|
||||||
{
|
{
|
||||||
public function getTags()
|
public function getTags()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
PluginTags::$RECOMMENDED,
|
PluginTags::$RECOMMENDED,
|
||||||
PluginTags::$LIVE,
|
PluginTags::$LIVE,
|
||||||
PluginTags::$PLAYER,
|
PluginTags::$PLAYER,
|
||||||
PluginTags::$STORAGE,
|
PluginTags::$STORAGE,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDescription()
|
public function getDescription()
|
||||||
{
|
{
|
||||||
global $global;
|
global $global;
|
||||||
$txt = "With our CDN we will provide you a highly-distributed platform of servers that helps minimize delays in loading web page content "
|
$txt = "With our CDN we will provide you a highly-distributed platform of servers that helps minimize delays in loading web page content "
|
||||||
. "by reducing the physical distance between the server and the user. This helps users around the world view the same high-quality "
|
. "by reducing the physical distance between the server and the user. This helps users around the world view the same high-quality "
|
||||||
. "content without slow loading times";
|
. "content without slow loading times";
|
||||||
$txt .= "<br>If you are using the CDN Storage, add this into your crontab <code>2 1 * * * php {$global['systemRootPath']}plugin/CDN/tools/moveMissingFiles.php</code>. "
|
$txt .= "<br>If you are using the CDN Storage, add this into your crontab <code>2 1 * * * php {$global['systemRootPath']}plugin/CDN/tools/moveMissingFiles.php</code>. "
|
||||||
. "This command will daily check your files and free some space into your server";
|
. "This command will daily check your files and free some space into your server";
|
||||||
$help = "";
|
$help = "";
|
||||||
return $txt . $help;
|
return $txt . $help;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getName()
|
public function getName()
|
||||||
{
|
{
|
||||||
return "CDN";
|
return "CDN";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getUUID()
|
public function getUUID()
|
||||||
{
|
{
|
||||||
return "CDN73225-3807-4167-ba81-0509dd280e06";
|
return "CDN73225-3807-4167-ba81-0509dd280e06";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPluginVersion()
|
public function getPluginVersion()
|
||||||
{
|
{
|
||||||
return "2.0";
|
return "2.0";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getEmptyDataObject()
|
public function getEmptyDataObject()
|
||||||
{
|
{
|
||||||
global $global, $config;
|
global $global, $config;
|
||||||
$obj = new stdClass();
|
$obj = new stdClass();
|
||||||
$obj->key = "";
|
$obj->key = "";
|
||||||
$obj->CDN = "";
|
$obj->CDN = "";
|
||||||
$obj->CDN_S3 = "";
|
$obj->CDN_S3 = "";
|
||||||
$obj->CDN_B2 = "";
|
$obj->CDN_B2 = "";
|
||||||
$obj->CDN_FTP = "";
|
$obj->CDN_FTP = "";
|
||||||
// this is a JSON with site_id + URL
|
// this is a JSON with site_id + URL
|
||||||
$obj->CDN_YPTStorage = ""; // array
|
$obj->CDN_YPTStorage = ""; // array
|
||||||
$obj->CDN_Live = "";
|
$obj->CDN_Live = "";
|
||||||
// this is a JSON with servers_id + URL
|
// this is a JSON with servers_id + URL
|
||||||
$obj->CDN_LiveServers = ""; // array
|
$obj->CDN_LiveServers = ""; // array
|
||||||
$obj->enable_storage = false;
|
$obj->enable_storage = false;
|
||||||
$obj->storage_autoupload_new_videos = true;
|
$obj->storage_autoupload_new_videos = true;
|
||||||
$obj->storage_users_can_choose_storage = true;
|
$obj->storage_users_can_choose_storage = true;
|
||||||
$obj->storage_username = "";
|
$obj->storage_username = "";
|
||||||
$obj->storage_password = "";
|
$obj->storage_password = "";
|
||||||
$obj->storage_hostname = "";
|
$obj->storage_hostname = "";
|
||||||
|
|
||||||
return $obj;
|
return $obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getVideosManagerListButton()
|
public function getVideosManagerListButton()
|
||||||
{
|
{
|
||||||
$btn = '';
|
$btn = '';
|
||||||
$videoHLSObj = AVideoPlugin::getDataObjectIfEnabled('VideoHLS');
|
if (self::userCanMoveVideoStorage()) {
|
||||||
if(!empty($videoHLSObj)){
|
$btn .= '<button type="button" class="btn btn-default btn-light btn-sm btn-xs btn-block " onclick="avideoModalIframeSmall(webSiteRootURL+\\\'plugin/CDN/Storage/syncVideo.php?videos_id=\'+ row.id +\'\\\');" ><i class="fas fa-project-diagram"></i> CDN Storage</button>';
|
||||||
if (!empty($videoHLSObj->saveMP4CopyOnCDNStorageToAllowDownload) || !empty($videoHLSObj->saveMP3CopyOnCDNStorageToAllowDownload)) {
|
}
|
||||||
$btn .= '<button type="button" class="btn btn-default btn-light btn-sm btn-xs btn-block " onclick="avideoModalIframeSmall(webSiteRootURL+\\\'plugin/CDN/downloadButtons.php?videos_id=\'+ row.id +\'\\\');" ><i class="fas fa-download"></i> Download</button>';
|
return $btn;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (self::userCanMoveVideoStorage()) {
|
public function getPluginMenu()
|
||||||
$btn .= '<button type="button" class="btn btn-default btn-light btn-sm btn-xs btn-block " onclick="avideoModalIframeSmall(webSiteRootURL+\\\'plugin/CDN/Storage/syncVideo.php?videos_id=\'+ row.id +\'\\\');" ><i class="fas fa-project-diagram"></i> CDN Storage</button>';
|
{
|
||||||
}
|
global $global;
|
||||||
return $btn;
|
$fileAPIName = $global['systemRootPath'] . 'plugin/CDN/pluginMenu.html';
|
||||||
}
|
$content = file_get_contents($fileAPIName);
|
||||||
|
$obj = $this->getDataObject();
|
||||||
public function getPluginMenu()
|
|
||||||
{
|
$url = "https://youphp.tube/marketplace/CDN/iframe.php?hash={hash}";
|
||||||
global $global;
|
|
||||||
$fileAPIName = $global['systemRootPath'] . 'plugin/CDN/pluginMenu.html';
|
$url = addQueryStringParameter($url, 'hash', $obj->key);
|
||||||
$content = file_get_contents($fileAPIName);
|
$url = addQueryStringParameter($url, 'webSiteRootURL', $global['webSiteRootURL']);
|
||||||
$obj = $this->getDataObject();
|
|
||||||
|
$cdnMenu = str_replace('{url}', $url, $content);
|
||||||
$url = "https://youphp.tube/marketplace/CDN/iframe.php?hash={hash}";
|
$storageMenu = '';
|
||||||
|
if (self::userCanMoveVideoStorage()) {
|
||||||
$url = addQueryStringParameter($url, 'hash', $obj->key);
|
$fileStorageMenu = $global['systemRootPath'] . 'plugin/CDN/Storage/pluginMenu.html';
|
||||||
$url = addQueryStringParameter($url, 'webSiteRootURL', $global['webSiteRootURL']);
|
$storageMenu = file_get_contents($fileStorageMenu);
|
||||||
|
}
|
||||||
$cdnMenu = str_replace('{url}', $url, $content);
|
return $cdnMenu.$storageMenu;
|
||||||
$storageMenu = '';
|
}
|
||||||
if (self::userCanMoveVideoStorage()) {
|
|
||||||
$fileStorageMenu = $global['systemRootPath'] . 'plugin/CDN/Storage/pluginMenu.html';
|
/**
|
||||||
$storageMenu = file_get_contents($fileStorageMenu);
|
*
|
||||||
}
|
* @param type $type enum(CDN, CDN_S3,CDN_B2,CDN_YPTStorage,CDN_Live,CDN_LiveServers)
|
||||||
return $cdnMenu.$storageMenu;
|
* @param type $id the ID of the URL in case the CDN is an array
|
||||||
}
|
* @return boolean
|
||||||
|
*/
|
||||||
/**
|
public static function getURL($type = 'CDN', $id = 0)
|
||||||
*
|
{
|
||||||
* @param type $type enum(CDN, CDN_S3,CDN_B2,CDN_YPTStorage,CDN_Live,CDN_LiveServers)
|
$obj = AVideoPlugin::getObjectData('CDN');
|
||||||
* @param type $id the ID of the URL in case the CDN is an array
|
|
||||||
* @return boolean
|
if (empty($obj->{$type})) {
|
||||||
*/
|
return false;
|
||||||
public static function getURL($type = 'CDN', $id = 0)
|
}
|
||||||
{
|
if (isIPPrivate(getDomain())) {
|
||||||
$obj = AVideoPlugin::getObjectData('CDN');
|
_error_log('The CDN will not work under a private network $type=' . $type);
|
||||||
|
return false;
|
||||||
if (empty($obj->{$type})) {
|
}
|
||||||
return false;
|
$url = '';
|
||||||
}
|
switch ($type) {
|
||||||
if (isIPPrivate(getDomain())) {
|
case 'CDN':
|
||||||
_error_log('The CDN will not work under a private network $type=' . $type);
|
case 'CDN_S3':
|
||||||
return false;
|
case 'CDN_B2':
|
||||||
}
|
case 'CDN_FTP':
|
||||||
$url = '';
|
case 'CDN_Live':
|
||||||
switch ($type) {
|
$url = $obj->{$type};
|
||||||
case 'CDN':
|
break;
|
||||||
case 'CDN_S3':
|
case 'CDN_LiveServers':
|
||||||
case 'CDN_B2':
|
case 'CDN_YPTStorage':
|
||||||
case 'CDN_FTP':
|
if (!empty($id)) {
|
||||||
case 'CDN_Live':
|
$json = _json_decode($obj->{$type});
|
||||||
$url = $obj->{$type};
|
//var_dump(!empty($json), is_object($json), is_array($json));//exit;
|
||||||
break;
|
if (!empty($json) && (is_object($json) || is_array($json))) {
|
||||||
case 'CDN_LiveServers':
|
foreach ($json as $value) {
|
||||||
case 'CDN_YPTStorage':
|
if ($value->id == $id) {
|
||||||
if (!empty($id)) {
|
$url = $value->URLToCDN;
|
||||||
$json = _json_decode($obj->{$type});
|
break;
|
||||||
//var_dump(!empty($json), is_object($json), is_array($json));//exit;
|
}
|
||||||
if (!empty($json) && (is_object($json) || is_array($json))) {
|
}
|
||||||
foreach ($json as $value) {
|
}
|
||||||
if ($value->id == $id) {
|
}
|
||||||
$url = $value->URLToCDN;
|
//var_dump($url);exit;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
if (!empty($url) && isValidURL($url)) {
|
||||||
}
|
return addLastSlash($url);
|
||||||
//var_dump($url);exit;
|
}
|
||||||
break;
|
|
||||||
}
|
return false;
|
||||||
|
}
|
||||||
if (!empty($url) && isValidURL($url)) {
|
|
||||||
return addLastSlash($url);
|
public static function getCDN_S3URL()
|
||||||
}
|
{
|
||||||
|
$plugin = AVideoPlugin::getDataObjectIfEnabled('AWS_S3');
|
||||||
return false;
|
$CDN_S3 = '';
|
||||||
}
|
if (!empty($plugin)) {
|
||||||
|
$region = trim($plugin->region);
|
||||||
public static function getCDN_S3URL()
|
$bucket_name = trim($plugin->bucket_name);
|
||||||
{
|
$endpoint = trim($plugin->endpoint);
|
||||||
$plugin = AVideoPlugin::getDataObjectIfEnabled('AWS_S3');
|
if (!empty($endpoint)) {
|
||||||
$CDN_S3 = '';
|
$CDN_S3 = str_replace('https://', "https://{$bucket_name}.", $endpoint);
|
||||||
if (!empty($plugin)) {
|
} elseif (!empty($plugin->region)) {
|
||||||
$region = trim($plugin->region);
|
$CDN_S3 = "https://{$bucket_name}.s3-accesspoint.{$region}.amazonaws.com";
|
||||||
$bucket_name = trim($plugin->bucket_name);
|
}
|
||||||
$endpoint = trim($plugin->endpoint);
|
if (!empty($resp->CDN_S3)) {
|
||||||
if (!empty($endpoint)) {
|
$CDN_S3 = addLastSlash($resp->CDN_S3);
|
||||||
$CDN_S3 = str_replace('https://', "https://{$bucket_name}.", $endpoint);
|
}
|
||||||
} elseif (!empty($plugin->region)) {
|
}
|
||||||
$CDN_S3 = "https://{$bucket_name}.s3-accesspoint.{$region}.amazonaws.com";
|
return $CDN_S3;
|
||||||
}
|
}
|
||||||
if (!empty($resp->CDN_S3)) {
|
|
||||||
$CDN_S3 = addLastSlash($resp->CDN_S3);
|
public static function getCDN_B2URL()
|
||||||
}
|
{
|
||||||
}
|
$CDN_B2 = '';
|
||||||
return $CDN_S3;
|
$plugin = AVideoPlugin::getDataObjectIfEnabled('Blackblaze_B2');
|
||||||
}
|
if (!empty($plugin)) {
|
||||||
|
$b2 = new Blackblaze_B2();
|
||||||
public static function getCDN_B2URL()
|
$CDN_B2 = $b2->getEndpoint();
|
||||||
{
|
if (!empty($resp->CDN_B2)) {
|
||||||
$CDN_B2 = '';
|
$CDN_B2 = addLastSlash($resp->CDN_B2);
|
||||||
$plugin = AVideoPlugin::getDataObjectIfEnabled('Blackblaze_B2');
|
}
|
||||||
if (!empty($plugin)) {
|
}
|
||||||
$b2 = new Blackblaze_B2();
|
return $CDN_B2;
|
||||||
$CDN_B2 = $b2->getEndpoint();
|
}
|
||||||
if (!empty($resp->CDN_B2)) {
|
|
||||||
$CDN_B2 = addLastSlash($resp->CDN_B2);
|
public static function getCDN_FTPURL()
|
||||||
}
|
{
|
||||||
}
|
$CDN_FTP = '';
|
||||||
return $CDN_B2;
|
$plugin = AVideoPlugin::getDataObjectIfEnabled('CDN');
|
||||||
}
|
if (!empty($plugin)) {
|
||||||
|
$CDN_FTP = addLastSlash($plugin->endpoint);
|
||||||
public static function getCDN_FTPURL()
|
}
|
||||||
{
|
return $CDN_FTP;
|
||||||
$CDN_FTP = '';
|
}
|
||||||
$plugin = AVideoPlugin::getDataObjectIfEnabled('CDN');
|
|
||||||
if (!empty($plugin)) {
|
public static function getVideoTags($videos_id)
|
||||||
$CDN_FTP = addLastSlash($plugin->endpoint);
|
{
|
||||||
}
|
global $global;
|
||||||
return $CDN_FTP;
|
if (empty($videos_id)) {
|
||||||
}
|
return [];
|
||||||
|
}
|
||||||
public static function getVideoTags($videos_id)
|
if (!Video::canEdit($videos_id)) {
|
||||||
{
|
return [];
|
||||||
global $global;
|
}
|
||||||
if (empty($videos_id)) {
|
$video = Video::getVideoLight($videos_id);
|
||||||
return [];
|
$sites_id = $video['sites_id'];
|
||||||
}
|
|
||||||
if (!Video::canEdit($videos_id)) {
|
$obj = new stdClass();
|
||||||
return [];
|
$obj->label = 'Storage';
|
||||||
}
|
$isMoving = CDNStorage::isMoving($videos_id);
|
||||||
$video = Video::getVideoLight($videos_id);
|
if ($isMoving) {
|
||||||
$sites_id = $video['sites_id'];
|
$obj->type = "danger";
|
||||||
|
$obj->text = '<i class="fas fa-sync fa-spin"></i> ' . __('Moving');
|
||||||
$obj = new stdClass();
|
} elseif (empty($sites_id)) {
|
||||||
$obj->label = 'Storage';
|
$obj->type = "success";
|
||||||
$isMoving = CDNStorage::isMoving($videos_id);
|
$obj->text = '<i class="fas fa-map-marker-alt"></i> ' . __('Local');
|
||||||
if ($isMoving) {
|
} else {
|
||||||
$obj->type = "danger";
|
$obj->type = "warning";
|
||||||
$obj->text = '<i class="fas fa-sync fa-spin"></i> ' . __('Moving');
|
$obj->text = "<i class=\"fas fa-project-diagram\"></i> " . __('Storage');
|
||||||
} elseif (empty($sites_id)) {
|
}
|
||||||
$obj->type = "success";
|
//var_dump($obj);exit;
|
||||||
$obj->text = '<i class="fas fa-map-marker-alt"></i> ' . __('Local');
|
return [$obj];
|
||||||
} else {
|
}
|
||||||
$obj->type = "warning";
|
|
||||||
$obj->text = "<i class=\"fas fa-project-diagram\"></i> " . __('Storage');
|
|
||||||
}
|
public function onEncoderNotifyIsDone($videos_id)
|
||||||
//var_dump($obj);exit;
|
{
|
||||||
return [$obj];
|
return $this->processNewVideo($videos_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function onUploadIsDone($videos_id)
|
||||||
public function onEncoderNotifyIsDone($videos_id)
|
{
|
||||||
{
|
return $this->processNewVideo($videos_id);
|
||||||
return $this->processNewVideo($videos_id);
|
}
|
||||||
}
|
|
||||||
|
private function processNewVideo($videos_id)
|
||||||
public function onUploadIsDone($videos_id)
|
{
|
||||||
{
|
$obj = AVideoPlugin::getDataObjectIfEnabled('CDN');
|
||||||
return $this->processNewVideo($videos_id);
|
if ($obj->enable_storage) {
|
||||||
}
|
if ($obj->storage_autoupload_new_videos) {
|
||||||
|
CDNStorage::moveLocalToRemote($videos_id, false);
|
||||||
private function processNewVideo($videos_id)
|
}
|
||||||
{
|
}
|
||||||
$obj = AVideoPlugin::getDataObjectIfEnabled('CDN');
|
}
|
||||||
if ($obj->enable_storage) {
|
|
||||||
if ($obj->storage_autoupload_new_videos) {
|
public static function userCanMoveVideoStorage()
|
||||||
CDNStorage::moveLocalToRemote($videos_id, false);
|
{
|
||||||
}
|
$obj = AVideoPlugin::getDataObjectIfEnabled('CDN');
|
||||||
}
|
if (empty($obj->enable_storage)) {
|
||||||
}
|
return false;
|
||||||
|
}
|
||||||
public static function userCanMoveVideoStorage()
|
if (User::isAdmin()) {
|
||||||
{
|
return true;
|
||||||
$obj = AVideoPlugin::getDataObjectIfEnabled('CDN');
|
}
|
||||||
if (empty($obj->enable_storage)) {
|
if (!empty($obj->storage_users_can_choose_storage) && User::canUpload()) {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
if (User::isAdmin()) {
|
return false;
|
||||||
return true;
|
}
|
||||||
}
|
|
||||||
if (!empty($obj->storage_users_can_choose_storage) && User::canUpload()) {
|
public function getFooterCode()
|
||||||
return true;
|
{
|
||||||
}
|
global $global;
|
||||||
return false;
|
if (self::userCanMoveVideoStorage()) {
|
||||||
}
|
include $global['systemRootPath'] . 'plugin/CDN/Storage/footer.php';
|
||||||
|
}
|
||||||
public function getFooterCode()
|
}
|
||||||
{
|
}
|
||||||
global $global;
|
|
||||||
if (self::userCanMoveVideoStorage()) {
|
|
||||||
include $global['systemRootPath'] . 'plugin/CDN/Storage/footer.php';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -1075,12 +1075,6 @@ class CDNStorage {
|
||||||
$parts2 = explode('?', $parts1[1]);
|
$parts2 = explode('?', $parts1[1]);
|
||||||
$relativeFilename = $parts2[0];
|
$relativeFilename = $parts2[0];
|
||||||
$localFile = getVideosDir() . "{$relativeFilename}";
|
$localFile = getVideosDir() . "{$relativeFilename}";
|
||||||
$localFileLock = getVideosDir() . "{$relativeFilename}.lock";
|
|
||||||
if(file_exists($localFileLock)){
|
|
||||||
_error_log('convertCDNHLSVideoToDownlaod: download from CDN There is a process running for ' . $localFile);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
file_put_contents($localFileLock, time());
|
|
||||||
//var_dump($localFile);exit;
|
//var_dump($localFile);exit;
|
||||||
$returnURL = false;
|
$returnURL = false;
|
||||||
if (file_exists($localFile)) {
|
if (file_exists($localFile)) {
|
||||||
|
@ -1105,20 +1099,7 @@ class CDNStorage {
|
||||||
} else {
|
} else {
|
||||||
//var_dump($localFile);exit;
|
//var_dump($localFile);exit;
|
||||||
if (!file_exists($localFile)) {
|
if (!file_exists($localFile)) {
|
||||||
if ($format == 'mp3') {
|
$progressFile = convertVideoFileWithFFMPEG($m3u8File, $localFile);
|
||||||
$command = get_ffmpeg() . " -i \"{$m3u8File}\" -c:a libmp3lame \"{$localFile}\"";
|
|
||||||
} else {
|
|
||||||
$command = get_ffmpeg() . " -i \"{$m3u8File}\" -c copy \"{$localFile}\"";
|
|
||||||
}
|
|
||||||
$progressFile = $localFile.'.log';
|
|
||||||
$command .= " 1> \"{$progressFile}\" 2>&1";
|
|
||||||
_error_log('convertCDNHLSVideoToDownlaod: download from CDN ' . $command);
|
|
||||||
session_write_close();
|
|
||||||
_mysql_close();
|
|
||||||
exec($command, $output);
|
|
||||||
_session_start();
|
|
||||||
_mysql_connect();
|
|
||||||
_error_log('convertCDNHLSVideoToDownlaod: download from CDN output: ' . json_encode($output));
|
|
||||||
}
|
}
|
||||||
if (!file_exists($localFile)) {
|
if (!file_exists($localFile)) {
|
||||||
_error_log('convertCDNHLSVideoToDownlaod: download from CDN file not created ' . $localFile);
|
_error_log('convertCDNHLSVideoToDownlaod: download from CDN file not created ' . $localFile);
|
||||||
|
@ -1135,7 +1116,6 @@ class CDNStorage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unlink($localFileLock);
|
|
||||||
return $returnURL;
|
return $returnURL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,16 +15,8 @@ $videoHLSObj = AVideoPlugin::getDataObjectIfEnabled('VideoHLS');
|
||||||
if (empty($videoHLSObj)) {
|
if (empty($videoHLSObj)) {
|
||||||
forbiddenPage('VideoHLS plugin is required for that');
|
forbiddenPage('VideoHLS plugin is required for that');
|
||||||
}
|
}
|
||||||
$downloadOptions = array();
|
$downloadOptions = VideoHLS::getMP3ANDMP4DownloadLinks($videos_id);
|
||||||
$cdnObj = AVideoPlugin::getDataObjectIfEnabled('CDN');
|
|
||||||
if(!empty($cdnObj) && $cdnObj->enable_storage){
|
|
||||||
if (!empty($videoHLSObj->saveMP4CopyOnCDNStorageToAllowDownload)) {
|
|
||||||
$downloadOptions[] = VideoHLS::getCDNDownloadLink($videos_id, 'mp4');
|
|
||||||
}
|
|
||||||
if (!empty($videoHLSObj->saveMP3CopyOnCDNStorageToAllowDownload)) {
|
|
||||||
$downloadOptions[] = VideoHLS::getCDNDownloadLink($videos_id, 'mp3');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (empty($downloadOptions)) {
|
if (empty($downloadOptions)) {
|
||||||
forbiddenPage('All download options on VideoHLS plugin are disabled');
|
forbiddenPage('All download options on VideoHLS plugin are disabled');
|
||||||
}
|
}
|
||||||
|
|
|
@ -1260,11 +1260,7 @@ function avideoAlert(title, msg, type) {
|
||||||
if (typeof msg !== 'string') {
|
if (typeof msg !== 'string') {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (msg !== msg.replace(/<\/?[^>]+(>|$)/g, "")) {//it has HTML
|
avideoAlertHTMLText(title, msg, type);
|
||||||
avideoAlertHTMLText(title, msg, type);
|
|
||||||
} else {
|
|
||||||
swal(title, msg, type);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function avideoAlertOnce(title, msg, type, uid) {
|
function avideoAlertOnce(title, msg, type, uid) {
|
||||||
|
@ -1370,6 +1366,7 @@ function avideoAlertAJAX(url) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function avideoAlertHTMLText(title, msg, type) {
|
function avideoAlertHTMLText(title, msg, type) {
|
||||||
|
var isErrorOrWarning = (type=='error' || type=='warning');
|
||||||
var span = document.createElement("span");
|
var span = document.createElement("span");
|
||||||
span.innerHTML = msg;
|
span.innerHTML = msg;
|
||||||
swal({
|
swal({
|
||||||
|
@ -1377,7 +1374,8 @@ function avideoAlertHTMLText(title, msg, type) {
|
||||||
content: span,
|
content: span,
|
||||||
icon: type,
|
icon: type,
|
||||||
closeModal: true,
|
closeModal: true,
|
||||||
buttons: type ? true : false,
|
closeOnClickOutside: !isErrorOrWarning,
|
||||||
|
buttons: isErrorOrWarning ? null : (empty(type)?false:true),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2208,7 +2206,8 @@ function goToURLOrAlertError(jsonURL, data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function downloadURL(url, filename) {
|
function downloadURL(url, filename) {
|
||||||
avideoToastInfo('Download start');
|
filename = clean_name(filename)+'.'+clean_name(url.split(/[#?]/)[0].split('.').pop().trim());
|
||||||
|
console.log('downloadURL start ', url, filename);
|
||||||
var loaded = 0;
|
var loaded = 0;
|
||||||
var contentLength = 0;
|
var contentLength = 0;
|
||||||
fetch(url)
|
fetch(url)
|
||||||
|
@ -2251,28 +2250,37 @@ function downloadURL(url, filename) {
|
||||||
})
|
})
|
||||||
.then(response => response.blob())
|
.then(response => response.blob())
|
||||||
.then(blob => {
|
.then(blob => {
|
||||||
const url = window.URL.createObjectURL(blob);
|
const urlFromBlob = window.URL.createObjectURL(blob);
|
||||||
|
console.log('downloadURL', url, filename, blob);
|
||||||
const a = document.createElement('a');
|
const a = document.createElement('a');
|
||||||
a.style.display = 'none';
|
a.style.display = 'none';
|
||||||
a.href = url;
|
a.href = urlFromBlob;
|
||||||
// the filename you want
|
// the filename you want
|
||||||
a.download = filename;
|
a.download = filename;
|
||||||
document.body.appendChild(a);
|
document.body.appendChild(a);
|
||||||
a.click();
|
a.click();
|
||||||
window.URL.revokeObjectURL(url);
|
window.URL.revokeObjectURL(url);
|
||||||
modal.hidePleaseWait();
|
modal.hidePleaseWait();
|
||||||
avideoToastSuccess('Download complete');
|
avideoToastSuccess('Download complete '+filename);
|
||||||
})
|
})
|
||||||
.catch(function (err) {
|
.catch(function (err) {
|
||||||
avideoAlertError('Error on download ');
|
//avideoAlertError('Error on download ');
|
||||||
//console.log(err)
|
console.log(err);
|
||||||
|
addQueryStringParameter(url, 'download', 1);
|
||||||
|
addQueryStringParameter(url, 'title', filename);
|
||||||
|
document.location = url;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
var downloadURLOrAlertErrorInterval;
|
var downloadURLOrAlertErrorInterval;
|
||||||
function downloadURLOrAlertError(jsonURL, data, filename, FFMpegProgress) {
|
function downloadURLOrAlertError(jsonURL, data, filename, FFMpegProgress) {
|
||||||
|
if(empty(jsonURL)){
|
||||||
|
console.log('downloadURLOrAlertError error empty jsonURL', jsonURL, data, filename, FFMpegProgress);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
modal.showPleaseWait();
|
modal.showPleaseWait();
|
||||||
avideoToastInfo('Converting');
|
avideoToastInfo('Converting');
|
||||||
|
console.log('downloadURLOrAlertError 1', jsonURL,FFMpegProgress);
|
||||||
checkFFMPEGProgress(FFMpegProgress);
|
checkFFMPEGProgress(FFMpegProgress);
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: jsonURL,
|
url: jsonURL,
|
||||||
|
@ -2678,7 +2686,7 @@ $(document).ready(function () {
|
||||||
|
|
||||||
setInterval(function () {
|
setInterval(function () {
|
||||||
setToolTips();
|
setToolTips();
|
||||||
}, 1000);
|
}, 5000);
|
||||||
/*
|
/*
|
||||||
$(".thumbsImage").on("mouseenter", function () {
|
$(".thumbsImage").on("mouseenter", function () {
|
||||||
gifId = $(this).find(".thumbsGIF").attr('id');
|
gifId = $(this).find(".thumbsGIF").attr('id');
|
||||||
|
|
|
@ -180,14 +180,8 @@ $description = getSEODescription(emptyHTML($video['description']) ? $video['titl
|
||||||
|
|
||||||
$videoHLSObj = AVideoPlugin::getDataObjectIfEnabled('VideoHLS');
|
$videoHLSObj = AVideoPlugin::getDataObjectIfEnabled('VideoHLS');
|
||||||
if (!empty($videoHLSObj)) {
|
if (!empty($videoHLSObj)) {
|
||||||
if ($cdnStorageEnabled) {
|
$downloadOptions = VideoHLS::getMP3ANDMP4DownloadLinks($videos_id);
|
||||||
if (!empty($videoHLSObj->saveMP4CopyOnCDNStorageToAllowDownload)) {
|
$filesToDownload = array_merge($filesToDownload, $downloadOptions);
|
||||||
$filesToDownload[] = VideoHLS::getCDNDownloadLink($video['id'], 'mp4');
|
|
||||||
}
|
|
||||||
if (!empty($videoHLSObj->saveMP3CopyOnCDNStorageToAllowDownload)) {
|
|
||||||
$filesToDownload[] = VideoHLS::getCDNDownloadLink($video['id'], 'mp3');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,104 +1,120 @@
|
||||||
<?php
|
<?php
|
||||||
global $global, $config;
|
global $global, $config;
|
||||||
if (!isset($global['systemRootPath'])) {
|
if (!isset($global['systemRootPath'])) {
|
||||||
require_once '../videos/configuration.php';
|
require_once '../videos/configuration.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
session_write_close();
|
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($_GET['file'])) {
|
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');
|
||||||
}
|
}
|
||||||
|
|
||||||
$path_parts = pathinfo($_GET['file']);
|
if($_GET['file']=='index.mp4'){
|
||||||
$file = $path_parts['basename'];
|
$url = parse_url($_SERVER["REQUEST_URI"]);
|
||||||
//var_dump($_GET['file'], $path_parts, $file);exit;
|
$paths = Video::getPaths($url["path"]);
|
||||||
|
$path = "{$paths['path']}index.mp4";
|
||||||
if ($file == "test.mp4") {
|
$file = "{$paths["relative"]}index.mp4";
|
||||||
$path = "{$global['systemRootPath']}view/xsendfile.html";
|
$path_parts = pathinfo($file);
|
||||||
header('Content-Transfer-Encoding: binary');
|
//var_dump(__LINE__, $file, $path, $paths);
|
||||||
header('Connection: Keep-Alive');
|
}else{
|
||||||
header('Expires: 0');
|
$path_parts = pathinfo($_GET['file']);
|
||||||
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
|
$file = $path_parts['basename'];
|
||||||
header('Pragma: public');
|
}
|
||||||
header('Content-Type: text/html');
|
//header('Content-Type: application/json');var_dump($path, $file, $paths, $url, Video::getPaths($redirectURI));exit;
|
||||||
header('Content-Length: ' . filesize($path));
|
|
||||||
header("X-Sendfile: {$path}");
|
if ($file == "test.mp4") {
|
||||||
exit;
|
$path = "{$global['systemRootPath']}view/xsendfile.html";
|
||||||
}
|
header('Content-Transfer-Encoding: binary');
|
||||||
|
header('Connection: Keep-Alive');
|
||||||
if ($file == "X-Sendfile.mp4") {
|
header('Expires: 0');
|
||||||
$path = "{$global['systemRootPath']}plugin/SecureVideosDirectory/test.json";
|
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
|
||||||
header('Content-Transfer-Encoding: binary');
|
header('Pragma: public');
|
||||||
header('Connection: Keep-Alive');
|
header('Content-Type: text/html');
|
||||||
header('Expires: 0');
|
header('Content-Length: ' . filesize($path));
|
||||||
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
|
header("X-Sendfile: {$path}");
|
||||||
header('Pragma: public');
|
exit;
|
||||||
header('Content-Type: application/json');
|
}
|
||||||
header('Content-Length: ' . filesize($path));
|
|
||||||
header("X-Sendfile: {$path}");
|
if ($file == "X-Sendfile.mp4") {
|
||||||
exit;
|
$path = "{$global['systemRootPath']}plugin/SecureVideosDirectory/test.json";
|
||||||
}
|
header('Content-Transfer-Encoding: binary');
|
||||||
|
header('Connection: Keep-Alive');
|
||||||
if ($file == "configuration.php") {
|
header('Expires: 0');
|
||||||
_error_log("XSENDFILE Can't read this configuration ");
|
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
|
||||||
forbiddenPage("Can't read this");
|
header('Pragma: public');
|
||||||
}
|
header('Content-Type: application/json');
|
||||||
if(!empty($_REQUEST['cacheDownload'])){
|
header('Content-Length: ' . filesize($path));
|
||||||
$file = preg_replace('/[^0-9a-z_\.]/i', '', $_GET['file']);
|
header("X-Sendfile: {$path}");
|
||||||
$relativePath = "cache/download/";
|
exit;
|
||||||
$path = getVideosDir().$relativePath.$file;
|
}
|
||||||
$_GET['download'] = 1;
|
|
||||||
_error_log("cacheDownload: $path");
|
if ($file == "configuration.php") {
|
||||||
}else{
|
_error_log("XSENDFILE Can't read this configuration ");
|
||||||
$path = Video::getPathToFile($file);
|
forbiddenPage("Can't read this");
|
||||||
}
|
}
|
||||||
if (file_exists($path)) {
|
if(!empty($_REQUEST['cacheDownload'])){
|
||||||
if (!empty($_GET['download'])) {
|
$file = preg_replace('/[^0-9a-z_\.]/i', '', $_GET['file']);
|
||||||
if (empty($_REQUEST['cacheDownload']) && !CustomizeUser::canDownloadVideos()) {
|
$relativePath = "cache/download/";
|
||||||
_error_log("downloadHLS: CustomizeUser::canDownloadVideos said NO");
|
$path = getVideosDir().$relativePath.$file;
|
||||||
forbiddenPage("Can't download this");
|
$_GET['download'] = 1;
|
||||||
}
|
_error_log("cacheDownload: $path");
|
||||||
if (!empty($_GET['title'])) {
|
}else{
|
||||||
$quoted = sprintf('"%s"', addcslashes(basename($_GET['title']), '"\\'));
|
$path = Video::getPathToFile($file);
|
||||||
} else {
|
}
|
||||||
$quoted = sprintf('"%s"', addcslashes(basename($_GET['file']), '"\\'));
|
//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-Description: File Transfer');
|
if (file_exists($path)) {
|
||||||
header('Content-Disposition: attachment; filename=' . $quoted);
|
$filesize = filesize($path);
|
||||||
header('Content-Transfer-Encoding: binary');
|
if (!empty($_GET['download'])) {
|
||||||
header('Connection: Keep-Alive');
|
if (empty($_REQUEST['cacheDownload']) && !CustomizeUser::canDownloadVideos()) {
|
||||||
header('Expires: 0');
|
_error_log("downloadHLS: CustomizeUser::canDownloadVideos said NO");
|
||||||
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
|
forbiddenPage("Can't download this");
|
||||||
header('Pragma: public');
|
}
|
||||||
}
|
if (!empty($_GET['title'])) {
|
||||||
if (preg_match("/(mp4|webm|m3u8|mp3|ogg)/i", $path_parts['extension'])) {
|
$quoted = safeString($_GET['title'], true).".{$path_parts['extension']}";
|
||||||
if (isAVideoEncoderOnSameDomain() || empty($_GET['ignoreXsendfilePreVideoPlay'])) {
|
} else {
|
||||||
AVideoPlugin::xsendfilePreVideoPlay();
|
$quoted = safeString(basename($_GET['file']), true).".{$path_parts['extension']}";
|
||||||
}
|
}
|
||||||
if (empty($advancedCustom->doNotUseXsendFile)) {
|
//header('Content-Type: application/json');var_dump($quoted);exit;
|
||||||
//_error_log("X-Sendfile: {$path}");
|
header('Content-Description: File Transfer');
|
||||||
header("X-Sendfile: {$path}");
|
header('Content-Disposition: attachment; filename=' . $quoted);
|
||||||
} else {
|
header('Content-Transfer-Encoding: binary');
|
||||||
_error_log("Careful, we recommend you to use the X-Sendfile and it is disabled on AdvancedCustom plugin -> doNotUseXsendFile. You may have an error 'Allowed Memory Size Exhausted' if your video file is too big", AVideoLog::$WARNING);
|
header('Connection: Keep-Alive');
|
||||||
}
|
header('Expires: 0');
|
||||||
} else {
|
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
|
||||||
$advancedCustom->doNotUseXsendFile = true;
|
header('Pragma: public');
|
||||||
}
|
}
|
||||||
header("Content-type: " . mime_content_type($path));
|
if (preg_match("/(mp4|webm|m3u8|mp3|ogg)/i", $path_parts['extension'])) {
|
||||||
header('Content-Length: ' . filesize($path));
|
if (isAVideoEncoderOnSameDomain() || empty($_GET['ignoreXsendfilePreVideoPlay'])) {
|
||||||
if (!empty($advancedCustom->doNotUseXsendFile)) {
|
AVideoPlugin::xsendfilePreVideoPlay();
|
||||||
ini_set('memory_limit', filesize($path) * 1.5);
|
}
|
||||||
_error_log("Your XSEND File is not enabled, it may slow down your site, file = $path", AVideoLog::$WARNING);
|
if (empty($advancedCustom->doNotUseXsendFile)) {
|
||||||
//echo url_get_contents($path);
|
//_error_log("X-Sendfile: {$path}");
|
||||||
// stream the file
|
header("X-Sendfile: {$path}");
|
||||||
$fp = fopen($path, 'rb');
|
} else {
|
||||||
fpassthru($fp);
|
_error_log("Careful, we recommend you to use the X-Sendfile and it is disabled on AdvancedCustom plugin -> doNotUseXsendFile. You may have an error 'Allowed Memory Size Exhausted' if your video file is too big", AVideoLog::$WARNING);
|
||||||
}
|
}
|
||||||
die();
|
} else {
|
||||||
} else {
|
$advancedCustom->doNotUseXsendFile = true;
|
||||||
_error_log("XSENDFILE ERROR: Not exists {$path}");
|
}
|
||||||
}
|
header("Content-type: " . mime_content_type($path));
|
||||||
|
header('Content-Length: ' . $filesize);
|
||||||
|
//header("Content-Range: 0-".($filesize-1)."/".$filesize);
|
||||||
|
_error_log("downloadHLS: filesize={$filesize} {$path}");
|
||||||
|
//var_dump($advancedCustom->doNotUseXsendFile);exit;
|
||||||
|
if (!empty($advancedCustom->doNotUseXsendFile)) {
|
||||||
|
ini_set('memory_limit', filesize($path) * 1.5);
|
||||||
|
_error_log("Your XSEND File is not enabled, it may slow down your site, file = $path", AVideoLog::$WARNING);
|
||||||
|
//echo url_get_contents($path);
|
||||||
|
// stream the file
|
||||||
|
$fp = fopen($path, 'rb');
|
||||||
|
fpassthru($fp);
|
||||||
|
}
|
||||||
|
die();
|
||||||
|
} else {
|
||||||
|
_error_log("XSENDFILE ERROR: Not exists {$path}");
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue