From 0b1c6e8d79df4ed2b426b28b825184b9d085a44b Mon Sep 17 00:00:00 2001 From: Daniel Neto Date: Wed, 11 Dec 2024 15:06:49 -0300 Subject: [PATCH] PPV live now can support custom posters --- objects/functions.php | 4 +- objects/functionsOpenGraph.php | 4 +- plugin/API/API.php | 28 +++---- plugin/Live/Live.php | 84 ++++++++++--------- plugin/Live/Objects/Live_schedule.php | 16 ++-- plugin/Live/getImage.php | 2 +- plugin/Live/index.php | 2 +- plugin/Live/latestOrLive.php | 4 +- plugin/Live/remindMe.php | 2 +- plugin/Live/removePoster.php | 2 +- plugin/Live/uploadPoster.json.php | 8 +- plugin/Live/uploadPoster.php | 4 +- plugin/Live/view/Live_schedule/panelForm.php | 2 +- .../Live/view/Live_schedule/uploadPoster.php | 34 ++++++-- plugin/Live/view/liveVideo.php | 2 +- plugin/Live/view/menuRight.php | 4 +- plugin/Live/view/modeYoutubeLive.php | 2 +- plugin/Live/view/videoEmbeded.php | 2 +- plugin/Live/view/videoEmbededV2.php | 2 +- 19 files changed, 119 insertions(+), 89 deletions(-) diff --git a/objects/functions.php b/objects/functions.php index 9ef8b6ade6f7..52b0dd16a4ed 100644 --- a/objects/functions.php +++ b/objects/functions.php @@ -6510,7 +6510,7 @@ function getMediaSession() if ($liveLink = isLiveLink()) { $MediaMetadata = LiveLinks::getMediaSession($liveLink); } elseif ($live = isLive()) { - $MediaMetadata = Live::getMediaSession($live['key'], $live['live_servers_id'], @$live['live_schedule_id']); + $MediaMetadata = Live::getMediaSession($live['key'], $live['live_servers_id'], @$live['live_schedule_id'], 0); } elseif (!empty($videos_id)) { if (!empty($videos_id)) { $MediaMetadata = Video::getMediaSession($videos_id); @@ -6520,7 +6520,7 @@ function getMediaSession() } elseif (!empty($_REQUEST['videos_id'])) { $MediaMetadata = Video::getMediaSession($_REQUEST['videos_id']); } elseif (!empty($_REQUEST['key'])) { - $MediaMetadata = Live::getMediaSession($_REQUEST['key'], @$_REQUEST['live_servers_id'], @$_REQUEST['live_schedule_id']); + $MediaMetadata = Live::getMediaSession($_REQUEST['key'], @$_REQUEST['live_servers_id'], @$_REQUEST['live_schedule_id'], 0); } if (empty($MediaMetadata) || empty($MediaMetadata->title)) { $MediaMetadata = new stdClass(); diff --git a/objects/functionsOpenGraph.php b/objects/functionsOpenGraph.php index 8dd2bbb938d2..6361b0776d39 100644 --- a/objects/functionsOpenGraph.php +++ b/objects/functionsOpenGraph.php @@ -362,7 +362,7 @@ function getOpenGraphLiveSchedule($live_schedule_id) $title = $liveS->getTitle(); $description = ''; $duration_in_seconds = 0; - $poster = Live_schedule::getPosterURL($live_schedule_id); + $poster = Live_schedule::getPosterURL($live_schedule_id, 0); $liveStreamObject = new LiveStreamObject($liveS->getKey(), $liveS->getLive_servers_id(), 0, 0, @$_REQUEST['live_schedule']); $sourceFileURL = $liveStreamObject->getM3U8(true); $pageURL = $liveStreamObject->getURL(); @@ -380,7 +380,7 @@ function getOpenGraphLive() $isLive = isLive(); $liveT = LiveTransmition::getFromKey($isLive['cleanKey']); $users_id = $liveT['users_id']; - $poster = Live::getPosterImage($users_id, $isLive['live_servers_id'], $isLive['live_schedule']); + $poster = Live::getRegularPosterImage($users_id, $isLive['live_servers_id'], $isLive['live_schedule'], 0); $liveStreamObject = new LiveStreamObject($isLive['cleanKey'], $isLive['live_servers_id'], $isLive['live_index'], 0); echo PHP_EOL . "" . PHP_EOL; $videoType = ''; diff --git a/plugin/API/API.php b/plugin/API/API.php index a543f5edd22f..b27955b8e415 100644 --- a/plugin/API/API.php +++ b/plugin/API/API.php @@ -982,7 +982,7 @@ public function get_api_video($parameters) $rows[$key]['isSubscribed'] = Subscribe::isSubscribed($rows[$key]['users_id']); } - + $sub = self::getSubtitle($value['filename']); $rows[$key]['subtitles_available'] = $sub['subtitles_available']; @@ -1464,15 +1464,15 @@ public function set_api_live_schedule($parameters) $live_schedule_id = $o->save(); if ($live_schedule_id) { if (!empty($parameters['base64PNGImageRegular'])) { - $image = Live_schedule::getPosterPaths($live_schedule_id, Live::$posterType_regular); + $image = Live_schedule::getPosterPaths($live_schedule_id, 0, Live::$posterType_regular); saveBase64DataToPNGImage($parameters['base64PNGImageRegular'], $image['path']); } if (!empty($parameters['base64PNGImagePreRoll'])) { - $image = Live_schedule::getPosterPaths($live_schedule_id, Live::$posterType_preroll); + $image = Live_schedule::getPosterPaths($live_schedule_id, 0, Live::$posterType_preroll); saveBase64DataToPNGImage($parameters['base64PNGImagePreRoll'], $image['path']); } if (!empty($parameters['base64PNGImagePostRoll'])) { - $image = Live_schedule::getPosterPaths($live_schedule_id, Live::$posterType_postroll); + $image = Live_schedule::getPosterPaths($live_schedule_id, 0, Live::$posterType_postroll); saveBase64DataToPNGImage($parameters['base64PNGImagePostRoll'], $image['path']); } @@ -1597,7 +1597,7 @@ public function get_api_user($parameters) $obj->livestream["server_v3"] = addLastSlash($url); $obj->livestream["key_v3"] = "{$obj->livestream['key_with_index']}?s={$encrypt}"; - $obj->livestream["poster"] = $global['webSiteRootURL'] . $p->getPosterImage($user->getBdId(), $obj->livestream["live_servers_id"]); + $obj->livestream["poster"] = $global['webSiteRootURL'] . Live::getRegularPosterImage($user->getBdId(), $obj->livestream["live_servers_id"], 0, 0); $obj->livestream["joinURL"] = Live::getLinkToLiveFromUsers_idAndLiveServer($user->getBdId(), $obj->livestream["live_servers_id"]); $obj->livestream["activeLives"] = array(); @@ -2151,7 +2151,7 @@ private function like($parameters, $like) new Like($like, $parameters['videos_id']); $obj = Like::getLikes($parameters['videos_id']); - if(empty($obj)){ + if (empty($obj)) { $obj = new stdClass(); } @@ -2834,12 +2834,12 @@ public function set_api_birth($parameters) return new ApiObject("You must login first"); } $msg = ''; - $obj = new stdClass(); + $obj = new stdClass(); $user = new User(0); $user->loadSelfUser(); $user->setBirth_date($_REQUEST['birth_date']); - $obj->users_id = $user->save(); + $obj->users_id = $user->save(); $obj->error = empty($obj->users_id); User::updateSessionInfo(); @@ -2859,13 +2859,13 @@ public function get_api_is_verified($parameters) if (!self::isAPISecretValid()) { return new ApiObject("APISecret is required"); } - $obj = new stdClass(); + $obj = new stdClass(); $obj->users_id = intval($_REQUEST['users_id']); if (empty($obj->users_id)) { return new ApiObject("Users ID is required"); } $user = new User($obj->users_id); - $obj->email_verified = !empty($user->getEmailVerified()); + $obj->email_verified = !empty($user->getEmailVerified()); return new ApiObject('', false, $obj); } @@ -2883,12 +2883,12 @@ public function set_api_send_verification_email($parameters) if (!self::isAPISecretValid()) { return new ApiObject("APISecret is required"); } - $obj = new stdClass(); + $obj = new stdClass(); $obj->users_id = intval($_REQUEST['users_id']); if (empty($obj->users_id)) { return new ApiObject("Users ID is required"); } - $user = new User($obj->users_id); + $user = new User($obj->users_id); $obj->sent = User::sendVerificationLink($obj->users_id); return new ApiObject('', false, $obj); } @@ -2906,7 +2906,7 @@ public static function isAPISecretValid() return false; } - /** + /** * return true if the secret is valid and false if it is not * 'APISecret' mandatory for security reasons - required * @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}&APISecret={APISecret} @@ -2917,7 +2917,7 @@ public function get_api_isAPISecretValid() global $global; if (!self::isAPISecretValid()) { return new ApiObject("APISecret is invalid"); - }else{ + } else { return new ApiObject("APISecret is valid", false); } } diff --git a/plugin/Live/Live.php b/plugin/Live/Live.php index 2c41de864083..ffd9a3b68e43 100644 --- a/plugin/Live/Live.php +++ b/plugin/Live/Live.php @@ -300,7 +300,7 @@ public function getLiveApplicationArray() 'users_id' => $users_id, 'title' => $title, 'link' => $link, - 'imgJPG' => Live_schedule::getPosterURL($value['id']), + 'imgJPG' => Live_schedule::getPosterURL($value['id'], 0), 'imgGIF' => '', 'type' => 'scheduleLive', 'LiveUsersLabelLive' => $LiveUsersLabelLive, @@ -377,7 +377,7 @@ public function getLiveApplicationArray() 'users_id' => $users_id, 'title' => $title, 'link' => $link, - 'imgJPG' => self::getPoster($value['users_id'], $value['live_servers_id']), + 'imgJPG' => self::getPoster($value['users_id'], $value['live_servers_id'], ''), 'imgGIF' => '', 'type' => 'live', 'LiveUsersLabelLive' => $LiveUsersLabelLive, @@ -823,20 +823,20 @@ public function getHeadCode() $liveImgCloseTimeInSecondsPostroll = 'false'; $liveImgTimeInSecondsPostroll = 'false'; //var_dump('',$live, self::prerollPosterExists($live['users_id'], $live['live_servers_id'], $live['live_schedule']));exit; - if (self::prerollPosterExists($live['users_id'], $live['live_servers_id'], $live['live_schedule'])) { + if (self::prerollPosterExists($live['users_id'], $live['live_servers_id'], $live['live_schedule'], 0)) { - $path = self::getPrerollPosterImage($live['users_id'], $live['live_servers_id'], $live['live_schedule']); + $path = self::getPrerollPosterImage($live['users_id'], $live['live_servers_id'], $live['live_schedule'], 0); $prerollPoster = "'" . getURL($path) . "'"; - $times = self::getPrerollPosterImageTimes($live['users_id'], $live['live_servers_id'], $live['live_schedule']); + $times = self::getPrerollPosterImageTimes($live['users_id'], $live['live_servers_id'], $live['live_schedule'], 0); $liveImgCloseTimeInSecondsPreroll = $times->liveImgCloseTimeInSeconds; $liveImgTimeInSecondsPreroll = $times->liveImgTimeInSeconds; //var_dump($times); } - if (self::postrollPosterExists($live['users_id'], $live['live_servers_id'], $live['live_schedule'])) { - $postrollPoster = "'" . getURL(self::getPostrollPosterImage($live['users_id'], $live['live_servers_id'], $live['live_schedule'])) . "'"; + if (self::postrollPosterExists($live['users_id'], $live['live_servers_id'], $live['live_schedule'], 0)) { + $postrollPoster = "'" . getURL(self::getPostrollPosterImage($live['users_id'], $live['live_servers_id'], $live['live_schedule'], 0)) . "'"; - $times = self::getPostrollPosterImageTimes($live['users_id'], $live['live_servers_id'], $live['live_schedule']); + $times = self::getPostrollPosterImageTimes($live['users_id'], $live['live_servers_id'], $live['live_schedule'], 0); $liveImgCloseTimeInSecondsPostroll = $times->liveImgCloseTimeInSeconds; $liveImgTimeInSecondsPostroll = $times->liveImgTimeInSeconds; //var_dump($times); @@ -3133,7 +3133,7 @@ public function getImageGif($users_id, $live_servers_id = 0, $playlists_id_live return $url; } - public static function getPosterImage($users_id, $live_servers_id, $live_schedule_id = 0, $posterType = 0) + private static function getPosterImage($users_id, $live_servers_id, $ppv_schedule_id, $live_schedule_id, $posterType) { global $global; if (empty($users_id)) { @@ -3156,7 +3156,7 @@ public static function getPosterImage($users_id, $live_servers_id, $live_schedul if (empty($users_id)) { return false; } - $file = self::_getPosterImage($users_id, $live_servers_id, $live_schedule_id, $posterType); + $file = self::_getPosterImage($users_id, $live_servers_id, $ppv_schedule_id, $live_schedule_id, $posterType); //var_dump($file); if (!file_exists($global['systemRootPath'] . $file)) { if (!empty($live_schedule_id)) { @@ -3177,17 +3177,22 @@ public static function getPosterImage($users_id, $live_servers_id, $live_schedul return $file; } - public static function getPrerollPosterImage($users_id = 0, $live_servers_id = 0, $live_schedule_id = 0) + public static function getRegularPosterImage($users_id, $live_servers_id, $live_schedule_id, $ppv_schedule_id) { - return self::getPosterImage($users_id, $live_servers_id, $live_schedule_id, self::$posterType_preroll); + return self::getPosterImage($users_id, $live_servers_id, $ppv_schedule_id, $live_schedule_id, self::$posterType_regular); + } + + public static function getPrerollPosterImage($users_id, $live_servers_id, $live_schedule_id, $ppv_schedule_id) + { + return self::getPosterImage($users_id, $live_servers_id, $ppv_schedule_id, $live_schedule_id, self::$posterType_preroll); } /** * @return object */ - public static function getPrerollPosterImageTimes($users_id = 0, $live_servers_id = 0, $live_schedule_id = 0) + public static function getPrerollPosterImageTimes($users_id, $live_servers_id, $live_schedule_id, $ppv_schedule_id) { global $global; - $path = self::getPrerollPosterImage($users_id, $live_servers_id, $live_schedule_id); + $path = self::getPrerollPosterImage($users_id, $live_servers_id, $live_schedule_id, $ppv_schedule_id); $jsonPath = $global['systemRootPath'] . str_replace('.jpg', '.json', $path); if (file_exists($jsonPath)) { @@ -3201,15 +3206,15 @@ public static function getPrerollPosterImageTimes($users_id = 0, $live_servers_i return $times; } - public static function getPostrollPosterImage($users_id = 0, $live_servers_id = 0, $live_schedule_id = 0) + public static function getPostrollPosterImage($users_id, $live_servers_id, $live_schedule_id, $ppv_schedule_id) { - return self::getPosterImage($users_id, $live_servers_id, $live_schedule_id, self::$posterType_postroll); + return self::getPosterImage($users_id, $live_servers_id, $live_schedule_id, $ppv_schedule_id, self::$posterType_postroll); } - public static function getPostrollPosterImageTimes($users_id = 0, $live_servers_id = 0, $live_schedule_id = 0) + public static function getPostrollPosterImageTimes($users_id, $live_servers_id, $live_schedule_id, $ppv_schedule_id) { global $global; - $path = self::getPostrollPosterImage($users_id, $live_servers_id, $live_schedule_id); + $path = self::getPostrollPosterImage($users_id, $live_servers_id, $live_schedule_id, $ppv_schedule_id); $jsonPath = $global['systemRootPath'] . str_replace('.jpg', '.json', $path); if (file_exists($jsonPath)) { $times = _json_decode($jsonPath); @@ -3222,7 +3227,7 @@ public static function getPostrollPosterImageTimes($users_id = 0, $live_servers_ return $times; } - public static function posterExists($users_id = 0, $live_servers_id = 0, $live_schedule_id = 0, $posterType = 0) + public static function posterExists($users_id, $live_servers_id, $live_schedule_id, $ppv_schedule_id, $posterType) { global $global; @@ -3247,23 +3252,23 @@ public static function posterExists($users_id = 0, $live_servers_id = 0, $live_s return false; } - $file = self::_getPosterImage($users_id, $live_servers_id, $live_schedule_id, $posterType); + $file = self::_getPosterImage($users_id, $live_servers_id, $ppv_schedule_id, $live_schedule_id, $posterType); return file_exists("{$global['systemRootPath']}{$file}"); } - public static function prerollPosterExists($users_id = 0, $live_servers_id = 0, $live_schedule_id = 0) + public static function prerollPosterExists($users_id, $live_servers_id, $live_schedule_id, $ppv_schedule_id) { - return self::posterExists($users_id, $live_servers_id, $live_schedule_id, self::$posterType_preroll); + return self::posterExists($users_id, $live_servers_id, $live_schedule_id, $ppv_schedule_id, self::$posterType_preroll); } - public static function postrollPosterExists($users_id = 0, $live_servers_id = 0, $live_schedule_id = 0) + public static function postrollPosterExists($users_id, $live_servers_id, $live_schedule_id, $ppv_schedule_id) { - return self::posterExists($users_id, $live_servers_id, $live_schedule_id, self::$posterType_postroll); + return self::posterExists($users_id, $live_servers_id, $live_schedule_id, $ppv_schedule_id, self::$posterType_postroll); } public static function getPosterImageOrFalse($users_id, $live_servers_id) { - $poster = self::getPosterImage($users_id, $live_servers_id); + $poster = self::getRegularPosterImage($users_id, $live_servers_id, 0, 0); if (preg_match('/OnAir.jpg$/', $poster)) { return false; } @@ -3275,10 +3280,10 @@ public function getLivePosterImage($users_id, $live_servers_id = 0, $playlists_i { global $global; - return self::getLivePosterImageRelativePath($users_id, $live_servers_id, $playlists_id_live, $live_index, $format, $live_schedule_id, true); + return self::getLivePosterImageRelativePath($users_id, $live_servers_id, 0, $playlists_id_live, $live_index, $format, $live_schedule_id, true); } - public static function getLivePosterImageRelativePath($users_id, $live_servers_id = 0, $playlists_id_live = 0, $live_index = '', $format = 'jpg', $live_schedule_id = 0, $returnURL = false) + public static function getLivePosterImageRelativePath($users_id, $live_servers_id, $ppv_schedule_id, $playlists_id_live = 0, $live_index = '', $format = 'jpg', $live_schedule_id = 0, $returnURL = false) { global $global; if (empty($live_servers_id)) { @@ -3289,7 +3294,7 @@ public static function getLivePosterImageRelativePath($users_id, $live_servers_i if ($format !== 'jpg') { return false; } - $file = self::_getPosterImage($users_id, $live_servers_id, $live_schedule_id); + $file = self::_getPosterImage($users_id, $live_servers_id, $ppv_schedule_id, $live_schedule_id); if (!file_exists($global['systemRootPath'] . $file)) { $file = self::getOnAirImage(false); @@ -3327,7 +3332,7 @@ public static function getPosterThumbsImage($users_id, $live_servers_id, $comins if (empty($_REQUEST['live_schedule'])) { $file = self::_getPosterThumbsImage($users_id, $live_servers_id); } else { - $array = Live_schedule::getPosterPaths($_REQUEST['live_schedule']); + $array = Live_schedule::getPosterPaths($_REQUEST['live_schedule'], 0); $file = $array['relative_path']; } @@ -3344,7 +3349,7 @@ public static function getPosterThumbsImage($users_id, $live_servers_id, $comins return $file; } - public static function getPoster($users_id, $live_servers_id, $key = '') + public static function getPoster($users_id, $live_servers_id, $key) { global $_getPoster; if (!isset($_getPoster)) { @@ -3370,13 +3375,13 @@ public static function getPoster($users_id, $live_servers_id, $key = '') $live_index = $parameters['live_index']; $playlists_id_live = $parameters['playlists_id_live']; if (self::isLiveAndIsReadyFromKey($lh['key'], $lh['live_servers_id'])) { - $_getPoster[$index] = self::getLivePosterImageRelativePath($users_id, $live_servers_id, $playlists_id_live, $live_index); + $_getPoster[$index] = self::getLivePosterImageRelativePath($users_id, $live_servers_id, 0, $playlists_id_live, $live_index); //_error_log('getImage: ' . ("[{$lh['key']}, {$lh['live_servers_id']}]") . ' is live and ready'); return $_getPoster[$index]; } else { if (self::isKeyLiveInStats($lh['key'], $lh['live_servers_id'])) { //_error_log('getImage: ' . ("[{$lh['key']}, {$lh['live_servers_id']}]") . ' key is in the stats'); - $_getPoster[$index] = self::getPosterImage($users_id, $live_servers_id, $live_index); + $_getPoster[$index] = self::getRegularPosterImage($users_id, $live_servers_id, 0, 0); } else { //_error_log('getImage: ' . ("[{$lh['key']}, {$lh['live_servers_id']}]") . ' key is NOT in the stats'); $_getPoster[$index] = $poster; @@ -3415,16 +3420,17 @@ public static function getComingSoonImage($includeURL = true) return $img; } - public static function _getPosterImage($users_id, $live_servers_id, $live_schedule_id = 0, $posterType = 0) + public static function _getPosterImage($users_id, $live_servers_id, $ppv_schedule_id, $live_schedule_id = 0, $posterType = 0) { $users_id = intval($users_id); + $ppv_schedule_id = intval($ppv_schedule_id); $live_servers_id = intval($live_servers_id); $live_schedule_id = intval($live_schedule_id); $posterType = intval($posterType); - if (!empty($live_schedule_id)) { - $paths = Live_schedule::getPosterPaths($live_schedule_id, $posterType); + if (!empty($live_schedule_id) || !empty($ppv_schedule_id)) { + $paths = Live_schedule::getPosterPaths($live_schedule_id, $ppv_schedule_id, $posterType); return $paths['relative_path']; } $type = ''; @@ -4004,10 +4010,10 @@ public static function checkIfPasswordIsGood($key) return true; } - public static function getMediaSession($key, $live_servers_id, $live_schedule_id = 0) + public static function getMediaSession($key, $live_servers_id, $live_schedule_id, $ppv_schedule_id) { $lt = LiveTransmition::getFromKey($key); - $posters = self::getMediaSessionPosters($lt['users_id'], $lt['live_servers_id'], $lt['live_schedule_id']); + $posters = self::getMediaSessionPosters($lt['users_id'], $lt['live_servers_id'], $lt['live_schedule_id'], $ppv_schedule_id); if (empty($posters)) { $posters = array(); } @@ -4025,11 +4031,11 @@ public static function getMediaSession($key, $live_servers_id, $live_schedule_id return $MediaMetadata; } - public static function getMediaSessionPosters($users_id, $live_servers_id, $live_schedule_id = 0) + public static function getMediaSessionPosters($users_id, $live_servers_id, $live_schedule_id, $ppv_schedule_id) { global $global; - $file = self::_getPosterImage($users_id, $live_servers_id, $live_schedule_id); + $file = self::_getPosterImage($users_id, $live_servers_id, $ppv_schedule_id, $live_schedule_id); $imagePath = $global['systemRootPath'] . $file; //var_dump($imagePath);exit; if (file_exists($imagePath)) { diff --git a/plugin/Live/Objects/Live_schedule.php b/plugin/Live/Objects/Live_schedule.php index a7bd7e061f43..13beb727e123 100644 --- a/plugin/Live/Objects/Live_schedule.php +++ b/plugin/Live/Objects/Live_schedule.php @@ -126,16 +126,20 @@ public static function getAllLive_servers() return $rows; } - public static function getPosterPaths($live_schedule_id, $posterType=0) + public static function getPosterPaths($live_schedule_id, $ppv_schedule_id, $posterType=0) { $live_schedule_id = intval($live_schedule_id); + $ppv_schedule_id = intval($ppv_schedule_id); $posterType = intval($posterType); - if (empty($live_schedule_id)) { + if (empty($live_schedule_id) && empty($ppv_schedule_id)) { return false; } if(!empty($posterType)){ $live_schedule_id = "{$live_schedule_id}_{$posterType}"; } + if(!empty($ppv_schedule_id)){ + $live_schedule_id = "ppv_{$ppv_schedule_id}_{$posterType}"; + } $subdir = "live_schedule_posters"; @@ -156,8 +160,8 @@ public static function getPosterPaths($live_schedule_id, $posterType=0) return $array; } - public static function getPosterURL($live_schedule_id, $posterType=0){ - $paths = self::getPosterPaths($live_schedule_id, $posterType); + public static function getPosterURL($live_schedule_id, $ppv_schedule_id, $posterType=0){ + $paths = self::getPosterPaths($live_schedule_id, $ppv_schedule_id, $posterType); if (file_exists($paths['path'])) { return $paths['url']; } else { @@ -204,7 +208,7 @@ public static function getAll($users_id=0, $activeHoursAgo=false) $row['future'] = isTimeForFuture($row['scheduled_time'], $row['timezone']); $row['secondsIntervalHuman'] = secondsIntervalHuman($row['scheduled_time'], $row['timezone']); //var_dump($row['secondsIntervalHuman']);exit; - $row['posterURL'] = self::getPosterURL($row['id']); + $row['posterURL'] = self::getPosterURL($row['id'], 0); $row['serverURL'] = Live::getServerURL($row['key'], $row['users_id']); if(empty($row['json'])){ $row['json'] = array(); @@ -249,7 +253,7 @@ public static function getAllActiveLimit($users_id=0,$limit = 100) foreach ($fullData as $row) { $row['future'] = isTimeForFuture($row['scheduled_time'], $row['timezone']); $row['secondsIntervalHuman'] = secondsIntervalHuman($row['scheduled_time'], $row['timezone']); - $row['posterURL'] = self::getPosterURL($row['id']); + $row['posterURL'] = self::getPosterURL($row['id'], 0); $row['serverURL'] = Live::getServerURL($row['key'], $row['users_id']); $rows[] = $row; } diff --git a/plugin/Live/getImage.php b/plugin/Live/getImage.php index 7f58da85559b..9fab6579858b 100644 --- a/plugin/Live/getImage.php +++ b/plugin/Live/getImage.php @@ -61,7 +61,7 @@ $livet = LiveTransmition::getFromRequest(); //header('Content-Type: text/plain');var_dump(Live::isLive($livet['users_id']), $livet);exit; if (!empty($_REQUEST['live_schedule']) && !empty($livet['scheduled_time']) && isTimeForFuture($livet['scheduled_time'], $livet['timezone'])) { - $array = Live_schedule::getPosterPaths($_REQUEST['live_schedule']); + $array = Live_schedule::getPosterPaths($_REQUEST['live_schedule'], 0); $uploadedPoster = $array['path']; header('Content-Type: image/jpg'); if(!file_exists($cacheFileImageNameResized)){ diff --git a/plugin/Live/index.php b/plugin/Live/index.php index f653adf5a777..63eae7b3459c 100644 --- a/plugin/Live/index.php +++ b/plugin/Live/index.php @@ -199,7 +199,7 @@ $_REQUEST['live_servers_id'] = Live::getLiveServersIdRequest(); $getLiveKey['live_servers_id'] = $_REQUEST['live_servers_id']; $getLiveKey['live_index'] = @$_REQUEST['live_index']; - $poster = Live::getPosterImage(User::getId(), $_REQUEST['live_servers_id']); + $poster = Live::getRegularPosterImage(User::getId(), $_REQUEST['live_servers_id'], 0, 0); $liveStreamObject = new LiveStreamObject($trasnmition['key'], $trasnmition['live_servers_id']); Live::getLiveControls($liveStreamObject->getKeyWithIndex(true,true), $trasnmition['live_servers_id']); diff --git a/plugin/Live/latestOrLive.php b/plugin/Live/latestOrLive.php index a7d18ae50461..6c3061a91c32 100644 --- a/plugin/Live/latestOrLive.php +++ b/plugin/Live/latestOrLive.php @@ -83,7 +83,7 @@ function matchWithRequest($row) //var_dump($liveFound, $liveVideo);exit; if (!empty($liveVideo)) { setLiveKey($liveVideo['key'], $liveVideo['live_servers_id'], $liveVideo['live_index']); - $poster = getURL(Live::getPosterImage($liveVideo['users_id'], $liveVideo['live_servers_id'])); + $poster = getURL(Live::getRegularPosterImage($liveVideo['users_id'], $liveVideo['live_servers_id'], 0, 0)); $m3u8 = Live::getM3U8File($liveVideo['key']); if (!empty($m3u8)) { $sources = ""; @@ -94,7 +94,7 @@ function matchWithRequest($row) $objectToReturnToParentIframe->videoHumanTime = __('Now'); $objectToReturnToParentIframe->creator = User::getNameIdentificationById($liveVideo['users_id']); - $objectToReturnToParentIframe->mediaSession = Live::getMediaSession($liveVideo['key'], $liveVideo['live_servers_id']); + $objectToReturnToParentIframe->mediaSession = Live::getMediaSession($liveVideo['key'], $liveVideo['live_servers_id'], 0, 0); $objectToReturnToParentIframe->live_transmitions_id = intval($liveVideo['live_transmitions_id']); $objectToReturnToParentIframe->live_transmitions_history_id = intval($liveVideo['live_transmitions_history_id']); $objectToReturnToParentIframe->users_id = intval($liveVideo['users_id']); diff --git a/plugin/Live/remindMe.php b/plugin/Live/remindMe.php index 21b2c372dd70..1d391ded72ec 100644 --- a/plugin/Live/remindMe.php +++ b/plugin/Live/remindMe.php @@ -11,7 +11,7 @@ } $ls = new Live_schedule($_REQUEST['live_schedule_id']); -$liveImg = Live_schedule::getPosterURL($_REQUEST['live_schedule_id']); +$liveImg = Live_schedule::getPosterURL($_REQUEST['live_schedule_id'], 0); $liveInfo = Live::getInfo($ls->getKey(), $ls->getLive_servers_id()); $_page = new Page(array('Remind me')); diff --git a/plugin/Live/removePoster.php b/plugin/Live/removePoster.php index 42ece78a94e7..524f07eed97e 100644 --- a/plugin/Live/removePoster.php +++ b/plugin/Live/removePoster.php @@ -28,7 +28,7 @@ header('Content-Type: application/json'); // A list of permitted file extensions -$obj->file = Live::_getPosterImage(User::getId(), $live_servers_id); +$obj->file = Live::_getPosterImage(User::getId(), $live_servers_id, $ppv_schedule_id); $obj->fileThumbs = Live::_getPosterThumbsImage(User::getId(), $live_servers_id); $obj->newPoster = 'plugin/Live/view/OnAir.jpg'; diff --git a/plugin/Live/uploadPoster.json.php b/plugin/Live/uploadPoster.json.php index 5ce57442ebec..838b407cca0a 100644 --- a/plugin/Live/uploadPoster.json.php +++ b/plugin/Live/uploadPoster.json.php @@ -14,23 +14,23 @@ } +$ppv_schedule_id = intval($_REQUEST['ppv_schedule_id'] ?? 0); $live_servers_id = intval($_REQUEST['live_servers_id'] ?? 0); $live_schedule_id = intval($_REQUEST['live_schedule_id'] ?? 0); $posterType = intval($_REQUEST['posterType'] ?? 0); -if (!empty($live_schedule_id)) { +if (!empty($live_schedule_id) || !empty($ppv_schedule_id)) { $row = new Live_schedule($live_schedule_id); if (User::isAdmin() || $row->getUsers_id() == User::getId()) { if (isset($_REQUEST['image'])) { - $image = Live_schedule::getPosterPaths($live_schedule_id, $posterType); + $image = Live_schedule::getPosterPaths($live_schedule_id, $ppv_schedule_id, $posterType); $obj->path = $image['path']; $obj->image = saveCroppieImage($obj->path, "image"); $obj->error = false; } } } else { - //_getPosterImage($users_id, $live_servers_id, $live_schedule_id = 0, $posterType=0) - $obj->path = $global['systemRootPath'] . Live::_getPosterImage(User::getId(), $live_servers_id, 0, $posterType); + $obj->path = $global['systemRootPath'] . Live::_getPosterImage(User::getId(), $live_servers_id, 0, 0, $posterType); $obj->image = saveCroppieImage($obj->path, "image"); if ($obj->image) { $obj->pathThumbs = $global['systemRootPath'] . Live::_getPosterThumbsImage(User::getId(), $live_servers_id, $posterType); diff --git a/plugin/Live/uploadPoster.php b/plugin/Live/uploadPoster.php index d289e94cc44c..95c4e9baed5b 100644 --- a/plugin/Live/uploadPoster.php +++ b/plugin/Live/uploadPoster.php @@ -34,10 +34,10 @@ } if (empty($live_schedule_id)) { - $obj->file = Live::_getPosterImage(User::getId(), $live_servers_id); + $obj->file = Live::_getPosterImage(User::getId(), $live_servers_id, 0); $obj->fileThumbs = Live::_getPosterThumbsImage(User::getId(), $live_servers_id); } else { - $paths = Live_schedule::getPosterPaths($live_schedule_id); + $paths = Live_schedule::getPosterPaths($live_schedule_id, 0); $obj->file = str_replace($global['systemRootPath'], '', $paths['path']); $obj->fileThumbs = str_replace($global['systemRootPath'], '', $paths['path_thumbs']); } diff --git a/plugin/Live/view/Live_schedule/panelForm.php b/plugin/Live/view/Live_schedule/panelForm.php index 78142fcc3274..6e9caaface20 100644 --- a/plugin/Live/view/Live_schedule/panelForm.php +++ b/plugin/Live/view/Live_schedule/panelForm.php @@ -155,7 +155,7 @@ function(resposta) { Schedule_plans[schedule.id] = schedule; var $clone = $($('#Live_schedulebtnModelList').html()); var id = 'scheduled_' + schedule.id; - var text = '
' + + var text = '
' + '' + schedule.title + '' + '
' + schedule.secondsIntervalHuman + diff --git a/plugin/Live/view/Live_schedule/uploadPoster.php b/plugin/Live/view/Live_schedule/uploadPoster.php index e43ed08a40d0..99d78bc9d0cc 100644 --- a/plugin/Live/view/Live_schedule/uploadPoster.php +++ b/plugin/Live/view/Live_schedule/uploadPoster.php @@ -3,12 +3,17 @@ if (!isset($global['systemRootPath'])) { require_once '../../../../videos/configuration.php'; } + if (!User::canStream()) { - forbiddenPage("You cant do this 1"); + forbiddenPage("You cant livestream"); } +$ppv_schedule_id = intval($_REQUEST['ppv_schedule_id'] ?? 0); $live_schedule_id = intval($_REQUEST['live_schedule_id'] ?? 0); $live_servers_id = intval($_REQUEST['live_servers_id'] ?? 0); + +$posterFor = 'Live'; + $callBackJSFunction = 'saveLivePoster'; if (!empty($live_schedule_id)) { $row = new Live_schedule($live_schedule_id); @@ -18,16 +23,29 @@ $callBackJSFunction = 'saveSchedulePoster'; } -if (!User::canStream()) { - forbiddenPage("You cant livestream"); +if (!empty($ppv_schedule_id)) { + $p = AVideoPlugin::loadPluginIfEnabled('PayPerViewLive'); + + if(empty($p)){ + forbiddenPage("PayPerViewLive is disabled"); + } + + $row = new Ppvlive_schedule($ppv_schedule_id); + if (!User::isAdmin() && $row->getUsers_id() != User::getId()) { + forbiddenPage("You cant do this"); + } + $callBackJSFunction = 'saveSchedulePosterPPV'; + $posterFor = 'Live PPV'; + } -$poster = Live::getPosterImage(User::getId(), $live_servers_id ?? '', $live_schedule_id); +//var_dump(User::getId(), $live_servers_id ?? '', $live_schedule_id, $ppv_schedule_id); +$poster = Live::getRegularPosterImage(User::getId(), $live_servers_id ?? '', $live_schedule_id, $ppv_schedule_id ); //var_dump($poster, User::getId(), $live_servers_id ?? '', $live_schedule_id);exit; $image = getURL($poster); -$poster = Live::getPrerollPosterImage(User::getId(), $live_servers_id ?? '', $live_schedule_id); +$poster = Live::getPrerollPosterImage(User::getId(), $live_servers_id ?? '', $live_schedule_id, $ppv_schedule_id); //var_dump($poster, User::getId(), $live_servers_id ?? '', $live_schedule_id, Live::$posterType_preroll);exit; $image_preroll = getURL($poster); -$poster = Live::getPostrollPosterImage(User::getId(), $live_servers_id ?? '', $live_schedule_id); +$poster = Live::getPostrollPosterImage(User::getId(), $live_servers_id ?? '', $live_schedule_id, $ppv_schedule_id); //var_dump($poster, User::getId(), $live_servers_id ?? '', $live_schedule_id);exit; $image_postroll = getURL($poster); @@ -130,6 +148,7 @@
+ ()
(image) { posterType: posterType, liveImgCloseTimeInSeconds: $('#liveImgCloseTimeInSeconds').val(), liveImgTimeInSeconds: $('#liveImgTimeInSeconds').val(), + ppv_schedule_id: , live_schedule_id: , live_servers_id: , image: image, @@ -167,7 +187,7 @@ function (image) { avideoResponse(response); if (response && !response.error) { if (closeWindowAfterImageSave) { - var scheduleElem = $('#schedule_poster_', window.parent.document); + var scheduleElem = $('#schedule_poster__', window.parent.document); $(scheduleElem).attr('src', addGetParam($(scheduleElem).attr('src'), 'cache', Math.random())); avideoModalIframeClose(); } diff --git a/plugin/Live/view/liveVideo.php b/plugin/Live/view/liveVideo.php index 5968ac97f4f9..7bfb85a7c248 100644 --- a/plugin/Live/view/liveVideo.php +++ b/plugin/Live/view/liveVideo.php @@ -1,6 +1,6 @@ liveImgTimeInSeconds) { echo "setTimeout(function(){showImage('prerollPoster', '{$liveInfo['key']}');},1500);"; } else { echo "/* prerollPoster will notplay */"; } } else { - $times = Live::getPostrollPosterImageTimes($liveInfo['users_id'], $liveInfo['live_servers_id'], $liveInfo['live_schedule_id']); + $times = Live::getPostrollPosterImageTimes($liveInfo['users_id'], $liveInfo['live_servers_id'], $liveInfo['live_schedule_id'], 0); //var_dump(isLive(),$times,$liveInfo['users_id'], $liveInfo['live_servers_id'], $liveInfo['live_schedule_id']);exit; if (!empty($liveInfo['finishedSecondsAgo']) && $liveInfo['finishedSecondsAgo'] < $times->liveImgTimeInSeconds) { echo "setTimeout(function(){showImage('postrollPoster', '{$liveInfo['key']}');},1500);"; diff --git a/plugin/Live/view/modeYoutubeLive.php b/plugin/Live/view/modeYoutubeLive.php index 7fb71f70ff89..24113252dfb8 100644 --- a/plugin/Live/view/modeYoutubeLive.php +++ b/plugin/Live/view/modeYoutubeLive.php @@ -71,7 +71,7 @@ $ls = new Live_schedule($_REQUEST['live_schedule']); $liveTitle = $ls->getTitle(); $liveDescription = $ls->getDescription(); - //$liveImg = Live_schedule::getPosterURL($_REQUEST['live_schedule']); + //$liveImg = Live_schedule::getPosterURL($_REQUEST['live_schedule'], 0); $liveUrl = addQueryStringParameter($liveUrl, 'live_schedule', intval($_REQUEST['live_schedule'])); $img = addQueryStringParameter($img, 'live_schedule', intval($_REQUEST['live_schedule'])); $img = addQueryStringParameter($img, 'cache', uniqid()); diff --git a/plugin/Live/view/videoEmbeded.php b/plugin/Live/view/videoEmbeded.php index 358e82a6433e..74efc08f6392 100644 --- a/plugin/Live/view/videoEmbeded.php +++ b/plugin/Live/view/videoEmbeded.php @@ -45,7 +45,7 @@ global $getLiveKey; $getLiveKey = ['key' => $ls->getKey(), 'live_servers_id' => intval($ls->getLive_servers_id()), 'live_index' => '', 'cleanKey' => '']; } -$poster = Live::getPosterImage($livet['users_id'], $_REQUEST['live_servers_id'], @$_REQUEST['live_schedule']); +$poster = Live::getRegularPosterImage($livet['users_id'], $_REQUEST['live_servers_id'], @$_REQUEST['live_schedule'], @$_REQUEST['ppv_schedule_id']); ?> diff --git a/plugin/Live/view/videoEmbededV2.php b/plugin/Live/view/videoEmbededV2.php index 5cd2f4f0b268..0fd6753e8090 100644 --- a/plugin/Live/view/videoEmbededV2.php +++ b/plugin/Live/view/videoEmbededV2.php @@ -37,7 +37,7 @@ $video['users_id'] = $user_id; AVideoPlugin::getModeYouTubeLive($user_id); $_REQUEST['live_servers_id'] = Live::getLiveServersIdRequest(); -$poster = Live::getPosterImage($livet['users_id'], $_REQUEST['live_servers_id'], @$_REQUEST['live_schedule']); +$poster = Live::getRegularPosterImage($livet['users_id'], $_REQUEST['live_servers_id'], @$_REQUEST['live_schedule'], @$_REQUEST['ppv_schedule_id']); ?>