1
0
Fork 0
mirror of https://github.com/DanielnetoDotCom/YouPHPTube synced 2025-10-04 18:29:39 +02:00

Optimise unsets.

(It's possible to combine sequential unsets into a single call).
This commit is contained in:
Caleb Mazalevskis 2021-05-07 00:09:41 +08:00
parent 4bf775d613
commit 09b4476fe5
No known key found for this signature in database
GPG key ID: 082E6BC1046FAB95
8 changed files with 31 additions and 49 deletions

View file

@ -3882,10 +3882,7 @@ function getDiskUsage() {
} }
function unsetSearch() { function unsetSearch() {
unset($_GET['searchPhrase']); unset($_GET['searchPhrase'], $_POST['searchPhrase'], $_GET['search'], $_GET['q']);
unset($_POST['searchPhrase']);
unset($_GET['search']);
unset($_GET['q']);
} }
function encrypt_decrypt($string, $action) { function encrypt_decrypt($string, $action) {
@ -4500,9 +4497,7 @@ function cleanSearchVar() {
} }
$searchIdex = array('q', 'searchPhrase', 'search'); $searchIdex = array('q', 'searchPhrase', 'search');
foreach ($searchIdex as $value) { foreach ($searchIdex as $value) {
unset($_REQUEST[$value]); unset($_REQUEST[$value], $_POST[$value], $_GET[$value]);
unset($_POST[$value]);
unset($_GET[$value]);
} }
} }

View file

@ -305,7 +305,6 @@ class PlayList extends ObjectYPT {
$close = false; $close = false;
_session_start(); _session_start();
unset($_SESSION['user']['sessionCache']['getAllFromUserVideo'][$videos_id]); unset($_SESSION['user']['sessionCache']['getAllFromUserVideo'][$videos_id]);
unset($_SESSION['user']['sessionCache']['getAllFromUserVideo'][$videos_id]);
} }
public static function getVideosIDFromPlaylistLight($playlists_id) { public static function getVideosIDFromPlaylistLight($playlists_id) {

View file

@ -33,8 +33,7 @@ $videos = PlayList::getVideosFromPlaylist($_POST['playlists_id']);
$objMob = AVideoPlugin::getObjectData("MobileManager"); $objMob = AVideoPlugin::getObjectData("MobileManager");
foreach ($videos as $key => $value) { foreach ($videos as $key => $value) {
unset($videos[$key]['password']); unset($videos[$key]['password'], $videos[$key]['recoverPass']);
unset($videos[$key]['recoverPass']);
$images = Video::getImageFromFilename($videos[$key]['filename'], $videos[$key]['type']); $images = Video::getImageFromFilename($videos[$key]['filename'], $videos[$key]['type']);
$videos[$key]['images'] = $images; $videos[$key]['images'] = $images;
$videos[$key]['Poster'] = !empty($objMob->portraitImage)?$images->posterPortrait:$images->poster; $videos[$key]['Poster'] = !empty($objMob->portraitImage)?$images->posterPortrait:$images->poster;
@ -44,9 +43,7 @@ foreach ($videos as $key => $value) {
$videos[$key]['createdHumanTiming'] = humanTiming(strtotime($videos[$key]['created'])); $videos[$key]['createdHumanTiming'] = humanTiming(strtotime($videos[$key]['created']));
$videos[$key]['pageUrl'] = "{$global['webSiteRootURL']}video/".$videos[$key]['clean_title']; $videos[$key]['pageUrl'] = "{$global['webSiteRootURL']}video/".$videos[$key]['clean_title'];
$videos[$key]['embedUrl'] = "{$global['webSiteRootURL']}videoEmbeded/".$videos[$key]['clean_title']; $videos[$key]['embedUrl'] = "{$global['webSiteRootURL']}videoEmbeded/".$videos[$key]['clean_title'];
unset($_POST['sort']); unset($_POST['sort'], $_POST['current'], $_POST['searchPhrase']);
unset($_POST['current']);
unset($_POST['searchPhrase']);
$_REQUEST['rowCount'] = 10; $_REQUEST['rowCount'] = 10;
$_POST['sort']['created'] = "desc"; $_POST['sort']['created'] = "desc";
$videos[$key]['comments'] = Comment::getAllComments($videos[$key]['id']); $videos[$key]['comments'] = Comment::getAllComments($videos[$key]['id']);

View file

@ -318,8 +318,7 @@ class Plugin extends ObjectYPT {
foreach ($fullData as $row) { foreach ($fullData as $row) {
$getAllEnabledRows[] = $row; $getAllEnabledRows[] = $row;
if (($key = array_search($row['uuid'], $defaultEnabledUUIDs)) !== false) { if (($key = array_search($row['uuid'], $defaultEnabledUUIDs)) !== false) {
unset($defaultEnabledUUIDs[$key]); unset($defaultEnabledUUIDs[$key], $defaultEnabledNames[$key]);
unset($defaultEnabledNames[$key]);
} }
} }

View file

@ -1247,16 +1247,17 @@ if (typeof gtag !== \"function\") {
} }
} }
} }
unset($user['password']); unset($user['password'], $user['recoverPass']);
unset($user['recoverPass']);
if (!Permissions::canAdminUsers() && $user['id'] !== User::getId()) { if (!Permissions::canAdminUsers() && $user['id'] !== User::getId()) {
unset($user['first_name']); unset(
unset($user['last_name']); $user['first_name'],
unset($user['address']); $user['last_name'],
unset($user['zip_code']); $user['address'],
unset($user['country']); $user['zip_code'],
unset($user['region']); $user['country'],
unset($user['city']); $user['region'],
$user['city']
);
} }
$user = $user; $user = $user;
return $user; return $user;
@ -1507,16 +1508,17 @@ if (typeof gtag !== \"function\") {
} }
} }
} }
unset($row['password']); unset($row['password'], $row['recoverPass']);
unset($row['recoverPass']);
if (!Permissions::canAdminUsers() && $row['id'] !== User::getId()) { if (!Permissions::canAdminUsers() && $row['id'] !== User::getId()) {
unset($row['first_name']); unset(
unset($row['last_name']); $row['first_name'],
unset($row['address']); $row['last_name'],
unset($row['zip_code']); $row['address'],
unset($row['country']); $row['zip_code'],
unset($row['region']); $row['country'],
unset($row['city']); $row['region'],
$row['city']
);
} }
return $row; return $row;
} }

