diff --git a/.phpcs.xml b/.phpcs.xml index 89305a0db..a6dafd3bb 100644 --- a/.phpcs.xml +++ b/.phpcs.xml @@ -7,7 +7,6 @@ . cache/* - lib/override.config.php */.docker/* */.git/* */node_modules/* @@ -17,46 +16,32 @@ */vendor/* - - - - - + - - - - - - - - - - - - + + diff --git a/app/API/User.php b/app/API/User.php index a7b82824e..6c86fec5a 100644 --- a/app/API/User.php +++ b/app/API/User.php @@ -9,7 +9,7 @@ class User extends AbstractAPI { public function run(): array { if (isset($_GET['user_id'])) { $this->id = (int)$_GET['user_id']; - } else if (isset($_GET['username'])) { + } elseif (isset($_GET['username'])) { $this->username = $_GET['username']; } else { json_error("Need to supply either user_id or username"); diff --git a/app/Artist/Similar.php b/app/Artist/Similar.php index 55c4eeaf0..7a4f8c973 100644 --- a/app/Artist/Similar.php +++ b/app/Artist/Similar.php @@ -276,7 +276,7 @@ public function similarGraph(int $width, int $height): array { $layout = []; $angle = fmod($this->id(), 2 * M_PI); $golden = M_PI * (3 - sqrt(5)); - foreach (range(0, $nrSimilar-1) as $r) { + foreach (range(0, $nrSimilar - 1) as $r) { $layout[] = $angle; $angle = fmod($angle + $golden, 2 * M_PI); } @@ -295,7 +295,7 @@ public function similarGraph(int $width, int $height): array { // For all artists with relations, sort their relations list by least relations first. // The idea is to have other artists that are only related to this one close by. foreach ($similar as &$s) { - if ($s['nrRelated'] < 2) { + if ($s['nrRelated'] < 2) { // trivial case continue; } @@ -335,7 +335,7 @@ public function similarGraph(int $width, int $height): array { // Rotate the layout angles to fit this artist in, so that we can // pick the first and last angles off the layout list below. $move = (int)ceil(($relatedToPlace + 1) / 2); - $layout = [...array_slice($layout, $move, NULL, true), ...array_slice($layout, 0, $move, true)]; + $layout = [...array_slice($layout, $move, null, true), ...array_slice($layout, 0, $move, true)]; } if (!($relatedTotal > 0 && $seen > 1)) { $angle = array_shift($layout); @@ -361,7 +361,7 @@ public function similarGraph(int $width, int $height): array { $bestPrevAngle = min($bestPrevAngle, $prevAngleDistance); } } - if (fmod($bestNextAngle, 2 * M_PI) < fmod($bestPrevAngle, 2 * M_PI)) { + if (fmod($bestNextAngle, 2 * M_PI) < fmod($bestPrevAngle, 2 * M_PI)) { $angle = array_shift($layout); $up = false; } else { diff --git a/app/ArtistRole.php b/app/ArtistRole.php index 5def3a34b..051271464 100644 --- a/app/ArtistRole.php +++ b/app/ArtistRole.php @@ -80,28 +80,28 @@ protected function renderRole(int $mode): string { return $link = ''; } - $and = match($mode) { + $and = match ($mode) { self::RENDER_HTML => ' & ', default => ' and ', }; $chunk = []; if ($djCount > 0) { - $chunk[] = match($djCount) { + $chunk[] = match ($djCount) { 1 => $this->artistLink($mode, $roleList['dj'][0]), 2 => $this->artistLink($mode, $roleList['dj'][0]) . $and . $this->artistLink($mode, $roleList['dj'][1]), default => $this->various('DJs', $roleList['dj'], $mode), }; } else { if ($composerCount > 0) { - $chunk[] = match($composerCount) { + $chunk[] = match ($composerCount) { 1 => $this->artistLink($mode, $roleList['composer'][0]), 2 => $this->artistLink($mode, $roleList['composer'][0]) . $and . $this->artistLink($mode, $roleList['composer'][1]), default => $this->various('Composers', $roleList['composer'], $mode), }; if ($arrangerCount > 0) { $chunk[] = 'arranged by'; - $chunk[] = match($arrangerCount) { + $chunk[] = match ($arrangerCount) { 1 => $this->artistLink($mode, $roleList['arranger'][0]), 2 => $this->artistLink($mode, $roleList['arranger'][0]) . $and . $this->artistLink($mode, $roleList['arranger'][1]), default => $this->various('Arrangers', $roleList['arranger'], $mode), @@ -119,7 +119,7 @@ protected function renderRole(int $mode): string { $chunk[] = 'Various Artists'; } else { if ($mainCount > 0) { - $chunk[] = match($mainCount) { + $chunk[] = match ($mainCount) { 1 => $this->artistLink($mode, $roleList['main'][0]), 2 => $this->artistLink($mode, $roleList['main'][0]) . $and . $this->artistLink($mode, $roleList['main'][1]), default => $this->various('Artists', $roleList['main'], $mode), @@ -130,7 +130,7 @@ protected function renderRole(int $mode): string { if ($mainCount + $composerCount > 0 && ($composerCount < 3 || $mainCount > 0)) { $chunk[] = 'under'; } - $chunk[] = match($conductorCount) { + $chunk[] = match ($conductorCount) { 1 => $this->artistLink($mode, $roleList['conductor'][0]), 2 => $this->artistLink($mode, $roleList['conductor'][0]) . $and . $this->artistLink($mode, $roleList['conductor'][1]), default => $this->various('Conductors', $roleList['conductor'], $mode), diff --git a/app/Better/ArtistCollage.php b/app/Better/ArtistCollage.php index 6e215d86e..a9edeeadf 100644 --- a/app/Better/ArtistCollage.php +++ b/app/Better/ArtistCollage.php @@ -3,7 +3,6 @@ namespace Gazelle\Better; class ArtistCollage extends AbstractBetter { - public function mode(): string { return 'artist'; } diff --git a/app/Better/ArtistDescription.php b/app/Better/ArtistDescription.php index 5e3c9eca2..fbf32642b 100644 --- a/app/Better/ArtistDescription.php +++ b/app/Better/ArtistDescription.php @@ -3,7 +3,6 @@ namespace Gazelle\Better; class ArtistDescription extends AbstractBetter { - public function mode(): string { return 'artist'; } diff --git a/app/Better/ArtistDiscogs.php b/app/Better/ArtistDiscogs.php index cdece1dd7..b4da3ce7b 100644 --- a/app/Better/ArtistDiscogs.php +++ b/app/Better/ArtistDiscogs.php @@ -3,7 +3,6 @@ namespace Gazelle\Better; class ArtistDiscogs extends AbstractBetter { - public function mode(): string { return 'artist'; } diff --git a/app/Better/ArtistImage.php b/app/Better/ArtistImage.php index 28b3bf691..63b4356d7 100644 --- a/app/Better/ArtistImage.php +++ b/app/Better/ArtistImage.php @@ -3,7 +3,6 @@ namespace Gazelle\Better; class ArtistImage extends AbstractBetter { - public function mode(): string { return 'artist'; } diff --git a/app/Better/Artwork.php b/app/Better/Artwork.php index 06b7f740b..ebd8fdeed 100644 --- a/app/Better/Artwork.php +++ b/app/Better/Artwork.php @@ -3,7 +3,6 @@ namespace Gazelle\Better; class Artwork extends AbstractBetter { - public function mode(): string { return 'group'; } diff --git a/app/Better/Bad.php b/app/Better/Bad.php index cf828a86f..82a3dbd32 100644 --- a/app/Better/Bad.php +++ b/app/Better/Bad.php @@ -10,7 +10,7 @@ public function mode(): string { } public function setBadType(string $bad): static { - $this->torrentFlag = match($bad) { /** @phpstan-ignore-line */ + $this->torrentFlag = match ($bad) { /** @phpstan-ignore-line */ 'files' => \Gazelle\TorrentFlag::badFile, 'folders' => \Gazelle\TorrentFlag::badFolder, 'lineage' => \Gazelle\TorrentFlag::noLineage, @@ -24,7 +24,7 @@ public function torrentFlag(): \Gazelle\TorrentFlag { } public function heading(): string { - return match($this->torrentFlag) { /** @phpstan-ignore-line */ + return match ($this->torrentFlag) { /** @phpstan-ignore-line */ \Gazelle\TorrentFlag::badFile => 'Releases with with bad filenames', \Gazelle\TorrentFlag::badFolder => 'Releases with with bad folders', \Gazelle\TorrentFlag::noLineage => 'Releases with missing lineage details', diff --git a/app/BonusPool.php b/app/BonusPool.php index c8bd786cd..a96f88978 100644 --- a/app/BonusPool.php +++ b/app/BonusPool.php @@ -5,7 +5,7 @@ class BonusPool extends Base { final const CACHE_SENT = 'bonuspool_sent_%d'; - public function __construct ( + public function __construct( protected readonly int $id, ) {} diff --git a/app/Collage.php b/app/Collage.php index 16a55c060..dfd5beb0f 100644 --- a/app/Collage.php +++ b/app/Collage.php @@ -2,8 +2,8 @@ namespace Gazelle; -use \Gazelle\Enum\LeechType; -use \Gazelle\Enum\LeechReason; +use Gazelle\Enum\LeechType; +use Gazelle\Enum\LeechReason; class Collage extends BaseObject { /** @@ -218,7 +218,7 @@ public function isSubscribed(User $user): bool { if (empty($this->userSubscriptions)) { $key = sprintf(self::SUBS_KEY, $user->id()); $subs = self::$cache->get_value($key); - if ($subs ===false) { + if ($subs === false) { self::$db->prepared_query(" SELECT CollageID FROM users_collage_subs WHERE UserID = ? ", $user->id() diff --git a/app/Collector/Artist.php b/app/Collector/Artist.php index 62f29ea28..81e3c71ff 100644 --- a/app/Collector/Artist.php +++ b/app/Collector/Artist.php @@ -53,7 +53,7 @@ public function fillZip(\ZipStream\ZipStream $zip): void { $this->addZip( $zip, $info, - match($this->roleList[$tgroup->id()]) { + match ($this->roleList[$tgroup->id()]) { ARTIST_MAIN => $releaseMan->findNameById($info['ReleaseType']), ARTIST_GUEST => 'Guest Appearance', ARTIST_REMIXER => 'Remixed By', diff --git a/app/Contest.php b/app/Contest.php index beaf3b8be..abed0ee4d 100644 --- a/app/Contest.php +++ b/app/Contest.php @@ -262,7 +262,7 @@ public function calculateLeaderboard(): int { $n = self::$db->affected_rows(); self::$db->commit(); /* recache the pages */ - $pages = range(0, (int)(ceil($n)/CONTEST_ENTRIES_PER_PAGE) - 1); + $pages = range(0, (int)(ceil($n) / CONTEST_ENTRIES_PER_PAGE) - 1); foreach ($pages as $p) { self::$cache->delete_value(sprintf(self::CONTEST_LEADERBOARD_CACHE_KEY, $this->id, $p)); $this->type()->leaderboard(CONTEST_ENTRIES_PER_PAGE, $p); /** @phpstan-ignore-line */ @@ -314,7 +314,7 @@ public function doPayout(Manager\User $userMan): int { if ($p['total_entries']) { $totalGain += $contestBonus + ($perEntryBonus * $p['total_entries']); } - $log = date('Y-m-d H:i:s') ." {$user->label()} n={$p['total_entries']} t={$totalGain}"; + $log = date('Y-m-d H:i:s') . " {$user->label()} n={$p['total_entries']} t={$totalGain}"; if ($user->hasAttr('no-fl-gifts') || $user->hasAttr('disable-bonus-points')) { fwrite($report, "$log DECLINED\n"); continue; diff --git a/app/Contest/AbstractContest.php b/app/Contest/AbstractContest.php index 29f79b57a..1139135ec 100644 --- a/app/Contest/AbstractContest.php +++ b/app/Contest/AbstractContest.php @@ -5,7 +5,7 @@ trait TorrentLeaderboard { public function leaderboard(int $limit, int $offset): array { $key = sprintf(\Gazelle\Contest::CONTEST_LEADERBOARD_CACHE_KEY, - $this->id, (int)($offset/CONTEST_ENTRIES_PER_PAGE) + $this->id, (int)($offset / CONTEST_ENTRIES_PER_PAGE) ); $leaderboard = self::$cache->get_value($key); if ($leaderboard === false) { diff --git a/app/DB.php b/app/DB.php index 077b59a17..e1b694554 100644 --- a/app/DB.php +++ b/app/DB.php @@ -3,7 +3,7 @@ namespace Gazelle; class DB extends Base { - static public function DB(): DB\Mysql { + public static function DB(): DB\Mysql { return self::$db ??= new DB\Mysql(SQLDB, SQLLOGIN, SQLPASS, SQLHOST, SQLPORT, SQLSOCK); } @@ -78,11 +78,9 @@ public function checkStructureMatch(string $schema, string $source, string $dest if (!$n1) { return [false, "No such source table $source"]; - } - elseif (!$n2) { + } elseif (!$n2) { return [false, "No such destination table $destination"]; - } - elseif ($n1 != $n2) { + } elseif ($n1 != $n2) { // tables do not have the same number of columns return [false, "$source and $destination column count mismatch ($n1 != $n2)"]; } @@ -128,7 +126,7 @@ public function softDelete(string $schema, string $table, array $condition, bool if (self::$db->affected_rows() == 0) { return [false, "condition selected 0 rows"]; } - } catch (DB\Mysql_DuplicateKeyException) { + } catch (DB\MysqlDuplicateKeyException) { // do nothing, for some reason it was already deleted } diff --git a/app/DB/Mysql.php b/app/DB/Mysql.php index cf1c15899..688b39d04 100644 --- a/app/DB/Mysql.php +++ b/app/DB/Mysql.php @@ -99,8 +99,8 @@ ------------------------------------------------------------------------------------- *///--------------------------------------------------------------------------------- -class Mysql_Exception extends \Exception {} -class Mysql_DuplicateKeyException extends Mysql_Exception {} +class MysqlException extends \Exception {} +class MysqlDuplicateKeyException extends MysqlException {} class Mysql { public \mysqli|false $LinkID = false; @@ -136,11 +136,11 @@ public function enableQueryLog(): void { private function halt(string $Msg): void { if ($this->Errno == 1062) { - throw new Mysql_DuplicateKeyException; + throw new MysqlDuplicateKeyException; } global $Debug; $Debug->saveCase("MySQL: error({$this->Errno}) {$this->Error} query=[$this->PreparedQuery]"); - throw new Mysql_Exception("$Msg -- {$this->Error}"); + throw new MysqlException("$Msg -- {$this->Error}"); } public function connect(): void { @@ -149,7 +149,7 @@ public function connect(): void { if ($this->LinkID === false) { $this->Errno = mysqli_connect_errno(); $this->Error = mysqli_connect_error(); - $this->halt('Connection failed (host:'.$this->Server.':'.$this->Port.')'); + $this->halt('Connection failed (host:' . $this->Server . ':' . $this->Port . ')'); } } } @@ -220,24 +220,22 @@ public function execute(mixed ...$Parameters): \mysqli_result|bool { foreach ($Parameters as $Parameter) { if (is_integer($Parameter)) { $Binders .= "i"; - } - elseif (is_double($Parameter)) { + } elseif (is_double($Parameter)) { $Binders .= "d"; - } - else { + } else { $Binders .= "s"; } } $Statement->bind_param($Binders, ...$Parameters); } - $Closure = function() use ($Statement) { + $Closure = function () use ($Statement) { try { $Statement->execute(); return $Statement->get_result(); } catch (\mysqli_sql_exception) { if ($this->LinkID && mysqli_error($this->LinkID) == 1062) { - throw new Mysql_DuplicateKeyException; + throw new MysqlDuplicateKeyException; } } }; @@ -260,7 +258,7 @@ public function prepared_query(string $Query, mixed ...$Parameters): bool|\mysql return $this->execute(...$Parameters); } - private function attempt_query(string $Query, Callable $Closure): \mysqli_result|false { + private function attempt_query(string $Query, callable $Closure): \mysqli_result|false { $QueryStartTime = microtime(true); if ($this->LinkID === false) { return false; @@ -279,8 +277,8 @@ private function attempt_query(string $Query, Callable $Closure): \mysqli_result } $QueryEndTime = microtime(true); // Kills admin pages, and prevents Debug->analysis when the whole set exceeds 1 MB - if (($Len = strlen($Query))>16384) { - $Query = substr($Query, 0, 16384).'... '.($Len-16384).' bytes trimmed'; + if (($Len = strlen($Query)) > 16384) { + $Query = substr($Query, 0, 16384) . '... ' . ($Len - 16384) . ' bytes trimmed'; } if ($this->queryLog) { $this->Queries[] = [$Query, ($QueryEndTime - $QueryStartTime) * 1000, null]; @@ -339,8 +337,7 @@ public function next_record(int $Type = MYSQLI_BOTH, array|bool $escape = true): public function fetch_record(mixed ...$escape): ?array { if (count($escape) === 1 && $escape[0] === true) { $escape = true; - } - elseif (count($escape) === 0) { + } elseif (count($escape) === 0) { $escape = false; } return $this->next_record(MYSQLI_BOTH, $escape); diff --git a/app/Debug.php b/app/Debug.php index 2346feccb..bcb464672 100644 --- a/app/Debug.php +++ b/app/Debug.php @@ -2,9 +2,7 @@ namespace Gazelle; -use \Gazelle\Util\{Irc, Time}; - -ini_set('max_execution_time',600); +use Gazelle\Util\{Irc, Time}; class Debug { protected const MAX_TIME = 20000; @@ -56,16 +54,16 @@ public function profile(User $user, string $document, string $Automatic = ''): b $Micro = (microtime(true) - self::$startTime) * 1000; if ($Micro > self::MAX_TIME && !in_array($document, IGNORE_PAGE_MAX_TIME)) { - $Reason[] = number_format($Micro, 3).' ms'; + $Reason[] = number_format($Micro, 3) . ' ms'; } $Errors = count($this->get_errors()); if ($Errors > self::MAX_ERRORS) { - $Reason[] = $Errors.' PHP errors'; + $Reason[] = $Errors . ' PHP errors'; } $Ram = memory_get_usage(true); if ($Ram > self::MAX_MEMORY && !in_array($document, IGNORE_PAGE_MAX_MEMORY)) { - $Reason[] = byte_format($Ram).' RAM used'; + $Reason[] = byte_format($Ram) . ' RAM used'; } self::$db->warnings(); // see comment in MYSQL::query @@ -114,7 +112,7 @@ public function saveCase(string $message): int { ); self::$cache->cache_value( - 'analysis_'.$id, [ + 'analysis_' . $id, [ 'URI' => isset($_SERVER['REQUEST_URI']) ? ($_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']) : 'cli', 'message' => $message, 'time' => time(), @@ -159,7 +157,7 @@ public function analysis($Message, $Report = '', $Time = 43200): void { public function saveError(\Exception $e): void { $this->saveCase( $e->getMessage() . "\n" - . str_replace(SERVER_ROOT .'/', '', $e->getTraceAsString()) + . str_replace(SERVER_ROOT . '/', '', $e->getTraceAsString()) ); } @@ -212,7 +210,7 @@ protected function format_args(array $Array): string { } elseif (is_object($Val)) { $Return[$Key] .= $Val::class; } elseif (is_array($Val)) { - $Return[$Key] .= '['.$this->format_args($Val).']'; + $Return[$Key] .= '[' . $this->format_args($Val) . ']'; } $LastKey = $Key; } @@ -240,7 +238,7 @@ public function php_error_handler($Level, string $Error, $File, $Line): bool { //At this time ONLY Array strict typing is fully supported. //Allow us to abuse strict typing (IE: function test(Array)) if (preg_match('/^Argument (\d+) passed to \S+ must be an (array), (array|string|integer|double|object) given, called in (\S+) on line (\d+) and defined$/', $Error, $Matches)) { - $Error = 'Type hinting failed on arg '.$Matches[1]. ', expected '.$Matches[2].' but found '.$Matches[3]; + $Error = 'Type hinting failed on arg ' . $Matches[1] . ', expected ' . $Matches[2] . ' but found ' . $Matches[3]; $File = $Matches[4]; $Line = $Matches[5]; } @@ -252,7 +250,7 @@ public function php_error_handler($Level, string $Error, $File, $Line): bool { //Class if (isset($Tracer[$Steps]['class'])) { - $Call .= $Tracer[$Steps]['class'].'::'; + $Call .= $Tracer[$Steps]['class'] . '::'; } //Function & args @@ -330,10 +328,10 @@ public function get_perf(): array { $Perf = [ 'URI' => $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], 'Memory usage' => byte_format(memory_get_usage(true)), - 'Page process time' => number_format($PageTime, 3).' s', + 'Page process time' => number_format($PageTime, 3) . ' s', ]; if ($CPUTime) { - $Perf['CPU time'] = number_format($CPUTime / 1_000_000, 3).' s'; + $Perf['CPU time'] = number_format($CPUTime / 1_000_000, 3) . ' s'; } $Perf['Script start'] = Time::sqlTime(self::$startTime); $Perf['Script end'] = Time::sqlTime(microtime(true)); diff --git a/app/Donate/Bitcoin.php b/app/Donate/Bitcoin.php index a53059c2b..f19c8a0dd 100644 --- a/app/Donate/Bitcoin.php +++ b/app/Donate/Bitcoin.php @@ -2,15 +2,15 @@ namespace Gazelle\Donate; -use \BitWasp\Bitcoin\Address\AddressCreator; -use \BitWasp\Bitcoin\Key\Deterministic\HierarchicalKey; -use \BitWasp\Bitcoin\Network\Slip132\BitcoinRegistry; -use \BitWasp\Bitcoin\Key\Deterministic\Slip132\Slip132; -use \BitWasp\Bitcoin\Key\KeyToScript\KeyToScriptHelper; -use \BitWasp\Bitcoin\Key\Deterministic\HdPrefix\GlobalPrefixConfig; -use \BitWasp\Bitcoin\Key\Deterministic\HdPrefix\NetworkConfig; -use \BitWasp\Bitcoin\Serializer\Key\HierarchicalKey\Base58ExtendedKeySerializer; -use \BitWasp\Bitcoin\Serializer\Key\HierarchicalKey\ExtendedKeySerializer; +use BitWasp\Bitcoin\Address\AddressCreator; +use BitWasp\Bitcoin\Key\Deterministic\HierarchicalKey; +use BitWasp\Bitcoin\Network\Slip132\BitcoinRegistry; +use BitWasp\Bitcoin\Key\Deterministic\Slip132\Slip132; +use BitWasp\Bitcoin\Key\KeyToScript\KeyToScriptHelper; +use BitWasp\Bitcoin\Key\Deterministic\HdPrefix\GlobalPrefixConfig; +use BitWasp\Bitcoin\Key\Deterministic\HdPrefix\NetworkConfig; +use BitWasp\Bitcoin\Serializer\Key\HierarchicalKey\Base58ExtendedKeySerializer; +use BitWasp\Bitcoin\Serializer\Key\HierarchicalKey\ExtendedKeySerializer; class Bitcoin { use \Gazelle\Pg; @@ -32,13 +32,14 @@ class Bitcoin { * @throws \Exception if $xyzpub is not valid */ public function __construct( - string $xyzpub = BITCOIN_DONATION_XYZPUB, - protected \Gazelle\Counter $nextKeyCounter = new \Gazelle\Counter("donation-bitcoin")) { + protected string $xyzpub = BITCOIN_DONATION_XYZPUB, + protected \Gazelle\Counter $nextKeyCounter = new \Gazelle\Counter("donation-bitcoin"), + ) { $adapter = \BitWasp\Bitcoin\Bitcoin::getEcAdapter(); $slip132 = new Slip132(new KeyToScriptHelper($adapter)); $btcPrefixes = new BitcoinRegistry(); - $prefix = match(substr($xyzpub, 0, 4)) { + $prefix = match (substr($xyzpub, 0, 4)) { 'xpub' => $slip132->p2pkh($btcPrefixes), 'ypub' => $slip132->p2shP2wpkh($btcPrefixes), 'zpub' => $slip132->p2wpkh($btcPrefixes), diff --git a/app/Donate/Monero.php b/app/Donate/Monero.php index 51ec2b4d1..2a9bfe966 100644 --- a/app/Donate/Monero.php +++ b/app/Donate/Monero.php @@ -2,7 +2,7 @@ namespace Gazelle\Donate; use Gazelle\Pg; -use \MoneroIntegrations\MoneroPhp; +use MoneroIntegrations\MoneroPhp; class Monero { use Pg; diff --git a/app/Enum/AvatarDisplay.php b/app/Enum/AvatarDisplay.php index 002318e98..b2976c4b8 100644 --- a/app/Enum/AvatarDisplay.php +++ b/app/Enum/AvatarDisplay.php @@ -9,7 +9,7 @@ enum AvatarDisplay: int { case forceSynthetic = 3; public function label(): string { - return match($this) { + return match ($this) { AvatarDisplay::show => 'show', AvatarDisplay::none => 'none', AvatarDisplay::fallbackSynthetic => 'fallbackSynthetic', diff --git a/app/Enum/AvatarSynthetic.php b/app/Enum/AvatarSynthetic.php index 15f882a32..3452ab263 100644 --- a/app/Enum/AvatarSynthetic.php +++ b/app/Enum/AvatarSynthetic.php @@ -12,7 +12,7 @@ enum AvatarSynthetic: int { case robot3 = 6; public function label(): string { - return match($this) { + return match ($this) { AvatarSynthetic::identicon => 'Identicon', AvatarSynthetic::monster => 'Monsters', AvatarSynthetic::wavatar => 'Wavatar', diff --git a/app/Enum/FeaturedAlbumType.php b/app/Enum/FeaturedAlbumType.php index 5ce428b96..2a4662ac2 100644 --- a/app/Enum/FeaturedAlbumType.php +++ b/app/Enum/FeaturedAlbumType.php @@ -2,28 +2,28 @@ namespace Gazelle\Enum; -use \Gazelle\Enum\LeechReason; +use Gazelle\Enum\LeechReason; enum FeaturedAlbumType: int { case AlbumOfTheMonth = 0; case Showcase = 1; public function label(): string { - return match($this) { + return match ($this) { FeaturedAlbumType::AlbumOfTheMonth => 'Album of the Month', FeaturedAlbumType::Showcase => 'Showcase', /** @phpstan-ignore-line */ }; } public function forumId(): int { - return match($this) { + return match ($this) { FeaturedAlbumType::AlbumOfTheMonth => AOTM_FORUM_ID, FeaturedAlbumType::Showcase => SHOWCASE_FORUM_ID, /** @phpstan-ignore-line */ }; } public function leechReason(): LeechReason { - return match($this) { + return match ($this) { FeaturedAlbumType::AlbumOfTheMonth => LeechReason::AlbumOfTheMonth, FeaturedAlbumType::Showcase => LeechReason::Showcase, /** @phpstan-ignore-line */ }; diff --git a/app/Enum/LeechReason.php b/app/Enum/LeechReason.php index f706fa705..6ee8d2a42 100644 --- a/app/Enum/LeechReason.php +++ b/app/Enum/LeechReason.php @@ -10,7 +10,7 @@ enum LeechReason: string { case AlbumOfTheMonth = '4'; public function label(): string { - return match($this) { + return match ($this) { LeechReason::Normal => 'Normal', LeechReason::StaffPick => 'Staff Pick', LeechReason::Permanent => 'Permanent FL', diff --git a/app/Enum/LeechType.php b/app/Enum/LeechType.php index 79676bee7..2daa640a1 100644 --- a/app/Enum/LeechType.php +++ b/app/Enum/LeechType.php @@ -8,7 +8,7 @@ enum LeechType: string { case Neutral = '2'; public function label(): string { - return match($this) { + return match ($this) { LeechType::Normal => 'Normal', LeechType::Neutral => 'Neutral Leech', LeechType::Free => 'Freeleech', /** @phpstan-ignore-line */ diff --git a/app/Enum/SearchReportOrder.php b/app/Enum/SearchReportOrder.php index b9d4c11a0..b20715b06 100644 --- a/app/Enum/SearchReportOrder.php +++ b/app/Enum/SearchReportOrder.php @@ -9,7 +9,7 @@ enum SearchReportOrder: int { case resolvedDesc = 3; public function label(): string { - return match($this) { + return match ($this) { self::createdAsc => 'created-asc', self::createdDesc => 'created-desc', self::resolvedAsc => 'resolved-asc', @@ -18,7 +18,7 @@ public function label(): string { } public function orderBy(): string { - return match($this) { + return match ($this) { self::createdAsc, self::createdDesc => 'created', self::resolvedAsc, @@ -27,7 +27,7 @@ public function orderBy(): string { } public function direction(): string { - return match($this) { + return match ($this) { self::createdAsc, self::resolvedAsc => 'ASC', self::createdDesc, diff --git a/app/Enum/UserStatus.php b/app/Enum/UserStatus.php index b5f5b2d58..39c71f0bb 100644 --- a/app/Enum/UserStatus.php +++ b/app/Enum/UserStatus.php @@ -9,7 +9,7 @@ enum UserStatus: string { case banned = '3'; public function label(): string { - return match($this) { + return match ($this) { UserStatus::unconfirmed => 'Unconfirmed', UserStatus::enabled => 'Enabled', UserStatus::disabled => 'Disabled', diff --git a/app/Enum/UserTokenType.php b/app/Enum/UserTokenType.php index 932efc48a..456080b7c 100644 --- a/app/Enum/UserTokenType.php +++ b/app/Enum/UserTokenType.php @@ -8,7 +8,7 @@ enum UserTokenType: string { case password = 'password'; public function interval(): ?string { - return match($this) { + return match ($this) { self::confirm => '1 day', self::password => '1 hour', default => null, // does not expire diff --git a/app/FeaturedAlbum.php b/app/FeaturedAlbum.php index 24a5195fa..246c2cf1a 100644 --- a/app/FeaturedAlbum.php +++ b/app/FeaturedAlbum.php @@ -11,7 +11,6 @@ class FeaturedAlbum extends BaseObject { public function __construct( protected FeaturedAlbumType $type, protected int $id, - ) { parent::__construct($id); } @@ -68,7 +67,7 @@ public function thread(): ForumThread { } public function type(): FeaturedAlbumType { - return match((int)$this->info()['type']) { + return match ((int)$this->info()['type']) { 1 => FeaturedAlbumType::Showcase, default => FeaturedAlbumType::AlbumOfTheMonth, }; diff --git a/app/Feed.php b/app/Feed.php index 0a3fba93b..010f033d3 100644 --- a/app/Feed.php +++ b/app/Feed.php @@ -3,7 +3,7 @@ namespace Gazelle; class Feed extends Base { - function header(): string { + public function header(): string { header('Cache-Control: no-cache, must-revalidate, post-check=0, pre-check=0'); header('Pragma:'); header('Expires: ' . date('D, d M Y H:i:s', time() + (2 * 60 * 60)) . ' GMT'); @@ -13,11 +13,11 @@ function header(): string { return self::$twig->render('feed/header.twig'); } - function footer(): string { + public function footer(): string { return self::$twig->render('feed/footer.twig'); } - function channel(string $title, string $description): string { + public function channel(string $title, string $description): string { return self::$twig->render('feed/channel.twig', [ 'date' => date('r'), 'description' => $description, @@ -25,7 +25,7 @@ function channel(string $title, string $description): string { ]); } - function item(string $title, string $description, string $page, string $creator, string $date, string $comments = '', string $category = ''): string { + public function item(string $title, string $description, string $page, string $creator, string $date, string $comments = '', string $category = ''): string { return self::$twig->render('feed/item.twig', [ 'category' => $category, 'comments' => $comments, @@ -37,7 +37,7 @@ function item(string $title, string $description, string $page, string $creator, ]); } - function retrieve(User $user, string $key): string { + public function retrieve(User $user, string $key): string { $list = self::$cache->get_value($key); if ($list === false) { $list = []; @@ -46,7 +46,7 @@ function retrieve(User $user, string $key): string { return implode('', array_map(fn ($item) => str_replace('[[PASSKEY]]', $announceKey, $item), $list)); } - function populate(string $key, string $item): int { + public function populate(string $key, string $item): int { $list = self::$cache->get_value($key); if ($list === false) { $list = []; @@ -100,7 +100,7 @@ public function bookmark(User $user, string $feedName): string { public function byFeedName(User $user, string $feedName): string { return $this->wrap( $this->channel( - match($feedName) { + match ($feedName) { 'torrents_all' => 'Everything', 'torrents_apps' => 'Applications', 'torrents_abooks' => 'Audiobooks', @@ -115,7 +115,7 @@ public function byFeedName(User $user, string $feedName): string { 'torrents_vinyl' => 'Vinyl', 'torrents_lossless24' => '24bit Lossless', }, - match($feedName) { + match ($feedName) { 'torrents_all' => 'RSS feed for new uploads', 'torrents_apps' => 'RSS feed for new application uploads', 'torrents_comedy' => 'RSS feed for new comedy uploads', diff --git a/app/Image.php b/app/Image.php index af92e08dc..373e1c547 100644 --- a/app/Image.php +++ b/app/Image.php @@ -23,15 +23,15 @@ public function __construct(string $data) { } } - function height(): int { + public function height(): int { return $this->height; } - function width(): int { + public function width(): int { return $this->width; } - function display(): ?bool { + public function display(): ?bool { return match ($this->type) { IMAGETYPE_BMP => imagebmp($this->image), IMAGETYPE_GIF => imagegif($this->image), @@ -43,7 +43,7 @@ function display(): ?bool { }; } - function type(): string { + public function type(): string { return match ($this->type) { IMAGETYPE_BMP => 'bmp', IMAGETYPE_GIF => 'gif', diff --git a/app/Json/AddLog.php b/app/Json/AddLog.php index 436f801ab..4fdfb36cd 100644 --- a/app/Json/AddLog.php +++ b/app/Json/AddLog.php @@ -20,7 +20,7 @@ public function payload(): array { $logSummaries = []; $checkerVersion = Logchecker::getLogcheckerVersion(); - foreach($this->logfileSummary->all() as $logfile) { + foreach ($this->logfileSummary->all() as $logfile) { $this->torrentLogManager->create($this->torrent, $logfile, $checkerVersion); $logSummaries[] = [ 'score' => $logfile->score(), diff --git a/app/Json/Inbox.php b/app/Json/Inbox.php index 873a4d574..ac4887093 100644 --- a/app/Json/Inbox.php +++ b/app/Json/Inbox.php @@ -19,7 +19,7 @@ public function __construct( public function setSearch(string $searchType, string $search): static { $search = trim($search); - switch($searchType) { + switch ($searchType) { case 'subject': $words = array_unique(array_map('trim', explode(' ', $search))); $this->cond = array_merge($this->cond, array_fill(0, count($words), "c.Subject LIKE concat('%', ?, '%')")); @@ -31,7 +31,7 @@ public function setSearch(string $searchType, string $search): static { $this->cond = array_merge($this->cond, array_fill(0, count($words), "m.Body LIKE concat('%', ?, '%')")); $this->args = array_merge($this->args, $words); break; - case 'user': + case 'user': $this->join[] = 'INNER JOIN users_main AS um ON (um.ID = other.UserID)'; $this->cond[] = "um.Username LIKE concat('%', ?, '%')"; $this->args[] = $search; @@ -60,7 +60,7 @@ public function payload(): array { INNER JOIN pm_conversations_users AS cu ON (cu.ConvID = c.ID AND cu.UserID = ?) LEFT JOIN pm_conversations_users AS other ON (other.ConvID = c.ID AND other.UserID != ? AND other.ForwardedTo = 0) " . implode(' ', $this->join) . " - WHERE " . implode(' AND ', $this->cond) ." + WHERE " . implode(' AND ', $this->cond) . " ", $this->user->id(), $this->user->id(), ...$this->args ); $paginator = new \Gazelle\Util\Paginator(MESSAGES_PER_PAGE, $this->page); @@ -80,7 +80,7 @@ public function payload(): array { INNER JOIN pm_conversations_users AS cu ON (cu.ConvID = c.ID AND cu.UserID = ?) LEFT JOIN pm_conversations_users AS other ON (other.ConvID = c.ID AND other.UserID != ? AND other.ForwardedTo = 0) " . implode(' ', $this->join) . " - WHERE " . implode(' AND ', $this->cond) ." + WHERE " . implode(' AND ', $this->cond) . " GROUP BY c.ID ORDER BY cu.Sticky, {$orderBy} LIMIT ? OFFSET ? diff --git a/app/Json/RipLog.php b/app/Json/RipLog.php index dd791484a..d30621d59 100644 --- a/app/Json/RipLog.php +++ b/app/Json/RipLog.php @@ -36,4 +36,3 @@ public function payload(): array { ]; } } - diff --git a/app/Json/User.php b/app/Json/User.php index d3a320d06..d9d25c745 100644 --- a/app/Json/User.php +++ b/app/Json/User.php @@ -2,7 +2,7 @@ namespace Gazelle\Json; -use \Gazelle\User\Vote; +use Gazelle\User\Vote; class User extends \Gazelle\Json { public function __construct( @@ -20,7 +20,7 @@ public function payload(): array { $stats = $user->stats(); $forumPosts = $stats->forumPostTotal(); - $releaseVotes = (new Vote($user))->userTotal(Vote::UPVOTE|Vote::DOWNVOTE); + $releaseVotes = (new Vote($user))->userTotal(Vote::UPVOTE | Vote::DOWNVOTE); $uploaded = $this->valueOrNull($user->uploadedSize(), 'uploaded'); $downloaded = $this->valueOrNull($user->downloadedSize(), 'downloaded'); $uploads = $this->valueOrNull($stats->uploadTotal(), 'uploads+'); @@ -64,7 +64,7 @@ public function payload(): array { 'profileText' => \Text::full_format($user->profileInfo()), 'stats' => [ 'joinedDate' => $user->created(), - 'lastAccess' => match(true) { + 'lastAccess' => match (true) { $viewer->id() == $user->id() => $user->lastAccessRealtime(), $viewer->isStaff() => $user->lastAccessRealtime(), $user->propertyVisible($viewer, 'lastseen') => $user->lastAccess(), @@ -73,7 +73,7 @@ public function payload(): array { 'uploaded' => $uploaded, 'downloaded' => $downloaded, 'requiredRatio' => $user->propertyVisible($viewer, 'requiredratio') ? $user->requiredRatio() : null, - 'ratio' => match(true) { + 'ratio' => match (true) { is_null($uploaded) || is_null($downloaded) => null, !$downloaded => 0.0, diff --git a/app/LoginWatch.php b/app/LoginWatch.php index 084f5a241..284253051 100644 --- a/app/LoginWatch.php +++ b/app/LoginWatch.php @@ -45,7 +45,7 @@ public function increment(int $userId, string $username): int { UserID = ?, capture = ? WHERE ID = ? - ', $seen ? 60 : LOGIN_ATTEMPT_BACKOFF[min($this->nrAttempts(), count(LOGIN_ATTEMPT_BACKOFF)-1)], + ', $seen ? 60 : LOGIN_ATTEMPT_BACKOFF[min($this->nrAttempts(), count(LOGIN_ATTEMPT_BACKOFF) - 1)], $this->userId, substr(urlencode($username), 0, 20), $this->id ); return self::$db->affected_rows(); diff --git a/app/Manager/Artist.php b/app/Manager/Artist.php index 5f3e56f1b..90e8d61b6 100644 --- a/app/Manager/Artist.php +++ b/app/Manager/Artist.php @@ -88,7 +88,7 @@ public function findByNameAndRevision(string $name, int $revisionId): ?\Gazelle\ AND RevisionID = ? ", trim($name), $revisionId ); - return $id ? new \Gazelle\Artist($id, $revisionId): null; + return $id ? new \Gazelle\Artist($id, $revisionId) : null; } public function findByAliasId(int $aliasId): ?\Gazelle\Artist { diff --git a/app/Manager/AutoEnable.php b/app/Manager/AutoEnable.php index accb0e990..2ac136e3d 100644 --- a/app/Manager/AutoEnable.php +++ b/app/Manager/AutoEnable.php @@ -125,6 +125,7 @@ public function configureView(string $view, bool $showChecked): static { break; case 'ip_overlap': $this->join[] = "INNER JOIN users_history_ips uhi ON (uhi.IP = uer.IP AND uhi.UserID != uer.UserID)"; + break; case 'manual_disable': $this->cond[] = "ui.BanReason != '3'"; break; diff --git a/app/Manager/Collage.php b/app/Manager/Collage.php index 0c0292e8e..0cd7b45df 100644 --- a/app/Manager/Collage.php +++ b/app/Manager/Collage.php @@ -194,7 +194,7 @@ public function addToArtistCollageDefault(int $userId, int $artistId): array { self::$cache->cache_value($key, $default, 86400); } $list = []; - foreach($default as $id) { + foreach ($default as $id) { $collage = $this->findById($id); if ($collage) { $list[] = $collage; @@ -249,7 +249,7 @@ public function addToCollageDefault(int $userId, int $groupId): array { self::$cache->cache_value($key, $default, 86400); } $list = []; - foreach($default as $id) { + foreach ($default as $id) { $collage = $this->findById($id); if ($collage) { $list[] = $collage; @@ -289,7 +289,7 @@ public function autocomplete(string $text): array { ); $pairs = self::$db->to_pair('ID', 'Name', false); $autocomplete = []; - foreach($pairs as $key => $value) { + foreach ($pairs as $key => $value) { $autocomplete[] = ['data' => $key, 'value' => $value]; } self::$cache->cache_value($key, $autocomplete, 1800 + 7200 * ($maxLength - $length)); diff --git a/app/Manager/Comment.php b/app/Manager/Comment.php index 3cfbe20c4..e578e1ab1 100644 --- a/app/Manager/Comment.php +++ b/app/Manager/Comment.php @@ -18,9 +18,12 @@ protected function className(string $page): string { /** * Post a comment on an artist, request or torrent page. */ - public function create(\Gazelle\User $user, string $page, int $pageId, string $body): - \Gazelle\Comment\Artist|\Gazelle\Comment\Collage|\Gazelle\Comment\Request|\Gazelle\Comment\Torrent - { + public function create( + \Gazelle\User $user, + string $page, + int $pageId, + string $body, + ): \Gazelle\Comment\Artist|\Gazelle\Comment\Collage|\Gazelle\Comment\Request|\Gazelle\Comment\Torrent { self::$db->prepared_query(" INSERT INTO comments (Page, PageID, AuthorID, Body) @@ -49,9 +52,9 @@ public function create(\Gazelle\User $user, string $page, int $pageId, string $b return new $className($pageId, 0, $postId); /** @phpstan-ignore-line */ } - public function findById(int $postId): - \Gazelle\Comment\Artist|\Gazelle\Comment\Collage|\Gazelle\Comment\Request|\Gazelle\Comment\Torrent|null - { + public function findById( + int $postId, + ): \Gazelle\Comment\Artist|\Gazelle\Comment\Collage|\Gazelle\Comment\Request|\Gazelle\Comment\Torrent|null { [$page, $pageId] = self::$db->row(" SELECT Page, PageID FROM comments WHERE ID = ? ", $postId diff --git a/app/Manager/Contest.php b/app/Manager/Contest.php index 7b60beb83..b9229035a 100644 --- a/app/Manager/Contest.php +++ b/app/Manager/Contest.php @@ -3,7 +3,7 @@ namespace Gazelle\Manager; class Contest extends \Gazelle\Base { - public function create ( + public function create( string $banner, string $dateBegin, string $dateEnd, diff --git a/app/Manager/ErrorLog.php b/app/Manager/ErrorLog.php index 1dbaa4194..66af7c166 100644 --- a/app/Manager/ErrorLog.php +++ b/app/Manager/ErrorLog.php @@ -6,8 +6,17 @@ class ErrorLog extends \Gazelle\BaseManager { protected string $filter; public function create( - string $uri, int $userId, float $duration, int $memory, int $nrQuery, int $nrCache, - string $digest, string $trace, string $request, string $errorList, string $loggedVar + string $uri, + int $userId, + float $duration, + int $memory, + int $nrQuery, + int $nrCache, + string $digest, + string $trace, + string $request, + string $errorList, + string $loggedVar ): int { self::$db->begin_transaction(); $id = (int)self::$db->scalar(" diff --git a/app/Manager/FeaturedAlbum.php b/app/Manager/FeaturedAlbum.php index 78e97e17a..9d4db4ee6 100644 --- a/app/Manager/FeaturedAlbum.php +++ b/app/Manager/FeaturedAlbum.php @@ -93,7 +93,7 @@ public function findById(int $tgroupId): ?\Gazelle\FeaturedAlbum { return null; } return new \Gazelle\FeaturedAlbum( - match((int)$type) { + match ((int)$type) { 1 => FeaturedAlbumType::Showcase, default => FeaturedAlbumType::AlbumOfTheMonth, }, diff --git a/app/Manager/IRC.php b/app/Manager/IRC.php index 18b097e39..330401491 100644 --- a/app/Manager/IRC.php +++ b/app/Manager/IRC.php @@ -31,7 +31,7 @@ public function list(): array { return $list; } - public function modify (int $id, string $name, int $sort, int $minLevel, array $classList): int { + public function modify(int $id, string $name, int $sort, int $minLevel, array $classList): int { self::$db->prepared_query(" UPDATE irc_channels SET Name = ?, diff --git a/app/Manager/Notification.php b/app/Manager/Notification.php index 8cef4a1d1..da6701900 100644 --- a/app/Manager/Notification.php +++ b/app/Manager/Notification.php @@ -2,7 +2,7 @@ namespace Gazelle\Manager; -use \Gazelle\NotificationTicketState; +use Gazelle\NotificationTicketState; class Notification extends \Gazelle\Base { use \Gazelle\Pg; diff --git a/app/Manager/NotificationTicket.php b/app/Manager/NotificationTicket.php index a914bf7be..baf12c577 100644 --- a/app/Manager/NotificationTicket.php +++ b/app/Manager/NotificationTicket.php @@ -2,7 +2,7 @@ namespace Gazelle\Manager; -use \Gazelle\NotificationTicketState; +use Gazelle\NotificationTicketState; class NotificationTicket { use \Gazelle\Pg; diff --git a/app/Manager/Payment.php b/app/Manager/Payment.php index 1dd66c8db..ba121ca36 100644 --- a/app/Manager/Payment.php +++ b/app/Manager/Payment.php @@ -2,7 +2,7 @@ namespace Gazelle\Manager; -use \Gazelle\Exception\PaymentFetchForexException; +use Gazelle\Exception\PaymentFetchForexException; class Payment extends \Gazelle\Base { final const LIST_KEY = 'payment_list'; diff --git a/app/Manager/PermissionRateLimit.php b/app/Manager/PermissionRateLimit.php index 228f6b1c6..a3cf7c694 100644 --- a/app/Manager/PermissionRateLimit.php +++ b/app/Manager/PermissionRateLimit.php @@ -3,7 +3,6 @@ namespace Gazelle\Manager; class PermissionRateLimit extends \Gazelle\Base { - public function list(): array { self::$db->prepared_query(' SELECT p.ID, p.Name, prl.factor, prl.overshoot diff --git a/app/Manager/Recovery.php b/app/Manager/Recovery.php index 25f8903a8..59a60e9e8 100644 --- a/app/Manager/Recovery.php +++ b/app/Manager/Recovery.php @@ -97,7 +97,7 @@ public function saveScreenshot(array $upload): array { if ($file['size'] > 10 * 1024 * 1024) { return [false, "File was too large, please make sure it is less than 10MB in size."]; } - $filename = sha1(RECOVERY_SALT . random_int(0, 10_000_000). sha1_file($file['tmp_name'])); + $filename = sha1(RECOVERY_SALT . random_int(0, 10_000_000) . sha1_file($file['tmp_name'])); $destination = sprintf('%s/%s/%s/%s/%s', RECOVERY_PATH, substr($filename, 0, 1), substr($filename, 1, 1), substr($filename, 2, 1), $filename ); @@ -328,7 +328,7 @@ public function search(array $terms): ?array { } protected function candidateSql(): string { - return match(true) { + return match (true) { self::$db->entityExists('users_main', 'Uploaded') => sprintf(' SELECT m.Username, m.torrent_pass, m.Email, m.Uploaded, m.Downloaded, m.Enabled, m.PermissionID, m.ID as UserID, @@ -350,7 +350,6 @@ protected function candidateSql(): string { ), default => throw new \Exception('Cannot determine recovery schema') }; - } public function findCandidate(string $username): ?array { @@ -365,8 +364,7 @@ protected function userDetailsSql($schema = null): string { $permission_t = "$schema.permissions"; $users_main_t = "$schema.users_main"; $torrents_t = "$schema.torrents"; - } - else { + } else { $permission_t = 'permissions'; $users_main_t = 'users_main'; $torrents_t = 'torrents'; @@ -493,12 +491,10 @@ public function boostUpload(): void { $irc_message = "Upscaled from $uploaded to $rescale_uploaded from final irc userclass $irc_userclass"; $final += 1.5 * ($rescale_uploaded - $final); $irc_change = "\n\nThe above buffer calculation takes into account your final recorded userclass on IRC '$irc_userclass'"; - } - else { + } else { $irc_message = "No change from logged irc userclass $irc_userclass"; } - } - else { + } else { $irc_message = 'never joined #APOLLO'; } diff --git a/app/Manager/Referral.php b/app/Manager/Referral.php index ad4ddef14..5a3519205 100644 --- a/app/Manager/Referral.php +++ b/app/Manager/Referral.php @@ -218,7 +218,7 @@ public function getReferredUsers(string $startDate, string $endDate, ?string $si if ($view === 'pending') { $filter[] = 'ru.Active = 0'; - } else if ($view === 'processed') { + } elseif ($view === 'processed') { $filter[] = 'ru.Active = 1'; } @@ -476,7 +476,7 @@ private function verifyGGNAccount(array $acc, string $user, string $key): string ); $json = json_decode($result["response"], true); - return str_contains($json["response"]["profileText"], $key) ? true :"Token not found. Please try again."; + return str_contains($json["response"]["profileText"], $key) ? true : "Token not found. Please try again."; } private function verifyTentacleAccount(array $acc, string $user, string $key): string|true { @@ -487,7 +487,7 @@ private function verifyTentacleAccount(array $acc, string $user, string $key): s $url = $acc["URL"] . 'user/profile/' . $user; $result = $this->proxy->fetch($url, [], $acc["Cookie"], false); - return str_contains($result["response"], $key) ? true :"Token not found. Please try again."; + return str_contains($result["response"], $key) ? true : "Token not found. Please try again."; } private function verifyLuminanceAccount(array $acc, string $user, string $key): string|true { @@ -498,7 +498,7 @@ private function verifyLuminanceAccount(array $acc, string $user, string $key): $url = $acc["URL"] . 'user.php'; $result = $this->proxy->fetch($url, ["id" => $user], $acc["Cookie"], false); - return str_contains($result["response"], $key) ? true :"Token not found. Please try again."; + return str_contains($result["response"], $key) ? true : "Token not found. Please try again."; } private function verifyGazelleHTMLAccount(array $acc, string $user, string $key): string|true { @@ -509,7 +509,7 @@ private function verifyGazelleHTMLAccount(array $acc, string $user, string $key) $url = $acc["URL"] . 'user.php'; $result = $this->proxy->fetch($url, ["id" => $user], $acc["Cookie"], false); - return str_contains($result["response"], $key) ? true :"Token not found. Please try again."; + return str_contains($result["response"], $key) ? true : "Token not found. Please try again."; } private function verifyPTPAccount(array $acc, string $user, string $key): string|true { @@ -519,7 +519,7 @@ private function verifyPTPAccount(array $acc, string $user, string $key): string $url = $acc["URL"] . 'user.php'; $result = $this->proxy->fetch($url, ["id" => $user], $acc["Cookie"], false); - return str_contains($result["response"], $key) ? true :"Token not found. Please try again."; + return str_contains($result["response"], $key) ? true : "Token not found. Please try again."; } public function generateInvite(array $acc, string $username, string $email): array { diff --git a/app/Manager/SiteLog.php b/app/Manager/SiteLog.php index bb5178081..7b04e4b30 100644 --- a/app/Manager/SiteLog.php +++ b/app/Manager/SiteLog.php @@ -7,7 +7,7 @@ class SiteLog extends \Gazelle\Base { protected array $result = []; protected array $usernames = []; - public function __construct ( + public function __construct( protected \Gazelle\Manager\User $userMan, ) {} @@ -115,21 +115,21 @@ public function colorize(string $message): array { for ($i = 0, $n = count($parts); $i < $n; $i++) { if (str_starts_with($parts[$i], SITE_URL)) { $offset = strlen(SITE_URL) + 1; // trailing slash - $parts[$i] = ''.substr($parts[$i], $offset).''; + $parts[$i] = '' . substr($parts[$i], $offset) . ''; } switch (strtolower($parts[$i])) { case 'artist': $id = $parts[$i + 1]; if ((int)$id) { - $message .= ' ' .$parts[$i++]." $id"; + $message .= ' ' . $parts[$i++] . " $id"; } else { - $message .= ' ' .$parts[$i]; + $message .= ' ' . $parts[$i]; } break; case 'collage': $id = $parts[$i + 1]; if ((int)$id) { - $message .= ' ' .$parts[$i]." $id"; + $message .= ' ' . $parts[$i] . " $id"; $i++; } else { $message .= " {$parts[$i]}"; @@ -138,18 +138,18 @@ public function colorize(string $message): array { case 'group': $id = $parts[$i + 1]; if ((int)$id) { - $message .= ' ' .$parts[$i]." $id"; + $message .= ' ' . $parts[$i] . " $id"; } else { - $message .= ' ' .$parts[$i]; + $message .= ' ' . $parts[$i]; } $i++; break; case 'request': $id = $parts[$i + 1]; if ((int)$id) { - $message .= ' ' .$parts[$i++]." $id"; + $message .= ' ' . $parts[$i++] . " $id"; } else { - $message .= ' ' .$parts[$i]; + $message .= ' ' . $parts[$i]; } break; case 'torrent': @@ -168,7 +168,7 @@ public function colorize(string $message): array { if ((int)($parts[$i + 1])) { $userId = $parts[++$i]; } - $URL = "user $userId (".substr($parts[++$i], 1, -1).')'; + $URL = "user $userId (" . substr($parts[++$i], 1, -1) . ')'; } elseif (in_array($parts[$i - 1], ['deleted', 'uploaded', 'edited', 'created', 'recovered'])) { $username = $parts[++$i]; if (str_ends_with($username, ':')) { @@ -176,7 +176,7 @@ public function colorize(string $message): array { $colon = true; } $userId = $this->usernameLookup($username); - $URL = $userId ? "$username".($colon ? ':' : '') : $username; + $URL = $userId ? "$username" . ($colon ? ':' : '') : $username; } $message .= " by $URL"; break; diff --git a/app/Manager/SiteOption.php b/app/Manager/SiteOption.php index 3a2013b31..9c9e7c415 100644 --- a/app/Manager/SiteOption.php +++ b/app/Manager/SiteOption.php @@ -18,7 +18,7 @@ public function create(string $name, string $value, string $comment): ?int { VALUES (?, ?, ?) ', $name, $value, $comment ); - } catch (\Gazelle\DB\Mysql_DuplicateKeyException) { + } catch (\Gazelle\DB\MysqlDuplicateKeyException) { return null; } self::$cache->cache_value(sprintf(self::CACHE_KEY, $name), $value); diff --git a/app/Manager/StaffPM.php b/app/Manager/StaffPM.php index 45fd9b699..1bccfdaab 100644 --- a/app/Manager/StaffPM.php +++ b/app/Manager/StaffPM.php @@ -180,7 +180,7 @@ public function staffHistory(int $classLevel, array $userIds, int $interval): ar LEFT JOIN staff_pm_conversations spc ON (spc.ResolverID = um.ID AND spc.Status = 'Resolved' AND spc.Date > now() - INTERVAL ? DAY) WHERE spm.SentDate > now() - INTERVAL ? DAY AND p.Level <= ? - AND um.ID IN (" . placeholders($userIds) .") + AND um.ID IN (" . placeholders($userIds) . ") GROUP BY um.ID ORDER BY total DESC, total2 DESC ", $interval, $interval, $classLevel, ...$userIds); @@ -198,7 +198,7 @@ public function userHistory(int $classLevel, array $userIds, int $interval): arr LEFT JOIN staff_pm_conversations spc ON (spc.UserID = um.ID AND spc.Date > now() - INTERVAL ? DAY) WHERE spm.SentDate > now() - INTERVAL ? DAY AND p.Level <= ? - AND um.ID NOT IN (" . placeholders($userIds) .") + AND um.ID NOT IN (" . placeholders($userIds) . ") GROUP BY um.ID ORDER BY total DESC, total2 DESC ", $interval, $interval, $classLevel, ...$userIds); diff --git a/app/Manager/Stylesheet.php b/app/Manager/Stylesheet.php index 7ae39c148..d4b2d291a 100644 --- a/app/Manager/Stylesheet.php +++ b/app/Manager/Stylesheet.php @@ -2,7 +2,7 @@ namespace Gazelle\Manager; -use \Gazelle\Enum\UserStatus; +use Gazelle\Enum\UserStatus; class Stylesheet extends \Gazelle\Base { final const CACHE_KEY = 'csslist'; diff --git a/app/Manager/TGroup.php b/app/Manager/TGroup.php index 4176e7fd7..a73efdb5c 100644 --- a/app/Manager/TGroup.php +++ b/app/Manager/TGroup.php @@ -83,7 +83,6 @@ public function createFromTorrent( $new->flush()->refresh(); $torrent->flush(); return $new; - } public function findById(int $tgroupId): ?\Gazelle\TGroup { diff --git a/app/Manager/Tag.php b/app/Manager/Tag.php index b72a56205..846afaad5 100644 --- a/app/Manager/Tag.php +++ b/app/Manager/Tag.php @@ -355,7 +355,7 @@ public function aliasList(): array { "); $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, $key) { $val = strtr($val, '.', '_'); }); // Clean up the array for smaller cache size @@ -396,7 +396,7 @@ public function replaceAliasList(array $Tags): array { for ($i = 0; $i < $End; $i++) { foreach ($TagAliases as $TagAlias) { if (substr($Tags['exclude'][$i], 1) === $TagAlias['BadTag']) { - $Tags['exclude'][$i] = '!'.$TagAlias['AliasTag']; + $Tags['exclude'][$i] = '!' . $TagAlias['AliasTag']; break; } } diff --git a/app/Manager/Torrent.php b/app/Manager/Torrent.php index 30e1447fb..a8bc9f5ea 100644 --- a/app/Manager/Torrent.php +++ b/app/Manager/Torrent.php @@ -58,7 +58,7 @@ public function create( ?, ? )", $tgroup->id(), $user->id(), $media, $format, $encoding, $isRemaster ? '1' : '0', $remasterYear, $remasterTitle, $remasterRecordLabel, $remasterCatalogueNumber, - $infohash, $isScene ? '1': '0', $logScore, $hasChecksum ? '1' : '0', $hasLog ? '1' : '0', + $infohash, $isScene ? '1' : '0', $logScore, $hasChecksum ? '1' : '0', $hasLog ? '1' : '0', $hasCue ? '1' : '0', $hasLogInDB ? '1' : '0', $filePath, count($fileList), implode("\n", $fileList), $size, $description, ); @@ -252,8 +252,7 @@ public function setSourceFlag(\OrpheusNET\BencodeTorrent\BencodeTorrent $torrent if (!is_null($creationDate)) { if (is_null($torrentSource) && $creationDate <= GRANDFATHER_OLD_SOURCE) { return false; - } - elseif (!is_null($torrentSource) && $torrentSource === GRANDFATHER_SOURCE && $creationDate <= GRANDFATHER_OLD_SOURCE) { + } elseif (!is_null($torrentSource) && $torrentSource === GRANDFATHER_SOURCE && $creationDate <= GRANDFATHER_OLD_SOURCE) { return false; } } diff --git a/app/Manager/User.php b/app/Manager/User.php index 340dffc80..b04944222 100644 --- a/app/Manager/User.php +++ b/app/Manager/User.php @@ -576,7 +576,7 @@ public function sendSnatchPm(\Gazelle\User $viewer, \Gazelle\Torrent $torrent, $this->sendPM($userId, 0, $subject, $body); } $total = count($snatchers); - (new \Gazelle\Log)->general($viewer->username()." sent a mass PM to $total snatcher" . plural($total) + (new \Gazelle\Log)->general($viewer->username() . " sent a mass PM to $total snatcher" . plural($total) . " of torrent " . $torrent->id() . " (" . $torrent->group()->text() . ")" ); return $total; diff --git a/app/Manager/UserLink.php b/app/Manager/UserLink.php index 29116c9dc..7fa06a5c6 100644 --- a/app/Manager/UserLink.php +++ b/app/Manager/UserLink.php @@ -95,7 +95,7 @@ public function dupe(\Gazelle\User $target, string $adminUsername, bool $updateN return true; } - function addGroupComments(string $comments, string $adminName, bool $updateNote): void { + public function addGroupComments(string $comments, string $adminName, bool $updateNote): void { $groupId = $this->groupId($this->user); $oldHash = self::$db->scalar(" SELECT sha1(Comments) AS CommentHash @@ -124,7 +124,7 @@ function addGroupComments(string $comments, string $adminName, bool $updateNote) } } - function info(): array { + public function info(): array { $sourceId = $this->user->id(); [$linkedGroupId, $comments] = self::$db->row(" SELECT d.ID, d.Comments @@ -146,7 +146,7 @@ function info(): array { return [$linkedGroupId, $comments ?? '', self::$db->to_array(false, MYSQLI_ASSOC, false)]; } - function remove(\Gazelle\User $target, string $adminName): int { + public function remove(\Gazelle\User $target, string $adminName): int { $targetId = $target->id(); self::$db->prepared_query(" UPDATE users_info AS i @@ -170,7 +170,7 @@ function remove(\Gazelle\User $target, string $adminName): int { return self::$db->affected_rows(); } - function removeGroup(int $linkGroupId): int { + public function removeGroup(int $linkGroupId): int { self::$db->prepared_query(" DELETE FROM dupe_groups WHERE ID = ? ", $linkGroupId diff --git a/app/Manager/UserToken.php b/app/Manager/UserToken.php index 55ee6f038..0da4ac11d 100644 --- a/app/Manager/UserToken.php +++ b/app/Manager/UserToken.php @@ -2,7 +2,7 @@ namespace Gazelle\Manager; -use \Gazelle\Enum\UserTokenType; +use Gazelle\Enum\UserTokenType; class UserToken extends \Gazelle\BaseManager { use \Gazelle\Pg; diff --git a/app/Notification/Upload.php b/app/Notification/Upload.php index 9d3173afd..f63a5d640 100644 --- a/app/Notification/Upload.php +++ b/app/Notification/Upload.php @@ -2,8 +2,8 @@ namespace Gazelle\Notification; -use \Gazelle\Util\Irc; -use \Gazelle\Util\IrcText; +use Gazelle\Util\Irc; +use Gazelle\Util\IrcText; // NB: if you receive failures running this locally, the most likely cause is the // presence of users_notify_filters rows that match the uploads created here. @@ -299,7 +299,7 @@ public function sendIrcNotification(): void { public function ircNotification(): string { $torrent = $this->torrent; $tgroup = $torrent->group(); - return match($tgroup->categoryName()) { + return match ($tgroup->categoryName()) { 'Music' => Irc::render( IrcText::Bold, 'TORRENT:', diff --git a/app/NotificationTicket.php b/app/NotificationTicket.php index 9bb51367f..65d84cfd8 100644 --- a/app/NotificationTicket.php +++ b/app/NotificationTicket.php @@ -134,7 +134,7 @@ public function setStale(): static { } public function ticketState(string $state): NotificationTicketState { - return match($state) { + return match ($state) { 'pending' => NotificationTicketState::Pending, 'stale' => NotificationTicketState::Stale, 'active' => NotificationTicketState::Active, diff --git a/app/Report/AbstractReport.php b/app/Report/AbstractReport.php index 9aa086084..f9a672f95 100644 --- a/app/Report/AbstractReport.php +++ b/app/Report/AbstractReport.php @@ -3,7 +3,6 @@ namespace Gazelle\Report; abstract class AbstractReport extends \Gazelle\Base { - /** * The context array is used to stash away pieces of information that will * be needed in the template, but are too complicated to derive within the diff --git a/app/Report/ForumPost.php b/app/Report/ForumPost.php index 79bb7f619..39454d031 100644 --- a/app/Report/ForumPost.php +++ b/app/Report/ForumPost.php @@ -3,7 +3,6 @@ namespace Gazelle\Report; class ForumPost extends AbstractReport { - public function __construct( protected int $reportId, protected \Gazelle\ForumPost $subject diff --git a/app/Request.php b/app/Request.php index 60d8f9eb6..a1982a694 100644 --- a/app/Request.php +++ b/app/Request.php @@ -29,7 +29,7 @@ public function location(): string { return 'requests.php?action=view&id=' . $th */ public function selfLink(): string { $title = display_str($this->title()); - return match($this->categoryName()) { + return match ($this->categoryName()) { 'Music' => "{$this->artistRole()->link()} – " . ($this->isFilled() @@ -52,7 +52,7 @@ public function selfLink(): string { * Display the title of a request, with all fields linkified where it makes sense. */ public function smartLink(): string { - return match($this->categoryName()) { + return match ($this->categoryName()) { 'Music' => "{$this->artistRole()->link()} – {$this->link()} [{$this->year()}]", 'Audiobooks', 'Comedy' => "{$this->link()} [{$this->year()}]", default => $this->link(), @@ -63,7 +63,7 @@ public function smartLink(): string { * Display the full title of the request with no links. */ public function text(): string { - return match($this->categoryName()) { + return match ($this->categoryName()) { 'Music' => "{$this->artistRole()->text()} – {$this->title()} [{$this->year()}]", 'Audiobooks', 'Comedy' => "{$this->title()} [{$this->year()}]", @@ -564,7 +564,7 @@ public function fill(User $user, Torrent $torrent): int { $user->addBounty($bounty); $name = $torrent->group()->text(); $message = "One of your requests — [url={$this->location()}]{$name}[/url] — has been filled." - ." You can view it here: [pl]{$torrent->id()}[/pl]"; + . " You can view it here: [pl]{$torrent->id()}[/pl]"; self::$db->prepared_query(" SELECT UserID FROM requests_votes WHERE RequestID = ? ", $this->id diff --git a/app/Router.php b/app/Router.php index 6994d301d..6cdd3037f 100644 --- a/app/Router.php +++ b/app/Router.php @@ -33,12 +33,10 @@ public function addRoute(string|array $methods, string $action, string $path, bo foreach ($methods as $method) { $this->addRoute($method, $action, $path, $authorize); } - } - else { + } else { if (strtoupper($methods) === 'GET') { $this->addGet($action, $path, $authorize); - } - elseif (strtoupper($methods) === 'POST') { + } elseif (strtoupper($methods) === 'POST') { $this->addPost($action, $path, $authorize); } } @@ -81,8 +79,7 @@ public function getRoute(string $action): string { if (($this->authorize[$request_method] || $method['authorize']) && !$this->authorized()) { throw new InvalidAccessException(); - } - else { + } else { return $method['file']; } } diff --git a/app/Search/ASN.php b/app/Search/ASN.php index fc30fa855..8f3f2075a 100644 --- a/app/Search/ASN.php +++ b/app/Search/ASN.php @@ -38,7 +38,7 @@ public function findByIpList(array $ipList): array { coalesce(a.name, 'unknown') AS name, a.id_asn AS n, (t.id_tor_node IS NOT NULL) AS is_tor - FROM (SELECT unnest(ARRAY[" . placeholders($ipList, "?::inet"). "]) as ip) AS lu + FROM (SELECT unnest(ARRAY[" . placeholders($ipList, "?::inet") . "]) as ip) AS lu LEFT JOIN geo.asn_network an ON (an.network >>= lu.ip) LEFT JOIN geo.asn a USING (id_asn) LEFT JOIN tor_node t ON (t.ipv4 = lu.ip) diff --git a/app/Search/Report.php b/app/Search/Report.php index dc7bb2fb1..b9a620462 100644 --- a/app/Search/Report.php +++ b/app/Search/Report.php @@ -2,7 +2,7 @@ namespace Gazelle\Search; -use \Gazelle\Enum\SearchReportOrder; +use Gazelle\Enum\SearchReportOrder; class Report extends \Gazelle\Base { protected array $args = []; diff --git a/app/Search/Request.php b/app/Search/Request.php index 933c68ebd..0dbc2942b 100644 --- a/app/Search/Request.php +++ b/app/Search/Request.php @@ -244,7 +244,7 @@ public function limit(int $offset, int $limit, int $end): static { public function execute(string $orderBy, string $direction): int { if (isset($this->bookmarkerId)) { - switch($orderBy) { + switch ($orderBy) { case 'bounty': $needVoteTable = true; $orderBy = 'sum(rv.Bounty)'; diff --git a/app/Search/Torrent.php b/app/Search/Torrent.php index 11ddb0aa1..c360fe35b 100644 --- a/app/Search/Torrent.php +++ b/app/Search/Torrent.php @@ -191,7 +191,7 @@ public function __construct( ) { $ErrMsg = "Search\Torrent constructor arguments:\n" . print_r(func_get_args(), true); global $Debug; - $Debug->analysis('Bad arguments in Search\Torrent constructor', $ErrMsg, 3600*24); + $Debug->analysis('Bad arguments in Search\Torrent constructor', $ErrMsg, 3600 * 24); error('-1'); } $this->Page = $searchMany ? $Page : min($Page, SPHINX_MAX_MATCHES / $PageSize); @@ -312,7 +312,7 @@ private function build_query(): void { if (isset($Words['operator'])) { // Is the operator already specified? $Operator = $Words['operator']; - } elseif(isset(self::$FieldOperators[$Field])) { + } elseif (isset(self::$FieldOperators[$Field])) { // Does this field have a non-standard operator? $Operator = self::$FieldOperators[$Field]; } else { diff --git a/app/Staff.php b/app/Staff.php index 6dc350207..3022a1dc4 100644 --- a/app/Staff.php +++ b/app/Staff.php @@ -10,7 +10,7 @@ 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) { + if (($readTime = self::$cache->get_value('staff_blog_read_' . $this->user->id())) === false) { $readTime = self::$db->scalar(' SELECT unix_timestamp(Time) FROM staff_blog_visits diff --git a/app/Stats/Artist.php b/app/Stats/Artist.php index bb084fca3..87b8e98aa 100644 --- a/app/Stats/Artist.php +++ b/app/Stats/Artist.php @@ -18,7 +18,7 @@ public function info(): array { return $this->info; } $key = sprintf(self::CACHE_KEY, $this->id); - $info =self::$cache->get_value($key); + $info = self::$cache->get_value($key); if ($info === false) { $info = self::$db->rowAssoc(" SELECT count(*) AS torrent_total, diff --git a/app/Stats/Artists.php b/app/Stats/Artists.php index 9840f41c8..f5b3bb79b 100644 --- a/app/Stats/Artists.php +++ b/app/Stats/Artists.php @@ -3,7 +3,6 @@ namespace Gazelle\Stats; class Artists extends \Gazelle\Base { - public function updateUsage(): int { self::$db->begin_transaction(); self::$db->prepared_query(" diff --git a/app/Stats/Economic.php b/app/Stats/Economic.php index 83518a43d..a2e13f32d 100644 --- a/app/Stats/Economic.php +++ b/app/Stats/Economic.php @@ -100,4 +100,3 @@ public function info(): array { return $this->info; } } - diff --git a/app/Stats/User.php b/app/Stats/User.php index b707f0682..42a628280 100644 --- a/app/Stats/User.php +++ b/app/Stats/User.php @@ -267,9 +267,9 @@ public function timeline(): array { ); $stats = array_reverse(self::$db->to_array(false, MYSQLI_ASSOC, false)); $timeline = array_column($stats, 'epoch'); - foreach(['data_up', 'data_down', 'buffer', 'bp', 'uploads', 'perfect'] as $dimension) { + foreach (['data_up', 'data_down', 'buffer', 'bp', 'uploads', 'perfect'] as $dimension) { $series = array_column($stats, $dimension); - $chart[$dimension] = array_map(fn($n) => [$timeline[$n], $series[$n]], range(0, count($series)-1)); + $chart[$dimension] = array_map(fn($n) => [$timeline[$n], $series[$n]], range(0, count($series) - 1)); } $chart['start'] = $timeline[0] ?? null; unset($chart); diff --git a/app/TGroup.php b/app/TGroup.php index 2e4ddba4c..043e24fea 100644 --- a/app/TGroup.php +++ b/app/TGroup.php @@ -35,7 +35,7 @@ public function flush(): static { public function link(): string { $url = "url()}\" title=\"" . ($this->hashTag() ?: 'View torrent group') . '" dir="ltr">' . display_str($this->name()) . ''; - return match($this->categoryName()) { + return match ($this->categoryName()) { 'Music' => "{$this->artistRole()->link()} – $url [{$this->year()} {$this->releaseTypeName()}]", 'Audiobooks', 'Comedy' => "$url [{$this->year()}]", @@ -48,7 +48,7 @@ public function location(): string { return "torrents.php?id={$this->id}"; } public function torrentLink(int $torrentId): string { $url = '" . display_str($this->name()) . ''; - return match($this->categoryName()) { + return match ($this->categoryName()) { 'Music' => "{$this->artistRole()->link()} – $url [{$this->year()} {$this->releaseTypeName()}]", 'Audiobooks', 'Comedy' => "$url [{$this->year()}]", @@ -57,7 +57,7 @@ public function torrentLink(int $torrentId): string { } public function text(): string { - return match($this->categoryName()) { + return match ($this->categoryName()) { 'Music' => "{$this->artistRole()->text()} – {$this->name()} [{$this->year()} {$this->releaseTypeName()}]" . ($this->isShowcase() ? '[Showcase]' : ''), 'Audiobooks', diff --git a/app/Task.php b/app/Task.php index 1c5cc7d93..d5341dbda 100644 --- a/app/Task.php +++ b/app/Task.php @@ -2,7 +2,7 @@ namespace Gazelle; -use \Gazelle\Util\Irc; +use Gazelle\Util\Irc; abstract class Task extends Base { protected array $events = []; @@ -40,7 +40,7 @@ public function end(bool $sane): int { ', 'completed', $errorCount, $this->processed, $elapsed, $this->historyId ); - echo("DONE! (".number_format(microtime(true) - $this->startTime, 3).")\n"); + echo("DONE! (" . number_format(microtime(true) - $this->startTime, 3) . ")\n"); foreach ($this->events as $event) { printf("%s [%s] (%d) %s\n", $event->timestamp, $event->severity, $event->reference, $event->event); @@ -61,7 +61,7 @@ public function end(bool $sane): int { Irc::sendMessage(LAB_CHAN, 'Task ' . $this->name . ' is no longer sane ' . SITE_URL . '/tools.php?action=periodic&mode=detail&id=' . $this->taskId); // todo: send notifications to appropriate users - } else if ($errorCount == 0 && !$sane) { + } elseif ($errorCount == 0 && !$sane) { self::$db->prepared_query(' UPDATE periodic_task SET is_sane = TRUE diff --git a/app/Task/Peerupdate.php b/app/Task/Peerupdate.php index 2cfc4b4c0..0891cb36c 100644 --- a/app/Task/Peerupdate.php +++ b/app/Task/Peerupdate.php @@ -8,4 +8,3 @@ public function run(): void { $this->processed += $updated; } } - diff --git a/app/Task/UploadNotifier.php b/app/Task/UploadNotifier.php index cca12ce39..d8555c2e9 100644 --- a/app/Task/UploadNotifier.php +++ b/app/Task/UploadNotifier.php @@ -11,4 +11,3 @@ public function run(): void { ); } } - diff --git a/app/Task/UserLastAccess.php b/app/Task/UserLastAccess.php index 2201e21f8..f3637fa35 100644 --- a/app/Task/UserLastAccess.php +++ b/app/Task/UserLastAccess.php @@ -7,4 +7,3 @@ public function run(): void { $this->processed += (new \Gazelle\Manager\User)->updateLastAccess(); } } - diff --git a/app/TaskScheduler.php b/app/TaskScheduler.php index b4ffe9dcd..c193de037 100644 --- a/app/TaskScheduler.php +++ b/app/TaskScheduler.php @@ -2,7 +2,7 @@ namespace Gazelle; -use \Gazelle\Util\Irc; +use Gazelle\Util\Irc; class TaskScheduler extends Base { final const CACHE_TASKS = 'scheduled_tasks'; @@ -33,7 +33,7 @@ public function getInsaneTasks(): int { } public static function isClassValid(string $class): bool { - $class = 'Gazelle\\Task\\'.$class; + $class = 'Gazelle\\Task\\' . $class; return class_exists($class); } diff --git a/app/Top10/Torrent.php b/app/Top10/Torrent.php index edd6757c3..b69dc9f5d 100644 --- a/app/Top10/Torrent.php +++ b/app/Top10/Torrent.php @@ -16,7 +16,7 @@ class Torrent extends \Gazelle\Base { ORDER BY %s LIMIT %s"; - public function __construct ( + public function __construct( protected readonly array $formats, protected readonly \Gazelle\User $viewer, ) {} @@ -172,7 +172,7 @@ private function tagWhere(string $getParameters, bool $any = false): array { private function flatten(array $array): array { $return = []; - array_walk_recursive($array, function($a) use (&$return) { $return[] = $a; }); + array_walk_recursive($array, function ($a) use (&$return) { $return[] = $a; }); return $return; } } diff --git a/app/Top10/User.php b/app/Top10/User.php index 8079c0b80..9df409397 100644 --- a/app/Top10/User.php +++ b/app/Top10/User.php @@ -72,4 +72,3 @@ public function fetch(string $type, int $limit): array { return $results; } } - diff --git a/app/Torrent.php b/app/Torrent.php index 1530508d4..2f6f68e14 100644 --- a/app/Torrent.php +++ b/app/Torrent.php @@ -100,7 +100,7 @@ public function hasToken(int $userId): bool { public function torrentFilename(bool $asText, int $maxLength): string { $tgroup = $this->group(); $filename = implode('.', - match($tgroup->categoryName()) { + match ($tgroup->categoryName()) { 'Music' => [ $tgroup->artistRole()->text(), $tgroup->year(), $tgroup->name(), '(' . implode('-', [$this->media(), $this->format(), $this->encoding()]) . ')' diff --git a/app/Torrent/Deleted.php b/app/Torrent/Deleted.php index bb8ea375d..7bb6bf13b 100644 --- a/app/Torrent/Deleted.php +++ b/app/Torrent/Deleted.php @@ -9,7 +9,7 @@ class Deleted extends \Gazelle\Base { * * @return array of many things */ - static public function info(int $torrentId): array { + public static function info(int $torrentId): array { $template = "SELECT t.GroupID, t.UserID, t.Media, t.Format, t.Encoding, t.Remastered, t.RemasterYear, t.RemasterTitle, t.RemasterCatalogueNumber, t.RemasterRecordLabel, t.Scene, t.HasLog, t.HasCue, t.HasLogDB, t.LogScore, t.LogChecksum, diff --git a/app/Torrent/Reaper.php b/app/Torrent/Reaper.php index 7dd953a41..2ecdca2d5 100644 --- a/app/Torrent/Reaper.php +++ b/app/Torrent/Reaper.php @@ -554,17 +554,14 @@ public function stats(): array { GROUP BY notify, state "); $results = self::$db->to_array(false, MYSQLI_ASSOC, false); - foreach($results as $r) { + foreach ($results as $r) { if ($r['state'] == ReaperState::UNSEEDED->value && $r['notify'] == ReaperNotify::INITIAL->value) { $stats['unseeded_initial'] = $r['total']; - } - elseif ($r['state'] == ReaperState::UNSEEDED->value && $r['notify'] == ReaperNotify::FINAL->value) { + } elseif ($r['state'] == ReaperState::UNSEEDED->value && $r['notify'] == ReaperNotify::FINAL->value) { $stats['unseeded_final'] = $r['total']; - } - elseif ($r['state'] == ReaperState::NEVER->value && $r['notify'] == ReaperNotify::INITIAL->value) { + } elseif ($r['state'] == ReaperState::NEVER->value && $r['notify'] == ReaperNotify::INITIAL->value) { $stats['never_seeded_initial'] = $r['total']; - } - else { + } else { $stats['never_seeded_final'] = $r['total']; } } diff --git a/app/Torrent/ReaperState.php b/app/Torrent/ReaperState.php index dd4e1442e..1ab1aa28e 100644 --- a/app/Torrent/ReaperState.php +++ b/app/Torrent/ReaperState.php @@ -7,7 +7,7 @@ enum ReaperState: string { case UNSEEDED = 'unseeded'; public function notifyAttr(): string { - return match($this) { + return match ($this) { ReaperState::NEVER => 'no-pm-unseeded-upload', ReaperState::UNSEEDED => 'no-pm-unseeded-snatch', /** @phpstan-ignore-line */ }; diff --git a/app/TorrentAbstract.php b/app/TorrentAbstract.php index e1d490d23..3154e461b 100644 --- a/app/TorrentAbstract.php +++ b/app/TorrentAbstract.php @@ -87,19 +87,13 @@ public function info(): array { if (is_null($info)) { return $this->info = []; } - foreach (['last_action', 'LastReseedRequest', 'RemasterCatalogueNumber', 'RemasterRecordLabel', 'RemasterTitle', 'RemasterYear'] - as $nullable - ) { + foreach (['last_action', 'LastReseedRequest', 'RemasterCatalogueNumber', 'RemasterRecordLabel', 'RemasterTitle', 'RemasterYear'] as $nullable) { $info[$nullable] = $info[$nullable] == '' ? null : $info[$nullable]; } - foreach (['LogChecksum', 'HasCue', 'HasLog', 'HasLogDB', 'Remastered', 'Scene'] - as $zerotruth - ) { + foreach (['LogChecksum', 'HasCue', 'HasLog', 'HasLogDB', 'Remastered', 'Scene'] as $zerotruth) { $info[$zerotruth] = !($info[$zerotruth] == '0'); } - foreach (['BadFiles', 'BadFolders', 'BadTags', 'CassetteApproved', 'LossymasterApproved', 'LossywebApproved', 'MissingLineage'] - as $emptytruth - ) { + foreach (['BadFiles', 'BadFolders', 'BadTags', 'CassetteApproved', 'LossymasterApproved', 'LossywebApproved', 'MissingLineage'] as $emptytruth) { $info[$emptytruth] = !($info[$emptytruth] == ''); } @@ -253,7 +247,7 @@ public function format(): ?string { } public function leechType(): LeechType { - return match($this->info()['FreeTorrent']) { + return match ($this->info()['FreeTorrent']) { LeechType::Free->value => LeechType::Free, LeechType::Neutral->value => LeechType::Neutral, default => LeechType::Normal, @@ -261,7 +255,7 @@ public function leechType(): LeechType { } public function leechReason(): LeechReason { - return match($this->info()['FreeLeechType']) { + return match ($this->info()['FreeLeechType']) { LeechReason::AlbumOfTheMonth->value => LeechReason::AlbumOfTheMonth, LeechReason::Permanent->value => LeechReason::Permanent, LeechReason::Showcase->value => LeechReason::Showcase, @@ -582,8 +576,8 @@ public function isReseedRequestAllowed(): bool { $lastActiveDate = (int)strtotime($this->lastActiveDate()); $createdDate = (int)strtotime($this->created()); - return match(true) { - !$lastActiveDate && !$lastRequestDate => (time() >= strtotime(RESEED_NEVER_ACTIVE_TORRENT .' days', $createdDate)), + return match (true) { + !$lastActiveDate && !$lastRequestDate => (time() >= strtotime(RESEED_NEVER_ACTIVE_TORRENT . ' days', $createdDate)), !$lastRequestDate => (time() >= strtotime(RESEED_TORRENT . 'days', $lastActiveDate)), default => false, }; diff --git a/app/TorrentFlag.php b/app/TorrentFlag.php index a51992b0a..4e2aaca1f 100644 --- a/app/TorrentFlag.php +++ b/app/TorrentFlag.php @@ -12,7 +12,7 @@ enum TorrentFlag: string { case noLineage = 'torrents_missing_lineage'; public function label(): string { - return match($this) { + return match ($this) { TorrentFlag::badFile => 'Bad Files', TorrentFlag::badFolder => 'Bad Folders', TorrentFlag::badTag => 'Bad Tags', diff --git a/app/Upload.php b/app/Upload.php index e1f7e0c33..017ac74cb 100644 --- a/app/Upload.php +++ b/app/Upload.php @@ -14,8 +14,8 @@ namespace Gazelle; -use \Gazelle\Util\Textarea; -use \OrpheusNET\Logchecker\Logchecker; +use Gazelle\Util\Textarea; +use OrpheusNET\Logchecker\Logchecker; class Upload extends \Gazelle\Base { protected int $categoryId = 0; @@ -129,7 +129,8 @@ public function music_form(array $GenreTags, \Gazelle\Manager\TGroup $manager): - +
@@ -228,8 +229,10 @@ public function music_form(array $GenreTags, \Gazelle\Manager\TGroup $manager): @@ -300,7 +310,8 @@ public function music_form(array $GenreTags, \Gazelle\Manager\TGroup $manager): @@ -309,7 +320,8 @@ public function music_form(array $GenreTags, \Gazelle\Manager\TGroup $manager): @@ -317,7 +329,8 @@ public function music_form(array $GenreTags, \Gazelle\Manager\TGroup $manager): @@ -329,7 +342,8 @@ public function music_form(array $GenreTags, \Gazelle\Manager\TGroup $manager): @@ -338,7 +352,8 @@ public function music_form(array $GenreTags, \Gazelle\Manager\TGroup $manager): @@ -395,16 +410,18 @@ public function music_form(array $GenreTags, \Gazelle\Manager\TGroup $manager): foreach (ENCODING as $Bitrate) { ?> - @@ -434,37 +451,46 @@ public function music_form(array $GenreTags, \Gazelle\Manager\TGroup $manager): - + - + - + - + - + - + - + - findById($groupId); if (is_null($tgroup)) { @@ -449,7 +453,7 @@ Switch to cloud
-
+
name()) ?>
@@ -479,7 +483,7 @@ } } ?> - " y1="" x2="" y2="" style="stroke:rgb(77,153,0);stroke-width:" /> the old name."'); + error('The new name is identical to the old name."'); } if (!($oldAliasId = $artist->getAlias($oldName))) { error('Could not find existing alias ID'); diff --git a/sections/better/better.php b/sections/better/better.php index 4e25c31a6..8c07c61f8 100644 --- a/sections/better/better.php +++ b/sections/better/better.php @@ -18,7 +18,7 @@ $type = $_GET['type'] ?? 'artwork'; } -$better = match($type) { +$better = match ($type) { 'artistcollage' => new Gazelle\Better\ArtistCollage($user, $filter, new Gazelle\Manager\Artist), 'artistdesc' => new Gazelle\Better\ArtistDescription($user, $filter, new Gazelle\Manager\Artist), 'artistdiscogs' => new Gazelle\Better\ArtistDiscogs($user, $filter, new Gazelle\Manager\Artist), diff --git a/sections/better/transcode.php b/sections/better/transcode.php index 8beb31ed7..e565795b9 100644 --- a/sections/better/transcode.php +++ b/sections/better/transcode.php @@ -26,7 +26,7 @@ $target = $_GET['target'] ?? null; $better = new Gazelle\Search\Transcode($user, new Gazelle\Manager\Torrent); -switch($filter) { +switch ($filter) { case 'seeding': $better->setModeSeeding(); break; diff --git a/sections/blog/take_edit_blog.php b/sections/blog/take_edit_blog.php index fed3d47d6..151b381a9 100644 --- a/sections/blog/take_edit_blog.php +++ b/sections/blog/take_edit_blog.php @@ -21,7 +21,7 @@ } $manager = new Gazelle\Manager\ForumThread; -$thread = match((int)($_POST['thread'] ?? -1)) { +$thread = match ((int)($_POST['thread'] ?? -1)) { -1 => null, 0 => $manager->create( forum: new Gazelle\Forum(ANNOUNCEMENT_FORUM_ID), diff --git a/sections/blog/take_new_blog.php b/sections/blog/take_new_blog.php index 956f934d3..e9238ca1e 100644 --- a/sections/blog/take_new_blog.php +++ b/sections/blog/take_new_blog.php @@ -15,7 +15,7 @@ error('The title of the blog article must not be empty'); } -$thread = match((int)($_POST['thread'] ?? -1)) { +$thread = match ((int)($_POST['thread'] ?? -1)) { -1 => null, 0 => (new Gazelle\Manager\ForumThread)->create( forum: new Gazelle\Forum(ANNOUNCEMENT_FORUM_ID), diff --git a/sections/bonus/bprates.php b/sections/bonus/bprates.php index 23f679579..4a3a2df23 100644 --- a/sections/bonus/bprates.php +++ b/sections/bonus/bprates.php @@ -3,7 +3,7 @@ $page = !empty($_GET['page']) ? (int) $_GET['page'] : 1; $page = max(1, $page); $limit = TORRENTS_PER_PAGE; -$offset = TORRENTS_PER_PAGE * ($page-1); +$offset = TORRENTS_PER_PAGE * ($page - 1); $heading = new \Gazelle\Util\SortableTableHeader('hourlypoints', [ 'size' => ['dbColumn' => 'size', 'defaultSort' => 'desc', 'text' => 'Size'], diff --git a/sections/bookmarks/torrents.php b/sections/bookmarks/torrents.php index 980f673e1..44d9d9668 100644 --- a/sections/bookmarks/torrents.php +++ b/sections/bookmarks/torrents.php @@ -37,7 +37,8 @@ ?>
-

auth() ?>&user=id() ?>&auth=rssAuth() ?>&passkey=announceKey() ?>&authkey=auth()?>&name="> $CollageCovers) { $Render = array_merge($Render, - array_fill(0, $CollageCovers * ceil($NumGroups/$CollageCovers) - $NumGroups, '
  • ') + array_fill(0, $CollageCovers * ceil($NumGroups / $CollageCovers) - $NumGroups, '
  • ') ); } for ($i = 0; $i < $NumGroups / $CollageCovers; $i++) { diff --git a/sections/collages/torrent_collage.php b/sections/collages/torrent_collage.php index 70165ff57..7cd39e0a1 100644 --- a/sections/collages/torrent_collage.php +++ b/sections/collages/torrent_collage.php @@ -88,15 +88,19 @@ $OpenGroup = true; } ?> - + @@ -142,7 +146,7 @@ if (!empty($chunk)) { $CollagePages[] = implode('', array_map( - function($id) use ($collMan, $tgMan) { + function ($id) use ($collMan, $tgMan) { $tgroup = $tgMan->findById($id); return $tgroup ? $collMan->tgroupCover($tgroup) : ''; }, $chunk diff --git a/sections/comments/comments.php b/sections/comments/comments.php index 13913bc7e..52e17106b 100644 --- a/sections/comments/comments.php +++ b/sections/comments/comments.php @@ -105,7 +105,7 @@ $idField = 'r.ID'; $nameField = 'r.Title'; - switch($Type) { + switch ($Type) { case 'created': $Title = "%s › Comments on their requests"; $condition[] = "r.UserID = ?"; @@ -151,7 +151,7 @@ $idField = 'tg.ID'; $nameField = 'tg.Name'; - switch($Type) { + switch ($Type) { case 'uploaded': $Title = "%s › Comments on their uploads"; $Join[] = 'INNER JOIN torrents t ON (t.GroupID = tg.ID)'; @@ -268,7 +268,7 @@ 'editor' => $userMan->findById((int)$EditedUserID), 'edit_time' => $EditedTime, 'id' => $PostID, - 'heading' => match($Page) { + 'heading' => match ($Page) { 'artist' => "
    " . html_escape($Name) . "", 'collages' => "" . html_escape($Name) . "", 'requests' => $requestList[$PageID]->smartLink(), diff --git a/sections/error/index.php b/sections/error/index.php index 9aa2f86fa..9ff270c0e 100644 --- a/sections/error/index.php +++ b/sections/error/index.php @@ -2,7 +2,7 @@ use Gazelle\Util\Irc; -function notify ($Viewer, $Channel, $Message) { +function notify($Viewer, $Channel, $Message) { Irc::sendMessage($Channel, $Message . " error by " . ($Viewer @@ -49,7 +49,7 @@ function notify ($Viewer, $Channel, $Message) { } if (isset($Log) && $Log) { - $Description .= ' Search Log'; + $Description .= ' Search Log'; } if (empty($NoHTML) && $Error != -1) { diff --git a/sections/forums/search.php b/sections/forums/search.php index efb1431b6..b5db39647 100644 --- a/sections/forums/search.php +++ b/sections/forums/search.php @@ -100,13 +100,16 @@

    - isBodySearch()) { echo "class='hidden'"; } ?>> + isBodySearch()) { +echo "class='hidden'"; } ?>> - isPinned() ? '' : ' class="hidden"' ?>> @@ -441,7 +446,8 @@ @@ -473,7 +479,8 @@ - + diff --git a/sections/friends/index.php b/sections/friends/index.php index 257cf1f16..0f55bbe8a 100644 --- a/sections/friends/index.php +++ b/sections/friends/index.php @@ -1,6 +1,6 @@ 'add.php', 'Save notes' => 'comment.php', 'Unfriend' => 'remove.php', diff --git a/sections/logchecker/take_upload.php b/sections/logchecker/take_upload.php index e294ba611..4ac70aedd 100644 --- a/sections/logchecker/take_upload.php +++ b/sections/logchecker/take_upload.php @@ -30,7 +30,7 @@ $torrentLogManager = new Gazelle\Manager\TorrentLog($ripFiler, $htmlFiler); $checkerVersion = Logchecker::getLogcheckerVersion(); - foreach($logfileSummary->all() as $logfile) { + foreach ($logfileSummary->all() as $logfile) { $torrentLogManager->create($torrent, $logfile, $checkerVersion); } $torrent->modifyLogscore(); diff --git a/sections/random/index.php b/sections/random/index.php index 06ed3fb91..7bb913f3a 100644 --- a/sections/random/index.php +++ b/sections/random/index.php @@ -1,6 +1,6 @@ (new Gazelle\Manager\Artist)->findRandom(), 'collage' => (new Gazelle\Manager\Collage)->findRandom(), default => (new Gazelle\Manager\TGroup)->findRandom(), diff --git a/sections/recovery/admin.php b/sections/recovery/admin.php index 73db10d0b..8e4336f12 100644 --- a/sections/recovery/admin.php +++ b/sections/recovery/admin.php @@ -8,15 +8,15 @@ $id = (int)($_GET['id'] ?? 0); if ($id) { switch ($_GET['task']) { - case 'accept'; + case 'accept': $ok = $recovery->accept($id, $Viewer->id(), $Viewer->username()); $message = $ok ? 'Invite sent' : 'Invite not sent, check log'; break; - case 'deny'; + case 'deny': $recovery->deny($id, $Viewer->id(), $Viewer->username()); $message = sprintf('Request %d was denied', $id); break; - case 'unclaim'; + case 'unclaim': $recovery->unclaim($id, $Viewer->username()); $message = sprintf('Request %d was unclaimed', $id); break; diff --git a/sections/recovery/save.php b/sections/recovery/save.php index 16f4a62e4..e02fe8d3e 100644 --- a/sections/recovery/save.php +++ b/sections/recovery/save.php @@ -31,8 +31,7 @@ if ($Cache->get_value($key)) { $msg = "Rate limiting in force.
    You tried to save this page too rapidly following the previous save."; -} -else { +} else { $info = $recovery->validate($_POST); if (count($info)) { $info['ipaddr'] = $ipaddr; @@ -41,14 +40,13 @@ [$ok, $filename] = $recovery->saveScreenshot($_FILES); if (!$ok) { $msg = $filename; // the reason we were unable to save the screenshot info - } - else { + } else { $info['screenshot'] = $filename; $token = ''; for ($i = 0; $i < 16; ++$i) { - $token .= chr(random_int(97, 97+25)); - if (($i+1) % 4 == 0 && $i < 15) { + $token .= chr(random_int(97, 97 + 25)); + if (($i + 1) % 4 == 0 && $i < 15) { $token .= '-'; } } @@ -56,13 +54,11 @@ if ($recovery->persist($info)) { $msg = 'ok'; - } - else { + } else { $msg = "Unable to save, are you sure you haven't registered already?"; } } - } - else { + } else { $msg = "Your upload was not accepted."; } } diff --git a/sections/referral/index.php b/sections/referral/index.php index 145fde466..6c5ec6421 100644 --- a/sections/referral/index.php +++ b/sections/referral/index.php @@ -64,7 +64,7 @@ generateToken(); if (session_status() === PHP_SESSION_NONE) { session_start(); @@ -98,7 +98,7 @@ generateInvite($Account, $_POST['username'], $Email); if (!$Success) { $Error = $Invite; - } else if ($Invite === false) { + } elseif ($Invite === false) { $Error = "Failed to generate invite."; } } diff --git a/sections/register/index.php b/sections/register/index.php index f2fbacaad..c8bbffcc2 100644 --- a/sections/register/index.php +++ b/sections/register/index.php @@ -1,7 +1,7 @@ setFields([ ['username', true, 'regex', 'You did not enter a valid username.', ['regex' => USERNAME_REGEXP]], ['email', true, 'email', 'You did not enter a valid email address.'], - ['password', true, 'regex', 'A strong password is 8 characters or longer, contains at least 1 lowercase and uppercase letter, and contains at least a number or symbol, or is 20 characters or longer', ['regex'=>'/(?=^.{8,}$)(?=.*[^a-zA-Z])(?=.*[A-Z])(?=.*[a-z]).*$|.{20,}/']], + ['password', true, 'regex', 'A strong password is 8 characters or longer, contains at least 1 lowercase and uppercase letter, and contains at least a number or symbol, or is 20 characters or longer', ['regex' => '/(?=^.{8,}$)(?=.*[^a-zA-Z])(?=.*[A-Z])(?=.*[a-z]).*$|.{20,}/']], ['confirm_password', true, 'compare', 'Your passwords do not match.', ['comparefield' => 'password']], ['readrules', true, 'checkbox', 'You did not select the box that says you will read the rules.'], ['readwiki', true, 'checkbox', 'You did not select the box that says you will read the wiki.'], @@ -59,7 +59,7 @@ try { $user = $creator->create(); - (new Gazelle\Util\Mail)->send($user->email(), 'New account confirmation at '.SITE_NAME, + (new Gazelle\Util\Mail)->send($user->email(), 'New account confirmation at ' . SITE_NAME, $Twig->render('email/registration.twig', [ 'ipaddr' => $_SERVER['REMOTE_ADDR'], 'user' => $user, @@ -67,8 +67,7 @@ ]) ); $emailSent = true; - } - catch (Gazelle\Exception\UserCreatorException $e) { + } catch (Gazelle\Exception\UserCreatorException $e) { switch ($e->getMessage()) { case 'duplicate': $error = 'Someone already took that username :-('; diff --git a/sections/reports/reports.php b/sections/reports/reports.php index 8501500f3..f2d3e2660 100644 --- a/sections/reports/reports.php +++ b/sections/reports/reports.php @@ -45,7 +45,7 @@ if (isset($_REQUEST['order'])) { $paginator->setParam('view=old'); $paginator->setParam("order={$_REQUEST['order']}"); - $search->setOrder(match($_REQUEST['order']) { + $search->setOrder(match ($_REQUEST['order']) { 'resolved-asc' => SearchReportOrder::resolvedAsc, 'resolved-desc' => SearchReportOrder::resolvedDesc, 'created-asc' => SearchReportOrder::createdAsc, diff --git a/sections/reports/takereport.php b/sections/reports/takereport.php index 46e535fcc..2fc1de29d 100644 --- a/sections/reports/takereport.php +++ b/sections/reports/takereport.php @@ -25,12 +25,12 @@ } $reason = "[b]Year[/b]: {$year}.\n\n"; // If the release type is somehow invalid, return "Not given"; otherwise, return the release type. - $reason .= '[b]Release type[/b]: '.((empty($_POST['releasetype']) || !is_number($_POST['releasetype']) || $_POST['releasetype'] == '0') - ? 'Not given' : (new Gazelle\ReleaseType)->findNameById($_POST['releasetype']))." . \n\n"; - $reason .= '[b]Additional comments[/b]: '.$_POST['comment']; + $reason .= '[b]Release type[/b]: ' . ((empty($_POST['releasetype']) || !is_number($_POST['releasetype']) || $_POST['releasetype'] == '0') + ? 'Not given' : (new Gazelle\ReleaseType)->findNameById($_POST['releasetype'])) . " . \n\n"; + $reason .= '[b]Additional comments[/b]: ' . $_POST['comment']; } -$location = match($reportType) { +$location = match ($reportType) { 'collage' => "collages.php?id=$subjectId", 'comment' => "comments.php?action=jump&postid=$subjectId", 'post' => (new Gazelle\Manager\ForumPost)->findById($subjectId)?->location(), // could be null diff --git a/sections/reportsv2/ajax_report.php b/sections/reportsv2/ajax_report.php index 9272dec94..9a38e03d6 100644 --- a/sections/reportsv2/ajax_report.php +++ b/sections/reportsv2/ajax_report.php @@ -24,7 +24,7 @@ render('torrent/stats.twig', ['torrent' => $torrent]) ?> - + diff --git a/sections/top10/votes.php b/sections/top10/votes.php index d89faab4a..d763912f1 100644 --- a/sections/top10/votes.php +++ b/sections/top10/votes.php @@ -50,7 +50,8 @@ @@ -58,9 +59,11 @@ @@ -76,17 +79,22 @@ + case 100: + ?> - Top 25 - Top 100 - Top 250 - + - Top 25 - Top 100 - Top 250 - + - Top 25 - Top 100 - Top 250 @@ -148,7 +156,8 @@
    - - link() ?>year()) { echo ' [' . $tgroup->year() . ']'; } ?> + - link() ?>year()) { +echo ' [' . $tgroup->year() . ']'; } ?>
    "$name", $tgroup->tagNameList() )) ?>
    diff --git a/sections/torrents/details.php b/sections/torrents/details.php index f042714c2..bc1fe96e2 100644 --- a/sections/torrents/details.php +++ b/sections/torrents/details.php @@ -482,7 +482,8 @@ render('torrent/stats.twig', ['torrent' => $torrent]) ?>
    - + diff --git a/sections/upload/upload_handle.php b/sections/upload/upload_handle.php index b818660e1..e37f4e9ae 100644 --- a/sections/upload/upload_handle.php +++ b/sections/upload/upload_handle.php @@ -78,7 +78,7 @@ function reportError(string $message): never { if ($Properties['Image']) { // Strip out Amazon's padding if (preg_match('/(http:\/\/ecx.images-amazon.com\/images\/.+)(\._.*_\.jpg)/i', $Properties['Image'], $match)) { - $Properties['Image'] = $match[1].'.jpg'; + $Properties['Image'] = $match[1] . '.jpg'; } if (!preg_match(IMAGE_REGEXP, $Properties['Image'])) { reportError(display_str($Properties['Image']) . " does not look like a valid image url"); @@ -135,7 +135,7 @@ function reportError(string $message): never { $Validate = new Gazelle\Util\Validator; $Validate->setFields([ ['type', true, 'inarray', 'Please select a valid category.', ['inarray' => array_keys(CATEGORY)]], - ['release_desc', false, 'string','The release description you entered is too long.', ['maxlength'=>1_000_000]], + ['release_desc', false, 'string','The release description you entered is too long.', ['maxlength' => 1_000_000]], ['rules', true,'require','Your torrent must abide by the rules.'], ]); @@ -155,15 +155,15 @@ function reportError(string $message): never { // audio types if (in_array($categoryName, ['Music', 'Audiobooks', 'Comedy'])) { - $Validate->setField('format', true, 'inarray','Please select a valid format.', ['inarray'=>FORMAT]); + $Validate->setField('format', true, 'inarray','Please select a valid format.', ['inarray' => FORMAT]); if ($Properties['Encoding'] !== 'Other') { - $Validate->setField('bitrate', true, 'inarray','You must choose a bitrate.', ['inarray'=>ENCODING]); + $Validate->setField('bitrate', true, 'inarray','You must choose a bitrate.', ['inarray' => ENCODING]); } else { if ($Properties['Format'] === 'FLAC') { - $Validate->setField('bitrate', true, 'string','FLAC bitrate must be lossless.', ['regex'=>'/Lossless/']); + $Validate->setField('bitrate', true, 'string','FLAC bitrate must be lossless.', ['regex' => '/Lossless/']); } else { $Validate->setField('other_bitrate', - true, 'string','You must enter the other bitrate (max length: 9 characters).', ['maxlength'=>9]); + true, 'string','You must enter the other bitrate (max length: 9 characters).', ['maxlength' => 9]); $Properties['Encoding'] = trim($_POST['other_bitrate']) . (!empty($_POST['vbr']) ? ' (VBR)' : '');; } } @@ -178,20 +178,20 @@ function reportError(string $message): never { case 'Music': $Validate->setFields([ ['groupid', false, 'number', 'Group ID was not numeric'], - ['media', true, 'inarray','Please select a valid media.', ['inarray'=>MEDIA]], + ['media', true, 'inarray','Please select a valid media.', ['inarray' => MEDIA]], ['remaster_title', false, 'string','Remaster title must be between 1 and 80 characters.', ['range' => [1, 80]]], ['remaster_record_label', false, 'string','Remaster record label must be between 1 and 80 characters.', ['range' => [1, 80]]], ['remaster_catalogue_number', false, 'string','Remaster catalogue number must be between 1 and 80 characters.', ['range' => [1, 80]]], ]); if (!$Properties['GroupID']) { $Validate->setFields([ - ['year', true, 'number','The year of the original release must be entered.', ['length'=>40]], - ['releasetype', true, 'inarray','Please select a valid release type.', ['inarray'=>array_keys($releaseTypes)]], + ['year', true, 'number','The year of the original release must be entered.', ['length' => 40]], + ['releasetype', true, 'inarray','Please select a valid release type.', ['inarray' => array_keys($releaseTypes)]], ['record_label', false, 'string','Record label must be between 1 and 80 characters.', ['range' => [1, 80]]], ['catalogue_number', false, 'string','Catalogue Number must be between 1 and 80 characters.', ['range' => [1, 80]]], ]); if ($Properties['Media'] == 'CD' && !$Properties['Remastered']) { - $Validate->setField('year', true, 'number', 'You have selected a year for an album that predates the media you say it was created on.', ['minlength'=>1982]); + $Validate->setField('year', true, 'number', 'You have selected a year for an album that predates the media you say it was created on.', ['minlength' => 1982]); } } @@ -447,7 +447,7 @@ function reportError(string $message): never { defined('AJAX') ? (string)json_encode( ['The torrent contained one or more files with too long a name', ['list' => $TooLongPaths]], - JSON_INVALID_UTF8_SUBSTITUTE|JSON_PARTIAL_OUTPUT_ON_ERROR + JSON_INVALID_UTF8_SUBSTITUTE | JSON_PARTIAL_OUTPUT_ON_ERROR ) : ('The torrent contained one or more files with too long a name:

    Edit link() ?>

    - - + + @@ -255,19 +258,25 @@ public function music_form(array $GenreTags, \Gazelle\Manager\TGroup $manager):
    Edition information: - onclick="Remaster(); CheckYear();" /> + onclick="Remaster(); CheckYear();" /> -
    /> + ?>" />

    Title of the edition (e.g. "Deluxe Edition" or "Remastered").

    /> + ?>" />

    This is for the record label of the edition. It may differ from the original.

    Catalogue number: /> + ?>" />

    This is for the catalogue number of the edition.

    Scene: - /> + />
    Showcase:
    Log/cue: - />
    - />
    + />
    + />
    Bad tags: /> />
    Bad folder names: /> />
    Bad file names: /> />
    Missing lineage: /> />
    Cassette approved: /> />
    Lossy master approved: /> />
    Lossy web approved: /> />
    Leechers
    Search in: - isBodySearch()) { echo ' checked="checked"'; } ?> /> + isBodySearch()) { +echo ' checked="checked"'; } ?> /> - isBodySearch()) { echo ' checked="checked"'; } ?> /> + isBodySearch()) { +echo ' checked="checked"'; } ?> />
    Post created: After: @@ -214,7 +217,8 @@ isBodySearch()) { ?> - (Show) "> + (Show) "> diff --git a/sections/forums/take_reply.php b/sections/forums/take_reply.php index 2a7a88de7..33ecd3b60 100644 --- a/sections/forums/take_reply.php +++ b/sections/forums/take_reply.php @@ -12,7 +12,7 @@ $threadId = $thread->id(); $forum = $thread->forum(); -if (!$Viewer->readAccess($forum)|| !$Viewer->writeAccess($forum) || $thread->isLocked() && !$Viewer->permitted('site_moderate_forums')) { +if (!$Viewer->readAccess($forum) || !$Viewer->writeAccess($forum) || $thread->isLocked() && !$Viewer->permitted('site_moderate_forums')) { error(403); } diff --git a/sections/forums/thread.php b/sections/forums/thread.php index b7a43438e..67ff976ef 100644 --- a/sections/forums/thread.php +++ b/sections/forums/thread.php @@ -47,7 +47,7 @@ $PerPage = $Viewer->postsPerPage(); //Post links utilize the catalogue & key params to prevent issues with custom posts per page -$PostNum = match(true) { +$PostNum = match (true) { isset($_GET['post']) => (int)$_GET['post'], $post && !$post->isSticky() => $post->priorPostTotal(), default => 1, @@ -79,7 +79,7 @@ $isSubscribed = (new Gazelle\User\Subscription($Viewer))->isSubscribed($threadId); if ($isSubscribed) { - $Cache->delete_value('subscriptions_user_new_'.$Viewer->id()); + $Cache->delete_value('subscriptions_user_new_' . $Viewer->id()); } $userMan = new Gazelle\Manager\User; @@ -113,8 +113,11 @@ } ?>
    -
    PollisClosed()) { echo ' [Closed]'; } ?>isFeatured()) { echo ' [Featured]'; } ?> View
    -
    +
    PollisClosed()) { +echo ' [Closed]'; } ?>isFeatured()) { +echo ' [Featured]'; } ?> View
    +

    question())?>

    isClosed() || $thread->isLocked()) { ?>
      @@ -334,7 +337,8 @@ render(['user' => $author, 'viewer' => $Viewer]) ?>
    showAvatars()) { echo ' colspan="2"'; } ?>> + showAvatars()) { +echo ' colspan="2"'; } ?>>
    @@ -429,7 +433,8 @@
    - isPinned()) { echo ' checked="checked"'; } ?> tabindex="4" /> + isPinned()) { +echo ' checked="checked"'; } ?> tabindex="4" />
    - isLocked()) { echo ' checked="checked"'; } ?> tabindex="6" /> + isLocked()) { +echo ' checked="checked"'; } ?> tabindex="6" />
    Link(s) to images ' (Required)', 'optional' => ' (Optional)', @@ -59,7 +59,7 @@
    Link(s) to external source ' (Required)', 'optional' => ' (Optional)', default => '', @@ -78,7 +78,7 @@
    Permalink to other relevant torrent(s) ' (Required)', 'optional' => ' (Optional)', default => '', diff --git a/sections/reportsv2/ajax_take_pm.php b/sections/reportsv2/ajax_take_pm.php index 4d2992789..16db3ef1f 100644 --- a/sections/reportsv2/ajax_take_pm.php +++ b/sections/reportsv2/ajax_take_pm.php @@ -29,7 +29,7 @@ $reportType = (new Gazelle\Manager\Torrent\ReportType)->findByType($_POST['resolve_type'] ?? ''); -switch($_POST['pm_type']) { +switch ($_POST['pm_type']) { case 'Uploader': $ToID = (int)$_POST['uploaderid']; if ($Report) { diff --git a/sections/reportsv2/ajax_update_resolve.php b/sections/reportsv2/ajax_update_resolve.php index b9e98c31b..11fdd3bee 100644 --- a/sections/reportsv2/ajax_update_resolve.php +++ b/sections/reportsv2/ajax_update_resolve.php @@ -22,4 +22,3 @@ 'new' => $reportType->type(), 'success' => $report->changeType($reportType), ]); - diff --git a/sections/reportsv2/report.php b/sections/reportsv2/report.php index 672530fcf..5090c8c43 100644 --- a/sections/reportsv2/report.php +++ b/sections/reportsv2/report.php @@ -70,7 +70,8 @@
    Uploaded by uploader()->link() ?> created()) ?> diff --git a/sections/reportsv2/search.php b/sections/reportsv2/search.php index 0b618b5b3..aa38a287e 100644 --- a/sections/reportsv2/search.php +++ b/sections/reportsv2/search.php @@ -19,7 +19,7 @@ } } -foreach(['reporter', 'handler', 'uploader'] as $role) { +foreach (['reporter', 'handler', 'uploader'] as $role) { if (isset($_GET[$role]) && preg_match('/(@?[\w.-]+)/', $_GET[$role], $match)) { $user = $userMan->find($match[1]); if (is_null($user)) { diff --git a/sections/reportsv2/takeresolve.php b/sections/reportsv2/takeresolve.php index 404ad5b59..ceb1058d7 100644 --- a/sections/reportsv2/takeresolve.php +++ b/sections/reportsv2/takeresolve.php @@ -67,19 +67,15 @@ if ($_POST['resolve_type'] === 'tags_lots') { $report->addTorrentFlag(Gazelle\TorrentFlag::badTag, $Viewer); $SendPM = true; -} -elseif ($_POST['resolve_type'] === 'folders_bad') { +} elseif ($_POST['resolve_type'] === 'folders_bad') { $report->addTorrentFlag(Gazelle\TorrentFlag::badFolder, $Viewer); $SendPM = true; -} -elseif ($_POST['resolve_type'] === 'filename') { +} elseif ($_POST['resolve_type'] === 'filename') { $report->addTorrentFlag(Gazelle\TorrentFlag::badFile, $Viewer); $SendPM = true; -} -elseif ($_POST['resolve_type'] === 'lineage') { +} elseif ($_POST['resolve_type'] === 'lineage') { $report->addTorrentFlag(Gazelle\TorrentFlag::noLineage, $Viewer); -} -elseif ($_POST['resolve_type'] === 'lossyapproval') { +} elseif ($_POST['resolve_type'] === 'lossyapproval') { $report->addTorrentFlag(Gazelle\TorrentFlag::lossyMaster, $Viewer); } @@ -136,14 +132,14 @@ } else { $staffNote = null; if ($revokeUpload) { - $staffNote = 'Upload privileges removed by '.$Viewer->username() + $staffNote = 'Upload privileges removed by ' . $Viewer->username() . "\nReason: Uploader of torrent ($torrentId) $name which was [url=" . $report->url() . "]resolved with the preset: {$reportTypeName}[/url]."; } if ($adminMessage) { // They did nothing of note, but still want to mark it (Or upload and mark) if (!$revokeUpload) { - $staffNote = "Torrent ($torrentId) $name [url=". $report->url() . "]was reported[/url]: $adminMessage"; + $staffNote = "Torrent ($torrentId) $name [url=" . $report->url() . "]was reported[/url]: $adminMessage"; } else { $staffNote .= ", mod note: $adminMessage"; } diff --git a/sections/requests/new_edit.php b/sections/requests/new_edit.php index 3f3d28fc7..bd5502cf0 100644 --- a/sections/requests/new_edit.php +++ b/sections/requests/new_edit.php @@ -182,7 +182,8 @@ - + + +
    = 100) { $LogCue .= ' (100%)'; } else { - $LogCue .= ' (>= '.$MinLogScore.'%)'; + $LogCue .= ' (>= ' . $MinLogScore . '%)'; } } } @@ -383,7 +383,7 @@ foreach ($Artists as $Artist) { $artistMan->addToRequest($Artist['id'], $Artist['aliasid'], $role); $Cache->increment('stats_album_count'); - $Cache->delete_value('artists_requests_'.$Artist['id']); + $Cache->delete_value('artists_requests_' . $Artist['id']); } } diff --git a/sections/requests/take_vote.php b/sections/requests/take_vote.php index 771be4295..8b64f47a5 100644 --- a/sections/requests/take_vote.php +++ b/sections/requests/take_vote.php @@ -13,7 +13,7 @@ echo "missing"; } elseif ($request->isFilled()) { echo "filled"; -} elseif(!$request->vote($Viewer, max((int)($_GET['amount'] ?? 0), REQUEST_MIN * 1024 * 1024))) { +} elseif (!$request->vote($Viewer, max((int)($_GET['amount'] ?? 0), REQUEST_MIN * 1024 * 1024))) { echo "bankrupt"; } else { echo "success"; diff --git a/sections/rules/index.php b/sections/rules/index.php index 48105a7e1..cfbd7025a 100644 --- a/sections/rules/index.php +++ b/sections/rules/index.php @@ -9,7 +9,7 @@ 'list' => (new Gazelle\Manager\ClientWhitelist)->list(), ]); break; - case 'collages'; + case 'collages': echo $Twig->render('rules/collage.twig'); break; case 'ratio': @@ -28,7 +28,7 @@ 'level_10' => ($b >= 100 * $GiB) ? 'a' : 'b', ]); break; - case 'requests'; + case 'requests': echo $Twig->render('rules/request.twig'); break; case 'tag': diff --git a/sections/staff/index.php b/sections/staff/index.php index fee36f411..0e060eeab 100644 --- a/sections/staff/index.php +++ b/sections/staff/index.php @@ -4,7 +4,7 @@ $classList = $userMan->classList(); echo $Twig->render('staff/index.twig', [ - 'hidden'=> true, + 'hidden' => true, 'reply' => new Gazelle\Util\Textarea('quickpost', ''), 'fls' => $userMan->flsList(), 'staff' => $userMan->staffListGrouped(), diff --git a/sections/staffpm/index.php b/sections/staffpm/index.php index 415e8c567..7d006c500 100644 --- a/sections/staffpm/index.php +++ b/sections/staffpm/index.php @@ -44,6 +44,6 @@ require('user_inbox.php'); break; default: - require($Viewer->isStaffPMReader()? 'staff_inbox.php' : 'user_inbox.php'); + require($Viewer->isStaffPMReader() ? 'staff_inbox.php' : 'user_inbox.php'); break; } diff --git a/sections/staffpm/staff_inbox.php b/sections/staffpm/staff_inbox.php index 74641e0f9..5ae7bfdd2 100644 --- a/sections/staffpm/staff_inbox.php +++ b/sections/staffpm/staff_inbox.php @@ -55,7 +55,7 @@ if ($Viewer->effectiveClass() >= $Classes[MOD]['Level']) { $cond[] = 'spc.Level >= ?'; $args[] = $Classes[MOD]['Level']; - } else if ($Viewer->effectiveClass() == $Classes[FORUM_MOD]['Level']) { + } elseif ($Viewer->effectiveClass() == $Classes[FORUM_MOD]['Level']) { $cond[] = 'spc.Level >= ?'; $args[] = $Classes[FORUM_MOD]['Level']; } diff --git a/sections/tools/data/site_info.php b/sections/tools/data/site_info.php index 871c678f1..906d206af 100644 --- a/sections/tools/data/site_info.php +++ b/sections/tools/data/site_info.php @@ -4,11 +4,11 @@ error(403); } -function uid (int $id): string { +function uid(int $id): string { return sprintf("%s(%d)", posix_getpwuid($id)['name'], $id); } -function gid (int $id): string { +function gid(int $id): string { return sprintf("%s(%d)", posix_getgrgid($id)['name'], $id); } diff --git a/sections/tools/development/database_specifics.php b/sections/tools/development/database_specifics.php index 380b9d4b6..8cefa10a6 100644 --- a/sections/tools/development/database_specifics.php +++ b/sections/tools/development/database_specifics.php @@ -36,7 +36,7 @@ $orderDir = $header->getOrderDir(); $mode = $_GET['mode'] ?? 'show'; -switch($mode) { +switch ($mode) { case 'show': $tableColumn = 'table_name'; $where = ''; diff --git a/sections/tools/development/periodic_alter.php b/sections/tools/development/periodic_alter.php index 1282a701b..5e1121609 100644 --- a/sections/tools/development/periodic_alter.php +++ b/sections/tools/development/periodic_alter.php @@ -26,7 +26,7 @@ $err = $Val->validate($p) ? false : $Val->errorMessage(); if (!$scheduler::isClassValid($p['classname'])) { - $err = "Couldn't import class ".$p['classname']; + $err = "Couldn't import class " . $p['classname']; } if ($err) { diff --git a/sections/tools/development/periodic_run.php b/sections/tools/development/periodic_run.php index 513f5b56e..dde3ee9c8 100644 --- a/sections/tools/development/periodic_run.php +++ b/sections/tools/development/periodic_run.php @@ -21,4 +21,3 @@ 'output' => $output, 'processed' => $processed, ]); - diff --git a/sections/tools/development/periodic_view.php b/sections/tools/development/periodic_view.php index 329c37a1f..387ec1e16 100644 --- a/sections/tools/development/periodic_view.php +++ b/sections/tools/development/periodic_view.php @@ -16,6 +16,6 @@ } echo $Twig->render('admin/scheduler/view.twig', [ - 'task_list'=> $scheduler->getTaskDetails(), + 'task_list' => $scheduler->getTaskDetails(), 'viewer' => $Viewer, ]); diff --git a/sections/tools/finances/donation_log.php b/sections/tools/finances/donation_log.php index 6ff32f19b..80803b77c 100644 --- a/sections/tools/finances/donation_log.php +++ b/sections/tools/finances/donation_log.php @@ -19,7 +19,7 @@ $timeline = $donorMan->timeline(); echo $Twig->render('admin/donation-log.twig', [ - 'after' => $_GET['after_date'] ?? date('Y-m-d', (int)date('U') - (int)(86400*365.25)), + 'after' => $_GET['after_date'] ?? date('Y-m-d', (int)date('U') - (int)(86400 * 365.25)), 'before' => $_GET['before_date'] ?? date('Y-m-d'), 'amount' => array_column($timeline, 'Amount'), 'month' => array_column($timeline, 'Month'), diff --git a/sections/tools/index.php b/sections/tools/index.php index 8a3abdbeb..670681efd 100644 --- a/sections/tools/index.php +++ b/sections/tools/index.php @@ -233,8 +233,10 @@ case 'donor_rewards': require_once('finances/donor_rewards.php'); break; + case 'payment_alter': require_once('finances/payment_alter.php'); + break; case 'payment_list': require_once('finances/payment_list.php'); diff --git a/sections/tools/managers/ajax_take_enable_request.php b/sections/tools/managers/ajax_take_enable_request.php index 42eca44e4..3c9661660 100644 --- a/sections/tools/managers/ajax_take_enable_request.php +++ b/sections/tools/managers/ajax_take_enable_request.php @@ -15,8 +15,8 @@ } switch ($_GET['type'] ?? '') { - case "resolve"; - $status = match(trim($_GET['status' ?? ''])) { + case "resolve": + $status = match (trim($_GET['status' ?? ''])) { "Approve", "Approve Selected" => Gazelle\Manager\AutoEnable::APPROVED, "Discard", "Discard Selected" => Gazelle\Manager\AutoEnable::DISCARDED, "Reject", "Reject Selected" => Gazelle\Manager\AutoEnable::DENIED, diff --git a/sections/tools/managers/bans.php b/sections/tools/managers/bans.php index f28b6fd36..558ebb71f 100644 --- a/sections/tools/managers/bans.php +++ b/sections/tools/managers/bans.php @@ -17,8 +17,8 @@ } else { //Edit & Create, Shared Validation $validator = new Gazelle\Util\Validator; $validator->setFields([ - ['start', true,'regex','You must include the starting IP address.',['regex'=>'/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/i']], - ['end', true,'regex','You must include the ending IP address.',['regex'=>'/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/i']], + ['start', true,'regex','You must include the starting IP address.',['regex' => '/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/i']], + ['end', true,'regex','You must include the ending IP address.',['regex' => '/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/i']], ['notes', true,'string','You must include the reason for the ban.'], ]); if (!$validator->validate($_POST)) { diff --git a/sections/tools/managers/create_user.php b/sections/tools/managers/create_user.php index e1b7e7c5b..c45407023 100644 --- a/sections/tools/managers/create_user.php +++ b/sections/tools/managers/create_user.php @@ -28,8 +28,7 @@ ->setIpaddr('127.0.0.1') ->setAdminComment('Created by ' . $Viewer->username() . ' via admin toolbox') ->create(); - } - catch (Gazelle\Exception\UserCreatorException $e) { + } catch (Gazelle\Exception\UserCreatorException $e) { error(match ($e->getMessage()) { 'username-invalid' => 'Specified username is forbidden', default => 'Unable to create user', diff --git a/sections/tools/managers/email_blacklist_alter.php b/sections/tools/managers/email_blacklist_alter.php index dda6fbebd..5fb753191 100644 --- a/sections/tools/managers/email_blacklist_alter.php +++ b/sections/tools/managers/email_blacklist_alter.php @@ -13,8 +13,8 @@ } } else { // Edit & Create, Shared Validation $validator = new Gazelle\Util\Validator; - $validator->setField('email', true, 'string', 'The email must be set', ['minlength'=>6]); - $validator->setField('comment', false, 'string', 'The description has a max length of 255 characters', ['maxlength'=>255]); + $validator->setField('email', true, 'string', 'The email must be set', ['minlength' => 6]); + $validator->setField('comment', false, 'string', 'The description has a max length of 255 characters', ['maxlength' => 255]); if (!$validator->validate($_POST)) { error($validator->errorMessage()); } diff --git a/sections/tools/managers/email_search.php b/sections/tools/managers/email_search.php index 909badb6b..1d424280a 100644 --- a/sections/tools/managers/email_search.php +++ b/sections/tools/managers/email_search.php @@ -13,7 +13,7 @@ $search = null; $paginator = new Gazelle\Util\Paginator(50, (int)($_GET['page'] ?? 1)); -$text = match(true) { +$text = match (true) { isset($_POST['text']) => trim($_POST['text']), isset($_GET['emaillist']) => implode("\n", explode(',', $_GET['emaillist'])), default => '', diff --git a/sections/tools/managers/forum_transitions_list.php b/sections/tools/managers/forum_transitions_list.php index 6e76e74c6..f87fbb494 100644 --- a/sections/tools/managers/forum_transitions_list.php +++ b/sections/tools/managers/forum_transitions_list.php @@ -35,7 +35,7 @@ function classList(int $Selected = 0): string { if ($Selected == $Level) { $Return .= ' selected="selected"'; } - $Return .= '>'.shortenString($Name, 20, true)."\n"; + $Return .= '>' . shortenString($Name, 20, true) . "\n"; } return $Return; } diff --git a/sections/tools/managers/ip_search.php b/sections/tools/managers/ip_search.php index e0daf9d46..ae29b967b 100644 --- a/sections/tools/managers/ip_search.php +++ b/sections/tools/managers/ip_search.php @@ -12,7 +12,7 @@ $search = null; $paginator = new Gazelle\Util\Paginator(50, (int)($_GET['page'] ?? 1)); -$text = match(true) { +$text = match (true) { isset($_POST['text']) => trim($_POST['text']), isset($_GET['iplist']) => implode("\n", array_map(fn ($ip) => long2ip((int)base_convert($ip, 36, 10)), explode(',', $_GET['iplist']))), isset($_GET['ip']) => $_GET['ip'], diff --git a/sections/tools/managers/tags_aliases.php b/sections/tools/managers/tags_aliases.php index c6ce59414..31bcf922c 100644 --- a/sections/tools/managers/tags_aliases.php +++ b/sections/tools/managers/tags_aliases.php @@ -17,8 +17,7 @@ if ($_POST['save']) { $action = 'modification'; $result = $tagMan->modifyAlias($aliasId, $_POST['badtag'], $_POST['aliastag']); - } - elseif ($_POST['delete']) { + } elseif ($_POST['delete']) { $action = 'removal'; $result = $tagMan->removeAlias($aliasId); } diff --git a/sections/tools/managers/take_mass_pm.php b/sections/tools/managers/take_mass_pm.php index 5d0fa8232..d7bc6075d 100644 --- a/sections/tools/managers/take_mass_pm.php +++ b/sections/tools/managers/take_mass_pm.php @@ -25,7 +25,7 @@ $userMan = new Gazelle\Manager\User; $subject = trim($_POST['subject']); $body = trim($_POST['body']); -while([$userId] = $db->next_record()) { +while ([$userId] = $db->next_record()) { $userMan->sendPM($userId, $fromId, $subject, $body); } diff --git a/sections/tools/managers/tor_node.php b/sections/tools/managers/tor_node.php index a0be83868..dedbabc18 100644 --- a/sections/tools/managers/tor_node.php +++ b/sections/tools/managers/tor_node.php @@ -8,7 +8,7 @@ if (isset($_POST['exitlist'])) { authorize(); - $tor->add($_POST['exitlist']); + $tor->add($_POST['exitlist']); } echo $Twig->render('admin/tor_node.twig', [ diff --git a/sections/tools/sandboxes/db_sandbox.php b/sections/tools/sandboxes/db_sandbox.php index d8af25068..20fdad309 100644 --- a/sections/tools/sandboxes/db_sandbox.php +++ b/sections/tools/sandboxes/db_sandbox.php @@ -30,7 +30,7 @@ $db = Gazelle\DB::DB(); $db->prepared_query($query); $result = $db->to_array(false, MYSQLI_ASSOC, false); - } catch (\Exception|\Error $e) { + } catch (\Exception | \Error $e) { $error = $e->getMessage(); } } diff --git a/sections/tools/sandboxes/referral_sandbox.php b/sections/tools/sandboxes/referral_sandbox.php index 2688724c7..330f872ea 100644 --- a/sections/tools/sandboxes/referral_sandbox.php +++ b/sections/tools/sandboxes/referral_sandbox.php @@ -134,7 +134,7 @@

    DB key not loaded - accounts suspended

    - +

    Auto

    No referral accounts found.

    diff --git a/sections/tools/services/get_cc.php b/sections/tools/services/get_cc.php index 5d522abc9..52953daf2 100644 --- a/sections/tools/services/get_cc.php +++ b/sections/tools/services/get_cc.php @@ -9,8 +9,8 @@ exit; } -header('Expires: '.date('D, d-M-Y H:i:s \U\T\C', time() + 3600 * 24 * 120)); //120 days -header('Last-Modified: '.date('D, d-M-Y H:i:s \U\T\C', time())); +header('Expires: ' . date('D, d-M-Y H:i:s \U\T\C', time() + 3600 * 24 * 120)); //120 days +header('Last-Modified: ' . date('D, d-M-Y H:i:s \U\T\C', time())); if (empty($_GET['ip'])) { die('Invalid IP address.'); diff --git a/sections/top10/index.php b/sections/top10/index.php index 51fb112c0..2330c2f68 100644 --- a/sections/top10/index.php +++ b/sections/top10/index.php @@ -5,7 +5,7 @@ exit(); } -require_once(match($_GET['type'] ?? 'torrents') { +require_once(match ($_GET['type'] ?? 'torrents') { 'donors' => 'donors.php', 'history' => 'history.php', 'lastfm' => 'lastfm.php', diff --git a/sections/top10/tags.php b/sections/top10/tags.php index 7063398d6..991d50d6c 100644 --- a/sections/top10/tags.php +++ b/sections/top10/tags.php @@ -48,21 +48,26 @@ function generate_tag_table(string $caption, string $tag, array $details, int $l $URLString = 'torrents.php?taglist='; } ?> -

    Top +

    Top + case 100: + ?> - Top 10 - Top 100 - Top 250 - + - Top 10 - Top 100 - Top 250 - + - Top 10 - Top 100 - Top 250 diff --git a/sections/top10/torrents.php b/sections/top10/torrents.php index 2aeb4e446..08265912f 100644 --- a/sections/top10/torrents.php +++ b/sections/top10/torrents.php @@ -126,7 +126,8 @@

    Tags (comma-separated): -   +   />   />
    Year: - + to - +
    @@ -492,7 +493,7 @@ $total = count($folderClash); if ($total > 1) { ?> - The folder of this upload clashes with other upload.
    + The folder of this upload clashes with other upload.
    Downloading two or more uploads to the same folder may result in corrupted files.
      findById((int)($_REQUEST['id'] ?? 0)); if (is_null($torrent)) { diff --git a/sections/torrents/edit.php b/sections/torrents/edit.php index 124eafe87..d9fc7b73c 100644 --- a/sections/torrents/edit.php +++ b/sections/torrents/edit.php @@ -78,7 +78,7 @@ ); $uploadForm->setCategoryId($categoryId); echo $uploadForm->head(); - echo match($categoryName) { + echo match ($categoryName) { 'Audiobooks', 'Comedy' => $uploadForm->audiobook_form(), 'Applications', 'Comics', 'E-Books', 'E-Learning Videos' => $uploadForm->simple_form(), default => $uploadForm->music_form( diff --git a/sections/torrents/manage_artists.php b/sections/torrents/manage_artists.php index dd66537dd..6a6ba540e 100644 --- a/sections/torrents/manage_artists.php +++ b/sections/torrents/manage_artists.php @@ -77,8 +77,7 @@ foreach ($EmptyArtists as $ArtistID) { (new Gazelle\Artist($ArtistID))->remove($Viewer, $logger); } - } - else { + } else { $NewImportance = (int)$_POST['importance']; if ($NewImportance === 0 || !isset(ARTIST_TYPE[$NewImportance])) { error(0); diff --git a/sections/torrents/reseed.php b/sections/torrents/reseed.php index 5abf9fa0a..a853cc827 100644 --- a/sections/torrents/reseed.php +++ b/sections/torrents/reseed.php @@ -6,9 +6,9 @@ } if (!$Viewer->permitted('users_mod')) { - match(true) { - is_null($torrent->lastActiveDate()) && !is_null($torrent->lastReseedRequestDate()) => error('There was already a re-seed request for this torrent within the past ' .RESEED_NEVER_ACTIVE_TORRENT. ' days.'), - !is_null($torrent->lastReseedRequestDate()) => error('There was already a re-seed request for this torrent within the past ' .RESEED_TORRENT. ' days.'), + match (true) { + is_null($torrent->lastActiveDate()) && !is_null($torrent->lastReseedRequestDate()) => error('There was already a re-seed request for this torrent within the past ' . RESEED_NEVER_ACTIVE_TORRENT . ' days.'), + !is_null($torrent->lastReseedRequestDate()) => error('There was already a re-seed request for this torrent within the past ' . RESEED_TORRENT . ' days.'), default => false, }; } diff --git a/sections/torrents/take_editgroup.php b/sections/torrents/take_editgroup.php index bdfde76d3..0d79093d1 100644 --- a/sections/torrents/take_editgroup.php +++ b/sections/torrents/take_editgroup.php @@ -53,7 +53,7 @@ $showcase = isset($_POST['vanity_house']) ? 1 : 0; if ($tgroup->isShowcase() != $showcase) { $tgroup->setField('VanityHouse', $showcase); - $logInfo[] = 'Vanity House status changed to '. ($showcase ? 'true' : 'false'); + $logInfo[] = 'Vanity House status changed to ' . ($showcase ? 'true' : 'false'); } } diff --git a/sections/torrents/takeedit.php b/sections/torrents/takeedit.php index f479b17fe..bc3532e4a 100644 --- a/sections/torrents/takeedit.php +++ b/sections/torrents/takeedit.php @@ -140,7 +140,7 @@ if (!$Err && isset($Properties['Image'])) { /** @phpstan-ignore-line */ // Strip out Amazon's padding if (preg_match('/(http:\/\/ecx.images-amazon.com\/images\/.+)(\._.*_\.jpg)/i', $Properties['Image'], $match)) { - $Properties['Image'] = $match[1].'.jpg'; + $Properties['Image'] = $match[1] . '.jpg'; } if (!preg_match(IMAGE_REGEXP, $Properties['Image'])) { @@ -194,7 +194,7 @@ if ($logfileSummary->total()) { $torrentLogManager = new Gazelle\Manager\TorrentLog(new Gazelle\File\RipLog, new Gazelle\File\RipLogHTML); $checkerVersion = Logchecker::getLogcheckerVersion(); - foreach($logfileSummary->all() as $logfile) { + foreach ($logfileSummary->all() as $logfile) { $torrentLogManager->create($torrent, $logfile, $checkerVersion); } $torrent->modifyLogscore(); diff --git a/sections/torrents/user.php b/sections/torrents/user.php index f4cd73f43..103853434 100644 --- a/sections/torrents/user.php +++ b/sections/torrents/user.php @@ -357,7 +357,7 @@ list(); - foreach ($releaseTypes as $id=>$type) { + foreach ($releaseTypes as $id => $type) { ?> @@ -453,7 +453,8 @@ $x++; ?>
    - checked="checked" /> + checked="checked" />