1
0
Fork 0
mirror of https://github.com/DanielnetoDotCom/YouPHPTube synced 2025-10-03 01:39:24 +02:00
DanielnetoDotCom 2021-05-06 11:03:42 -03:00
parent 3c9114119f
commit 757504314e
29 changed files with 377 additions and 163 deletions

View file

@ -309,7 +309,7 @@ Options All -Indexes
RewriteRule ^vast.xml/?([0-9]+)?$ plugin/AD_Server/VAST.php?campaign_has_videos_id=$1 [NC,L] RewriteRule ^vast.xml/?([0-9]+)?$ plugin/AD_Server/VAST.php?campaign_has_videos_id=$1 [NC,L]
<IfModule mod_xsendfile.c> <IfModule mod_xsendfile.c>
RewriteRule ^videos/([^!#$&'()*+,\/:;=?@[\]]+(\.(mp4|webm|m3u8|mp3|ogg)))$ view/xsendfile.php?file=$1 [QSA] RewriteRule ^videos/([_A-Za-z0-9.-]+/)?([^!#$&'()*+,\/:;=?@[\]]+(\.(mp4|webm|m3u8|mp3|ogg)))$ view/xsendfile.php?file=$2 [QSA]
</IfModule> </IfModule>
# if image do not exists # if image do not exists

View file

@ -4,7 +4,7 @@ if (file_exists("../videos/configuration.php")) {
exit; exit;
} }
$installationVersion = "10.8"; $installationVersion = "11.0";
error_log("Installation: ".__LINE__." ". json_encode($_POST)); error_log("Installation: ".__LINE__." ". json_encode($_POST));
header('Content-Type: application/json'); header('Content-Type: application/json');

View file

@ -7,69 +7,48 @@ if (!isCommandLineInterface()) {
return die('Command Line only'); return die('Command Line only');
} }
$fileExtensions = array('jpg', 'gif', 'mp4', 'webm'); $lockFilename = '.move_v1.lock';
$path = getVideosDir();
$files = array_diff(scandir($path), array('.', '..'));
$files = array();
//foreach (glob("../videos/*.{" . implode(",", $fileExtensions) . "}", GLOB_BRACE) as $filename) {
foreach (glob("../videos/*", GLOB_BRACE) as $filename) {
$base = basename($filename);
if (is_dir($filename)) {
if (strpos($base, "_YPTuniqid_") !== false) {
$files[$base] = array($base, $filename);
}
} else {
$baseName = explode("_portrait", $base);
if (!empty($baseName[1])) {
$files[$base] = array($baseName[0], $filename);
} else {
$baseName = explode("_thumbs", $base);
if (!empty($baseName[1])) {
$files[$base] = array($baseName[0], $filename);
} else {
$types = array('_HD', '_Low', '_SD');
$notFound = true;
foreach ($types as $value) {
$baseName = explode($value, $base);
if (!empty($baseName[1])) {
$files[$base] = array($baseName[0], $filename);
$notFound = false;
}
}
if ($notFound) {
foreach ($fileExtensions as $value) {
if (strpos($base, ".$value") === false) {
continue;
}
$baseName = str_replace("." . $value, "", $base);
if (!empty($baseName[1])) {
if (!in_array($baseName, $files)) {
$files[$base] = array($baseName, $filename);
}
}
}
}
}
}
}
}
echo "*** Total filenames " . count($files) . "\n"; echo "*** Total filenames " . count($files) . "\n";
foreach ($files as $key => $value) { foreach ($files as $key => $value) {
$video = Video::getVideoFromFileName($value[0], true); $dir = "{$path}{$value}";
if (!empty($video)) { if(!is_dir($dir)){
unset($files[$key]);
continue;
}
$file = "{$dir}".DIRECTORY_SEPARATOR."{$lockFilename}";
if(file_exists($file)){
$filename = Video::getCleanFilenameFromFile($dir);
$video = Video::getVideoFromFileName($filename, true);
if (!empty($video)) {
//echo "+++ Video FOUND for filename {$filename} ".PHP_EOL;
unset($files[$key]);
}else{
$files[$key] = array($value, $dir);
//echo "*** Video NOT found for filename {$filename} ".PHP_EOL;
}
}else{
//echo "*** Lock file does not exists {$file} ".PHP_EOL;
unset($files[$key]); unset($files[$key]);
} }
} }
echo "*** Total filenames " . count($files) . " Will be deleted\n";
$total = count($files) ;
echo "*** Total filenames " . $total . " Will be deleted\n";
if(empty($total)){
exit;
}
$totalSize = 0; $totalSize = 0;
foreach ($files as $key => $value) { foreach ($files as $key => $value) {
$size = filesize($value[1]); $size = getDirSize($value[1]);
$totalSize += $size; $totalSize += $size;
echo "{$value[0]} => $value[1] " . (humanFileSize($size)) . " \n"; echo "{$value[0]} => $value[1] " . (humanFileSize($size)) . " \n";
} }
echo "*** Confirm Delete Them (" . humanFileSize($totalSize) . ")? y/n: "; echo "*** Confirm Delete Them (" . humanFileSize($totalSize) . ")? y/n: ";
ob_flush(); ob_flush();
$confirm = trim(readline("")); $confirm = trim(readline(""));
if (!empty($confirm) && strtolower($confirm) === 'y') { if (!empty($confirm) && strtolower($confirm) === 'y') {
@ -88,4 +67,4 @@ if (!empty($confirm) && strtolower($confirm) === 'y') {
echo "$value[1] Could Not be Deleted \n"; echo "$value[1] Could Not be Deleted \n";
} }
} }
} }

View file

