diff --git a/install/checkConfiguration.php b/install/checkConfiguration.php index e1c17e3209..e70c127d6c 100644 --- a/install/checkConfiguration.php +++ b/install/checkConfiguration.php @@ -4,7 +4,7 @@ if (file_exists("../videos/configuration.php")) { exit; } -$installationVersion = "10.2"; +$installationVersion = "10.3"; error_log("Installation: ".__LINE__." ". json_encode($_POST)); header('Content-Type: application/json'); diff --git a/install/database.sql b/install/database.sql index 46daa925f7..80a9cbf004 100644 --- a/install/database.sql +++ b/install/database.sql @@ -147,6 +147,7 @@ CREATE TABLE IF NOT EXISTS `videos` ( `encoderURL` VARCHAR(255) NULL DEFAULT NULL, `filepath` VARCHAR(255) NULL DEFAULT NULL, `filesize` BIGINT(19) UNSIGNED NULL DEFAULT 0, + `live_transmitions_history_id` INT(11) NULL DEFAULT NULL, PRIMARY KEY (`id`), INDEX `fk_videos_users_idx` (`users_id` ASC), INDEX `fk_videos_categories1_idx` (`categories_id` ASC), @@ -158,6 +159,7 @@ CREATE TABLE IF NOT EXISTS `videos` ( INDEX `video_filename_INDEX` (`filename` ASC), INDEX `video_status_idx` (`status` ASC), INDEX `video_type_idx` (`type` ASC) , + INDEX `fk_videos_live_transmitions_history1_idx` (`live_transmitions_history_id` ASC), FULLTEXT INDEX `index17vname` (`title`), FULLTEXT INDEX `index18vdesc` (`description`), CONSTRAINT `fk_videos_sites1` diff --git a/objects/functiongetPagination.php b/objects/functiongetPagination.php index 006454949c..bf487fd153 100644 --- a/objects/functiongetPagination.php +++ b/objects/functiongetPagination.php @@ -16,6 +16,7 @@ }); $container$uid.on('append.infiniteScroll', function (event, response, path, items) { lazyImage(); + avideoSocket(); }); }); diff --git a/objects/functions.php b/objects/functions.php index 474024c785..dd8c12fc37 100644 --- a/objects/functions.php +++ b/objects/functions.php @@ -3309,7 +3309,7 @@ function TimeLogStart($name) { function TimeLogEnd($name, $line, $TimeLogLimit = 0.7) { global $global; - if (!empty($global['noDebug'])) { + if (!empty($global['noDebug']) || empty($global['start'][$name])) { return false; } $time = microtime(); @@ -3843,7 +3843,7 @@ function _dieAndLogObject($obj, $prefix = "") { } function isAVideoPlayer() { - if (isVideo()) { + if (isVideo() || isSerie()) { return true; } return false; @@ -3998,12 +3998,53 @@ function URLsAreSameVideo($url1, $url2) { } function getVideos_id() { + global $_getVideos_id; + if(isset($_getVideos_id)){ + return $_getVideos_id; + } if (isVideo()) { - return getVideoIDFromURL(getSelfURI()); + $videos_id = getVideoIDFromURL(getSelfURI()); + if(empty($videos_id) && !empty($_REQUEST['videoName'])){ + $video = Video::getVideoFromCleanTitle($_REQUEST['videoName']); + if(!empty($video)){ + $videos_id = $video['id']; + } + } + setVideos_id($videos_id); + return $videos_id; } return false; } +function setVideos_id($videos_id) { + global $_getVideos_id; + $_getVideos_id = $videos_id; +} + +function getPlaylists_id() { + global $_isPlayList; + if(!isset($_isPlayList)){ + $_isPlayList = false; + if(isPlayList()){ + $_isPlayList = intval(@$_GET['playlists_id']); + if(empty($_isPlayList)){ + $videos_id = getVideos_id(); + if(empty($videos_id)){ + $_isPlayList = false; + }else{ + $v = Video::getVideoLight($videos_id); + if(empty($v) || empty($v['serie_playlists_id'])){ + $_isPlayList = false; + }else{ + $_isPlayList = $v['serie_playlists_id']; + } + } + } + } + } + return $_isPlayList; +} + function isVideoOrAudioNotEmbed(){ if(!isVideo()){ return false; diff --git a/objects/include_config.php b/objects/include_config.php index 912883c0b6..87db1a8b03 100644 --- a/objects/include_config.php +++ b/objects/include_config.php @@ -125,6 +125,13 @@ if (empty($global['bodyClass'])) { $global['bodyClass'] = ''; } $global['allowedExtension'] = array('gif', 'jpg', 'mp4', 'webm', 'mp3', 'm4a', 'ogg', 'zip', 'm3u8'); + +if(empty($global['avideo_resolutions'])){ + $global['avideo_resolutions'] = array(240, 360, 480, 540, 720, 1080, 1440, 2160); +} + +sort($global['avideo_resolutions']); + $advancedCustom = AVideoPlugin::getObjectData('CustomizeAdvanced'); if (empty($global['disableTimeFix'])) { diff --git a/objects/playlist.php b/objects/playlist.php index 228e26ef3a..7844d4b49e 100644 --- a/objects/playlist.php +++ b/objects/playlist.php @@ -1,4 +1,5 @@ $value2) { + if (!empty($value2['serie_playlists_id'])) { + $videosP[$key]['icon'] = ''; + } else { + $videosP[$key]['icon'] = ''; + } + } + + return $videosP; + } + /** * * @global type $global @@ -65,8 +80,7 @@ class PlayList extends ObjectYPT * @param type $isVideoIdPresent pass the ID of the video checking * @return boolean */ - public static function getAllFromUser($userId, $publicOnly = true, $status = false, $playlists_id = 0, $try = 0) - { + public static function getAllFromUser($userId, $publicOnly = true, $status = false, $playlists_id = 0, $try = 0) { global $global, $config, $refreshCacheFromPlaylist; $playlists_id = intval($playlists_id); $formats = ""; @@ -162,9 +176,62 @@ class PlayList extends ObjectYPT } return $rows; } + + /** + * + * @global type $global + * @param type $publicOnly + * @param type $userId if not present check session + * @param type $isVideoIdPresent pass the ID of the video checking + * @return boolean + */ + public static function getAllFromUserLight($userId, $publicOnly = true, $status = false, $playlists_id = 0, $onlyWithVideos = false) { + global $global, $config, $refreshCacheFromPlaylist; + $playlists_id = intval($playlists_id); + $formats = ""; + $values = array(); + $sql = "SELECT u.*, pl.* FROM " . static::getTableName() . " pl " + . " LEFT JOIN users u ON u.id = users_id WHERE 1=1 "; + if (!empty($playlists_id)) { + $sql .= " AND pl.id = '{$playlists_id}' "; + } + if (!empty($status)) { + $status = str_replace("'", "", $status); + $sql .= " AND pl.status = '{$status}' "; + } elseif ($publicOnly) { + if(User::getId() != $userId){ + $sql .= " AND pl.status = 'public' "; + } + } + if (!empty($userId)) { + $sql .= " AND users_id = ? "; + $formats .= "i"; + $values[] = $userId; + } + $sql .= self::getSqlFromPost("pl."); + //echo $sql, $userId;exit; + $res = sqlDAL::readSql($sql, $formats, $values, $refreshCacheFromPlaylist); + $fullData = sqlDAL::fetchAllAssoc($res); + sqlDAL::close($res); + $rows = array(); + if ($res != false) { + foreach ($fullData as $row) { + $row = cleanUpRowFromDatabase($row); + if($onlyWithVideos){ + $videos = self::getVideosIDFromPlaylistLight($row['id']); + if(empty($videos)){ + continue; + } + } + $rows[] = $row; + } + } else { + die($sql . '\nError : (' . $global['mysqli']->errno . ') ' . $global['mysqli']->error); + } + return $rows; + } - public static function fixDuplicatePlayList($user_id) - { + public static function fixDuplicatePlayList($user_id) { if (empty($user_id)) { return false; } @@ -217,8 +284,7 @@ class PlayList extends ObjectYPT } } - public static function getAllFromUserVideo($userId, $videos_id, $publicOnly = true, $status = false) - { + public static function getAllFromUserVideo($userId, $videos_id, $publicOnly = true, $status = false) { if (empty($_SESSION['user']['sessionCache']['getAllFromUserVideo'][$videos_id][$userId][intval($publicOnly)][intval($status)])) { $rows = self::getAllFromUser($userId, $publicOnly, $status); foreach ($rows as $key => $value) { @@ -235,25 +301,32 @@ class PlayList extends ObjectYPT return $rows; } - private static function removeCache($videos_id) - { + private static function removeCache($videos_id) { $close = false; _session_start(); unset($_SESSION['user']['sessionCache']['getAllFromUserVideo'][$videos_id]); unset($_SESSION['user']['sessionCache']['getAllFromUserVideo'][$videos_id]); } - public static function getVideosIDFromPlaylistLight($playlists_id) - { - global $global; + public static function getVideosIDFromPlaylistLight($playlists_id) { + global $global, $getVideosIDFromPlaylistLight; + + if(!isset($getVideosIDFromPlaylistLight)){ + $getVideosIDFromPlaylistLight = array(); + } + + if(isset($getVideosIDFromPlaylistLight[$playlists_id])){ + return $getVideosIDFromPlaylistLight[$playlists_id]; + } + $sql = "SELECT * FROM playlists_has_videos p WHERE playlists_id = ? ORDER BY `order` "; /* - cleanSearchVar(); - $sort = @$_POST['sort']; - $_POST['sort'] = array(); - $sql .= self::getSqlFromPost(); - $_POST['sort'] = $sort; - reloadSearchVar(); + cleanSearchVar(); + $sort = @$_POST['sort']; + $_POST['sort'] = array(); + $sql .= self::getSqlFromPost(); + $_POST['sort'] = $sort; + reloadSearchVar(); * */ $res = sqlDAL::readSql($sql, "i", array($playlists_id)); @@ -267,16 +340,15 @@ class PlayList extends ObjectYPT } else { die($sql . '\nError : (' . $global['mysqli']->errno . ') ' . $global['mysqli']->error); } + $getVideosIDFromPlaylistLight[$playlists_id] = $rows; return $rows; } - public static function setCache($name, $value) - { + public static function setCache($name, $value) { parent::setCache($name, $value); } - public static function getVideosFromPlaylist($playlists_id) - { + public static function getVideosFromPlaylist($playlists_id) { $sql = "SELECT *,v.created as cre, p.`order` as video_order, v.externalOptions as externalOptions " . ", (SELECT count(id) FROM likes as l where l.videos_id = v.id AND `like` = 1 ) as likes " . " FROM playlists_has_videos p " @@ -290,7 +362,7 @@ class PlayList extends ObjectYPT $sql .= self::getSqlFromPost(); reloadSearchVar(); $_POST['sort'] = $sort; - $cacheName = "getVideosFromPlaylist{$playlists_id}".md5($sql); + $cacheName = "getVideosFromPlaylist{$playlists_id}" . md5($sql); $rows = self::getCache($cacheName, 0); if (empty($rows)) { global $global; @@ -301,8 +373,6 @@ class PlayList extends ObjectYPT $rows = array(); $SubtitleSwitcher = AVideoPlugin::loadPluginIfEnabled("SubtitleSwitcher"); if ($res != false) { - $timeLog2 = __FILE__ . " - getVideosFromPlaylist: {$playlists_id}"; - TimeLogStart($timeLog2); foreach ($fullData as $row) { $row = cleanUpRowFromDatabase($row); if (!empty($_GET['isChannel'])) { @@ -310,35 +380,26 @@ class PlayList extends ObjectYPT $row['pluginBtns'] = AVideoPlugin::getPlayListButtons($playlists_id); $row['humancreate'] = humanTiming(strtotime($row['cre'])); } - TimeLogEnd($timeLog2, __LINE__); $images = Video::getImageFromFilename($row['filename'], $row['type']); - TimeLogEnd($timeLog2, __LINE__); + if (!file_exists($images->posterLandscapePath) && !empty($row['serie_playlists_id'])) { + $images = self::getRandomImageFromPlayList($row['serie_playlists_id']); + } $row['images'] = $images; $row['videos'] = Video::getVideosPaths($row['filename'], true); - TimeLogEnd($timeLog2, __LINE__); $row['progress'] = Video::getVideoPogressPercent($row['videos_id']); - TimeLogEnd($timeLog2, __LINE__); $row['title'] = UTF8encode($row['title']); - TimeLogEnd($timeLog2, __LINE__); $row['description'] = UTF8encode($row['description']); - TimeLogEnd($timeLog2, __LINE__); $row['tags'] = Video::getTags($row['videos_id']); - TimeLogEnd($timeLog2, __LINE__); if (AVideoPlugin::isEnabledByName("VideoTags")) { $row['videoTags'] = Tags::getAllFromVideosId($row['videos_id']); $row['videoTagsObject'] = Tags::getObjectFromVideosId($row['videos_id']); } - TimeLogEnd($timeLog2, __LINE__); if ($SubtitleSwitcher) { $row['subtitles'] = getVTTTracks($row['filename'], true); foreach ($row['subtitles'] as $value) { $row['subtitlesSRT'][] = convertSRTTrack($value); } } - TimeLogEnd($timeLog2, __LINE__); - unset($row['password']); - unset($row['recoverPass']); - //unset($row['description']); $rows[] = $row; } @@ -352,18 +413,86 @@ class PlayList extends ObjectYPT return $rows; } - public static function isVideoOnFavorite($videos_id, $users_id) - { + public static function getRandomImageFromPlayList($playlists_id) { + global $global; + $sql = "SELECT v.* " + . " FROM playlists_has_videos p " + . " LEFT JOIN videos as v ON videos_id = v.id " + . " WHERE playlists_id = ? AND v.status != 'i' ORDER BY RAND() + LIMIT 1"; + $res = sqlDAL::readSql($sql, "i", array($playlists_id)); + $data = sqlDAL::fetchAssoc($res); + sqlDAL::close($res); + if ($res) { + $row = $data; + $images = Video::getImageFromFilename($row['filename'], $row['type']); + + if (!file_exists($images->posterLandscapePath) && !empty($row['serie_playlists_id'])) { + return self::getRandomImageFromPlayList($row['serie_playlists_id']); + } + return $images; + } + return false; + } + + public static function isAGroupOfPlayLists($playlists_id) { + + $rows = self::getAllSubPlayLists($playlists_id); + + return count($rows); + } + + public static function getAllSubPlayLists($playlists_id, $NOTSubPlaylists = 0) { + global $getAllSubPlayLists; + if (empty($playlists_id)) { + return false; + } + if (!isset($getAllSubPlayLists)) { + $getAllSubPlayLists = array(); + } + if (!isset($getAllSubPlayLists[$playlists_id])) { + $getAllSubPlayLists[$playlists_id] = array(); + } + if (isset($getAllSubPlayLists[$playlists_id][$NOTSubPlaylists])) { + return $getAllSubPlayLists[$playlists_id][$NOTSubPlaylists]; + } + $sql = "SELECT v.* " + . " FROM playlists_has_videos p " + . " LEFT JOIN videos as v ON videos_id = v.id " + . " WHERE playlists_id = ? AND v.status != 'i' "; + + if ($NOTSubPlaylists) { + $sql .= ' AND serie_playlists_id IS NULL '; + } else { + $sql .= ' AND serie_playlists_id IS NOT NULL '; + } + + $res = sqlDAL::readSql($sql, "i", array($playlists_id)); + $fullData = sqlDAL::fetchAllAssoc($res); + sqlDAL::close($res); + $rows = array(); + if ($res != false) { + foreach ($fullData as $row) { + $rows[] = $row; + } + } + $getAllSubPlayLists[$playlists_id][$NOTSubPlaylists] = $rows; + return $rows; + } + + public static function getAllNOTSubPlayLists($playlists_id) { + return self::getAllSubPlayLists($playlists_id, 1); + } + + public static function isVideoOnFavorite($videos_id, $users_id) { return self::isVideoOn($videos_id, $users_id, 'favorite'); } - public static function isVideoOnWatchLater($videos_id, $users_id) - { + public static function isVideoOnWatchLater($videos_id, $users_id) { return self::isVideoOn($videos_id, $users_id, 'watch_later'); } - private static function isVideoOn($videos_id, $users_id, $status) - { + private static function isVideoOn($videos_id, $users_id, $status) { global $global; $status = str_replace("'", "", $status); @@ -385,8 +514,7 @@ class PlayList extends ObjectYPT return $row; } - public static function getFavoriteIdFromUser($users_id) - { + public static function getFavoriteIdFromUser($users_id) { global $refreshCacheFromPlaylist; $favorite = self::getIdFromUser($users_id, "favorite"); if (empty($favorite)) { @@ -401,8 +529,7 @@ class PlayList extends ObjectYPT return $favorite; } - public static function getWatchLaterIdFromUser($users_id) - { + public static function getWatchLaterIdFromUser($users_id) { global $refreshCacheFromPlaylist; $watch_later = self::getIdFromUser($users_id, "watch_later"); @@ -418,8 +545,7 @@ class PlayList extends ObjectYPT return $watch_later; } - private static function getIdFromUser($users_id, $status) - { + private static function getIdFromUser($users_id, $status) { global $global; $status = str_replace("'", "", $status); @@ -436,8 +562,7 @@ class PlayList extends ObjectYPT return $row; } - public static function getVideosIdFromPlaylist($playlists_id) - { + public static function getVideosIdFromPlaylist($playlists_id) { global $getVideosIdFromPlaylist; if (empty($getVideosIdFromPlaylist)) { $getVideosIdFromPlaylist = array(); @@ -455,8 +580,7 @@ class PlayList extends ObjectYPT return $videosId; } - public static function sortVideos($videosList, $listIdOrder) - { + public static function sortVideos($videosList, $listIdOrder) { $list = array(); foreach ($listIdOrder as $value) { $found = false; @@ -478,8 +602,7 @@ class PlayList extends ObjectYPT return $list; } - public function save() - { + public function save() { if (!User::isLogged()) { return false; } @@ -498,15 +621,13 @@ class PlayList extends ObjectYPT * This is just to fix errors from the update 6.4 to 6.5, where empty playlists were created before the update * @return type */ - private function clearEmptyLists() - { + private function clearEmptyLists() { $sql = "DELETE FROM " . static::getTableName() . " WHERE status = ''"; return sqlDAL::writeSql($sql); } - public function addVideo($videos_id, $add, $order = 0) - { + public function addVideo($videos_id, $add, $order = 0) { global $global; $formats = ""; $values = array(); @@ -528,8 +649,7 @@ class PlayList extends ObjectYPT return sqlDAL::writeSql($sql, $formats, $values); } - public function delete() - { + public function delete() { if (empty($this->id)) { return false; } @@ -540,38 +660,31 @@ class PlayList extends ObjectYPT return sqlDAL::writeSql($sql, "i", array($this->id)); } - public function getId() - { + public function getId() { return $this->id; } - public function getName() - { + public function getName() { return $this->name; } - public function getModified() - { + public function getModified() { return $this->modified; } - public function getUsers_id() - { + public function getUsers_id() { return $this->users_id; } - public function getStatus() - { + public function getStatus() { return $this->status; } - public function setId($id) - { + public function setId($id) { $this->id = $id; } - public function setName($name) - { + public function setName($name) { if (strlen($name) > 45) { $name = substr($name, 0, 42) . '...'; } @@ -579,21 +692,18 @@ class PlayList extends ObjectYPT //var_dump($name,$this->name);exit; } - public function setUsers_id($users_id) - { + public function setUsers_id($users_id) { $this->users_id = $users_id; } - public function setStatus($status) - { + public function setStatus($status) { if (!in_array($status, self::$validStatus)) { $status = 'public'; } $this->status = $status; } - public static function canSee($playlist_id, $users_id) - { + public static function canSee($playlist_id, $users_id) { $obj = new PlayList($playlist_id); $status = $obj->getStatus(); if ($status !== 'public' && $status !== 'unlisted' && $users_id != $obj->getUsers_id()) { @@ -602,33 +712,29 @@ class PlayList extends ObjectYPT return true; } - public static function getEPG() - { + public static function getEPG() { global $config, $global; $encoder = $config->_getEncoderURL(); - $url = "{$encoder}view/videosListEPG.php?date_default_timezone=". urlencode(date_default_timezone_get()); + $url = "{$encoder}view/videosListEPG.php?date_default_timezone=" . urlencode(date_default_timezone_get()); $content = url_get_contents($url); return json_decode($content); } - public function getShowOnTV() - { + public function getShowOnTV() { return intval($this->showOnTV); } - public function setShowOnTV($showOnTV) - { - if (strtolower($showOnTV)==="false") { + public function setShowOnTV($showOnTV) { + if (strtolower($showOnTV) === "false") { $showOnTV = 0; - } elseif (strtolower($showOnTV)==="true") { + } elseif (strtolower($showOnTV) === "true") { $showOnTV = 1; } $this->showOnTV = intval($showOnTV); } - public static function getAllToShowOnTV() - { + public static function getAllToShowOnTV() { global $global; if (!static::isTableInstalled()) { return false; @@ -653,4 +759,26 @@ class PlayList extends ObjectYPT } return $rows; } + + public static function showPlayListSelector($playListArray) { + $collections = array(); + $videos = array(); + foreach ($playListArray as $value) { + if ($value['type'] === 'serie' && !empty($value['serie_playlists_id'])) { + $collections[] = $value; + } else { + $videos[] = $value; + } + } + $countCollections = count($collections); + $countVideos = count($videos); + if(!empty($countCollections)){ + if($countCollections===1 && empty($countVideos)){ + return false; + } + return $collections; + } + return false; + } + } diff --git a/objects/video.php b/objects/video.php index 32742a9c25..9d0f9f1366 100644 --- a/objects/video.php +++ b/objects/video.php @@ -54,6 +54,7 @@ if (!class_exists('Video')) { private $encoderURL; private $filepath; private $filesize; + private $live_transmitions_history_id; public static $statusDesc = array( 'a' => 'active', 'k' => 'active and encoding', @@ -166,6 +167,14 @@ if (!class_exists('Video')) { } } + function getLive_transmitions_history_id() { + return $this->live_transmitions_history_id; + } + + function setLive_transmitions_history_id($live_transmitions_history_id) { + $this->live_transmitions_history_id = intval($live_transmitions_history_id); + } + public function getEncoderURL() { return $this->encoderURL; @@ -321,6 +330,10 @@ if (!class_exists('Video')) { $this->type = 'video'; } } + + if (empty($this->live_transmitions_history_id)) { + $this->live_transmitions_history_id = 'NULL'; + } if (!empty($this->id)) { if (!$this->userCanManageVideo() && !$allowOfflineUser && !Permissions::canModerateVideos()) { @@ -330,13 +343,13 @@ if (!class_exists('Video')) { $sql = "UPDATE videos SET title = '{$this->title}',clean_title = '{$this->clean_title}'," . " filename = '{$this->filename}', categories_id = '{$this->categories_id}', status = '{$this->status}'," . " description = '{$this->description}', duration = '{$this->duration}', type = '{$this->type}', videoDownloadedLink = '{$this->videoDownloadedLink}', youtubeId = '{$this->youtubeId}', videoLink = '{$this->videoLink}', next_videos_id = {$this->next_videos_id}, isSuggested = {$this->isSuggested}, users_id = {$this->users_id}, " - . " trailer1 = '{$this->trailer1}', trailer2 = '{$this->trailer2}', trailer3 = '{$this->trailer3}', rate = '{$this->rate}', can_download = '{$this->can_download}', can_share = '{$this->can_share}', only_for_paid = '{$this->only_for_paid}', rrating = '{$this->rrating}', externalOptions = '{$this->externalOptions}', sites_id = {$this->sites_id}, serie_playlists_id = {$this->serie_playlists_id} , video_password = '{$this->video_password}', " + . " trailer1 = '{$this->trailer1}', trailer2 = '{$this->trailer2}', trailer3 = '{$this->trailer3}', rate = '{$this->rate}', can_download = '{$this->can_download}', can_share = '{$this->can_share}', only_for_paid = '{$this->only_for_paid}', rrating = '{$this->rrating}', externalOptions = '{$this->externalOptions}', sites_id = {$this->sites_id}, serie_playlists_id = {$this->serie_playlists_id} ,live_transmitions_history_id = {$this->live_transmitions_history_id} , video_password = '{$this->video_password}', " . " encoderURL = '{$this->encoderURL}', filepath = '{$this->filepath}' , filesize = '{$this->filesize}' , modified = now()" . " WHERE id = {$this->id}"; } else { $sql = "INSERT INTO videos " - . "(title,clean_title, filename, users_id, categories_id, status, description, duration,type,videoDownloadedLink, next_videos_id, created, modified, videoLink, can_download, can_share, only_for_paid, rrating, externalOptions, sites_id, serie_playlists_id, video_password, encoderURL, filepath , filesize) values " - . "('{$this->title}','{$this->clean_title}', '{$this->filename}', {$this->users_id},{$this->categories_id}, '{$this->status}', '{$this->description}', '{$this->duration}', '{$this->type}', '{$this->videoDownloadedLink}', {$this->next_videos_id},now(), now(), '{$this->videoLink}', '{$this->can_download}', '{$this->can_share}','{$this->only_for_paid}', '{$this->rrating}', '$this->externalOptions', {$this->sites_id}, {$this->serie_playlists_id}, '{$this->video_password}', '{$this->encoderURL}', '{$this->filepath}', '{$this->filesize}')"; + . "(title,clean_title, filename, users_id, categories_id, status, description, duration,type,videoDownloadedLink, next_videos_id, created, modified, videoLink, can_download, can_share, only_for_paid, rrating, externalOptions, sites_id, serie_playlists_id,live_transmitions_history_id, video_password, encoderURL, filepath , filesize) values " + . "('{$this->title}','{$this->clean_title}', '{$this->filename}', {$this->users_id},{$this->categories_id}, '{$this->status}', '{$this->description}', '{$this->duration}', '{$this->type}', '{$this->videoDownloadedLink}', {$this->next_videos_id},now(), now(), '{$this->videoLink}', '{$this->can_download}', '{$this->can_share}','{$this->only_for_paid}', '{$this->rrating}', '$this->externalOptions', {$this->sites_id}, {$this->serie_playlists_id},{$this->live_transmitions_history_id}, '{$this->video_password}', '{$this->encoderURL}', '{$this->filepath}', '{$this->filesize}')"; } $insert_row = sqlDAL::writeSql($sql); if ($insert_row) { @@ -566,8 +579,7 @@ if (!class_exists('Video')) { $this->clean_title = cleanURLName($clean_title); } - public function setDuration($duration) - { + public function setDuration($duration){ $this->duration = $duration; } @@ -769,12 +781,14 @@ if (!class_exists('Video')) { $sql .= " AND ("; $sql .= "v.id IN (select videos_id FROM tags_has_videos LEFT JOIN tags as t ON tags_id = t.id AND t.name LIKE '%{$_POST['searchPhrase']}%' WHERE t.id is NOT NULL)"; $sql .= BootGrid::getSqlSearchFromPost($searchFieldsNames, "OR"); + $searchFieldsNames = array('v.title'); + $sql .= self::getFullTextSearch($searchFieldsNames, $_POST['searchPhrase']); $sql .= ")"; } else { - $sql .= BootGrid::getSqlSearchFromPost($searchFieldsNames); + $sql .= ' AND (1=1 '.BootGrid::getSqlSearchFromPost($searchFieldsNames); + $searchFieldsNames = array('v.title'); + $sql .= self::getFullTextSearch($searchFieldsNames, $_POST['searchPhrase']).')'; } - $searchFieldsNames = array('v.title'); - $sql .= self::getFullTextSearch($searchFieldsNames, $_POST['searchPhrase']); } if (!$ignoreGroup) { $arrayNotIN = AVideoPlugin::getAllVideosExcludeVideosIDArray(); @@ -946,14 +960,8 @@ if (!class_exists('Video')) { public static function getVideoFromCleanTitle($clean_title) { - // for some reason in some servers (CPanel) we got the error "Error while sending QUERY packet centos on a select" // even increasing the max_allowed_packet it only goes away when close and reopen the connection - global $global, $mysqlHost, $mysqlUser, $mysqlPass, $mysqlDatabase, $mysqlPort; - $global['mysqli']->close(); - _mysql_connect(); - if (!empty($global['mysqli_charset'])) { - $global['mysqli']->set_charset($global['mysqli_charset']); - } + global $global; $sql = "SELECT id FROM videos WHERE clean_title = ? LIMIT 1"; $res = sqlDAL::readSql($sql, "s", array($clean_title)); $video = sqlDAL::fetchAssoc($res); @@ -975,7 +983,7 @@ if (!class_exists('Video')) { * @param type $videosArrayId an array with videos to return (for filter only) * @return boolean */ - public static function getAllVideos($status = "viewable", $showOnlyLoggedUserVideos = false, $ignoreGroup = false, $videosArrayId = array(), $getStatistcs = false, $showUnlisted = false, $activeUsersOnly = true, $suggestedOnly = false) + public static function getAllVideos($status = "viewable", $showOnlyLoggedUserVideos = false, $ignoreGroup = false, $videosArrayId = array(), $getStatistcs = false, $showUnlisted = false, $activeUsersOnly = true, $suggestedOnly = false, $is_serie = null) { global $global, $config, $advancedCustom; if ($config->currentVersionLowerThen('5')) { @@ -1017,6 +1025,19 @@ if (!class_exists('Video')) { $uid = intval($user['id']); $sql .= " AND v.users_id = '{$uid}' "; } + + if (isset($_REQUEST['is_serie']) && empty($is_serie)) { + $is_serie = intval($_REQUEST['is_serie']); + } + + if (isset($is_serie)) { + if(empty($is_serie)){ + $sql .= " AND v.serie_playlists_id IS NULL "; + }else{ + $sql .= " AND v.serie_playlists_id IS NOT NULL "; + } + } + if (!empty($videosArrayId) && is_array($videosArrayId)) { $sql .= " AND v.id IN ( '" . implode("', '", $videosArrayId) . "') "; } @@ -1087,9 +1108,9 @@ if (!class_exists('Video')) { $sql .= self::getFullTextSearch($searchFieldsNames, $_POST['searchPhrase']); $sql .= ")"; } else { - $sql .= BootGrid::getSqlSearchFromPost($searchFieldsNames); + $sql .= ' AND (1=1 '.BootGrid::getSqlSearchFromPost($searchFieldsNames); $searchFieldsNames = array('v.title'); - $sql .= self::getFullTextSearch($searchFieldsNames, $_POST['searchPhrase']); + $sql .= self::getFullTextSearch($searchFieldsNames, $_POST['searchPhrase']).')'; } } @@ -1145,7 +1166,7 @@ if (!class_exists('Video')) { } } - //echo $sql;exit; + //echo $sql;//exit; //_error_log("getAllVideos($status, $showOnlyLoggedUserVideos , $ignoreGroup , ". json_encode($videosArrayId).")" . $sql); $res = sqlDAL::readSql($sql); $fullData = sqlDAL::fetchAllAssoc($res); @@ -1487,6 +1508,16 @@ if (!class_exists('Video')) { } elseif (is_int($showOnlyLoggedUserVideos)) { $sql .= " AND v.users_id = '{$showOnlyLoggedUserVideos}'"; } + + if (isset($_REQUEST['is_serie'])) { + $is_serie = intval($_REQUEST['is_serie']); + if(empty($is_serie)){ + $sql .= " AND v.serie_playlists_id IS NULL "; + }else{ + $sql .= " AND v.serie_playlists_id IS NOT NULL "; + } + } + if (!empty($_GET['catName'])) { $catName = $global['mysqli']->real_escape_string($_GET['catName']); $sql .= " AND c.clean_name = '{$catName}'"; @@ -1524,9 +1555,9 @@ if (!class_exists('Video')) { $sql .= self::getFullTextSearch($searchFieldsNames, $_POST['searchPhrase']); $sql .= ")"; } else { - $sql .= BootGrid::getSqlSearchFromPost($searchFieldsNames); + $sql .= ' AND (1=1 '.BootGrid::getSqlSearchFromPost($searchFieldsNames); $searchFieldsNames = array('v.title'); - $sql .= self::getFullTextSearch($searchFieldsNames, $_POST['searchPhrase']); + $sql .= self::getFullTextSearch($searchFieldsNames, $_POST['searchPhrase']).')'; } } @@ -2030,7 +2061,7 @@ if (!class_exists('Video')) { $res = sqlDAL::writeSql($sql, "si", array($this->duration, $this->id)); return $this->id; } else { - _error_log("Do not need update duration: " . json_encode($this)); + _error_log("Do not need update duration: "); return false; } } @@ -2909,17 +2940,25 @@ if (!class_exists('Video')) { return $VideoGetSourceFile[$cacheName]; } - public static function getCleanFilenameFromFile($filename) - { + public static function getCleanFilenameFromFile($filename){ + global $global; if (empty($filename)) { return ""; } - $cleanName = str_replace( - array('_Low', '_SD', '_HD', '_thumbsV2', '_thumbsSmallV2', '_thumbsSprit', '_roku', - '_2160', '_1440', '_1080', '_720', '_480', '_360', '_240', '_portrait', '_portrait_thumbsV2', '_portrait_thumbsSmallV2'), - array('', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), - $filename - ); + + $search = array('_Low', '_SD', '_HD', '_thumbsV2', '_thumbsSmallV2', '_thumbsSprit', '_roku', '_portrait', '_portrait_thumbsV2', '_portrait_thumbsSmallV2'); + $replace = array('', '', '', '', '', '', '', '', '', ''); + + if(empty($global['avideo_resolutions']) || !is_array($global['avideo_resolutions'])){ + $global['avideo_resolutions'] = array(240, 360, 480, 540, 720, 1080, 1440, 2160); + } + + foreach ($global['avideo_resolutions'] as $value) { + $search[] = "_{$value}"; + $replace[] = ''; + } + + $cleanName = str_replace($search,$replace,$filename); $path_parts = pathinfo($cleanName); if (!empty($path_parts["extension"]) && $path_parts["extension"] === "m3u8") { @@ -3060,13 +3099,14 @@ if (!class_exists('Video')) { return false; } - public static function getHigherVideoPathFromID($videos_id) - { + public static function getHigherVideoPathFromID($videos_id){ + global $global; if (empty($videos_id)) { return false; } $paths = self::getVideosPathsFromID($videos_id); - $types = array(0, 2160, 1330, 1080, 720, 'HD', 'SD', 'Low', 480, 360, 240); + + $types = array(0, 2160, 1440, 1080, 720, 'HD', 'SD', 'Low', 540, 480, 360, 240); if (!empty($paths['mp4'])) { foreach ($types as $value) { @@ -3116,9 +3156,14 @@ if (!class_exists('Video')) { return self::getVideosPaths($video->getFilename(), true); } - public static function getVideosPaths($filename, $includeS3 = false) - { - $types = array('', '_Low', '_SD', '_HD', '_2160', '_1440', '_1080', '_720', '_480', '_360', '_240'); + public static function getVideosPaths($filename, $includeS3 = false){ + global $global; + $types = array('', '_Low', '_SD', '_HD'); + + foreach ($global['avideo_resolutions'] as $value) { + $types[] = "_{$value}"; + } + $videos = array(); $plugin = AVideoPlugin::loadPluginIfEnabled("VideoHLS"); @@ -3927,8 +3972,7 @@ if (!class_exists('Video')) { $this->serie_playlists_id = $serie_playlists_id; } - public static function getVideoFromSeriePlayListsId($serie_playlists_id) - { + public static function getVideoFromSeriePlayListsId($serie_playlists_id){ global $global, $config; $serie_playlists_id = intval($serie_playlists_id); $sql = "SELECT * FROM videos WHERE serie_playlists_id = '$serie_playlists_id' LIMIT 1"; @@ -4056,6 +4100,21 @@ if (!class_exists('Video')) { $sql .= ")"; return "{$connection} {$sql}"; } + + public static function getChangeVideoStatusButton($videos_id){ + + $video = new Video('', '', $videos_id); + $status = $video->getStatus(); + + $activeBtn = ''; + $inactiveBtn = ''; + $unlistedBtn = ''; + + return "{$activeBtn}{$inactiveBtn}{$unlistedBtn}"; + } } } // just to convert permalink into clean_title diff --git a/objects/videoStatus.json.php b/objects/videoStatus.json.php index 0a88c0920a..c8e71ac8e3 100644 --- a/objects/videoStatus.json.php +++ b/objects/videoStatus.json.php @@ -16,16 +16,41 @@ if (!is_array($_POST['id'])) { require_once 'video.php'; $id = 0; + +$obj = new stdClass(); +$obj->error = true; +$obj->status = array(); +$obj->msg = ''; + foreach ($_POST['id'] as $value) { - $obj = new Video("", "", $value); - if (empty($obj)) { - die("Object not found"); + $obj2 = new stdClass(); + $obj2->error = true; + $obj2->videos_id = $value; + $obj2->status = $_POST['status']; + $obj2->msg = ''; + + + $v = new Video("", "", $value); + if (empty($v)) { + $obj2->msg = __("Video NOT Found"); + $obj->status[] = $obj2; + continue; } - if (!$obj->userCanManageVideo() && !Permissions::canModerateVideos()) { - $obj->msg = __("You can not Manage This Video"); - die(json_encode($obj)); + if (!$v->userCanManageVideo() && !Permissions::canModerateVideos()) { + $obj2->msg = __("You can not Manage This Video"); + $obj->status[] = $obj2; + continue; } - $obj->setStatus($_POST['status']); - $resp = $value; + $v->setStatus($_POST['status']); + $obj2->error = false; + $obj->status[] = $obj2; } -echo '{"status":"' . !empty($resp) . '"}'; + +foreach ($obj->status as $value) { + if($value->error){ + break; + } + $obj->error = false; +} + +die(json_encode($obj)); diff --git a/plugin/API/API.php b/plugin/API/API.php index c1d2ae0925..f077a53034 100644 --- a/plugin/API/API.php +++ b/plugin/API/API.php @@ -261,6 +261,7 @@ class API extends PluginAbstract { * ['tags_id' the ID of the tag you want to filter] * ['catName' the clean_APIName of the category you want to filter] * ['channelName' the channelName of the videos you want to filter] + * ['is_serie' if is 0 return only videos, if is 1 return only series, if is not set, return all] * @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}&catName=default&rowCount=10 * @return \ApiObject */ diff --git a/plugin/AVideoPlugin.php b/plugin/AVideoPlugin.php index b47fcfa415..41b63615c6 100644 --- a/plugin/AVideoPlugin.php +++ b/plugin/AVideoPlugin.php @@ -1168,28 +1168,28 @@ class AVideoPlugin { } } - public static function onUserSocketConnect($users_id, $data) { + public static function onUserSocketConnect() { _mysql_connect(); $plugins = Plugin::getAllEnabled(); foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { - $p->onUserSocketConnect($users_id, $data); + $p->onUserSocketConnect(); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } _mysql_close(); } - public static function onUserSocketDisconnect($users_id, $data) { + public static function onUserSocketDisconnect() { _mysql_connect(); $plugins = Plugin::getAllEnabled(); foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { - $p->onUserSocketConnect($users_id, $data); + $p->onUserSocketDisconnect(); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } diff --git a/plugin/AdsForJesus/AdsForJesus.php b/plugin/AdsForJesus/AdsForJesus.php index 42a05379a8..04fb78a702 100644 --- a/plugin/AdsForJesus/AdsForJesus.php +++ b/plugin/AdsForJesus/AdsForJesus.php @@ -63,13 +63,11 @@ class AdsForJesus extends PluginAbstract { $js = ''; $css = ''; //if (!empty($_GET['videoName']) || !empty($_GET['u'])) { - if (!empty($_GET['videoName'])) { - if (empty($_GET['u'])) { - $video = Video::getVideoFromCleanTitle($_GET['videoName']); - $showAds = AVideoPlugin::showAds($video['id']); - if (!$showAds) { - return ""; - } + $videos_id = getVideos_id(); + if (!empty($videos_id)) { + $showAds = AVideoPlugin::showAds($videos_id); + if (!$showAds) { + return ""; } global $global; $css .= ''; @@ -86,7 +84,12 @@ class AdsForJesus extends PluginAbstract { $js .= ''; //if (!empty($_GET['videoName']) || !empty($_GET['u'])) { - if (!empty($_GET['videoName'])) { + $videos_id = getVideos_id(); + if (!empty($videos_id)) { + $showAds = AVideoPlugin::showAds($videos_id); + if (!$showAds) { + return ""; + } if (empty($_GET['u'])) { $video = Video::getVideoFromCleanTitle($_GET['videoName']); $showAds = AVideoPlugin::showAds($video['id']); @@ -101,10 +104,7 @@ class AdsForJesus extends PluginAbstract { $video_length = parseDurationToSeconds($video['duration']); $obj = $this->getDataObject(); PlayerSkins::setIMAADTag("https://forjesus.tv/vmap.xml?video_durarion={$video_length}&start={$obj->start}&mid25Percent={$obj->mid25Percent}&mid50Percent={$obj->mid50Percent}&mid75Percent={$obj->mid75Percent}&end={$obj->end}"); - }else if(isLive()){ - //PlayerSkins::setIMAADTag("https://forjesus.tv/vmap.xml?video_durarion=0&start=1&mid25Percent=0&mid50Percent=0&mid75Percent=0&end=1"); - } - + } return $js; } diff --git a/plugin/Gallery/functions.php b/plugin/Gallery/functions.php index b00c3cb4a2..6384a568f2 100644 --- a/plugin/Gallery/functions.php +++ b/plugin/Gallery/functions.php @@ -176,6 +176,9 @@ function createGallerySection($videos, $crc = "", $get = array(), $ignoreAds = f $images->thumbsJpg = "{$global['webSiteRootURL']}view/img/notfoundThumbs.jpg"; $images->thumbsJpgSmall = "{$global['webSiteRootURL']}view/img/notfoundThumbsSmall.jpg"; } + if ($value['type'] === 'serie' && !empty($value['serie_playlists_id']) && stripos($images->thumbsJpg, 'notfound') !== false) { + $images = PlayList::getRandomImageFromPlayList($value['serie_playlists_id']); + } $startG = microtime(true); $imgGif = $images->thumbsGif; $poster = $images->thumbsJpg; @@ -331,7 +334,7 @@ function createGallerySection($videos, $crc = "", $get = array(), $ignoreAds = f