From 590fe0762d33411bb4c2ee81c87567294bb5082d Mon Sep 17 00:00:00 2001
From: slawkens <slawkens@gmail.com>
Date: Tue, 14 Feb 2023 22:03:22 +0100
Subject: [PATCH] small fixes

---
 system/router.php            | 11 +++++++----
 templates/tibiacom/index.php |  2 +-
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/system/router.php b/system/router.php
index ff8c7d3d..596121f5 100644
--- a/system/router.php
+++ b/system/router.php
@@ -55,10 +55,9 @@ if (BASE_DIR !== '') {
 
 define('URI', $uri);
 
-/** @var boolean $load_it */
 if(!$load_it) {
 	// ignore warnings in some functions/plugins
-	// page is not loaded anyways
+	// page is not loaded anyway
 	define('PAGE', '');
 
 	return;
@@ -147,6 +146,10 @@ $found = true;
 // old support for pages like /?subtopic=accountmanagement
 $page = $_REQUEST['p'] ?? ($_REQUEST['subtopic'] ?? '');
 if(!empty($page) && preg_match('/^[A-z0-9\-]+$/', $page)) {
+	if (isset($_REQUEST['p'])) { // some plugins may require this
+		$_REQUEST['subtopic'] = $_REQUEST['p'];
+	}
+
 	if (config('backward_support')) {
 		require SYSTEM . 'compat/pages.php';
 	}
@@ -161,7 +164,6 @@ else {
 	switch ($routeInfo[0]) {
 		case FastRoute\Dispatcher::NOT_FOUND:
 			// ... 404 Not Found
-			//var_dump('not found');
 			/**
 			 * Fallback to load page from templates/ or system/pages/ directory
 			 */
@@ -282,7 +284,8 @@ function getDatabasePages() {
 	return $ret;
 }
 
-function loadPageFromFileSystem($page, &$found) {
+function loadPageFromFileSystem($page, &$found): string
+{
 	$file = SYSTEM . 'pages/' . $page . '.php';
 	if (!is_file($file)) {
 		// feature: convert camelCase to snake_case
diff --git a/templates/tibiacom/index.php b/templates/tibiacom/index.php
index 8ebbd5b6..989a05ca 100644
--- a/templates/tibiacom/index.php
+++ b/templates/tibiacom/index.php
@@ -27,7 +27,7 @@ if(isset($config['boxes']))
 		var loginStatus="<?php echo ($logged ? 'true' : 'false'); ?>";
 		<?php
 			if(PAGE !== 'news') {
-				if(strpos(URI, 'subtopic=') !== false) {
+				if(isset($_REQUEST['subtopic'])) {
 					$tmp = $_REQUEST['subtopic'];
 					if($tmp === 'accountmanagement') {
 						$tmp = 'accountmanage';