mirror of
https://github.com/slawkens/myaac.git
synced 2025-10-13 17:24:54 +02:00
Add option to use ?subtopic=x for plugins pages
This commit is contained in:
@@ -88,8 +88,10 @@ if($logged && $account_logged && $account_logged->isLoaded()) {
|
||||
/**
|
||||
* Routes loading
|
||||
*/
|
||||
$routesFinal = [];
|
||||
$dispatcher = FastRoute\cachedDispatcher(function (FastRoute\RouteCollector $r) {
|
||||
$routesFinal = [];
|
||||
global $routesFinal;
|
||||
|
||||
foreach(getDatabasePages() as $page) {
|
||||
$routesFinal[] = ['*', $page, '__database__/' . $page, 100];
|
||||
}
|
||||
@@ -165,7 +167,7 @@ $dispatcher = FastRoute\cachedDispatcher(function (FastRoute\RouteCollector $r)
|
||||
echo '</pre>';
|
||||
die;
|
||||
*/
|
||||
foreach ($routesFinal as $route) {
|
||||
foreach ($routesFinal as &$route) {
|
||||
if ($route[0] === '*') {
|
||||
$route[0] = ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'HEAD'];
|
||||
}
|
||||
@@ -212,7 +214,7 @@ $found = true;
|
||||
|
||||
// old support for pages like /?subtopic=accountmanagement
|
||||
$page = $_REQUEST['p'] ?? ($_REQUEST['subtopic'] ?? '');
|
||||
if(!empty($page) && preg_match('/^[A-z0-9\-]+$/', $page)) {
|
||||
if(!empty($page) && preg_match('/^[A-z0-9\/\-]+$/', $page)) {
|
||||
if (isset($_REQUEST['p'])) { // some plugins may require this
|
||||
$_REQUEST['subtopic'] = $_REQUEST['p'];
|
||||
}
|
||||
@@ -221,10 +223,21 @@ if(!empty($page) && preg_match('/^[A-z0-9\-]+$/', $page)) {
|
||||
require SYSTEM . 'compat/pages.php';
|
||||
}
|
||||
|
||||
$foundRoute = false;
|
||||
foreach ($routesFinal as $route) {
|
||||
if ($page === $route[1]) {
|
||||
$file = $route[2];
|
||||
$foundRoute = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$foundRoute) {
|
||||
$file = loadPageFromFileSystem($page, $found);
|
||||
if(!$found) {
|
||||
$file = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
$routeInfo = $dispatcher->dispatch($httpMethod, $uri);
|
||||
|
Reference in New Issue
Block a user