View file

@ -1043,8 +1043,7 @@ if (!class_exists('Video')) {
} }
$sql .= BootGrid::getSqlFromPost(array(), empty($_POST['sort']['likes']) ? "v." : "", "", true); $sql .= BootGrid::getSqlFromPost(array(), empty($_POST['sort']['likes']) ? "v." : "", "", true);
} else { } else {
unset($_POST['sort']['trending']); unset($_POST['sort']['trending'], $_GET['sort']['trending']);
unset($_GET['sort']['trending']);
$rows = array(); $rows = array();
if (!empty($_REQUEST['current']) && $_REQUEST['current'] == 1) { if (!empty($_REQUEST['current']) && $_REQUEST['current'] == 1) {
$rows = VideoStatistic::getVideosWithMoreViews($status, $showOnlyLoggedUserVideos, $showUnlisted, $suggestedOnly); $rows = VideoStatistic::getVideosWithMoreViews($status, $showOnlyLoggedUserVideos, $showUnlisted, $suggestedOnly);
@ -3607,11 +3606,7 @@ if (!class_exists('Video')) {
$get['channelName'] = $video->getChannelName(); $get['channelName'] = $video->getChannelName();
} }
unset($get['v']); unset($get['v'], $get['videoName'], $get['videoName'], $get['isMediaPlaySite'], $get['parentsOnly']);
unset($get['videoName']);
unset($get['videoName']);
unset($get['isMediaPlaySite']);
unset($get['parentsOnly']);
$get_http = http_build_query($get); $get_http = http_build_query($get);
if (empty($get_http)) { if (empty($get_http)) {
$get_http = ""; $get_http = "";

View file

@ -26,8 +26,7 @@ if (empty($_REQUEST['current'])) {
$videos = Video::getAllVideos('', $showOnlyLoggedUserVideos, true, array(), false, $showUnlisted, $activeUsersOnly); $videos = Video::getAllVideos('', $showOnlyLoggedUserVideos, true, array(), false, $showUnlisted, $activeUsersOnly);
$total = Video::getTotalVideos('', $showOnlyLoggedUserVideos, true, $showUnlisted, $activeUsersOnly); $total = Video::getTotalVideos('', $showOnlyLoggedUserVideos, true, $showUnlisted, $activeUsersOnly);
foreach ($videos as $key => $value) { foreach ($videos as $key => $value) {
unset($value['password']); unset($value['password'], $value['recoverPass']);
unset($value['recoverPass']);
$name = empty($value['name'])?$value['user']:$value['name']; $name = empty($value['name'])?$value['user']:$value['name'];
//$categories[$key]['comment'] = " <div class=\"commenterName\"><strong>{$name}</strong><div class=\"date sub-text\">{$value['created']}</div></div><div class=\"commentText\">". nl2br($value['comment'])."</div>"; //$categories[$key]['comment'] = " <div class=\"commenterName\"><strong>{$name}</strong><div class=\"date sub-text\">{$value['created']}</div></div><div class=\"commentText\">". nl2br($value['comment'])."</div>";
$videos[$key]['creator'] = '<div class="pull-left"><img src="'.User::getPhoto($value['users_id']).'" alt="User Photo" class="img img-responsive img-circle" style="max-width: 50px;"/></div><div class="commentDetails"><div class="commenterName"><strong>'.$name.'</strong>' . User::getEmailVerifiedIcon($value['users_id']) . ' <small>'.humanTiming(strtotime($value['videoCreation'])).'</small></div></div>'; $videos[$key]['creator'] = '<div class="pull-left"><img src="'.User::getPhoto($value['users_id']).'" alt="User Photo" class="img img-responsive img-circle" style="max-width: 50px;"/></div><div class="commentDetails"><div class="commenterName"><strong>'.$name.'</strong>' . User::getEmailVerifiedIcon($value['users_id']) . ' <small>'.humanTiming(strtotime($value['videoCreation'])).'</small></div></div>';
@ -54,8 +53,7 @@ foreach ($videos as $key => $value) {
} else { } else {
$videos[$key]['videosURL'] = getVideosURL($videos[$key]['filename']); $videos[$key]['videosURL'] = getVideosURL($videos[$key]['filename']);
} }
unset($videos[$key]['password']); unset($videos[$key]['password'], $videos[$key]['recoverPass']);
unset($videos[$key]['recoverPass']);
} }
$obj = new stdClass(); $obj = new stdClass();

View file

@ -45,8 +45,7 @@ if(!empty($random)){
} }
foreach ($videos as $key => $value) { foreach ($videos as $key => $value) {
unset($videos[$key]['password']); unset($videos[$key]['password'], $videos[$key]['recoverPass']);
unset($videos[$key]['recoverPass']);
$images = Video::getImageFromFilename($videos[$key]['filename'], $videos[$key]['type']); $images = Video::getImageFromFilename($videos[$key]['filename'], $videos[$key]['type']);
$videos[$key]['images'] = $images; $videos[$key]['images'] = $images;
$videos[$key]['Poster'] = !empty($objMob->portraitImage) ? $images->posterPortrait : $images->poster; $videos[$key]['Poster'] = !empty($objMob->portraitImage) ? $images->posterPortrait : $images->poster;
@ -56,9 +55,7 @@ foreach ($videos as $key => $value) {
$videos[$key]['createdHumanTiming'] = humanTiming(strtotime($videos[$key]['created'])); $videos[$key]['createdHumanTiming'] = humanTiming(strtotime($videos[$key]['created']));
$videos[$key]['pageUrl'] = "{$global['webSiteRootURL']}video/" . $videos[$key]['clean_title']; $videos[$key]['pageUrl'] = "{$global['webSiteRootURL']}video/" . $videos[$key]['clean_title'];
$videos[$key]['embedUrl'] = "{$global['webSiteRootURL']}videoEmbeded/" . $videos[$key]['clean_title']; $videos[$key]['embedUrl'] = "{$global['webSiteRootURL']}videoEmbeded/" . $videos[$key]['clean_title'];
unset($_POST['sort']); unset($_POST['sort'], $_POST['current'], $_POST['searchPhrase']);
unset($_POST['current']);
unset($_POST['searchPhrase']);
$_REQUEST['rowCount'] = 10; $_REQUEST['rowCount'] = 10;
$_POST['sort']['created'] = "desc"; $_POST['sort']['created'] = "desc";
$videos[$key]['comments'] = Comment::getAllComments($videos[$key]['id']); $videos[$key]['comments'] = Comment::getAllComments($videos[$key]['id']);