@ -21,7 +21,7 @@ foreach ($videos as $value) {
echo "\nStart: " . $value['title']; echo "\nStart: " . $value['title'];
ob_flush(); ob_flush();
$videoFileName = $value['filename']; $videoFileName = $value['filename'];
$destination = Video::getStoragePath()."{$videoFileName}.webp"; $destination = Video::getPathToFile("{$videoFileName}.webp");
if (!file_exists($destination)) { if (!file_exists($destination)) {
echo "\nGet webp"; echo "\nGet webp";
ob_flush(); ob_flush();

View file

@ -0,0 +1,40 @@
<?php
//streamer config
require_once '../videos/configuration.php';
if (!isCommandLineInterface()) {
return die('Command Line only');
}
$path = getVideosDir();
$total = Video::getTotalVideos("", false, true, true, false, false);
$videos = Video::getAllVideosLight("", false, true, false);
$count = 0;
foreach ($videos as $value) {
$count++;
$basename = "{$path}{$value['filename']}";
$glob = glob("{$basename}*");
$dirname = $basename.DIRECTORY_SEPARATOR;
foreach ($glob as $file) {
if (is_dir($file)) {
//echo $file.PHP_EOL;
$move = Video::updateDirectoryFilename($file);
echo "-->".PHP_EOL." {$count}/{$total} move directory {$move['oldDir']} to {$move['newDir']} ".PHP_EOL."<--" . PHP_EOL . PHP_EOL;
continue;
}
$filename = basename($file);
$newname = Video::getPathToFile($filename);
rename($file, $newname);
echo "{$count}/{$total} move $filename to $newname" . PHP_EOL;
}
ob_flush();
}
echo PHP_EOL." Deleting cache ... ";
ObjectYPT::deleteALLCache();
echo PHP_EOL." Done! ";
die();

View file

@ -8,8 +8,6 @@ global $global, $config;
if (!isset($global['systemRootPath'])) { if (!isset($global['systemRootPath'])) {
require_once '../videos/configuration.php'; require_once '../videos/configuration.php';
} }
require_once $global['systemRootPath'] . 'objects/user.php';
require_once $global['systemRootPath'] . 'objects/video.php';
if (empty($_POST)) { if (empty($_POST)) {
$obj->msg = __("Your POST data is empty, maybe your video file is too big for the host"); $obj->msg = __("Your POST data is empty, maybe your video file is too big for the host");
@ -21,9 +19,10 @@ if (empty($_POST['format']) || !in_array($_POST['format'], $global['allowedExten
_error_log("aVideoEncoder.json: Extension not allowed File " . __FILE__ . ": " . json_encode($_POST)); _error_log("aVideoEncoder.json: Extension not allowed File " . __FILE__ . ": " . json_encode($_POST));
die(); die();
} }
// pass admin user and pass if(!isset($_REQUEST['encodedPass'])){
$user = new User("", @$_POST['user'], @$_POST['password']); $_REQUEST['encodedPass'] = 1;
$user->login(false, true); }
useVideoHashOrLogin();
if (!User::canUpload()) { if (!User::canUpload()) {
_error_log("aVideoEncoder.json: Permission denied to receive a file: " . json_encode($_POST)); _error_log("aVideoEncoder.json: Permission denied to receive a file: " . json_encode($_POST));
$obj->msg = __("Permission denied to receive a file: ") . json_encode($_POST); $obj->msg = __("Permission denied to receive a file: ") . json_encode($_POST);
@ -84,12 +83,13 @@ if (preg_match("/(mp3|wav|ogg)$/i", $_POST['format'])) {
$videoFileName = $video->getFilename(); $videoFileName = $video->getFilename();
if (empty($videoFileName)) { if (empty($videoFileName)) {
$mainName = preg_replace("/[^A-Za-z0-9]/", "", cleanString($title)); $paths = Video::getNewVideoFilename();
$videoFileName = uniqid($mainName . "_YPTuniqid_", true); $filename = $paths['filename'];
$video->setFilename($videoFileName); $videoFileName = $video->setFilename($videoFileName);
} }
$destination_local = Video::getStoragePath()."{$videoFileName}"; $paths = Video::getPaths($videoFilename);
$destination_local = "{$paths['path']}{$videoFileName}";
if (!empty($_FILES)) { if (!empty($_FILES)) {
_error_log("aVideoEncoder.json: Files " . json_encode($_FILES)); _error_log("aVideoEncoder.json: Files " . json_encode($_FILES));
@ -176,6 +176,10 @@ if (!empty($_POST['usergroups_id'])) {
$obj->error = false; $obj->error = false;
$obj->video_id = $video_id; $obj->video_id = $video_id;
$v = new Video('', '', $video_id);
$obj->video_id_hash = $v->getVideoIdHash();
_error_log("aVideoEncoder.json: Files Received for video {$video_id}: " . $video->getTitle()); _error_log("aVideoEncoder.json: Files Received for video {$video_id}: " . $video->getTitle());
die(json_encode($obj)); die(json_encode($obj));

View file

@ -20,9 +20,7 @@ if (empty($_POST)) {
die(json_encode($obj)); die(json_encode($obj));
} }
// pass admin user and pass useVideoHashOrLogin();
$user = new User("", @$_POST['user'], @$_POST['password']);
$user->login(false, true);
if (!User::canUpload()) { if (!User::canUpload()) {
$obj->msg = __("Permission denied to Notify Done: ") . print_r($_POST, true); $obj->msg = __("Permission denied to Notify Done: ") . print_r($_POST, true);
_error_log($obj->msg); _error_log($obj->msg);

View file

@ -9,8 +9,6 @@ global $global, $config;
if(!isset($global['systemRootPath'])){ if(!isset($global['systemRootPath'])){
require_once '../videos/configuration.php'; require_once '../videos/configuration.php';
} }
require_once $global['systemRootPath'] . 'objects/user.php';
require_once $global['systemRootPath'] . 'objects/video.php';
if (empty($_POST)) { if (empty($_POST)) {
$obj->msg = __("Your POST data is empty, maybe your video file is too big for the host"); $obj->msg = __("Your POST data is empty, maybe your video file is too big for the host");
@ -18,9 +16,7 @@ if (empty($_POST)) {
die(json_encode($obj)); die(json_encode($obj));
} }
// pass admin user and pass useVideoHashOrLogin();
$user = new User("", @$_POST['user'], @$_POST['password']);
$user->login(false, true);
if (!User::canUpload()) { if (!User::canUpload()) {
$obj->msg = __("Permission denied to receive a file: " . json_encode($_POST)); $obj->msg = __("Permission denied to receive a file: " . json_encode($_POST));
_error_log("ReceiveImage: ".$obj->msg); _error_log("ReceiveImage: ".$obj->msg);
@ -32,17 +28,16 @@ if(!Video::canEdit($_POST['videos_id'])){
_error_log("ReceiveImage: ".$obj->msg); _error_log("ReceiveImage: ".$obj->msg);
die(json_encode($obj)); die(json_encode($obj));
} }
_error_log("ReceiveImage: "."Start receiving image ". json_encode($_FILES)."". json_encode($_POST)); _error_log("ReceiveImage: Start receiving image ". json_encode($_FILES)."". json_encode($_POST));
// check if there is en video id if yes update if is not create a new one // check if there is en video id if yes update if is not create a new one
$video = new Video("", "", $_POST['videos_id']); $video = new Video("", "", $_POST['videos_id']);
$obj->video_id = $_POST['videos_id']; $obj->video_id = $_POST['videos_id'];
_error_log("ReceiveImage: "."Encoder receiving post ". json_encode($_FILES));
//_error_log("ReceiveImage: ".json_encode($_POST));
$videoFileName = $video->getFilename(); $videoFileName = $video->getFilename();
$paths = Video::getPaths($videoFileName);
$destination_local = "{$paths['path']}{$videoFileName}";
$destination_local = Video::getStoragePath()."{$videoFileName}"; _error_log("ReceiveImage: videoFilename = [$videoFileName] destination_local = {$destination_local} Encoder receiving post ". json_encode($_FILES));
$obj->jpgDest = "{$destination_local}.jpg"; $obj->jpgDest = "{$destination_local}.jpg";
if (!empty($_FILES['image']['tmp_name']) && ( !empty($_REQUEST['update_video_id']) || !file_exists($obj->jpgDest) || filesize($obj->jpgDest)===42342)) { if (!empty($_FILES['image']['tmp_name']) && ( !empty($_REQUEST['update_video_id']) || !file_exists($obj->jpgDest) || filesize($obj->jpgDest)===42342)) {
@ -143,7 +138,7 @@ $obj->error = false;
$obj->video_id = $videos_id; $obj->video_id = $videos_id;
$json = json_encode($obj); $json = json_encode($obj);
_error_log("ReceiveImage: "."Files Received for video {$videos_id}: " . $video->getTitle()." {$json}"); _error_log("ReceiveImage: Files Received for video {$videos_id}: " . $video->getTitle()." {$json}");
die($json); die($json);
/* /*

View file

@ -75,7 +75,8 @@ if (isset($_FILES['upl']) && $_FILES['upl']['error'] == 0) {
} }
$mainName = preg_replace("/[^A-Za-z0-9]/", "", cleanString($path_parts['filename'])); $mainName = preg_replace("/[^A-Za-z0-9]/", "", cleanString($path_parts['filename']));
$filename = uniqid($mainName . "_YPTuniqid_", true); $paths = Video::getNewVideoFilename();
$filename = $paths['filename'];
$originalFilePath = Video::getStoragePath()."original_" . $filename; $originalFilePath = Video::getStoragePath()."original_" . $filename;
$video = new Video(preg_replace("/_+/", " ", $path_parts['filename']), $filename, @$_FILES['upl']['videoId']); $video = new Video(preg_replace("/_+/", " ", $path_parts['filename']), $filename, @$_FILES['upl']['videoId']);

View file

@ -444,9 +444,13 @@ $global['langs_codes'] = array(
); );
$global['bcp47'] = array(); $global['bcp47'] = array();
$global['langs_codes_values'] = array();
$global['langs_codes_values_withdot'] = array();
foreach ($global['langs_codes'] as $value) { foreach ($global['langs_codes'] as $value) {
$global['bcp47'][$value['value']] = $value; $global['bcp47'][$value['value']] = $value;
$global['langs_codes_values'][] = $value['value'];
$global['langs_codes_values_withdot'][] = '.'.$value['value'];
} }
$global['js_availableLangs'] = 'var availableLangs = ' . json_encode($global['langs_codes']) . ';'; $global['js_availableLangs'] = 'var availableLangs = ' . json_encode($global['langs_codes']) . ';';

View file

@ -1099,13 +1099,12 @@ function getVideosURLAudio($fileName, $fileNameisThePath = false) {
$time = explode(' ', $time); $time = explode(' ', $time);
$time = $time[1] + $time[0]; $time = $time[1] + $time[0];
$start = $time; $start = $time;
if ($fileNameisThePath) { if ($fileNameisThePath) {
$filename = str_replace(getVideosDir(), '', $fileName); $filename = basename($fileName);
$url = getCDN() . "videos/{$filename}";
$files["mp3"] = array( $files["mp3"] = array(
'filename' => $filename, 'filename' => $filename,
'path' => $fileName, 'path' => Video::getPathToFile($filename),
'url' => $url, 'url' => Video::getURLToFile($filename),
'type' => 'audio', 'type' => 'audio',
); );
} else { } else {
@ -1212,9 +1211,11 @@ function getVideosURL_V2($fileName, $recreateCache = false) {
if (!empty($getVideosURL_V2Array[$cleanfilename])) { if (!empty($getVideosURL_V2Array[$cleanfilename])) {
return $getVideosURL_V2Array[$cleanfilename]; return $getVideosURL_V2Array[$cleanfilename];
} }
$pdf = getVideosDir() . "{$cleanfilename}.pdf"; $paths = Video::getPaths($cleanfilename);
$mp3 = getVideosDir() . "{$cleanfilename}.mp3";
$pdf = $paths['path'] . "{$cleanfilename}.pdf";
$mp3 = $paths['path'] . "{$cleanfilename}.mp3";
if (file_exists($pdf)) { if (file_exists($pdf)) {
return getVideosURLPDF($fileName); return getVideosURLPDF($fileName);
} elseif (file_exists($mp3)) { } elseif (file_exists($mp3)) {
@ -1274,6 +1275,7 @@ function getVideosURL_V2($fileName, $recreateCache = false) {
TimeLogStart($timeName); TimeLogStart($timeName);
$filesInDir = globVideosDir($cleanfilename, true); $filesInDir = globVideosDir($cleanfilename, true);
TimeLogEnd($timeName, __LINE__); TimeLogEnd($timeName, __LINE__);
$timeName = "getVideosURL_V2::foreach"; $timeName = "getVideosURL_V2::foreach";
TimeLogStart($timeName); TimeLogStart($timeName);
@ -1281,17 +1283,17 @@ function getVideosURL_V2($fileName, $recreateCache = false) {
$parts = pathinfo($file); $parts = pathinfo($file);
if ($parts['filename'] == 'index') { if ($parts['filename'] == 'index') {
$parts['filename'] = str_replace(getVideosDir(), '', $parts['dirname']); $parts['filename'] = str_replace(Video::getPathToFile($parts['dirname']), '', $parts['dirname']);
} }
$timeName2 = "getVideosURL_V2::Video::getSourceFile({$parts['filename']}, .{$parts['extension']})"; //$timeName2 = "getVideosURL_V2::Video::getSourceFile({$parts['filename']}, .{$parts['extension']})";
TimeLogStart($timeName2); //TimeLogStart($timeName2);
$source = Video::getSourceFile($parts['filename'], ".{$parts['extension']}"); $source = Video::getSourceFile($parts['filename'], ".{$parts['extension']}");//var_dump($file, $parts, $source);
TimeLogEnd($timeName2, __LINE__); //TimeLogEnd($timeName2, __LINE__);
if (empty($source)) { if (empty($source)) {
continue; continue;
} }
if (filesize($file) < 20000 && !preg_match("/Dummy File/i", file_get_contents($file))) { if (filesize($file) < 1000 && !preg_match("/Dummy File/i", file_get_contents($file))) {
continue; continue;
} }
@ -1325,7 +1327,7 @@ function getVideosURL_V2($fileName, $recreateCache = false) {
// sort by resolution // sort by resolution
uasort($files, "sortVideosURL"); uasort($files, "sortVideosURL");
} }
//var_dump($files);exit;
$getVideosURL_V2Array[$cleanfilename] = $files; $getVideosURL_V2Array[$cleanfilename] = $files;
return $getVideosURL_V2Array[$cleanfilename]; return $getVideosURL_V2Array[$cleanfilename];
} }
@ -1764,12 +1766,15 @@ function decideMoveUploadedToVideos($tmp_name, $filename, $type = "video") {
$aws_s3 = AVideoPlugin::loadPluginIfEnabled('AWS_S3'); $aws_s3 = AVideoPlugin::loadPluginIfEnabled('AWS_S3');
$bb_b2 = AVideoPlugin::loadPluginIfEnabled('Blackblaze_B2'); $bb_b2 = AVideoPlugin::loadPluginIfEnabled('Blackblaze_B2');
$ftp = AVideoPlugin::loadPluginIfEnabled('FTP_Storage'); $ftp = AVideoPlugin::loadPluginIfEnabled('FTP_Storage');
$destinationFile = getVideosDir() . "{$filename}"; $paths = Video::getPaths($filename);
$destinationFile = "{$paths['path']}{$filename}";
//$destinationFile = getVideosDir() . "{$filename}";
_error_log("decideMoveUploadedToVideos: {$filename}"); _error_log("decideMoveUploadedToVideos: {$filename}");
$path_info = pathinfo($filename); $path_info = pathinfo($filename);
if ($type !== "zip" && $path_info['extension'] === 'zip') { if ($type !== "zip" && $path_info['extension'] === 'zip') {
_error_log("decideMoveUploadedToVideos: ZIp file {$filename}"); _error_log("decideMoveUploadedToVideos: ZIp file {$filename}");
$dir = getVideosDir() . "{$path_info['filename']}"; $paths = Video::getPaths($path_info['filename']);
$dir = $paths['path'];
unzipDirectory($tmp_name, $dir); // unzip it unzipDirectory($tmp_name, $dir); // unzip it
cleanDirectory($dir); cleanDirectory($dir);
if (!empty($aws_s3)) { if (!empty($aws_s3)) {
@ -1899,7 +1904,8 @@ function decideFile_put_contentsToVideos($tmp_name, $filename) {
} elseif (!empty($ftp)) { } elseif (!empty($ftp)) {
$ftp->move_uploaded_file($tmp_name, $filename); $ftp->move_uploaded_file($tmp_name, $filename);
} else { } else {
if (!move_uploaded_file($tmp_name, getVideosDir() . "{$filename}")) { $path = Video::getPathToFile($filename);
if (!move_uploaded_file($tmp_name, $path)) {
$obj->msg = "Error on move_uploaded_file({$tmp_name}, {$filename})"; $obj->msg = "Error on move_uploaded_file({$tmp_name}, {$filename})";
die(json_encode($obj)); die(json_encode($obj));
} }
@ -3631,7 +3637,8 @@ function getUsageFromFilename($filename, $dir = "") {
} }
if (empty($dir)) { if (empty($dir)) {
$dir = getVideosDir() . ""; $paths = Video::getPaths($filename);
$dir = $paths['path'];
} }
$pos = strrpos($dir, '/'); $pos = strrpos($dir, '/');
$dir .= (($pos === false) ? "/" : ""); $dir .= (($pos === false) ? "/" : "");
@ -4134,7 +4141,7 @@ function isHLS() {
global $video, $global; global $video, $global;
if (isLive()) { if (isLive()) {
return true; return true;
} elseif (!empty($video) && $video['type'] == 'video' && file_exists(getVideosDir() . "{$video['filename']}/index.m3u8")) { } elseif (!empty($video) && $video['type'] == 'video' && file_exists(Video::getPathToFile("{$video['filename']}/index.m3u8"))) {
return true; return true;
} }
return false; return false;
@ -5539,7 +5546,8 @@ function globVideosDir($filename, $filesOnly = false) {
return array(); return array();
} }
$cleanfilename = Video::getCleanFilenameFromFile($filename); $cleanfilename = Video::getCleanFilenameFromFile($filename);
$dir = getVideosDir(); $paths = Video::getPaths($filename);;
$dir = $paths['path'];
if (is_dir($dir . $filename)) { if (is_dir($dir . $filename)) {
$dir = $dir . $filename; $dir = $dir . $filename;
@ -5552,7 +5560,7 @@ function globVideosDir($filename, $filesOnly = false) {
$pattern .= ".(" . implode("|", $formats) . ")"; $pattern .= ".(" . implode("|", $formats) . ")";
} }
$pattern .= "/"; $pattern .= "/";
//var_dump($dir, $pattern);
return _glob($dir, $pattern); return _glob($dir, $pattern);
} }
@ -5876,7 +5884,9 @@ function pathToRemoteURL($filename, $forceHTTP = false) {
} }
if (empty($url)) { if (empty($url)) {
if ($forceHTTP) { if ($forceHTTP) {
$url = str_replace(getVideosDir(), getCDN() . "videos/", $filename); $paths = Video::getPaths($filename);
//$url = str_replace(getVideosDir(), getCDN() . "videos/", $filename);
$url = getCDN()."{$paths['relative']}";
} else { } else {
$url = $filename; $url = $filename;
} }
@ -5890,9 +5900,7 @@ function pathToRemoteURL($filename, $forceHTTP = false) {
function getFilenameFromPath($path) { function getFilenameFromPath($path) {
global $global; global $global;
$fileName = str_replace(getVideosDir() . "", "", $path);
$fileName = Video::getCleanFilenameFromFile($fileName); $fileName = Video::getCleanFilenameFromFile($fileName);
return $fileName; return $fileName;
} }
@ -6591,4 +6599,18 @@ function inputToRequest(){
} }
} }
} }
}
function useVideoHashOrLogin(){
if(!empty($_REQUEST['video_id_hash'])){
$videos_id = Video::getVideoIdFromHash($_REQUEST['video_id_hash']);
if(!empty($videos_id)){
$users_id = Video::getOwner($videos_id);
$user = new User($users_id);
_error_log("useVideoHashOrLogin: $users_id, $videos_id");
return $user->login(true);
}
}
return User::loginFromRequest();
} }

View file

@ -2164,9 +2164,13 @@ if (typeof gtag !== \"function\") {
if (!empty($_REQUEST['do_not_login'])) { if (!empty($_REQUEST['do_not_login'])) {
return false; return false;
} }
if(empty($_REQUEST['pass']) && !empty($_REQUEST['password'])){
$_REQUEST['pass'] = $_REQUEST['password'];
}
if (!empty($_REQUEST['user']) && !empty($_REQUEST['pass'])) { if (!empty($_REQUEST['user']) && !empty($_REQUEST['pass'])) {
$user = new User(0, $_REQUEST['user'], $_REQUEST['pass']); $user = new User(0, $_REQUEST['user'], $_REQUEST['pass']);
$user->login(false, !empty($_REQUEST['encodedPass'])); $user->login(false, !empty($_REQUEST['encodedPass']));
$_REQUEST['do_not_login'] = 1;
} }
} }

View file

@ -310,7 +310,12 @@ if (!class_exists('Video')) {
} }
if (empty($this->filename)) { if (empty($this->filename)) {
$this->filename = $this->type . "_" . uniqid(); $prefix = $this->type;
if(empty($prefix)){
$prefix = 'v';
}
$paths = self::getNewVideoFilename($prefix);
$this->filename = $paths['filename'];
} }
$this->can_download = intval($this->can_download); $this->can_download = intval($this->can_download);
@ -853,7 +858,7 @@ if (!class_exists('Video')) {
return false; return false;
} }
$sql = "SELECT * FROM videos WHERE filename = ? LIMIT 1"; $sql = "SELECT * FROM videos WHERE filename = ? LIMIT 1";
//var_dump($sql, $fileName);
$res = sqlDAL::readSql($sql, "s", array($fileName), true); $res = sqlDAL::readSql($sql, "s", array($fileName), true);
if ($res != false) { if ($res != false) {
$video = sqlDAL::fetchAssoc($res); $video = sqlDAL::fetchAssoc($res);
@ -2707,7 +2712,10 @@ if (!class_exists('Video')) {
//if(!isValidFormats($type)){ //if(!isValidFormats($type)){
//return array(); //return array();
//} //}
self::_moveSourceFilesToDir($filename);
$paths = self::getPaths($filename);
if ($type == '_thumbsSmallV2.jpg' && empty($advancedCustom->usePreloadLowResolutionImages)) { if ($type == '_thumbsSmallV2.jpg' && empty($advancedCustom->usePreloadLowResolutionImages)) {
return array('path' => $global['systemRootPath'] . 'view/img/loading-gif.png', 'url' => getCDN() . 'view/img/loading-gif.png'); return array('path' => $global['systemRootPath'] . 'view/img/loading-gif.png', 'url' => getCDN() . 'view/img/loading-gif.png');
} }
@ -2721,7 +2729,7 @@ if (!class_exists('Video')) {
// check if there is a webp image // check if there is a webp image
if ($type === '.gif' && (empty($_SERVER['HTTP_USER_AGENT']) || get_browser_name($_SERVER['HTTP_USER_AGENT']) !== 'Safari')) { if ($type === '.gif' && (empty($_SERVER['HTTP_USER_AGENT']) || get_browser_name($_SERVER['HTTP_USER_AGENT']) !== 'Safari')) {
$path = self::getStoragePath() . "{$filename}.webp"; $path = "{$paths['path']}{$filename}.webp";
if (file_exists($path)) { if (file_exists($path)) {
$type = ".webp"; $type = ".webp";
} }
@ -2754,8 +2762,12 @@ if (!class_exists('Video')) {
$token = "?" . implode("&", $vars); $token = "?" . implode("&", $vars);
} }
} }
$paths = self::getPaths($filename);
$source = array(); $source = array();
$source['path'] = self::getStoragePath() . "{$filename}{$type}"; $source['path'] = $paths['path']."{$filename}{$type}";
if ($type == ".m3u8") { if ($type == ".m3u8") {
$source['path'] = self::getStoragePath() . "{$filename}/index{$type}"; $source['path'] = self::getStoragePath() . "{$filename}/index{$type}";
@ -2772,18 +2784,18 @@ if (!class_exists('Video')) {
if (!empty($video['sites_id']) && (preg_match("/.*\\.mp3$/", $type) || preg_match("/.*\\.mp4$/", $type) || preg_match("/.*\\.webm$/", $type) || $type == ".m3u8" || $type == ".pdf" || $type == ".zip") && @filesize($source['path']) < 20) { if (!empty($video['sites_id']) && (preg_match("/.*\\.mp3$/", $type) || preg_match("/.*\\.mp4$/", $type) || preg_match("/.*\\.webm$/", $type) || $type == ".m3u8" || $type == ".pdf" || $type == ".zip") && @filesize($source['path']) < 20) {
$site = new Sites($video['sites_id']); $site = new Sites($video['sites_id']);
$siteURL = getCDNOrURL($site->getUrl(), 'CDN_YPTStorage', $video['sites_id']); $siteURL = getCDNOrURL($site->getUrl(), 'CDN_YPTStorage', $video['sites_id']);
$source['url'] = "{$siteURL}videos/{$filename}{$type}{$token}"; $source['url'] = "{$siteURL}{$paths['relative']}{$filename}{$type}{$token}";
if ($type == ".m3u8") { if ($type == ".m3u8") {
$source['url'] = "{$siteURL}videos/{$filename}/index{$type}{$token}"; $source['url'] = "{$siteURL}videos/{$filename}/index{$type}{$token}";
} }
} elseif (!empty($advancedCustom->videosCDN) && $canUseCDN) { } elseif (!empty($advancedCustom->videosCDN) && $canUseCDN) {
$advancedCustom->videosCDN = rtrim($advancedCustom->videosCDN, '/') . '/'; $advancedCustom->videosCDN = rtrim($advancedCustom->videosCDN, '/') . '/';
$source['url'] = "{$advancedCustom->videosCDN}videos/{$filename}{$type}{$token}"; $source['url'] = "{$advancedCustom->videosCDN}{$paths['relative']}{$filename}{$type}{$token}";
if ($type == ".m3u8") { if ($type == ".m3u8") {
$source['url'] = "{$advancedCustom->videosCDN}videos/{$filename}/index{$type}{$token}"; $source['url'] = "{$advancedCustom->videosCDN}videos/{$filename}/index{$type}{$token}";
} }
} else { } else {
$source['url'] = getCDN() . "videos/{$filename}{$type}{$token}"; $source['url'] = getCDN() . "{$paths['relative']}{$filename}{$type}{$token}";
if ($type == ".m3u8") { if ($type == ".m3u8") {
$source['url'] = getCDN() . "videos/{$filename}/index{$type}{$token}"; $source['url'] = getCDN() . "videos/{$filename}/index{$type}{$token}";
} }
@ -2803,6 +2815,7 @@ if (!class_exists('Video')) {
if (!file_exists($source['path']) || ($type !== ".m3u8" && !is_dir($source['path']) && (filesize($source['path']) < 1000 && filesize($source['path']) != 10))) { if (!file_exists($source['path']) || ($type !== ".m3u8" && !is_dir($source['path']) && (filesize($source['path']) < 1000 && filesize($source['path']) != 10))) {
if ($type != "_thumbsV2.jpg" && $type != "_thumbsSmallV2.jpg" && $type != "_portrait_thumbsV2.jpg" && $type != "_portrait_thumbsSmallV2.jpg") { if ($type != "_thumbsV2.jpg" && $type != "_thumbsSmallV2.jpg" && $type != "_portrait_thumbsV2.jpg" && $type != "_portrait_thumbsSmallV2.jpg") {
$VideoGetSourceFile[$cacheName] = array('path' => false, 'url' => false); $VideoGetSourceFile[$cacheName] = array('path' => false, 'url' => false);
//echo PHP_EOL.'---'.PHP_EOL;var_dump($source, $type, !file_exists($source['path']), ($type !== ".m3u8" && !is_dir($source['path']) && (filesize($source['path']) < 1000 && filesize($source['path']) != 10)));echo PHP_EOL.'+++'.PHP_EOL;
return $VideoGetSourceFile[$cacheName]; return $VideoGetSourceFile[$cacheName];
} }
} }
@ -2825,35 +2838,179 @@ if (!class_exists('Video')) {
return $VideoGetSourceFile[$cacheName]; return $VideoGetSourceFile[$cacheName];
} }
public static function getCleanFilenameFromFile($filename) { private static function _moveSourceFilesToDir($videoFilename){
$videoFilename = self::getCleanFilenameFromFile($videoFilename);
if(preg_match('/^(hd|low|sd|(res[0-9]{3,4}))$/', $videoFilename)){
return false;
}
$paths = self::getPaths($videoFilename);
$lock = "{$paths['path']}.move_v1.lock";
if(file_exists($lock)){
return true;
}
$videosDir = self::getStoragePath();
mkdir($paths['path'], 0755, true);
$files = _glob($videosDir, '/'.$videoFilename.'[._][a-z0-9_]+/i');
//var_dump($paths['path'], is_dir($paths['path']), $files);exit;
foreach ($files as $oldname) {
if(is_dir($oldname)){
continue;
}
$newname = str_replace($videosDir, $paths['path'], $oldname);
rename($oldname , $newname);
}
return file_put_contents($lock, time());
}
public static function getPaths($videoFilename){
global $global; global $global;
$cleanVideoFilename = self::getCleanFilenameFromFile($videoFilename);
$videosDir = self::getStoragePath();
if(preg_match('/index\.m3u8$/', $videoFilename)){
$path = "{$videosDir}";
}else{
$path = "{$videosDir}{$cleanVideoFilename}".DIRECTORY_SEPARATOR;
}
$relative = "videos/{$cleanVideoFilename}/";
$url = getCDN()."{$relative}";
return array('filename'=>$cleanVideoFilename, 'path'=>$path, 'url'=>$url, 'relative'=>$relative);
}
public static function getPathToFile($videoFilename){
$paths = Video::getPaths($videoFilename);
return "{$paths['path']}{$videoFilename}";
}
public static function getURLToFile($videoFilename){
$paths = Video::getPaths($videoFilename);
return "{$paths['url']}{$videoFilename}";
}
public static function getURLToFileIfExists($videoFilename){
$paths = Video::getPaths($videoFilename);
if(!file_exists("{$paths['path']}{$videoFilename}")){
return false;
}
return "{$paths['url']}{$videoFilename}";
}
public static function getNewVideoFilename($prefix='', $time=''){
$uid = substr(uniqid(), -4);
if(empty($time)){
$time=time();
}
$prefix = preg_replace('/[^a-z0-9]/i', '', $prefix);
if(empty($prefix)){
$prefix='v';
}
$date = date('ymdHis', $time);
$videoFilename = strtolower("{$prefix}_{$date}_{$uid}");
return self::getPaths($videoFilename);
}
public static function getNewVideoFilenameWithPrefixFromFilename($filename){
$video = self::getVideoFromFileNameLight($filename);
if(empty($video)){
return self::getNewVideoFilename();
}
return self::getNewVideoFilename($video['type']);
}
public static function updateDirectoryFilename($directory){
if(!is_dir($directory)){
_error_log('Video::updateDirectoryFilename directory not found '."[{$directory}]");
return false;
}
$video = self::getVideoFromFileNameLight($directory);
if(empty($video)){
_error_log('Video::updateDirectoryFilename video not found for directory '."[{$directory}]");
return false;
}
$newFilename = self::getNewVideoFilename($video['type'], strtotime($video['created']));
$v = new Video('', '', $video['id']);
$v->setFilename($newFilename['filename'], true);
$id = $v->save(false, true);
if($id){
$renamed = rename($directory, $newFilename['path']);
if(empty($renamed)){ // rename dir fail rollback
_error_log('Video::updateDirectoryFilename rename dir fail, we will rollback changes '."[olddir={$directory}] [newdir={$newFilename['path']}]");
$v = new Video('', '', $video['id']);
$v->setFilename($video['filename'], true);
$id = $v->save(false, true);
return false;
}else{
_error_log('Video::updateDirectoryFilename video folder renamed from '."[olddir={$directory}] [newdir={$newFilename['path']}]");
self::updateFilesInDirectoryFilename($newFilename['path']);
}
}
return array('videos_id'=>$video['id'], 'filename'=>$newFilename['filename'], 'oldDir'=>$directory, 'newDir'=>$newFilename['path'] );
}
public static function updateFilesInDirectoryFilename($directory){
if(!is_dir($directory)){
_error_log('Video::updateFilesInDirectoryFilename directory not found '."[{$directory}]");
return false;
}
$video = self::getVideoFromFileNameLight($directory);
if(empty($video)){
_error_log('Video::updateFilesInDirectoryFilename video not found for directory '."[{$directory}]");
return false;
}
$newFilename = $video['filename'];
$files = glob("{$directory}*.{jpg,png,gif,webp,vtt,srt,mp4,webm,mp3,ogg,notfound}", GLOB_BRACE);
_error_log('Video::updateFilesInDirectoryFilename total files found '.count($files));
foreach ($files as $value) {
$oldFilename = self::getCleanFilenameFromFile($value);
$newFilenamePath = str_replace($oldFilename, $newFilename, $value);
$renamed = rename($value, $newFilenamePath);
if(empty($renamed)){ // rename dir fail rollback
_error_log('Video::updateFilesInDirectoryFilename rename file fail '."[olddir={$value}] [newdir={$newFilenamePath}]");
}else{
_error_log('Video::updateFilesInDirectoryFilename video file renamed from '."[olddir={$value}] [newdir={$newFilenamePath}]");
}
}
}
public function getVideoIdHash(){
$obj = new stdClass();
$obj->videos_id = $this->id;
return encryptString(json_encode($obj));
}
public static function getVideoIdFromHash($hash){
$string = decryptString($hash);
if(!empty($string)){
$json = json_decode($string);
if(!empty($json) && !empty($json->videos_id)){
return $json->videos_id;
}
}
return false;
}
public static function getCleanFilenameFromFile($filename) {
global $global;
if (empty($filename)) { if (empty($filename)) {
return ""; return "";
} }
$filename = fixPath($filename); $filename = fixPath($filename);
$search = array('_Low', '_SD', '_HD', '_thumbsV2', '_thumbsSmallV2', '_thumbsSprit', '_roku', '_portrait', '_portrait_thumbsV2', '_portrait_thumbsSmallV2'); $filename = str_replace(getVideosDir(), '', $filename);
$replace = array('', '', '', '', '', '', '', '', '', ''); $search = array('_Low', '_SD', '_HD', '_thumbsV2', '_thumbsSmallV2', '_thumbsSprit', '_roku', '_portrait', '_portrait_thumbsV2', '_portrait_thumbsSmallV2', '_spectrum', '_tvg')+$global['langs_codes_values_withdot'];
if (empty($global['avideo_resolutions']) || !is_array($global['avideo_resolutions'])) { if (empty($global['avideo_resolutions']) || !is_array($global['avideo_resolutions'])) {
$global['avideo_resolutions'] = array(240, 360, 480, 540, 720, 1080, 1440, 2160); $global['avideo_resolutions'] = array(240, 360, 480, 540, 720, 1080, 1440, 2160);
} }
foreach ($global['avideo_resolutions'] as $value) { foreach ($global['avideo_resolutions'] as $value) {
$search[] = "_{$value}"; $search[] = "_{$value}";
$replace[] = '';
$search[] = "res{$value}"; $search[] = "res{$value}";
$replace[] = '';
} }
$cleanName = str_replace($search, $replace, $filename); $cleanName = str_replace($search, '', $filename);
$path_parts = pathinfo($cleanName); $path_parts = pathinfo($cleanName);
if (!empty($path_parts["extension"]) && $path_parts["extension"] === "m3u8") {
preg_match('/videos\/([^\/]+)/', $path_parts["dirname"], $matches);
if (!empty($matches[1])) {
$path_parts['filename'] = $matches[1];
}
}
if (empty($path_parts['extension'])) { if (empty($path_parts['extension'])) {
//_error_log("Video::getCleanFilenameFromFile could not find extension of ".$filename); //_error_log("Video::getCleanFilenameFromFile could not find extension of ".$filename);
if (!empty($path_parts['filename'])) { if (!empty($path_parts['filename'])) {
@ -2864,8 +3021,7 @@ if (!class_exists('Video')) {
} else if (strlen($path_parts['extension']) > 4) { } else if (strlen($path_parts['extension']) > 4) {
return $cleanName; return $cleanName;
} else if ($path_parts['filename'] == 'index' && $path_parts['extension'] == 'm3u8') { } else if ($path_parts['filename'] == 'index' && $path_parts['extension'] == 'm3u8') {
$clanFileName = str_replace(getVideosDir(), '', $path_parts['dirname']); $parts = explode(DIRECTORY_SEPARATOR, $cleanName);
$parts = explode(DIRECTORY_SEPARATOR, $clanFileName);
return $parts[0]; return $parts[0];
} else { } else {
return $path_parts['filename']; return $path_parts['filename'];
@ -3592,7 +3748,8 @@ if (!class_exists('Video')) {
return false; return false;
} }
global $global; global $global;
$filePath = Video::getStoragePath() . "{$filename}";
$filePath = Video::getPathToFile($filename);
// Streamlined for less coding space. // Streamlined for less coding space.
$files = glob("{$filePath}*_thumbs*.jpg"); $files = glob("{$filePath}*_thumbs*.jpg");
foreach ($files as $file) { foreach ($files as $file) {

View file

@ -42,7 +42,8 @@ if (!empty($_POST['videoLink'])) {
if (empty($_POST['id']) && !(in_array($extension, $audioLinks) || in_array($extension, $videoLinks))) { if (empty($_POST['id']) && !(in_array($extension, $audioLinks) || in_array($extension, $videoLinks))) {
$info = url_get_contents($config->getEncoderURL() . "getLinkInfo/" . base64_encode($_POST['videoLink'])); $info = url_get_contents($config->getEncoderURL() . "getLinkInfo/" . base64_encode($_POST['videoLink']));
$infoObj = _json_decode($info); $infoObj = _json_decode($info);
$filename = uniqid("_YPTuniqid_", true); $paths = Video::getNewVideoFilename();
$filename = $paths['filename'];
$filename = $obj->setFilename($filename); $filename = $obj->setFilename($filename);
$obj->setTitle($infoObj->title); $obj->setTitle($infoObj->title);
$obj->setClean_title($infoObj->title); $obj->setClean_title($infoObj->title);
@ -51,7 +52,8 @@ if (!empty($_POST['videoLink'])) {
file_put_contents($global['systemRootPath'] . "videos/{$filename}.jpg", base64_decode($infoObj->thumbs64)); file_put_contents($global['systemRootPath'] . "videos/{$filename}.jpg", base64_decode($infoObj->thumbs64));
$_POST['videoLinkType'] = "embed"; $_POST['videoLinkType'] = "embed";
} else if (empty($_POST['id'])) { } else if (empty($_POST['id'])) {
$filename = uniqid("_YPTuniqid_", true); $paths = Video::getNewVideoFilename();
$filename = $paths['filename'];
$filename = $obj->setFilename($filename); $filename = $obj->setFilename($filename);
$obj->setTitle($path_parts["filename"]); $obj->setTitle($path_parts["filename"]);
$obj->setClean_title($path_parts["filename"]); $obj->setClean_title($path_parts["filename"]);
@ -87,7 +89,8 @@ if (!empty($_POST['isArticle'])) {
if (empty($_POST['id'])) { if (empty($_POST['id'])) {
$obj->setStatus('a'); $obj->setStatus('a');
} }
$filename = uniqid("_YPTuniqid_", true); $paths = Video::getNewVideoFilename();
$filename = $paths['filename'];
$filename = $obj->setFilename($filename); $filename = $obj->setFilename($filename);
} }
TimeLogEnd(__FILE__, __LINE__); TimeLogEnd(__FILE__, __LINE__);

View file

@ -72,14 +72,16 @@ if (empty($objo) || ($objo->onlyAdminCanBulkEmbed && !User::isAdmin())) {
} }
//$info = url_get_contents($config->getEncoderURL() . "getLinkInfo/" . base64_encode($value)); //$info = url_get_contents($config->getEncoderURL() . "getLinkInfo/" . base64_encode($value));
//$infoObj = _json_decode($info); //$infoObj = _json_decode($info);
$filename = uniqid("_YPTuniqid_", true); $paths = Video::getNewVideoFilename();
$filename = $paths['filename'];
$videos = new Video(); $videos = new Video();
$videos->setFilename($filename); $videos->setFilename($filename);
$videos->setTitle($value['title']); $videos->setTitle($value['title']);
$videos->setDescription($value['description']); $videos->setDescription($value['description']);
$videos->setClean_title($value['title']); $videos->setClean_title($value['title']);
$videos->setDuration(ISO8601ToDuration($value['duration'])); $videos->setDuration(ISO8601ToDuration($value['duration']));
file_put_contents($global['systemRootPath'] . "videos/{$filename}.jpg", url_get_contents($value['thumbs'])); $poster = Video::getPathToFile("{$video['filename']}.jpg");
file_put_contents($poster, url_get_contents($value['thumbs']));
$videos->setVideoLink($value['link']); $videos->setVideoLink($value['link']);
$videos->setType('embed'); $videos->setType('embed');

View file

@ -11,9 +11,10 @@ function getCloneFilesInfo($dir, $subdir = "", $extensionsToCopy = array('mp4',
if (!in_array($path_info['extension'], $extensionsToCopy)) { if (!in_array($path_info['extension'], $extensionsToCopy)) {
continue; continue;
} }
$url = Video::getURLToFile("{$subdir}{$entry}");
$f = new stdClass(); $f = new stdClass();
$f->filename = $entry; $f->filename = $entry;
$f->url = "{$global['webSiteRootURL']}videos/{$subdir}{$entry}"; $f->url = $url;
$f->filesize = filesize($dir . $entry); $f->filesize = filesize($dir . $entry);
$f->filemtime = filemtime($dir . $entry); $f->filemtime = filemtime($dir . $entry);
$files[] = $f; $files[] = $f;

View file

@ -155,7 +155,7 @@ a.h6{
position: absolute; position: absolute;
right: 5px; right: 5px;
top: 5px; top: 5px;
z-index: 9999; z-index: 1025;
display: none; display: none;
} }
.galleryVideo .galleryVideoButtons button{ .galleryVideo .galleryVideoButtons button{

View file

@ -26,7 +26,8 @@ if ($oIMDB->isReady) {
if (empty($_GET['what']) || $_GET['what'] == 1) { if (empty($_GET['what']) || $_GET['what'] == 1) {
// get poster // get poster
$poster = $oIMDB->getPoster('big', true); $poster = $oIMDB->getPoster('big', true);
$filename = Video::getStoragePath()."{$videoFileName}_portrait.jpg";
$filename = Video::getPathToFile("{$videoFileName}_portrait.jpg");
im_resizeV2($poster, $filename, $plugin->posterWidth, $plugin->posterHeight); im_resizeV2($poster, $filename, $plugin->posterWidth, $plugin->posterHeight);
} }

View file

@ -155,7 +155,7 @@ Best regards,
return false; return false;
} }
if (empty($loginControlCreateLog)) { if (empty($loginControlCreateLog)) {
_error_log("LoginControl::createLog {$_SERVER['SCRIPT_NAME']} " . json_encode(debug_backtrace())); //_error_log("LoginControl::createLog {$_SERVER['SCRIPT_NAME']} " . json_encode(debug_backtrace()));
$ulh = new logincontrol_history(0); $ulh = new logincontrol_history(0);
$ulh->setIp(getRealIpAddr()); $ulh->setIp(getRealIpAddr());
$ulh->setStatus(self::is2FAConfirmed($users_id) ? logincontrol_history_status::$CONFIRMED : logincontrol_history_status::$WAITING_CONFIRMATION); $ulh->setStatus(self::is2FAConfirmed($users_id) ? logincontrol_history_status::$CONFIRMED : logincontrol_history_status::$WAITING_CONFIRMATION);

View file

@ -66,7 +66,9 @@ if (isset($_FILES['upl']) && $_FILES['upl']['error'] == 0) {
} }
$mainName = preg_replace("/[^A-Za-z0-9]/", "", cleanString($_FILES['upl']['name'])); $mainName = preg_replace("/[^A-Za-z0-9]/", "", cleanString($_FILES['upl']['name']));
$filename = uniqid($mainName . "_YPTuniqid_", true);
$paths = Video::getNewVideoFilename();
$filename = $paths['filename'];
$video = new Video(preg_replace("/_+/", " ", $_FILES['upl']['name']), $filename, 0); $video = new Video(preg_replace("/_+/", " ", $_FILES['upl']['name']), $filename, 0);
$video->setDuration($duration); $video->setDuration($duration);

View file

@ -417,15 +417,15 @@ class PlayLists extends PluginAbstract {
$serie = self::isPlayListASerie($playlists_id); $serie = self::isPlayListASerie($playlists_id);
if (!empty($serie)) { if (!empty($serie)) {
$tvg_logo = "videos/{$serie['filename']}_tvg.jpg"; $tvg_logo = "{$serie['filename']}_tvg.jpg";
$tvg_logo_path = "{$global['systemRootPath']}{$tvg_logo}"; $tvg_logo_path = Video::getPathToFile($tvg_logo);
if (!file_exists($tvg_logo_path)) { if (!file_exists($tvg_logo_path)) {
$images = Video::getSourceFile($serie['filename']); $images = Video::getSourceFile($serie['filename']);
$img = $images["path"]; $img = $images["path"];
im_resizeV2($img, $tvg_logo_path, 150, 150, 80); im_resizeV2($img, $tvg_logo_path, 150, 150, 80);
} }
$tvg_logo_url = "{$global['webSiteRootURL']}{$tvg_logo}"; $tvg_logo_url = Video::getURLToFile($tvg_logo);
return $tvg_logo_url; return $tvg_logo_url;
} else { } else {
$pl = new PlayList($playlists_id); $pl = new PlayList($playlists_id);

View file

@ -0,0 +1,3 @@
-- https://github.com/WWBN/AVideo/issues/5075
UPDATE configurations SET version = '11.0', modified = now() WHERE id = 1;

View file

@ -18,7 +18,7 @@ if (empty($_GET['videoDirectory'])) {
$video = Video::getVideoFromFileName($_GET['videoDirectory'], true); $video = Video::getVideoFromFileName($_GET['videoDirectory'], true);
$filename = Video::getStoragePath() . "{$_GET['videoDirectory']}".DIRECTORY_SEPARATOR."index.m3u8"; $filename = Video::getPathToFile("{$_GET['videoDirectory']}".DIRECTORY_SEPARATOR."index.m3u8");
if (empty($video) || !file_exists($filename)) { if (empty($video) || !file_exists($filename)) {
header("Content-Type: text/plain"); header("Content-Type: text/plain");
@ -47,7 +47,7 @@ if (empty($video) || !file_exists($filename)) {
} }
} }
$_GET['file'] = Video::getStoragePath() . "{$_GET['videoDirectory']}".DIRECTORY_SEPARATOR."index.m3u8"; $_GET['file'] = Video::getPathToFile("{$_GET['videoDirectory']}".DIRECTORY_SEPARATOR."index.m3u8");
//var_dump($_GET['file']);exit; //var_dump($_GET['file']);exit;
$cachedPath = explode(DIRECTORY_SEPARATOR, $_GET['videoDirectory']); $cachedPath = explode(DIRECTORY_SEPARATOR, $_GET['videoDirectory']);
if (empty($_SESSION['user']['sessionCache']['hls'][$cachedPath[0]]) && empty($_GET['download'])) { if (empty($_SESSION['user']['sessionCache']['hls'][$cachedPath[0]]) && empty($_GET['download'])) {

View file

@ -14,7 +14,8 @@ if(!empty($_GET['image'])){
} }
// if the thumb is not ready yet, try to find the default image // if the thumb is not ready yet, try to find the default image
if(preg_match('/videos\/(.*)_thumbs(V2)?.jpg/',$imageURL, $matches)){ if(preg_match('/videos\/(.*)_thumbs(V2)?.jpg/',$imageURL, $matches)){
$jpg = Video::getStoragePath()."{$matches[1]}.jpg";
$jpg = Video::getPathToFile("{$matches[1]}.jpg");
if(file_exists($jpg)){ if(file_exists($jpg)){
$file = $jpg; $file = $jpg;
$type = 'image/jpg'; $type = 'image/jpg';

View file

@ -1924,14 +1924,14 @@ if (Permissions::canAdminVideos()) {
var type, img, is_portrait; var type, img, is_portrait;
if (row.type === "audio") { if (row.type === "audio") {
type = "<i class='fa fa-headphones hidden-xs' style='font-size:14px;'></i> "; type = "<i class='fa fa-headphones hidden-xs' style='font-size:14px;'></i> ";
img = "<img class='img img-responsive img-thumbnail pull-left rotate" + row.rotation + "' src='<?php echo $global['webSiteRootURL']; ?>videos/" + row.filename + ".jpg?" + Math.random() + "' style='max-height:80px; margin-right: 5px;'> "; img = "<img class='img img-responsive img-thumbnail pull-left rotate" + row.rotation + "' src='<?php echo $global['webSiteRootURL']; ?>videos/" + row.filename + "/" + row.filename + ".jpg?" + Math.random() + "' style='max-height:80px; margin-right: 5px;'> ";
if (row.videosURL && typeof row.videosURL !== 'undefined' && typeof row.videosURL.pjpg !== 'undefined' && row.videosURL.pjpg.url) { if (row.videosURL && typeof row.videosURL !== 'undefined' && typeof row.videosURL.pjpg !== 'undefined' && row.videosURL.pjpg.url) {
img = "<img class='img img-responsive img-thumbnail pull-left' src='" + row.videosURL.pjpg.url + "?" + Math.random() + "' style='max-height:80px; margin-right: 5px;'> "; img = "<img class='img img-responsive img-thumbnail pull-left' src='" + row.videosURL.pjpg.url + "?" + Math.random() + "' style='max-height:80px; margin-right: 5px;'> ";
} else if (row.videosURL && typeof row.videosURL !== 'undefined' && typeof row.videosURL.jpg !== 'undefined' && row.videosURL.jpg.url) { } else if (row.videosURL && typeof row.videosURL !== 'undefined' && typeof row.videosURL.jpg !== 'undefined' && row.videosURL.jpg.url) {
img = "<img class='img img-responsive img-thumbnail pull-left' src='" + row.videosURL.jpg.url + "?" + Math.random() + "' style='max-height:80px; margin-right: 5px;'> "; img = "<img class='img img-responsive img-thumbnail pull-left' src='" + row.videosURL.jpg.url + "?" + Math.random() + "' style='max-height:80px; margin-right: 5px;'> ";
} else { } else {
is_portrait = (row.rotation === "90" || row.rotation === "270") ? "img-portrait" : ""; is_portrait = (row.rotation === "90" || row.rotation === "270") ? "img-portrait" : "";
img = "<img class='img img-responsive " + is_portrait + " img-thumbnail pull-left rotate" + row.rotation + "' src='<?php echo $global['webSiteRootURL']; ?>videos/" + row.filename + ".jpg?" + Math.random() + "' style='max-height:80px; margin-right: 5px;'> "; img = "<img class='img img-responsive " + is_portrait + " img-thumbnail pull-left rotate" + row.rotation + "' src='<?php echo $global['webSiteRootURL']; ?>videos/" + row.filename + "/" + row.filename + ".jpg?" + Math.random() + "' style='max-height:80px; margin-right: 5px;'> ";
} }
} else { } else {
type = "<i class='fa fa-film hidden-xs' style='font-size:14px;'></i> "; type = "<i class='fa fa-film hidden-xs' style='font-size:14px;'></i> ";

View file

@ -142,9 +142,11 @@ if (isset($_FILES['upl']) && $_FILES['upl']['error'] == 0) {
if ($extension !== "jpg" && $video->getType() == "image") { if ($extension !== "jpg" && $video->getType() == "image") {
sleep(1); // to make sure the file will be available sleep(1); // to make sure the file will be available
$file = Video::getStoragePath() . "" . $video->getFilename(); $file = $video->getFilename();
$jpgFrom = Video::getPathToFile("{$file}.{$extension}");
$jpgTo = Video::getPathToFile("{$file}.jpg");
try { try {
convertImage("{$file}.{$extension}", "{$file}.jpg", 70); convertImage($jpgFrom, $jpgTo, 70);
} catch (Exception $exc) { } catch (Exception $exc) {
_error_log("We could not convert the image to JPG " . $exc->getMessage()); _error_log("We could not convert the image to JPG " . $exc->getMessage());
} }

View file

@ -50,22 +50,17 @@ if (!empty($playlist_id)) {
<a href="<?php echo Video::getLink($autoPlayVideo['id'], $autoPlayVideo['clean_title'], "", $get); ?>" title="<?php echo str_replace('"', '', $autoPlayVideo['title']); ?>" class="videoLink h6"> <a href="<?php echo Video::getLink($autoPlayVideo['id'], $autoPlayVideo['clean_title'], "", $get); ?>" title="<?php echo str_replace('"', '', $autoPlayVideo['title']); ?>" class="videoLink h6">
<div class="col-lg-5 col-sm-5 col-xs-5 nopadding thumbsImage"> <div class="col-lg-5 col-sm-5 col-xs-5 nopadding thumbsImage">
<?php <?php
$imgGif = ""; $imgGif = Video::getURLToFileIfExists("{$autoPlayVideo['filename']}.gif");
if (file_exists(Video::getStoragePath()."{$autoPlayVideo['filename']}.gif")) {
$imgGif = "{$global['webSiteRootURL']}videos/{$autoPlayVideo['filename']}.gif";
}
if ($autoPlayVideo['type'] === "pdf") { if ($autoPlayVideo['type'] === "pdf") {
$img = "{$global['webSiteRootURL']}videos/{$autoPlayVideo['filename']}.png"; $imgGif = Video::getURLToFileIfExists("{$autoPlayVideo['filename']}.png");
$img_portrait = ($autoPlayVideo['rotation'] === "90" || $autoPlayVideo['rotation'] === "270") ? "img-portrait" : "";
} else if (($autoPlayVideo['type'] !== "audio") && ($autoPlayVideo['type'] !== "linkAudio")) { } else if (($autoPlayVideo['type'] !== "audio") && ($autoPlayVideo['type'] !== "linkAudio")) {
$img = "{$global['webSiteRootURL']}videos/{$autoPlayVideo['filename']}.jpg"; $imgGif = Video::getURLToFileIfExists("{$autoPlayVideo['filename']}.jpg");
$img_portrait = ($autoPlayVideo['rotation'] === "90" || $autoPlayVideo['rotation'] === "270") ? "img-portrait" : "";
} else { } else {
$img = "".getCDN()."view/img/audio_wave.jpg"; $img = getCDN()."view/img/audio_wave.jpg";
$img_portrait = ""; $img_portrait = "";
} }
?> ?>
<img src="<?php echo $img; ?>" alt="<?php echo str_replace('"', '', $autoPlayVideo['title']); ?>" class="img-responsive <?php echo $img_portrait; ?> rotate<?php echo $autoPlayVideo['rotation']; ?>" height="130" /> <img src="<?php echo $img; ?>" alt="<?php echo str_replace('"', '', $autoPlayVideo['title']); ?>" class="img img-responsive " height="130" />
<?php if (!empty($imgGif)) { ?> <?php if (!empty($imgGif)) { ?>
<img src="<?php echo $imgGif; ?>" style="position: absolute; top: 0; display: none;" alt="<?php echo str_replace('"', '', $autoPlayVideo['title']); ?>" id="thumbsGIF<?php echo $autoPlayVideo['id']; ?>" class="thumbsGIF img-responsive <?php echo $img_portrait; ?> rotate<?php echo $autoPlayVideo['rotation']; ?>" height="130" /> <img src="<?php echo $imgGif; ?>" style="position: absolute; top: 0; display: none;" alt="<?php echo str_replace('"', '', $autoPlayVideo['title']); ?>" id="thumbsGIF<?php echo $autoPlayVideo['id']; ?>" class="thumbsGIF img-responsive <?php echo $img_portrait; ?> rotate<?php echo $autoPlayVideo['rotation']; ?>" height="130" />
<?php } ?> <?php } ?>

View file

@ -403,7 +403,7 @@ if (User::hasBlockedUser($video['users_id'])) {
}); });
</script> </script>
<?php <?php
} else if ($video['type'] == "audio" && !file_exists(Video::getStoragePath() . "{$video['filename']}.mp4")) { } else if ($video['type'] == "audio" && !file_exists(Video::getPathToFile("{$video['filename']}.mp4"))) {
$isAudio = 1; $isAudio = 1;
?> ?>
<!-- audio --> <!-- audio -->

View file

@ -1,5 +1,4 @@
<?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';
@ -16,7 +15,7 @@ if (empty($_GET['file'])) {
$path_parts = pathinfo($_GET['file']); $path_parts = pathinfo($_GET['file']);
$file = $path_parts['basename']; $file = $path_parts['basename'];
$path = Video::getStoragePath()."{$file}";
if ($file == "X-Sendfile.mp4") { if ($file == "X-Sendfile.mp4") {
$path = "{$global['systemRootPath']}plugin/SecureVideosDirectory/test.json"; $path = "{$global['systemRootPath']}plugin/SecureVideosDirectory/test.json";
@ -36,6 +35,7 @@ if ($file == "configuration.php") {
forbiddenPage("Cant read this"); forbiddenPage("Cant read this");
} }
$path = Video::getPathToFile($file);
if (file_exists($path)) { if (file_exists($path)) {
if (!empty($_GET['download'])) { if (!empty($_GET['download'])) {
if(!CustomizeUser::canDownloadVideos()){ if(!CustomizeUser::canDownloadVideos()){