mirror of
https://github.com/OPSnet/Gazelle.git
synced 2026-01-16 18:04:34 -05:00
more phpcs rules
This commit is contained in:
31
.phpcs.xml
31
.phpcs.xml
@@ -39,8 +39,6 @@
|
||||
<exclude name="Squiz.WhiteSpace.ScopeClosingBrace.Indent" />
|
||||
</rule>
|
||||
|
||||
<rule ref="Generic.Arrays.DisallowLongArraySyntax" />
|
||||
|
||||
<rule ref="PSR1.Classes.ClassDeclaration.MissingNamespace">
|
||||
<exclude-pattern>classes/*</exclude-pattern>
|
||||
<exclude-pattern>misc/phinx/*</exclude-pattern>
|
||||
@@ -62,5 +60,34 @@
|
||||
<type>warning</type>
|
||||
</rule>
|
||||
|
||||
<rule ref="Generic.Arrays.DisallowLongArraySyntax" />
|
||||
<rule ref="Generic.CodeAnalysis.EmptyStatement" />
|
||||
<rule ref="Generic.CodeAnalysis.ForLoopShouldBeWhileLoop" />
|
||||
<rule ref="Generic.CodeAnalysis.JumbledIncrementer" />
|
||||
<rule ref="Generic.CodeAnalysis.UnconditionalIfStatement" />
|
||||
<rule ref="Generic.CodeAnalysis.UnusedFunctionParameter" />
|
||||
<rule ref="Generic.CodeAnalysis.UselessOverridingMethod" />
|
||||
<rule ref="Generic.Files.LineEndings" />
|
||||
<rule ref="Generic.Files.OneClassPerFile" />
|
||||
<rule ref="Generic.Formatting.NoSpaceAfterCast" />
|
||||
<rule ref="Generic.Functions.OpeningFunctionBraceKernighanRitchie" />
|
||||
<rule ref="Generic.PHP.Syntax" />
|
||||
|
||||
<rule ref="PEAR.Files.IncludingFile" />
|
||||
|
||||
<rule ref="Squiz.ControlStructures.ForEachLoopDeclaration" />
|
||||
<rule ref="Squiz.ControlStructures.ForLoopDeclaration" />
|
||||
<rule ref="Squiz.PHP.NonExecutableCode" />
|
||||
<rule ref="Squiz.WhiteSpace.SemicolonSpacing" />
|
||||
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace" />
|
||||
|
||||
<rule ref="Squiz.WhiteSpace.FunctionSpacing">
|
||||
<properties>
|
||||
<property name="spacing" value="1" />
|
||||
<property name="spacingBeforeFirst" value="0" />
|
||||
<property name="spacingAfterLast" value="0" />
|
||||
</properties>
|
||||
</rule>
|
||||
|
||||
<rule ref="Zend.Files.ClosingTag" />
|
||||
</ruleset>
|
||||
|
||||
10
Makefile
10
Makefile
@@ -39,7 +39,7 @@ build-css:
|
||||
|
||||
.PHONY: check-php
|
||||
check-php:
|
||||
git status | awk '/(modified|new file):.*\.php$$/ {print $$NF}' | xargs -n1 php -l
|
||||
git status | awk '/(modified|new file):.*\.php$$/ {print $$NF}' | xargs php -l
|
||||
|
||||
.PHONY: composer-dev-update
|
||||
composer-dev-update:
|
||||
@@ -79,7 +79,13 @@ lint-js:
|
||||
|
||||
.PHONY: lint-php
|
||||
lint-php:
|
||||
find . -path vendor -prune -o -path node_modules -prune -o -path misc/docker -prune -o -type f -name '*.php' -print0 | xargs -0 -n1 -P4 php -l -n | grep -v '^No syntax errors detected in' || true
|
||||
find . -path ./vendor -prune \
|
||||
-o -path ./cache -prune \
|
||||
-o -path ./node_modules -prune \
|
||||
-o -path ./misc/docker -prune \
|
||||
-o -type f -name '*.php' \
|
||||
print0 \
|
||||
| xargs -0 php -l -n | grep -v '^No syntax errors detected in' || true
|
||||
vendor/bin/phpcs -p --report-width=256
|
||||
vendor/bin/phpstan analyse --memory-limit=1024M --configuration=misc/phpstan.neon
|
||||
|
||||
|
||||
@@ -16,8 +16,14 @@ class Applicant extends BaseObject {
|
||||
unset($this->info);
|
||||
return $this;
|
||||
}
|
||||
public function link(): string { return sprintf('<a href="%s">%s</a>', $this->url(), html_escape($this->role()->title())); }
|
||||
public function location(): string { return 'apply.php?action=view&id=' . $this->id; }
|
||||
|
||||
public function link(): string {
|
||||
return sprintf('<a href="%s">%s</a>', $this->url(), html_escape($this->role()->title()));
|
||||
}
|
||||
|
||||
public function location(): string {
|
||||
return 'apply.php?action=view&id=' . $this->id;
|
||||
}
|
||||
|
||||
public function info(): array {
|
||||
if (isset($this->info)) {
|
||||
|
||||
@@ -11,8 +11,14 @@ class ApplicantRole extends BaseObject {
|
||||
unset($this->info);
|
||||
return $this;
|
||||
}
|
||||
public function link(): string { return sprintf('<a href="%s">%s</a>', $this->url(), html_escape($this->title())); }
|
||||
public function location(): string { return 'apply.php?action=view&id=' . $this->id; }
|
||||
|
||||
public function link(): string {
|
||||
return sprintf('<a href="%s">%s</a>', $this->url(), html_escape($this->title()));
|
||||
}
|
||||
|
||||
public function location(): string {
|
||||
return 'apply.php?action=view&id=' . $this->id;
|
||||
}
|
||||
|
||||
public function info(): array {
|
||||
if (isset($this->info)) {
|
||||
|
||||
@@ -53,8 +53,13 @@ class Artist extends BaseObject implements CollageEntry {
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function link(): string { return sprintf('<a href="%s">%s</a>', $this->url(), display_str($this->name())); }
|
||||
public function location(): string { return 'artist.php?id=' . $this->id; }
|
||||
public function link(): string {
|
||||
return sprintf('<a href="%s">%s</a>', $this->url(), display_str($this->name()));
|
||||
}
|
||||
|
||||
public function location(): string {
|
||||
return 'artist.php?id=' . $this->id;
|
||||
}
|
||||
|
||||
public function info(): array {
|
||||
$cacheKey = $this->cacheKey();
|
||||
@@ -909,6 +914,7 @@ class Artist extends BaseObject implements CollageEntry {
|
||||
}
|
||||
|
||||
/* STATIC METHODS - for when you do not yet have an ID, e.g. during creation */
|
||||
|
||||
/**
|
||||
* Collapse whitespace and directional markers, because people copypaste carelessly.
|
||||
* TODO: make stricter, e.g. on all whitespace characters or Unicode normalisation
|
||||
|
||||
@@ -13,7 +13,9 @@ abstract class ArtistRole extends \Gazelle\Base {
|
||||
protected array $idList;
|
||||
|
||||
abstract protected function artistListQuery(): \mysqli_result|bool;
|
||||
|
||||
abstract public function idList(): array;
|
||||
|
||||
abstract public function roleList(): array;
|
||||
|
||||
public function __construct(
|
||||
|
||||
@@ -18,7 +18,9 @@ abstract class BaseObject extends Base {
|
||||
) {}
|
||||
|
||||
abstract public function flush(): static;
|
||||
|
||||
abstract public function link(): string;
|
||||
|
||||
abstract public function location(): string;
|
||||
|
||||
public function id(): int {
|
||||
|
||||
@@ -116,8 +116,7 @@ abstract class AbstractBetter extends \Gazelle\Base {
|
||||
return "SELECT " . ($this->distinct ? 'DISTINCT ' : '') . $this->field
|
||||
. " " . $this->buildQuery()
|
||||
. " " . $this->orderBy
|
||||
. " LIMIT ? OFFSET ?"
|
||||
;
|
||||
. " LIMIT ? OFFSET ?";
|
||||
}
|
||||
|
||||
public function list(int $limit, int $offset): array {
|
||||
|
||||
@@ -114,6 +114,7 @@ class Cache extends \Memcached {
|
||||
$this->elapsed += (microtime(true) - $begin) * 1000;
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function delete_multi(array $list): array {
|
||||
$begin = microtime(true);
|
||||
if (empty($list)) {
|
||||
|
||||
115
app/Collage.php
115
app/Collage.php
@@ -39,8 +39,14 @@ class Collage extends BaseObject {
|
||||
unset($this->info);
|
||||
return $this;
|
||||
}
|
||||
public function link(): string { return sprintf('<a href="%s">%s</a>', $this->url(), display_str($this->name())); }
|
||||
public function location(): string { return 'collages.php?id=' . $this->id; }
|
||||
|
||||
public function link(): string {
|
||||
return sprintf('<a href="%s">%s</a>', $this->url(), display_str($this->name()));
|
||||
}
|
||||
|
||||
public function location(): string {
|
||||
return 'collages.php?id=' . $this->id;
|
||||
}
|
||||
|
||||
public function info(): array {
|
||||
if (isset($this->info)) {
|
||||
@@ -83,36 +89,97 @@ class Collage extends BaseObject {
|
||||
return $this->info;
|
||||
}
|
||||
|
||||
public function categoryId(): int { return $this->info()['category_id']; }
|
||||
public function description(): string { return $this->info()['description']; }
|
||||
public function maxGroups(): int { return $this->info()['group_max']; }
|
||||
public function maxGroupsPerUser(): int { return $this->info()['group_max_per_user']; }
|
||||
public function name(): string { return $this->info()['name']; }
|
||||
public function numSubscribers(): int { return $this->info()['subscriber_total']; }
|
||||
public function ownerId(): int { return $this->info()['user_id']; }
|
||||
public function tags(): array { return $this->info()['tag_list']; }
|
||||
public function updated(): ?string { return $this->info()['updated']; }
|
||||
public function categoryId(): int {
|
||||
return $this->info()['category_id'];
|
||||
}
|
||||
|
||||
public function numEntries(): int { return $this->info()['torrent_total']; }
|
||||
public function groupIds(): array { return $this->collage->groupIdList(); /** @phpstan-ignore-line */ }
|
||||
public function description(): string {
|
||||
return $this->info()['description'];
|
||||
}
|
||||
|
||||
public function isDeleted(): bool { return $this->info()['is_deleted'] === '1'; }
|
||||
public function isFeatured(): bool { return (bool)$this->info()['is_featured']; }
|
||||
public function isLocked(): bool { return $this->info()['is_locked'] == '1' || $this->lockedForUser; }
|
||||
public function isOwner(User $user): bool { return $this->info()['user_id'] === $user->id(); }
|
||||
public function isPersonal(): bool { return $this->info()['category_id'] === CollageType::personal->value; }
|
||||
public function maxGroups(): int {
|
||||
return $this->info()['group_max'];
|
||||
}
|
||||
|
||||
public function isArtist(): bool { return $this->categoryId() === CollageType::artist->value; }
|
||||
public function contributors(): array { return $this->collage->contributorList(); }
|
||||
public function maxGroupsPerUser(): int {
|
||||
return $this->info()['group_max_per_user'];
|
||||
}
|
||||
|
||||
public function numContributors(): int { return count(array_keys($this->contributors())); }
|
||||
public function numArtists(): int { return count($this->collage->artistList()); }
|
||||
public function sequence(int $entryId): int { return $this->collage->sequence($entryId); /** @phpstan-ignore-line */ }
|
||||
public function name(): string {
|
||||
return $this->info()['name'];
|
||||
}
|
||||
|
||||
public function numSubscribers(): int {
|
||||
return $this->info()['subscriber_total'];
|
||||
}
|
||||
|
||||
public function ownerId(): int {
|
||||
return $this->info()['user_id'];
|
||||
}
|
||||
|
||||
public function tags(): array {
|
||||
return $this->info()['tag_list'];
|
||||
}
|
||||
|
||||
public function updated(): ?string {
|
||||
return $this->info()['updated'];
|
||||
}
|
||||
|
||||
public function numEntries(): int {
|
||||
return $this->info()['torrent_total'];
|
||||
}
|
||||
|
||||
public function groupIds(): array {
|
||||
return $this->collage->groupIdList(); /** @phpstan-ignore-line */
|
||||
}
|
||||
|
||||
public function isDeleted(): bool {
|
||||
return $this->info()['is_deleted'] === '1';
|
||||
}
|
||||
|
||||
public function isFeatured(): bool {
|
||||
return (bool)$this->info()['is_featured'];
|
||||
}
|
||||
|
||||
public function isLocked(): bool {
|
||||
return $this->info()['is_locked'] == '1' || $this->lockedForUser;
|
||||
}
|
||||
|
||||
public function isOwner(User $user): bool {
|
||||
return $this->info()['user_id'] === $user->id();
|
||||
}
|
||||
|
||||
public function isPersonal(): bool {
|
||||
return $this->info()['category_id'] === CollageType::personal->value;
|
||||
}
|
||||
|
||||
public function isArtist(): bool {
|
||||
return $this->categoryId() === CollageType::artist->value;
|
||||
}
|
||||
|
||||
public function contributors(): array {
|
||||
return $this->collage->contributorList();
|
||||
}
|
||||
|
||||
public function numContributors(): int {
|
||||
return count(array_keys($this->contributors()));
|
||||
}
|
||||
|
||||
public function numArtists(): int {
|
||||
return count($this->collage->artistList());
|
||||
}
|
||||
|
||||
public function sequence(int $entryId): int {
|
||||
return $this->collage->sequence($entryId); /** @phpstan-ignore-line */
|
||||
}
|
||||
|
||||
public function hasAttr(string $name): bool {
|
||||
return isset($this->info()['attr'][$name]);
|
||||
}
|
||||
public function sortNewest(): bool { return $this->hasAttr('sort-newest'); }
|
||||
|
||||
public function sortNewest(): bool {
|
||||
return $this->hasAttr('sort-newest');
|
||||
}
|
||||
|
||||
public function setViewer(User $viewer): static {
|
||||
$this->viewer = $viewer;
|
||||
|
||||
@@ -11,9 +11,13 @@ abstract class AbstractCollage extends \Gazelle\Base {
|
||||
protected array $created;
|
||||
|
||||
abstract public function entryTable(): string;
|
||||
|
||||
abstract public function entryColumn(): string;
|
||||
|
||||
abstract public function entryList(): array;
|
||||
|
||||
abstract public function load(): int;
|
||||
|
||||
abstract public function rebuildTagList(): array;
|
||||
|
||||
abstract protected function flushTarget(CollageEntry $target): void;
|
||||
|
||||
@@ -5,8 +5,13 @@ namespace Gazelle\Collage;
|
||||
use Gazelle\Intf\CollageEntry;
|
||||
|
||||
class Artist extends AbstractCollage {
|
||||
public function entryTable(): string { return 'collages_artists'; }
|
||||
public function entryColumn(): string { return 'ArtistID'; }
|
||||
public function entryTable(): string {
|
||||
return 'collages_artists';
|
||||
}
|
||||
|
||||
public function entryColumn(): string {
|
||||
return 'ArtistID';
|
||||
}
|
||||
|
||||
public function load(): int {
|
||||
self::$db->prepared_query("
|
||||
|
||||
@@ -9,8 +9,13 @@ class TGroup extends AbstractCollage {
|
||||
protected array $sequence = [];
|
||||
protected array $torrentTags;
|
||||
|
||||
public function entryTable(): string { return 'collages_torrents'; }
|
||||
public function entryColumn(): string { return 'GroupID'; }
|
||||
public function entryTable(): string {
|
||||
return 'collages_torrents';
|
||||
}
|
||||
|
||||
public function entryColumn(): string {
|
||||
return 'GroupID';
|
||||
}
|
||||
|
||||
public function groupIdList(): array {
|
||||
if (!isset($this->groupIds)) {
|
||||
|
||||
@@ -57,6 +57,7 @@ abstract class Collector extends Base {
|
||||
protected float $startTime;
|
||||
|
||||
abstract public function prepare(array $list): bool;
|
||||
|
||||
abstract public function fillZip(\ZipStream\ZipStream $zip): int;
|
||||
|
||||
public function __construct(
|
||||
|
||||
@@ -12,14 +12,21 @@ abstract class AbstractComment extends \Gazelle\BaseObject {
|
||||
protected array $thread = []; // the page of comments
|
||||
|
||||
abstract public function page(): string;
|
||||
|
||||
abstract public function pageUrl(): string;
|
||||
|
||||
public function flush(): static {
|
||||
// No-op: There is no such thing as an individual comment cache
|
||||
return $this;
|
||||
}
|
||||
public function link(): string { return sprintf('<a href="%s">%s</a>', $this->url(), "Comment #" . $this->id); }
|
||||
public function location(): string { return $this->pageUrl() . "{$this->pageId}&postid={$this->id}#post{$this->id}"; }
|
||||
|
||||
public function link(): string {
|
||||
return sprintf('<a href="%s">%s</a>', $this->url(), "Comment #" . $this->id);
|
||||
}
|
||||
|
||||
public function location(): string {
|
||||
return $this->pageUrl() . "{$this->pageId}&postid={$this->id}#post{$this->id}";
|
||||
}
|
||||
|
||||
public function __construct(
|
||||
protected int $pageId,
|
||||
|
||||
@@ -16,8 +16,14 @@ class Contest extends BaseObject {
|
||||
$this->info = [];
|
||||
return $this;
|
||||
}
|
||||
public function link(): string { return "<a href=\"{$this->url()}\">{$this->name()}</a>"; }
|
||||
public function location(): string { return "contest.php?id={$this->id}"; }
|
||||
|
||||
public function link(): string {
|
||||
return "<a href=\"{$this->url()}\">{$this->name()}</a>";
|
||||
}
|
||||
|
||||
public function location(): string {
|
||||
return "contest.php?id={$this->id}";
|
||||
}
|
||||
|
||||
public function info(): array {
|
||||
if (isset($this->info) && !empty($this->info)) {
|
||||
|
||||
@@ -10,6 +10,8 @@ abstract class AbstractContest extends \Gazelle\Base {
|
||||
) {}
|
||||
|
||||
abstract public function ranker(): array;
|
||||
|
||||
abstract public function participationStats(): array;
|
||||
|
||||
abstract public function userPayout(int $enabledUserBonus, int $contestBonus, int $perEntryBonus): array;
|
||||
}
|
||||
|
||||
@@ -5,11 +5,14 @@ namespace Gazelle\Contest;
|
||||
/* how many requests filled */
|
||||
|
||||
class RequestFill extends AbstractContest {
|
||||
// phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassAfterLastUsed
|
||||
public function leaderboard(int $limit, int $offset): array {
|
||||
// TODO
|
||||
return [];
|
||||
}
|
||||
|
||||
// phpcs:enable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassAfterLastUsed
|
||||
|
||||
public function ranker(): array {
|
||||
return [
|
||||
"SELECT r.FillerID AS userid,
|
||||
|
||||
@@ -137,7 +137,7 @@ class DB extends Base {
|
||||
return [false, "condition selected 0 rows"];
|
||||
}
|
||||
} catch (DB\MysqlDuplicateKeyException) {
|
||||
// do nothing, for some reason it was already deleted
|
||||
; // do nothing, for some reason it was already deleted
|
||||
}
|
||||
|
||||
if (!$delete) {
|
||||
|
||||
@@ -101,9 +101,6 @@ set_query_id($ResultSet)
|
||||
-------------------------------------------------------------------------------------
|
||||
*///---------------------------------------------------------------------------------
|
||||
|
||||
class MysqlException extends \Exception {}
|
||||
class MysqlDuplicateKeyException extends MysqlException {}
|
||||
|
||||
class Mysql {
|
||||
public \mysqli|false $LinkID = false;
|
||||
protected \mysqli_result|false|null $QueryID = false;
|
||||
|
||||
5
app/DB/MysqlDuplicateKeyException.php
Normal file
5
app/DB/MysqlDuplicateKeyException.php
Normal file
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace Gazelle\DB;
|
||||
|
||||
class MysqlDuplicateKeyException extends MysqlException {}
|
||||
5
app/DB/MysqlException.php
Normal file
5
app/DB/MysqlException.php
Normal file
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace Gazelle\DB;
|
||||
|
||||
class MysqlException extends \Exception {}
|
||||
@@ -26,6 +26,7 @@ class Pg {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// phpcs:enable
|
||||
|
||||
public function insert(string $query, ...$args): int {
|
||||
|
||||
@@ -199,6 +199,8 @@ class Debug {
|
||||
return implode(', ', $Return);
|
||||
}
|
||||
|
||||
// phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundBeforeLastUsed
|
||||
// for $Level
|
||||
public function errorHandler(int $Level, string $Error, string $File, int $Line): bool {
|
||||
$Steps = 1; //Steps to go up in backtrace, default one
|
||||
$Call = '';
|
||||
@@ -254,6 +256,8 @@ class Debug {
|
||||
return true;
|
||||
}
|
||||
|
||||
// phpcs:enable Generic.CodeAnalysis.UnusedFunctionParameter.FoundBeforeLastUsed
|
||||
|
||||
/* Data wrappers */
|
||||
|
||||
public function errorList($Light = false): array {
|
||||
|
||||
@@ -5,9 +5,17 @@ namespace Gazelle;
|
||||
class ErrorLog extends BaseObject {
|
||||
final public const tableName = 'error_log';
|
||||
|
||||
public function flush(): static { return $this; }
|
||||
public function link(): string { return ''; }
|
||||
public function location(): string { return ''; }
|
||||
public function flush(): static {
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function link(): string {
|
||||
return '';
|
||||
}
|
||||
|
||||
public function location(): string {
|
||||
return '';
|
||||
}
|
||||
|
||||
public function info(): array {
|
||||
if (isset($this->info) && !empty($this->info)) {
|
||||
|
||||
@@ -20,8 +20,14 @@ class FeaturedAlbum extends BaseObject {
|
||||
self::$cache->delete_value(sprintf(self::FEATURED, $this->type->value, $this->id));
|
||||
return $this;
|
||||
}
|
||||
public function link(): string {return $this->thread()->link();}
|
||||
public function location(): string {return $this->thread()->location();}
|
||||
|
||||
public function link(): string {
|
||||
return $this->thread()->link();
|
||||
}
|
||||
|
||||
public function location(): string {
|
||||
return $this->thread()->location();
|
||||
}
|
||||
|
||||
public function info(): array {
|
||||
if (!isset($this->info)) {
|
||||
|
||||
@@ -12,8 +12,14 @@ class ForumCategory extends BaseObject {
|
||||
unset($this->info);
|
||||
return $this;
|
||||
}
|
||||
public function link(): string { return "<a href=\"{$this->location()}\">Forum Categories</a>"; }
|
||||
public function location(): string { return "tools.php?action=categories"; }
|
||||
|
||||
public function link(): string {
|
||||
return "<a href=\"{$this->location()}\">Forum Categories</a>";
|
||||
}
|
||||
|
||||
public function location(): string {
|
||||
return "tools.php?action=categories";
|
||||
}
|
||||
|
||||
public function info(): array {
|
||||
if (isset($this->info)) {
|
||||
|
||||
@@ -15,8 +15,14 @@ class ForumPoll extends BaseObject {
|
||||
unset($this->info);
|
||||
return $this;
|
||||
}
|
||||
public function link(): string { return $this->thread()->link(); }
|
||||
public function location(): string { return "forums.php?action=viewthread&threadid={$this->id}"; }
|
||||
|
||||
public function link(): string {
|
||||
return $this->thread()->link();
|
||||
}
|
||||
|
||||
public function location(): string {
|
||||
return "forums.php?action=viewthread&threadid={$this->id}";
|
||||
}
|
||||
|
||||
public function thread(): ForumThread {
|
||||
return new ForumThread($this->id);
|
||||
|
||||
@@ -13,8 +13,13 @@ class ForumPost extends BaseObject {
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function link(): string { return sprintf('<a href="%s">%s</a>', $this->url(), "Post #{$this->id}"); }
|
||||
public function location(): string { return "forums.php?action=viewthread&threadid={$this->threadId()}&postid={$this->id}#post{$this->id}"; }
|
||||
public function link(): string {
|
||||
return sprintf('<a href="%s">%s</a>', $this->url(), "Post #{$this->id}");
|
||||
}
|
||||
|
||||
public function location(): string {
|
||||
return "forums.php?action=viewthread&threadid={$this->threadId()}&postid={$this->id}#post{$this->id}";
|
||||
}
|
||||
|
||||
/**
|
||||
* Get information about a post
|
||||
|
||||
@@ -38,8 +38,13 @@ class ForumThread extends BaseObject {
|
||||
);
|
||||
}
|
||||
|
||||
public function link(): string { return sprintf('<a href="%s">%s</a>', $this->url(), display_str($this->title())); }
|
||||
public function location(): string { return "forums.php?action=viewthread&threadid={$this->id}"; }
|
||||
public function link(): string {
|
||||
return sprintf('<a href="%s">%s</a>', $this->url(), display_str($this->title()));
|
||||
}
|
||||
|
||||
public function location(): string {
|
||||
return "forums.php?action=viewthread&threadid={$this->id}";
|
||||
}
|
||||
|
||||
/**
|
||||
* Get information about a thread
|
||||
|
||||
@@ -25,8 +25,13 @@ class ForumTransition extends BaseObject {
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function link(): string { return ""; }
|
||||
public function location(): string { return "tools.php?action=forum_transitions"; }
|
||||
public function link(): string {
|
||||
return "";
|
||||
}
|
||||
|
||||
public function location(): string {
|
||||
return "tools.php?action=forum_transitions";
|
||||
}
|
||||
|
||||
public function info(): array {
|
||||
if (isset($this->info)) {
|
||||
|
||||
@@ -4,5 +4,6 @@ namespace Gazelle\Intf;
|
||||
|
||||
interface CategoryHasArtist {
|
||||
public function id(): int;
|
||||
|
||||
public function title(): string;
|
||||
}
|
||||
|
||||
@@ -8,17 +8,16 @@ use OrpheusNET\Logchecker\Check\Checksum;
|
||||
class Logfile {
|
||||
protected string $checksumState;
|
||||
protected array $details;
|
||||
protected string $filepath;
|
||||
protected string $filename;
|
||||
protected int $score;
|
||||
protected string $text;
|
||||
protected string $ripper;
|
||||
protected string $ripperVersion;
|
||||
protected string $language;
|
||||
|
||||
public function __construct(string $filepath, ?string $filename = null) {
|
||||
$this->filepath = $filepath; // where the uploaded logfile is stored
|
||||
$this->filename = $filename; // the name of the file e.g. "Artist - Album.log"
|
||||
public function __construct(
|
||||
protected string $filepath, // where the uploaded logfile is stored
|
||||
protected ?string $filename = null, // the name of the file e.g. "Artist - Album.log"
|
||||
) {
|
||||
$checker = new Logchecker();
|
||||
$checker->newFile($this->filepath);
|
||||
$checker->parse();
|
||||
@@ -31,16 +30,51 @@ class Logfile {
|
||||
$this->language = $checker->getLanguage();
|
||||
}
|
||||
|
||||
public function checksum(): bool { return $this->checksumState === Checksum::CHECKSUM_OK; }
|
||||
public function checksumState(): string { return $this->checksumState; }
|
||||
public function checksumStatus(): string { return $this->checksum() ? '1' : '0'; }
|
||||
public function details(): array { return $this->details; }
|
||||
public function detailsAsString(): string { return implode("\r\n", $this->details); }
|
||||
public function filepath(): string { return $this->filepath; }
|
||||
public function filename(): string { return $this->filename; }
|
||||
public function score(): int { return $this->score; }
|
||||
public function text(): string { return $this->text; }
|
||||
public function ripper(): string { return $this->ripper; }
|
||||
public function ripperVersion(): string { return $this->ripperVersion; }
|
||||
public function language(): string { return $this->language; }
|
||||
public function checksum(): bool {
|
||||
return $this->checksumState === Checksum::CHECKSUM_OK;
|
||||
}
|
||||
|
||||
public function checksumState(): string {
|
||||
return $this->checksumState;
|
||||
}
|
||||
|
||||
public function checksumStatus(): string {
|
||||
return $this->checksum() ? '1' : '0';
|
||||
}
|
||||
|
||||
public function details(): array {
|
||||
return $this->details;
|
||||
}
|
||||
|
||||
public function detailsAsString(): string {
|
||||
return implode("\r\n", $this->details);
|
||||
}
|
||||
|
||||
public function filepath(): string {
|
||||
return $this->filepath;
|
||||
}
|
||||
|
||||
public function filename(): string {
|
||||
return $this->filename;
|
||||
}
|
||||
|
||||
public function score(): int {
|
||||
return $this->score;
|
||||
}
|
||||
|
||||
public function text(): string {
|
||||
return $this->text;
|
||||
}
|
||||
|
||||
public function ripper(): string {
|
||||
return $this->ripper;
|
||||
}
|
||||
|
||||
public function ripperVersion(): string {
|
||||
return $this->ripperVersion;
|
||||
}
|
||||
|
||||
public function language(): string {
|
||||
return $this->language;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -203,7 +203,7 @@ class InviteSource extends \Gazelle\Base {
|
||||
* "profile" => <new profile> or '' to remove,
|
||||
* ]
|
||||
*/
|
||||
public function modifyInviteeSource(\Gazelle\User $user, array $sourceList): int {
|
||||
public function modifyInviteeSource(array $sourceList): int {
|
||||
self::$db->begin_transaction();
|
||||
$affected = 0;
|
||||
foreach ($sourceList as $source) {
|
||||
|
||||
@@ -6,12 +6,18 @@ class PM extends \Gazelle\BaseUser {
|
||||
final public const tableName = 'pm_conversations_users';
|
||||
protected const ID_KEY = 'zz_pm_%d_%d';
|
||||
|
||||
public function flush(): static {
|
||||
public function flush(): static {
|
||||
$this->user()->flush();
|
||||
return $this;
|
||||
}
|
||||
public function link(): string { return $this->user()->link(); }
|
||||
public function location(): string { return $this->user()->location(); }
|
||||
|
||||
public function link(): string {
|
||||
return $this->user()->link();
|
||||
}
|
||||
|
||||
public function location(): string {
|
||||
return $this->user()->location();
|
||||
}
|
||||
|
||||
public function findById(int $pmId): ?\Gazelle\PM {
|
||||
$key = sprintf(self::ID_KEY, $pmId, $this->user->id());
|
||||
|
||||
@@ -11,8 +11,13 @@ class SiteLog extends \Gazelle\Base {
|
||||
protected \Gazelle\Manager\User $userMan,
|
||||
) {}
|
||||
|
||||
public function totalMatches(): int { return $this->totalMatches; }
|
||||
public function result(): array { return $this->result; }
|
||||
public function totalMatches(): int {
|
||||
return $this->totalMatches;
|
||||
}
|
||||
|
||||
public function result(): array {
|
||||
return $this->result;
|
||||
}
|
||||
|
||||
public function page(int $perPage, int $offset, string $searchTerm, bool $bypassSphinx = false): array {
|
||||
if ($searchTerm === '' || $bypassSphinx) {
|
||||
|
||||
@@ -64,10 +64,13 @@ class Tag extends \Gazelle\BaseManager {
|
||||
* Check whether this name is allowed. Some tags we never want to see again.
|
||||
* TODO: implement
|
||||
*/
|
||||
// phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass
|
||||
public function validName(string $name): bool {
|
||||
return true;
|
||||
}
|
||||
|
||||
// phpcs:enable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass
|
||||
|
||||
/**
|
||||
* Get a tag ready for database input and display.
|
||||
* Trim whitespace, force to lower case, internal spaces and dashes become dots,
|
||||
@@ -414,7 +417,7 @@ class Tag extends \Gazelle\BaseManager {
|
||||
");
|
||||
$aliasList = self::$db->to_array(false, MYSQLI_ASSOC, false);
|
||||
// Unify tag aliases to be in_this_format as tags not in.this.format
|
||||
array_walk_recursive($aliasList, function (&$val, $key) {
|
||||
array_walk_recursive($aliasList, function (&$val) {
|
||||
$val = strtr($val, '.', '_');
|
||||
});
|
||||
// Clean up the array for smaller cache size
|
||||
|
||||
@@ -8,9 +8,17 @@ class NotificationFilter extends BaseObject {
|
||||
'artist', 'recordLabel', 'tag', 'notTag', 'category', 'format', 'encoding', 'media', 'user'
|
||||
];
|
||||
|
||||
public function flush(): static { return $this; }
|
||||
public function link(): string { return sprintf('<a href="%s">%s</a>', $this->url(), $this->url()); }
|
||||
public function location(): string { return 'user.php?action=notify'; }
|
||||
public function flush(): static {
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function link(): string {
|
||||
return sprintf('<a href="%s">%s</a>', $this->url(), $this->url());
|
||||
}
|
||||
|
||||
public function location(): string {
|
||||
return 'user.php?action=notify';
|
||||
}
|
||||
|
||||
public function info(): array {
|
||||
if (isset($this->info) && !empty($this->info)) {
|
||||
|
||||
@@ -9,8 +9,14 @@ class Privilege extends BaseObject {
|
||||
$this->info = [];
|
||||
return $this;
|
||||
}
|
||||
public function location(): string { return ''; }
|
||||
public function link(): string { return sprintf('<a href="%s">%s</a>', $this->url(), $this->url()); }
|
||||
|
||||
public function location(): string {
|
||||
return '';
|
||||
}
|
||||
|
||||
public function link(): string {
|
||||
return sprintf('<a href="%s">%s</a>', $this->url(), $this->url());
|
||||
}
|
||||
|
||||
public function info(): array {
|
||||
if (isset($this->info) && !empty($this->info)) {
|
||||
|
||||
@@ -11,8 +11,14 @@ class Report extends BaseObject {
|
||||
$this->info = [];
|
||||
return $this;
|
||||
}
|
||||
public function link(): string { return sprintf('<a href="%s">Report #%d</a>', $this->url(), $this->id()); }
|
||||
public function location(): string { return "reports.php?id={$this->id}#report{$this->id}"; }
|
||||
|
||||
public function link(): string {
|
||||
return sprintf('<a href="%s">Report #%d</a>', $this->url(), $this->id());
|
||||
}
|
||||
|
||||
public function location(): string {
|
||||
return "reports.php?id={$this->id}#report{$this->id}";
|
||||
}
|
||||
|
||||
public function setUserManager(Manager\User $userMan): static {
|
||||
$this->userMan = $userMan;
|
||||
|
||||
@@ -12,8 +12,11 @@ abstract class AbstractReport extends \Gazelle\Base {
|
||||
protected array $context = [];
|
||||
|
||||
abstract public function template(): string;
|
||||
|
||||
abstract public function bbLink(): string;
|
||||
|
||||
abstract public function title(): string;
|
||||
|
||||
abstract public function titlePrefix(): string;
|
||||
|
||||
public function subject(): \Gazelle\Base {
|
||||
|
||||
@@ -18,8 +18,14 @@ class ReportAuto extends BasePgObject {
|
||||
unset($this->info);
|
||||
return $this;
|
||||
}
|
||||
public function link(): string { return sprintf('<a href="%s">Auto Report #%d</a>', $this->url(), $this->id()); }
|
||||
public function location(): string { return "report_auto.php?id={$this->id}#report{$this->id}"; }
|
||||
|
||||
public function link(): string {
|
||||
return sprintf('<a href="%s">Auto Report #%d</a>', $this->url(), $this->id());
|
||||
}
|
||||
|
||||
public function location(): string {
|
||||
return "report_auto.php?id={$this->id}#report{$this->id}";
|
||||
}
|
||||
|
||||
public function info(): array {
|
||||
if (isset($this->info)) {
|
||||
|
||||
@@ -22,8 +22,14 @@ class Request extends BaseObject implements CategoryHasArtist {
|
||||
unset($this->info);
|
||||
return $this;
|
||||
}
|
||||
public function link(): string { return sprintf('<a href="%s">%s</a>', $this->url(), display_str($this->title())); }
|
||||
public function location(): string { return 'requests.php?action=view&id=' . $this->id; }
|
||||
|
||||
public function link(): string {
|
||||
return sprintf('<a href="%s">%s</a>', $this->url(), display_str($this->title()));
|
||||
}
|
||||
|
||||
public function location(): string {
|
||||
return 'requests.php?action=view&id=' . $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a title on the request page itself. If there are artists in the name,
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace Gazelle\Request;
|
||||
|
||||
abstract class AbstractValue {
|
||||
protected array $label;
|
||||
|
||||
public function __construct(
|
||||
protected bool $all = false,
|
||||
protected array $list = [],
|
||||
|
||||
@@ -5,10 +5,14 @@ namespace Gazelle;
|
||||
class RipLog extends BaseObject {
|
||||
final public const tableName = 'torrents_logs';
|
||||
|
||||
public function flush(): static { return $this; }
|
||||
public function flush(): static {
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function location(): string {
|
||||
return "view.php?type=riplog&id={$this->torrentId}.{$this->id}";
|
||||
}
|
||||
|
||||
public function link(): string {
|
||||
return "<a href=\"{$this->url()}\">Log #{$this->id}</a>";
|
||||
}
|
||||
|
||||
@@ -30,12 +30,18 @@ class Forum extends \Gazelle\BaseUser {
|
||||
|
||||
protected \Gazelle\User $viewer;
|
||||
|
||||
public function flush(): static {
|
||||
public function flush(): static {
|
||||
$this->user()->flush();
|
||||
return $this;
|
||||
}
|
||||
public function link(): string { return $this->user()->link(); }
|
||||
public function location(): string { return $this->user()->location(); }
|
||||
|
||||
public function link(): string {
|
||||
return $this->user()->link();
|
||||
}
|
||||
|
||||
public function location(): string {
|
||||
return $this->user()->location();
|
||||
}
|
||||
|
||||
public function __construct(\Gazelle\User $user) {
|
||||
parent::__construct($user);
|
||||
|
||||
@@ -16,7 +16,6 @@ class Report extends \Gazelle\Base {
|
||||
protected \Gazelle\Manager\User $userMan,
|
||||
) {}
|
||||
|
||||
|
||||
protected function configure(): void {
|
||||
if (isset($this->cond)) {
|
||||
return;
|
||||
|
||||
@@ -5,12 +5,18 @@ namespace Gazelle;
|
||||
class Staff extends BaseUser {
|
||||
final public const tableName = 'staff_blog_visits';
|
||||
|
||||
public function flush(): static {
|
||||
public function flush(): static {
|
||||
$this->user()->flush();
|
||||
return $this;
|
||||
}
|
||||
public function link(): string { return $this->user()->link(); }
|
||||
public function location(): string { return $this->user()->location(); }
|
||||
|
||||
public function link(): string {
|
||||
return $this->user()->link();
|
||||
}
|
||||
|
||||
public function location(): string {
|
||||
return $this->user()->location();
|
||||
}
|
||||
|
||||
public function blogAlert(): bool {
|
||||
if (($readTime = self::$cache->get_value('staff_blog_read_' . $this->user->id())) === false) {
|
||||
|
||||
@@ -9,8 +9,14 @@ class StaffBlog extends BaseObject {
|
||||
$this->info = [];
|
||||
return $this;
|
||||
}
|
||||
public function link(): string { return sprintf('<a href="%s">%s</a>', $this->url(), display_str($this->title())); }
|
||||
public function location(): string { return 'staffblog.php#blog' . $this->id; }
|
||||
|
||||
public function link(): string {
|
||||
return sprintf('<a href="%s">%s</a>', $this->url(), display_str($this->title()));
|
||||
}
|
||||
|
||||
public function location(): string {
|
||||
return 'staffblog.php#blog' . $this->id;
|
||||
}
|
||||
|
||||
public function info(): array {
|
||||
if (isset($this->info) && !empty($this->info)) {
|
||||
|
||||
@@ -11,8 +11,14 @@ class StaffGroup extends BaseObject {
|
||||
unset($this->info);
|
||||
return $this;
|
||||
}
|
||||
public function link(): string { return sprintf('<a href="%s" class="tooltip" title="%s">%s</a>', $this->url(), 'Staff groups', 'Staff groups'); }
|
||||
public function location(): string { return 'tools.php?action=staff_groups'; }
|
||||
|
||||
public function link(): string {
|
||||
return sprintf('<a href="%s" class="tooltip" title="%s">%s</a>', $this->url(), 'Staff groups', 'Staff groups');
|
||||
}
|
||||
|
||||
public function location(): string {
|
||||
return 'tools.php?action=staff_groups';
|
||||
}
|
||||
|
||||
/**
|
||||
* A staff group object is so trival that it never needs to be instantiated,
|
||||
|
||||
@@ -9,8 +9,14 @@ class StaffPM extends BaseObject {
|
||||
$this->info = [];
|
||||
return $this;
|
||||
}
|
||||
public function link(): string { return sprintf('<a href="%s">%s</a>', $this->url(), display_str($this->subject())); }
|
||||
public function location(): string { return 'staffpm.php?action=viewconv&id=' . $this->id; }
|
||||
|
||||
public function link(): string {
|
||||
return sprintf('<a href="%s">%s</a>', $this->url(), display_str($this->subject()));
|
||||
}
|
||||
|
||||
public function location(): string {
|
||||
return 'staffpm.php?action=viewconv&id=' . $this->id;
|
||||
}
|
||||
|
||||
public function flushUser(User $user): static {
|
||||
self::$cache->delete_multi([
|
||||
|
||||
@@ -10,8 +10,14 @@ class Artist extends \Gazelle\BaseObject {
|
||||
self::$cache->delete_value(sprintf(self::CACHE_KEY, $this->id));
|
||||
return $this;
|
||||
}
|
||||
public function link(): string { return sprintf('<a href="%s">artist %d</a>', $this->url(), $this->id()); }
|
||||
public function location(): string { return 'artist.php?id=' . $this->id; }
|
||||
|
||||
public function link(): string {
|
||||
return sprintf('<a href="%s">artist %d</a>', $this->url(), $this->id());
|
||||
}
|
||||
|
||||
public function location(): string {
|
||||
return 'artist.php?id=' . $this->id;
|
||||
}
|
||||
|
||||
public function info(): array {
|
||||
if (isset($this->info)) {
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace Gazelle\Stats;
|
||||
|
||||
class Collage extends \Gazelle\Base {
|
||||
protected const CACHE_KEY = 'stats_collages';
|
||||
|
||||
public function collageTotal(): int {
|
||||
$count = self::$cache->get_value(self::CACHE_KEY);
|
||||
if ($count === false) {
|
||||
|
||||
@@ -19,8 +19,14 @@ class TGroup extends \Gazelle\BaseObject {
|
||||
self::$cache->delete_value(sprintf(self::CACHE_GENERAL, $this->id));
|
||||
return $this;
|
||||
}
|
||||
public function link(): string { return sprintf('<a href="%s">%s</a>', $this->url(), 'Stats'); }
|
||||
public function location(): string { return 'torrents.php?id=' . $this->id; }
|
||||
|
||||
public function link(): string {
|
||||
return sprintf('<a href="%s">%s</a>', $this->url(), 'Stats');
|
||||
}
|
||||
|
||||
public function location(): string {
|
||||
return 'torrents.php?id=' . $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \Gazelle\Stats\TGroups::refresh()
|
||||
|
||||
@@ -110,16 +110,45 @@ class Torrent extends \Gazelle\Base {
|
||||
return $this->info;
|
||||
}
|
||||
|
||||
public function torrentTotal(): int { return $this->info()['torrent-total']; }
|
||||
public function totalFiles(): int { return $this->info()['total-files']; }
|
||||
public function totalSize(): int { return $this->info()['total-size']; }
|
||||
public function amount(string $interval): int { return $this->info()[$interval]['count']; }
|
||||
public function files(string $interval): int { return $this->info()[$interval]['files']; }
|
||||
public function size(string $interval): int { return $this->info()[$interval]['size']; }
|
||||
public function category(): array { return $this->info()['category']; }
|
||||
public function format(): array { return $this->info()['format']; }
|
||||
public function formatMonth(): array { return $this->info()['format-month']; }
|
||||
public function media(): array { return $this->info()['media']; }
|
||||
public function torrentTotal(): int {
|
||||
return $this->info()['torrent-total'];
|
||||
}
|
||||
|
||||
public function totalFiles(): int {
|
||||
return $this->info()['total-files'];
|
||||
}
|
||||
|
||||
public function totalSize(): int {
|
||||
return $this->info()['total-size'];
|
||||
}
|
||||
|
||||
public function amount(string $interval): int {
|
||||
return $this->info()[$interval]['count'];
|
||||
}
|
||||
|
||||
public function files(string $interval): int {
|
||||
return $this->info()[$interval]['files'];
|
||||
}
|
||||
|
||||
public function size(string $interval): int {
|
||||
return $this->info()[$interval]['size'];
|
||||
}
|
||||
|
||||
public function category(): array {
|
||||
return $this->info()['category'];
|
||||
}
|
||||
|
||||
public function format(): array {
|
||||
return $this->info()['format'];
|
||||
}
|
||||
|
||||
public function formatMonth(): array {
|
||||
return $this->info()['format-month'];
|
||||
}
|
||||
|
||||
public function media(): array {
|
||||
return $this->info()['media'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Yearly torrent flows (added, removed and net per month)
|
||||
|
||||
@@ -27,8 +27,14 @@ class User extends \Gazelle\BaseObject {
|
||||
]);
|
||||
return $this;
|
||||
}
|
||||
public function link(): string { return sprintf('<a href="%s">%s</a>', $this->url(), 'Stats'); }
|
||||
public function location(): string { return 'user.php?action=stats&userid=' . $this->id; }
|
||||
|
||||
public function link(): string {
|
||||
return sprintf('<a href="%s">%s</a>', $this->url(), 'Stats');
|
||||
}
|
||||
|
||||
public function location(): string {
|
||||
return 'user.php?action=stats&userid=' . $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the total number of comments made by page type
|
||||
|
||||
@@ -48,7 +48,9 @@ class TGroup extends BaseObject implements CategoryHasArtist, CollageEntry {
|
||||
};
|
||||
}
|
||||
|
||||
public function location(): string { return "torrents.php?id={$this->id}"; }
|
||||
public function location(): string {
|
||||
return "torrents.php?id={$this->id}";
|
||||
}
|
||||
|
||||
public function torrentLink(int $torrentId): string {
|
||||
$url = '<a href="' . $this->url() . "&torrentid={$torrentId}#torrent{$torrentId}\" dir=\"ltr\">"
|
||||
@@ -966,7 +968,7 @@ class TGroup extends BaseObject implements CategoryHasArtist, CollageEntry {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rename(string $name, User $user, Manager\TGroup $manager, Log $logger): bool {
|
||||
public function rename(string $name, User $user, Log $logger): bool {
|
||||
$oldName = $this->name();
|
||||
$success = $this->setField('Name', $name)->modify();
|
||||
if ($success) {
|
||||
|
||||
10
app/Tag.php
10
app/Tag.php
@@ -18,8 +18,14 @@ class Tag extends BaseObject {
|
||||
unset($this->info);
|
||||
return $this;
|
||||
}
|
||||
public function link(): string { return sprintf('<a href="%s">%s</a>', $this->url(), display_str($this->name())); }
|
||||
public function location(): string { return 'torrents.php?taglist=' . $this->name(); }
|
||||
|
||||
public function link(): string {
|
||||
return sprintf('<a href="%s">%s</a>', $this->url(), display_str($this->name()));
|
||||
}
|
||||
|
||||
public function location(): string {
|
||||
return 'torrents.php?taglist=' . $this->name();
|
||||
}
|
||||
|
||||
public function info(): array {
|
||||
return $this->info ??= self::$db->rowAssoc("
|
||||
|
||||
@@ -17,8 +17,14 @@ class Thread extends BaseObject {
|
||||
unset($this->info);
|
||||
return $this;
|
||||
}
|
||||
public function link(): string { return ''; }
|
||||
public function location(): string { return ''; }
|
||||
|
||||
public function link(): string {
|
||||
return '';
|
||||
}
|
||||
|
||||
public function location(): string {
|
||||
return '';
|
||||
}
|
||||
|
||||
public function info(): array {
|
||||
if (isset($this->info)) {
|
||||
|
||||
@@ -11,7 +11,9 @@ class Torrent extends TorrentAbstract {
|
||||
final public const CACHE_KEY_PEERLIST_PAGE = 'peerlist_page_%d_%d';
|
||||
final public const USER_RECENT_UPLOAD = 'u_recent_up_%d';
|
||||
|
||||
public function location(): string { return "torrents.php?id={$this->groupId()}&torrentid={$this->id}#torrent{$this->id}"; }
|
||||
public function location(): string {
|
||||
return "torrents.php?id={$this->groupId()}&torrentid={$this->id}#torrent{$this->id}";
|
||||
}
|
||||
|
||||
public function infoRow(): ?array {
|
||||
$info = self::$db->rowAssoc("
|
||||
|
||||
@@ -20,8 +20,14 @@ class Report extends \Gazelle\BaseObject {
|
||||
unset($this->info);
|
||||
return $this;
|
||||
}
|
||||
public function link(): string { return sprintf('<a href="%s">Report #%d</a>', $this->url(), $this->id()); }
|
||||
public function location(): string { return "reportsv2.php?view=report&id=" . $this->id; }
|
||||
|
||||
public function link(): string {
|
||||
return sprintf('<a href="%s">Report #%d</a>', $this->url(), $this->id());
|
||||
}
|
||||
|
||||
public function location(): string {
|
||||
return "reportsv2.php?view=report&id=" . $this->id;
|
||||
}
|
||||
|
||||
public function info(): array {
|
||||
return $this->info ??= self::$db->rowAssoc("
|
||||
|
||||
@@ -16,13 +16,22 @@ class ReportType extends \Gazelle\BaseObject {
|
||||
self::$cache->delete_value(sprintf(\Gazelle\Manager\Torrent\ReportType::TYPE_KEY, $this->id));
|
||||
return $this;
|
||||
}
|
||||
public function link(): string { return ''; }
|
||||
public function location(): string { return "tools.php?action=torrent_report_edit&id=" . $this->id; }
|
||||
|
||||
public function link(): string {
|
||||
return '';
|
||||
}
|
||||
|
||||
public function location(): string {
|
||||
return "tools.php?action=torrent_report_edit&id=" . $this->id;
|
||||
}
|
||||
|
||||
// phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass
|
||||
public function url(string|null $param = null): string {
|
||||
return htmlentities($this->location());
|
||||
}
|
||||
|
||||
// phpcs:enable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass
|
||||
|
||||
public function info(): array {
|
||||
$key = sprintf(self::CACHE_KEY, $this->id);
|
||||
$info = self::$cache->get_value($key);
|
||||
|
||||
@@ -115,7 +115,6 @@ abstract class TorrentAbstract extends BaseObject {
|
||||
return $this->info;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Assume a torrent has not been deleted. This function is
|
||||
* overridden in TorrentDeleted
|
||||
|
||||
@@ -8,7 +8,9 @@ class TorrentDeleted extends TorrentAbstract {
|
||||
final public const tableName = 'deleted_torrents';
|
||||
final public const CACHE_KEY = 'tdel_%d';
|
||||
|
||||
public function location(): string { return "log.php?search=Torrent+" . $this->id; }
|
||||
public function location(): string {
|
||||
return "log.php?search=Torrent+" . $this->id;
|
||||
}
|
||||
|
||||
public function infoRow(): ?array {
|
||||
$info = self::$db->rowAssoc("
|
||||
@@ -65,8 +67,4 @@ class TorrentDeleted extends TorrentAbstract {
|
||||
public function isDeleted(): bool {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function addFlag(TorrentFlag $flag, User $user): int {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,8 +16,14 @@ class TorrentLog extends BaseObject {
|
||||
$this->torrent->flush();
|
||||
return $this;
|
||||
}
|
||||
public function link(): string { return $this->torrent->link(); }
|
||||
public function location(): string { return $this->torrent->location(); }
|
||||
|
||||
public function link(): string {
|
||||
return $this->torrent->link();
|
||||
}
|
||||
|
||||
public function location(): string {
|
||||
return $this->torrent->location();
|
||||
}
|
||||
|
||||
public function torrentId(): int {
|
||||
return $this->torrent->id();
|
||||
|
||||
67
app/User.php
67
app/User.php
@@ -48,8 +48,14 @@ class User extends BaseObject {
|
||||
unset($this->info, $this->ordinal, $this->privilege, $this->stats, $this->tokenCache);
|
||||
return $this;
|
||||
}
|
||||
public function link(): string { return sprintf('<a href="%s">%s</a>', $this->url(), html_escape($this->username())); }
|
||||
public function location(): string { return 'user.php?id=' . $this->id; }
|
||||
|
||||
public function link(): string {
|
||||
return sprintf('<a href="%s">%s</a>', $this->url(), html_escape($this->username()));
|
||||
}
|
||||
|
||||
public function location(): string {
|
||||
return 'user.php?id=' . $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delegate privilege methods to the User\AuditTrail class
|
||||
@@ -1449,18 +1455,49 @@ class User extends BaseObject {
|
||||
return $change;
|
||||
}
|
||||
|
||||
public function isUnconfirmed(): bool { return $this->info()['Enabled'] == UserStatus::unconfirmed->value; }
|
||||
public function isEnabled(): bool { return $this->info()['Enabled'] == UserStatus::enabled->value; }
|
||||
public function isDisabled(): bool { return $this->info()['Enabled'] == UserStatus::disabled->value; }
|
||||
public function isLocked(): bool { return !is_null($this->info()['locked_account']); }
|
||||
public function isVisible(): bool { return $this->info()['Visible'] == '1'; }
|
||||
public function isWarned(): bool { return !is_null($this->warningExpiry()); }
|
||||
public function isUnconfirmed(): bool {
|
||||
return $this->info()['Enabled'] == UserStatus::unconfirmed->value;
|
||||
}
|
||||
|
||||
public function isStaff(): bool { return $this->info()['isStaff']; }
|
||||
public function isFLS(): bool { return $this->privilege()->isFLS(); }
|
||||
public function isInterviewer(): bool { return $this->privilege()->isInterviewer(); }
|
||||
public function isRecruiter(): bool { return $this->privilege()->isRecruiter(); }
|
||||
public function isStaffPMReader(): bool { return $this->isFLS() || $this->isStaff(); }
|
||||
public function isEnabled(): bool {
|
||||
return $this->info()['Enabled'] == UserStatus::enabled->value;
|
||||
}
|
||||
|
||||
public function isDisabled(): bool {
|
||||
return $this->info()['Enabled'] == UserStatus::disabled->value;
|
||||
}
|
||||
|
||||
public function isLocked(): bool {
|
||||
return !is_null($this->info()['locked_account']);
|
||||
}
|
||||
|
||||
public function isVisible(): bool {
|
||||
return $this->info()['Visible'] == '1';
|
||||
}
|
||||
|
||||
public function isWarned(): bool {
|
||||
return !is_null($this->warningExpiry());
|
||||
}
|
||||
|
||||
public function isStaff(): bool {
|
||||
return $this->info()['isStaff'];
|
||||
}
|
||||
|
||||
public function isFLS(): bool {
|
||||
return $this->privilege()->isFLS();
|
||||
}
|
||||
|
||||
public function isInterviewer(): bool {
|
||||
return $this->privilege()->isInterviewer();
|
||||
}
|
||||
|
||||
public function isRecruiter(): bool {
|
||||
return $this->privilege()->isRecruiter();
|
||||
}
|
||||
|
||||
public function isStaffPMReader(): bool {
|
||||
return $this->isFLS() || $this->isStaff();
|
||||
}
|
||||
|
||||
public function warningExpiry(): ?string {
|
||||
return $this->info()['warning_expiry'];
|
||||
@@ -1753,8 +1790,7 @@ class User extends BaseObject {
|
||||
&& !$torrent->isFreeleech()
|
||||
&& !$torrent->isFreeleechPersonal()
|
||||
&& (STACKABLE_FREELEECH_TOKENS || $torrent->tokenCount() == 1)
|
||||
&& $this->tokenCount() >= $torrent->tokenCount()
|
||||
;
|
||||
&& $this->tokenCount() >= $torrent->tokenCount();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1974,6 +2010,7 @@ class User extends BaseObject {
|
||||
);
|
||||
return $token;
|
||||
} catch (\Gazelle\DB\MysqlDuplicateKeyException) {
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,11 +13,7 @@ class Inbox extends \Gazelle\BaseUser {
|
||||
protected string $searchField = 'user';
|
||||
protected string $searchTerm;
|
||||
|
||||
public function __construct(\Gazelle\User $user) {
|
||||
parent::__construct($user);
|
||||
}
|
||||
|
||||
public function flush(): static {
|
||||
public function flush(): static {
|
||||
self::$cache->delete_value(sprintf(self::CACHE_NEW, $this->id()));
|
||||
$this->user->flush();
|
||||
return $this;
|
||||
|
||||
@@ -14,11 +14,19 @@ abstract class AbstractNotification extends \Gazelle\BaseUser {
|
||||
$this->user()->flush();
|
||||
return $this;
|
||||
}
|
||||
public function link(): string { return $this->user()->link(); }
|
||||
public function location(): string { return $this->user()->location(); }
|
||||
|
||||
public function link(): string {
|
||||
return $this->user()->link();
|
||||
}
|
||||
|
||||
public function location(): string {
|
||||
return $this->user()->location();
|
||||
}
|
||||
|
||||
abstract public function className(): string;
|
||||
|
||||
abstract public function clear(): int;
|
||||
|
||||
abstract public function load(): bool;
|
||||
|
||||
public function context(): int {
|
||||
|
||||
@@ -118,9 +118,18 @@ class Privilege extends \Gazelle\BaseUser {
|
||||
public function isSecondary(int $privilegeId): bool {
|
||||
return isset($this->info()['secondary'][$privilegeId]);
|
||||
}
|
||||
public function isFLS(): bool { return $this->isSecondary(FLS_TEAM); }
|
||||
public function isInterviewer(): bool { return $this->isSecondary(INTERVIEWER); }
|
||||
public function isRecruiter(): bool { return $this->isSecondary(RECRUITER); }
|
||||
|
||||
public function isFLS(): bool {
|
||||
return $this->isSecondary(FLS_TEAM);
|
||||
}
|
||||
|
||||
public function isInterviewer(): bool {
|
||||
return $this->isSecondary(INTERVIEWER);
|
||||
}
|
||||
|
||||
public function isRecruiter(): bool {
|
||||
return $this->isSecondary(RECRUITER);
|
||||
}
|
||||
|
||||
public function allowedForumList(): array {
|
||||
return $this->info()['forum'];
|
||||
|
||||
@@ -79,7 +79,9 @@ class Seedbox extends \Gazelle\BaseUser {
|
||||
);
|
||||
}
|
||||
|
||||
public function viewBy(): int { return $this->viewBy; }
|
||||
public function viewBy(): int {
|
||||
return $this->viewBy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a signature of the useragent and IP address.
|
||||
@@ -208,7 +210,7 @@ class Seedbox extends \Gazelle\BaseUser {
|
||||
", mb_substr($name, 0, 100), $this->user->id(), $this->hashid->decode($seedbox['id'])[0]
|
||||
);
|
||||
} catch (\Gazelle\DB\MysqlDuplicateKeyException) {
|
||||
// do nothing
|
||||
; // do nothing
|
||||
} finally {
|
||||
$n += self::$db->affected_rows();
|
||||
}
|
||||
|
||||
@@ -396,7 +396,7 @@ class Vote extends \Gazelle\BaseUser {
|
||||
WHERE v.GroupID = ?
|
||||
", $tgroup->id()
|
||||
);
|
||||
return [$total, (int)$ups, $this->calcScore($total, (int)$ups)] ;
|
||||
return [$total, (int)$ups, $this->calcScore($total, (int)$ups)];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -12,9 +12,11 @@ class UserNavigation extends BaseObject {
|
||||
unset($this->info);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function link(): string {
|
||||
return "<a href=\"{$this->location()}\">User Link Editor</a>";
|
||||
}
|
||||
|
||||
public function location(): string {
|
||||
return "tools.php?action=navigation";
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ namespace Gazelle\UserRank;
|
||||
|
||||
abstract class AbstractUserRank extends \Gazelle\Base {
|
||||
abstract public function cacheKey(): string;
|
||||
|
||||
abstract public function selector(): string;
|
||||
|
||||
/**
|
||||
|
||||
@@ -8,7 +8,6 @@ class PasswordCheck {
|
||||
public const REGEXP = '/(?=^.{8,}$)(?=.*[^a-zA-Z])(?=.*[A-Z])(?=.*[a-z]).*$|.{20,}/';
|
||||
public const ERROR_MSG = 'You have specified a weak or known-compromised password.';
|
||||
|
||||
|
||||
public static function checkPasswordStrength(#[\SensitiveParameter] string $password, ?User $user, bool $skipRegex = true): bool {
|
||||
return static::checkPasswordStrengthNoUser($password, $user?->username(), $user?->email(), $skipRegex);
|
||||
}
|
||||
|
||||
@@ -210,7 +210,6 @@ class Time {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Converts a numeric amount of seconds (though we round down via floor for all levels) into a more human readeable
|
||||
* string representing the number of weeks, days, hours, minutes, seconds.
|
||||
|
||||
@@ -208,7 +208,7 @@ class Twig {
|
||||
'UTF-8'
|
||||
)));
|
||||
|
||||
$twig->addFunction(new \Twig\TwigFunction('donor_icon', fn($icon, $userId) => new \Twig\Markup(image_cache_encode($icon), 'UTF-8')));
|
||||
$twig->addFunction(new \Twig\TwigFunction('donor_icon', fn($icon) => new \Twig\Markup(image_cache_encode($icon), 'UTF-8')));
|
||||
|
||||
$twig->addFunction(new \Twig\TwigFunction('ipaddr', fn(string $ipaddr) => new \Twig\Markup(
|
||||
"$ipaddr <a href=\"user.php?action=search&ip_history=on&matchtype=strict&ip=$ipaddr\" title=\"Search\" class=\"brackets tooltip\">S</a>",
|
||||
|
||||
10
app/Wiki.php
10
app/Wiki.php
@@ -12,8 +12,13 @@ class Wiki extends BaseObject {
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function link(): string { return sprintf('<a href="%s">%s</a>', $this->url(), display_str($this->title())); }
|
||||
public function location(): string { return 'wiki.php?action=article&id=' . $this->id; }
|
||||
public function link(): string {
|
||||
return sprintf('<a href="%s">%s</a>', $this->url(), display_str($this->title()));
|
||||
}
|
||||
|
||||
public function location(): string {
|
||||
return 'wiki.php?action=article&id=' . $this->id;
|
||||
}
|
||||
|
||||
public function info(): array {
|
||||
if (isset($this->info)) {
|
||||
@@ -109,6 +114,7 @@ class Wiki extends BaseObject {
|
||||
public function ToC(): string {
|
||||
return $this->info()['toc'] ?? '';
|
||||
}
|
||||
|
||||
// phpcs:enable
|
||||
|
||||
public function editable(User $user): bool {
|
||||
|
||||
@@ -4,9 +4,13 @@ namespace Gazelle\WitnessTable;
|
||||
|
||||
abstract class AbstractWitnessTable extends \Gazelle\Base {
|
||||
abstract protected function reference(): string;
|
||||
|
||||
abstract protected function tableName(): string;
|
||||
|
||||
abstract protected function idColumn(): string;
|
||||
|
||||
abstract protected function valueColumn(): string;
|
||||
|
||||
abstract public function witness(\Gazelle\User $user): bool;
|
||||
|
||||
protected function latestValue(): ?int {
|
||||
|
||||
@@ -3,10 +3,21 @@
|
||||
namespace Gazelle\WitnessTable;
|
||||
|
||||
class UserReadBlog extends AbstractWitnessTable {
|
||||
protected function reference(): string { return 'blog'; }
|
||||
protected function tableName(): string { return 'user_read_blog'; }
|
||||
protected function idColumn(): string { return 'user_id'; }
|
||||
protected function valueColumn(): string { return 'blog_id'; }
|
||||
protected function reference(): string {
|
||||
return 'blog';
|
||||
}
|
||||
|
||||
protected function tableName(): string {
|
||||
return 'user_read_blog';
|
||||
}
|
||||
|
||||
protected function idColumn(): string {
|
||||
return 'user_id';
|
||||
}
|
||||
|
||||
protected function valueColumn(): string {
|
||||
return 'blog_id';
|
||||
}
|
||||
|
||||
public function witness(\Gazelle\User $user): bool {
|
||||
return $this->witnessValue($user);
|
||||
|
||||
@@ -3,10 +3,21 @@
|
||||
namespace Gazelle\WitnessTable;
|
||||
|
||||
class UserReadForum extends AbstractWitnessTable {
|
||||
protected function reference(): string { return ''; }
|
||||
protected function tableName(): string { return 'user_read_forum'; }
|
||||
protected function idColumn(): string { return 'user_id'; }
|
||||
protected function valueColumn(): string { return 'last_read'; }
|
||||
protected function reference(): string {
|
||||
return '';
|
||||
}
|
||||
|
||||
protected function tableName(): string {
|
||||
return 'user_read_forum';
|
||||
}
|
||||
|
||||
protected function idColumn(): string {
|
||||
return 'user_id';
|
||||
}
|
||||
|
||||
protected function valueColumn(): string {
|
||||
return 'last_read';
|
||||
}
|
||||
|
||||
public function witness(\Gazelle\User $user): bool {
|
||||
return $this->witnessDate($user);
|
||||
|
||||
@@ -3,10 +3,21 @@
|
||||
namespace Gazelle\WitnessTable;
|
||||
|
||||
class UserReadNews extends AbstractWitnessTable {
|
||||
protected function reference(): string { return 'news'; }
|
||||
protected function tableName(): string { return 'user_read_news'; }
|
||||
protected function idColumn(): string { return 'user_id'; }
|
||||
protected function valueColumn(): string { return 'news_id'; }
|
||||
protected function reference(): string {
|
||||
return 'news';
|
||||
}
|
||||
|
||||
protected function tableName(): string {
|
||||
return 'user_read_news';
|
||||
}
|
||||
|
||||
protected function idColumn(): string {
|
||||
return 'user_id';
|
||||
}
|
||||
|
||||
protected function valueColumn(): string {
|
||||
return 'news_id';
|
||||
}
|
||||
|
||||
public function witness(\Gazelle\User $user): bool {
|
||||
return $this->witnessValue($user);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
/* If ever can_leech and RatioWatchEnds get out of synch, no task will catch it */
|
||||
|
||||
require_once(__DIR__ . '/../lib/bootstrap.php');
|
||||
require_once __DIR__ . '/../lib/bootstrap.php';
|
||||
|
||||
ini_set('max_execution_time', -1);
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
* longer exists.
|
||||
*/
|
||||
|
||||
require_once(__DIR__ . '/../lib/bootstrap.php');
|
||||
require_once __DIR__ . '/../lib/bootstrap.php';
|
||||
|
||||
ini_set('max_execution_time', -1);
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
// phpcs:disable PSR1.Files.SideEffects.FoundWithSymbols
|
||||
|
||||
require_once(__DIR__ . '/../lib/bootstrap.php');
|
||||
require_once __DIR__ . '/../lib/bootstrap.php';
|
||||
|
||||
ini_set('max_execution_time', -1);
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
require_once(__DIR__ . '/../lib/bootstrap.php');
|
||||
require_once __DIR__ . '/../lib/bootstrap.php';
|
||||
$db = Gazelle\DB::DB();
|
||||
|
||||
$db->prepared_query("
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
* migrate existing Gazelle installations.
|
||||
*/
|
||||
|
||||
require_once(__DIR__ . '/../lib/bootstrap.php');
|
||||
require_once __DIR__ . '/../lib/bootstrap.php';
|
||||
|
||||
$allConfig = [
|
||||
'-html' => [
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
require_once(__DIR__ . '/../lib/bootstrap.php');
|
||||
require_once __DIR__ . '/../lib/bootstrap.php';
|
||||
$Cache->disableLocalCache();
|
||||
|
||||
$torMan = new Gazelle\Manager\Torrent();
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
/* A script to import the old WhatCD wiki articles from the 10th birthday release */
|
||||
|
||||
require_once(__DIR__ . '/../lib/bootstrap.php');
|
||||
require_once __DIR__ . '/../lib/bootstrap.php';
|
||||
|
||||
$in = fopen($argv[1], 'r');
|
||||
if ($in === false) {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace
|
||||
// phpcs:disable PSR1.Files.SideEffects.FoundWithSymbols
|
||||
|
||||
require_once(__DIR__ . '/vendor/autoload.php');
|
||||
require_once __DIR__ . '/vendor/autoload.php';
|
||||
|
||||
use SebastianBergmann\CodeCoverage\Filter;
|
||||
use SebastianBergmann\CodeCoverage\Driver\Selector;
|
||||
@@ -10,7 +10,10 @@ use SebastianBergmann\CodeCoverage\CodeCoverage;
|
||||
use SebastianBergmann\CodeCoverage\Report\PHP as PhpReport;
|
||||
use SebastianBergmann\CodeCoverage\Util\Filesystem;
|
||||
|
||||
function filenameList(string $path): array { /** @phpstan-ignore-line */
|
||||
/**
|
||||
* @return array<string>
|
||||
*/
|
||||
function filenameList(string $path): array {
|
||||
$list = [];
|
||||
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path)) as $entry) {
|
||||
$filename = $entry->getPathname();
|
||||
@@ -56,4 +59,4 @@ class CoverageHelper {
|
||||
}
|
||||
|
||||
$coverage_helper = new CoverageHelper();
|
||||
require_once(__DIR__ . '/gazelle.php');
|
||||
require_once __DIR__ . '/gazelle.php';
|
||||
|
||||
@@ -14,7 +14,6 @@ class Sphinxql extends mysqli {
|
||||
public static $Queries = [];
|
||||
public static $Time = 0.0;
|
||||
|
||||
|
||||
/**
|
||||
* Initialize Sphinxql object
|
||||
*
|
||||
|
||||
@@ -10,9 +10,12 @@ class SphinxqlResult {
|
||||
* @param int $Errno error code returned by the query upon failure
|
||||
* @param string $Error error message returned by the query upon failure
|
||||
*/
|
||||
public function __construct(private $Result, private $Meta, public $Errno, public $Error)
|
||||
{
|
||||
}
|
||||
public function __construct(
|
||||
private $Result,
|
||||
private $Meta,
|
||||
public $Errno,
|
||||
public $Error,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Did the query find anything?
|
||||
|
||||
@@ -510,6 +510,8 @@ class Text {
|
||||
// Thus, we have to handle these before we handle the majority of tags
|
||||
|
||||
//5a) Different for different types of tag. Some tags don't close, others are weird like [*]
|
||||
// phpcs:disable Generic.CodeAnalysis.EmptyStatement.DetectedIf
|
||||
// phpcs:disable Generic.CodeAnalysis.EmptyStatement.DetectedElseif
|
||||
if ($i >= strlen($Str)) {
|
||||
// document end, tag unclosed
|
||||
} elseif ($TagName == 'img' && !empty($Tag[3][0])) { //[img=...]
|
||||
@@ -591,6 +593,8 @@ class Text {
|
||||
|
||||
$i = $CloseTag + strlen($TagName) + 3; // 5d) Move the pointer past the end of the [/close] tag.
|
||||
}
|
||||
// phpcs:enable Generic.CodeAnalysis.EmptyStatement.DetectedIf
|
||||
// phpcs:enable Generic.CodeAnalysis.EmptyStatement.DetectedElseif
|
||||
|
||||
// 6) Depending on what type of tag we're dealing with, create an array with the attribute and block.
|
||||
switch ($TagName) {
|
||||
|
||||
@@ -136,7 +136,7 @@ class View {
|
||||
* @param array<mixed> $Target
|
||||
* @param array<mixed> $Tests
|
||||
*/
|
||||
protected static function add_active(array $Target, array $Tests, bool $UserIDKey = false): bool {
|
||||
protected static function add_active(array $Target, array $Tests): bool {
|
||||
if (!is_array($Tests[0])) {
|
||||
// Test all values in vectors
|
||||
foreach ($Tests as $Type => $Part) {
|
||||
|
||||
@@ -6,7 +6,7 @@ use Gazelle\Util\Time;
|
||||
|
||||
// 1. Initialization
|
||||
|
||||
require_once(__DIR__ . '/lib/bootstrap.php');
|
||||
require_once __DIR__ . '/lib/bootstrap.php';
|
||||
global $Cache, $Debug, $Twig;
|
||||
|
||||
// Get the user's actual IP address if they're proxied.
|
||||
@@ -161,7 +161,7 @@ $Cache->cache_value('php_' . getmypid(), [
|
||||
register_shutdown_function(
|
||||
function () {
|
||||
if (preg_match(DEBUG_URI, $_SERVER['REQUEST_URI'])) {
|
||||
require(DEBUG_TRACE);
|
||||
include DEBUG_TRACE;
|
||||
}
|
||||
$error = error_get_last();
|
||||
if ($error['type'] ?? 0 == E_ERROR) {
|
||||
@@ -182,7 +182,7 @@ if (!$file || !preg_match('/^[a-z][a-z0-9_]+$/', $module)) {
|
||||
}
|
||||
|
||||
try {
|
||||
require_once($file);
|
||||
include_once $file;
|
||||
} catch (Gazelle\DB\MysqlException $e) {
|
||||
Gazelle\DB::DB()->rollback(); // if there was an ongoing transaction, abort it
|
||||
if (DEBUG_MODE || (isset($Viewer) && $Viewer->permitted('site_debug'))) {
|
||||
|
||||
@@ -13,9 +13,9 @@ foreach (['memcached', 'mysqli'] as $e) {
|
||||
date_default_timezone_set('UTC');
|
||||
|
||||
if (!defined('SITE_NAME')) {
|
||||
require_once(__DIR__ . '/config.php');
|
||||
require_once(__DIR__ . '/../lib/util.php');
|
||||
require_once(__DIR__ . '/../vendor/autoload.php');
|
||||
include_once __DIR__ . '/config.php';
|
||||
include_once __DIR__ . '/../lib/util.php';
|
||||
include_once __DIR__ . '/../vendor/autoload.php';
|
||||
}
|
||||
|
||||
global $Cache, $Debug, $Twig;
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
*/
|
||||
|
||||
if (file_exists(__DIR__ . '/override.config.php')) {
|
||||
require_once(__DIR__ . '/override.config.php');
|
||||
include_once __DIR__ . '/override.config.php';
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
@@ -392,15 +392,18 @@ function parse_user_agent(string $useragent): array {
|
||||
* $NoHTML If true, the header/footer won't be shown, just the description.
|
||||
* $Log If true, the user is given a link to search $Log in the site log.
|
||||
*/
|
||||
// phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed
|
||||
function error(int|string $Error, bool $NoHTML = false, bool $Log = false): never {
|
||||
global $Debug, $Viewer, $Twig;
|
||||
require_once(__DIR__ . '/../sections/error/index.php');
|
||||
include_once __DIR__ . '/../sections/error/index.php';
|
||||
if (isset($Viewer)) {
|
||||
$Debug->profile($Viewer, $Viewer->requestContext()->module());
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
// phpcs:enable Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed
|
||||
|
||||
/**
|
||||
* Print JSON status result with an optional message and die.
|
||||
*/
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
require_once(__DIR__ . '/../lib/config.php');
|
||||
require_once __DIR__ . '/../lib/config.php';
|
||||
|
||||
return [
|
||||
'paths' => [
|
||||
|
||||
@@ -4,5 +4,6 @@ use Phinx\Migration\AbstractMigration;
|
||||
|
||||
class RequestChecksum extends AbstractMigration {
|
||||
public function up(): void {}
|
||||
|
||||
public function down(): void {}
|
||||
}
|
||||
|
||||
@@ -29,10 +29,10 @@ class UserDonorRank extends AbstractMigration
|
||||
* Remember to call "create()" or "update()" and NOT "save()" when working
|
||||
* with the Table class.
|
||||
*/
|
||||
|
||||
public function up(): void {
|
||||
$this->execute("ALTER TABLE users_donor_ranks CHANGE InvitesRecievedRank InvitesReceivedRank tinyint(4) DEFAULT '0'");
|
||||
}
|
||||
|
||||
public function down(): void {
|
||||
$this->execute("ALTER TABLE users_donor_ranks CHANGE InvitesReceivedRank InvitesRecievedRank tinyint(4) DEFAULT '0'");
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user