1
0
Fork 0
mirror of https://github.com/DanielnetoDotCom/YouPHPTube synced 2025-10-03 09:49:28 +02:00
This commit is contained in:
Daniel Neto 2023-06-23 12:08:57 -03:00
parent 4a3c059174
commit 20a971ae4f
34 changed files with 1162 additions and 861 deletions

View file

@ -133,7 +133,7 @@ Options All -Indexes
RewriteRule ^videoOnly/?$ view/?type=video [NC,L]
RewriteRule ^audioOnly/?$ view/?type=audio [NC,L]
RewriteRule ^download$ view/downloadExternalVideo.php [NC,L]
RewriteRule ^info$ view/info.php [NC,L]
RewriteRule ^info$ view/info.php [QSA,L]
RewriteRule ^version$ view/info.php?version=1 [NC,L]
RewriteRule ^downloadNow$ objects/downloadVideo.php [NC,L]
RewriteRule ^getDownloadProgress$ objects/downloadVideoProgress.php [NC,L]

BIN
install/assets/Arial.ttf Normal file

Binary file not shown.

View file

View file

@ -0,0 +1,2 @@
WEBVTT

BIN
install/assets/testMP3.mp3 Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 307 KiB

194
install/populateForTest.php Normal file
View file

@ -0,0 +1,194 @@
<?php
require_once '../videos/configuration.php';
if (!isCommandLineInterface()) {
return die('Command Line only');
}
error_reporting(E_ALL);
ini_set('display_errors', 1);
$_SESSION['user'] = array();
$_SESSION['user']['id'] = 1;
ob_end_flush();
$videoFile = 'assets/testVideo.mp4';
$audioFile = 'assets/testMP3.mp3';
$spritFile = 'assets/thumbsSprit.jpg';
$subtitleSRT = 'assets/subtitle.srt';
$subtitleVTT = 'assets/subtitle.vtt';
$totalVideos = 50;
$totalPlaylists = 10;
$totalVideosPerPlaylist = 30;
$totalCategories = 10;
$totalSubCategories = 5;
/*
for ($i = 0; $i < $totalCategories; $i++) {
$date = date('Y/m/d H:i:s');
$catTitle = "$i Auto Category $date";
$catCleanTitle = "{$i}-Auto-Category-".date('YmdHis');
$cat = new Category(0);
$cat->setName($catTitle);
$cat->setClean_name($catCleanTitle);
$parentId = $cat->save(true);
echo "pupulating [$totalVideos/$i] category saved [id=$parentId]" . PHP_EOL;
for ($j = 0; $j < $totalSubCategories; $j++) {
$catTitle = "$i Auto SubCategory $date";
$catCleanTitle = "{$i}-Auto-SubCategory-".date('YmdHis');
$cat = new Category(0);
$cat->setName($catTitle);
$cat->setClean_name($catCleanTitle);
$cat->setParentId($parentId);
$id = $cat->save(true);
echo "pupulating [$totalVideos/$i] subcategory saved [id=$id]" . PHP_EOL;
}
}
echo "pupulating ... ";
$cats = Category::getAllCategories();
echo "pupulating ... ".__LINE__;
$videos = Video::getAllVideosLight('');
echo "pupulating ... ".__LINE__;
$total = count($videos);
echo "[{$total}/{$key}] pupulating video start ";
foreach ($videos as $key => $value) {
$video = new Video('', '', $value['id']);
$index = array_rand($cats);
$video->setCategories_id($cats[$index]['id']);
$id = $video->save(false, true);
echo "[{$total}/{$key}] pupulating video category saved [id=$id catId={$cats[$index]['id']}]" . PHP_EOL;
}
exit;
$newVideosIds = array();
// create videos
for ($i = 0; $i < $totalVideos; $i++) {
$date = date('Y/m/d H:i:s');
$title = "[$i] Auto {$date}";
$filename = "testvideo{$i}_" . uniqid();
$video = new Video($title, $filename);
$video->setDuration("00:00:45");
$video->setType('video');
$video->setDuration_in_seconds(45);
$video->setDescription($title);
$video->setUsers_id(1);
$index = array_rand($cats);
$video->setCategories_id($cats[$index]['id']);
$video->setStatus(Video::$statusActive);
$video->setFilesize(2858747);
$video->setLikes(rand(0, 1000));
$video->setDislikes(rand(0, 1000));
$path = Video::getPathToFile($filename, true);
$mp4Filename = "{$path}_480.mp4";
$mp3Filename = "{$path}.mp3";
$jpgFilename = "{$path}.jpg";
$spritFilename = "{$path}_thumbsSprit.jpg";
$subtitleSRTFilename = "{$path}.srt";
$subtitleVTTFilename = "{$path}.vtt";
createImageWithText("[$i] Auto Pupulated", $date, $jpgFilename);
copy($videoFile, $mp4Filename);
copy($audioFile, $mp3Filename);
copy($spritFile, $spritFilename);
copy($subtitleSRT, $subtitleSRTFilename);
copy($subtitleVTT, $subtitleVTTFilename);
$id = $video->save(false, true);
$newVideosIds[] = $id;
echo "pupulating [$totalVideos/$i] Video saved [id=$id]" . PHP_EOL;
}
AVideoPlugin::loadPlugin('PlayLists');
for ($i = 0; $i < $totalPlaylists; $i++) {
$name = "Playlist test autogenerated $i " . date('Y/m/d H:i:s');
$playlist = new PlayList(0);
$playlist->setName($name);
$playlist->setStatus('a');
$id = $playlist->save();
echo "pupulating [$totalPlaylists/$i] Playlist saved [id=$id]" . PHP_EOL;
for ($j = 0; $j < $totalVideosPerPlaylist; $j++) {
$playList = new PlayList($id);
$playList->addVideo($newVideosIds[array_rand($newVideosIds)], 1);
echo "pupulating [$totalVideosPerPlaylist/$j] Video added in a Playlist" . PHP_EOL;
}
}
die();
function createImageWithText($text1, $text2, $filename)
{
// Create a blank image
$width = 640;
$height = 360;
$image = imagecreatetruecolor($width, $height);
// Allocate a color for the background and fill the background
$red = rand(0, 255);
$green = rand(0, 255);
$blue = rand(0, 255);
$backgroundColor = imagecolorallocate($image, $red, $green, $blue);
imagefilledrectangle($image, 0, 0, $width, $height, $backgroundColor);
// Calculate the luminance of the background color
$luminance = (0.299 * $red + 0.587 * $green + 0.114 * $blue) / 255;
// Allocate a color for the text
if ($luminance > 0.5) {
$textColor = imagecolorallocate($image, 0, 0, 0); // Use black text for a light background
} else {
$textColor = imagecolorallocate($image, 255, 255, 255); // Use white text for a dark background
}
// Font size and path
$fontSize = 48;
$fontPath = 'assets/Arial.ttf';
// Calculate x position of the first line of text
$box1 = imagettfbbox($fontSize, 0, $fontPath, $text1);
$textWidth1 = $box1[2] - $box1[0];
$x1 = ($width - $textWidth1) / 2;
// Calculate x position of the second line of text
$box2 = imagettfbbox($fontSize, 0, $fontPath, $text2);
$textWidth2 = $box2[2] - $box2[0];
$x2 = ($width - $textWidth2) / 2;
// Y positions for each line of text
$y1 = ceil($height / 3);
$y2 = $y1 * 2;
// Add the text to the image
imagettftext($image, $fontSize, 0, $x1, $y1, $textColor, $fontPath, $text1);
imagettftext($image, $fontSize, 0, $x2, $y2, $textColor, $fontPath, $text2);
// Save the image
imagejpeg($image, $filename);
// Free up memory
imagedestroy($image);
}
*/
/*
AVideoPlugin::loadPlugin('PlayLists');
$pls = PlayList::getAll();
$videos = Video::getAllVideosLight('');
$total = count($videos);
foreach ($pls as $key => $value) {
echo "[{$total}/{$key}] playlists_id={$value['id']} pupulating video start " . PHP_EOL;
for ($j = 0; $j < 50; $j++) {
$playlist = new PlayList($value['id']);
$index = array_rand($videos);
$videos_id = $videos[$index]['id'];
echo "[{$total}/{$key}/{$j}] pupulating [$videos_id] type={$videos[$index]['type']} Video added in a Playlist start" . PHP_EOL;
$playlist->addVideo($videos[$index]['id'], 1, 0, false);
echo "[{$total}/{$key}/{$j}] pupulating done [$videos_id] Video added in a Playlist" . PHP_EOL;
}
}
*/

