diff --git a/.phpcs.xml b/.phpcs.xml index 9a8304213..d03351fd9 100644 --- a/.phpcs.xml +++ b/.phpcs.xml @@ -29,14 +29,15 @@ - - + - + + + diff --git a/app/Artist/Similar.php b/app/Artist/Similar.php index 199fca6c6..b54e27d8a 100644 --- a/app/Artist/Similar.php +++ b/app/Artist/Similar.php @@ -135,28 +135,32 @@ class Similar extends \Gazelle\Base { // if the vote already exists in this direction: do nothing $vote = $upvote ? 'up' : 'down'; - if ((bool)self::$db->scalar(" - SELECT 1 - FROM artists_similar_votes - WHERE SimilarID = ? - AND UserID = ? - AND Way = ? - ", $similarId, $user->id(), $vote - )) { + if ( + (bool)self::$db->scalar(" + SELECT 1 + FROM artists_similar_votes + WHERE SimilarID = ? + AND UserID = ? + AND Way = ? + ", $similarId, $user->id(), $vote + ) + ) { return false; } // if the new vote is in the opposite direction of the old one, // remove the previous vote $opposite = !$upvote ? 'up' : 'down'; - if ((bool)self::$db->scalar(" + if ( + (bool)self::$db->scalar(" SELECT 1 FROM artists_similar_votes WHERE SimilarID = ? AND UserID = ? AND Way = ? ", $similarId, $user->id(), $opposite - )) { + ) + ) { self::$db->begin_transaction(); self::$db->prepared_query(" UPDATE artists_similar_scores SET diff --git a/app/ArtistRole.php b/app/ArtistRole.php index 36be2b609..8901e8d2b 100644 --- a/app/ArtistRole.php +++ b/app/ArtistRole.php @@ -120,7 +120,8 @@ abstract class ArtistRole extends \Gazelle\Base { } } - if ($composerCount > 0 + if ( + $composerCount > 0 && $mainCount > 1 && $conductorCount > 1 ) { diff --git a/app/Collage.php b/app/Collage.php index c9d2ebbff..23e459104 100644 --- a/app/Collage.php +++ b/app/Collage.php @@ -124,7 +124,8 @@ class Collage extends BaseObject { } } $groupsByUser = $this->contributors()[$this->viewer->id()] ?? 0; - if ($this->isLocked() + if ( + $this->isLocked() || ($this->maxGroups() > 0 && count($this->groupIds()) >= $this->maxGroups()) || ($this->maxGroupsPerUser() > 0 && $groupsByUser >= $this->maxGroupsPerUser()) ) { @@ -164,13 +165,15 @@ class Collage extends BaseObject { public function toggleSubscription(User $user): int { $affected = 0; - if ((bool)self::$db->scalar(" - SELECT 1 - FROM users_collage_subs - WHERE UserID = ? - AND CollageID = ? + if ( + (bool)self::$db->scalar(" + SELECT 1 + FROM users_collage_subs + WHERE UserID = ? + AND CollageID = ? ", $user->id(), $this->id - )) { + ) + ) { self::$db->prepared_query(" DELETE FROM users_collage_subs WHERE UserID = ? diff --git a/app/Debug.php b/app/Debug.php index c7fcfdd6e..ab6c1c729 100644 --- a/app/Debug.php +++ b/app/Debug.php @@ -137,7 +137,8 @@ class Debug { public function analysis($Message, $Report = ''): void { $RequestURI = empty($_SERVER['REQUEST_URI']) ? '' : substr($_SERVER['REQUEST_URI'], 1); - if (PHP_SAPI === 'cli' + if ( + PHP_SAPI === 'cli' || in_array($RequestURI, ['tools.php?action=db_sandbox']) ) { // Don't spam IRC from Boris or these pages diff --git a/app/Download.php b/app/Download.php index 6db8810e1..3382688a0 100644 --- a/app/Download.php +++ b/app/Download.php @@ -33,7 +33,8 @@ class Download extends Base { */ $user = $this->limiter->user(); $userId = $user->id(); - if ($this->torrent->uploaderId() == $userId + if ( + $this->torrent->uploaderId() == $userId || $user->snatch()->isSnatched($this->torrent) || $user->isSeeding($this->torrent) ) { @@ -62,7 +63,8 @@ class Download extends Base { * and they have already downloaded too many files recently, then * stop them. Exception: always allowed if they are using FL tokens. */ - if (!$this->useToken + if ( + !$this->useToken && $this->torrent->uploaderId() != $userId && $this->limiter->isOvershoot($this->torrent) ) { diff --git a/app/Enum/LeechReason.php b/app/Enum/LeechReason.php index 6ee8d2a42..616e9747e 100644 --- a/app/Enum/LeechReason.php +++ b/app/Enum/LeechReason.php @@ -18,4 +18,4 @@ enum LeechReason: string { LeechReason::AlbumOfTheMonth => 'Album of the Month', /** @phpstan-ignore-line */ }; } -}; +} diff --git a/app/Enum/LeechType.php b/app/Enum/LeechType.php index 2daa640a1..0e176aa21 100644 --- a/app/Enum/LeechType.php +++ b/app/Enum/LeechType.php @@ -14,4 +14,4 @@ enum LeechType: string { LeechType::Free => 'Freeleech', /** @phpstan-ignore-line */ }; } -}; +} diff --git a/app/Json/ForumThread.php b/app/Json/ForumThread.php index cdfa58b0b..a701d7a56 100644 --- a/app/Json/ForumThread.php +++ b/app/Json/ForumThread.php @@ -21,7 +21,8 @@ class ForumThread extends \Gazelle\Json { $lastPost = end($slice); $lastPostId = $lastPost['ID']; reset($slice); - if ($thread->postTotal() <= $paginator->perPage() * $paginator->page() + if ( + $thread->postTotal() <= $paginator->perPage() * $paginator->page() && $thread->pinnedPostId() > $lastPostId ) { $lastPostId = $thread->pinnedPostId(); diff --git a/app/Manager/Forum.php b/app/Manager/Forum.php index f4667ae87..2118e3f70 100644 --- a/app/Manager/Forum.php +++ b/app/Manager/Forum.php @@ -105,7 +105,7 @@ class Forum extends \Gazelle\BaseManager { */ public function tableOfContentsMain(): array { $toc = self::$cache->get_value(self::CACHE_TOC_MAIN); - if ($toc === false ) { + if ($toc === false) { self::$db->prepared_query(" SELECT cat.Name AS categoryName, cat.ID AS categoryId, f.ID, f.Name, f.Description, f.NumTopics, f.NumPosts, diff --git a/app/Manager/NotificationTicket.php b/app/Manager/NotificationTicket.php index 718a7e0e8..356391e55 100644 --- a/app/Manager/NotificationTicket.php +++ b/app/Manager/NotificationTicket.php @@ -16,10 +16,12 @@ class NotificationTicket { } public function findById(int $torrentId): ?\Gazelle\NotificationTicket { - if ($this->pg()->scalar(" - select 1 from notification_ticket where id_torrent = ? - ", $torrentId - )) { + if ( + $this->pg()->scalar(" + select 1 from notification_ticket where id_torrent = ? + ", $torrentId + ) + ) { return new \Gazelle\NotificationTicket($torrentId); } return null; diff --git a/app/Search/Torrent.php b/app/Search/Torrent.php index fd4c6a528..f063e85fb 100644 --- a/app/Search/Torrent.php +++ b/app/Search/Torrent.php @@ -5,10 +5,10 @@ namespace Gazelle\Search; use Gazelle\Enum\LeechType; class Torrent { - final const TAGS_ANY = 0; - final const TAGS_ALL = 1; - final const SPH_BOOL_AND = ' '; - final const SPH_BOOL_OR = ' | '; + final protected const TAGS_ANY = 0; + final protected const TAGS_ALL = 1; + final protected const SPH_BOOL_AND = ' '; + final protected const SPH_BOOL_OR = ' | '; /** * Map of sort mode => attribute name for ungrouped torrent page @@ -185,7 +185,8 @@ class Torrent { protected int $PageSize, protected readonly bool $searchMany, ) { - if ($this->GroupResults && !isset(self::$SortOrdersGrouped[$OrderBy]) + if ( + $this->GroupResults && !isset(self::$SortOrdersGrouped[$OrderBy]) || !$this->GroupResults && !isset(self::$SortOrders[$OrderBy]) || !in_array($OrderWay, ['asc', 'desc']) ) { diff --git a/app/Stats/Economic.php b/app/Stats/Economic.php index 73585ec6f..782cee596 100644 --- a/app/Stats/Economic.php +++ b/app/Stats/Economic.php @@ -20,7 +20,7 @@ class Economic extends \Gazelle\Base { return $this->info; } $info = self::$cache->get_value(self::CACHE_KEY); - if ($info === false ) { + if ($info === false) { $info = self::$db->rowAssoc(" SELECT sum(uls.Uploaded) AS upload_total, sum(uls.Downloaded) AS download_total diff --git a/app/User/Bookmark.php b/app/User/Bookmark.php index d572f303a..84a625574 100644 --- a/app/User/Bookmark.php +++ b/app/User/Bookmark.php @@ -37,10 +37,12 @@ class Bookmark extends \Gazelle\BaseUser { */ public function create(string $type, int $id): bool { [$table, $column] = $this->schema($type); - if ((bool)self::$db->scalar(" - SELECT 1 FROM $table WHERE UserID = ? AND $column = ? - ", $this->user->id(), $id - )) { + if ( + (bool)self::$db->scalar(" + SELECT 1 FROM $table WHERE UserID = ? AND $column = ? + ", $this->user->id(), $id + ) + ) { // overbooked return false; } diff --git a/app/User/Stylesheet.php b/app/User/Stylesheet.php index c402fc7eb..a8146e790 100644 --- a/app/User/Stylesheet.php +++ b/app/User/Stylesheet.php @@ -81,10 +81,12 @@ class Stylesheet extends \Gazelle\BaseUser { . base_convert((string)filemtime(SERVER_ROOT . '/sass/' . preg_replace('/\.css$/', '.scss', $this->cssName())), 10, 36); } $info = parse_url($url); - if (str_ends_with($info['path'] ?? '', '.css') + if ( + str_ends_with($info['path'] ?? '', '.css') && (($info['query'] ?? '') . ($info['fragment'] ?? '')) === '' && ($info['host'] ?? '') === SITE_HOST - && file_exists(SERVER_ROOT . $info['path'])) { + && file_exists(SERVER_ROOT . $info['path']) + ) { $url .= '?v=' . filemtime(SERVER_ROOT . "/sass/{$info['path']}"); } return $url; diff --git a/ci-coverage.php b/ci-coverage.php index 3f1d4d8bb..1ec820546 100644 --- a/ci-coverage.php +++ b/ci-coverage.php @@ -24,7 +24,7 @@ class CoverageHelper { * ensure coverage is saved if die() is called somewhere */ - const TARGET_DIR = '/tmp/coverage'; + protected const TARGET_DIR = '/tmp/coverage'; private CodeCoverage $coverage; public function __construct() { diff --git a/gazelle.php b/gazelle.php index 47e1313dd..d7c0f2dac 100644 --- a/gazelle.php +++ b/gazelle.php @@ -30,7 +30,8 @@ require_once(__DIR__ . '/lib/bootstrap.php'); global $Cache, $Debug, $Twig; // Get the user's actual IP address if they're proxied. -if (!empty($_SERVER['HTTP_X_FORWARDED_FOR']) +if ( + !empty($_SERVER['HTTP_X_FORWARDED_FOR']) && proxyCheck($_SERVER['REMOTE_ADDR']) && filter_var($_SERVER['HTTP_X_FORWARDED_FOR'], FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) ) { diff --git a/misc/phinx/migrations/20240407000000_users_info_fkey_cascade.php b/misc/phinx/migrations/20240407000000_users_info_fkey_cascade.php index 24c4e8ef4..1f9570c60 100644 --- a/misc/phinx/migrations/20240407000000_users_info_fkey_cascade.php +++ b/misc/phinx/migrations/20240407000000_users_info_fkey_cascade.php @@ -1,4 +1,5 @@ table('xbt_client_whitelist')->insert([ 'vstring' => $client[0], 'peer_id' => $client[1], diff --git a/misc/phinx/seeds/EmailBlacklistSeeder.php b/misc/phinx/seeds/EmailBlacklistSeeder.php index fed966fbb..7748d7a4d 100644 --- a/misc/phinx/seeds/EmailBlacklistSeeder.php +++ b/misc/phinx/seeds/EmailBlacklistSeeder.php @@ -5,7 +5,8 @@ use Phinx\Seed\AbstractSeed; class EmailBlacklistSeeder extends AbstractSeed { public function run() { /* the first few domains from https://github.com/ivolo/disposable-email-domains/ */ - foreach ([ + foreach ( + [ "0-180.com", "0-30-24.com", "0-420.com", "0-900.com", "0-aa.com", "0-mail.com", "0-z.xyz", "00.pe", "000000pay.com", "000476.com", "000521.xyz", "00082aa.com", "00082cc.com", "00082ff.com", @@ -29,7 +30,8 @@ class EmailBlacklistSeeder extends AbstractSeed { "01155555.com", "0124445.com", "0134445.com", "01502.monster", "0164445.com", "01689306707.mobi", "0174445.com", "0184445.com", "0188.info", "0188019.com", "01911.ru", "019352.com", "019625.com", - ] as $email) { + ] as $email + ) { $this->table('email_blacklist')->insert([ 'Email' => $email, 'Comment' => 'Initial seed', diff --git a/misc/phinx/seeds/UserAttrHideVote.php b/misc/phinx/seeds/UserAttrHideVote.php index 128901187..488eb867c 100644 --- a/misc/phinx/seeds/UserAttrHideVote.php +++ b/misc/phinx/seeds/UserAttrHideVote.php @@ -6,10 +6,12 @@ class UserAttrHideVote extends AbstractSeed { public function run() { - foreach ([ + foreach ( + [ ['hide-vote-recent', 'Do not show recent votes on profile page'], ['hide-vote-history', 'Do not show link to vote history on profile page'], - ] as $row) { + ] as $row + ) { $this->table('user_attr')->insert([ 'Name' => $row[0], 'Description' => $row[1], diff --git a/public/feeds.php b/public/feeds.php index c3c6590a6..f1b94b2bc 100644 --- a/public/feeds.php +++ b/public/feeds.php @@ -9,7 +9,8 @@ require_once(__DIR__ . '/../lib/bootstrap.php'); $feed = new Gazelle\Feed(); $user = (new Gazelle\Manager\User())->findById((int)($_GET['user'] ?? 0)); -if (!$user?->isEnabled() +if ( + !$user?->isEnabled() || empty($_GET['feed']) || md5($user->id() . RSS_HASH . ($_GET['passkey'] ?? 'NOTPASS')) !== ($_GET['auth'] ?? 'NOTAUTH') ) { diff --git a/sections/collages/edit_handle.php b/sections/collages/edit_handle.php index 1a8de5f44..c344c60cb 100644 --- a/sections/collages/edit_handle.php +++ b/sections/collages/edit_handle.php @@ -53,7 +53,8 @@ if (!isset($_POST['regen-tags'])) { } $collage->setField('Description', trim($_POST['description'])); -if (isset($_POST['featured']) +if ( + isset($_POST['featured']) && ( ($collage->isPersonal() && $collage->isOwner($Viewer)) || $Viewer->permitted('site_collages_delete') @@ -62,7 +63,8 @@ if (isset($_POST['featured']) $collage->setFeatured(); } -if (($collage->isPersonal() && $collage->isOwner($Viewer) && $Viewer->permitted('site_collages_renamepersonal')) +if ( + ($collage->isPersonal() && $collage->isOwner($Viewer) && $Viewer->permitted('site_collages_renamepersonal')) || $Viewer->permitted('site_collages_delete') ) { $collage->setField('Name', trim($_POST['name'])); diff --git a/sections/forums/thread.php b/sections/forums/thread.php index 457997676..11b2819cf 100644 --- a/sections/forums/thread.php +++ b/sections/forums/thread.php @@ -119,7 +119,7 @@ foreach ($slice as $Key => $Post) { (!$thread->isLocked() || $thread->isPinned()) && $PostID > $lastRead && strtotime($AddedTime) > $Viewer->forumCatchupEpoch() - ) { + ) { $tableClass[] = 'forum_unread'; } if (!$Viewer->showAvatars()) { diff --git a/sections/reportsv2/static.php b/sections/reportsv2/static.php index 031d1b21b..cfa988972 100644 --- a/sections/reportsv2/static.php +++ b/sections/reportsv2/static.php @@ -387,7 +387,7 @@ if ($search->canUnclaim($Viewer)) { message() ?? '' ?> - +   diff --git a/sections/requests/take_fill.php b/sections/requests/take_fill.php index af72b845a..6548a32b9 100644 --- a/sections/requests/take_fill.php +++ b/sections/requests/take_fill.php @@ -44,7 +44,8 @@ if (!empty($_REQUEST['user']) && $Viewer->permitted('site_moderate_requests')) { } else { $filler = $Viewer; } -if ($torrent->isUploadGracePeriod() +if ( + $torrent->isUploadGracePeriod() && $torrent->uploader()->id() !== $filler->id() && !$Viewer->permitted('site_moderate_requests') ) { diff --git a/sections/requests/unfill_handle.php b/sections/requests/unfill_handle.php index 4eb49dbd9..c4283187d 100644 --- a/sections/requests/unfill_handle.php +++ b/sections/requests/unfill_handle.php @@ -6,7 +6,8 @@ $request = (new Gazelle\Manager\Request())->findById((int)$_REQUEST['id']); if (is_null($request)) { error(404); } -if ($request->fillerId() === 0 +if ( + $request->fillerId() === 0 || ( !in_array($Viewer->id(), [$request->userId(), $request->fillerId()]) && !$Viewer->permitted('site_moderate_requests') diff --git a/sections/tools/managers/email_blacklist_alter.php b/sections/tools/managers/email_blacklist_alter.php index 6edde0363..3fec2a575 100644 --- a/sections/tools/managers/email_blacklist_alter.php +++ b/sections/tools/managers/email_blacklist_alter.php @@ -25,20 +25,24 @@ if ($_POST['submit'] === 'Delete') { // Delete } if ($_POST['submit'] === 'Edit') { // Edit - if (!$emailBlacklist->modify( - id: (int)$_POST['id'], - domain: $email, - comment: trim($_POST['comment']), - user: $Viewer, - )) { + if ( + !$emailBlacklist->modify( + id: (int)$_POST['id'], + domain: $email, + comment: trim($_POST['comment']), + user: $Viewer, + ) + ) { error(0); } } else { // Create - if (!$emailBlacklist->create( - domain: $email, - comment: trim($_POST['comment']), - user: $Viewer, - )) { + if ( + !$emailBlacklist->create( + domain: $email, + comment: trim($_POST['comment']), + user: $Viewer, + ) + ) { error(0); } } diff --git a/sections/tools/managers/ocelot.php b/sections/tools/managers/ocelot.php index 59b98f9c0..4a1ebd831 100644 --- a/sections/tools/managers/ocelot.php +++ b/sections/tools/managers/ocelot.php @@ -2,12 +2,14 @@ /* This page is called only by Ocelot */ -if (!( - ($_SERVER['REMOTE_ADDR'] ?? '') === TRACKER_HOST - && ($_GET['key'] ?? '') === TRACKER_SECRET - && ($_GET['type'] ?? '') === 'expiretoken' - && isset($_GET['tokens']) -)) { +if ( + !( + ($_SERVER['REMOTE_ADDR'] ?? '') === TRACKER_HOST + && ($_GET['key'] ?? '') === TRACKER_SECRET + && ($_GET['type'] ?? '') === 'expiretoken' + && isset($_GET['tokens']) + ) +) { error(403); } diff --git a/sections/torrents/details.php b/sections/torrents/details.php index b6153d812..8fed75be3 100644 --- a/sections/torrents/details.php +++ b/sections/torrents/details.php @@ -265,7 +265,8 @@ if (!$torrentList) {
Last active: lastActiveDate()); ?> isReseedRequestAllowed() || $Viewer->permitted('users_mod') + if ( + $torrent->isReseedRequestAllowed() || $Viewer->permitted('users_mod') ) { ?>
permitted('users_mod')) { $args = array_merge($args, ['0', '0']); } - foreach ([ - (object)['flag' => TorrentFlag::badFile, 'property' => 'BadFiles'], - (object)['flag' => TorrentFlag::badFolder, 'property' => 'BadFolders'], - (object)['flag' => TorrentFlag::badTag, 'property' => 'BadTags'], - (object)['flag' => TorrentFlag::cassette, 'property' => 'CassetteApproved'], - (object)['flag' => TorrentFlag::lossyMaster, 'property' => 'LossymasterApproved'], - (object)['flag' => TorrentFlag::lossyWeb, 'property' => 'LossywebApproved'], - ] as $f) { + foreach ( + [ + (object)['flag' => TorrentFlag::badFile, 'property' => 'BadFiles'], + (object)['flag' => TorrentFlag::badFolder, 'property' => 'BadFolders'], + (object)['flag' => TorrentFlag::badTag, 'property' => 'BadTags'], + (object)['flag' => TorrentFlag::cassette, 'property' => 'CassetteApproved'], + (object)['flag' => TorrentFlag::lossyMaster, 'property' => 'LossymasterApproved'], + (object)['flag' => TorrentFlag::lossyWeb, 'property' => 'LossywebApproved'], + ] as $f + ) { $exists = $torrent->hasFlag($f->flag); if (!$exists && $Properties[$f->property]) { $change[] = "{$f->flag->label()} checked"; diff --git a/sections/upload/upload_handle.php b/sections/upload/upload_handle.php index 73e3ef68b..5811db3f4 100644 --- a/sections/upload/upload_handle.php +++ b/sections/upload/upload_handle.php @@ -209,7 +209,7 @@ switch ($categoryName) { if (!$Properties['UnknownRelease']) { $Validate->setField('remaster_year', true, 'number', 'Year of remaster/re-issue must be entered.'); } - if ($Properties['Media'] == 'CD' ) { + if ($Properties['Media'] == 'CD') { $Validate->setField('remaster_year', true, 'number', 'You have selected a year for an album that predates the media you say it was created on.', ['minlength' => 1982] ); @@ -443,7 +443,8 @@ foreach ($FileList as ['path' => $filename, 'size' => $size]) { if ($Properties['Encoding'] == "Lossless" && preg_match('/\.cue$/i', $filename)) { $hasCue = true; } - if ($Properties['Media'] == 'CD' + if ( + $Properties['Media'] == 'CD' && $Properties['Encoding'] == "Lossless" && !in_array(strtolower($filename), IGNORE_AUDIO_LOGFILE) && preg_match('/\.log$/i', $filename) diff --git a/sections/user/edit_handle.php b/sections/user/edit_handle.php index 29e61675c..ed2bd4392 100644 --- a/sections/user/edit_handle.php +++ b/sections/user/edit_handle.php @@ -228,19 +228,21 @@ foreach ($notification as $n) { } (new Gazelle\User\Notification($user))->save($settings, ["PushKey" => $_POST['pushkey']], $_POST['pushservice'], $_POST['pushdevice']); -foreach ([ - 'admin-error-reporting' => isset($_POST['error_reporting']), - 'download-as-text' => isset($_POST['downloadtext']), - 'hide-tags' => isset($_POST['hidetags']), - 'hide-vote-history' => !isset($_POST['pattr_hide_vote_history']), - 'hide-vote-recent' => !isset($_POST['pattr_hide_vote_recent']), - 'no-fl-gifts' => !isset($_POST['acceptfltoken']), - 'no-pm-delete-download' => !isset($_POST['notifyondeletedownloaded']), - 'no-pm-delete-seed' => !isset($_POST['notifyondeleteseeding']), - 'no-pm-delete-snatch' => !isset($_POST['notifyondeletesnatched']), - 'no-pm-unseeded-snatch' => !isset($_POST['notifyonunseededsnatch']), - 'no-pm-unseeded-upload' => !isset($_POST['notifyonunseededupload']), -] as $attr => $state) { +foreach ( + [ + 'admin-error-reporting' => isset($_POST['error_reporting']), + 'download-as-text' => isset($_POST['downloadtext']), + 'hide-tags' => isset($_POST['hidetags']), + 'hide-vote-history' => !isset($_POST['pattr_hide_vote_history']), + 'hide-vote-recent' => !isset($_POST['pattr_hide_vote_recent']), + 'no-fl-gifts' => !isset($_POST['acceptfltoken']), + 'no-pm-delete-download' => !isset($_POST['notifyondeletedownloaded']), + 'no-pm-delete-seed' => !isset($_POST['notifyondeleteseeding']), + 'no-pm-delete-snatch' => !isset($_POST['notifyondeletesnatched']), + 'no-pm-unseeded-snatch' => !isset($_POST['notifyonunseededsnatch']), + 'no-pm-unseeded-upload' => !isset($_POST['notifyonunseededupload']), + ] as $attr => $state +) { $user->toggleAttr($attr, $state); } diff --git a/sections/user/moderate_handle.php b/sections/user/moderate_handle.php index 22f3573f4..0daaf2d4c 100644 --- a/sections/user/moderate_handle.php +++ b/sections/user/moderate_handle.php @@ -176,8 +176,10 @@ if ($flTokens != $user->tokenCount() && ($editRatio || $Viewer->permitted('admin } $newBonusPoints = false; -if (!in_array($bonusPoints, [$user->bonusPointsTotal(), (float)($_POST['OldBonusPoints'])]) - && ($Viewer->permitted('users_edit_ratio') || ($Viewer->permitted('users_edit_own_ratio') && $ownProfile))) { +if ( + !in_array($bonusPoints, [$user->bonusPointsTotal(), (float)($_POST['OldBonusPoints'])]) + && ($Viewer->permitted('users_edit_ratio') || ($Viewer->permitted('users_edit_own_ratio') && $ownProfile)) +) { $newBonusPoints = $bonusPoints; $editSummary[] = "bonus points changed from {$user->bonusPointsTotal()} to {$bonusPoints}"; } @@ -188,7 +190,8 @@ if ($unlimitedDownload !== $user->hasUnlimitedDownload() && $Viewer->permitted(' } } -if ($Collages != $user->paidPersonalCollages() && $Collages != (int)$_POST['OldCollages'] +if ( + $Collages != $user->paidPersonalCollages() && $Collages != (int)$_POST['OldCollages'] && ($Viewer->permitted('users_edit_ratio') || ($Viewer->permitted('users_edit_own_ratio') && $ownProfile)) ) { $user->setField('collage_total', $Collages); @@ -218,11 +221,13 @@ if ($editRatio) { if ($class) { $Classes = $userMan->classList(); $newClass = $Classes[$class]['Level']; - if ($newClass != $user->classLevel() + if ( + $newClass != $user->classLevel() && ( ($newClass < $Viewer->classLevel() && $Viewer->permitted('users_promote_below')) || ($newClass <= $Viewer->classLevel() && $Viewer->permitted('users_promote_to')) - )) { + ) + ) { $user->setField('PermissionID', $class); $editSummary[] = 'class changed to ' . $userMan->userclassName($class); diff --git a/tests/phpunit/ReaperTest.php b/tests/phpunit/ReaperTest.php index 1775fe7be..274b69afc 100644 --- a/tests/phpunit/ReaperTest.php +++ b/tests/phpunit/ReaperTest.php @@ -1,9 +1,5 @@ upvote($this->tgroupList[0]); $vote[2]->downvote($this->tgroupList[0]); $this->assertEquals(0.32115, round($vote[0]->score($this->tgroupList[0]), 5), 'tg-vote-3-1'); - + $top = $vote[0]->topVotes(); $this->assertEquals(2, $top[$this->tgroupList[0]->id()]['Ups'], 'tgroup-downvote-top-up'); $this->assertEquals(3, $top[$this->tgroupList[0]->id()]['Total'], 'tgroup-downvote-top-total'); diff --git a/tests/phpunit/manager/CollageFreeleechTest.php b/tests/phpunit/manager/CollageFreeleechTest.php index b30574cfa..b604316fd 100644 --- a/tests/phpunit/manager/CollageFreeleechTest.php +++ b/tests/phpunit/manager/CollageFreeleechTest.php @@ -38,7 +38,8 @@ class CollageFreeleechTest extends TestCase { logger: new \Gazelle\Log(), ); foreach ($this->tgroupList as $tgroup) { - foreach ([ + foreach ( + [ ['format' => 'FLAC', 'size' => 10_000_000], ['format' => 'FLAC', 'size' => 15_000_000], ['format' => 'MP3', 'size' => 2_000_000],