1
0
Fork 0
mirror of https://github.com/DanielnetoDotCom/YouPHPTube synced 2025-10-03 09:49:28 +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() {
unset($_GET['searchPhrase']);
unset($_POST['searchPhrase']);
unset($_GET['search']);
unset($_GET['q']);
unset($_GET['searchPhrase'], $_POST['searchPhrase'], $_GET['search'], $_GET['q']);
}
function encrypt_decrypt($string, $action) {
@ -4500,9 +4497,7 @@ function cleanSearchVar() {
}
$searchIdex = array('q', 'searchPhrase', 'search');
foreach ($searchIdex as $value) {
unset($_REQUEST[$value]);
unset($_POST[$value]);
unset($_GET[$value]);
unset($_REQUEST[$value], $_POST[$value], $_GET[$value]);
}
}

View file

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

View file

@ -33,8 +33,7 @@ $videos = PlayList::getVideosFromPlaylist($_POST['playlists_id']);
$objMob = AVideoPlugin::getObjectData("MobileManager");
foreach ($videos as $key => $value) {
unset($videos[$key]['password']);
unset($videos[$key]['recoverPass']);
unset($videos[$key]['password'], $videos[$key]['recoverPass']);
$images = Video::getImageFromFilename($videos[$key]['filename'], $videos[$key]['type']);
$videos[$key]['images'] = $images;
$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]['pageUrl'] = "{$global['webSiteRootURL']}video/".$videos[$key]['clean_title'];
$videos[$key]['embedUrl'] = "{$global['webSiteRootURL']}videoEmbeded/".$videos[$key]['clean_title'];
unset($_POST['sort']);
unset($_POST['current']);
unset($_POST['searchPhrase']);
unset($_POST['sort'], $_POST['current'], $_POST['searchPhrase']);
$_REQUEST['rowCount'] = 10;
$_POST['sort']['created'] = "desc";
$videos[$key]['comments'] = Comment::getAllComments($videos[$key]['id']);

View file

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

View file

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

View file

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

View file

@ -26,8 +26,7 @@ if (empty($_REQUEST['current'])) {
$videos = Video::getAllVideos('', $showOnlyLoggedUserVideos, true, array(), false, $showUnlisted, $activeUsersOnly);
$total = Video::getTotalVideos('', $showOnlyLoggedUserVideos, true, $showUnlisted, $activeUsersOnly);
foreach ($videos as $key => $value) {
unset($value['password']);
unset($value['recoverPass']);
unset($value['password'], $value['recoverPass']);
$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>";
$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 {
$videos[$key]['videosURL'] = getVideosURL($videos[$key]['filename']);
}
unset($videos[$key]['password']);
unset($videos[$key]['recoverPass']);
unset($videos[$key]['password'], $videos[$key]['recoverPass']);
}
$obj = new stdClass();

View file

@ -45,8 +45,7 @@ if(!empty($random)){
}
foreach ($videos as $key => $value) {
unset($videos[$key]['password']);
unset($videos[$key]['recoverPass']);
unset($videos[$key]['password'], $videos[$key]['recoverPass']);
$images = Video::getImageFromFilename($videos[$key]['filename'], $videos[$key]['type']);
$videos[$key]['images'] = $images;
$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]['pageUrl'] = "{$global['webSiteRootURL']}video/" . $videos[$key]['clean_title'];
$videos[$key]['embedUrl'] = "{$global['webSiteRootURL']}videoEmbeded/" . $videos[$key]['clean_title'];
unset($_POST['sort']);
unset($_POST['current']);
unset($_POST['searchPhrase']);
unset($_POST['sort'], $_POST['current'], $_POST['searchPhrase']);
$_REQUEST['rowCount'] = 10;
$_POST['sort']['created'] = "desc";
$videos[$key]['comments'] = Comment::getAllComments($videos[$key]['id']);