View file

@ -73,7 +73,6 @@ class Category {
public function setClean_name($clean_name) {
$clean_name = preg_replace('/\W+/', '-', strtolower(cleanString($clean_name)));
$this->clean_name = _substr($clean_name, 0, 45);
;
}
public function setNextVideoOrder($nextVideoOrder) {
@ -471,7 +470,7 @@ class Category {
//_error_log("getAllCategories id={$row['id']} line=".__LINE__);
$row['hierarchyAndName'] = $row['hierarchy'] . __($row['name']);
//_error_log("getAllCategories id={$row['id']} line=".__LINE__);
$row['description_html'] = textToLink(htmlentities($row['description']));
$row['description_html'] = textToLink(htmlentities("{$row['description']}"));
$category[] = $row;
}

View file

@ -388,6 +388,9 @@ function getRealIpAddr()
function cleanString($text)
{
if(empty($text)){
return '';
}
$utf8 = [
'/[áaâaaäą]/u' => 'a',
'/[ÁAÂAÄĄ]/u' => 'A',
@ -1674,6 +1677,9 @@ function getResolutionFromFilename($filename)
return $getResolutionFromFilenameArray[$filename];
}
if(empty($filename)){
return 0;
}
if (!preg_match('/^http/i', $filename) && !file_exists($filename)) {
return 0;
}
@ -10132,7 +10138,7 @@ function forbiddenPageIfCannotEmbed($videos_id)
$reason[] = __('Admin block video sharing');
}
if (!CustomizeUser::canShareVideosFromVideo($videos_id)) {
error_log("forbiddenPageIfCannotEmbed: Embed is forbidden: !CustomizeUser::canShareVideosFromVideo({$video['id']})");
error_log("forbiddenPageIfCannotEmbed: Embed is forbidden: !CustomizeUser::canShareVideosFromVideo({$videos_id})");
$reason[] = __('User block video sharing');
}
forbiddenPage("Embed is forbidden " . implode('<br>', $reason));
@ -11199,3 +11205,33 @@ function getImageOrientation($imagePath) {
}
}
function canSearchUsers(){
global $advancedCustomUser;
if(canAdminUsers()){
return true;
}
if(AVideoPlugin::isEnabledByName('PlayLists')){
if(PlayLists::canManageAllPlaylists()){
return true;
}
}
if (empty($advancedCustomUser)) {
$advancedCustomUser = AVideoPlugin::getObjectDataIfEnabled('CustomizeUser');
}
if($advancedCustomUser->userCanChangeVideoOwner){
return true;
}
return false;
}
function canAdminUsers(){
if(Permissions::canAdminUsers()){
return true;
}
if(AVideoPlugin::isEnabledByName('PayPerView')){
if(PayPerView::canSeePPVManagementInfo()){
return true;
}
}
return false;
}

View file

@ -469,7 +469,7 @@ class PlayList extends ObjectYPT {
$row['humancreate'] = humanTiming(strtotime($row['cre']));
}
$images = Video::getImageFromFilename($row['filename'], $row['type']);
if (!file_exists($images->posterLandscapePath) && !empty($row['serie_playlists_id'])) {
if (is_object($images) && !empty($images->posterLandscapePath) && !file_exists($images->posterLandscapePath) && !empty($row['serie_playlists_id'])) {
$images = self::getRandomImageFromPlayList($row['serie_playlists_id']);
}
$row['images'] = $images;
@ -729,6 +729,7 @@ class PlayList extends ObjectYPT {
if (!empty($playlists_id)) {
self::deleteCacheDir($playlists_id);
}
$this->id = $playlists_id;
return $playlists_id;
}

View file

@ -10,20 +10,16 @@ if (!User::isLogged()) {
die('{"error":"'.__("Permission denied").'"}');
}
if (empty($_POST['playlist_id']) && !empty($_GET['playlist_id'])) {
$_POST['playlist_id'] = intval($_GET['playlist_id']);
}
$obj = new PlayList($_POST['playlist_id']);
if (User::getId() !== $obj->getUsers_id()) {
if (!PlayLists::canManagePlaylist($_REQUEST['playlist_id'])) {
die('{"error":"'.__("Permission denied").'"}');
}
$obj = new PlayList($_REQUEST['playlist_id']);
$count = 1;
if (empty($_POST['list'])) {
// get all videos from playlist
$videosArrayId = PlayList::getVideosIdFromPlaylist($_POST['playlist_id']);
$videosArrayId = PlayList::getVideosIdFromPlaylist($_REQUEST['playlist_id']);
$videos = [];
foreach ($videosArrayId as $value) {
$videos[] = Video::getVideoLight($value);

View file

@ -341,7 +341,7 @@ if (typeof gtag !== \"function\") {
public static function _recommendChannelName($name = "", $try = 0, $unknown = "", $users_id = 0) {
$name = preg_replace('/\s+/', '', $name);
$name = preg_replace('/\s+/', '', "{$name}");
if (empty($users_id)) {
if (!empty(User::getId())) {
$users_id = User::getId();
@ -694,7 +694,7 @@ if (typeof gtag !== \"function\") {
$password = ($this->password);
$name = ($this->name);
$status = ($this->status);
$this->about = preg_replace("/(\\\)+n/", "\n", $this->about);
$this->about = preg_replace("/(\\\)+n/", "\n", "{$this->about}");
$this->channelName = self::_recommendChannelName($this->channelName, 0, $this->user, $this->id);
$channelName = ($this->channelName);
if (filter_var($this->donationLink, FILTER_VALIDATE_URL) === false) {
@ -749,6 +749,8 @@ if (typeof gtag !== \"function\") {
. " status,photoURL,recoverPass, created, modified, channelName, analyticsCode, externalOptions, phone, is_company,emailVerified) "
. " VALUES (?,?,?,?,?,?,?,?, false, "
. "?,?,?, now(), now(),?,?,?,?," . (empty($this->is_company) ? 'NULL' : intval($this->is_company)) . ",?)";
_error_log("Insert new user user=$user, email={$this->email}, name=$name ". json_encode(debug_backtrace()));
}
$insert_row = sqlDAL::writeSql($sql, $formats, $values);
@ -771,6 +773,7 @@ if (typeof gtag !== \"function\") {
// update the user groups
UserGroups::updateUserGroups($id, $this->userGroups);
}
$this->id = $id;
return $id;
} else {
_error_log(' Error : (' . $global['mysqli']->errno . ') ' . $global['mysqli']->error . " $sql");
@ -1188,7 +1191,7 @@ if (typeof gtag !== \"function\") {
return !empty($_SESSION['user']['emailVerified']);
}
public static function isAdmin($users_id = 0) {
public static function isAdmin($users_id = 0) : bool {
if (!empty($users_id)) {
$user = new User($users_id);
return !empty($user->getIsAdmin());

View file

@ -16,6 +16,15 @@ $obj->status = 0;
if (!Permissions::canAdminUsers()) {
forbiddenPage();
}
if(empty($_REQUEST['securityToken'])){
forbiddenPage('Security token is empty');
}
if(!isTokenValid($_REQUEST['securityToken'])){
forbiddenPage('Security token is invalid');
}
session_write_close();
if (!empty($advancedCustomUser->forceLoginToBeTheEmail)) {
$_POST['email'] = $_POST['user'];
@ -34,7 +43,7 @@ $user->setEmail($_POST['email']);
$user->setName($_POST['name']);
$user->setIsAdmin($_POST['isAdmin']);
$user->setCanStream($_POST['canStream']);
$user->setIs_company($_POST['is_company']);
$user->setIs_company(@$_POST['is_company']);
$user->setCanUpload($_POST['canUpload']);
$user->setCanViewChart($_POST['canViewChart']);
$user->setCanCreateMeet($_POST['canCreateMeet']);

View file

@ -54,9 +54,6 @@ class UserGroups{
public function save()
{
global $global;
if (empty($this->isAdmin)) {
$this->isAdmin = "false";
}
$formats = '';
$values = [];
$this->group_name = _substr($this->group_name, 0, 255);

View file

@ -8,7 +8,7 @@ require_once $global['systemRootPath'] . 'videos/configuration.php';
require_once $global['systemRootPath'] . 'objects/user.php';
header('Content-Type: application/json');
$canAdminUsers = Permissions::canAdminUsers();
$canAdminUsers = canAdminUsers();
if (empty($_POST['current'])) {
$_POST['current'] = 1;
}
@ -29,7 +29,7 @@ if (!empty($_REQUEST['users_id'])) {
//echo __LINE__, PHP_EOL;
$isAdmin = null;
$isCompany = null;
$ignoreAdmin = $advancedCustomUser->userCanChangeVideoOwner ? true : false;
$ignoreAdmin = canSearchUsers() ? true : false;
if (isset($_REQUEST['isAdmin'])) {
$isAdmin = 1;
}
@ -48,8 +48,8 @@ if (!empty($_REQUEST['users_id'])) {
$total = User::getTotalUsers($ignoreAdmin, @$_GET['status'], $isAdmin, $isCompany);
} else {
//echo __LINE__, PHP_EOL;
$users = User::getAllUsersFromUsergroup($_REQUEST['user_groups_id'], $advancedCustomUser->userCanChangeVideoOwner ? true : false, ['name', 'email', 'user', 'channelName', 'about'], @$_GET['status']);
$total = User::getTotalUsersFromUsergroup($_REQUEST['user_groups_id'], $advancedCustomUser->userCanChangeVideoOwner ? true : false, @$_GET['status']);
$users = User::getAllUsersFromUsergroup($_REQUEST['user_groups_id'], canSearchUsers() ? true : false, ['name', 'email', 'user', 'channelName', 'about'], @$_GET['status']);
$total = User::getTotalUsersFromUsergroup($_REQUEST['user_groups_id'], canSearchUsers() ? true : false, @$_GET['status']);
}
//echo examineJSONError($users);exit;

View file

@ -645,9 +645,9 @@ if (!class_exists('Video')) {
public function setDuration($duration) {
if (!self::isValidDuration($this->duration) || self::isValidDuration($duration)) {
_error_log("setDuration before {$duration}");
//_error_log("setDuration before {$duration}");
AVideoPlugin::onVideoSetDuration($this->id, $this->duration, $duration);
_error_log("setDuration after {$duration}");
//_error_log("setDuration after {$duration}");
$this->duration = $duration;
} else {
_error_log("setDuration error is not a valid {$duration}, old duration = {$this->duration}");
@ -1669,7 +1669,7 @@ if (!class_exists('Video')) {
$timeLogName = TimeLogStart("video::getInfo getStatistcs");
$name = "_getVideoInfo_{$row['id']}";
$OneHour = 3600;
$cache = ObjectYPT::getCache($name, $OneHour);
$cache = ObjectYPT::getCacheGlobal($name, $OneHour);
if (!empty($cache)) {
$externalOptions = $cache->externalOptions;
$obj = object_to_array($cache);
@ -1733,7 +1733,7 @@ if (!class_exists('Video')) {
}
TimeLogEnd($timeLogName, __LINE__, $TimeLogLimit);
$otherInfocachename = "otherInfo{$row['id']}";
$otherInfo = object_to_array(ObjectYPT::getCache($otherInfocachename, 600));
$otherInfo = object_to_array(ObjectYPT::getCacheGlobal($otherInfocachename, 600));
TimeLogEnd($timeLogName, __LINE__, $TimeLogLimit);
if (empty($otherInfo)) {
$otherInfo = [];
@ -1743,7 +1743,7 @@ if (!class_exists('Video')) {
//TimeLogEnd("video::otherInfo", __LINE__, 0.05);
$otherInfo['tags'] = self::getTags($row['id']);
//TimeLogEnd("video::otherInfo", __LINE__, 0.05);
$cached = ObjectYPT::setCache($otherInfocachename, $otherInfo);
$cached = ObjectYPT::setCacheGlobal($otherInfocachename, $otherInfo);
//TimeLogEnd("video::otherInfo", __LINE__, 0.05);
//_error_log("video::getInfo cache " . json_encode($cached));
}
@ -1786,7 +1786,7 @@ if (!class_exists('Video')) {
//var_dump($row['userExternalOptions']);exit;
$row = array_merge($row, AVideoPlugin::getAllVideosArray($row['id']));
TimeLogEnd($timeLogName, __LINE__, $TimeLogLimit);
ObjectYPT::setCache($name, $row);
ObjectYPT::setCacheGlobal($name, $row);
TimeLogEnd($timeLogName, __LINE__, $TimeLogLimit);
if (self::forceAudio()) {
@ -5344,7 +5344,7 @@ if (!class_exists('Video')) {
} else {
if (self::userGroupAndVideoGroupMatch($users_id, $videos_id)) {
$videosug = self::getVideoGroups($videos_id);
$categoriessug = self::getCategoriesGroups($videos_id);
$categoriessug = UserGroups::getCategoriesGroups($videos_id);
$rowsUser = UserGroups::getUserGroups(User::getId());
// what group the user needs
}
@ -5355,12 +5355,12 @@ if (!class_exists('Video')) {
if ($p = AVideoPlugin::loadPluginIfEnabled($name)) {
$obj = $p->getDataObject();
if ($obj->ifExceedQuotaDoNotPlayVideos) {
if ($this->videoOwnerExceedsQuota($videos_id)) {
if ($p->videoOwnerExceedsQuota($videos_id)) {
$response->canWatch = false;
$response->why[] = 'DiskUploadQuota videoOwnerExceedsQuota and ifExceedQuotaDoNotPlayVideos';
}
} else {
if ($this->videoOwnerExceedsQuota($videos_id)) {
if ($p->videoOwnerExceedsQuota($videos_id)) {
$response->why[] = 'DiskUploadQuota is active but the owner still have quota';
} else {
$response->why[] = 'DiskUploadQuota is active but the owner quota os gone but ifExceedQuotaDoNotPlayVideos is deactivated';

View file

@ -327,6 +327,9 @@ class AVideoPlugin
public static function getHTMLMenuRight()
{
$name = "getHTMLMenuRight" . User::getId();
$str = ObjectYPT::getCache($name, 3600);
if (empty($str)) {
$plugins = Plugin::getAllEnabled();
$str = "";
foreach ($plugins as $value) {
@ -337,6 +340,9 @@ class AVideoPlugin
}
self::YPTend("{$value['dirName']}::" . __FUNCTION__);
}
ObjectYPT::setCache($name, $str);
}
return $str;
}

View file

@ -575,7 +575,7 @@ class Layout extends PluginAbstract
return $content;
}
static function getUserAutocomplete($default_users_id = 0, $id = '', $parameters = array())
static function getUserAutocomplete($default_users_id = 0, $id = '', $parameters = array(), $jsFunctionForSelectCallback = '')
{
global $global;
$default_users_id = intval($default_users_id);

View file

@ -95,6 +95,11 @@ if (empty($name)) {
photoURL = ui.item.photo;
}
$("#user-img<?php echo $id; ?>").attr("src", photoURL);
<?php
if(!empty($jsFunctionForSelectCallback)){
echo $jsFunctionForSelectCallback.';';
}
?>
return false;
}
}).autocomplete("instance")._renderItem = function (ul, item) {

View file

@ -129,6 +129,7 @@ Passcode: {password}
"sub" => "meet.jitsi",
"room" => $room,
"exp" => strtotime("+30 hours"),
"nbf" => strtotime("-24 hours"),
"moderator" => $isModerator,
];
return $jitsiPayload; // HS256

View file

@ -30,7 +30,9 @@ if (empty($obj->key) || strlen($obj->key) < 50) {
if (empty($server)) {
$obj->msg = "The server URL is empty";
} else {
$obj->key = url_get_contents("http://key.ypt.me?server=" . urlencode($server));
$url = "http://key.ypt.me?server=" . urlencode($server);
//$obj->url = $url;
$obj->key = url_get_contents($url);
$obj->length = strlen($obj->key); // 1 day
if (!empty($obj->key) && $obj->length > 50) {
$obj->error = false;

View file

@ -17,7 +17,8 @@ class MobileYPT extends PluginAbstract {
}
public function getDescription() {
$desc = "Manage the Mobile YPTApp";
$desc = "Your Media Companion: YPT Mobile App";
$desc .= "<p>YPT Media is a dynamic mobile app for streaming high-quality videos, audios, managing playlists, supporting PPV, and live streaming. Enjoy an ad-free experience with our server hosting. <a href=\"https://github.com/WWBN/AVideo/wiki/YPT-Media-Mobile-app\">Learn more</a>.</p>";
$desc .= $this->isReadyLabel(['API']);
return $desc;
}

View file

@ -2,7 +2,7 @@
class PlayListElement {
public $name, $description, $duration, $sources, $thumbnail, $poster, $videoStartSeconds, $created, $likes, $views, $videos_id;
public $name, $description, $duration, $sources, $thumbnail, $poster, $videoStartSeconds, $created, $likes, $views, $videos_id, $className, $tracks;
function __construct($name, $description, $duration, $playListSource, $playListThumbnail, $poster, $videoStartSeconds, $created, $likes, $views, $videos_id, $className='', $tracks=array()) {
$this->name = $name;
@ -12,7 +12,7 @@ class PlayListElement {
$this->thumbnail = $playListThumbnail;
$this->poster = $poster;
$this->videoStartSeconds = intval($videoStartSeconds);
$this->created = strtotime($created);
$this->created = empty($created)?0:strtotime($created);
$this->likes = $likes;
$this->views = $views;
$this->videos_id = $videos_id;
@ -38,7 +38,7 @@ class PlayListElement {
}
function getPlayListThumbnail() {
return $this->playListThumbnail;
return $this->thumbnail;
}
function setName($name) {
@ -133,7 +133,7 @@ class PlayListElement {
class playListSource {
public $src, $type;
public $src, $type, $label;
function __construct($src, $youtube = false) {
$this->src = $src;

View file

@ -9,6 +9,8 @@ require_once $global['systemRootPath'] . 'plugin/PlayLists/PlayListElement.php';
class PlayLists extends PluginAbstract {
const PERMISSION_CAN_MANAGE_ALL_PLAYLISTS = 0;
public function getTags() {
return array(
PluginTags::$RECOMMENDED,
@ -30,6 +32,33 @@ class PlayLists extends PluginAbstract {
return "plist12345-370-4b1f-977a-fd0e5cabtube";
}
function getPermissionsOptions():array {
$permissions = array();
$permissions[] = new PluginPermissionOption(self::PERMISSION_CAN_MANAGE_ALL_PLAYLISTS, __("Can Manage All Playlists"), __("Can Manage All Playlists"), 'PlayLists');
return $permissions;
}
static function canManageAllPlaylists():bool {
if(User::isAdmin()){
return true;
}
return Permissions::hasPermission(self::PERMISSION_CAN_MANAGE_ALL_PLAYLISTS, 'PlayLists');
}
static function canManagePlaylist($playlists_id) {
if (!User::isLogged()) {
return false;
}
if (self::canManageAllPlaylists()) {
return true;
}
$pl = new PlayList($playlists_id);
if ($pl->getUsers_id() == User::getId()) {
return true;
}
return false;
}
public function getPluginVersion() {
return "1.0";
}
@ -564,20 +593,6 @@ class PlayLists extends PluginAbstract {
return !empty($obj->showTVFeatures);
}
static function canManagePlaylist($playlists_id) {
if (!User::isLogged()) {
return false;
}
if (User::isAdmin()) {
return true;
}
$pl = new PlayList($playlists_id);
if ($pl->getUsers_id() == User::getId()) {
return true;
}
return false;
}
static function getShowOnTVSwitch($playlists_id) {
if (!self::showTVFeatures()) {
return "";
@ -1002,9 +1017,10 @@ class PlayListPlayer {
$playListData = array();
}
foreach ($this->videos as $key => $video) {
if ($video['type'] === 'embed') {
$sources[0]['type'] = 'video';
$sources[0]['url'] = $video["videoLink"];
$sources[0]['url'] = @$video["videoLink"];
} else {
$sources = getVideosURL($video['filename']);
}
@ -1027,7 +1043,7 @@ class PlayListPlayer {
$messagesFromPlayList[] = "videos_id={$video['videos_id']} empty playlist source ";
continue;
}
$playListData[] = new PlayListElement($video['title'], $video['description'], $video['duration'], $playListSources, $thumbnail, $images->poster, parseDurationToSeconds(@$externalOptions->videoStartSeconds), @$video['created'], $video['likes'], $video['views_count'], $video['videos_id']);
$playListData[] = new PlayListElement($video['title'], $video['description'], @$video['duration'], $playListSources, $thumbnail, $images->poster, parseDurationToSeconds(@$externalOptions->videoStartSeconds), @$video['created'], @$video['likes'], @$video['views_count'], $video['videos_id']);
}
return $playListData;
}

View file

@ -9,8 +9,6 @@ $program = PlayList::getFromDbFromId($playlists_id);
if(empty($program)){
return;
}
//var_dump($playlists_id, $program);
$isMyChannel = $program['users_id'] == User::getId();
$playListButtons = AVideoPlugin::getPlayListButtons($playlists_id);
$link = PlayLists::getLink($program['id']);
@ -28,7 +26,7 @@ if (empty($isASerie)) {
<?php echo $playListButtons; ?>
<?php
echo PlayLists::getPlayLiveButton($program['id']);
if ($isMyChannel) {
if (PlayLists::canManagePlaylist($playlists_id)) {
?>
<script>
$(function () {

View file

@ -7,13 +7,20 @@ require_once $global['systemRootPath'] . 'objects/user.php';
if (!User::isLogged()) {
gotToLoginAndComeBackHere('');
}
$users_id = User::getId();
if(User::isAdmin() && !empty($_REQUEST['users_id'])){
$users_id = $_REQUEST['users_id'];
function getPlaylistOwnerUsersId(){
if(!empty($_REQUEST['PlaylistOwnerUsersId'])){
return intval($_REQUEST['PlaylistOwnerUsersId']);
}else if (User::isAdmin() && !empty($_REQUEST['users_id'])) {
return intval($_REQUEST['users_id']);
}
return User::getId();
}
$users_id = getPlaylistOwnerUsersId();
?>
<!DOCTYPE html>
<html lang="<?php echo getLanguage(); ?>">
<head>
<title><?php echo __("Users") . $config->getPageTitleSeparator() . $config->getWebSiteTitle(); ?></title>
<?php
@ -24,6 +31,7 @@ if(User::isAdmin() && !empty($_REQUEST['users_id'])){
.playLists li {
min-height: 45px;
}
.playLists .list-group {
height: 221px;
overflow: auto;
@ -41,11 +49,13 @@ if(User::isAdmin() && !empty($_REQUEST['users_id'])){
.playLists {
min-height: 330px;
}
.pl .panel-footer {
min-height: 42px;
}
</style>
</head>
<body class="<?php echo $global['bodyClass']; ?>">
<?php
include $global['systemRootPath'] . 'view/include/navbar.php';
@ -56,29 +66,41 @@ if(User::isAdmin() && !empty($_REQUEST['users_id'])){
<div class="panel">
<div class="panel-heading">
<ul class="nav nav-tabs">
<li class="active pl_filter" onclick="pl_filter('all', $(this));" data-toggle="tooltip"
title="<?php echo __('Show all types'); ?>">
<li class="active pl_filter" onclick="pl_filter('all', $(this));" data-toggle="tooltip" title="<?php echo __('Show all types'); ?>">
<a href="#"><i class="fas fa-layer-group"></i>
<i class="fas fa-list"></i>
<i class="fas fa-film"></i> <?php echo __('All'); ?></a></li>
<li class="pl_filter" onclick="pl_filter('serie', $(this));" data-toggle="tooltip"
title="<?php echo __('Show all programs that are listed in your video library'); ?>">
<i class="fas fa-film"></i> <?php echo __('All'); ?></a>
</li>
<li class="pl_filter" onclick="pl_filter('serie', $(this));" data-toggle="tooltip" title="<?php echo __('Show all programs that are listed in your video library'); ?>">
<a href="#"><span class="label label-success"><i class="fas fa-list"></i>
<?php echo __('Series'); ?></span></a></li>
<li class="pl_filter" onclick="pl_filter('collection', $(this));" data-toggle="tooltip"
title="<?php echo __('Show all that is a collection of programs'); ?>">
<?php echo __('Series'); ?></span></a>
</li>
<li class="pl_filter" onclick="pl_filter('collection', $(this));" data-toggle="tooltip" title="<?php echo __('Show all that is a collection of programs'); ?>">
<a href="#"><span class="label label-primary"><i class="fas fa-layer-group"></i>
<?php echo __('Collections'); ?></span></a></li>
<li class="pl_filter" onclick="pl_filter('videos', $(this));" data-toggle="tooltip"
title="<?php echo __('Show all that include a list of videos'); ?>">
<?php echo __('Collections'); ?></span></a>
</li>
<li class="pl_filter" onclick="pl_filter('videos', $(this));" data-toggle="tooltip" title="<?php echo __('Show all that include a list of videos'); ?>">
<a href="#"><span class="label label-default"><i class="fas fa-film"></i>
<?php echo __('Videos'); ?></span></a></li>
<?php echo __('Videos'); ?></span></a>
</li>
<li class="pull-right">
<button type="button" class="btn btn-default pull-right" data-toggle="tooltip" title="<?php echo __('New'); ?>"
onclick="createNewProgram();" >
<button type="button" class="btn btn-default pull-right" data-toggle="tooltip" title="<?php echo __('New'); ?>" onclick="createNewProgram();">
<i class="fas fa-plus"></i>
</button>
</li>
<?php
if (PlayLists::canManageAllPlaylists()) {
?>
<li class="pull-right">
<?php
if (PlayLists::canManageAllPlaylists()) {
$autocomplete = Layout::getUserAutocomplete(getPlaylistOwnerUsersId(), 'User_playlist_owner', array(), 'updatePlaylistOwner()');
}
?>
</li>
<?php
}
?>
</ul>
</div>
<div class="panel-body">
@ -123,17 +145,13 @@ if(User::isAdmin() && !empty($_REQUEST['users_id'])){
?>
<div class="btn-group pull-right" playlists_id="<?php echo $value["id"]; ?>">
<button type="button" class="btn btn-default btn-xs pull-right" data-toggle="tooltip"
title="<?php echo __('Delete'); ?>"
onclick="deleteProgram(<?php echo $value["id"]; ?>);" >
<button type="button" class="btn btn-default btn-xs pull-right" data-toggle="tooltip" title="<?php echo __('Delete'); ?>" onclick="deleteProgram(<?php echo $value["id"]; ?>);">
<i class="fas fa-trash"></i>
</button>
<button type="button" class="btn btn-default btn-xs pull-right" data-toggle="tooltip"
title="<?php echo __('Play'); ?>" onclick="avideoModalIframe('<?php echo PlayLists::getLink($value["id"], true); ?>');" >
<button type="button" class="btn btn-default btn-xs pull-right" data-toggle="tooltip" title="<?php echo __('Play'); ?>" onclick="avideoModalIframe('<?php echo PlayLists::getLink($value["id"], true); ?>');">
<i class="fas fa-play"></i>
</button>
<button type="button" class="btn btn-default btn-xs editBtn " onclick="editPlayList(<?php echo $value["id"]; ?>);" data-toggle="tooltip"
title="<?php echo __('Edit'); ?>" >
<button type="button" class="btn btn-default btn-xs editBtn " onclick="editPlayList(<?php echo $value["id"]; ?>);" data-toggle="tooltip" title="<?php echo __('Edit'); ?>">
<i class="fas fa-edit"></i>
</button>
</div>
@ -227,19 +245,13 @@ if(User::isAdmin() && !empty($_REQUEST['users_id'])){
echo $row['title'];
?>
</div>
<button type="button" class="btn btn-default btn-xs pull-right"
data-toggle="tooltip" title="<?php echo __('Remove Video'); ?>"
onclick="removeFromSerie(<?php echo $value["id"]; ?>, <?php echo $row["id"]; ?>);" >
<button type="button" class="btn btn-default btn-xs pull-right" data-toggle="tooltip" title="<?php echo __('Remove Video'); ?>" onclick="removeFromSerie(<?php echo $value["id"]; ?>, <?php echo $row["id"]; ?>);">
<i class="fas fa-trash"></i>
</button>
<button type="button" class="btn btn-default btn-xs pull-right"
data-toggle="tooltip" title="<?php echo __('Play Video'); ?>"
onclick="avideoModalIframe('<?php echo Video::getPermaLink($row["id"], true); ?>');" >
<button type="button" class="btn btn-default btn-xs pull-right" data-toggle="tooltip" title="<?php echo __('Play Video'); ?>" onclick="avideoModalIframe('<?php echo Video::getPermaLink($row["id"], true); ?>');">
<i class="fas fa-play"></i>
</button>
<button type="button" class="btn btn-default btn-xs pull-right"
data-toggle="tooltip" title="<?php echo __('Edit Video'); ?>"
onclick="avideoModalIframe(webSiteRootURL+'view/managerVideosLight.php?avideoIframe=1&videos_id=<?php echo $row['id']; ?>');" >
<button type="button" class="btn btn-default btn-xs pull-right" data-toggle="tooltip" title="<?php echo __('Edit Video'); ?>" onclick="avideoModalIframe(webSiteRootURL+'view/managerVideosLight.php?avideoIframe=1&videos_id=<?php echo $row['id']; ?>');">
<i class="fas fa-edit"></i>
</button>
</li>
@ -276,6 +288,15 @@ if(User::isAdmin() && !empty($_REQUEST['users_id'])){
</div>
</div>
<?php
if($count % 2 == 0){
echo '<div class="clearfix visible-sm"></div>';
}
if($count % 3 == 0){
echo '<div class="clearfix visible-md"></div>';
}
if($count % 4 == 0){
echo '<div class="clearfix visible-lg"></div>';
}
}
if (empty($count)) {
?>
@ -301,6 +322,14 @@ if(User::isAdmin() && !empty($_REQUEST['users_id'])){
});
function updatePlaylistOwner(){
modal.showPleaseWait();
var url = window.location.href;
url = addQueryStringParameter(url, 'PlaylistOwnerUsersId', $('#User_playlist_owner').val());
console.log('updatePlaylistOwner', url);
window.location.href = url;
}
function pl_filter(filter, t) {
$('.pl_filter').removeClass('active');
t.addClass('active');
@ -408,4 +437,5 @@ if(User::isAdmin() && !empty($_REQUEST['users_id'])){
}
</script>
</body>
</html>

View file

@ -38,6 +38,7 @@ $playListsObj = AVideoPlugin::getObjectData("PlayLists");
?>
<!DOCTYPE html>
<html lang="<?php echo getLanguage(); ?>">
<head>
<title><?php echo __("Program") . $config->getPageTitleSeparator() . $config->getWebSiteTitle(); ?></title>
<?php
@ -48,6 +49,7 @@ $playListsObj = AVideoPlugin::getObjectData("PlayLists");
border-color: transparent;
box-shadow: none;
}
.galleryVideo .panel .panel-body {
padding: 5px;
}
@ -201,7 +203,7 @@ $playListsObj = AVideoPlugin::getObjectData("PlayLists");
<div>
<span playlist_id="<?php echo $program['id']; ?>" video_id="<?php echo $value['id']; ?>">
<i class="fas fa-sort-numeric-down"></i> <?php echo __("Sort"); ?>
<input type="number" step="1" class="video_order" value="<?php echo intval($program['videos'][$count - 1]['video_order']); ?>" style="max-width: 50px;">
<input type="number" step="1" class="video_order" value="<?php echo empty($program['videos'][$count - 1]) ? 0 : intval(@$program['videos'][$count - 1]['video_order']); ?>" style="max-width: 50px;">
<button class="btn btn-sm btn-xs sortNow"><i class="fas fa-check-square"></i></button>
</span>
</div>
@ -253,8 +255,8 @@ $playListsObj = AVideoPlugin::getObjectData("PlayLists");
?>
<script>
var timoutembed;
function setTextEmbedCopied() {
clearTimeout(timoutembed);
$("#btnEmbedText").html("<?php echo __("Copied!"); ?>");
@ -451,8 +453,7 @@ if (count($programs) <= 1 || !empty($palyListsObj->expandPlayListOnChannels)) {
swal.close();
}
modal.hidePleaseWait();
});
;
});;
});
@ -485,4 +486,5 @@ if (count($programs) <= 1 || !empty($palyListsObj->expandPlayListOnChannels)) {
include $global['systemRootPath'] . 'view/include/footer.php';
?>
</body>
</html>

View file

@ -26,7 +26,7 @@ if (file_exists($extraPluginFile) && AVideoPlugin::isEnabledByName("Customize"))
TimeLogEnd($timeLogHead, __LINE__);
if (!empty($poster)) {
$subTitle = str_replace(['"', "\n", "\r"], ["", "", ""], strip_tags($video['description']));
$subTitle = str_replace(['"', "\n", "\r"], ["", "", ""], strip_tags("{$video['description']}"));
$custom = [];
$custom[] = $subTitle;
if (!empty($video["category"])) {

View file

@ -73,25 +73,27 @@ if (!empty($videoSerie)) {
$indicator = '<span class="fa fa-play text-danger"></span>';
} ?>
<li class="<?php echo $class; ?>">
<a href="<?php echo $global['webSiteRootURL']; ?>program/<?php echo $playlist_id; ?>/<?php echo $count . "/" . urlencode(cleanURLName($value["channelName"])) . "/" . urlencode(cleanURLName($playlist->getName())) . "/{$value['clean_title']}"; ?>" title="<?php echo $value['title']; ?>" class="videoLink row">
<a href="<?php echo $global['webSiteRootURL']; ?>program/<?php echo $playlist_id; ?>/<?php echo $count . "/" . urlencode(cleanURLName(@$value["channelName"])) . "/" . urlencode(cleanURLName($playlist->getName())) . "/".(@$value['clean_title']); ?>" title="<?php echo $value['title']; ?>" class="videoLink row">
<div class="col-md-1 col-sm-1 col-xs-1">
<?php echo $indicator; ?>
</div>
<div class="col-md-3 col-sm-3 col-xs-3 nopadding">
<?php
if (($value['type'] !== "audio") && ($value['type'] !== "linkAudio")) {
if(empty($value['images']['poster'])){
$img = Video::getPoster($value['videos_id']);
}else{
$img = $value['images']['poster'];
$img_portrait = ($value['rotation'] === "90" || $value['rotation'] === "270") ? "img-portrait" : "";
}
} else {
$img = "" . getCDN() . "view/img/audio_wave.jpg";
$img_portrait = '';
} ?>
<img src="<?php echo $img; ?>" alt="<?php echo $value['title']; ?>" class="img-responsive <?php echo $img_portrait; ?> rotate<?php echo $value['rotation']; ?>" height="130" itemprop="thumbnail" />
<img src="<?php echo $img; ?>" alt="<?php echo $value['title']; ?>" class="img-responsive" height="130" itemprop="thumbnail" />
<?php
if ($value['type'] !== 'pdf' && $value['type'] !== 'article' && $value['type'] !== 'serie') {
?>
<time class="duration"><?php echo Video::getCleanDuration($value['duration']); ?></time>
<time class="duration"><?php echo Video::getCleanDuration(@$value['duration']); ?></time>
<div class="progress" style="height: 3px; margin-bottom: 2px;">
<div class="progress-bar progress-bar-danger" role="progressbar" style="width: <?php echo $value['progress']['percent'] ?>%;" aria-valuenow="<?php echo $value['progress']['percent'] ?>" aria-valuemin="0" aria-valuemax="100"></div>
</div>
@ -109,7 +111,7 @@ if (!empty($videoSerie)) {
if (empty($advancedCustom->doNotDisplayViews)) {
?>
<div>
<strong class=""><?php echo number_format($value['views_count'], 0); ?></strong> <?php echo __("Views"); ?>
<strong class=""><?php echo empty($value['views_count'])?0:number_format($value['views_count'], 0); ?></strong> <?php echo __("Views"); ?>
</div>
<?php
} ?>

View file

@ -1,6 +1,6 @@
<?php
header('Content-Type: application/json');
$cachedFile = '../videos/cache/version.cache';
$cachedFile = '../videos/cache/version'.(empty($_GET['version'])?1:0).'.cache';
if (empty($_GET['modified']) && file_exists($cachedFile)) {
$content = file_get_contents($cachedFile);

View file

@ -2169,6 +2169,7 @@ function addGetParam(_url, _key, _value) {
}
_url += sep + param;
_url = removeDuplicatedGetParam(_url);
_url = _url.replace("#?", "?");
return _url;
}

View file

@ -390,7 +390,8 @@ print AVideoPlugin::updateUserFormJS();
"status": $('#status').is(':checked') ? 'a' : 'i',
"isEmailVerified": $('#isEmailVerified').is(':checked'),
"userGroups": selectedUserGroups,
"do_not_login": 1
"do_not_login": 1,
"securityToken": '<?php echo getToken(3600); ?>'
},
type: 'post',
success: function (response) {

View file

@ -177,7 +177,7 @@ if (!empty($evideo)) {
$modeYouTubeTimeLog['Code part 2'] = microtime(true) - $modeYouTubeTime;
$modeYouTubeTime = microtime(true);
if (!empty($video)) {
if (!empty($video) && !empty($video['users_id'])) {
$name = User::getNameIdentificationById($video['users_id']);
$name = "<a href='" . User::getChannelLink($video['users_id']) . "' class='btn btn-xs btn-default'>{$name} " . User::getEmailVerifiedIcon($video['users_id']) . "</a>";
$subscribe = Subscribe::getButton($video['users_id']);
@ -241,7 +241,7 @@ if (!empty($evideo)) {
}
TimeLogEnd($timeLogNameMY, __LINE__, $TimeLogLimitMY);
if (empty($_GET['videoName']) && !empty($video)) {
if (empty($_GET['videoName']) && !empty($video) && !empty($video['clean_title'])) {
$_GET['videoName'] = $video['clean_title'];
}
if(!empty($video)){
@ -352,7 +352,6 @@ TimeLogEnd($timeLogNameMY, __LINE__, $TimeLogLimitMY);
if (empty($video['type'])) {
$video['type'] = "video";
}
$img_portrait = ($video['rotation'] === "90" || $video['rotation'] === "270") ? "img-portrait" : "";
TimeLogEnd($timeLogNameMY, __LINE__, $TimeLogLimitMY);
require "{$global['systemRootPath']}view/modeYoutubeBundle.php";