diff --git a/.phpcs.xml b/.phpcs.xml index 063ed84b4..b9c90808f 100644 --- a/.phpcs.xml +++ b/.phpcs.xml @@ -39,8 +39,6 @@ - - classes/* misc/phinx/* @@ -62,5 +60,34 @@ warning + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Makefile b/Makefile index 4afeac440..f4a99f0d0 100644 --- a/Makefile +++ b/Makefile @@ -39,7 +39,7 @@ build-css: .PHONY: check-php check-php: - git status | awk '/(modified|new file):.*\.php$$/ {print $$NF}' | xargs -n1 php -l + git status | awk '/(modified|new file):.*\.php$$/ {print $$NF}' | xargs php -l .PHONY: composer-dev-update composer-dev-update: @@ -79,7 +79,13 @@ lint-js: .PHONY: lint-php lint-php: - find . -path vendor -prune -o -path node_modules -prune -o -path misc/docker -prune -o -type f -name '*.php' -print0 | xargs -0 -n1 -P4 php -l -n | grep -v '^No syntax errors detected in' || true + find . -path ./vendor -prune \ + -o -path ./cache -prune \ + -o -path ./node_modules -prune \ + -o -path ./misc/docker -prune \ + -o -type f -name '*.php' \ + print0 \ + | xargs -0 php -l -n | grep -v '^No syntax errors detected in' || true vendor/bin/phpcs -p --report-width=256 vendor/bin/phpstan analyse --memory-limit=1024M --configuration=misc/phpstan.neon diff --git a/app/Applicant.php b/app/Applicant.php index 17ffab00e..f8ca05d4f 100644 --- a/app/Applicant.php +++ b/app/Applicant.php @@ -16,8 +16,14 @@ class Applicant extends BaseObject { unset($this->info); return $this; } - public function link(): string { return sprintf('%s', $this->url(), html_escape($this->role()->title())); } - public function location(): string { return 'apply.php?action=view&id=' . $this->id; } + + public function link(): string { + return sprintf('%s', $this->url(), html_escape($this->role()->title())); + } + + public function location(): string { + return 'apply.php?action=view&id=' . $this->id; + } public function info(): array { if (isset($this->info)) { diff --git a/app/ApplicantRole.php b/app/ApplicantRole.php index a31ac707a..e4a915482 100644 --- a/app/ApplicantRole.php +++ b/app/ApplicantRole.php @@ -11,8 +11,14 @@ class ApplicantRole extends BaseObject { unset($this->info); return $this; } - public function link(): string { return sprintf('%s', $this->url(), html_escape($this->title())); } - public function location(): string { return 'apply.php?action=view&id=' . $this->id; } + + public function link(): string { + return sprintf('%s', $this->url(), html_escape($this->title())); + } + + public function location(): string { + return 'apply.php?action=view&id=' . $this->id; + } public function info(): array { if (isset($this->info)) { diff --git a/app/Artist.php b/app/Artist.php index cf81fed91..16c28ac9a 100644 --- a/app/Artist.php +++ b/app/Artist.php @@ -53,8 +53,13 @@ class Artist extends BaseObject implements CollageEntry { return $this; } - public function link(): string { return sprintf('%s', $this->url(), display_str($this->name())); } - public function location(): string { return 'artist.php?id=' . $this->id; } + public function link(): string { + return sprintf('%s', $this->url(), display_str($this->name())); + } + + public function location(): string { + return 'artist.php?id=' . $this->id; + } public function info(): array { $cacheKey = $this->cacheKey(); @@ -909,6 +914,7 @@ class Artist extends BaseObject implements CollageEntry { } /* STATIC METHODS - for when you do not yet have an ID, e.g. during creation */ + /** * Collapse whitespace and directional markers, because people copypaste carelessly. * TODO: make stricter, e.g. on all whitespace characters or Unicode normalisation diff --git a/app/ArtistRole.php b/app/ArtistRole.php index 4f8143500..a2c7ab47e 100644 --- a/app/ArtistRole.php +++ b/app/ArtistRole.php @@ -13,7 +13,9 @@ abstract class ArtistRole extends \Gazelle\Base { protected array $idList; abstract protected function artistListQuery(): \mysqli_result|bool; + abstract public function idList(): array; + abstract public function roleList(): array; public function __construct( diff --git a/app/BaseObject.php b/app/BaseObject.php index 0249ca5bc..e71b63a4a 100644 --- a/app/BaseObject.php +++ b/app/BaseObject.php @@ -18,7 +18,9 @@ abstract class BaseObject extends Base { ) {} abstract public function flush(): static; + abstract public function link(): string; + abstract public function location(): string; public function id(): int { diff --git a/app/Better/AbstractBetter.php b/app/Better/AbstractBetter.php index a576bedf5..e15fd3f21 100644 --- a/app/Better/AbstractBetter.php +++ b/app/Better/AbstractBetter.php @@ -116,8 +116,7 @@ abstract class AbstractBetter extends \Gazelle\Base { return "SELECT " . ($this->distinct ? 'DISTINCT ' : '') . $this->field . " " . $this->buildQuery() . " " . $this->orderBy - . " LIMIT ? OFFSET ?" - ; + . " LIMIT ? OFFSET ?"; } public function list(int $limit, int $offset): array { diff --git a/app/Cache.php b/app/Cache.php index dd4a378e6..8fae70f28 100644 --- a/app/Cache.php +++ b/app/Cache.php @@ -114,6 +114,7 @@ class Cache extends \Memcached { $this->elapsed += (microtime(true) - $begin) * 1000; return $ret; } + public function delete_multi(array $list): array { $begin = microtime(true); if (empty($list)) { diff --git a/app/Collage.php b/app/Collage.php index 12b31473e..325cda32e 100644 --- a/app/Collage.php +++ b/app/Collage.php @@ -39,8 +39,14 @@ class Collage extends BaseObject { unset($this->info); return $this; } - public function link(): string { return sprintf('%s', $this->url(), display_str($this->name())); } - public function location(): string { return 'collages.php?id=' . $this->id; } + + public function link(): string { + return sprintf('%s', $this->url(), display_str($this->name())); + } + + public function location(): string { + return 'collages.php?id=' . $this->id; + } public function info(): array { if (isset($this->info)) { @@ -83,36 +89,97 @@ class Collage extends BaseObject { return $this->info; } - public function categoryId(): int { return $this->info()['category_id']; } - public function description(): string { return $this->info()['description']; } - public function maxGroups(): int { return $this->info()['group_max']; } - public function maxGroupsPerUser(): int { return $this->info()['group_max_per_user']; } - public function name(): string { return $this->info()['name']; } - public function numSubscribers(): int { return $this->info()['subscriber_total']; } - public function ownerId(): int { return $this->info()['user_id']; } - public function tags(): array { return $this->info()['tag_list']; } - public function updated(): ?string { return $this->info()['updated']; } + public function categoryId(): int { + return $this->info()['category_id']; + } - public function numEntries(): int { return $this->info()['torrent_total']; } - public function groupIds(): array { return $this->collage->groupIdList(); /** @phpstan-ignore-line */ } + public function description(): string { + return $this->info()['description']; + } - public function isDeleted(): bool { return $this->info()['is_deleted'] === '1'; } - public function isFeatured(): bool { return (bool)$this->info()['is_featured']; } - public function isLocked(): bool { return $this->info()['is_locked'] == '1' || $this->lockedForUser; } - public function isOwner(User $user): bool { return $this->info()['user_id'] === $user->id(); } - public function isPersonal(): bool { return $this->info()['category_id'] === CollageType::personal->value; } + public function maxGroups(): int { + return $this->info()['group_max']; + } - public function isArtist(): bool { return $this->categoryId() === CollageType::artist->value; } - public function contributors(): array { return $this->collage->contributorList(); } + public function maxGroupsPerUser(): int { + return $this->info()['group_max_per_user']; + } - public function numContributors(): int { return count(array_keys($this->contributors())); } - public function numArtists(): int { return count($this->collage->artistList()); } - public function sequence(int $entryId): int { return $this->collage->sequence($entryId); /** @phpstan-ignore-line */ } + public function name(): string { + return $this->info()['name']; + } + + public function numSubscribers(): int { + return $this->info()['subscriber_total']; + } + + public function ownerId(): int { + return $this->info()['user_id']; + } + + public function tags(): array { + return $this->info()['tag_list']; + } + + public function updated(): ?string { + return $this->info()['updated']; + } + + public function numEntries(): int { + return $this->info()['torrent_total']; + } + + public function groupIds(): array { + return $this->collage->groupIdList(); /** @phpstan-ignore-line */ + } + + public function isDeleted(): bool { + return $this->info()['is_deleted'] === '1'; + } + + public function isFeatured(): bool { + return (bool)$this->info()['is_featured']; + } + + public function isLocked(): bool { + return $this->info()['is_locked'] == '1' || $this->lockedForUser; + } + + public function isOwner(User $user): bool { + return $this->info()['user_id'] === $user->id(); + } + + public function isPersonal(): bool { + return $this->info()['category_id'] === CollageType::personal->value; + } + + public function isArtist(): bool { + return $this->categoryId() === CollageType::artist->value; + } + + public function contributors(): array { + return $this->collage->contributorList(); + } + + public function numContributors(): int { + return count(array_keys($this->contributors())); + } + + public function numArtists(): int { + return count($this->collage->artistList()); + } + + public function sequence(int $entryId): int { + return $this->collage->sequence($entryId); /** @phpstan-ignore-line */ + } public function hasAttr(string $name): bool { return isset($this->info()['attr'][$name]); } - public function sortNewest(): bool { return $this->hasAttr('sort-newest'); } + + public function sortNewest(): bool { + return $this->hasAttr('sort-newest'); + } public function setViewer(User $viewer): static { $this->viewer = $viewer; diff --git a/app/Collage/AbstractCollage.php b/app/Collage/AbstractCollage.php index ad785f984..116a9e009 100644 --- a/app/Collage/AbstractCollage.php +++ b/app/Collage/AbstractCollage.php @@ -11,9 +11,13 @@ abstract class AbstractCollage extends \Gazelle\Base { protected array $created; abstract public function entryTable(): string; + abstract public function entryColumn(): string; + abstract public function entryList(): array; + abstract public function load(): int; + abstract public function rebuildTagList(): array; abstract protected function flushTarget(CollageEntry $target): void; diff --git a/app/Collage/Artist.php b/app/Collage/Artist.php index f5e6b5ebb..e8fd96435 100644 --- a/app/Collage/Artist.php +++ b/app/Collage/Artist.php @@ -5,8 +5,13 @@ namespace Gazelle\Collage; use Gazelle\Intf\CollageEntry; class Artist extends AbstractCollage { - public function entryTable(): string { return 'collages_artists'; } - public function entryColumn(): string { return 'ArtistID'; } + public function entryTable(): string { + return 'collages_artists'; + } + + public function entryColumn(): string { + return 'ArtistID'; + } public function load(): int { self::$db->prepared_query(" diff --git a/app/Collage/TGroup.php b/app/Collage/TGroup.php index fc1ef5ed7..621d5f414 100644 --- a/app/Collage/TGroup.php +++ b/app/Collage/TGroup.php @@ -9,8 +9,13 @@ class TGroup extends AbstractCollage { protected array $sequence = []; protected array $torrentTags; - public function entryTable(): string { return 'collages_torrents'; } - public function entryColumn(): string { return 'GroupID'; } + public function entryTable(): string { + return 'collages_torrents'; + } + + public function entryColumn(): string { + return 'GroupID'; + } public function groupIdList(): array { if (!isset($this->groupIds)) { diff --git a/app/Collector.php b/app/Collector.php index c4ccfaeec..1239f1821 100644 --- a/app/Collector.php +++ b/app/Collector.php @@ -57,6 +57,7 @@ abstract class Collector extends Base { protected float $startTime; abstract public function prepare(array $list): bool; + abstract public function fillZip(\ZipStream\ZipStream $zip): int; public function __construct( diff --git a/app/Comment/AbstractComment.php b/app/Comment/AbstractComment.php index 1c241c97e..72e7c8b37 100644 --- a/app/Comment/AbstractComment.php +++ b/app/Comment/AbstractComment.php @@ -12,14 +12,21 @@ abstract class AbstractComment extends \Gazelle\BaseObject { protected array $thread = []; // the page of comments abstract public function page(): string; + abstract public function pageUrl(): string; public function flush(): static { // No-op: There is no such thing as an individual comment cache return $this; } - public function link(): string { return sprintf('%s', $this->url(), "Comment #" . $this->id); } - public function location(): string { return $this->pageUrl() . "{$this->pageId}&postid={$this->id}#post{$this->id}"; } + + public function link(): string { + return sprintf('%s', $this->url(), "Comment #" . $this->id); + } + + public function location(): string { + return $this->pageUrl() . "{$this->pageId}&postid={$this->id}#post{$this->id}"; + } public function __construct( protected int $pageId, diff --git a/app/Contest.php b/app/Contest.php index 54758c58a..0c0cef73c 100644 --- a/app/Contest.php +++ b/app/Contest.php @@ -16,8 +16,14 @@ class Contest extends BaseObject { $this->info = []; return $this; } - public function link(): string { return "url()}\">{$this->name()}"; } - public function location(): string { return "contest.php?id={$this->id}"; } + + public function link(): string { + return "url()}\">{$this->name()}"; + } + + public function location(): string { + return "contest.php?id={$this->id}"; + } public function info(): array { if (isset($this->info) && !empty($this->info)) { diff --git a/app/Contest/AbstractContest.php b/app/Contest/AbstractContest.php index 366809e83..5c9a403b5 100644 --- a/app/Contest/AbstractContest.php +++ b/app/Contest/AbstractContest.php @@ -10,6 +10,8 @@ abstract class AbstractContest extends \Gazelle\Base { ) {} abstract public function ranker(): array; + abstract public function participationStats(): array; + abstract public function userPayout(int $enabledUserBonus, int $contestBonus, int $perEntryBonus): array; } diff --git a/app/Contest/RequestFill.php b/app/Contest/RequestFill.php index 748b30f68..1fd8d01dd 100644 --- a/app/Contest/RequestFill.php +++ b/app/Contest/RequestFill.php @@ -5,11 +5,14 @@ namespace Gazelle\Contest; /* how many requests filled */ class RequestFill extends AbstractContest { + // phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassAfterLastUsed public function leaderboard(int $limit, int $offset): array { // TODO return []; } + // phpcs:enable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassAfterLastUsed + public function ranker(): array { return [ "SELECT r.FillerID AS userid, diff --git a/app/DB.php b/app/DB.php index 05bf7428f..de65ab54c 100644 --- a/app/DB.php +++ b/app/DB.php @@ -137,7 +137,7 @@ class DB extends Base { return [false, "condition selected 0 rows"]; } } catch (DB\MysqlDuplicateKeyException) { - // do nothing, for some reason it was already deleted + ; // do nothing, for some reason it was already deleted } if (!$delete) { diff --git a/app/DB/Mysql.php b/app/DB/Mysql.php index 841abac2c..5e42e5f18 100644 --- a/app/DB/Mysql.php +++ b/app/DB/Mysql.php @@ -101,9 +101,6 @@ set_query_id($ResultSet) ------------------------------------------------------------------------------------- *///--------------------------------------------------------------------------------- -class MysqlException extends \Exception {} -class MysqlDuplicateKeyException extends MysqlException {} - class Mysql { public \mysqli|false $LinkID = false; protected \mysqli_result|false|null $QueryID = false; diff --git a/app/DB/MysqlDuplicateKeyException.php b/app/DB/MysqlDuplicateKeyException.php new file mode 100644 index 000000000..5911d8faf --- /dev/null +++ b/app/DB/MysqlDuplicateKeyException.php @@ -0,0 +1,5 @@ +info) && !empty($this->info)) { diff --git a/app/FeaturedAlbum.php b/app/FeaturedAlbum.php index 324c47520..b1ba351cf 100644 --- a/app/FeaturedAlbum.php +++ b/app/FeaturedAlbum.php @@ -20,8 +20,14 @@ class FeaturedAlbum extends BaseObject { self::$cache->delete_value(sprintf(self::FEATURED, $this->type->value, $this->id)); return $this; } - public function link(): string {return $this->thread()->link();} - public function location(): string {return $this->thread()->location();} + + public function link(): string { + return $this->thread()->link(); + } + + public function location(): string { + return $this->thread()->location(); + } public function info(): array { if (!isset($this->info)) { diff --git a/app/ForumCategory.php b/app/ForumCategory.php index 50ee38765..c4d76c0ff 100644 --- a/app/ForumCategory.php +++ b/app/ForumCategory.php @@ -12,8 +12,14 @@ class ForumCategory extends BaseObject { unset($this->info); return $this; } - public function link(): string { return "location()}\">Forum Categories"; } - public function location(): string { return "tools.php?action=categories"; } + + public function link(): string { + return "location()}\">Forum Categories"; + } + + public function location(): string { + return "tools.php?action=categories"; + } public function info(): array { if (isset($this->info)) { diff --git a/app/ForumPoll.php b/app/ForumPoll.php index 233c6d118..d5e37e9f6 100644 --- a/app/ForumPoll.php +++ b/app/ForumPoll.php @@ -15,8 +15,14 @@ class ForumPoll extends BaseObject { unset($this->info); return $this; } - public function link(): string { return $this->thread()->link(); } - public function location(): string { return "forums.php?action=viewthread&threadid={$this->id}"; } + + public function link(): string { + return $this->thread()->link(); + } + + public function location(): string { + return "forums.php?action=viewthread&threadid={$this->id}"; + } public function thread(): ForumThread { return new ForumThread($this->id); diff --git a/app/ForumPost.php b/app/ForumPost.php index 8a1c5f5f8..b2aaaa296 100644 --- a/app/ForumPost.php +++ b/app/ForumPost.php @@ -13,8 +13,13 @@ class ForumPost extends BaseObject { return $this; } - public function link(): string { return sprintf('%s', $this->url(), "Post #{$this->id}"); } - public function location(): string { return "forums.php?action=viewthread&threadid={$this->threadId()}&postid={$this->id}#post{$this->id}"; } + public function link(): string { + return sprintf('%s', $this->url(), "Post #{$this->id}"); + } + + public function location(): string { + return "forums.php?action=viewthread&threadid={$this->threadId()}&postid={$this->id}#post{$this->id}"; + } /** * Get information about a post diff --git a/app/ForumThread.php b/app/ForumThread.php index e42191387..ec6224671 100644 --- a/app/ForumThread.php +++ b/app/ForumThread.php @@ -38,8 +38,13 @@ class ForumThread extends BaseObject { ); } - public function link(): string { return sprintf('%s', $this->url(), display_str($this->title())); } - public function location(): string { return "forums.php?action=viewthread&threadid={$this->id}"; } + public function link(): string { + return sprintf('%s', $this->url(), display_str($this->title())); + } + + public function location(): string { + return "forums.php?action=viewthread&threadid={$this->id}"; + } /** * Get information about a thread diff --git a/app/ForumTransition.php b/app/ForumTransition.php index 1e5cb3a35..c62222049 100644 --- a/app/ForumTransition.php +++ b/app/ForumTransition.php @@ -25,8 +25,13 @@ class ForumTransition extends BaseObject { return $this; } - public function link(): string { return ""; } - public function location(): string { return "tools.php?action=forum_transitions"; } + public function link(): string { + return ""; + } + + public function location(): string { + return "tools.php?action=forum_transitions"; + } public function info(): array { if (isset($this->info)) { diff --git a/app/Intf/CategoryHasArtist.php b/app/Intf/CategoryHasArtist.php index ffef0d6af..f565d19de 100644 --- a/app/Intf/CategoryHasArtist.php +++ b/app/Intf/CategoryHasArtist.php @@ -4,5 +4,6 @@ namespace Gazelle\Intf; interface CategoryHasArtist { public function id(): int; + public function title(): string; } diff --git a/app/Logfile.php b/app/Logfile.php index f092bdbb0..4368f7146 100644 --- a/app/Logfile.php +++ b/app/Logfile.php @@ -8,17 +8,16 @@ use OrpheusNET\Logchecker\Check\Checksum; class Logfile { protected string $checksumState; protected array $details; - protected string $filepath; - protected string $filename; protected int $score; protected string $text; protected string $ripper; protected string $ripperVersion; protected string $language; - public function __construct(string $filepath, ?string $filename = null) { - $this->filepath = $filepath; // where the uploaded logfile is stored - $this->filename = $filename; // the name of the file e.g. "Artist - Album.log" + public function __construct( + protected string $filepath, // where the uploaded logfile is stored + protected ?string $filename = null, // the name of the file e.g. "Artist - Album.log" + ) { $checker = new Logchecker(); $checker->newFile($this->filepath); $checker->parse(); @@ -31,16 +30,51 @@ class Logfile { $this->language = $checker->getLanguage(); } - public function checksum(): bool { return $this->checksumState === Checksum::CHECKSUM_OK; } - public function checksumState(): string { return $this->checksumState; } - public function checksumStatus(): string { return $this->checksum() ? '1' : '0'; } - public function details(): array { return $this->details; } - public function detailsAsString(): string { return implode("\r\n", $this->details); } - public function filepath(): string { return $this->filepath; } - public function filename(): string { return $this->filename; } - public function score(): int { return $this->score; } - public function text(): string { return $this->text; } - public function ripper(): string { return $this->ripper; } - public function ripperVersion(): string { return $this->ripperVersion; } - public function language(): string { return $this->language; } + public function checksum(): bool { + return $this->checksumState === Checksum::CHECKSUM_OK; + } + + public function checksumState(): string { + return $this->checksumState; + } + + public function checksumStatus(): string { + return $this->checksum() ? '1' : '0'; + } + + public function details(): array { + return $this->details; + } + + public function detailsAsString(): string { + return implode("\r\n", $this->details); + } + + public function filepath(): string { + return $this->filepath; + } + + public function filename(): string { + return $this->filename; + } + + public function score(): int { + return $this->score; + } + + public function text(): string { + return $this->text; + } + + public function ripper(): string { + return $this->ripper; + } + + public function ripperVersion(): string { + return $this->ripperVersion; + } + + public function language(): string { + return $this->language; + } } diff --git a/app/Manager/InviteSource.php b/app/Manager/InviteSource.php index 56fb5ad91..af868de9c 100644 --- a/app/Manager/InviteSource.php +++ b/app/Manager/InviteSource.php @@ -203,7 +203,7 @@ class InviteSource extends \Gazelle\Base { * "profile" => or '' to remove, * ] */ - public function modifyInviteeSource(\Gazelle\User $user, array $sourceList): int { + public function modifyInviteeSource(array $sourceList): int { self::$db->begin_transaction(); $affected = 0; foreach ($sourceList as $source) { diff --git a/app/Manager/PM.php b/app/Manager/PM.php index de555a31c..d38f2add7 100644 --- a/app/Manager/PM.php +++ b/app/Manager/PM.php @@ -6,12 +6,18 @@ class PM extends \Gazelle\BaseUser { final public const tableName = 'pm_conversations_users'; protected const ID_KEY = 'zz_pm_%d_%d'; - public function flush(): static { + public function flush(): static { $this->user()->flush(); return $this; } - public function link(): string { return $this->user()->link(); } - public function location(): string { return $this->user()->location(); } + + public function link(): string { + return $this->user()->link(); + } + + public function location(): string { + return $this->user()->location(); + } public function findById(int $pmId): ?\Gazelle\PM { $key = sprintf(self::ID_KEY, $pmId, $this->user->id()); diff --git a/app/Manager/SiteLog.php b/app/Manager/SiteLog.php index bcaacfddc..28a69917e 100644 --- a/app/Manager/SiteLog.php +++ b/app/Manager/SiteLog.php @@ -11,8 +11,13 @@ class SiteLog extends \Gazelle\Base { protected \Gazelle\Manager\User $userMan, ) {} - public function totalMatches(): int { return $this->totalMatches; } - public function result(): array { return $this->result; } + public function totalMatches(): int { + return $this->totalMatches; + } + + public function result(): array { + return $this->result; + } public function page(int $perPage, int $offset, string $searchTerm, bool $bypassSphinx = false): array { if ($searchTerm === '' || $bypassSphinx) { diff --git a/app/Manager/Tag.php b/app/Manager/Tag.php index ec34ca365..698cbab40 100644 --- a/app/Manager/Tag.php +++ b/app/Manager/Tag.php @@ -64,10 +64,13 @@ class Tag extends \Gazelle\BaseManager { * Check whether this name is allowed. Some tags we never want to see again. * TODO: implement */ + // phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass public function validName(string $name): bool { return true; } + // phpcs:enable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass + /** * Get a tag ready for database input and display. * Trim whitespace, force to lower case, internal spaces and dashes become dots, @@ -414,7 +417,7 @@ class Tag extends \Gazelle\BaseManager { "); $aliasList = self::$db->to_array(false, MYSQLI_ASSOC, false); // Unify tag aliases to be in_this_format as tags not in.this.format - array_walk_recursive($aliasList, function (&$val, $key) { + array_walk_recursive($aliasList, function (&$val) { $val = strtr($val, '.', '_'); }); // Clean up the array for smaller cache size diff --git a/app/NotificationFilter.php b/app/NotificationFilter.php index ae44ccc7b..4fcb596a4 100644 --- a/app/NotificationFilter.php +++ b/app/NotificationFilter.php @@ -8,9 +8,17 @@ class NotificationFilter extends BaseObject { 'artist', 'recordLabel', 'tag', 'notTag', 'category', 'format', 'encoding', 'media', 'user' ]; - public function flush(): static { return $this; } - public function link(): string { return sprintf('%s', $this->url(), $this->url()); } - public function location(): string { return 'user.php?action=notify'; } + public function flush(): static { + return $this; + } + + public function link(): string { + return sprintf('%s', $this->url(), $this->url()); + } + + public function location(): string { + return 'user.php?action=notify'; + } public function info(): array { if (isset($this->info) && !empty($this->info)) { diff --git a/app/Privilege.php b/app/Privilege.php index d782c8e38..ce2a03c8c 100644 --- a/app/Privilege.php +++ b/app/Privilege.php @@ -9,8 +9,14 @@ class Privilege extends BaseObject { $this->info = []; return $this; } - public function location(): string { return ''; } - public function link(): string { return sprintf('%s', $this->url(), $this->url()); } + + public function location(): string { + return ''; + } + + public function link(): string { + return sprintf('%s', $this->url(), $this->url()); + } public function info(): array { if (isset($this->info) && !empty($this->info)) { diff --git a/app/Report.php b/app/Report.php index 82a0a2c8f..961fc7265 100644 --- a/app/Report.php +++ b/app/Report.php @@ -11,8 +11,14 @@ class Report extends BaseObject { $this->info = []; return $this; } - public function link(): string { return sprintf('Report #%d', $this->url(), $this->id()); } - public function location(): string { return "reports.php?id={$this->id}#report{$this->id}"; } + + public function link(): string { + return sprintf('Report #%d', $this->url(), $this->id()); + } + + public function location(): string { + return "reports.php?id={$this->id}#report{$this->id}"; + } public function setUserManager(Manager\User $userMan): static { $this->userMan = $userMan; diff --git a/app/Report/AbstractReport.php b/app/Report/AbstractReport.php index e98cc7593..43fbbe84d 100644 --- a/app/Report/AbstractReport.php +++ b/app/Report/AbstractReport.php @@ -12,8 +12,11 @@ abstract class AbstractReport extends \Gazelle\Base { protected array $context = []; abstract public function template(): string; + abstract public function bbLink(): string; + abstract public function title(): string; + abstract public function titlePrefix(): string; public function subject(): \Gazelle\Base { diff --git a/app/ReportAuto.php b/app/ReportAuto.php index 8374d2e40..da13b363e 100644 --- a/app/ReportAuto.php +++ b/app/ReportAuto.php @@ -18,8 +18,14 @@ class ReportAuto extends BasePgObject { unset($this->info); return $this; } - public function link(): string { return sprintf('Auto Report #%d', $this->url(), $this->id()); } - public function location(): string { return "report_auto.php?id={$this->id}#report{$this->id}"; } + + public function link(): string { + return sprintf('Auto Report #%d', $this->url(), $this->id()); + } + + public function location(): string { + return "report_auto.php?id={$this->id}#report{$this->id}"; + } public function info(): array { if (isset($this->info)) { diff --git a/app/Request.php b/app/Request.php index 9f2440bec..d6197a320 100644 --- a/app/Request.php +++ b/app/Request.php @@ -22,8 +22,14 @@ class Request extends BaseObject implements CategoryHasArtist { unset($this->info); return $this; } - public function link(): string { return sprintf('%s', $this->url(), display_str($this->title())); } - public function location(): string { return 'requests.php?action=view&id=' . $this->id; } + + public function link(): string { + return sprintf('%s', $this->url(), display_str($this->title())); + } + + public function location(): string { + return 'requests.php?action=view&id=' . $this->id; + } /** * Display a title on the request page itself. If there are artists in the name, diff --git a/app/Request/AbstractValue.php b/app/Request/AbstractValue.php index 8a6e914c8..a0aaad53a 100644 --- a/app/Request/AbstractValue.php +++ b/app/Request/AbstractValue.php @@ -4,6 +4,7 @@ namespace Gazelle\Request; abstract class AbstractValue { protected array $label; + public function __construct( protected bool $all = false, protected array $list = [], diff --git a/app/RipLog.php b/app/RipLog.php index 7d4676028..15eaab179 100644 --- a/app/RipLog.php +++ b/app/RipLog.php @@ -5,10 +5,14 @@ namespace Gazelle; class RipLog extends BaseObject { final public const tableName = 'torrents_logs'; - public function flush(): static { return $this; } + public function flush(): static { + return $this; + } + public function location(): string { return "view.php?type=riplog&id={$this->torrentId}.{$this->id}"; } + public function link(): string { return "url()}\">Log #{$this->id}"; } diff --git a/app/Search/Forum.php b/app/Search/Forum.php index d29d67109..83018a2c1 100644 --- a/app/Search/Forum.php +++ b/app/Search/Forum.php @@ -30,12 +30,18 @@ class Forum extends \Gazelle\BaseUser { protected \Gazelle\User $viewer; - public function flush(): static { + public function flush(): static { $this->user()->flush(); return $this; } - public function link(): string { return $this->user()->link(); } - public function location(): string { return $this->user()->location(); } + + public function link(): string { + return $this->user()->link(); + } + + public function location(): string { + return $this->user()->location(); + } public function __construct(\Gazelle\User $user) { parent::__construct($user); diff --git a/app/Search/Torrent/Report.php b/app/Search/Torrent/Report.php index 44a485312..a8940dfc6 100644 --- a/app/Search/Torrent/Report.php +++ b/app/Search/Torrent/Report.php @@ -16,7 +16,6 @@ class Report extends \Gazelle\Base { protected \Gazelle\Manager\User $userMan, ) {} - protected function configure(): void { if (isset($this->cond)) { return; diff --git a/app/Staff.php b/app/Staff.php index e4fa6f6a9..796837c19 100644 --- a/app/Staff.php +++ b/app/Staff.php @@ -5,12 +5,18 @@ namespace Gazelle; class Staff extends BaseUser { final public const tableName = 'staff_blog_visits'; - public function flush(): static { + public function flush(): static { $this->user()->flush(); return $this; } - public function link(): string { return $this->user()->link(); } - public function location(): string { return $this->user()->location(); } + + public function link(): string { + return $this->user()->link(); + } + + public function location(): string { + return $this->user()->location(); + } public function blogAlert(): bool { if (($readTime = self::$cache->get_value('staff_blog_read_' . $this->user->id())) === false) { diff --git a/app/StaffBlog.php b/app/StaffBlog.php index 9eda7175e..3704e54e0 100644 --- a/app/StaffBlog.php +++ b/app/StaffBlog.php @@ -9,8 +9,14 @@ class StaffBlog extends BaseObject { $this->info = []; return $this; } - public function link(): string { return sprintf('%s', $this->url(), display_str($this->title())); } - public function location(): string { return 'staffblog.php#blog' . $this->id; } + + public function link(): string { + return sprintf('%s', $this->url(), display_str($this->title())); + } + + public function location(): string { + return 'staffblog.php#blog' . $this->id; + } public function info(): array { if (isset($this->info) && !empty($this->info)) { diff --git a/app/StaffGroup.php b/app/StaffGroup.php index f31b84673..c54d763a3 100644 --- a/app/StaffGroup.php +++ b/app/StaffGroup.php @@ -11,8 +11,14 @@ class StaffGroup extends BaseObject { unset($this->info); return $this; } - public function link(): string { return sprintf('%s', $this->url(), 'Staff groups', 'Staff groups'); } - public function location(): string { return 'tools.php?action=staff_groups'; } + + public function link(): string { + return sprintf('%s', $this->url(), 'Staff groups', 'Staff groups'); + } + + public function location(): string { + return 'tools.php?action=staff_groups'; + } /** * A staff group object is so trival that it never needs to be instantiated, diff --git a/app/StaffPM.php b/app/StaffPM.php index 2bfe3f542..3d2eb5ec2 100644 --- a/app/StaffPM.php +++ b/app/StaffPM.php @@ -9,8 +9,14 @@ class StaffPM extends BaseObject { $this->info = []; return $this; } - public function link(): string { return sprintf('%s', $this->url(), display_str($this->subject())); } - public function location(): string { return 'staffpm.php?action=viewconv&id=' . $this->id; } + + public function link(): string { + return sprintf('%s', $this->url(), display_str($this->subject())); + } + + public function location(): string { + return 'staffpm.php?action=viewconv&id=' . $this->id; + } public function flushUser(User $user): static { self::$cache->delete_multi([ diff --git a/app/Stats/Artist.php b/app/Stats/Artist.php index afa09c5e3..d262af71e 100644 --- a/app/Stats/Artist.php +++ b/app/Stats/Artist.php @@ -10,8 +10,14 @@ class Artist extends \Gazelle\BaseObject { self::$cache->delete_value(sprintf(self::CACHE_KEY, $this->id)); return $this; } - public function link(): string { return sprintf('artist %d', $this->url(), $this->id()); } - public function location(): string { return 'artist.php?id=' . $this->id; } + + public function link(): string { + return sprintf('artist %d', $this->url(), $this->id()); + } + + public function location(): string { + return 'artist.php?id=' . $this->id; + } public function info(): array { if (isset($this->info)) { diff --git a/app/Stats/Collage.php b/app/Stats/Collage.php index 6887ae5bc..8ac1548d0 100644 --- a/app/Stats/Collage.php +++ b/app/Stats/Collage.php @@ -4,6 +4,7 @@ namespace Gazelle\Stats; class Collage extends \Gazelle\Base { protected const CACHE_KEY = 'stats_collages'; + public function collageTotal(): int { $count = self::$cache->get_value(self::CACHE_KEY); if ($count === false) { diff --git a/app/Stats/TGroup.php b/app/Stats/TGroup.php index 615dd2592..29066b8f4 100644 --- a/app/Stats/TGroup.php +++ b/app/Stats/TGroup.php @@ -19,8 +19,14 @@ class TGroup extends \Gazelle\BaseObject { self::$cache->delete_value(sprintf(self::CACHE_GENERAL, $this->id)); return $this; } - public function link(): string { return sprintf('%s', $this->url(), 'Stats'); } - public function location(): string { return 'torrents.php?id=' . $this->id; } + + public function link(): string { + return sprintf('%s', $this->url(), 'Stats'); + } + + public function location(): string { + return 'torrents.php?id=' . $this->id; + } /** * @see \Gazelle\Stats\TGroups::refresh() diff --git a/app/Stats/Torrent.php b/app/Stats/Torrent.php index 46187ab31..112bebeaa 100644 --- a/app/Stats/Torrent.php +++ b/app/Stats/Torrent.php @@ -110,16 +110,45 @@ class Torrent extends \Gazelle\Base { return $this->info; } - public function torrentTotal(): int { return $this->info()['torrent-total']; } - public function totalFiles(): int { return $this->info()['total-files']; } - public function totalSize(): int { return $this->info()['total-size']; } - public function amount(string $interval): int { return $this->info()[$interval]['count']; } - public function files(string $interval): int { return $this->info()[$interval]['files']; } - public function size(string $interval): int { return $this->info()[$interval]['size']; } - public function category(): array { return $this->info()['category']; } - public function format(): array { return $this->info()['format']; } - public function formatMonth(): array { return $this->info()['format-month']; } - public function media(): array { return $this->info()['media']; } + public function torrentTotal(): int { + return $this->info()['torrent-total']; + } + + public function totalFiles(): int { + return $this->info()['total-files']; + } + + public function totalSize(): int { + return $this->info()['total-size']; + } + + public function amount(string $interval): int { + return $this->info()[$interval]['count']; + } + + public function files(string $interval): int { + return $this->info()[$interval]['files']; + } + + public function size(string $interval): int { + return $this->info()[$interval]['size']; + } + + public function category(): array { + return $this->info()['category']; + } + + public function format(): array { + return $this->info()['format']; + } + + public function formatMonth(): array { + return $this->info()['format-month']; + } + + public function media(): array { + return $this->info()['media']; + } /** * Yearly torrent flows (added, removed and net per month) diff --git a/app/Stats/User.php b/app/Stats/User.php index bc95fa722..083b36c84 100644 --- a/app/Stats/User.php +++ b/app/Stats/User.php @@ -27,8 +27,14 @@ class User extends \Gazelle\BaseObject { ]); return $this; } - public function link(): string { return sprintf('%s', $this->url(), 'Stats'); } - public function location(): string { return 'user.php?action=stats&userid=' . $this->id; } + + public function link(): string { + return sprintf('%s', $this->url(), 'Stats'); + } + + public function location(): string { + return 'user.php?action=stats&userid=' . $this->id; + } /** * Get the total number of comments made by page type diff --git a/app/TGroup.php b/app/TGroup.php index 5eb65cda4..2231c7151 100644 --- a/app/TGroup.php +++ b/app/TGroup.php @@ -48,7 +48,9 @@ class TGroup extends BaseObject implements CategoryHasArtist, CollageEntry { }; } - public function location(): string { return "torrents.php?id={$this->id}"; } + public function location(): string { + return "torrents.php?id={$this->id}"; + } public function torrentLink(int $torrentId): string { $url = '" @@ -966,7 +968,7 @@ class TGroup extends BaseObject implements CategoryHasArtist, CollageEntry { return true; } - public function rename(string $name, User $user, Manager\TGroup $manager, Log $logger): bool { + public function rename(string $name, User $user, Log $logger): bool { $oldName = $this->name(); $success = $this->setField('Name', $name)->modify(); if ($success) { diff --git a/app/Tag.php b/app/Tag.php index 39ba8e8d4..dc5026428 100644 --- a/app/Tag.php +++ b/app/Tag.php @@ -18,8 +18,14 @@ class Tag extends BaseObject { unset($this->info); return $this; } - public function link(): string { return sprintf('%s', $this->url(), display_str($this->name())); } - public function location(): string { return 'torrents.php?taglist=' . $this->name(); } + + public function link(): string { + return sprintf('%s', $this->url(), display_str($this->name())); + } + + public function location(): string { + return 'torrents.php?taglist=' . $this->name(); + } public function info(): array { return $this->info ??= self::$db->rowAssoc(" diff --git a/app/Thread.php b/app/Thread.php index 4fce5e83b..d02894631 100644 --- a/app/Thread.php +++ b/app/Thread.php @@ -17,8 +17,14 @@ class Thread extends BaseObject { unset($this->info); return $this; } - public function link(): string { return ''; } - public function location(): string { return ''; } + + public function link(): string { + return ''; + } + + public function location(): string { + return ''; + } public function info(): array { if (isset($this->info)) { diff --git a/app/Torrent.php b/app/Torrent.php index c7741fec5..b66573a6a 100644 --- a/app/Torrent.php +++ b/app/Torrent.php @@ -11,7 +11,9 @@ class Torrent extends TorrentAbstract { final public const CACHE_KEY_PEERLIST_PAGE = 'peerlist_page_%d_%d'; final public const USER_RECENT_UPLOAD = 'u_recent_up_%d'; - public function location(): string { return "torrents.php?id={$this->groupId()}&torrentid={$this->id}#torrent{$this->id}"; } + public function location(): string { + return "torrents.php?id={$this->groupId()}&torrentid={$this->id}#torrent{$this->id}"; + } public function infoRow(): ?array { $info = self::$db->rowAssoc(" diff --git a/app/Torrent/Report.php b/app/Torrent/Report.php index d6ddec471..b2bf6c07d 100644 --- a/app/Torrent/Report.php +++ b/app/Torrent/Report.php @@ -20,8 +20,14 @@ class Report extends \Gazelle\BaseObject { unset($this->info); return $this; } - public function link(): string { return sprintf('Report #%d', $this->url(), $this->id()); } - public function location(): string { return "reportsv2.php?view=report&id=" . $this->id; } + + public function link(): string { + return sprintf('Report #%d', $this->url(), $this->id()); + } + + public function location(): string { + return "reportsv2.php?view=report&id=" . $this->id; + } public function info(): array { return $this->info ??= self::$db->rowAssoc(" diff --git a/app/Torrent/ReportType.php b/app/Torrent/ReportType.php index 6bc68b4b8..09da72dd8 100644 --- a/app/Torrent/ReportType.php +++ b/app/Torrent/ReportType.php @@ -16,13 +16,22 @@ class ReportType extends \Gazelle\BaseObject { self::$cache->delete_value(sprintf(\Gazelle\Manager\Torrent\ReportType::TYPE_KEY, $this->id)); return $this; } - public function link(): string { return ''; } - public function location(): string { return "tools.php?action=torrent_report_edit&id=" . $this->id; } + public function link(): string { + return ''; + } + + public function location(): string { + return "tools.php?action=torrent_report_edit&id=" . $this->id; + } + + // phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass public function url(string|null $param = null): string { return htmlentities($this->location()); } + // phpcs:enable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass + public function info(): array { $key = sprintf(self::CACHE_KEY, $this->id); $info = self::$cache->get_value($key); diff --git a/app/TorrentAbstract.php b/app/TorrentAbstract.php index a069be2bc..64fffcbd5 100644 --- a/app/TorrentAbstract.php +++ b/app/TorrentAbstract.php @@ -115,7 +115,6 @@ abstract class TorrentAbstract extends BaseObject { return $this->info; } - /** * Assume a torrent has not been deleted. This function is * overridden in TorrentDeleted diff --git a/app/TorrentDeleted.php b/app/TorrentDeleted.php index b633fedba..d53f0985e 100644 --- a/app/TorrentDeleted.php +++ b/app/TorrentDeleted.php @@ -8,7 +8,9 @@ class TorrentDeleted extends TorrentAbstract { final public const tableName = 'deleted_torrents'; final public const CACHE_KEY = 'tdel_%d'; - public function location(): string { return "log.php?search=Torrent+" . $this->id; } + public function location(): string { + return "log.php?search=Torrent+" . $this->id; + } public function infoRow(): ?array { $info = self::$db->rowAssoc(" @@ -65,8 +67,4 @@ class TorrentDeleted extends TorrentAbstract { public function isDeleted(): bool { return true; } - - public function addFlag(TorrentFlag $flag, User $user): int { - return 0; - } } diff --git a/app/TorrentLog.php b/app/TorrentLog.php index 45408e870..65e48a2e5 100644 --- a/app/TorrentLog.php +++ b/app/TorrentLog.php @@ -16,8 +16,14 @@ class TorrentLog extends BaseObject { $this->torrent->flush(); return $this; } - public function link(): string { return $this->torrent->link(); } - public function location(): string { return $this->torrent->location(); } + + public function link(): string { + return $this->torrent->link(); + } + + public function location(): string { + return $this->torrent->location(); + } public function torrentId(): int { return $this->torrent->id(); diff --git a/app/User.php b/app/User.php index 8a96267c7..d8fa17a36 100644 --- a/app/User.php +++ b/app/User.php @@ -48,8 +48,14 @@ class User extends BaseObject { unset($this->info, $this->ordinal, $this->privilege, $this->stats, $this->tokenCache); return $this; } - public function link(): string { return sprintf('%s', $this->url(), html_escape($this->username())); } - public function location(): string { return 'user.php?id=' . $this->id; } + + public function link(): string { + return sprintf('%s', $this->url(), html_escape($this->username())); + } + + public function location(): string { + return 'user.php?id=' . $this->id; + } /** * Delegate privilege methods to the User\AuditTrail class @@ -1449,18 +1455,49 @@ class User extends BaseObject { return $change; } - public function isUnconfirmed(): bool { return $this->info()['Enabled'] == UserStatus::unconfirmed->value; } - public function isEnabled(): bool { return $this->info()['Enabled'] == UserStatus::enabled->value; } - public function isDisabled(): bool { return $this->info()['Enabled'] == UserStatus::disabled->value; } - public function isLocked(): bool { return !is_null($this->info()['locked_account']); } - public function isVisible(): bool { return $this->info()['Visible'] == '1'; } - public function isWarned(): bool { return !is_null($this->warningExpiry()); } + public function isUnconfirmed(): bool { + return $this->info()['Enabled'] == UserStatus::unconfirmed->value; + } - public function isStaff(): bool { return $this->info()['isStaff']; } - public function isFLS(): bool { return $this->privilege()->isFLS(); } - public function isInterviewer(): bool { return $this->privilege()->isInterviewer(); } - public function isRecruiter(): bool { return $this->privilege()->isRecruiter(); } - public function isStaffPMReader(): bool { return $this->isFLS() || $this->isStaff(); } + public function isEnabled(): bool { + return $this->info()['Enabled'] == UserStatus::enabled->value; + } + + public function isDisabled(): bool { + return $this->info()['Enabled'] == UserStatus::disabled->value; + } + + public function isLocked(): bool { + return !is_null($this->info()['locked_account']); + } + + public function isVisible(): bool { + return $this->info()['Visible'] == '1'; + } + + public function isWarned(): bool { + return !is_null($this->warningExpiry()); + } + + public function isStaff(): bool { + return $this->info()['isStaff']; + } + + public function isFLS(): bool { + return $this->privilege()->isFLS(); + } + + public function isInterviewer(): bool { + return $this->privilege()->isInterviewer(); + } + + public function isRecruiter(): bool { + return $this->privilege()->isRecruiter(); + } + + public function isStaffPMReader(): bool { + return $this->isFLS() || $this->isStaff(); + } public function warningExpiry(): ?string { return $this->info()['warning_expiry']; @@ -1753,8 +1790,7 @@ class User extends BaseObject { && !$torrent->isFreeleech() && !$torrent->isFreeleechPersonal() && (STACKABLE_FREELEECH_TOKENS || $torrent->tokenCount() == 1) - && $this->tokenCount() >= $torrent->tokenCount() - ; + && $this->tokenCount() >= $torrent->tokenCount(); } /** @@ -1974,6 +2010,7 @@ class User extends BaseObject { ); return $token; } catch (\Gazelle\DB\MysqlDuplicateKeyException) { + ; } } } diff --git a/app/User/Inbox.php b/app/User/Inbox.php index fbf758c25..7b099f05e 100644 --- a/app/User/Inbox.php +++ b/app/User/Inbox.php @@ -13,11 +13,7 @@ class Inbox extends \Gazelle\BaseUser { protected string $searchField = 'user'; protected string $searchTerm; - public function __construct(\Gazelle\User $user) { - parent::__construct($user); - } - - public function flush(): static { + public function flush(): static { self::$cache->delete_value(sprintf(self::CACHE_NEW, $this->id())); $this->user->flush(); return $this; diff --git a/app/User/Notification/AbstractNotification.php b/app/User/Notification/AbstractNotification.php index 2e8e00e87..7468f5bed 100644 --- a/app/User/Notification/AbstractNotification.php +++ b/app/User/Notification/AbstractNotification.php @@ -14,11 +14,19 @@ abstract class AbstractNotification extends \Gazelle\BaseUser { $this->user()->flush(); return $this; } - public function link(): string { return $this->user()->link(); } - public function location(): string { return $this->user()->location(); } + + public function link(): string { + return $this->user()->link(); + } + + public function location(): string { + return $this->user()->location(); + } abstract public function className(): string; + abstract public function clear(): int; + abstract public function load(): bool; public function context(): int { diff --git a/app/User/Privilege.php b/app/User/Privilege.php index 154ec7a52..89bf850b5 100644 --- a/app/User/Privilege.php +++ b/app/User/Privilege.php @@ -118,9 +118,18 @@ class Privilege extends \Gazelle\BaseUser { public function isSecondary(int $privilegeId): bool { return isset($this->info()['secondary'][$privilegeId]); } - public function isFLS(): bool { return $this->isSecondary(FLS_TEAM); } - public function isInterviewer(): bool { return $this->isSecondary(INTERVIEWER); } - public function isRecruiter(): bool { return $this->isSecondary(RECRUITER); } + + public function isFLS(): bool { + return $this->isSecondary(FLS_TEAM); + } + + public function isInterviewer(): bool { + return $this->isSecondary(INTERVIEWER); + } + + public function isRecruiter(): bool { + return $this->isSecondary(RECRUITER); + } public function allowedForumList(): array { return $this->info()['forum']; diff --git a/app/User/Seedbox.php b/app/User/Seedbox.php index 6743ea60b..ff641aeca 100644 --- a/app/User/Seedbox.php +++ b/app/User/Seedbox.php @@ -79,7 +79,9 @@ class Seedbox extends \Gazelle\BaseUser { ); } - public function viewBy(): int { return $this->viewBy; } + public function viewBy(): int { + return $this->viewBy; + } /** * Generate a signature of the useragent and IP address. @@ -208,7 +210,7 @@ class Seedbox extends \Gazelle\BaseUser { ", mb_substr($name, 0, 100), $this->user->id(), $this->hashid->decode($seedbox['id'])[0] ); } catch (\Gazelle\DB\MysqlDuplicateKeyException) { - // do nothing + ; // do nothing } finally { $n += self::$db->affected_rows(); } diff --git a/app/User/Vote.php b/app/User/Vote.php index 347d6ca00..eaf1c0dac 100644 --- a/app/User/Vote.php +++ b/app/User/Vote.php @@ -396,7 +396,7 @@ class Vote extends \Gazelle\BaseUser { WHERE v.GroupID = ? ", $tgroup->id() ); - return [$total, (int)$ups, $this->calcScore($total, (int)$ups)] ; + return [$total, (int)$ups, $this->calcScore($total, (int)$ups)]; } /** diff --git a/app/UserNavigation.php b/app/UserNavigation.php index 4928708de..5d0395432 100644 --- a/app/UserNavigation.php +++ b/app/UserNavigation.php @@ -12,9 +12,11 @@ class UserNavigation extends BaseObject { unset($this->info); return $this; } + public function link(): string { return "location()}\">User Link Editor"; } + public function location(): string { return "tools.php?action=navigation"; } diff --git a/app/UserRank/AbstractUserRank.php b/app/UserRank/AbstractUserRank.php index 587aefec6..e4b72ca2e 100644 --- a/app/UserRank/AbstractUserRank.php +++ b/app/UserRank/AbstractUserRank.php @@ -11,6 +11,7 @@ namespace Gazelle\UserRank; abstract class AbstractUserRank extends \Gazelle\Base { abstract public function cacheKey(): string; + abstract public function selector(): string; /** diff --git a/app/Util/PasswordCheck.php b/app/Util/PasswordCheck.php index c6732de90..1feec4b02 100644 --- a/app/Util/PasswordCheck.php +++ b/app/Util/PasswordCheck.php @@ -8,7 +8,6 @@ class PasswordCheck { public const REGEXP = '/(?=^.{8,}$)(?=.*[^a-zA-Z])(?=.*[A-Z])(?=.*[a-z]).*$|.{20,}/'; public const ERROR_MSG = 'You have specified a weak or known-compromised password.'; - public static function checkPasswordStrength(#[\SensitiveParameter] string $password, ?User $user, bool $skipRegex = true): bool { return static::checkPasswordStrengthNoUser($password, $user?->username(), $user?->email(), $skipRegex); } diff --git a/app/Util/Time.php b/app/Util/Time.php index 1c260c7af..bbf57a890 100644 --- a/app/Util/Time.php +++ b/app/Util/Time.php @@ -210,7 +210,6 @@ class Time { } } - /** * Converts a numeric amount of seconds (though we round down via floor for all levels) into a more human readeable * string representing the number of weeks, days, hours, minutes, seconds. diff --git a/app/Util/Twig.php b/app/Util/Twig.php index cd02e9d6e..ba0f437f8 100644 --- a/app/Util/Twig.php +++ b/app/Util/Twig.php @@ -208,7 +208,7 @@ class Twig { 'UTF-8' ))); - $twig->addFunction(new \Twig\TwigFunction('donor_icon', fn($icon, $userId) => new \Twig\Markup(image_cache_encode($icon), 'UTF-8'))); + $twig->addFunction(new \Twig\TwigFunction('donor_icon', fn($icon) => new \Twig\Markup(image_cache_encode($icon), 'UTF-8'))); $twig->addFunction(new \Twig\TwigFunction('ipaddr', fn(string $ipaddr) => new \Twig\Markup( "$ipaddr S", diff --git a/app/Wiki.php b/app/Wiki.php index b69ef47da..d996a888d 100644 --- a/app/Wiki.php +++ b/app/Wiki.php @@ -12,8 +12,13 @@ class Wiki extends BaseObject { return $this; } - public function link(): string { return sprintf('%s', $this->url(), display_str($this->title())); } - public function location(): string { return 'wiki.php?action=article&id=' . $this->id; } + public function link(): string { + return sprintf('%s', $this->url(), display_str($this->title())); + } + + public function location(): string { + return 'wiki.php?action=article&id=' . $this->id; + } public function info(): array { if (isset($this->info)) { @@ -109,6 +114,7 @@ class Wiki extends BaseObject { public function ToC(): string { return $this->info()['toc'] ?? ''; } + // phpcs:enable public function editable(User $user): bool { diff --git a/app/WitnessTable/AbstractWitnessTable.php b/app/WitnessTable/AbstractWitnessTable.php index 49fb57575..30ac9f34b 100644 --- a/app/WitnessTable/AbstractWitnessTable.php +++ b/app/WitnessTable/AbstractWitnessTable.php @@ -4,9 +4,13 @@ namespace Gazelle\WitnessTable; abstract class AbstractWitnessTable extends \Gazelle\Base { abstract protected function reference(): string; + abstract protected function tableName(): string; + abstract protected function idColumn(): string; + abstract protected function valueColumn(): string; + abstract public function witness(\Gazelle\User $user): bool; protected function latestValue(): ?int { diff --git a/app/WitnessTable/UserReadBlog.php b/app/WitnessTable/UserReadBlog.php index 5b060bea5..7d20070d6 100644 --- a/app/WitnessTable/UserReadBlog.php +++ b/app/WitnessTable/UserReadBlog.php @@ -3,10 +3,21 @@ namespace Gazelle\WitnessTable; class UserReadBlog extends AbstractWitnessTable { - protected function reference(): string { return 'blog'; } - protected function tableName(): string { return 'user_read_blog'; } - protected function idColumn(): string { return 'user_id'; } - protected function valueColumn(): string { return 'blog_id'; } + protected function reference(): string { + return 'blog'; + } + + protected function tableName(): string { + return 'user_read_blog'; + } + + protected function idColumn(): string { + return 'user_id'; + } + + protected function valueColumn(): string { + return 'blog_id'; + } public function witness(\Gazelle\User $user): bool { return $this->witnessValue($user); diff --git a/app/WitnessTable/UserReadForum.php b/app/WitnessTable/UserReadForum.php index 9b9bc8151..9662d2260 100644 --- a/app/WitnessTable/UserReadForum.php +++ b/app/WitnessTable/UserReadForum.php @@ -3,10 +3,21 @@ namespace Gazelle\WitnessTable; class UserReadForum extends AbstractWitnessTable { - protected function reference(): string { return ''; } - protected function tableName(): string { return 'user_read_forum'; } - protected function idColumn(): string { return 'user_id'; } - protected function valueColumn(): string { return 'last_read'; } + protected function reference(): string { + return ''; + } + + protected function tableName(): string { + return 'user_read_forum'; + } + + protected function idColumn(): string { + return 'user_id'; + } + + protected function valueColumn(): string { + return 'last_read'; + } public function witness(\Gazelle\User $user): bool { return $this->witnessDate($user); diff --git a/app/WitnessTable/UserReadNews.php b/app/WitnessTable/UserReadNews.php index 020ddb105..95146913f 100644 --- a/app/WitnessTable/UserReadNews.php +++ b/app/WitnessTable/UserReadNews.php @@ -3,10 +3,21 @@ namespace Gazelle\WitnessTable; class UserReadNews extends AbstractWitnessTable { - protected function reference(): string { return 'news'; } - protected function tableName(): string { return 'user_read_news'; } - protected function idColumn(): string { return 'user_id'; } - protected function valueColumn(): string { return 'news_id'; } + protected function reference(): string { + return 'news'; + } + + protected function tableName(): string { + return 'user_read_news'; + } + + protected function idColumn(): string { + return 'user_id'; + } + + protected function valueColumn(): string { + return 'news_id'; + } public function witness(\Gazelle\User $user): bool { return $this->witnessValue($user); diff --git a/bin/fix-leech-status.php b/bin/fix-leech-status.php index 267488554..34f4f416d 100644 --- a/bin/fix-leech-status.php +++ b/bin/fix-leech-status.php @@ -2,7 +2,7 @@ /* If ever can_leech and RatioWatchEnds get out of synch, no task will catch it */ -require_once(__DIR__ . '/../lib/bootstrap.php'); +require_once __DIR__ . '/../lib/bootstrap.php'; ini_set('max_execution_time', -1); diff --git a/bin/migrate-logs.php b/bin/migrate-logs.php index 2be4ffb1c..5af194905 100644 --- a/bin/migrate-logs.php +++ b/bin/migrate-logs.php @@ -8,7 +8,7 @@ * longer exists. */ -require_once(__DIR__ . '/../lib/bootstrap.php'); +require_once __DIR__ . '/../lib/bootstrap.php'; ini_set('max_execution_time', -1); diff --git a/bin/migrate-torrent-files.php b/bin/migrate-torrent-files.php index 379b94426..2d47b23d3 100644 --- a/bin/migrate-torrent-files.php +++ b/bin/migrate-torrent-files.php @@ -1,7 +1,7 @@ prepared_query(" diff --git a/bin/recheck-file-storage.php b/bin/recheck-file-storage.php index f1f62ebd0..e3a08397b 100644 --- a/bin/recheck-file-storage.php +++ b/bin/recheck-file-storage.php @@ -16,7 +16,7 @@ * migrate existing Gazelle installations. */ -require_once(__DIR__ . '/../lib/bootstrap.php'); +require_once __DIR__ . '/../lib/bootstrap.php'; $allConfig = [ '-html' => [ diff --git a/bin/regen-filelists.php b/bin/regen-filelists.php index 71e84d35b..d8c1ede48 100644 --- a/bin/regen-filelists.php +++ b/bin/regen-filelists.php @@ -1,6 +1,6 @@ disableLocalCache(); $torMan = new Gazelle\Manager\Torrent(); diff --git a/bin/upload-wiki.php b/bin/upload-wiki.php index 1ff328529..bd7f80bce 100644 --- a/bin/upload-wiki.php +++ b/bin/upload-wiki.php @@ -2,7 +2,7 @@ /* A script to import the old WhatCD wiki articles from the 10th birthday release */ -require_once(__DIR__ . '/../lib/bootstrap.php'); +require_once __DIR__ . '/../lib/bootstrap.php'; $in = fopen($argv[1], 'r'); if ($in === false) { diff --git a/ci-coverage.php b/ci-coverage.php index 0ade301d3..afc6833df 100644 --- a/ci-coverage.php +++ b/ci-coverage.php @@ -2,7 +2,7 @@ // phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace // phpcs:disable PSR1.Files.SideEffects.FoundWithSymbols -require_once(__DIR__ . '/vendor/autoload.php'); +require_once __DIR__ . '/vendor/autoload.php'; use SebastianBergmann\CodeCoverage\Filter; use SebastianBergmann\CodeCoverage\Driver\Selector; @@ -10,7 +10,10 @@ use SebastianBergmann\CodeCoverage\CodeCoverage; use SebastianBergmann\CodeCoverage\Report\PHP as PhpReport; use SebastianBergmann\CodeCoverage\Util\Filesystem; -function filenameList(string $path): array { /** @phpstan-ignore-line */ +/** + * @return array + */ +function filenameList(string $path): array { $list = []; foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path)) as $entry) { $filename = $entry->getPathname(); @@ -56,4 +59,4 @@ class CoverageHelper { } $coverage_helper = new CoverageHelper(); -require_once(__DIR__ . '/gazelle.php'); +require_once __DIR__ . '/gazelle.php'; diff --git a/classes/sphinxql.class.php b/classes/sphinxql.class.php index b4a6f2786..117d5ecb2 100644 --- a/classes/sphinxql.class.php +++ b/classes/sphinxql.class.php @@ -14,7 +14,6 @@ class Sphinxql extends mysqli { public static $Queries = []; public static $Time = 0.0; - /** * Initialize Sphinxql object * diff --git a/classes/sphinxqlresult.class.php b/classes/sphinxqlresult.class.php index 1c8f80c39..2df62fcf1 100644 --- a/classes/sphinxqlresult.class.php +++ b/classes/sphinxqlresult.class.php @@ -10,9 +10,12 @@ class SphinxqlResult { * @param int $Errno error code returned by the query upon failure * @param string $Error error message returned by the query upon failure */ - public function __construct(private $Result, private $Meta, public $Errno, public $Error) - { - } + public function __construct( + private $Result, + private $Meta, + public $Errno, + public $Error, + ) {} /** * Did the query find anything? diff --git a/classes/text.class.php b/classes/text.class.php index 3ebdb469c..094ca3b6a 100644 --- a/classes/text.class.php +++ b/classes/text.class.php @@ -510,6 +510,8 @@ class Text { // Thus, we have to handle these before we handle the majority of tags //5a) Different for different types of tag. Some tags don't close, others are weird like [*] + // phpcs:disable Generic.CodeAnalysis.EmptyStatement.DetectedIf + // phpcs:disable Generic.CodeAnalysis.EmptyStatement.DetectedElseif if ($i >= strlen($Str)) { // document end, tag unclosed } elseif ($TagName == 'img' && !empty($Tag[3][0])) { //[img=...] @@ -591,6 +593,8 @@ class Text { $i = $CloseTag + strlen($TagName) + 3; // 5d) Move the pointer past the end of the [/close] tag. } + // phpcs:enable Generic.CodeAnalysis.EmptyStatement.DetectedIf + // phpcs:enable Generic.CodeAnalysis.EmptyStatement.DetectedElseif // 6) Depending on what type of tag we're dealing with, create an array with the attribute and block. switch ($TagName) { diff --git a/classes/view.class.php b/classes/view.class.php index 607766948..04cdba4c7 100644 --- a/classes/view.class.php +++ b/classes/view.class.php @@ -136,7 +136,7 @@ class View { * @param array $Target * @param array $Tests */ - protected static function add_active(array $Target, array $Tests, bool $UserIDKey = false): bool { + protected static function add_active(array $Target, array $Tests): bool { if (!is_array($Tests[0])) { // Test all values in vectors foreach ($Tests as $Type => $Part) { diff --git a/gazelle.php b/gazelle.php index d800d1090..67df8d79d 100644 --- a/gazelle.php +++ b/gazelle.php @@ -6,7 +6,7 @@ use Gazelle\Util\Time; // 1. Initialization -require_once(__DIR__ . '/lib/bootstrap.php'); +require_once __DIR__ . '/lib/bootstrap.php'; global $Cache, $Debug, $Twig; // Get the user's actual IP address if they're proxied. @@ -161,7 +161,7 @@ $Cache->cache_value('php_' . getmypid(), [ register_shutdown_function( function () { if (preg_match(DEBUG_URI, $_SERVER['REQUEST_URI'])) { - require(DEBUG_TRACE); + include DEBUG_TRACE; } $error = error_get_last(); if ($error['type'] ?? 0 == E_ERROR) { @@ -182,7 +182,7 @@ if (!$file || !preg_match('/^[a-z][a-z0-9_]+$/', $module)) { } try { - require_once($file); + include_once $file; } catch (Gazelle\DB\MysqlException $e) { Gazelle\DB::DB()->rollback(); // if there was an ongoing transaction, abort it if (DEBUG_MODE || (isset($Viewer) && $Viewer->permitted('site_debug'))) { diff --git a/lib/bootstrap.php b/lib/bootstrap.php index 6562f28aa..9dc6b9eb3 100644 --- a/lib/bootstrap.php +++ b/lib/bootstrap.php @@ -13,9 +13,9 @@ foreach (['memcached', 'mysqli'] as $e) { date_default_timezone_set('UTC'); if (!defined('SITE_NAME')) { - require_once(__DIR__ . '/config.php'); - require_once(__DIR__ . '/../lib/util.php'); - require_once(__DIR__ . '/../vendor/autoload.php'); + include_once __DIR__ . '/config.php'; + include_once __DIR__ . '/../lib/util.php'; + include_once __DIR__ . '/../vendor/autoload.php'; } global $Cache, $Debug, $Twig; diff --git a/lib/config.php b/lib/config.php index 5b7536e20..0bd645cea 100644 --- a/lib/config.php +++ b/lib/config.php @@ -33,7 +33,7 @@ */ if (file_exists(__DIR__ . '/override.config.php')) { - require_once(__DIR__ . '/override.config.php'); + include_once __DIR__ . '/override.config.php'; } // ------------------------------------------------------------------------ diff --git a/lib/util.php b/lib/util.php index ba404540c..290500f07 100644 --- a/lib/util.php +++ b/lib/util.php @@ -392,15 +392,18 @@ function parse_user_agent(string $useragent): array { * $NoHTML If true, the header/footer won't be shown, just the description. * $Log If true, the user is given a link to search $Log in the site log. */ +// phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed function error(int|string $Error, bool $NoHTML = false, bool $Log = false): never { global $Debug, $Viewer, $Twig; - require_once(__DIR__ . '/../sections/error/index.php'); + include_once __DIR__ . '/../sections/error/index.php'; if (isset($Viewer)) { $Debug->profile($Viewer, $Viewer->requestContext()->module()); } exit; } +// phpcs:enable Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed + /** * Print JSON status result with an optional message and die. */ diff --git a/misc/phinx-pg.php b/misc/phinx-pg.php index 691551c87..02c98d9ee 100644 --- a/misc/phinx-pg.php +++ b/misc/phinx-pg.php @@ -1,6 +1,6 @@ [ diff --git a/misc/phinx/migrations/20181219220422_request_checksum.php b/misc/phinx/migrations/20181219220422_request_checksum.php index 4fa1afdef..d7d7b9fdd 100644 --- a/misc/phinx/migrations/20181219220422_request_checksum.php +++ b/misc/phinx/migrations/20181219220422_request_checksum.php @@ -4,5 +4,6 @@ use Phinx\Migration\AbstractMigration; class RequestChecksum extends AbstractMigration { public function up(): void {} + public function down(): void {} } diff --git a/misc/phinx/migrations/20190923063251_user_donor_rank.php b/misc/phinx/migrations/20190923063251_user_donor_rank.php index 27566fbef..581351d6c 100644 --- a/misc/phinx/migrations/20190923063251_user_donor_rank.php +++ b/misc/phinx/migrations/20190923063251_user_donor_rank.php @@ -29,10 +29,10 @@ class UserDonorRank extends AbstractMigration * Remember to call "create()" or "update()" and NOT "save()" when working * with the Table class. */ - public function up(): void { $this->execute("ALTER TABLE users_donor_ranks CHANGE InvitesRecievedRank InvitesReceivedRank tinyint(4) DEFAULT '0'"); } + public function down(): void { $this->execute("ALTER TABLE users_donor_ranks CHANGE InvitesReceivedRank InvitesRecievedRank tinyint(4) DEFAULT '0'"); } diff --git a/misc/phinx/migrations/20191103064312_drop_donation_email.php b/misc/phinx/migrations/20191103064312_drop_donation_email.php index 4199efcc3..9494ead8c 100644 --- a/misc/phinx/migrations/20191103064312_drop_donation_email.php +++ b/misc/phinx/migrations/20191103064312_drop_donation_email.php @@ -36,6 +36,7 @@ class DropDonationEmail extends AbstractMigration "); */ } + public function down(): void { $this->execute(" ALTER TABLE users_donor_ranks ADD COLUMN Email varchar(255) diff --git a/misc/phinx/migrations/20200421092111_annual_rent_float.php b/misc/phinx/migrations/20200421092111_annual_rent_float.php index e75fe4620..25b534d09 100644 --- a/misc/phinx/migrations/20200421092111_annual_rent_float.php +++ b/misc/phinx/migrations/20200421092111_annual_rent_float.php @@ -10,6 +10,7 @@ class AnnualRentFloat extends AbstractMigration { MODIFY `cc` enum('BTC', 'EUR','USD') NOT NULL DEFAULT 'USD' "); } + public function down(): void { $this->execute(" ALTER TABLE payment_reminders diff --git a/misc/phinx/migrations/20200421123459_donations_pk.php b/misc/phinx/migrations/20200421123459_donations_pk.php index d42cdab29..c2a4edc7a 100644 --- a/misc/phinx/migrations/20200421123459_donations_pk.php +++ b/misc/phinx/migrations/20200421123459_donations_pk.php @@ -12,6 +12,7 @@ class DonationsPk extends AbstractMigration { ADD KEY don_userid_time_idx (UserID, Time) '); } + public function down(): void { $this->execute(' ALTER TABLE donations diff --git a/misc/phinx/migrations/20200422170915_bitcoin_is_xbt.php b/misc/phinx/migrations/20200422170915_bitcoin_is_xbt.php index 40fc0ee26..f9e476acf 100644 --- a/misc/phinx/migrations/20200422170915_bitcoin_is_xbt.php +++ b/misc/phinx/migrations/20200422170915_bitcoin_is_xbt.php @@ -8,6 +8,7 @@ class BitcoinIsXbt extends AbstractMigration { $this->execute("UPDATE payment_reminders SET cc = 'XBT' WHERE cc = 'BTC'"); $this->execute("ALTER TABLE payment_reminders MODIFY cc enum('XBT', 'EUR', 'USD') NOT NULL DEFAULT 'USD'"); } + public function down(): void { $this->execute("ALTER TABLE payment_reminders MODIFY cc enum('BTC', 'EUR', 'USD', 'XBT') NOT NULL DEFAULT 'USD'"); $this->execute("UPDATE payment_reminders SET cc = 'BTC' WHERE cc = 'XBT'"); diff --git a/misc/phinx/migrations/20200423105540_donations_xbt.php b/misc/phinx/migrations/20200423105540_donations_xbt.php index 465f9dafe..ccddb04d1 100644 --- a/misc/phinx/migrations/20200423105540_donations_xbt.php +++ b/misc/phinx/migrations/20200423105540_donations_xbt.php @@ -7,6 +7,7 @@ class DonationsXbt extends AbstractMigration { $this->execute("ALTER TABLE donations CHANGE btc xbt decimal(24,12) NULL"); $this->execute("RENAME TABLE btc_forex TO xbt_forex"); } + public function down(): void { $this->execute("ALTER TABLE donations CHANGE xbt btc decimal(24,12) NULL"); $this->execute("RENAME TABLE xbt_forex TO btc_forex"); diff --git a/misc/phinx/migrations/20200510095617_tags_not_null.php b/misc/phinx/migrations/20200510095617_tags_not_null.php index d23406676..a7959494d 100644 --- a/misc/phinx/migrations/20200510095617_tags_not_null.php +++ b/misc/phinx/migrations/20200510095617_tags_not_null.php @@ -13,6 +13,7 @@ class TagsNotNull extends AbstractMigration { ALTER TABLE tags MODIFY Name varchar(100) NOT NULL '); } + public function down(): void { $this->execute(' ALTER TABLE tags MODIFY Name varchar(100) NULL diff --git a/misc/phinx/migrations/20200523094019_drop_user_main_columns.php b/misc/phinx/migrations/20200523094019_drop_user_main_columns.php index ca779b316..979207e83 100644 --- a/misc/phinx/migrations/20200523094019_drop_user_main_columns.php +++ b/misc/phinx/migrations/20200523094019_drop_user_main_columns.php @@ -15,6 +15,7 @@ class DropUserMainColumns extends AbstractMigration { DROP COLUMN Invites_Given '); } + public function down(): void { $this->execute(" ALTER TABLE users_main diff --git a/misc/phinx/migrations/20200626165022_pk_bookmarks_collages.php b/misc/phinx/migrations/20200626165022_pk_bookmarks_collages.php index ed09577da..54ab83c42 100644 --- a/misc/phinx/migrations/20200626165022_pk_bookmarks_collages.php +++ b/misc/phinx/migrations/20200626165022_pk_bookmarks_collages.php @@ -45,6 +45,7 @@ class PkBookmarksCollages extends AbstractMigration { DROP KEY CollageID '); } + public function down(): void { $this->execute(' ALTER TABLE bookmarks_collages diff --git a/misc/phinx/migrations/20200626165343_pk_bookmarks_requests.php b/misc/phinx/migrations/20200626165343_pk_bookmarks_requests.php index 2fa02e95f..105a540d7 100644 --- a/misc/phinx/migrations/20200626165343_pk_bookmarks_requests.php +++ b/misc/phinx/migrations/20200626165343_pk_bookmarks_requests.php @@ -15,6 +15,7 @@ class PkBookmarksRequests extends AbstractMigration { DROP KEY RequestID '); } + public function down(): void { $this->execute(' ALTER TABLE bookmarks_requests diff --git a/misc/phinx/migrations/20200817131141_drop_html_log_column.php b/misc/phinx/migrations/20200817131141_drop_html_log_column.php index b76f03ba6..f99f00441 100644 --- a/misc/phinx/migrations/20200817131141_drop_html_log_column.php +++ b/misc/phinx/migrations/20200817131141_drop_html_log_column.php @@ -6,6 +6,7 @@ class DropHtmlLogColumn extends AbstractMigration { public function up(): void { $this->execute("ALTER TABLE torrents_logs DROP COLUMN `Log`"); } + public function down(): void { $this->execute("ALTER TABLE torrents_logs ADD COLUMN `Log` mediumtext NOT NULL"); } diff --git a/misc/phinx/migrations/20200830134449_user_history_email_pk.php b/misc/phinx/migrations/20200830134449_user_history_email_pk.php index 98d238698..5d0eac57a 100644 --- a/misc/phinx/migrations/20200830134449_user_history_email_pk.php +++ b/misc/phinx/migrations/20200830134449_user_history_email_pk.php @@ -8,6 +8,7 @@ class UserHistoryEmailPk extends AbstractMigration { ALTER TABLE users_history_emails ADD COLUMN users_history_emails_id int(10) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY '); } + public function down(): void { $this->execute(' ALTER TABLE users_history_emails DROP COLUMN users_history_emails_id diff --git a/misc/phinx/migrations/20200918065547_artist_name_sort.php b/misc/phinx/migrations/20200918065547_artist_name_sort.php index 0f7bc8195..728f2a3e6 100644 --- a/misc/phinx/migrations/20200918065547_artist_name_sort.php +++ b/misc/phinx/migrations/20200918065547_artist_name_sort.php @@ -10,6 +10,7 @@ class ArtistNameSort extends AbstractMigration { ADD PRIMARY KEY (GroupID, Importance, ArtistID) '); } + public function down(): void { $this->execute(' ALTER TABLE torrents_artists diff --git a/misc/phinx/migrations/20201128060653_dead_stylesheets.php b/misc/phinx/migrations/20201128060653_dead_stylesheets.php index 5001f9dd5..d3a9153f9 100644 --- a/misc/phinx/migrations/20201128060653_dead_stylesheets.php +++ b/misc/phinx/migrations/20201128060653_dead_stylesheets.php @@ -9,8 +9,7 @@ use Phinx\Migration\AbstractMigration; */ final class DeadStylesheets extends AbstractMigration { - public function up(): void - { + public function up(): void { $removedStylesheets = [ 'Hydro', 'Anorex', @@ -33,8 +32,7 @@ final class DeadStylesheets extends AbstractMigration } } - public function down(): void - { + public function down(): void { $this->query("DELETE FROM stylesheets WHERE `Name` = 'Dark Cake'"); } } diff --git a/misc/phinx/migrations/20201227143426_artist_arranger.php b/misc/phinx/migrations/20201227143426_artist_arranger.php index e6fd80444..a9e5e4fab 100644 --- a/misc/phinx/migrations/20201227143426_artist_arranger.php +++ b/misc/phinx/migrations/20201227143426_artist_arranger.php @@ -6,8 +6,7 @@ use Phinx\Migration\AbstractMigration; final class ArtistArranger extends AbstractMigration { - public function up(): void - { + public function up(): void { $this->table('requests_artists') ->changeColumn('Importance', 'enum', [ 'null' => false, 'values' => ['1', '2', '3', '4', '5', '6', '7', '8'], @@ -20,8 +19,7 @@ final class ArtistArranger extends AbstractMigration ->save(); } - public function down(): void - { + public function down(): void { $this->table('requests_artists') ->changeColumn('Importance', 'enum', [ 'null' => true, 'values' => ['1', '2', '3', '4', '5', '6', '7'], diff --git a/misc/phinx/migrations/20210101173152_artist_role.php b/misc/phinx/migrations/20210101173152_artist_role.php index 0fba17b06..fe5611697 100644 --- a/misc/phinx/migrations/20210101173152_artist_role.php +++ b/misc/phinx/migrations/20210101173152_artist_role.php @@ -7,8 +7,7 @@ use Phinx\Db\Adapter\MysqlAdapter; final class ArtistRole extends AbstractMigration { - public function change(): void - { + public function change(): void { $this->table('artist_role', ['id' => false, 'primary_key' => ['artist_role_id']]) ->addColumn('artist_role_id', 'integer', ['identity' => true, 'limit' => MysqlAdapter::INT_TINY]) ->addColumn('sequence', 'integer') diff --git a/misc/phinx/migrations/20210101182308_use_artist_role.php b/misc/phinx/migrations/20210101182308_use_artist_role.php index ded8b082f..756bb18f0 100644 --- a/misc/phinx/migrations/20210101182308_use_artist_role.php +++ b/misc/phinx/migrations/20210101182308_use_artist_role.php @@ -18,8 +18,7 @@ final class UseArtistRole extends AbstractMigration * Remember to call "create()" or "update()" and NOT "save()" when working * with the Table class. */ - public function change(): void - { + public function change(): void { $this->table('torrents_artists') ->addColumn('artist_role_id', 'integer', ['null' => true, 'limit' => MysqlAdapter::INT_TINY]) ->addForeignKey('artist_role_id', 'artist_role', 'artist_role_id', diff --git a/misc/phinx/migrations/20210103152728_index_torrent_path.php b/misc/phinx/migrations/20210103152728_index_torrent_path.php index e4edfcac1..0806247c2 100644 --- a/misc/phinx/migrations/20210103152728_index_torrent_path.php +++ b/misc/phinx/migrations/20210103152728_index_torrent_path.php @@ -17,8 +17,7 @@ final class IndexTorrentPath extends AbstractMigration * Remember to call "create()" or "update()" and NOT "save()" when working * with the Table class. */ - public function change(): void - { + public function change(): void { $this->table('torrents') ->addIndex(['FilePath'], ['name' => 't_filepath_idx']) ->update(); diff --git a/misc/phinx/migrations/20210117113305_user_read_tables.php b/misc/phinx/migrations/20210117113305_user_read_tables.php index 51795535c..5aca0c2e2 100644 --- a/misc/phinx/migrations/20210117113305_user_read_tables.php +++ b/misc/phinx/migrations/20210117113305_user_read_tables.php @@ -6,8 +6,7 @@ use Phinx\Migration\AbstractMigration; final class UserReadTables extends AbstractMigration { - public function change(): void - { + public function change(): void { $this->table('user_read_blog', ['id' => false, 'primary_key' => 'user_id']) ->addColumn('user_id', 'integer', ['limit' => 10, 'signed' => false]) ->addColumn('blog_id', 'integer', ['limit' => 10, 'signed' => false]) diff --git a/misc/phinx/migrations/20210119174130_user_default_visible.php b/misc/phinx/migrations/20210119174130_user_default_visible.php index 5a325eb66..2216c166f 100644 --- a/misc/phinx/migrations/20210119174130_user_default_visible.php +++ b/misc/phinx/migrations/20210119174130_user_default_visible.php @@ -6,8 +6,7 @@ use Phinx\Migration\AbstractMigration; final class UserDefaultVisible extends AbstractMigration { - public function up(): void - { + public function up(): void { $this->table('users_main') ->changeColumn('Visible', 'enum', [ 'default' => '1', @@ -16,8 +15,7 @@ final class UserDefaultVisible extends AbstractMigration ->save(); } - public function down(): void - { + public function down(): void { $this->table('users_main') ->changeColumn('Visible', 'enum', [ 'null' => true, diff --git a/misc/phinx/migrations/20210119180148_user_enabled_not_null.php b/misc/phinx/migrations/20210119180148_user_enabled_not_null.php index 84eb690c9..7ea6f0a4a 100644 --- a/misc/phinx/migrations/20210119180148_user_enabled_not_null.php +++ b/misc/phinx/migrations/20210119180148_user_enabled_not_null.php @@ -6,8 +6,7 @@ use Phinx\Migration\AbstractMigration; final class UserEnabledNotNull extends AbstractMigration { - public function up(): void - { + public function up(): void { $this->table('users_main') ->changeColumn('Enabled', 'enum', [ 'default' => '0', @@ -16,8 +15,7 @@ final class UserEnabledNotNull extends AbstractMigration ->save(); } - public function down(): void - { + public function down(): void { $this->table('users_main') ->changeColumn('Enabled', 'enum', [ 'null' => true, diff --git a/misc/phinx/migrations/20210203173519_sane_wiki_revisions.php b/misc/phinx/migrations/20210203173519_sane_wiki_revisions.php index 864dd9a92..08d3a8f71 100644 --- a/misc/phinx/migrations/20210203173519_sane_wiki_revisions.php +++ b/misc/phinx/migrations/20210203173519_sane_wiki_revisions.php @@ -7,8 +7,7 @@ use Phinx\Db\Adapter\MysqlAdapter; final class SaneWikiRevisions extends AbstractMigration { - public function up(): void - { + public function up(): void { $this->table('wiki_revisions') ->changeColumn('Revision', 'integer', ['null' => false, 'limit' => '10', 'default' => 1]) ->changeColumn('Title', 'string', ['null' => false, 'collation' => 'utf8mb4_unicode_ci', 'encoding' => 'utf8mb4']) @@ -20,8 +19,7 @@ final class SaneWikiRevisions extends AbstractMigration $this->execute("ALTER TABLE wiki_revisions ADD PRIMARY KEY (ID, Revision)"); } - public function down(): void - { + public function down(): void { $this->execute("ALTER TABLE wiki_revisions DROP PRIMARY KEY"); $this->table('wiki_revisions') ->changeColumn('Revision', 'integer', ['null' => false, 'limit' => '10']) diff --git a/misc/phinx/migrations/20210316105133_artist_attribute.php b/misc/phinx/migrations/20210316105133_artist_attribute.php index 97e1aaff6..b91ec0fac 100644 --- a/misc/phinx/migrations/20210316105133_artist_attribute.php +++ b/misc/phinx/migrations/20210316105133_artist_attribute.php @@ -6,8 +6,7 @@ use Phinx\Migration\AbstractMigration; final class ArtistAttribute extends AbstractMigration { - public function change(): void - { + public function change(): void { $this->table('artist_attr', ['id' => false, 'primary_key' => 'artist_attr_id']) ->addColumn('artist_attr_id', 'integer', ['limit' => 6, 'identity' => true]) ->addColumn('name', 'string', ['limit' => 24]) diff --git a/misc/phinx/migrations/20210514142740_recovery_buffer.php b/misc/phinx/migrations/20210514142740_recovery_buffer.php index b136e6bf9..376c9006a 100644 --- a/misc/phinx/migrations/20210514142740_recovery_buffer.php +++ b/misc/phinx/migrations/20210514142740_recovery_buffer.php @@ -6,8 +6,7 @@ use Phinx\Migration\AbstractMigration; final class RecoveryBuffer extends AbstractMigration { - public function change(): void - { + public function change(): void { $this->table('recovery_buffer', ['id' => false, 'primary_key' => ['user_id']]) ->addColumn('user_id', 'integer', ['limit' => 10, 'signed' => false, 'identity' => true]) ->addColumn('prev_id', 'integer', ['limit' => 10, 'signed' => false]) diff --git a/misc/phinx/migrations/20210514174014_unicode_inbox.php b/misc/phinx/migrations/20210514174014_unicode_inbox.php index 4098c48c8..64f9cc6cf 100644 --- a/misc/phinx/migrations/20210514174014_unicode_inbox.php +++ b/misc/phinx/migrations/20210514174014_unicode_inbox.php @@ -7,8 +7,7 @@ use Phinx\Db\Adapter\MysqlAdapter; final class UnicodeInbox extends AbstractMigration { - public function up(): void - { + public function up(): void { $this->table('pm_conversations') ->changeColumn('Subject', 'string', ['null' => false, 'limit' => 255, 'collation' => 'utf8mb4_unicode_ci', 'encoding' => 'utf8mb4']) ->save(); @@ -35,8 +34,7 @@ final class UnicodeInbox extends AbstractMigration ->save(); } - public function down(): void - { + public function down(): void { $this->table('pm_conversations') ->changeColumn('Subject', 'string', ['null' => true, 'limit' => 255, 'collation' => 'utf8_general_ci', 'encoding' => 'utf8']) ->save(); diff --git a/misc/phinx/migrations/20210609175044_wiki_utf_8mb_4.php b/misc/phinx/migrations/20210609175044_wiki_utf_8mb_4.php index 01d1e322f..01d267b63 100644 --- a/misc/phinx/migrations/20210609175044_wiki_utf_8mb_4.php +++ b/misc/phinx/migrations/20210609175044_wiki_utf_8mb_4.php @@ -7,8 +7,7 @@ use Phinx\Db\Adapter\MysqlAdapter; final class WikiUtf8mb4 extends AbstractMigration { - public function up(): void - { + public function up(): void { $this->table('wiki_articles') ->changeColumn('Title', 'string', ['null' => false, 'limit' => 100, 'collation' => 'utf8mb4_unicode_ci', 'encoding' => 'utf8mb4']) ->changeColumn('Body', 'text', ['null' => false, 'default' => null, 'collation' => 'utf8mb4_unicode_ci', 'encoding' => 'utf8mb4', 'limit' => MysqlAdapter::TEXT_MEDIUM]) @@ -19,8 +18,7 @@ final class WikiUtf8mb4 extends AbstractMigration ->save(); } - public function down(): void - { + public function down(): void { $this->table('wiki_articles') ->changeColumn('Title', 'string', ['null' => true, 'limit' => 100, 'collation' => 'utf8_general_ci', 'encoding' => 'utf8']) ->changeColumn('Body', 'text', ['null' => true, 'default' => null, 'collation' => 'utf8_general_ci', 'encoding' => 'utf8', 'limit' => MysqlAdapter::TEXT_MEDIUM]) diff --git a/misc/phinx/migrations/20210616100351_invite_source.php b/misc/phinx/migrations/20210616100351_invite_source.php index af94e88d9..6567b844f 100644 --- a/misc/phinx/migrations/20210616100351_invite_source.php +++ b/misc/phinx/migrations/20210616100351_invite_source.php @@ -17,8 +17,7 @@ final class InviteSource extends AbstractMigration * Remember to call "create()" or "update()" and NOT "save()" when working * with the Table class. */ - public function change(): void - { + public function change(): void { $this->table('invite_source', ['id' => false, 'primary_key' => ['invite_source_id']]) ->addColumn('invite_source_id', 'integer', ['limit' => 10, 'signed' => false, 'identity' => true]) ->addColumn('name', 'string', ['limit' => 20, 'encoding' => 'ascii']) diff --git a/misc/phinx/migrations/20210819164124_user_upvote.php b/misc/phinx/migrations/20210819164124_user_upvote.php index 1dba3ac54..b5b21ec6f 100644 --- a/misc/phinx/migrations/20210819164124_user_upvote.php +++ b/misc/phinx/migrations/20210819164124_user_upvote.php @@ -7,8 +7,7 @@ use Phinx\Db\Adapter\MysqlAdapter; final class UserUpvote extends AbstractMigration { - public function up(): void - { + public function up(): void { $this->table('users_votes') ->addColumn('upvote', 'integer', ['default' => 1, 'limit' => MysqlAdapter::INT_TINY]) ->addIndex(['upvote','GroupID','UserID'], ['name' => 'uv_t_grp_usr_idx']) @@ -18,8 +17,7 @@ final class UserUpvote extends AbstractMigration $this->execute("UPDATE users_votes SET upvote = if(Type = 'Up', 1, 0)"); } - public function down(): void - { + public function down(): void { $this->table('users_votes') ->removeColumn('upvote') ->removeIndex(['upvote','GroupID','UserID']) diff --git a/misc/phinx/migrations/20210905164459_more_user_stats.php b/misc/phinx/migrations/20210905164459_more_user_stats.php index f7c2376fe..29cb2c340 100644 --- a/misc/phinx/migrations/20210905164459_more_user_stats.php +++ b/misc/phinx/migrations/20210905164459_more_user_stats.php @@ -6,8 +6,7 @@ use Phinx\Migration\AbstractMigration; final class MoreUserStats extends AbstractMigration { - public function change(): void - { + public function change(): void { $this->table('user_summary', ['id' => false, 'primary_key' => 'user_id']) ->addColumn('user_id', 'integer', ['limit' => 10, 'signed' => false]) ->addColumn('artist_added_total', 'integer', ['limit' => 10, 'default' => 0]) diff --git a/misc/phinx/migrations/20210907165651_forum_topic_foreign_keys.php b/misc/phinx/migrations/20210907165651_forum_topic_foreign_keys.php index 4afcecf8e..496bbf005 100644 --- a/misc/phinx/migrations/20210907165651_forum_topic_foreign_keys.php +++ b/misc/phinx/migrations/20210907165651_forum_topic_foreign_keys.php @@ -6,8 +6,7 @@ use Phinx\Migration\AbstractMigration; final class ForumTopicForeignKeys extends AbstractMigration { - public function up(): void - { + public function up(): void { $this->table('forums_topics') ->changeColumn('ForumID', 'integer', ['signed' => false]) ->changeColumn('AuthorID', 'integer', ['signed' => false]) @@ -19,8 +18,7 @@ final class ForumTopicForeignKeys extends AbstractMigration ->save(); } - public function down(): void - { + public function down(): void { $this->table('forums_topics') ->dropForeignKey('ForumID') ->dropForeignKey('AuthorID') diff --git a/misc/phinx/migrations/20210907213146_forum_post_foreign_keys.php b/misc/phinx/migrations/20210907213146_forum_post_foreign_keys.php index d57b71aee..c3adae142 100644 --- a/misc/phinx/migrations/20210907213146_forum_post_foreign_keys.php +++ b/misc/phinx/migrations/20210907213146_forum_post_foreign_keys.php @@ -6,8 +6,7 @@ use Phinx\Migration\AbstractMigration; final class ForumPostForeignKeys extends AbstractMigration { - public function up(): void - { + public function up(): void { $this->table('forums_posts') ->changeColumn('AuthorID', 'integer', ['signed' => false]) ->changeColumn('EditedUserID', 'integer', ['signed' => false]) @@ -15,8 +14,7 @@ final class ForumPostForeignKeys extends AbstractMigration ->save(); } - public function down(): void - { + public function down(): void { $this->table('forums_posts') ->dropForeignKey('AuthorID') ->dropForeignKey('TopicID') diff --git a/misc/phinx/migrations/20210907214723_forum_poll_foreign_keys.php b/misc/phinx/migrations/20210907214723_forum_poll_foreign_keys.php index c7f9cbb8c..0e3afb8f7 100644 --- a/misc/phinx/migrations/20210907214723_forum_poll_foreign_keys.php +++ b/misc/phinx/migrations/20210907214723_forum_poll_foreign_keys.php @@ -6,16 +6,14 @@ use Phinx\Migration\AbstractMigration; final class ForumPollForeignKeys extends AbstractMigration { - public function up(): void - { + public function up(): void { $this->table('forums_polls') ->changeColumn('TopicID', 'integer', ['signed' => true]) ->addForeignKey('TopicID', 'forums_topics', 'ID', ['delete' => 'CASCADE', 'update' => 'CASCADE']) ->save(); } - public function down(): void - { + public function down(): void { $this->table('forums_polls') ->dropForeignKey('TopicID') ->save(); diff --git a/misc/phinx/migrations/20210907215019_forum_last_read_topics_keys.php b/misc/phinx/migrations/20210907215019_forum_last_read_topics_keys.php index b286315ed..4a223a933 100644 --- a/misc/phinx/migrations/20210907215019_forum_last_read_topics_keys.php +++ b/misc/phinx/migrations/20210907215019_forum_last_read_topics_keys.php @@ -6,8 +6,7 @@ use Phinx\Migration\AbstractMigration; final class ForumLastReadTopicsKeys extends AbstractMigration { - public function up(): void - { + public function up(): void { $this->table('forums_last_read_topics') ->changeColumn('UserID', 'integer', ['signed' => false]) ->addForeignKey('PostID', 'forums_posts', 'ID', ['delete' => 'CASCADE', 'update' => 'CASCADE']) @@ -16,8 +15,7 @@ final class ForumLastReadTopicsKeys extends AbstractMigration ->save(); } - public function down(): void - { + public function down(): void { $this->table('forums_last_read_topics') ->dropForeignKey('PostID') ->dropForeignKey('TopicID') diff --git a/misc/phinx/migrations/20210908072448_collage_foreign_keys.php b/misc/phinx/migrations/20210908072448_collage_foreign_keys.php index 1f9e734fe..994febb47 100644 --- a/misc/phinx/migrations/20210908072448_collage_foreign_keys.php +++ b/misc/phinx/migrations/20210908072448_collage_foreign_keys.php @@ -6,8 +6,7 @@ use Phinx\Migration\AbstractMigration; final class CollageForeignKeys extends AbstractMigration { - public function up(): void - { + public function up(): void { $this->table('collages') ->changeColumn('UserID', 'integer', ['signed' => false]) ->addForeignKey('UserID', 'users_main', 'ID', ['delete' => 'CASCADE', 'update' => 'CASCADE']) @@ -40,8 +39,7 @@ final class CollageForeignKeys extends AbstractMigration ->save(); } - public function down(): void - { + public function down(): void { $this->table('collages') ->dropForeignKey('UserID') diff --git a/misc/phinx/migrations/20210911215404_drop_users_summary.php b/misc/phinx/migrations/20210911215404_drop_users_summary.php index 01a18d5bb..e1038917e 100644 --- a/misc/phinx/migrations/20210911215404_drop_users_summary.php +++ b/misc/phinx/migrations/20210911215404_drop_users_summary.php @@ -6,13 +6,11 @@ use Phinx\Migration\AbstractMigration; final class DropUsersSummary extends AbstractMigration { - public function up(): void - { + public function up(): void { $this->table('users_summary')->drop()->update(); } - public function down(): void - { + public function down(): void { $this->table('users_summary', ['id' => false, 'primary_key' => 'UserID']) ->addColumn('UserID', 'integer', ['limit' => 10, 'signed' => false]) ->addColumn('Groups', 'integer', ['limit' => 10, 'default' => 0]) diff --git a/misc/phinx/migrations/20211106221613_drop_calendar.php b/misc/phinx/migrations/20211106221613_drop_calendar.php index 3e78675e6..317627628 100644 --- a/misc/phinx/migrations/20211106221613_drop_calendar.php +++ b/misc/phinx/migrations/20211106221613_drop_calendar.php @@ -7,13 +7,11 @@ use Phinx\Db\Adapter\MysqlAdapter; final class DropCalendar extends AbstractMigration { - public function up(): void - { + public function up(): void { $this->table('calendar')->drop()->save(); } - public function down(): void - { + public function down(): void { $this->table('calendar', [ 'id' => false, 'primary_key' => ['ID'], diff --git a/misc/phinx/migrations/20211126205331_error_management.php b/misc/phinx/migrations/20211126205331_error_management.php index c6731e71b..bae704959 100644 --- a/misc/phinx/migrations/20211126205331_error_management.php +++ b/misc/phinx/migrations/20211126205331_error_management.php @@ -7,8 +7,7 @@ use Phinx\Db\Adapter\MysqlAdapter; final class ErrorManagement extends AbstractMigration { - public function change(): void - { + public function change(): void { $this->table('error_log', ['id' => false, 'primary_key' => 'error_log_id', 'encoding' => 'utf8mb4']) ->addColumn('error_log_id', 'integer', ['limit' => 10, 'signed' => false, 'identity' => true]) ->addColumn('duration', 'float', ['default' => 0]) diff --git a/misc/phinx/migrations/20211127214642_bookmark_torrent_fkey.php b/misc/phinx/migrations/20211127214642_bookmark_torrent_fkey.php index 6e88dc220..ce78185be 100644 --- a/misc/phinx/migrations/20211127214642_bookmark_torrent_fkey.php +++ b/misc/phinx/migrations/20211127214642_bookmark_torrent_fkey.php @@ -6,8 +6,7 @@ use Phinx\Migration\AbstractMigration; final class BookmarkTorrentFkey extends AbstractMigration { - public function up(): void - { + public function up(): void { $this->table('bookmarks_torrents') ->changeColumn('UserID', 'integer', ['limit' => 10, 'signed' => false]) ->addForeignKey('GroupID', 'torrents_group', 'ID') @@ -15,8 +14,7 @@ final class BookmarkTorrentFkey extends AbstractMigration ->save(); } - public function down(): void - { + public function down(): void { $this->table('bookmarks_torrents') ->dropForeignKey('GroupID') ->dropForeignKey('UserID') diff --git a/misc/phinx/migrations/20211203132409_user_download_pk.php b/misc/phinx/migrations/20211203132409_user_download_pk.php index 549821026..f24672615 100644 --- a/misc/phinx/migrations/20211203132409_user_download_pk.php +++ b/misc/phinx/migrations/20211203132409_user_download_pk.php @@ -6,8 +6,7 @@ use Phinx\Migration\AbstractMigration; final class UserDownloadPk extends AbstractMigration { - public function up(): void - { + public function up(): void { $this->execute(" ALTER TABLE users_downloads DROP PRIMARY KEY, @@ -16,8 +15,7 @@ final class UserDownloadPk extends AbstractMigration "); } - public function down(): void - { + public function down(): void { $this->execute(" ALTER TABLE users_downloads DROP PRIMARY KEY, diff --git a/misc/phinx/migrations/20211206083341_deleted_torrent_group.php b/misc/phinx/migrations/20211206083341_deleted_torrent_group.php index 5f43eea5a..efa646c40 100644 --- a/misc/phinx/migrations/20211206083341_deleted_torrent_group.php +++ b/misc/phinx/migrations/20211206083341_deleted_torrent_group.php @@ -8,8 +8,7 @@ use Phinx\Util\Literal; final class DeletedTorrentGroup extends AbstractMigration { - public function up(): void - { + public function up(): void { $this->table('deleted_torrents_group', ['id' => false, 'primary_key' => 'ID']) ->addColumn('ID', 'integer', ['length' => 10, 'identity' => true]) ->addColumn('CategoryID', 'integer', ['length' => 3]) @@ -37,8 +36,8 @@ final class DeletedTorrentGroup extends AbstractMigration MODIFY WikiBody mediumtext "); } - public function down(): void - { + + public function down(): void { // because "You can't delete all columns with ALTER TABLE; use DROP TABLE instead" $this->table('deleted_torrents_group')->drop()->save(); } diff --git a/misc/phinx/migrations/20211218182022_non_music_request_release_type.php b/misc/phinx/migrations/20211218182022_non_music_request_release_type.php index db0baaf96..f75258840 100644 --- a/misc/phinx/migrations/20211218182022_non_music_request_release_type.php +++ b/misc/phinx/migrations/20211218182022_non_music_request_release_type.php @@ -6,13 +6,11 @@ use Phinx\Migration\AbstractMigration; final class NonMusicRequestReleaseType extends AbstractMigration { - public function up(): void - { + public function up(): void { $this->query("ALTER TABLE requests MODIFY ReleaseType tinyint(2) NOT NULL DEFAULT 21"); } - public function down(): void - { + public function down(): void { $this->query("ALTER TABLE requests MODIFY ReleaseType tinyint(2) DEFAULT NULL"); } } diff --git a/misc/phinx/migrations/20211220180428_tgroup_stats.php b/misc/phinx/migrations/20211220180428_tgroup_stats.php index 2b35391d2..07799fe7c 100644 --- a/misc/phinx/migrations/20211220180428_tgroup_stats.php +++ b/misc/phinx/migrations/20211220180428_tgroup_stats.php @@ -6,8 +6,7 @@ use Phinx\Migration\AbstractMigration; final class TgroupStats extends AbstractMigration { - public function change(): void - { + public function change(): void { $this->table('tgroup_summary', ['id' => false, 'primary_key' => 'tgroup_id']) ->addColumn('tgroup_id', 'integer', ['limit' => 10]) ->addColumn('bookmark_total', 'integer', ['limit' => 10, 'default' => 0]) diff --git a/misc/phinx/migrations/20211221221145_torrents_fkey.php b/misc/phinx/migrations/20211221221145_torrents_fkey.php index b93fa6437..42cfebf6d 100644 --- a/misc/phinx/migrations/20211221221145_torrents_fkey.php +++ b/misc/phinx/migrations/20211221221145_torrents_fkey.php @@ -6,8 +6,7 @@ use Phinx\Migration\AbstractMigration; final class TorrentsFkey extends AbstractMigration { - public function up(): void - { + public function up(): void { $this->table('torrents') ->changeColumn('UserID', 'integer', ['limit' => 10, 'signed' => false]) ->addForeignKey('GroupID', 'torrents_group', 'ID') @@ -16,8 +15,7 @@ final class TorrentsFkey extends AbstractMigration ->save(); } - public function down(): void - { + public function down(): void { $this->table('torrents') ->dropForeignKey('GroupID') ->dropForeignKey('UserID') diff --git a/misc/phinx/migrations/20211224171515_xfu_ip.php b/misc/phinx/migrations/20211224171515_xfu_ip.php index 9f52fc251..6f9744490 100644 --- a/misc/phinx/migrations/20211224171515_xfu_ip.php +++ b/misc/phinx/migrations/20211224171515_xfu_ip.php @@ -6,8 +6,7 @@ use Phinx\Migration\AbstractMigration; final class XfuIp extends AbstractMigration { - public function change(): void - { + public function change(): void { $this->table('xbt_files_users') ->addIndex(['IP'], ['name' => 'xfu_ip_idx']) ->update(); diff --git a/misc/phinx/migrations/20211230213043_scheduler_launch_index.php b/misc/phinx/migrations/20211230213043_scheduler_launch_index.php index bd562b5c4..3acc33856 100644 --- a/misc/phinx/migrations/20211230213043_scheduler_launch_index.php +++ b/misc/phinx/migrations/20211230213043_scheduler_launch_index.php @@ -6,8 +6,7 @@ use Phinx\Migration\AbstractMigration; final class SchedulerLaunchIndex extends AbstractMigration { - public function change(): void - { + public function change(): void { $this->table('periodic_task_history') ->addIndex(['launch_time'], ['name' => 'pth_lt_idx']) ->update(); diff --git a/misc/phinx/migrations/20211231215237_error_log_vars.php b/misc/phinx/migrations/20211231215237_error_log_vars.php index 759da1453..2aad0ca3e 100644 --- a/misc/phinx/migrations/20211231215237_error_log_vars.php +++ b/misc/phinx/migrations/20211231215237_error_log_vars.php @@ -6,8 +6,7 @@ use Phinx\Migration\AbstractMigration; final class ErrorLogVars extends AbstractMigration { - public function up(): void - { + public function up(): void { $this->table('error_log') ->addColumn('logged_var', 'json', ['null' => true]) ->save(); @@ -17,8 +16,7 @@ final class ErrorLogVars extends AbstractMigration ->save(); } - public function down(): void - { + public function down(): void { $this->table('error_log') ->removeColumn('logged_var') ->save(); diff --git a/misc/phinx/migrations/20220111130438_user_buy_collage.php b/misc/phinx/migrations/20220111130438_user_buy_collage.php index 5b25ac877..df96e8093 100644 --- a/misc/phinx/migrations/20220111130438_user_buy_collage.php +++ b/misc/phinx/migrations/20220111130438_user_buy_collage.php @@ -6,15 +6,13 @@ use Phinx\Migration\AbstractMigration; final class UserBuyCollage extends AbstractMigration { - public function up(): void - { + public function up(): void { $this->query(" UPDATE bonus_item SET MinClass = 0 WHERE label = 'collage-1' and MinClass != 0 "); } - public function down(): void - { + public function down(): void { $this->query(" UPDATE bonus_item SET MinClass = 150 WHERE label = 'collage-1' and MinClass != 150 "); diff --git a/misc/phinx/migrations/20220118161619_nuke_users_info_columns.php b/misc/phinx/migrations/20220118161619_nuke_users_info_columns.php index dc1d9c1a9..25c490e09 100644 --- a/misc/phinx/migrations/20220118161619_nuke_users_info_columns.php +++ b/misc/phinx/migrations/20220118161619_nuke_users_info_columns.php @@ -6,8 +6,7 @@ use Phinx\Migration\AbstractMigration; final class NukeUsersInfoColumns extends AbstractMigration { - public function up(): void - { + public function up(): void { $this->table('users_info') ->removeColumn('BitcoinAddress') ->removeColumn('HideCountryChanges') @@ -15,8 +14,7 @@ final class NukeUsersInfoColumns extends AbstractMigration ->save(); } - public function down(): void - { + public function down(): void { $this->table('users_info') ->addColumn('BitcoinAddress', 'string', ['limit' => 34]) ->addColumn('HideCountryChanges', 'enum', ['values' => ['0', '1'], 'default' => '0']) diff --git a/misc/phinx/migrations/20220118231832_add_disable_user_attrs.php b/misc/phinx/migrations/20220118231832_add_disable_user_attrs.php index e972ebeb6..3d2eff4f4 100644 --- a/misc/phinx/migrations/20220118231832_add_disable_user_attrs.php +++ b/misc/phinx/migrations/20220118231832_add_disable_user_attrs.php @@ -6,8 +6,7 @@ use Phinx\Migration\AbstractMigration; final class AddDisableUserAttrs extends AbstractMigration { - public function up(): void - { + public function up(): void { $rows = [ ['Name' => 'disable-avatar', 'Description' => 'This user has avatar privileges disabled'], ['Name' => 'disable-forums', 'Description' => 'This user has forum privileges disabled'], @@ -25,8 +24,7 @@ final class AddDisableUserAttrs extends AbstractMigration $this->table('user_attr')->insert($rows)->save(); } - public function down(): void - { + public function down(): void { $this->execute("DELETE FROM user_attr where Name = 'disable-avatar'"); $this->execute("DELETE FROM user_attr where Name = 'disable-forums'"); $this->execute("DELETE FROM user_attr where Name = 'disable-invites'"); diff --git a/misc/phinx/migrations/20220124085719_user_catchup_disable_attr.php b/misc/phinx/migrations/20220124085719_user_catchup_disable_attr.php index f2bcbf5b0..3ab09f08b 100644 --- a/misc/phinx/migrations/20220124085719_user_catchup_disable_attr.php +++ b/misc/phinx/migrations/20220124085719_user_catchup_disable_attr.php @@ -6,8 +6,7 @@ use Phinx\Migration\AbstractMigration; final class UserCatchupDisableAttr extends AbstractMigration { - public function change(): void - { + public function change(): void { $this->query(" INSERT IGNORE INTO user_has_attr (UserID, UserAttrID) SELECT ID, (SELECT ID FROM user_attr WHERE Name = 'disable-leech') FROM users_main where can_leech != 1 diff --git a/misc/phinx/migrations/20220206181747_mysql_rank.php b/misc/phinx/migrations/20220206181747_mysql_rank.php index 54d581c5a..1ace74314 100644 --- a/misc/phinx/migrations/20220206181747_mysql_rank.php +++ b/misc/phinx/migrations/20220206181747_mysql_rank.php @@ -6,8 +6,7 @@ use Phinx\Migration\AbstractMigration; final class MysqlRank extends AbstractMigration { - public function change(): void - { + public function change(): void { $this->table('donations')->renameColumn('Rank', 'donor_rank')->save(); $this->table('users_donor_ranks')->renameColumn('Rank', 'donor_rank')->save(); $this->table('top10_history_torrents')->renameColumn('Rank', 'sequence')->save(); diff --git a/misc/phinx/migrations/20220210082532_more_table_defaults.php b/misc/phinx/migrations/20220210082532_more_table_defaults.php index db67ec02c..de27f2354 100644 --- a/misc/phinx/migrations/20220210082532_more_table_defaults.php +++ b/misc/phinx/migrations/20220210082532_more_table_defaults.php @@ -6,8 +6,7 @@ use Phinx\Migration\AbstractMigration; final class MoreTableDefaults extends AbstractMigration { - public function up(): void - { + public function up(): void { $this->table('forums_topics') ->changeColumn('Title', 'string', ['length' => 255, 'null' => false]) ->save(); @@ -37,8 +36,7 @@ final class MoreTableDefaults extends AbstractMigration ->save(); } - public function down(): void - { + public function down(): void { $this->table('forums_topics') ->changeColumn('Title', 'string', ['length' => 255, 'null' => true]) ->save(); diff --git a/misc/phinx/migrations/20220402191945_error_log_user.php b/misc/phinx/migrations/20220402191945_error_log_user.php index 7503071b2..24b2c715b 100644 --- a/misc/phinx/migrations/20220402191945_error_log_user.php +++ b/misc/phinx/migrations/20220402191945_error_log_user.php @@ -5,15 +5,13 @@ declare(strict_types=1); use Phinx\Migration\AbstractMigration; final class ErrorLogUser extends AbstractMigration { - public function up(): void - { + public function up(): void { $this->table('error_log') ->addColumn('user_id', 'integer', ['default' => 0]) ->save(); } - public function down(): void - { + public function down(): void { $this->table('error_log') ->removeColumn('user_id') ->save(); diff --git a/misc/phinx/migrations/20221022181407_report_types.php b/misc/phinx/migrations/20221022181407_report_types.php index 8749f6b62..d89443396 100644 --- a/misc/phinx/migrations/20221022181407_report_types.php +++ b/misc/phinx/migrations/20221022181407_report_types.php @@ -6,7 +6,7 @@ use Phinx\Migration\AbstractMigration; use Phinx\Db\Adapter\MysqlAdapter; // phpcs:disable PSR1.Files.SideEffects.FoundWithSymbols -require_once(__DIR__ . '/../../../lib/config.php'); // for SITE_NAME +require_once __DIR__ . '/../../../lib/config.php'; // for SITE_NAME // phpcs:enable PSR1.Files.SideEffects.FoundWithSymbols final class ReportTypes extends AbstractMigration { diff --git a/misc/phinx/migrations/20230108132655_drop_user_main_secret.php b/misc/phinx/migrations/20230108132655_drop_user_main_secret.php index 568e9c429..a36f0380d 100644 --- a/misc/phinx/migrations/20230108132655_drop_user_main_secret.php +++ b/misc/phinx/migrations/20230108132655_drop_user_main_secret.php @@ -12,6 +12,7 @@ final class DropUserMainSecret extends AbstractMigration { MODIFY SiteOptions mediumtext '); } + public function down(): void { $this->table('users_main')->removeColumn('Secret')->save(); $this->query('ALTER TABLE users_info diff --git a/misc/phinx/migrations/20230406170000_group_log_null_userid.php b/misc/phinx/migrations/20230406170000_group_log_null_userid.php index bd80c87ba..76d3d836c 100644 --- a/misc/phinx/migrations/20230406170000_group_log_null_userid.php +++ b/misc/phinx/migrations/20230406170000_group_log_null_userid.php @@ -6,15 +6,13 @@ use Phinx\Migration\AbstractMigration; final class GroupLogNullUserID extends AbstractMigration { - public function up(): void - { + public function up(): void { $this->table('group_log') ->changeColumn('UserID', 'integer', ['null' => true, 'default' => null]) ->save(); } - public function down(): void - { + public function down(): void { $this->table('group_log') ->changeColumn('UserID', 'integer', ['null' => false, 'default' => 0]) ->save(); diff --git a/misc/phinx/migrations/20230911000000_forum_category_int_id.php b/misc/phinx/migrations/20230911000000_forum_category_int_id.php index 94667d1d4..7caba3e37 100644 --- a/misc/phinx/migrations/20230911000000_forum_category_int_id.php +++ b/misc/phinx/migrations/20230911000000_forum_category_int_id.php @@ -17,8 +17,7 @@ final class ForumCategoryIntId extends AbstractMigration * Remember to call "create()" or "update()" and NOT "save()" when working * with the Table class. */ - public function change(): void - { + public function change(): void { // forums_categories } } diff --git a/misc/phinx/migrations/20231104000000_invite_pending_source_no_user.php b/misc/phinx/migrations/20231104000000_invite_pending_source_no_user.php index 2cac2d4e0..77462fa13 100644 --- a/misc/phinx/migrations/20231104000000_invite_pending_source_no_user.php +++ b/misc/phinx/migrations/20231104000000_invite_pending_source_no_user.php @@ -5,16 +5,14 @@ declare(strict_types=1); use Phinx\Migration\AbstractMigration; final class InvitePendingSourceNoUser extends AbstractMigration { - public function up(): void - { + public function up(): void { $this->table('invite_source_pending') ->dropForeignKey('user_id') ->removeColumn('user_id') ->save(); } - public function down(): void - { + public function down(): void { $this->table('invite_source_pending') ->addColumn('user_id', 'integer') ->addForeignKey('user_id', 'users_main', 'ID', ['delete' => 'CASCADE', 'update' => 'CASCADE']) diff --git a/misc/phinx/migrations/20240904000000_table_collation_0900.php b/misc/phinx/migrations/20240904000000_table_collation_0900.php index a2af6adbf..46425cb5c 100644 --- a/misc/phinx/migrations/20240904000000_table_collation_0900.php +++ b/misc/phinx/migrations/20240904000000_table_collation_0900.php @@ -26,7 +26,10 @@ where table_schema = 'gazelle' * with different collations. */ -function tableList(): array { /** @phpstan-ignore-line */ +/** + * @return non-empty-array + */ +function tableList(): array { return [ 'applicant_role_has_user' => 'utf8mb3_general_ci', 'better_transcode_music' => 'utf8mb3_general_ci', @@ -182,7 +185,10 @@ function tableList(): array { /** @phpstan-ignore-line */ ]; } -function colCharset(): array { /** @phpstan-ignore-line */ +/** + * @return non-empty-array + */ +function colCharset(): array { return [ 'api_applications' => [ ['Token char(32)', 'NOT NULL', 'utf8mb4', 'utf8mb4_unicode_ci'], @@ -879,7 +885,7 @@ final class TableCollation0900 extends AbstractMigration { "); } - public function down(): void{ + public function down(): void { foreach (tableList() as $tableName => $collate) { $this->query(" ALTER TABLE $tableName COLLATE $collate diff --git a/misc/phinx/seeds/BonusDiscount.php b/misc/phinx/seeds/BonusDiscount.php index f0480eb8f..757f5c5b1 100644 --- a/misc/phinx/seeds/BonusDiscount.php +++ b/misc/phinx/seeds/BonusDiscount.php @@ -4,8 +4,7 @@ use Phinx\Seed\AbstractSeed; class BonusDiscount extends AbstractSeed { - public function run(): void - { + public function run(): void { $this->table('site_options')->insert([ 'Name' => 'bonus-discount', 'Value' => 0, diff --git a/misc/phinx/seeds/InviteSource.php b/misc/phinx/seeds/InviteSource.php index 3c9bac375..7fdd4f7d6 100644 --- a/misc/phinx/seeds/InviteSource.php +++ b/misc/phinx/seeds/InviteSource.php @@ -4,8 +4,7 @@ use Phinx\Seed\AbstractSeed; class InviteSource extends AbstractSeed { - public function run(): void - { + public function run(): void { $this->table('invite_source')->insert(['name' => 'Personal'])->save(); } } diff --git a/misc/phinx/seeds/UserAttrHideVote.php b/misc/phinx/seeds/UserAttrHideVote.php index 3c22b43cf..be436ad73 100644 --- a/misc/phinx/seeds/UserAttrHideVote.php +++ b/misc/phinx/seeds/UserAttrHideVote.php @@ -4,8 +4,7 @@ use Phinx\Seed\AbstractSeed; class UserAttrHideVote extends AbstractSeed { - public function run(): void - { + public function run(): void { foreach ( [ ['hide-vote-recent', 'Do not show recent votes on profile page'], diff --git a/misc/phpunit-autoload.php b/misc/phpunit-autoload.php index b99e4f571..037b0cee2 100644 --- a/misc/phpunit-autoload.php +++ b/misc/phpunit-autoload.php @@ -1,7 +1,7 @@ [ diff --git a/public/api.php b/public/api.php index 608a5a6ff..bf4f33cef 100644 --- a/public/api.php +++ b/public/api.php @@ -16,5 +16,5 @@ header('Expires: ' . date('D, d M Y H:i:s', time() + (2 * 60 * 60)) . ' GMT'); header('Last-Modified: ' . date('D, d M Y H:i:s') . ' GMT'); header('Content-type: application/json'); -require_once(__DIR__ . '/../lib/bootstrap.php'); -require_once(__DIR__ . '/../sections/api/index.php'); +require_once __DIR__ . '/../lib/bootstrap.php'; +require_once __DIR__ . '/../sections/api/index.php'; diff --git a/public/feeds.php b/public/feeds.php index 8fd8ec773..a270f6f71 100644 --- a/public/feeds.php +++ b/public/feeds.php @@ -5,7 +5,7 @@ if (isset($_GET['clearcache'])) { unset($_GET['clearcache']); } -require_once(__DIR__ . '/../lib/bootstrap.php'); +require_once __DIR__ . '/../lib/bootstrap.php'; $user = (new Gazelle\Manager\User())->findById((int)($_GET['user'] ?? 0)); if (is_null($user)) { diff --git a/public/index.php b/public/index.php index a9dacdc80..5a4b52589 100644 --- a/public/index.php +++ b/public/index.php @@ -1,3 +1,3 @@ require_once('transcode.php'), - 'single' => require_once('single.php'), + 'transcode' => include_once 'transcode.php', + 'single' => include_once 'single.php', default => json_error('bad method'), }; diff --git a/sections/ajax/bookmarks/index.php b/sections/ajax/bookmarks/index.php index 7f698d506..5f209587b 100644 --- a/sections/ajax/bookmarks/index.php +++ b/sections/ajax/bookmarks/index.php @@ -2,17 +2,17 @@ switch ($_REQUEST['type'] ?? '') { case 'artists': - require_once(__DIR__ . '/artists.php'); + include_once __DIR__ . '/artists.php'; break; case 'collages': $_GET['bookmarks'] = 1; - require_once(__DIR__ . '/browse.php'); + include_once __DIR__ . '/browse.php'; break; case 'requests': $_GET['type'] = 'bookmarks'; - require_once(__DIR__ . '/requests.php'); + include_once __DIR__ . '/requests.php'; break; default: - require_once(__DIR__ . '/torrents.php'); + include_once __DIR__ . '/torrents.php'; break; } diff --git a/sections/ajax/forum/index.php b/sections/ajax/forum/index.php index 7c35ae826..ea6e39ce1 100644 --- a/sections/ajax/forum/index.php +++ b/sections/ajax/forum/index.php @@ -6,8 +6,8 @@ if ($Viewer->disableForums()) { } match ($_GET['type'] ?? 'main') { - 'main' => require_once('main.php'), - 'viewforum' => require_once('forum.php'), - 'viewthread' => require_once('thread.php'), + 'main' => include_once 'main.php', + 'viewforum' => include_once 'forum.php', + 'viewthread' => include_once 'thread.php', default => json_error('type'), }; diff --git a/sections/ajax/inbox/index.php b/sections/ajax/inbox/index.php index fb4f77538..b39f6b1e3 100644 --- a/sections/ajax/inbox/index.php +++ b/sections/ajax/inbox/index.php @@ -1,6 +1,6 @@ 'viewconv.php', default => 'inbox.php', -}); +}; diff --git a/sections/ajax/index.php b/sections/ajax/index.php index bd1d985ab..1ab05e16c 100644 --- a/sections/ajax/index.php +++ b/sections/ajax/index.php @@ -94,166 +94,166 @@ switch ($Action) { // things (that may be) used on the site case 'upload_section': // Gets one of the upload forms - require_once('upload.php'); + include_once 'upload.php'; break; case 'preview': - require_once('preview.php'); + include_once 'preview.php'; break; case 'torrent_info': - require_once('torrent_info.php'); + include_once 'torrent_info.php'; break; case 'add_tag': - require_once('torrent_tag_add.php'); + include_once 'torrent_tag_add.php'; break; case 'delete_tag': - require_once('torrent_tag_remove.php'); + include_once 'torrent_tag_remove.php'; break; case 'stats': - require_once('stats.php'); + include_once 'stats.php'; break; case 'checkprivate': - include('checkprivate.php'); + include 'checkprivate.php'; break; // things not yet used on the site case 'torrent': - require_once('torrent.php'); + include_once 'torrent.php'; break; case 'torrentgroup': - require_once('torrentgroup.php'); + include_once 'torrentgroup.php'; break; case 'torrentgroupalbumart': // so the album art script can function without breaking the ratelimit - require_once('torrentgroupalbumart.php'); + include_once 'torrentgroupalbumart.php'; break; case 'torrent_remove_cover_art': - require_once('torrent_remove_cover_art.php'); + include_once 'torrent_remove_cover_art.php'; break; case 'tcomments': - require_once('tcomments.php'); + include_once 'tcomments.php'; break; case 'user': - require_once('user.php'); + include_once 'user.php'; break; case 'forum': - require_once('forum/index.php'); + include_once 'forum/index.php'; break; case 'post_edit': - require_once('post_edit.php'); + include_once 'post_edit.php'; break; case 'top10': - require_once('top10/index.php'); + include_once 'top10/index.php'; break; case 'browse': - require_once('browse.php'); + include_once 'browse.php'; break; case 'usersearch': - require_once('usersearch.php'); + include_once 'usersearch.php'; break; case 'requests': - require_once('requests.php'); + include_once 'requests.php'; break; case 'artist': - require_once('artist.php'); + include_once 'artist.php'; break; case 'add_similar': - require_once(__DIR__ . '/../artist/add_similar.php'); + include_once __DIR__ . '/../artist/add_similar.php'; break; case 'inbox': - require_once('inbox/index.php'); + include_once 'inbox/index.php'; break; case 'subscriptions': - require_once('subscriptions.php'); + include_once 'subscriptions.php'; break; case 'index': - require_once('info.php'); + include_once 'info.php'; break; case 'bookmarks': - require_once('bookmarks/index.php'); + include_once 'bookmarks/index.php'; break; case 'announcements': - require_once('announcements.php'); + include_once 'announcements.php'; break; case 'request': - require_once('request.php'); + include_once 'request.php'; break; case 'loadavg': - require_once('loadavg.php'); + include_once 'loadavg.php'; break; case 'better': - require_once('better/index.php'); + include_once 'better/index.php'; break; case 'password_validate': - require_once('password_validate.php'); + include_once 'password_validate.php'; break; case 'similar_artists': - require_once('similar_artists.php'); + include_once 'similar_artists.php'; break; case 'userhistory': match ($_GET['type'] ?? '') { - 'posts' => require_once('userhistory/post_history.php'), + 'posts' => include_once 'userhistory/post_history.php', default => json_error('bad type'), }; break; case 'votefavorite': - require_once('vote_handle.php'); + include_once 'vote_handle.php'; break; case 'wiki': - require_once('wiki.php'); + include_once 'wiki.php'; break; case 'get_friends': echo json_encode((new Gazelle\User\Friend($Viewer))->userList()); break; case 'news_ajax': - require_once('news_ajax.php'); + include_once 'news_ajax.php'; break; case 'user_recents': - require_once('user_recents.php'); + include_once 'user_recents.php'; break; case 'collage': - require_once('collage.php'); + include_once 'collage.php'; break; case 'raw_bbcode': - require_once('raw_bbcode.php'); + include_once 'raw_bbcode.php'; break; case 'notifications': - require_once('notifications.php'); + include_once 'notifications.php'; break; case 'get_user_notifications': - require_once('get_user_notifications.php'); + include_once 'get_user_notifications.php'; break; case 'clear_user_notification': - require_once('clear_user_notification.php'); + include_once 'clear_user_notification.php'; break; case 'pushbullet_devices': - require_once('pushbullet_devices.php'); + include_once 'pushbullet_devices.php'; break; case 'loggy': - require_once('loggy.php'); + include_once 'loggy.php'; break; case 'user_stats': - require_once('stats/users.php'); + include_once 'stats/users.php'; break; case 'torrent_stats': - require_once('stats/torrents.php'); + include_once 'stats/torrents.php'; break; case 'logchecker': - require_once('logchecker.php'); + include_once 'logchecker.php'; break; case 'riplog': - require_once('riplog.php'); + include_once 'riplog.php'; break; case 'upload': - require_once(__DIR__ . '/../upload/upload_handle.php'); + include_once __DIR__ . '/../upload/upload_handle.php'; break; case 'download': - require_once(__DIR__ . '/../torrents/download.php'); + include_once __DIR__ . '/../torrents/download.php'; break; case 'request_fill': - json_print('success', require_once(__DIR__ . '/../requests/take_fill.php')); + json_print('success', include_once __DIR__ . '/../requests/take_fill.php'); break; case 'add_log': - require_once(__DIR__ . '/add_log.php'); + include_once __DIR__ . '/add_log.php'; break; default: // If they're screwing around with the query string diff --git a/sections/ajax/top10/index.php b/sections/ajax/top10/index.php index cb9aeccc6..01cbd3f14 100644 --- a/sections/ajax/top10/index.php +++ b/sections/ajax/top10/index.php @@ -6,9 +6,9 @@ if (!$Viewer->permitted('site_top10')) { } match ($_GET['type'] ?? 'torrents') { - 'history' => require_once('history.php'), - 'tags' => require_once('tags.php'), - 'torrents' => require_once('torrents.php'), - 'users' => require_once('users.php'), + 'history' => include_once 'history.php', + 'tags' => include_once 'tags.php', + 'torrents' => include_once 'torrents.php', + 'users' => include_once 'users.php', default => json_error('bad type'), }; diff --git a/sections/ajax/userhistory/index.php b/sections/ajax/userhistory/index.php index 1653d546d..65b1e2cfc 100644 --- a/sections/ajax/userhistory/index.php +++ b/sections/ajax/userhistory/index.php @@ -1,6 +1,6 @@ require_once('post_history.php'), + 'posts' => include_once 'post_history.php', default => json_error('bad type'), }; diff --git a/sections/apply/index.php b/sections/apply/index.php index 4cf42859f..5c05436ed 100644 --- a/sections/apply/index.php +++ b/sections/apply/index.php @@ -1,8 +1,8 @@ 'admin.php', 'edit' => 'edit.php', 'view' => 'view.php', default => 'apply.php', -}); +}; diff --git a/sections/artist/index.php b/sections/artist/index.php index f3b4c5800..42d6b5848 100644 --- a/sections/artist/index.php +++ b/sections/artist/index.php @@ -3,34 +3,34 @@ if (!empty($_POST['action'])) { match ($_POST['action']) { - 'add_similar' => require_once('add_similar.php'), - 'add_alias' => require_once('add_alias.php'), - 'change_artistid' => require_once('change_artistid.php'), - 'download' => require_once('download.php'), - 'rename' => require_once('rename.php'), - 'edit' => require_once('edit_handle.php'), - 'takeeditrequest' => require_once('edit_request_handle.php'), + 'add_similar' => include_once 'add_similar.php', + 'add_alias' => include_once 'add_alias.php', + 'change_artistid' => include_once 'change_artistid.php', + 'download' => include_once 'download.php', + 'rename' => include_once 'rename.php', + 'edit' => include_once 'edit_handle.php', + 'takeeditrequest' => include_once 'edit_request_handle.php', default => error('Missing artist POST action'), }; } elseif (!empty($_GET['action'])) { match ($_GET['action']) { - 'autocomplete' => require_once('autocomplete.php'), - 'change_artistid' => require_once('change_artistid.php'), - 'delete' => require_once('delete.php'), - 'delete_alias' => require_once('delete_alias.php'), - 'delete_similar' => require_once('delete_similar.php'), - 'edit' => require_once('edit.php'), - 'editrequest' => require_once('edit_request.php'), - 'history' => require_once('history.php'), - 'notify' => require_once('notify.php'), - 'notifyremove' => require_once('notify_remove.php'), - 'revert' => require_once('edit_handle.php'), - 'vote_similar' => require_once('vote_similar.php'), + 'autocomplete' => include_once 'autocomplete.php', + 'change_artistid' => include_once 'change_artistid.php', + 'delete' => include_once 'delete.php', + 'delete_alias' => include_once 'delete_alias.php', + 'delete_similar' => include_once 'delete_similar.php', + 'edit' => include_once 'edit.php', + 'editrequest' => include_once 'edit_request.php', + 'history' => include_once 'history.php', + 'notify' => include_once 'notify.php', + 'notifyremove' => include_once 'notify_remove.php', + 'revert' => include_once 'edit_handle.php', + 'vote_similar' => include_once 'vote_similar.php', default => error('Missing artist action'), }; } else { if (!empty($_GET['id'])) { - require_once('artist.php'); + include_once 'artist.php'; } elseif (empty($_GET['artistname'])) { header('Location: torrents.php'); } else { diff --git a/sections/better/index.php b/sections/better/index.php index f35f7852a..b55a840b7 100644 --- a/sections/better/index.php +++ b/sections/better/index.php @@ -1,6 +1,6 @@ 'transcode.php', default => 'better.php', -}); +}; diff --git a/sections/blog/index.php b/sections/blog/index.php index 766fe134d..e56f4884f 100644 --- a/sections/blog/index.php +++ b/sections/blog/index.php @@ -1,9 +1,9 @@ 'dead_thread.php', 'deleteblog' => 'delete_blog.php', 'takeeditblog' => 'edit_blog_handle.php', 'takenewblog' => 'new_blog_handle.php', default => 'blog_page.php', -}); +}; diff --git a/sections/bonus/bprates.php b/sections/bonus/bprates.php index 5a200b771..fe6a77f3e 100644 --- a/sections/bonus/bprates.php +++ b/sections/bonus/bprates.php @@ -2,9 +2,8 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ -$page = !empty($_GET['page']) ? (int) $_GET['page'] : 1; -$page = max(1, $page); -$limit = TORRENTS_PER_PAGE; +$page = max(1, (int)($_GET['page'] ?? 1)); +$limit = TORRENTS_PER_PAGE; $offset = TORRENTS_PER_PAGE * ($page - 1); $heading = new \Gazelle\Util\SortableTableHeader('hourlypoints', [ diff --git a/sections/bonus/index.php b/sections/bonus/index.php index a40fe107f..286aeda82 100644 --- a/sections/bonus/index.php +++ b/sections/bonus/index.php @@ -15,31 +15,31 @@ switch ($_GET['action'] ?? '') { $Label = $_REQUEST['label']; $Item = $viewerBonus->item($Label); if (!$Item) { - require_once(DEFAULT_PAGE); + include_once DEFAULT_PAGE; break; } $Price = $viewerBonus->effectivePrice($Label); if ($Price > $Viewer->bonusPointsTotal()) { error('You cannot afford this item.'); } - require_once(match ($Label) { + include_once match ($Label) { 'invite' => 'invite.php', 'collage-1', 'seedbox', 'file-count' => 'purchase.php', 'title-bb-y', 'title-bb-n', 'title-off' => 'title.php', 'token-1', 'token-2', 'token-3', 'token-4' => 'tokens.php', 'other-1', 'other-2', 'other-3', 'other-4' => 'token_other.php', default => DEFAULT_PAGE, - }); + }; } break; case 'bprates': - require_once('bprates.php'); + include_once 'bprates.php'; break; case 'title': - require_once('title.php'); + include_once 'title.php'; break; case 'history': - require_once('history.php'); + include_once 'history.php'; break; case 'cacheflush': (new \Gazelle\Manager\Bonus())->flushPriceCache(); @@ -47,6 +47,6 @@ switch ($_GET['action'] ?? '') { exit; case 'donate': default: - require_once(DEFAULT_PAGE); + include_once DEFAULT_PAGE; break; } diff --git a/sections/bookmarks/index.php b/sections/bookmarks/index.php index 4a8e1bb6f..7a5df0a2f 100644 --- a/sections/bookmarks/index.php +++ b/sections/bookmarks/index.php @@ -2,24 +2,24 @@ switch ($_REQUEST['action'] ?? 'view') { case 'add': - require_once('add.php'); + include_once 'add.php'; break; case 'remove': - require_once('remove.php'); + include_once 'remove.php'; break; case 'mass_edit': - require_once('mass_edit.php'); + include_once 'mass_edit.php'; break; case 'remove_snatched': - require_once('remove_snatched.php'); + include_once 'remove_snatched.php'; break; case 'edit': match ($_REQUEST['type'] ?? '') { - 'torrents' => require_once('edit_torrents.php'), + 'torrents' => include_once 'edit_torrents.php', default => error(404), }; break; @@ -27,18 +27,18 @@ switch ($_REQUEST['action'] ?? 'view') { case 'view': switch ($_REQUEST['type'] ?? 'torrents') { case 'torrents': - require_once('torrents.php'); + include_once 'torrents.php'; break; case 'artists': - require_once('artists.php'); + include_once 'artists.php'; break; case 'collages': $_GET['bookmarks'] = '1'; - require_once(__DIR__ . '/../collages/browse.php'); + include_once __DIR__ . '/../collages/browse.php'; break; case 'requests': $_GET['type'] = 'bookmarks'; - require_once(__DIR__ . '/../requests/requests.php'); + include_once __DIR__ . '/../requests/requests.php'; break; default: error(404); diff --git a/sections/chat/index.php b/sections/chat/index.php index 175089af1..5a8e876d1 100644 --- a/sections/chat/index.php +++ b/sections/chat/index.php @@ -2,11 +2,11 @@ /** @phpstan-var ?\Gazelle\User $Viewer */ if (!$Viewer || $Viewer->isLocked()) { - require_once('webirc_disabled.php'); + include_once 'webirc_disabled.php'; exit; } -require_once(match ($_REQUEST['action'] ?? '') { +require_once match ($_REQUEST['action'] ?? '') { 'webirc' => 'webirc.php', default => 'join.php', -}); +}; diff --git a/sections/collages/collage.php b/sections/collages/collage.php index 5a006e721..b96d56afa 100644 --- a/sections/collages/collage.php +++ b/sections/collages/collage.php @@ -11,6 +11,6 @@ if ($Collage->isDeleted()) { exit; } -require_once($Collage->isArtist() ? 'collage_artists.php' : 'collage_torrent.php'); +require_once $Collage->isArtist() ? 'collage_artists.php' : 'collage_torrent.php'; View::show_footer(); diff --git a/sections/collages/edit_handle.php b/sections/collages/edit_handle.php index 99641b466..07bb457c4 100644 --- a/sections/collages/edit_handle.php +++ b/sections/collages/edit_handle.php @@ -34,7 +34,7 @@ if (isset($_POST['name'])) { $Err = "A collage with that name already exists: {$check->link()}."; } $ErrNoEscape = true; - require('edit.php'); + include 'edit.php'; exit; } if ($collage->isOwner($Viewer)) { diff --git a/sections/collages/index.php b/sections/collages/index.php index 4ee38459c..4ec4d28aa 100644 --- a/sections/collages/index.php +++ b/sections/collages/index.php @@ -1,6 +1,6 @@ 'add_torrent.php', 'add_artist', @@ -21,4 +21,4 @@ require_once(match ($_REQUEST['action'] ?? '') { 'new_handle' => 'new_handle.php', 'recover' => 'recover.php', default => empty($_GET['id']) ? 'browse.php' : 'collage.php', -}); +}; diff --git a/sections/collages/new_handle.php b/sections/collages/new_handle.php index abf554676..89c111f3e 100644 --- a/sections/collages/new_handle.php +++ b/sections/collages/new_handle.php @@ -54,7 +54,7 @@ if ($Err) { $Category = $categoryId; $Tags = $_POST['tags']; $Description = $_POST['description']; - require('new.php'); + include 'new.php'; exit; } diff --git a/sections/comments/index.php b/sections/comments/index.php index d402628bc..c6cc74686 100644 --- a/sections/comments/index.php +++ b/sections/comments/index.php @@ -1,6 +1,6 @@ 'get.php', 'jump' => 'jump.php', 'take_delete' => 'delete_handle.php', @@ -9,4 +9,4 @@ require_once(match ($_REQUEST['action'] ?? null) { 'take_warn' => 'warn_handle.php', 'warn' => 'warn.php', default => 'comments.php', -}); +}; diff --git a/sections/comments/warn_handle.php b/sections/comments/warn_handle.php index 5f68b343d..e70b967c8 100644 --- a/sections/comments/warn_handle.php +++ b/sections/comments/warn_handle.php @@ -1,7 +1,7 @@ setField('Body', $body) diff --git a/sections/contest/index.php b/sections/contest/index.php index 17eed74c7..5c02cd82c 100644 --- a/sections/contest/index.php +++ b/sections/contest/index.php @@ -6,11 +6,11 @@ $contestMan = new Gazelle\Manager\Contest(); switch ($_GET['action'] ?? '') { case 'leaderboard': - require('leaderboard.php'); + include 'leaderboard.php'; break; case 'admin': case 'create': - require('admin.php'); + include 'admin.php'; break; default: echo $Twig->render('contest/intro.twig', [ diff --git a/sections/forums/index.php b/sections/forums/index.php index a06c70b34..c9fa90e45 100644 --- a/sections/forums/index.php +++ b/sections/forums/index.php @@ -5,7 +5,7 @@ if ($Viewer->disableForums()) { error(403); } -require_once(match ($_REQUEST['action'] ?? '') { +require_once match ($_REQUEST['action'] ?? '') { 'add_poll_option' => 'add_poll_option.php', 'autosub' => 'autosub.php', 'catchup' => 'catchup.php', @@ -28,4 +28,4 @@ require_once(match ($_REQUEST['action'] ?? '') { 'viewtopic' => 'thread.php', 'warn' => 'warn.php', default => 'main.php', -}); +}; diff --git a/sections/forums/warn_handle.php b/sections/forums/warn_handle.php index 7da5cb108..bf2b4ac5e 100644 --- a/sections/forums/warn_handle.php +++ b/sections/forums/warn_handle.php @@ -1,7 +1,7 @@ edit($Viewer, $body); if ($post->isPinned()) { diff --git a/sections/friends/index.php b/sections/friends/index.php index 0f55bbe8a..de04fed74 100644 --- a/sections/friends/index.php +++ b/sections/friends/index.php @@ -1,8 +1,8 @@ 'add.php', 'Save notes' => 'comment.php', 'Unfriend' => 'remove.php', default => 'friends.php', -}); +}; diff --git a/sections/inbox/index.php b/sections/inbox/index.php index 234d4db51..3959b8a37 100644 --- a/sections/inbox/index.php +++ b/sections/inbox/index.php @@ -1,6 +1,6 @@ 'compose.php', 'forward' => 'forward.php', 'get_post' => 'get_post.php', @@ -9,4 +9,4 @@ require_once(match ($_REQUEST['action'] ?? '') { 'takeedit' => 'edit_handle.php', 'viewconv' => 'conversation.php', default => 'inbox.php', -}); +}; diff --git a/sections/index/index.php b/sections/index/index.php index 7bdea34a7..033db062b 100644 --- a/sections/index/index.php +++ b/sections/index/index.php @@ -2,13 +2,13 @@ /** @phpstan-var ?\Gazelle\User $Viewer */ if (!isset($Viewer)) { - require('public.php'); + include 'public.php'; } else { if (!isset($_REQUEST['action'])) { - require('private.php'); + include 'private.php'; } else { match ($_REQUEST['action']) { - 'poll' => require(__DIR__ . '/../forums/poll_vote.php'), + 'poll' => include __DIR__ . '/../forums/poll_vote.php', default => error('Unknown action requested'), }; } diff --git a/sections/logchecker/index.php b/sections/logchecker/index.php index 9c0f1920e..7cf13ef9f 100644 --- a/sections/logchecker/index.php +++ b/sections/logchecker/index.php @@ -1,9 +1,9 @@ 'update.php', 'upload' => 'upload.php', 'take_upload' => 'upload_handle.php', 'take_test' => 'test_handle.php', default => 'test.php', -}); +}; diff --git a/sections/login/index.php b/sections/login/index.php index 7904d250b..150b1ea52 100644 --- a/sections/login/index.php +++ b/sections/login/index.php @@ -1,7 +1,7 @@ 'disabled.php', 'recover' => isset($_REQUEST['key']) ? 'recover_step2.php' : 'recover_step1.php', default => 'login.php', -}); +}; diff --git a/sections/recovery/index.php b/sections/recovery/index.php index 509519bd9..065b1d115 100644 --- a/sections/recovery/index.php +++ b/sections/recovery/index.php @@ -1,10 +1,10 @@ 'admin.php', 'browse' => 'browse.php', 'pair' => 'pair.php', 'save' => RECOVERY ? 'save.php' : 'recover.php', 'search', 'view' => 'view.php', default => 'recover.php', -}); +}; diff --git a/sections/report_auto/index.php b/sections/report_auto/index.php index 400cdb44f..caec96a24 100644 --- a/sections/report_auto/index.php +++ b/sections/report_auto/index.php @@ -1,7 +1,7 @@ 'ajax_add_notes.php', 'claim' => 'ajax_claim_report.php', 'compose' => 'compose.php', @@ -12,4 +12,4 @@ require_once(match ($_REQUEST['action'] ?? '') { 'takeresolve' => 'resolve_handle.php', 'unclaim' => 'ajax_unclaim_report.php', default => 'reports.php', -}); +}; diff --git a/sections/reports/report.php b/sections/reports/report.php index ef8a92940..75f680418 100644 --- a/sections/reports/report.php +++ b/sections/reports/report.php @@ -7,7 +7,7 @@ if (!$id) { error(404); } -require_once('array.php'); +require_once 'array.php'; if (!isset($Types[$_GET['type'] ?? ''])) { error(403); } diff --git a/sections/reports/report_handle.php b/sections/reports/report_handle.php index 3f2657b53..468d9bf65 100644 --- a/sections/reports/report_handle.php +++ b/sections/reports/report_handle.php @@ -10,7 +10,7 @@ if (!$subjectId || empty($_POST['type']) || ($_POST['type'] !== 'request_update' error(404); } -require_once('array.php'); +require_once 'array.php'; /** @var array $Types */ if (!array_key_exists($_POST['type'], $Types)) { error(403); diff --git a/sections/reports/reports.php b/sections/reports/reports.php index 3ab218aca..42a4fa144 100644 --- a/sections/reports/reports.php +++ b/sections/reports/reports.php @@ -8,7 +8,7 @@ if (!$Viewer->permittedAny('admin_reports', 'site_moderate_forums')) { error(403); } -require_once('array.php'); +require_once 'array.php'; $search = new Gazelle\Search\Report(); $paginator = new Gazelle\Util\Paginator(REPORTS_PER_PAGE, (int)($_REQUEST['page'] ?? 1)); diff --git a/sections/reportsv2/index.php b/sections/reportsv2/index.php index 4467a63c9..7317b6cbf 100644 --- a/sections/reportsv2/index.php +++ b/sections/reportsv2/index.php @@ -1,6 +1,6 @@ 'ajax_claim.php', 'ajax_get_resolve_options' => 'ajax_get_resolve_options.php', 'ajax_new_report' => 'ajax_new_report.php', @@ -16,4 +16,4 @@ require_once(match ($_REQUEST['action'] ?? '') { 'takereport' => 'report_handle.php', 'takeresolve' => 'resolve_handle.php', default => isset($_GET['view']) ? 'static.php' : 'views.php', -}); +}; diff --git a/sections/reportsv2/static.php b/sections/reportsv2/static.php index 539e374f3..fe3d86d0b 100644 --- a/sections/reportsv2/static.php +++ b/sections/reportsv2/static.php @@ -37,7 +37,7 @@ View::show_header('Torrent Reports', ['js' => 'reportsv2,bbcode,browse,torrent'] ?>

title() ?>

- +
mode() !== 'resolved') { ?> @@ -101,13 +101,13 @@ if ($search->canUnclaim($Viewer)) { Relevant other torrents: otherIdList() as $extraId) { - $extra = $torMan->findById($extraId)?->setViewer($Viewer); - if ($extra) { + $n = 0; + foreach ($report->otherIdList() as $extraId) { + $extra = $torMan->findById($extraId)?->setViewer($Viewer); + if ($extra) { ?> - ' ?> - group()->link() ?> shortLabelLink() ?> (size()) ?>) + ' ?> + group()->link() ?> shortLabelLink() ?> (size()) ?>)
edition() ?>
DL Downloaders @@ -135,13 +135,13 @@ if ($search->canUnclaim($Viewer)) {

uploaded by uploader()->link() ?> on created() ?> (created()) < strtotime($torrent?->created() ?? '2000-01-01 00:00:00') ? 'older upload' : 'more recent upload' ?>) + time_diff($extra->created(), 3, false) ?>">created() ?> (created()) < strtotime($torrent?->created() ?? '2000-01-01 00:00:00') ? 'older upload' : 'more recent upload' ?>)
Last action: lastActiveDate() ?: 'Never' ?>
Audio files present: fileListPrimaryMap(); - if (count($extMap) == 0) { + $extMap = $extra->fileListPrimaryMap(); + if (count($extMap) == 0) { ?> none @@ -162,32 +162,32 @@ if ($search->canUnclaim($Viewer)) { logDetails(); -?> + ?>
    - +
  • No logs
  • $info) { - if ($info['adjustment']) { - $adj = $info['adjustment']; - $adjUser = $userMan->findById($adj['userId']); -?> + foreach ($details as $logId => $info) { + if ($info['adjustment']) { + $adj = $info['adjustment']; + $adjUser = $userMan->findById($adj['userId']); + ?>
  • Log adjusted link()}" : '' ?> from score to
  • - + ?> to +
  • - +
  • Logfile #: Show @@ -196,36 +196,36 @@ if ($search->canUnclaim($Viewer)) { HTML logfile #: Show
  • - + ?>
-logDetails(); -?> + ?>
    - +
  • No logs
  • $info) { - if ($info['adjustment']) { - $adj = $info['adjustment']; - $adjUser = $userMan->findById($adj['userId']); -?> + foreach ($details as $logId => $info) { + if ($info['adjustment']) { + $adj = $info['adjustment']; + $adjUser = $userMan->findById($adj['userId']); + ?>
  • Log adjusted link()}" : '' ?> from score to
  • - + ?> to +
  • @@ -236,22 +236,22 @@ if ($search->canUnclaim($Viewer)) { HTML logfile #: Show
  • - + ?>
- + Switch: Switch the source and target torrents (you become the report owner). @@ -263,7 +263,7 @@ if ($search->canUnclaim($Viewer)) { Relevant images: image() as $image) { + foreach ($report->image() as $image) { ?> Relevant image @@ -306,7 +306,7 @@ if ($search->canUnclaim($Viewer)) { categoryList((int)$torrent?->group()?->categoryId()) as $rt) { $selected = $rt->type() === $report->type() ? ' selected' : ''; ?> - + | @@ -314,14 +314,14 @@ if ($search->canUnclaim($Viewer)) { | permitted('users_mod')) { ?> doDeleteUpload() ? ' checked' : '' ?> />  | - + doRevokeUploadPrivs() ? ' checked' : '' ?> />  | @@ -363,9 +363,9 @@ if ($search->canUnclaim($Viewer)) { | status() == 'InProgress' && $Viewer->id() == $resolverId) { ?> | - + | - + |   diff --git a/sections/requests/edit.php b/sections/requests/edit.php index 496e23917..0998a480f 100644 --- a/sections/requests/edit.php +++ b/sections/requests/edit.php @@ -11,8 +11,9 @@ if (!$request->canEdit($Viewer)) { } $requestId = $request->id(); $ownRequest = $request->userId() == $Viewer->id(); - +// phpcs:disable Generic.CodeAnalysis.EmptyStatement.DetectedIf if (isset($returnEdit)) { +// phpcs:enable Generic.CodeAnalysis.EmptyStatement.DetectedIf // if we are coming back from an edit, these were already initialized in take_new_edit /** @var string $categoryName */ /** @var array $artistRole */ diff --git a/sections/requests/edit_handle.php b/sections/requests/edit_handle.php index d4425e112..fa51a7b9d 100644 --- a/sections/requests/edit_handle.php +++ b/sections/requests/edit_handle.php @@ -210,7 +210,7 @@ while (true) { } if (!empty($error)) { - require_once('edit.php'); + include_once 'edit.php'; exit; } diff --git a/sections/requests/index.php b/sections/requests/index.php index d941a2265..c3311ad59 100644 --- a/sections/requests/index.php +++ b/sections/requests/index.php @@ -5,7 +5,7 @@ if ($Viewer->disableRequests()) { error('Your request privileges have been removed.'); } -require_once(match ($_REQUEST['action'] ?? null) { +require_once match ($_REQUEST['action'] ?? null) { 'delete', 'unfill' => 'interim.php', 'edit-bounty' => 'edit_bounty.php', 'edit' => 'edit.php', @@ -19,4 +19,4 @@ require_once(match ($_REQUEST['action'] ?? null) { 'takevote' => 'vote_handle.php', 'view', 'viewrequest' => 'request.php', default => 'requests.php', -}); +}; diff --git a/sections/requests/new_handle.php b/sections/requests/new_handle.php index bb74cf04d..24b6eca36 100644 --- a/sections/requests/new_handle.php +++ b/sections/requests/new_handle.php @@ -175,7 +175,7 @@ if (isset($error)) { if ($year == 0) { $year = null; } - require_once('new.php'); + include_once 'new.php'; exit; } diff --git a/sections/staffpm/index.php b/sections/staffpm/index.php index e9976f1ab..7deb56a85 100644 --- a/sections/staffpm/index.php +++ b/sections/staffpm/index.php @@ -3,45 +3,45 @@ switch ($_REQUEST['action'] ?? '') { case 'assign': - require('assign.php'); + include 'assign.php'; break; case 'viewconv': - require('viewconv.php'); + include 'viewconv.php'; break; case 'takepost': - require('viewconv_handle.php'); + include 'viewconv_handle.php'; break; case 'unresolve': - require('unresolve.php'); + include 'unresolve.php'; break; case 'multiresolve': - require('multiresolve.php'); + include 'multiresolve.php'; break; case 'responses': - require('common_responses.php'); + include 'common_responses.php'; break; case 'delete_response': - require('ajax_delete_response.php'); + include 'ajax_delete_response.php'; break; case 'edit_response': - require('ajax_edit_response.php'); + include 'ajax_edit_response.php'; break; case 'get_response': - require('ajax_get_response.php'); + include 'ajax_get_response.php'; break; case 'preview': echo Text::full_format($_POST['message'] ?? ''); break; case 'get_post': - require('get_post.php'); + include 'get_post.php'; break; case 'scoreboard': - require('scoreboard.php'); + include 'scoreboard.php'; break; case 'userinbox': - require('user_inbox.php'); + include 'user_inbox.php'; break; default: - require($Viewer->isStaffPMReader() ? 'staff_inbox.php' : 'user_inbox.php'); + include $Viewer->isStaffPMReader() ? 'staff_inbox.php' : 'user_inbox.php'; break; } diff --git a/sections/stats/index.php b/sections/stats/index.php index 77811e469..088b7edcb 100644 --- a/sections/stats/index.php +++ b/sections/stats/index.php @@ -3,10 +3,10 @@ switch ($_REQUEST['action'] ?? null) { case 'users': - require_once('users.php'); + include_once 'users.php'; break; case 'torrents': - require_once('torrents.php'); + include_once 'torrents.php'; break; default: echo $Twig->render('stats.twig'); diff --git a/sections/tools/development/periodic_alter.php b/sections/tools/development/periodic_alter.php index ce68fda95..39ec7e638 100644 --- a/sections/tools/development/periodic_alter.php +++ b/sections/tools/development/periodic_alter.php @@ -31,7 +31,7 @@ if ($p['submit'] == 'Delete') { } if ($err) { - require_once('periodic_edit.php'); + include_once 'periodic_edit.php'; exit; } diff --git a/sections/tools/development/referral_sandbox.php b/sections/tools/development/referral_sandbox.php index 42f8f0433..b9c68205a 100644 --- a/sections/tools/development/referral_sandbox.php +++ b/sections/tools/development/referral_sandbox.php @@ -79,7 +79,7 @@ div#preview {display: none;}
@@ -193,4 +193,4 @@ var_dump($response)
+ diff --git a/sections/tools/finances/payment_alter.php b/sections/tools/finances/payment_alter.php index 7e0bf3ee5..73037e200 100644 --- a/sections/tools/finances/payment_alter.php +++ b/sections/tools/finances/payment_alter.php @@ -22,7 +22,7 @@ if ($_POST['submit'] == 'Delete') { ]); if (!$Validator->validate($_POST)) { $Err = $Validator->errorMessage(); - require_once('payment_list.php'); + include_once 'payment_list.php'; exit; } diff --git a/sections/tools/index.php b/sections/tools/index.php index 27fe42fd4..b94977353 100644 --- a/sections/tools/index.php +++ b/sections/tools/index.php @@ -5,57 +5,57 @@ switch ($_REQUEST['action'] ?? '') { //Managers case 'asn_search': - require_once('managers/asn_search.php'); + include_once 'managers/asn_search.php'; break; case 'bonus_points': - require_once('managers/bonus_points.php'); + include_once 'managers/bonus_points.php'; break; case 'categories': - require_once('managers/categories_list.php'); + include_once 'managers/categories_list.php'; break; case 'categories_alter': - require_once('managers/categories_alter.php'); + include_once 'managers/categories_alter.php'; break; case 'change_log': - require_once('managers/change_log.php'); + include_once 'managers/change_log.php'; break; case 'create_user': - require_once('managers/create_user.php'); + include_once 'managers/create_user.php'; break; case 'custom_pm': - require_once('managers/custom_pm.php'); + include_once 'managers/custom_pm.php'; break; case 'dbkey': - require_once('managers/db_key.php'); + include_once 'managers/db_key.php'; break; case 'dnu': - require_once('managers/dnu_list.php'); + include_once 'managers/dnu_list.php'; break; case 'dnu_alter': - require_once('managers/dnu_alter.php'); + include_once 'managers/dnu_alter.php'; break; case 'dupe_ips': - require_once('managers/dupe_ip.php'); + include_once 'managers/dupe_ip.php'; break; case 'email_blacklist': - require_once('managers/email_blacklist.php'); + include_once 'managers/email_blacklist.php'; break; case 'email_blacklist_alter': - require_once('managers/email_blacklist_alter.php'); + include_once 'managers/email_blacklist_alter.php'; break; case 'email_search': - require_once('managers/email_search.php'); + include_once 'managers/email_search.php'; break; case 'enable_requests': - require_once('managers/enable_requests.php'); + include_once 'managers/enable_requests.php'; break; case 'ajax_take_enable_request': if (FEATURE_EMAIL_REENABLE) { - require_once('managers/ajax_take_enable_request.php'); + include_once 'managers/ajax_take_enable_request.php'; } else { // Prevent post requests to the ajax page header("Location: tools.php"); @@ -63,63 +63,63 @@ switch ($_REQUEST['action'] ?? '') { break; case 'featured_album': - require_once('managers/featured_album.php'); + include_once 'managers/featured_album.php'; break; case 'forum': - require_once('managers/forum_list.php'); + include_once 'managers/forum_list.php'; break; case 'forum_alter': - require_once('managers/forum_alter.php'); + include_once 'managers/forum_alter.php'; break; case 'forum_transitions': - require_once('managers/forum_transitions_list.php'); + include_once 'managers/forum_transitions_list.php'; break; case 'forum_transitions_alter': - require_once('managers/forum_transitions_alter.php'); + include_once 'managers/forum_transitions_alter.php'; break; case 'global_notification': - require_once('managers/global_notification.php'); + include_once 'managers/global_notification.php'; break; case 'invite_source': - require_once('managers/invite_source.php'); + include_once 'managers/invite_source.php'; break; case 'invite_source_config': - require_once('managers/invite_source_config.php'); + include_once 'managers/invite_source_config.php'; break; case 'ip_ban': - require_once('managers/bans.php'); + include_once 'managers/bans.php'; break; case 'ip_search': - require_once('managers/ip_search.php'); + include_once 'managers/ip_search.php'; break; case 'irc': - require_once('managers/irc_list.php'); + include_once 'managers/irc_list.php'; break; case 'irc_alter': - require_once('managers/irc_alter.php'); + include_once 'managers/irc_alter.php'; break; case 'login_watch': - require_once('managers/login_watch.php'); + include_once 'managers/login_watch.php'; break; case 'manipulate_tree': - require_once('managers/manipulate_tree.php'); + include_once 'managers/manipulate_tree.php'; break; case 'mass_pm': - require_once('managers/mass_pm.php'); + include_once 'managers/mass_pm.php'; break; case 'take_mass_pm': - require_once('managers/take_mass_pm.php'); + include_once 'managers/take_mass_pm.php'; break; case 'navigation_alter': - require_once('managers/navigation_alter.php'); + include_once 'managers/navigation_alter.php'; break; case 'navigation': - require_once('managers/navigation_list.php'); + include_once 'managers/navigation_list.php'; break; case 'news': @@ -127,159 +127,159 @@ switch ($_REQUEST['action'] ?? '') { case 'editnews': case 'takeeditnews': case 'takenewnews': - require_once('managers/news.php'); + include_once 'managers/news.php'; break; case 'ocelot': // this is the callback for ocelot - require_once('managers/ocelot.php'); + include_once 'managers/ocelot.php'; break; case 'ocelot_info': - require_once('managers/ocelot_info.php'); + include_once 'managers/ocelot_info.php'; break; case 'userclass': - require_once('managers/userclass_list.php'); + include_once 'managers/userclass_list.php'; break; case 'privilege-edit': - require_once('managers/userclass_edit.php'); + include_once 'managers/userclass_edit.php'; break; case 'privilege-alter': - require_once('managers/userclass_alter.php'); + include_once 'managers/userclass_alter.php'; break; case 'privilege_matrix': - require_once('managers/privilege_matrix.php'); + include_once 'managers/privilege_matrix.php'; break; case 'quick_ban': - require_once('managers/quick_ban.php'); + include_once 'managers/quick_ban.php'; break; case 'rate_limit': - require_once('managers/rate_limit.php'); + include_once 'managers/rate_limit.php'; break; case 'reaper': - require_once('managers/reaper.php'); + include_once 'managers/reaper.php'; break; case 'referral_accounts': - require_once('managers/referral_accounts.php'); + include_once 'managers/referral_accounts.php'; break; case 'referral_alter': - require_once('managers/referral_alter.php'); + include_once 'managers/referral_alter.php'; break; case 'referral_users': - require_once('managers/referral_users.php'); + include_once 'managers/referral_users.php'; break; case 'ssl_host': - require_once('managers/ssl_host.php'); + include_once 'managers/ssl_host.php'; break; case 'staff_groups_alter': - require_once('managers/staff_groups_alter.php'); + include_once 'managers/staff_groups_alter.php'; break; case 'staff_groups': - require_once('managers/staff_groups_list.php'); + include_once 'managers/staff_groups_list.php'; break; case 'stylesheets': - require_once('managers/stylesheets_list.php'); + include_once 'managers/stylesheets_list.php'; break; case 'tags': - require_once('managers/tags.php'); + include_once 'managers/tags.php'; break; case 'tags_aliases': - require_once('managers/tags_aliases.php'); + include_once 'managers/tags_aliases.php'; break; case 'tags_official': - require_once('managers/tags_official.php'); + include_once 'managers/tags_official.php'; break; case 'tokens': - require_once('managers/tokens.php'); + include_once 'managers/tokens.php'; break; case 'tor_node': - require_once('managers/tor_node.php'); + include_once 'managers/tor_node.php'; break; case 'torrent_report_edit': - require_once('managers/torrent_report_edit.php'); + include_once 'managers/torrent_report_edit.php'; break; case 'torrent_report_view': - require_once('managers/torrent_report_view.php'); + include_once 'managers/torrent_report_view.php'; break; case 'whitelist': - require_once('managers/whitelist_list.php'); + include_once 'managers/whitelist_list.php'; break; case 'whitelist_alter': - require_once('managers/whitelist_alter.php'); + include_once 'managers/whitelist_alter.php'; break; // Finances case 'donation_log': - require_once('finances/donation_log.php'); + include_once 'finances/donation_log.php'; break; case 'donor_rewards': - require_once('finances/donor_rewards.php'); + include_once 'finances/donor_rewards.php'; break; case 'payment_alter': - require_once('finances/payment_alter.php'); + include_once 'finances/payment_alter.php'; break; case 'payment_list': - require_once('finances/payment_list.php'); + include_once 'finances/payment_list.php'; break; //Data case 'registration_log': - require_once('data/registration_log.php'); + include_once 'data/registration_log.php'; break; case 'ratio_watch': - require_once('data/ratio_watch.php'); + include_once 'data/ratio_watch.php'; break; case 'invite_pool': - require_once('data/invite_pool.php'); + include_once 'data/invite_pool.php'; break; case 'site_info': - require_once('data/site_info.php'); + include_once 'data/site_info.php'; break; case 'torrent_stats': - require_once('data/torrent_stats.php'); + include_once 'data/torrent_stats.php'; break; case 'user_flow': - require_once('data/user_flow.php'); + include_once 'data/user_flow.php'; break; case 'user_info': - require_once('data/user_info.php'); + include_once 'data/user_info.php'; break; case 'bonus_stats': - require_once('data/bonus_stats.php'); + include_once 'data/bonus_stats.php'; break; case 'economic_stats': - require_once('data/economic_stats.php'); + include_once 'data/economic_stats.php'; break; case 'special_users': - require_once('data/special_users.php'); + include_once 'data/special_users.php'; break; case 'platform_usage': - require_once('data/platform_usage.php'); + include_once 'data/platform_usage.php'; break; // Development case 'analysis': - require_once('development/analysis.php'); + include_once 'development/analysis.php'; break; case 'analysis_list': - require_once('development/analysis_list.php'); + include_once 'development/analysis_list.php'; break; case 'bbcode_sandbox': if (!$Viewer->permitted('users_mod')) { @@ -288,31 +288,31 @@ switch ($_REQUEST['action'] ?? '') { echo $Twig->render('admin/sandbox/bbcode.twig'); break; case 'clear_cache': - require_once('development/clear_cache.php'); + include_once 'development/clear_cache.php'; break; case 'db-mysql': - require_once('development/mysql.php'); + include_once 'development/mysql.php'; break; case 'db-pg': - require_once('development/pg.php'); + include_once 'development/pg.php'; break; case 'db_sandbox': - require_once('development/db_sandbox.php'); + include_once 'development/db_sandbox.php'; break; case 'notification_sandbox': - require_once('development/notification.php'); + include_once 'development/notification.php'; break; case 'process_info': - require_once('development/process_info.php'); + include_once 'development/process_info.php'; break; case 'referral_sandbox': - require_once('development/referral_sandbox.php'); + include_once 'development/referral_sandbox.php'; break; case 'service_stats': - require_once('development/service_stats.php'); + include_once 'development/service_stats.php'; break; case 'site_options': - require_once('development/site_options.php'); + include_once 'development/site_options.php'; break; case 'periodic': @@ -320,34 +320,34 @@ switch ($_REQUEST['action'] ?? '') { switch ($mode) { case 'enqueue': case 'view': - require_once('development/periodic_view.php'); + include_once 'development/periodic_view.php'; break; case 'detail': - require_once('development/periodic_detail.php'); + include_once 'development/periodic_detail.php'; break; case 'stats': - require_once('development/periodic_stats.php'); + include_once 'development/periodic_stats.php'; break; case 'edit': - require_once('development/periodic_edit.php'); + include_once 'development/periodic_edit.php'; break; case 'alter': - require_once('development/periodic_alter.php'); + include_once 'development/periodic_alter.php'; break; case 'run': - require_once('development/periodic_run.php'); + include_once 'development/periodic_run.php'; break; } break; //Services case 'get_host': - require_once('services/get_host.php'); + include_once 'services/get_host.php'; break; case 'get_cc': - require_once('services/get_cc.php'); + include_once 'services/get_cc.php'; break; default: - require_once('tools.php'); + include_once 'tools.php'; } diff --git a/sections/tools/managers/referral_accounts.php b/sections/tools/managers/referral_accounts.php index 77ef37878..767aaf0c1 100644 --- a/sections/tools/managers/referral_accounts.php +++ b/sections/tools/managers/referral_accounts.php @@ -131,4 +131,4 @@ if (!$ReferralManager->readOnly) { + diff --git a/sections/tools/managers/userclass_alter.php b/sections/tools/managers/userclass_alter.php index 501860e87..bb475c69c 100644 --- a/sections/tools/managers/userclass_alter.php +++ b/sections/tools/managers/userclass_alter.php @@ -83,4 +83,4 @@ if (isset($_REQUEST['submit'])) { $usersAffected = (new Gazelle\Manager\User())->flushUserclass($privilege->id()); } -require_once('userclass_edit.php'); +require_once 'userclass_edit.php'; diff --git a/sections/tools/managers/userclass_list.php b/sections/tools/managers/userclass_list.php index 7bf917cfd..548298935 100644 --- a/sections/tools/managers/userclass_list.php +++ b/sections/tools/managers/userclass_list.php @@ -7,7 +7,7 @@ if (!$Viewer->permitted('admin_manage_permissions')) { } if (isset($_REQUEST['id']) && $_REQUEST['id'] === 'new') { - require_once('userclass_edit.php'); + include_once 'userclass_edit.php'; exit; } diff --git a/sections/top10/index.php b/sections/top10/index.php index 807fdbe63..c81d3e496 100644 --- a/sections/top10/index.php +++ b/sections/top10/index.php @@ -7,7 +7,7 @@ if (!$Viewer->permitted('site_top10')) { exit(); } -require_once(match ($_GET['type'] ?? 'torrents') { +require_once match ($_GET['type'] ?? 'torrents') { 'donors' => 'donors.php', 'history' => 'history.php', 'lastfm' => 'lastfm.php', @@ -15,4 +15,4 @@ require_once(match ($_GET['type'] ?? 'torrents') { 'users' => 'users.php', 'votes' => 'votes.php', default => 'torrents.php', -}); +}; diff --git a/sections/torrents/index.php b/sections/torrents/index.php index 702674cf7..4483fb9ca 100644 --- a/sections/torrents/index.php +++ b/sections/torrents/index.php @@ -3,114 +3,114 @@ if (!empty($_REQUEST['action'])) { switch ($_REQUEST['action']) { case 'edit': - require_once('edit.php'); + include_once 'edit.php'; break; case 'takeedit': - require_once('edit_handle.php'); + include_once 'edit_handle.php'; break; case 'changecategory': - require_once('edit_category_handle.php'); + include_once 'edit_category_handle.php'; break; case 'editgroup': - require_once('edit_group.php'); + include_once 'edit_group.php'; break; case 'revert': case 'takegroupedit': - require_once('edit_group_handle.php'); + include_once 'edit_group_handle.php'; break; case 'editgroupid': - require_once('new_groupid.php'); + include_once 'new_groupid.php'; break; case 'newgroup': - require_once('new_group_handle.php'); + include_once 'new_group_handle.php'; break; case 'editrequest': - require_once('edit_request.php'); + include_once 'edit_request.php'; break; case 'takeeditrequest': - require_once('edit_request_handle.php'); + include_once 'edit_request_handle.php'; break; case 'editlog': - require_once('edit_log.php'); + include_once 'edit_log.php'; break; case 'take_editlog': - require_once('edit_log_handle.php'); + include_once 'edit_log_handle.php'; break; case 'filelist': - require_once('filelist.php'); + include_once 'filelist.php'; break; case 'rescore_log': - require_once('rescore_log.php'); + include_once 'rescore_log.php'; break; case 'viewlog': - require_once('log_ajax.php'); + include_once 'log_ajax.php'; break; case 'deletelog': // legacy name case 'removelog': - require_once('remove_log.php'); + include_once 'remove_log.php'; break; case 'removelogs': - require_once('remove_logs.php'); + include_once 'remove_logs.php'; break; case 'grouplog': - require_once('grouplog.php'); + include_once 'grouplog.php'; break; case 'history': - require_once('history.php'); + include_once 'history.php'; break; case 'peerlist': - require_once('peerlist.php'); + include_once 'peerlist.php'; break; case 'snatchlist': - require_once('snatchlist.php'); + include_once 'snatchlist.php'; break; case 'download': - require_once('download.php'); + include_once 'download.php'; break; case 'downloadlist': - require_once('downloadlist.php'); + include_once 'downloadlist.php'; break; case 'redownload': - require_once('redownload.php'); + include_once 'redownload.php'; break; case 'nonwikiedit': - require_once('nonwikiedit.php'); + include_once 'nonwikiedit.php'; break; case 'rename': - require_once('rename.php'); + include_once 'rename.php'; break; case 'merge': - require_once('merge.php'); + include_once 'merge.php'; break; case 'add_alias': - require_once('add_alias.php'); + include_once 'add_alias.php'; break; case 'delete_alias': - require_once('delete_alias.php'); + include_once 'delete_alias.php'; break; case 'delete': - require_once('delete.php'); + include_once 'delete.php'; break; case 'takedelete': - require_once('delete_handle.php'); + include_once 'delete_handle.php'; break; case 'masspm': - require_once('masspm.php'); + include_once 'masspm.php'; break; case 'takemasspm': - require_once('masspm_handle.php'); + include_once 'masspm_handle.php'; break; case 'reseed': - require_once('reseed.php'); + include_once 'reseed.php'; break; case 'vote_tag': - require_once('vote_tag.php'); + include_once 'vote_tag.php'; break; case 'manage_artists': - require_once('manage_artists.php'); + include_once 'manage_artists.php'; break; case 'notify': - require_once('notify.php'); + include_once 'notify.php'; break; case 'notify_catchup': case 'notify_catchup_filter': @@ -118,25 +118,25 @@ if (!empty($_REQUEST['action'])) { case 'notify_clear_filter': case 'notify_clear_item': case 'notify_clear_items': - require_once('notify_actions.php'); + include_once 'notify_actions.php'; break; case 'collector': // NB: called from better.php - require_once('collector.php'); + include_once 'collector.php'; break; case 'regen_filelist': - require_once('regen.php'); + include_once 'regen.php'; break; case 'add_cover_art': - require_once('add_cover_art.php'); + include_once 'add_cover_art.php'; break; case 'autocomplete_tags': - require_once('autocomplete_tags.php'); + include_once 'autocomplete_tags.php'; break; default: if (!empty($_GET['id'])) { - require_once('details.php'); + include_once 'details.php'; } elseif (isset($_GET['torrentid'])) { $torrent = (new Gazelle\Manager\Torrent())->findById((int)$_GET['torrentid']); if ($torrent) { @@ -145,14 +145,14 @@ if (!empty($_REQUEST['action'])) { header("Location: log.php?search=Torrent+" . $_GET['torrentid']); } } else { - require_once('browse.php'); + include_once 'browse.php'; } break; } } else { $manager = new \Gazelle\Manager\TGroup(); if (!empty($_GET['id'])) { - require_once('details.php'); + include_once 'details.php'; } elseif (isset($_GET['torrentid'])) { $torrentId = (int)$_GET['torrentid']; $tgroup = $manager->findByTorrentId($torrentId); @@ -162,7 +162,7 @@ if (!empty($_REQUEST['action'])) { header("Location: log.php?search=Torrent+$torrentId"); } } elseif (!empty($_GET['type'])) { - require_once('user.php'); + include_once 'user.php'; } elseif (!empty($_GET['groupname'])) { $db = Gazelle\DB::DB(); $db->prepared_query(" @@ -176,6 +176,6 @@ if (!empty($_REQUEST['action'])) { header("Location: torrents.php?action=advanced&groupname=" . trim($_GET['groupname'])); } } else { - require_once('browse.php'); + include_once 'browse.php'; } } diff --git a/sections/torrents/rename.php b/sections/torrents/rename.php index b6830b940..04fb94bad 100644 --- a/sections/torrents/rename.php +++ b/sections/torrents/rename.php @@ -18,5 +18,5 @@ if (is_null($tgroup)) { error(404); } -$tgroup->rename($name, $Viewer, $tgMan, new Gazelle\Log()); +$tgroup->rename($name, $Viewer, new Gazelle\Log()); header("Location: {$tgroup->location()}"); diff --git a/sections/upload/index.php b/sections/upload/index.php index 681f0046d..346ca2120 100644 --- a/sections/upload/index.php +++ b/sections/upload/index.php @@ -9,9 +9,9 @@ if ($Viewer->disableUpload()) { } if (isset($_GET['action']) && $_GET['action'] == 'parse_html') { - require_once('parse_html.php'); + include_once 'parse_html.php'; } elseif (!empty($_POST['submit'])) { - require_once('upload_handle.php'); + include_once 'upload_handle.php'; } else { - require_once('upload.php'); + include_once 'upload.php'; } diff --git a/sections/upload/upload_handle.php b/sections/upload/upload_handle.php index 49c379395..71745b9c2 100644 --- a/sections/upload/upload_handle.php +++ b/sections/upload/upload_handle.php @@ -661,7 +661,7 @@ if (defined('AJAX')) { if (isset($RequestID)) { define('NO_AJAX_ERROR', true); $_REQUEST['torrentid'] = $TorrentID; - $FillResponse = require_once(__DIR__ . '/../requests/take_fill.php'); + $FillResponse = include_once __DIR__ . '/../requests/take_fill.php'; if (!isset($FillResponse['requestId'])) { $FillResponse = [ 'status' => 400, diff --git a/sections/user/2fa/index.php b/sections/user/2fa/index.php index 617fbb986..bc2b19406 100644 --- a/sections/user/2fa/index.php +++ b/sections/user/2fa/index.php @@ -14,15 +14,15 @@ switch ($_GET['do'] ?? '') { if ($user->TFAKey()) { error($Viewer->permitted('users_edit_password') ? '2FA is already configured' : 404); } - require_once('configure.php'); + include_once 'configure.php'; break; case 'complete': - require_once('complete.php'); + include_once 'complete.php'; break; case 'remove': - require_once('remove.php'); + include_once 'remove.php'; break; default: diff --git a/sections/user/2fa/remove.php b/sections/user/2fa/remove.php index bb492e5d1..002cea9ab 100644 --- a/sections/user/2fa/remove.php +++ b/sections/user/2fa/remove.php @@ -15,7 +15,7 @@ if (!$Viewer->permitted('users_edit_password')) { if ($userId !== $Viewer->id()) { error(403); } elseif (empty($_POST['password'])) { - require_once('confirm.php'); + include_once 'confirm.php'; exit; } elseif (!$user->validatePassword($_POST['password'])) { header('Location: user.php?action=2fa&do=confirm=invalid&userid=' . $userId); diff --git a/sections/user/index.php b/sections/user/index.php index f04f96ac3..e06ef8e39 100644 --- a/sections/user/index.php +++ b/sections/user/index.php @@ -3,43 +3,43 @@ switch ($_REQUEST['action'] ?? '') { case '2fa': - require_once('2fa/index.php'); + include_once '2fa/index.php'; break; case 'audit': - require_once('audit.php'); + include_once 'audit.php'; break; case 'dupes': - require_once('userlink_handle.php'); + include_once 'userlink_handle.php'; break; case 'edit': - require_once('edit.php'); + include_once 'edit.php'; break; case 'take_edit': - require_once('edit_handle.php'); + include_once 'edit_handle.php'; break; case 'invitetree': - require_once('invitetree.php'); + include_once 'invitetree.php'; break; case 'invite': - require_once('invite.php'); + include_once 'invite.php'; break; case 'take_invite': - require_once('invite_handle.php'); + include_once 'invite_handle.php'; break; case 'delete_invite': - require_once('delete_invite.php'); + include_once 'delete_invite.php'; break; case 'lastfm': - require_once('lastfm.php'); + include_once 'lastfm.php'; break; case 'moderate': - require_once('moderate_handle.php'); + include_once 'moderate_handle.php'; break; case 'notify': - require_once('notify_edit.php'); + include_once 'notify_edit.php'; break; case 'notify_handle': - require_once('notify_handle.php'); + include_once 'notify_handle.php'; break; case 'notify_delete': authorize(); @@ -50,47 +50,44 @@ switch ($_REQUEST['action'] ?? '') { header('Location: user.php?action=notify'); break; case 'permissions': - require_once('permissions.php'); + include_once 'permissions.php'; break; case 'search':// User search if ($Viewer->permitted('admin_advanced_user_search') && $Viewer->permitted('users_view_ips') && $Viewer->permitted('users_view_email')) { - require_once('advancedsearch.php'); + include_once 'advancedsearch.php'; } else { - require_once('search.php'); + include_once 'search.php'; } break; - case 'stats': - require_once('user_stats.php'); - break; case 'seedbox': - require_once('seedbox_edit.php'); + include_once 'seedbox_edit.php'; break; case 'seedbox-view': - require_once('seedbox_view.php'); + include_once 'seedbox_view.php'; break; case 'sessions': - require_once('sessions.php'); + include_once 'sessions.php'; break; case 'stats': - require_once('user_stats.php'); + include_once 'user_stats.php'; break; case 'token': - require_once('token.php'); + include_once 'token.php'; break; case 'vote-history': - require_once('vote_history.php'); + include_once 'vote_history.php'; break; case 'clearcache': if (!$Viewer->permittedAny('admin_clear_cache', 'users_override_paranoia')) { error(403); } (new Gazelle\Manager\User())->findById((int)$_REQUEST['id'])?->flush(); - require_once('user.php'); + include_once 'user.php'; break; default: if (isset($_REQUEST['id'])) { - require_once('user.php'); + include_once 'user.php'; } else { header('Location: ' . $Viewer->location()); } diff --git a/sections/user/invite.php b/sections/user/invite.php index bbf9e784d..a99177d7b 100644 --- a/sections/user/invite.php +++ b/sections/user/invite.php @@ -57,7 +57,7 @@ if ($inviteSourceMan && isset($_GET['edit'])) { if ($update) { authorize(); - $inviteSourceMan->modifyInviteeSource($user, $update); + $inviteSourceMan->modifyInviteeSource($update); } } diff --git a/sections/userhistory/index.php b/sections/userhistory/index.php index aad4f9a38..ee0bccf77 100644 --- a/sections/userhistory/index.php +++ b/sections/userhistory/index.php @@ -3,34 +3,34 @@ switch ($_GET['action'] ?? '') { case 'passkeys': - require_once('announce_key_history.php'); + include_once 'announce_key_history.php'; break; case 'ips': - require_once('ip_history.php'); + include_once 'ip_history.php'; break; case 'tracker_ips': - require_once('ip_tracker_history.php'); + include_once 'ip_tracker_history.php'; break; case 'passwords': - require_once('password_history.php'); + include_once 'password_history.php'; break; case 'email': - require_once('email_history.php'); + include_once 'email_history.php'; break; case 'posts': - require_once('post_history.php'); + include_once 'post_history.php'; break; case 'topics': - require_once('topic_history.php'); + include_once 'topic_history.php'; break; case 'subscriptions': - require_once('subscriptions.php'); + include_once 'subscriptions.php'; break; case 'thread_subscribe': - require_once('thread_subscribe.php'); + include_once 'thread_subscribe.php'; break; case 'comments_subscribe': - require_once('comments_subscribe.php'); + include_once 'comments_subscribe.php'; break; case 'catchup': authorize(); @@ -38,19 +38,19 @@ switch ($_GET['action'] ?? '') { header('Location: userhistory.php?action=subscriptions'); break; case 'collage_subscribe': - require_once('collage_subscribe.php'); + include_once 'collage_subscribe.php'; break; case 'subscribed_collages': - require_once('subscribed_collages.php'); + include_once 'subscribed_collages.php'; break; case 'catchup_collages': - require_once('catchup_collages.php'); + include_once 'catchup_collages.php'; break; case 'token_history': - require_once('token_history.php'); + include_once 'token_history.php'; break; case 'quote_notifications': - require_once('quote_notifications.php'); + include_once 'quote_notifications.php'; break; default: header('Location: index.php'); diff --git a/sections/wiki/index.php b/sections/wiki/index.php index 731ba24f0..e1aef8ce7 100644 --- a/sections/wiki/index.php +++ b/sections/wiki/index.php @@ -18,7 +18,7 @@ function class_list(int $Selected = 0): string { return $Return; } -require_once(match ($_REQUEST['action'] ?? '') { +require_once match ($_REQUEST['action'] ?? '') { 'add_alias' => 'add_alias.php', 'browse' => 'wiki_browse.php', 'compare' => 'compare.php', @@ -29,4 +29,4 @@ require_once(match ($_REQUEST['action'] ?? '') { 'revisions' => 'revisions.php', 'search' => 'search.php', default => 'article.php', -}); +}; diff --git a/templates/donation/reward-list.twig b/templates/donation/reward-list.twig index 2a0c24503..848459c58 100644 --- a/templates/donation/reward-list.twig +++ b/templates/donation/reward-list.twig @@ -36,7 +36,7 @@ {{ u.custom_icon }} {% if u.custom_icon %}
- + {% endif %} diff --git a/tests/helper.php b/tests/helper.php index c1182b495..dec3793fd 100644 --- a/tests/helper.php +++ b/tests/helper.php @@ -66,8 +66,7 @@ class Helper { } public static function makeTGroupEBook( - string $name, - \Gazelle\User $user, + string $name, ): \Gazelle\TGroup { return (new \Gazelle\Manager\TGroup())->create( categoryId: (new \Gazelle\Manager\Category())->findIdByName('E-Books'), diff --git a/tests/phpunit/CategoryTest.php b/tests/phpunit/CategoryTest.php index f7c6fa976..ca1eebf18 100644 --- a/tests/phpunit/CategoryTest.php +++ b/tests/phpunit/CategoryTest.php @@ -26,7 +26,6 @@ class CategoryTest extends TestCase { $user = \GazelleUnitTest\Helper::makeUser('tgcat.' . randomString(10), 'tgroup-cat'); $tgroup = \GazelleUnitTest\Helper::makeTGroupEBook( name: 'phpunit category change ' . randomString(6), - user: $user, ); $this->assertFalse($tgroup->hasArtistRole(), 'tgroup-cat-non-music'); $torrentList = array_map(fn($info) => diff --git a/tests/phpunit/InviteTest.php b/tests/phpunit/InviteTest.php index 782eb8e8d..36988c151 100644 --- a/tests/phpunit/InviteTest.php +++ b/tests/phpunit/InviteTest.php @@ -352,7 +352,7 @@ class InviteTest extends TestCase { ]; $this->assertEquals( 2, - $inviteSourceMan->modifyInviteeSource($this->user, $new), + $inviteSourceMan->modifyInviteeSource($new), 'invite-modify-invitee' ); $this->assertEquals($newProfile, $this->invitee->externalProfile()->profile(), 'invite-source-new-profile');