diff --git a/endpoints/aboutus/aboutus.php b/endpoints/aboutus/aboutus.php index f6ef07ba..524dfc0c 100644 --- a/endpoints/aboutus/aboutus.php +++ b/endpoints/aboutus/aboutus.php @@ -13,11 +13,11 @@ class AboutusBaseResponse extends TemplateResponse protected ?int $activeTab = parent::TAB_MORE; protected array $breadcrumb = [2, 0]; - public function __construct(string $pageParam) + public function __construct(string $rawParam) { - parent::__construct($pageParam); + parent::__construct($rawParam); - if ($pageParam) + if ($rawParam) $this->generateError(); } diff --git a/endpoints/account/account.php b/endpoints/account/account.php index f095ea81..eec875b8 100644 --- a/endpoints/account/account.php +++ b/endpoints/account/account.php @@ -42,12 +42,12 @@ class AccountBaseResponse extends TemplateResponse public ?array $bans; - public function __construct($pageParam) + public function __construct($rawParam) { if (!User::isLoggedIn()) $this->forwardToSignIn('account'); - parent::__construct($pageParam); + parent::__construct($rawParam); } protected function generate() : void diff --git a/endpoints/account/confirm-delete.php b/endpoints/account/confirm-delete.php index b5d0b6b9..440dc415 100644 --- a/endpoints/account/confirm-delete.php +++ b/endpoints/account/confirm-delete.php @@ -35,12 +35,12 @@ class AccountConfirmdeleteResponse extends TemplateResponse private bool $success = false; - public function __construct(string $pageParam) + public function __construct(string $rawParam) { if (Cfg::get('ACC_AUTH_MODE') != AUTH_MODE_SELF) $this->generateError(); - parent::__construct($pageParam); + parent::__construct($rawParam); } protected function generate() : void diff --git a/endpoints/account/delete.php b/endpoints/account/delete.php index 34da70e2..6828481d 100644 --- a/endpoints/account/delete.php +++ b/endpoints/account/delete.php @@ -28,12 +28,12 @@ class AccountDeleteResponse extends TemplateResponse public string $deleteFormTarget = '?account=delete'; public ?array $inputbox = null; - public function __construct(string $pageParam) + public function __construct(string $rawParam) { if (Cfg::get('ACC_AUTH_MODE') != AUTH_MODE_SELF) $this->generateError(); - parent::__construct($pageParam); + parent::__construct($rawParam); } protected function generate() : void diff --git a/endpoints/account/forgot-password.php b/endpoints/account/forgot-password.php index 1f340cad..a1e644c6 100644 --- a/endpoints/account/forgot-password.php +++ b/endpoints/account/forgot-password.php @@ -29,7 +29,7 @@ class AccountforgotpasswordResponse extends TemplateResponse private bool $success = false; - public function __construct(string $pageParam) + public function __construct(string $rawParam) { // don't redirect logged in users // you can be forgetful AND logged in @@ -40,7 +40,7 @@ class AccountforgotpasswordResponse extends TemplateResponse if (Cfg::get('ACC_AUTH_MODE') != AUTH_MODE_SELF) $this->generateError(); - parent::__construct($pageParam); + parent::__construct($rawParam); } protected function generate() : void diff --git a/endpoints/account/forgot-username.php b/endpoints/account/forgot-username.php index 0b8345fd..6b946a0a 100644 --- a/endpoints/account/forgot-username.php +++ b/endpoints/account/forgot-username.php @@ -28,7 +28,7 @@ class AccountforgotusernameResponse extends TemplateResponse private bool $success = false; - public function __construct(string $pageParam) + public function __construct(string $rawParam) { // if the user is looged in goto account dashboard if (User::isLoggedIn()) @@ -40,7 +40,7 @@ class AccountforgotusernameResponse extends TemplateResponse if (Cfg::get('ACC_AUTH_MODE') != AUTH_MODE_SELF) $this->generateError(); - parent::__construct($pageParam); + parent::__construct($rawParam); } protected function generate() : void diff --git a/endpoints/account/resend-submit.php b/endpoints/account/resend-submit.php index c45c0499..28fe9c51 100644 --- a/endpoints/account/resend-submit.php +++ b/endpoints/account/resend-submit.php @@ -20,12 +20,12 @@ class AccountResendsubmitResponse extends TemplateResponse 'email' => ['filter' => FILTER_VALIDATE_EMAIL, 'flags' => FILTER_FLAG_STRIP_AOWOW] ); - public function __construct(string $pageParam) + public function __construct(string $rawParam) { if (!Cfg::get('ACC_ALLOW_REGISTER') || Cfg::get('ACC_AUTH_MODE') != AUTH_MODE_SELF) $this->generateError(); - parent::__construct($pageParam); + parent::__construct($rawParam); } protected function generate() : void diff --git a/endpoints/account/resend.php b/endpoints/account/resend.php index 7c02075e..fc6baee3 100644 --- a/endpoints/account/resend.php +++ b/endpoints/account/resend.php @@ -22,7 +22,7 @@ class AccountResendResponse extends TemplateResponse private bool $success = false; - public function __construct(string $pageParam) + public function __construct(string $rawParam) { if (Cfg::get('ACC_EXT_RECOVER_URL')) $this->forward(Cfg::get('ACC_EXT_RECOVER_URL')); @@ -30,7 +30,7 @@ class AccountResendResponse extends TemplateResponse if (!Cfg::get('ACC_ALLOW_REGISTER') || Cfg::get('ACC_AUTH_MODE') != AUTH_MODE_SELF) $this->generateError(); - parent::__construct($pageParam); + parent::__construct($rawParam); } protected function generate() : void diff --git a/endpoints/account/signout.php b/endpoints/account/signout.php index 67eaeacf..7f96e56e 100644 --- a/endpoints/account/signout.php +++ b/endpoints/account/signout.php @@ -15,13 +15,13 @@ class AccountSignoutResponse extends TextResponse 'global' => ['filter' => FILTER_CALLBACK, 'options' => [self::class, 'checkEmptySet'] ] ); - public function __construct(string $pageParam) + public function __construct(string $rawParam) { // if the user not is logged in goto login page if (!User::isLoggedIn()) $this->forwardToSignIn(); - parent::__construct($pageParam); + parent::__construct($rawParam); } protected function generate() : void diff --git a/endpoints/account/update-email.php b/endpoints/account/update-email.php index 6806ad3b..caf5c63a 100644 --- a/endpoints/account/update-email.php +++ b/endpoints/account/update-email.php @@ -22,12 +22,12 @@ class AccountUpdateemailResponse extends TextResponse private bool $success = false; - public function __construct(string $pageParam) + public function __construct(string $rawParam) { if (Cfg::get('ACC_AUTH_MODE') != AUTH_MODE_SELF) (new TemplateResponse())->generateError(); - parent::__construct($pageParam); + parent::__construct($rawParam); } protected function generate() : void diff --git a/endpoints/account/update-password.php b/endpoints/account/update-password.php index 35543fe6..b9c82b04 100644 --- a/endpoints/account/update-password.php +++ b/endpoints/account/update-password.php @@ -25,12 +25,12 @@ class AccountUpdatepasswordResponse extends TextResponse private bool $success = false; - public function __construct(string $pageParam) + public function __construct(string $rawParam) { if (Cfg::get('ACC_AUTH_MODE') != AUTH_MODE_SELF) (new TemplateResponse())->generateError(); - parent::__construct($pageParam); + parent::__construct($rawParam); } protected function generate() : void diff --git a/endpoints/account/update-username.php b/endpoints/account/update-username.php index d301fb6a..240e1542 100644 --- a/endpoints/account/update-username.php +++ b/endpoints/account/update-username.php @@ -22,12 +22,12 @@ class AccountUpdateusernameResponse extends TextResponse private bool $success = false; - public function __construct(string $pageParam) + public function __construct(string $rawParam) { if (Cfg::get('ACC_AUTH_MODE') != AUTH_MODE_SELF) (new TemplateResponse())->generateError(); - parent::__construct($pageParam); + parent::__construct($rawParam); } protected function generate() : void diff --git a/endpoints/achievements/achievements.php b/endpoints/achievements/achievements.php index f127dad1..3a934e4e 100644 --- a/endpoints/achievements/achievements.php +++ b/endpoints/achievements/achievements.php @@ -46,13 +46,15 @@ class AchievementsBaseResponse extends TemplateResponse implements ICache ) ); - public function __construct(string $pageParam) + public function __construct(string $rawParam) { - $this->getCategoryFromUrl($pageParam); + $this->getCategoryFromUrl($rawParam); - parent::__construct($pageParam); + parent::__construct($rawParam); + + if ($this->category) + $this->subCat = '='.implode('.', $this->category); - $this->subCat = $pageParam !== '' ? '='.$pageParam : ''; $this->filter = new AchievementListFilter($this->_get['filter'] ?? '', ['parentCats' => $this->category]); if ($this->filter->shouldReload) { diff --git a/endpoints/areatriggers/areatriggers.php b/endpoints/areatriggers/areatriggers.php index 6914b642..0d681c95 100644 --- a/endpoints/areatriggers/areatriggers.php +++ b/endpoints/areatriggers/areatriggers.php @@ -23,14 +23,14 @@ class AreatriggersBaseResponse extends TemplateResponse implements ICache protected array $expectedGET = ['filter' => ['filter' => FILTER_VALIDATE_REGEXP, 'options' => ['regexp' => Filter::PATTERN_PARAM]]]; protected array $validCats = [0, 1, 2, 3, 4, 5]; - public function __construct(string $pageParam) + public function __construct(string $rawParam) { - $this->getCategoryFromUrl($pageParam); + $this->getCategoryFromUrl($rawParam); if (isset($this->category[0])) $this->forward('?areatriggers&filter=ty='.$this->category[0]); - parent::__construct($pageParam); + parent::__construct($rawParam); $this->filter = new AreaTriggerListFilter($this->_get['filter'] ?? ''); if ($this->filter->shouldReload) diff --git a/endpoints/arena-team/resync.php b/endpoints/arena-team/resync.php index dc16f103..8df05439 100644 --- a/endpoints/arena-team/resync.php +++ b/endpoints/arena-team/resync.php @@ -13,9 +13,9 @@ class ArenaTeamResyncResponse extends TextResponse 'profile' => ['filter' => FILTER_CALLBACK, 'options' => [self::class, 'checkEmptySet']] ); - public function __construct(string $pageParam) + public function __construct(string $rawParam) { - parent::__construct($pageParam); + parent::__construct($rawParam); if (!Cfg::get('PROFILER_ENABLE')) $this->generate404(); diff --git a/endpoints/arena-team/status.php b/endpoints/arena-team/status.php index b9029d61..ad89f016 100644 --- a/endpoints/arena-team/status.php +++ b/endpoints/arena-team/status.php @@ -12,9 +12,9 @@ class ArenaTeamStatusResponse extends TextResponse 'id' => ['filter' => FILTER_CALLBACK, 'options' => [self::class, 'checkIdList']] ); - public function __construct(string $pageParam) + public function __construct(string $rawParam) { - parent::__construct($pageParam); + parent::__construct($rawParam); if (!Cfg::get('PROFILER_ENABLE')) $this->generate404(); diff --git a/endpoints/arena-teams/arena-teams.php b/endpoints/arena-teams/arena-teams.php index 63b6415e..9983422d 100644 --- a/endpoints/arena-teams/arena-teams.php +++ b/endpoints/arena-teams/arena-teams.php @@ -29,14 +29,14 @@ class ArenateamsBaseResponse extends TemplateResponse implements IProfilerList private int $sumSubjects = 0; - public function __construct(string $pageParam) + public function __construct(string $rawParam) { if (!Cfg::get('PROFILER_ENABLE')) $this->generateError(); - $this->getSubjectFromUrl($pageParam); + $this->getSubjectFromUrl($rawParam); - parent::__construct($pageParam); + parent::__construct($rawParam); $realms = []; foreach (Profiler::getRealms() as $idx => $r) @@ -51,7 +51,9 @@ class ArenateamsBaseResponse extends TemplateResponse implements IProfilerList $realms[] = $idx; } - $this->subCat = $pageParam !== '' ? '='.$pageParam : ''; + if ($this->category) + $this->subCat = '='.implode('.', $this->category); + $this->filter = new ArenaTeamListFilter($this->_get['filter'] ?? '', ['realms' => $realms]); if ($this->filter->shouldReload) { diff --git a/endpoints/classes/classes.php b/endpoints/classes/classes.php index 46959c9f..07e1f6f9 100644 --- a/endpoints/classes/classes.php +++ b/endpoints/classes/classes.php @@ -18,11 +18,11 @@ class ClassesBaseResponse extends TemplateResponse implements ICache protected ?int $activeTab = parent::TAB_DATABASE; protected array $breadcrumb = [0, 12]; - public function __construct(string $pageParam) + public function __construct(string $rawParam) { - $this->getCategoryFromUrl($pageParam); + $this->getCategoryFromUrl($rawParam); - parent::__construct($pageParam); + parent::__construct($rawParam); } protected function generate() : void diff --git a/endpoints/compare/compare.php b/endpoints/compare/compare.php index 04a16a4e..67604b4f 100644 --- a/endpoints/compare/compare.php +++ b/endpoints/compare/compare.php @@ -34,9 +34,9 @@ class CompareBaseResponse extends TemplateResponse private string $compareString = ''; - public function __construct($pageParam) + public function __construct($rawParam) { - parent::__construct($pageParam); + parent::__construct($rawParam); // prefer GET over COOKIE if ($this->_get['compare']) diff --git a/endpoints/currencies/currencies.php b/endpoints/currencies/currencies.php index 931cd885..bc07dbca 100644 --- a/endpoints/currencies/currencies.php +++ b/endpoints/currencies/currencies.php @@ -20,11 +20,11 @@ class CurrenciesBaseResponse extends TemplateResponse implements ICache protected array $validCats = [1, 2, 3, 22]; - public function __construct(string $pageParam) + public function __construct(string $rawParam) { - $this->getCategoryFromUrl($pageParam); + $this->getCategoryFromUrl($rawParam); - parent::__construct($pageParam); + parent::__construct($rawParam); } protected function generate() : void diff --git a/endpoints/data/data.php b/endpoints/data/data.php index 2376b38c..876c9433 100644 --- a/endpoints/data/data.php +++ b/endpoints/data/data.php @@ -17,9 +17,9 @@ class DataBaseResponse extends TextResponse 'callback' => ['filter' => FILTER_CALLBACK, 'options' => [self::class, 'checkCallback' ]] ); - public function __construct(string $pageParam) + public function __construct(string $rawParam) { - parent::__construct($pageParam); + parent::__construct($rawParam); if ($this->_get['locale']?->validate()) Lang::load($this->_get['locale']); diff --git a/endpoints/emotes/emotes.php b/endpoints/emotes/emotes.php index d23a70e7..de77397a 100644 --- a/endpoints/emotes/emotes.php +++ b/endpoints/emotes/emotes.php @@ -18,11 +18,11 @@ class EmotesBaseResponse extends TemplateResponse implements ICache protected ?int $activeTab = parent::TAB_DATABASE; protected array $breadcrumb = [0, 100]; - public function __construct(string $pageParam) + public function __construct(string $rawParam) { - $this->getCategoryFromUrl($pageParam); + $this->getCategoryFromUrl($rawParam); - parent::__construct($pageParam); + parent::__construct($rawParam); } protected function generate() : void diff --git a/endpoints/enchantments/enchantments.php b/endpoints/enchantments/enchantments.php index 3088f145..3dfbb79a 100644 --- a/endpoints/enchantments/enchantments.php +++ b/endpoints/enchantments/enchantments.php @@ -24,16 +24,18 @@ class EnchantmentsBaseResponse extends TemplateResponse implements ICache ); protected array $validCats = [1, 2, 3, 4, 5, 6, 7, 8]; - public function __construct(string $pageParam) + public function __construct(string $rawParam) { - $this->getCategoryFromUrl($pageParam); + $this->getCategoryFromUrl($rawParam); - parent::__construct($pageParam); + parent::__construct($rawParam); if ($this->category) $this->forward('?enchantments&filter=ty='.$this->category[0]); - $this->subCat = $pageParam !== '' ? '='.$pageParam : ''; + if ($this->category) + $this->subCat = '='.implode('.', $this->category); + $this->filter = new EnchantmentListFilter($this->_get['filter'] ?? '', ['parentCats' => $this->category]); if ($this->filter->shouldReload) { diff --git a/endpoints/events/events.php b/endpoints/events/events.php index 2b614094..885a7821 100644 --- a/endpoints/events/events.php +++ b/endpoints/events/events.php @@ -20,11 +20,11 @@ class EventsBaseResponse extends TemplateResponse implements ICache protected array $validCats = [0, 1, 2, 3]; - public function __construct(string $pageParam) + public function __construct(string $rawParam) { - $this->getCategoryFromUrl($pageParam); + $this->getCategoryFromUrl($rawParam); - parent::__construct($pageParam); + parent::__construct($rawParam); } protected function generate() : void diff --git a/endpoints/factions/factions.php b/endpoints/factions/factions.php index d4839bbd..b415d933 100644 --- a/endpoints/factions/factions.php +++ b/endpoints/factions/factions.php @@ -25,11 +25,11 @@ class FactionsBaseResponse extends TemplateResponse implements ICache 0 => true ); - public function __construct(string $pageParam) + public function __construct(string $rawParam) { - $this->getCategoryFromUrl($pageParam); + $this->getCategoryFromUrl($rawParam); - parent::__construct($pageParam); + parent::__construct($rawParam); } protected function generate() : void diff --git a/endpoints/faq/faq.php b/endpoints/faq/faq.php index 70337871..7946f354 100644 --- a/endpoints/faq/faq.php +++ b/endpoints/faq/faq.php @@ -13,11 +13,11 @@ class FaqBaseResponse extends TemplateResponse protected ?int $activeTab = parent::TAB_MORE; protected array $breadcrumb = [2, 3]; - public function __construct(string $pageParam) + public function __construct(string $rawParam) { - parent::__construct($pageParam); + parent::__construct($rawParam); - if ($pageParam) + if ($rawParam) $this->generateError(); } diff --git a/endpoints/filter/filter.php b/endpoints/filter/filter.php index f6fdc23b..ff7835f4 100644 --- a/endpoints/filter/filter.php +++ b/endpoints/filter/filter.php @@ -12,18 +12,18 @@ class FilterBaseResponse extends TextResponse private string $page = ''; private ?Filter $filter = null; - public function __construct(string $pageParam) + public function __construct(string $rawParam) { - if (!$pageParam) + if (!$rawParam) return; - parent::__construct($pageParam); + parent::__construct($rawParam); $catg = null; - if (strstr($pageParam, '=')) - [$this->page, $catg] = explode('=', $pageParam); + if (strstr($rawParam, '=')) + [$this->page, $catg] = explode('=', $rawParam); else - $this->page = $pageParam; + $this->page = $rawParam; if ($catg !== null) $this->catg = explode('.', $catg); diff --git a/endpoints/guides/guides.php b/endpoints/guides/guides.php index 5216111c..cff1b489 100644 --- a/endpoints/guides/guides.php +++ b/endpoints/guides/guides.php @@ -20,11 +20,11 @@ class GuidesBaseResponse extends TemplateResponse // implements ICache protected array $validCats = [null, 1, 2, 3, 4, 5, 6, 7, 8, 9]; - public function __construct(string $pageParam) + public function __construct(string $rawParam) { - $this->getCategoryFromUrl($pageParam); + $this->getCategoryFromUrl($rawParam); - parent::__construct($pageParam); + parent::__construct($rawParam); } protected function generate() : void diff --git a/endpoints/guild/resync.php b/endpoints/guild/resync.php index 2af65bb7..deddcbde 100644 --- a/endpoints/guild/resync.php +++ b/endpoints/guild/resync.php @@ -13,9 +13,9 @@ class GuildResyncResponse extends TextResponse 'profile' => ['filter' => FILTER_CALLBACK, 'options' => [self::class, 'checkEmptySet']] ); - public function __construct(string $pageParam) + public function __construct(string $rawParam) { - parent::__construct($pageParam); + parent::__construct($rawParam); if (!Cfg::get('PROFILER_ENABLE')) $this->generate404(); diff --git a/endpoints/guild/status.php b/endpoints/guild/status.php index 128cc5fd..df311ee0 100644 --- a/endpoints/guild/status.php +++ b/endpoints/guild/status.php @@ -12,9 +12,9 @@ class GuildStatusResponse extends TextResponse 'id' => ['filter' => FILTER_CALLBACK, 'options' => [self::class, 'checkIdList']] ); - public function __construct(string $pageParam) + public function __construct(string $rawParam) { - parent::__construct($pageParam); + parent::__construct($rawParam); if (!Cfg::get('PROFILER_ENABLE')) $this->generate404(); diff --git a/endpoints/guilds/guilds.php b/endpoints/guilds/guilds.php index 8a1f1391..38f76557 100644 --- a/endpoints/guilds/guilds.php +++ b/endpoints/guilds/guilds.php @@ -29,14 +29,14 @@ class GuildsBaseResponse extends TemplateResponse implements IProfilerList private int $sumSubjects = 0; - public function __construct(string $pageParam) + public function __construct(string $rawParam) { if (!Cfg::get('PROFILER_ENABLE')) $this->generateError(); - $this->getSubjectFromUrl($pageParam); + $this->getSubjectFromUrl($rawParam); - parent::__construct($pageParam); + parent::__construct($rawParam); $realms = []; foreach (Profiler::getRealms() as $idx => $r) @@ -51,7 +51,9 @@ class GuildsBaseResponse extends TemplateResponse implements IProfilerList $realms[] = $idx; } - $this->subCat = $pageParam !== '' ? '='.$pageParam : ''; + if ($this->category) + $this->subCat = '='.implode('.', $this->category); + $this->filter = new GuildListFilter($this->_get['filter'] ?? '', ['realms' => $realms]); if ($this->filter->shouldReload) { diff --git a/endpoints/help/help.php b/endpoints/help/help.php index 224a0c46..558aef02 100644 --- a/endpoints/help/help.php +++ b/endpoints/help/help.php @@ -17,18 +17,18 @@ class HelpBaseResponse extends TemplateResponse private string $catg = ''; - public function __construct(string $pageParam) + public function __construct(string $rawParam) { - parent::__construct($pageParam); + parent::__construct($rawParam); - if (!$pageParam) + if (!$rawParam) $this->generateError(); - $pageId = array_search($pageParam, $this->validCats); + $pageId = array_search($rawParam, $this->validCats); if ($pageId === false) $this->generateError(); - $this->catg = $pageParam; + $this->catg = $rawParam; } protected function generate() : void diff --git a/endpoints/icons/icons.php b/endpoints/icons/icons.php index 3ceab77a..75464fae 100644 --- a/endpoints/icons/icons.php +++ b/endpoints/icons/icons.php @@ -24,13 +24,15 @@ class IconsBaseResponse extends TemplateResponse implements ICache ); protected array $validCats = [0, 1, 2, 3]; - public function __construct(string $pageParam) + public function __construct(string $rawParam) { - $this->getCategoryFromUrl($pageParam); + $this->getCategoryFromUrl($rawParam); - parent::__construct($pageParam); + parent::__construct($rawParam); + + if ($this->category) + $this->subCat = '='.implode('.', $this->category); - $this->subCat = $pageParam !== '' ? '='.$pageParam : ''; $this->filter = new IconListFilter($this->_get['filter'] ?? '', ['parentCats' => $this->category]); if ($this->filter->shouldReload) { diff --git a/endpoints/items/items.php b/endpoints/items/items.php index 04931ef5..27dde3f5 100644 --- a/endpoints/items/items.php +++ b/endpoints/items/items.php @@ -91,13 +91,15 @@ class ItemsBaseResponse extends TemplateResponse implements ICache 'extraCols' => [] ); - public function __construct(string $pageParam) + public function __construct(string $rawParam) { - $this->getCategoryFromUrl($pageParam); + $this->getCategoryFromUrl($rawParam); - parent::__construct($pageParam); + parent::__construct($rawParam); + + if ($this->category) + $this->subCat = '='.implode('.', $this->category); - $this->subCat = $pageParam !== '' ? '='.$pageParam : ''; $this->filter = new ItemListFilter($this->_get['filter'] ?? '', ['parentCats' => $this->category]); if ($this->filter->shouldReload) { diff --git a/endpoints/itemsets/itemsets.php b/endpoints/itemsets/itemsets.php index 6dd79980..945e5100 100644 --- a/endpoints/itemsets/itemsets.php +++ b/endpoints/itemsets/itemsets.php @@ -24,13 +24,15 @@ class ItemsetsBaseResponse extends TemplateResponse implements ICache 'filter' => ['filter' => FILTER_VALIDATE_REGEXP, 'options' => ['regexp' => Filter::PATTERN_PARAM]] ); - public function __construct(string $pageParam) + public function __construct(string $rawParam) { - $this->getCategoryFromUrl($pageParam); + $this->getCategoryFromUrl($rawParam); - parent::__construct($pageParam); + parent::__construct($rawParam); + + if ($this->category) + $this->subCat = '='.implode('.', $this->category); - $this->subCat = $pageParam !== '' ? '='.$pageParam : ''; $this->filter = new ItemsetListFilter($this->_get['filter'] ?? '', ['parentCats' => $this->category]); if ($this->filter->shouldReload) { diff --git a/endpoints/mails/mails.php b/endpoints/mails/mails.php index 0e7e4c60..e1319aca 100644 --- a/endpoints/mails/mails.php +++ b/endpoints/mails/mails.php @@ -18,11 +18,11 @@ class MailsBaseResponse extends TemplateResponse implements ICache protected ?int $activeTab = parent::TAB_DATABASE; protected array $breadcrumb = [0, 103]; - public function __construct(string $pageParam) + public function __construct(string $rawParam) { - $this->getCategoryFromUrl($pageParam); + $this->getCategoryFromUrl($rawParam); - parent::__construct($pageParam); + parent::__construct($rawParam); } protected function generate() : void diff --git a/endpoints/most-comments/most-comments.php b/endpoints/most-comments/most-comments.php index 7d4f178e..f72baec6 100644 --- a/endpoints/most-comments/most-comments.php +++ b/endpoints/most-comments/most-comments.php @@ -15,11 +15,11 @@ class MostcommentsBaseResponse extends TemplateResponse protected array $validCats = [1, 7, 30]; - public function __construct($pageParam) + public function __construct($rawParam) { - $this->getCategoryFromUrl($pageParam); + $this->getCategoryFromUrl($rawParam); - parent::__construct($pageParam); + parent::__construct($rawParam); } protected function onInvalidCategory() : never diff --git a/endpoints/most-comments/most-comments_rss.php b/endpoints/most-comments/most-comments_rss.php index da5a1baf..95ae25ea 100644 --- a/endpoints/most-comments/most-comments_rss.php +++ b/endpoints/most-comments/most-comments_rss.php @@ -14,9 +14,9 @@ class MostcommentsRssResponse extends TextResponse private array $validCats = [1, 7, 30]; - public function __construct($pageParam) + public function __construct($rawParam) { - parent::__construct($pageParam); + parent::__construct($rawParam); if ($this->params && !in_array($this->params[0], $this->validCats)) $this->forward('?most-comments=1&rss'); diff --git a/endpoints/my-guides/my-guides.php b/endpoints/my-guides/my-guides.php index 288d87aa..f335369f 100644 --- a/endpoints/my-guides/my-guides.php +++ b/endpoints/my-guides/my-guides.php @@ -17,11 +17,11 @@ class MyguidesBaseResponse extends TemplateResponse protected ?int $activeTab = parent::TAB_GUIDES; // protected array $breadcrumb = [6]; // breadcrumb menu not displayed by WH.? - public function __construct(string $pageParam) + public function __construct(string $rawParam) { - parent::__construct($pageParam); + parent::__construct($rawParam); - if (!User::isLoggedIn() || $pageParam) + if (!User::isLoggedIn() || $rawParam) $this->generateError(); } diff --git a/endpoints/npcs/npcs.php b/endpoints/npcs/npcs.php index 72649067..de03c9a4 100644 --- a/endpoints/npcs/npcs.php +++ b/endpoints/npcs/npcs.php @@ -27,13 +27,15 @@ class NpcsBaseResponse extends TemplateResponse implements ICache public bool $petFamPanel = false; - public function __construct(string $pageParam) + public function __construct(string $rawParam) { - $this->getCategoryFromUrl($pageParam); + $this->getCategoryFromUrl($rawParam); - parent::__construct($pageParam); + parent::__construct($rawParam); + + if ($this->category) + $this->subCat = '='.implode('.', $this->category); - $this->subCat = $pageParam !== '' ? '='.$pageParam : ''; $this->filter = new CreatureListFilter($this->_get['filter'] ?? '', ['parentCats' => $this->category]); if ($this->filter->shouldReload) { @@ -93,6 +95,8 @@ class NpcsBaseResponse extends TemplateResponse implements ICache /****************/ $this->redButtons[BUTTON_WOWHEAD] = true; + if ($fiQuery = $this->filter->buildGETParam()) + $this->wowheadLink .= '&filter='.$fiQuery; // beast subtypes are selected via filter $tabData = ['data' => []]; diff --git a/endpoints/objects/objects.php b/endpoints/objects/objects.php index 487e806d..cf4d8976 100644 --- a/endpoints/objects/objects.php +++ b/endpoints/objects/objects.php @@ -27,13 +27,15 @@ class ObjectsBaseResponse extends TemplateResponse implements ICache public bool $petFamPanel = false; - public function __construct(string $pageParam) + public function __construct(string $rawParam) { - $this->getCategoryFromUrl($pageParam); + $this->getCategoryFromUrl($rawParam); - parent::__construct($pageParam); + parent::__construct($rawParam); + + if ($this->category) + $this->subCat = '='.implode('.', $this->category); - $this->subCat = $pageParam !== '' ? '='.$pageParam : ''; $this->filter = new GameObjectListFilter($this->_get['filter'] ?? '', ['parentCats' => $this->category]); if ($this->filter->shouldReload) { diff --git a/endpoints/pets/pets.php b/endpoints/pets/pets.php index 50ac423a..c95fcc5c 100644 --- a/endpoints/pets/pets.php +++ b/endpoints/pets/pets.php @@ -20,11 +20,11 @@ class PetsBaseResponse extends TemplateResponse implements ICache protected array $validCats = [PET_TALENT_TYPE_FEROCITY, PET_TALENT_TYPE_TENACITY, PET_TALENT_TYPE_CUNNING]; - public function __construct(string $pageParam) + public function __construct(string $rawParam) { - $this->getCategoryFromUrl($pageParam); + $this->getCategoryFromUrl($rawParam); - parent::__construct($pageParam); + parent::__construct($rawParam); } protected function generate() : void diff --git a/endpoints/privilege/privilege.php b/endpoints/privilege/privilege.php index 6b4d30b7..9065193e 100644 --- a/endpoints/privilege/privilege.php +++ b/endpoints/privilege/privilege.php @@ -34,17 +34,17 @@ class PrivilegeBaseResponse extends TemplateResponse 17 => 'REP_REQ_PREMIUM' // premium status ); - public function __construct(string $pageParam) + public function __construct(string $rawParam) { - $this->getCategoryFromUrl($pageParam); + $this->getCategoryFromUrl($rawParam); - parent::__construct($pageParam); + parent::__construct($rawParam); - if (!$pageParam) + if (!$rawParam) $this->generateError(); // apply actual values - $this->repVal = Cfg::get($this->req2priv[$pageParam]); + $this->repVal = Cfg::get($this->req2priv[$rawParam]); } protected function generate() : void diff --git a/endpoints/privileges/privileges.php b/endpoints/privileges/privileges.php index 68a80ed3..83857f04 100644 --- a/endpoints/privileges/privileges.php +++ b/endpoints/privileges/privileges.php @@ -31,11 +31,11 @@ class PrivilegesBaseResponse extends TemplateResponse 17 => 'REP_REQ_PREMIUM' // premium status ); - public function __construct(string $pageParam) + public function __construct(string $rawParam) { - parent::__construct($pageParam); + parent::__construct($rawParam); - if ($pageParam) + if ($rawParam) $this->generateError(); // apply actual values and order by requirement ASC diff --git a/endpoints/profile/avatar.php b/endpoints/profile/avatar.php index 6b6ce37f..34a73734 100644 --- a/endpoints/profile/avatar.php +++ b/endpoints/profile/avatar.php @@ -26,9 +26,9 @@ class ProfileAvatarResponse extends TextResponse 'size' => ['filter' => FILTER_CALLBACK, 'options' => [self::class, 'checkTextLine']] ); - public function __construct(string $pageParam) + public function __construct(string $rawParam) { - parent::__construct($pageParam); + parent::__construct($rawParam); if (!Cfg::get('PROFILER_ENABLE')) $this->generate404(); diff --git a/endpoints/profile/delete.php b/endpoints/profile/delete.php index 15a8e961..895755dc 100644 --- a/endpoints/profile/delete.php +++ b/endpoints/profile/delete.php @@ -14,9 +14,9 @@ class ProfileDeleteResponse extends TextResponse 'id' => ['filter' => FILTER_CALLBACK, 'options' => [self::class, 'checkIdList']], ); - public function __construct(string $pageParam) + public function __construct(string $rawParam) { - parent::__construct($pageParam); + parent::__construct($rawParam); if (!Cfg::get('PROFILER_ENABLE')) $this->generate404(); diff --git a/endpoints/profile/link.php b/endpoints/profile/link.php index 63a7434f..2ba9cea8 100644 --- a/endpoints/profile/link.php +++ b/endpoints/profile/link.php @@ -14,9 +14,9 @@ class ProfileLinkResponse extends TextResponse 'id' => ['filter' => FILTER_VALIDATE_INT] ); - public function __construct(string $pageParam) + public function __construct(string $rawParam) { - parent::__construct($pageParam); + parent::__construct($rawParam); if (!Cfg::get('PROFILER_ENABLE')) $this->generate404(); diff --git a/endpoints/profile/load.php b/endpoints/profile/load.php index 8c0d2e95..08b996cf 100644 --- a/endpoints/profile/load.php +++ b/endpoints/profile/load.php @@ -13,9 +13,9 @@ class ProfileLoadResponse extends TextResponse 'items' => ['filter' => FILTER_CALLBACK, 'options' => [self::class, 'checkItemList']] ); - public function __construct(string $pageParam) + public function __construct(string $rawParam) { - parent::__construct($pageParam); + parent::__construct($rawParam); if (!Cfg::get('PROFILER_ENABLE')) $this->generate404(); diff --git a/endpoints/profile/pin.php b/endpoints/profile/pin.php index aef2ef64..d8da5418 100644 --- a/endpoints/profile/pin.php +++ b/endpoints/profile/pin.php @@ -15,9 +15,9 @@ class ProfilePinResponse extends TextResponse 'user' => ['filter' => FILTER_CALLBACK, 'options' => [Util::class, 'validateUsername']] ); - public function __construct(string $pageParam) + public function __construct(string $rawParam) { - parent::__construct($pageParam); + parent::__construct($rawParam); if (!Cfg::get('PROFILER_ENABLE')) $this->generate404(); diff --git a/endpoints/profile/private.php b/endpoints/profile/private.php index 5c72d9a5..1e8433fa 100644 --- a/endpoints/profile/private.php +++ b/endpoints/profile/private.php @@ -16,9 +16,9 @@ class ProfilePrivateResponse extends TextResponse // 'bookmarked' => ['filter' => FILTER_CALLBACK, 'options' => [self::class, 'checkEmptySet'] ] // something with signatures? (must have bookmarked profile to create signature from) ); - public function __construct(string $pageParam) + public function __construct(string $rawParam) { - parent::__construct($pageParam); + parent::__construct($rawParam); if (!Cfg::get('PROFILER_ENABLE')) $this->generate404(); diff --git a/endpoints/profile/profile_power.php b/endpoints/profile/profile_power.php index a1a23844..4bb85545 100644 --- a/endpoints/profile/profile_power.php +++ b/endpoints/profile/profile_power.php @@ -19,9 +19,9 @@ class ProfilePowerResponse extends TextResponse implements ICache 'domain' => ['filter' => FILTER_CALLBACK, 'options' => [Locale::class, 'tryFromDomain']] ); - public function __construct(string $pageParam) + public function __construct(string $rawParam) { - parent::__construct($pageParam); + parent::__construct($rawParam); if (!Cfg::get('PROFILER_ENABLE')) $this->generate404(); @@ -30,9 +30,9 @@ class ProfilePowerResponse extends TextResponse implements ICache if ($this->_get['domain']) Lang::load($this->_get['domain']); - $this->getSubjectFromUrl($pageParam); + $this->getSubjectFromUrl($rawParam); - if ($this->subjectName) // pageParam is fully defined profiler string + if ($this->subjectName) // rawParam is fully defined profiler string { // pending rename if (preg_match('/([^\-]+)-(\d+)/i', $this->subjectName, $m)) diff --git a/endpoints/profile/public.php b/endpoints/profile/public.php index 71cb65bb..9193d426 100644 --- a/endpoints/profile/public.php +++ b/endpoints/profile/public.php @@ -16,9 +16,9 @@ class ProfilePublicResponse extends TextResponse // 'bookmarked' => ['filter' => FILTER_CALLBACK, 'options' => [self::class, 'checkEmptySet'] ] // something with signatures? (must have bookmarked profile to create signature from) ); - public function __construct(string $pageParam) + public function __construct(string $rawParam) { - parent::__construct($pageParam); + parent::__construct($rawParam); if (!Cfg::get('PROFILER_ENABLE')) $this->generate404(); diff --git a/endpoints/profile/resync.php b/endpoints/profile/resync.php index afeb0d4c..29ef263a 100644 --- a/endpoints/profile/resync.php +++ b/endpoints/profile/resync.php @@ -12,9 +12,9 @@ class ProfileResyncResponse extends TextResponse 'id' => ['filter' => FILTER_CALLBACK, 'options' => [self::class, 'checkIdList']] ); - public function __construct(string $pageParam) + public function __construct(string $rawParam) { - parent::__construct($pageParam); + parent::__construct($rawParam); if (!Cfg::get('PROFILER_ENABLE')) $this->generate404(); diff --git a/endpoints/profile/save.php b/endpoints/profile/save.php index 51caca81..cf57e651 100644 --- a/endpoints/profile/save.php +++ b/endpoints/profile/save.php @@ -35,9 +35,9 @@ class ProfileSaveResponse extends TextResponse 'inv' => ['filter' => FILTER_CALLBACK, 'options' => [self::class, 'checkIdList'], 'flags' => FILTER_REQUIRE_ARRAY] ); - public function __construct(string $pageParam) + public function __construct(string $rawParam) { - parent::__construct($pageParam); + parent::__construct($rawParam); if (!Cfg::get('PROFILER_ENABLE')) $this->generate404(); diff --git a/endpoints/profile/status.php b/endpoints/profile/status.php index dd5e9b44..117a50e3 100644 --- a/endpoints/profile/status.php +++ b/endpoints/profile/status.php @@ -14,9 +14,9 @@ class ProfileStatusResponse extends TextResponse 'arena-team' => ['filter' => FILTER_CALLBACK, 'options' => [self::class, 'checkEmptySet']] ); - public function __construct(string $pageParam) + public function __construct(string $rawParam) { - parent::__construct($pageParam); + parent::__construct($rawParam); if (!Cfg::get('PROFILER_ENABLE')) $this->generate404(); diff --git a/endpoints/profile/unlink.php b/endpoints/profile/unlink.php index 8904db6e..28aad3a9 100644 --- a/endpoints/profile/unlink.php +++ b/endpoints/profile/unlink.php @@ -15,9 +15,9 @@ class ProfileUnlinkResponse extends TextResponse 'user' => ['filter' => FILTER_CALLBACK, 'options' => [Util::class, 'validateUsername']] ); - public function __construct(string $pageParam) + public function __construct(string $rawParam) { - parent::__construct($pageParam); + parent::__construct($rawParam); if (!Cfg::get('PROFILER_ENABLE')) $this->generate404(); diff --git a/endpoints/profile/unpin.php b/endpoints/profile/unpin.php index 7139f15a..fdb7ad90 100644 --- a/endpoints/profile/unpin.php +++ b/endpoints/profile/unpin.php @@ -15,9 +15,9 @@ class ProfileUnpinResponse extends TextResponse 'user' => ['filter' => FILTER_CALLBACK, 'options' => [Util::class, 'validateUsername']] ); - public function __construct(string $pageParam) + public function __construct(string $rawParam) { - parent::__construct($pageParam); + parent::__construct($rawParam); if (!Cfg::get('PROFILER_ENABLE')) $this->generate404(); diff --git a/endpoints/profiles/profiles.php b/endpoints/profiles/profiles.php index 065065fe..3b3ab0af 100644 --- a/endpoints/profiles/profiles.php +++ b/endpoints/profiles/profiles.php @@ -33,11 +33,11 @@ class ProfilesBaseResponse extends TemplateResponse implements IProfilerList private int $sumSubjects = 0; - public function __construct(string $pageParam) + public function __construct(string $rawParam) { - $this->getSubjectFromUrl($pageParam); + $this->getSubjectFromUrl($rawParam); - parent::__construct($pageParam); + parent::__construct($rawParam); if (!Cfg::get('PROFILER_ENABLE')) $this->generateError(); @@ -55,7 +55,9 @@ class ProfilesBaseResponse extends TemplateResponse implements IProfilerList $realms[] = $idx; } - $this->subCat = $pageParam !== '' ? '='.$pageParam : ''; + if ($this->category) + $this->subCat = '='.implode('.', $this->category); + $this->filter = new ProfileListFilter($this->_get['filter'] ?? '', ['realms' => $realms]); if ($this->filter->shouldReload) { diff --git a/endpoints/quests/quests.php b/endpoints/quests/quests.php index 16bd0f9a..7473577d 100644 --- a/endpoints/quests/quests.php +++ b/endpoints/quests/quests.php @@ -45,13 +45,15 @@ class QuestsBaseResponse extends TemplateResponse implements ICache ); protected array $validCats = Game::QUEST_CLASSES; - public function __construct(string $pageParam) + public function __construct(string $rawParam) { - $this->getCategoryFromUrl($pageParam); + $this->getCategoryFromUrl($rawParam); - parent::__construct($pageParam); + parent::__construct($rawParam); + + if ($this->category) + $this->subCat = '='.implode('.', $this->category); - $this->subCat = $pageParam !== '' ? '='.$pageParam : ''; $this->filter = new QuestListFilter($this->_get['filter'] ?? '', ['parentCats' => $this->category]); if ($this->filter->shouldReload) { diff --git a/endpoints/races/races.php b/endpoints/races/races.php index 6a0733cd..43d370b6 100644 --- a/endpoints/races/races.php +++ b/endpoints/races/races.php @@ -18,11 +18,11 @@ class RacesBaseResponse extends TemplateResponse implements ICache protected ?int $activeTab = parent::TAB_DATABASE; protected array $breadcrumb = [0, 13]; - public function __construct(string $pageParam) + public function __construct(string $rawParam) { - $this->getCategoryFromUrl($pageParam); + $this->getCategoryFromUrl($rawParam); - parent::__construct($pageParam); + parent::__construct($rawParam); } protected function generate() : void diff --git a/endpoints/reputation/reputation.php b/endpoints/reputation/reputation.php index 55d05faa..b47bc33a 100644 --- a/endpoints/reputation/reputation.php +++ b/endpoints/reputation/reputation.php @@ -15,11 +15,11 @@ class ReputationBaseResponse extends TemplateResponse protected ?int $activeTab = parent::TAB_COMMUNITY; protected array $breadcrumb = [3, 10]; - public function __construct(string $pageParam) + public function __construct(string $rawParam) { - parent::__construct($pageParam); + parent::__construct($rawParam); - if ($pageParam) + if ($rawParam) $this->generateError(); } diff --git a/endpoints/screenshot/add.php b/endpoints/screenshot/add.php index f6452771..294a4285 100644 --- a/endpoints/screenshot/add.php +++ b/endpoints/screenshot/add.php @@ -25,9 +25,9 @@ class ScreenshotAddResponse extends TextResponse private int $destType = 0; private int $destTypeId = 0; - public function __construct(string $pageParam) + public function __construct(string $rawParam) { - parent::__construct($pageParam); + parent::__construct($rawParam); // get screenshot destination // target delivered as screenshot=&.. (hash is optional) diff --git a/endpoints/screenshot/complete.php b/endpoints/screenshot/complete.php index 0ea503bc..da331f67 100644 --- a/endpoints/screenshot/complete.php +++ b/endpoints/screenshot/complete.php @@ -30,9 +30,9 @@ class ScreenshotCompleteResponse extends TextResponse private int $destTypeId = 0; private string $imgHash = ''; - public function __construct(string $pageParam) + public function __construct(string $rawParam) { - parent::__construct($pageParam); + parent::__construct($rawParam); // get screenshot destination // target delivered as screenshot=&.. (hash is optional) diff --git a/endpoints/screenshot/crop.php b/endpoints/screenshot/crop.php index cabae726..9f446899 100644 --- a/endpoints/screenshot/crop.php +++ b/endpoints/screenshot/crop.php @@ -32,9 +32,9 @@ class ScreenshotCropResponse extends TemplateResponse public int $destTypeId = 0; public string $imgHash = ''; - public function __construct(string $pageParam) + public function __construct(string $rawParam) { - parent::__construct($pageParam); + parent::__construct($rawParam); // get screenshot destination // target delivered as screenshot=&.. (hash is optional) diff --git a/endpoints/screenshot/thankyou.php b/endpoints/screenshot/thankyou.php index 53b62bfc..d2517671 100644 --- a/endpoints/screenshot/thankyou.php +++ b/endpoints/screenshot/thankyou.php @@ -25,9 +25,9 @@ class ScreenshotThankyouResponse extends TemplateResponse private int $destType = 0; private int $destTypeId = 0; - public function __construct(string $pageParam) + public function __construct(string $rawParam) { - parent::__construct($pageParam); + parent::__construct($rawParam); // get screenshot destination // target delivered as screenshot=&.. (hash is optional) diff --git a/endpoints/search/search.php b/endpoints/search/search.php index 8da47402..11bce6f4 100644 --- a/endpoints/search/search.php +++ b/endpoints/search/search.php @@ -29,11 +29,11 @@ class SearchBaseResponse extends TemplateResponse implements ICache public string $invalidTerms = ''; - public function __construct(string $pageParam) + public function __construct(string $rawParam) { - parent::__construct($pageParam); // just to set g_user and g_locale + parent::__construct($rawParam); // just to set g_user and g_locale - $this->query = $this->_get['search']; // technically pageParam, but prepared + $this->query = $this->_get['search']; // technically rawParam, but prepared $this->searchMask = Search::TYPE_REGULAR | self::SEARCH_MODS_ALL; diff --git a/endpoints/search/search_json.php b/endpoints/search/search_json.php index 1fbec2e8..fa8d4b5c 100644 --- a/endpoints/search/search_json.php +++ b/endpoints/search/search_json.php @@ -33,11 +33,11 @@ class SearchJsonResponse extends TextResponse implements ICache private array $extraOpts = []; // for weighted search private array $extraCnd = []; // for weighted search - public function __construct(string $pageParam) + public function __construct(string $rawParam) { - parent::__construct($pageParam); + parent::__construct($rawParam); - $this->query = $this->_get['search']; // technically pageParam, but prepared + $this->query = $this->_get['search']; // technically rawParam, but prepared if ($this->_get['wt'] && $this->_get['wtv']) // slots and type should get ignored { diff --git a/endpoints/search/search_open.php b/endpoints/search/search_open.php index 04e9198c..699fc3fa 100644 --- a/endpoints/search/search_open.php +++ b/endpoints/search/search_open.php @@ -62,11 +62,11 @@ class SearchOpenResponse extends TextResponse implements ICache 'search' => ['filter' => FILTER_CALLBACK, 'options' => [self::class, 'checkTextLine']] ); - public function __construct(string $pageParam) + public function __construct(string $rawParam) { - parent::__construct($pageParam); // just to set g_user and g_locale + parent::__construct($rawParam); // just to set g_user and g_locale - $this->query = $this->_get['search']; // technically pageParam, but prepared + $this->query = $this->_get['search']; // technically rawParam, but prepared $this->searchMask = Search::TYPE_OPEN | self::SEARCH_MODS_OPEN; diff --git a/endpoints/searchbox/searchbox.php b/endpoints/searchbox/searchbox.php index eda8f931..22c289d9 100644 --- a/endpoints/searchbox/searchbox.php +++ b/endpoints/searchbox/searchbox.php @@ -13,11 +13,11 @@ class SearchboxBaseResponse extends TemplateResponse protected ?int $activeTab = parent::TAB_MORE; protected array $breadcrumb = [2, 16]; - public function __construct(string $pageParam) + public function __construct(string $rawParam) { - parent::__construct($pageParam); + parent::__construct($rawParam); - if ($pageParam) + if ($rawParam) $this->generateError(); } diff --git a/endpoints/searchplugins/searchplugins.php b/endpoints/searchplugins/searchplugins.php index 43925cce..6dd00b1b 100644 --- a/endpoints/searchplugins/searchplugins.php +++ b/endpoints/searchplugins/searchplugins.php @@ -13,11 +13,11 @@ class SearchpluginsBaseResponse extends TemplateResponse protected ?int $activeTab = parent::TAB_MORE; protected array $breadcrumb = [2, 8]; - public function __construct(string $pageParam) + public function __construct(string $rawParam) { - parent::__construct($pageParam); + parent::__construct($rawParam); - if ($pageParam) + if ($rawParam) $this->generateError(); } diff --git a/endpoints/signature/delete.php b/endpoints/signature/delete.php index 3266220c..9a7fa17f 100644 --- a/endpoints/signature/delete.php +++ b/endpoints/signature/delete.php @@ -13,9 +13,9 @@ class SignatureDeleteResponse extends TextResponse 'id' => ['filter' => FILTER_CALLBACK, 'options' => [self::class, 'checkIdListUnsigned']] ); - public function __construct(string $pageParam) + public function __construct(string $rawParam) { - parent::__construct($pageParam); + parent::__construct($rawParam); } protected function generate() : void diff --git a/endpoints/signature/generate.php b/endpoints/signature/generate.php index af88f9d7..a04ef5ac 100644 --- a/endpoints/signature/generate.php +++ b/endpoints/signature/generate.php @@ -24,9 +24,9 @@ class SignatureGenerateResponse extends TextResponse 'id' => ['filter' => FILTER_CALLBACK, 'options' => [self::class, 'checkProfileId']] ); - public function __construct(string $pageParam) + public function __construct(string $rawParam) { - parent::__construct($pageParam); + parent::__construct($rawParam); } protected function generate() : void diff --git a/endpoints/signature/signature.php b/endpoints/signature/signature.php index dfe34e9e..520bbea2 100644 --- a/endpoints/signature/signature.php +++ b/endpoints/signature/signature.php @@ -18,12 +18,12 @@ class SignatureBaseResponse extends TemplateResponse private int $id = 0; - public function __construct(string $pageParam) + public function __construct(string $rawParam) { - parent::__construct($pageParam); + parent::__construct($rawParam); - if ($pageParam) - $this->id = intVal($pageParam); + if ($rawParam) + $this->id = intVal($rawParam); else if ($this->assertGET('profile')) $this->id = $this->_get['profile']; else diff --git a/endpoints/skills/skills.php b/endpoints/skills/skills.php index fc4f1afc..1d1f1a36 100644 --- a/endpoints/skills/skills.php +++ b/endpoints/skills/skills.php @@ -20,11 +20,11 @@ class SkillsBaseResponse extends TemplateResponse implements ICache protected array $validCats = [-6, -5, -4, 6, 7, 8, 9, 10, 11]; - public function __construct(string $pageParam) + public function __construct(string $rawParam) { - $this->getCategoryFromUrl($pageParam); + $this->getCategoryFromUrl($rawParam); - parent::__construct($pageParam); + parent::__construct($rawParam); } protected function generate() : void diff --git a/endpoints/sounds/sounds.php b/endpoints/sounds/sounds.php index 164b3840..eef7a1ea 100644 --- a/endpoints/sounds/sounds.php +++ b/endpoints/sounds/sounds.php @@ -24,15 +24,17 @@ class SoundsBaseResponse extends TemplateResponse implements ICache ); protected array $validCats = [1, 2, 3, 4, 6, 9, 10, 12, 13, 14, 16, 17, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 50, 52, 53]; - public function __construct(string $pageParam) + public function __construct(string $rawParam) { - $this->getCategoryFromUrl($pageParam); + $this->getCategoryFromUrl($rawParam); if ($this->category) $this->forward('?sounds&filter=ty='.$this->category[0]); - parent::__construct($pageParam); + parent::__construct($rawParam); + + if ($this->category) + $this->subCat = '='.implode('.', $this->category); - $this->subCat = $pageParam !== '' ? '='.$pageParam : ''; $this->filter = new SoundListFilter($this->_get['filter'] ?? '', ['parentCats' => $this->category]); if ($this->filter->shouldReload) { diff --git a/endpoints/spells/spells.php b/endpoints/spells/spells.php index 023a0bf9..b7c5674c 100644 --- a/endpoints/spells/spells.php +++ b/endpoints/spells/spells.php @@ -91,13 +91,15 @@ class SpellsBaseResponse extends TemplateResponse implements ICache public bool $classPanel = false; public bool $glyphPanel = false; - public function __construct(string $pageParam) + public function __construct(string $rawParam) { - $this->getCategoryFromUrl($pageParam); + $this->getCategoryFromUrl($rawParam); - parent::__construct($pageParam); + parent::__construct($rawParam); + + if ($this->category) + $this->subCat = '='.implode('.', $this->category); - $this->subCat = $pageParam !== '' ? '='.$pageParam : ''; $this->filter = new SpellListFilter($this->_get['filter'] ?? '', ['parentCats' => $this->category]); if ($this->filter->shouldReload) { diff --git a/endpoints/titles/titles.php b/endpoints/titles/titles.php index 198b2271..a6c3d4d5 100644 --- a/endpoints/titles/titles.php +++ b/endpoints/titles/titles.php @@ -20,11 +20,11 @@ class TitlesBaseResponse extends TemplateResponse implements ICache protected array $validCats = [0, 1, 2, 3, 4, 5, 6]; - public function __construct(string $pageParam) + public function __construct(string $rawParam) { - $this->getCategoryFromUrl($pageParam); + $this->getCategoryFromUrl($rawParam); - parent::__construct($pageParam); + parent::__construct($rawParam); } protected function generate() : void diff --git a/endpoints/tooltips/tooltips.php b/endpoints/tooltips/tooltips.php index d9507e36..7ead16a0 100644 --- a/endpoints/tooltips/tooltips.php +++ b/endpoints/tooltips/tooltips.php @@ -13,11 +13,11 @@ class TooltipsBaseResponse extends TemplateResponse protected ?int $activeTab = parent::TAB_MORE; protected array $breadcrumb = [2, 10]; - public function __construct(string $pageParam) + public function __construct(string $rawParam) { - parent::__construct($pageParam); + parent::__construct($rawParam); - if ($pageParam) + if ($rawParam) $this->generateError(); } diff --git a/endpoints/top-users/top-users.php b/endpoints/top-users/top-users.php index 038fd699..4d3be418 100644 --- a/endpoints/top-users/top-users.php +++ b/endpoints/top-users/top-users.php @@ -15,11 +15,11 @@ class TopusersBaseResponse extends TemplateResponse protected ?int $activeTab = parent::TAB_COMMUNITY; protected array $breadcrumb = [3, 11]; - public function __construct(string $pageParam) + public function __construct(string $rawParam) { - parent::__construct($pageParam); + parent::__construct($rawParam); - if ($pageParam) + if ($rawParam) $this->generateError(); } diff --git a/endpoints/upload/image-complete.php b/endpoints/upload/image-complete.php index 10f9ea3b..1c60a39e 100644 --- a/endpoints/upload/image-complete.php +++ b/endpoints/upload/image-complete.php @@ -19,12 +19,12 @@ class UploadImagecompleteResponse extends TextResponse public string $imgHash; public int $newId; - public function __construct(string $pageParam) + public function __construct(string $rawParam) { if (User::isBanned()) $this->generate404(); - parent::__construct($pageParam); + parent::__construct($rawParam); if (!preg_match('/^upload=image-complete&(\d+)\.(\w{16})$/i', $_SERVER['QUERY_STRING'] ?? '', $m, PREG_UNMATCHED_AS_NULL)) $this->generate404(); diff --git a/endpoints/upload/image-crop.php b/endpoints/upload/image-crop.php index ba046dd6..edd6444b 100644 --- a/endpoints/upload/image-crop.php +++ b/endpoints/upload/image-crop.php @@ -23,12 +23,12 @@ class UploadImagecropResponse extends TemplateResponse public int $nextId = 0; public string $imgHash = ''; - public function __construct(string $pageParam) + public function __construct(string $rawParam) { if (User::isBanned()) $this->generateError(); - parent::__construct($pageParam); + parent::__construct($rawParam); } protected function generate() : void diff --git a/endpoints/user/user.php b/endpoints/user/user.php index f1b01a12..3d33c677 100644 --- a/endpoints/user/user.php +++ b/endpoints/user/user.php @@ -28,24 +28,24 @@ class UserBaseResponse extends TemplateResponse private array $user = []; - public function __construct($pageParam) + public function __construct($rawParam) { - parent::__construct($pageParam); + parent::__construct($rawParam); - if (!$pageParam && User::isLoggedIn()) + if (!$rawParam && User::isLoggedIn()) $this->forward('?user='.User::$username); - if (!$pageParam) + if (!$rawParam) $this->forwardToSignIn('user'); - if ($user = DB::Aowow()->selectRow('SELECT a.`id`, a.`username`, a.`consecutiveVisits`, a.`userGroups`, a.`avatar`, a.`avatarborder`, a.`wowicon`, a.`title`, a.`description`, a.`joinDate`, a.`prevLogin`, IFNULL(SUM(ar.`amount`), 0) AS "sumRep", a.`prevIP`, a.`email` FROM ?_account a LEFT JOIN ?_account_reputation ar ON a.`id` = ar.`userId` WHERE LOWER(a.`username`) = LOWER(?) GROUP BY a.`id`', $pageParam)) + if ($user = DB::Aowow()->selectRow('SELECT a.`id`, a.`username`, a.`consecutiveVisits`, a.`userGroups`, a.`avatar`, a.`avatarborder`, a.`wowicon`, a.`title`, a.`description`, a.`joinDate`, a.`prevLogin`, IFNULL(SUM(ar.`amount`), 0) AS "sumRep", a.`prevIP`, a.`email` FROM ?_account a LEFT JOIN ?_account_reputation ar ON a.`id` = ar.`userId` WHERE LOWER(a.`username`) = LOWER(?) GROUP BY a.`id`', $rawParam)) $this->user = $user; else - $this->generateNotFound(Lang::user('notFound', [$pageParam])); + $this->generateNotFound(Lang::user('notFound', [$rawParam])); // do not display system account if (!$this->user['id']) - $this->generateNotFound(Lang::user('notFound', [$pageParam])); + $this->generateNotFound(Lang::user('notFound', [$rawParam])); } protected function generate() : void diff --git a/endpoints/video/add.php b/endpoints/video/add.php index 36c67ebc..9459e9a9 100644 --- a/endpoints/video/add.php +++ b/endpoints/video/add.php @@ -27,9 +27,9 @@ class VideoAddResponse extends TextResponse private int $destType = 0; private int $destTypeId = 0; - public function __construct(string $pageParam) + public function __construct(string $rawParam) { - parent::__construct($pageParam); + parent::__construct($rawParam); // get video destination // target delivered as video=&.. (hash is optional) diff --git a/endpoints/video/complete.php b/endpoints/video/complete.php index 46cf9d0b..c36cb959 100644 --- a/endpoints/video/complete.php +++ b/endpoints/video/complete.php @@ -27,9 +27,9 @@ class VideoCompleteResponse extends TextResponse private int $destType = 0; private int $destTypeId = 0; - public function __construct(string $pageParam) + public function __construct(string $rawParam) { - parent::__construct($pageParam); + parent::__construct($rawParam); // get video destination // target delivered as video=&.. (hash is optional) diff --git a/endpoints/video/confirm.php b/endpoints/video/confirm.php index 055670ef..46ed385a 100644 --- a/endpoints/video/confirm.php +++ b/endpoints/video/confirm.php @@ -32,9 +32,9 @@ class VideoConfirmResponse extends TemplateResponse public array $video = []; public string $viTitle = ''; - public function __construct(string $pageParam) + public function __construct(string $rawParam) { - parent::__construct($pageParam); + parent::__construct($rawParam); // get video destination // target delivered as video=&.. (hash is optional) diff --git a/endpoints/video/thankyou.php b/endpoints/video/thankyou.php index c90e7922..f07822ee 100644 --- a/endpoints/video/thankyou.php +++ b/endpoints/video/thankyou.php @@ -23,9 +23,9 @@ class VideoThankyouResponse extends TemplateResponse private int $destType = 0; private int $destTypeId = 0; - public function __construct(string $pageParam) + public function __construct(string $rawParam) { - parent::__construct($pageParam); + parent::__construct($rawParam); // get video destination // target delivered as video=&. diff --git a/endpoints/whats-new/whats-new.php b/endpoints/whats-new/whats-new.php index 080a69c4..63124dfe 100644 --- a/endpoints/whats-new/whats-new.php +++ b/endpoints/whats-new/whats-new.php @@ -13,11 +13,11 @@ class WhatsnewBaseResponse extends TemplateResponse protected ?int $activeTab = parent::TAB_MORE; protected array $breadcrumb = [2, 7]; - public function __construct(string $pageParam) + public function __construct(string $rawParam) { - parent::__construct($pageParam); + parent::__construct($rawParam); - if ($pageParam) + if ($rawParam) $this->generateError(); } diff --git a/endpoints/zones/zones.php b/endpoints/zones/zones.php index cc2e6d63..1909c6b1 100644 --- a/endpoints/zones/zones.php +++ b/endpoints/zones/zones.php @@ -23,11 +23,11 @@ class ZonesBaseResponse extends TemplateResponse implements ICache public ?array $map = null; - public function __construct(string $pageParam) + public function __construct(string $rawParam) { - $this->getCategoryFromUrl($pageParam); + $this->getCategoryFromUrl($rawParam); - parent::__construct($pageParam); + parent::__construct($rawParam); } protected function generate() : void diff --git a/includes/components/response/templateresponse.class.php b/includes/components/response/templateresponse.class.php index f97db6b4..9062d358 100644 --- a/includes/components/response/templateresponse.class.php +++ b/includes/components/response/templateresponse.class.php @@ -31,7 +31,7 @@ trait TrDetailPage trait TrListPage { - public ?string $subCat = null; + public string $subCat = ''; public ?Filter $filter = null; public function getCacheKeyComponents() : array @@ -150,7 +150,7 @@ class TemplateResponse extends BaseResponse public array $pageTemplate = []; // js PageTemplate object public array $jsGlobals = []; // ready to be used in template - public function __construct(string $pageParam = '') + public function __construct(string $rawParam = '') { $this->title[] = Cfg::get('NAME'); self::$time = microtime(true); @@ -158,8 +158,8 @@ class TemplateResponse extends BaseResponse parent::__construct(); $this->fullParams = $this->pageName; - if ($pageParam) - $this->fullParams .= '='.$pageParam; + if ($this->category) + $this->fullParams .= '='.implode('.', $this->category); // prep js+css includes $parentVars = get_class_vars(__CLASS__); @@ -175,7 +175,7 @@ class TemplateResponse extends BaseResponse if ($this->pageName) { - $this->wowheadLink = sprintf(WOWHEAD_LINK, Lang::getLocale()->domain(), $this->pageName, $pageParam ? '=' . $pageParam : ''); + $this->wowheadLink = sprintf(WOWHEAD_LINK, Lang::getLocale()->domain(), $this->fullParams, ''); $this->pageTemplate['pageName'] = $this->pageName; } @@ -672,15 +672,13 @@ class TemplateResponse extends BaseResponse // has a valid combination of categories private function isValidPage() : bool { - if (!$this->category || !$this->validCats) + if (!$this->category) return true; $c = $this->category; // shorthand switch (count($c)) { - case 0: // no params works always - return true; case 1: // null is valid || value in a 1-dim-array || (key for a n-dim-array && ( has more subcats || no further subCats )) $filtered = array_filter($this->validCats, fn ($x) => is_int($x)); return $c[0] === null || in_array($c[0], $filtered) || (!empty($this->validCats[$c[0]]) && (is_array($this->validCats[$c[0]]) || $this->validCats[$c[0]] === true)); diff --git a/includes/components/response/textresponse.class.php b/includes/components/response/textresponse.class.php index cfcc3167..1541d239 100644 --- a/includes/components/response/textresponse.class.php +++ b/includes/components/response/textresponse.class.php @@ -96,12 +96,12 @@ class TextResponse extends BaseResponse protected array $params = []; /// generation stats - protected static float $time = 0.0; + protected static float $time = 0.0; - public function __construct(string $pageParam = '') + public function __construct(string $rawParam = '') { self::$time = microtime(true); - $this->params = explode('.', $pageParam); + $this->params = explode('.', $rawParam); // todo - validate params? parent::__construct(); diff --git a/index.php b/index.php index 4c267ea9..9cb4cc2f 100644 --- a/index.php +++ b/index.php @@ -23,8 +23,9 @@ foreach ($query as $page => $param) // fix page calls - pages like search use the page call directly and expect it as lower case if (preg_match('/[A-Z]/', $page)) { - $url = str_replace('?'.$page.'=', '?'.Util::lower($page).'=', $_SERVER['REQUEST_URI']); - header('Location: '.$url, true, 302); + $url = explode('=', $_SERVER['REQUEST_URI'], 2); + $page = Util::lower(array_shift($url)).($url ? '=' . $url[0] : ''); + header('Location: '.$page, true, 302); exit; }