mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-05-07 03:29:19 +02:00
fix: router.php — bypass admin requests to front controller
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
* Router script for PHP built-in development server (php -S).
|
* Router script for PHP built-in development server (php -S).
|
||||||
*
|
*
|
||||||
* All non-asset requests go through the front controller (public/index.php).
|
* All non-asset requests go through the front controller (public/index.php).
|
||||||
* Static files (CSS, JS, images, fonts) are served directly.
|
* Admin panel and static files are served directly.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$uri = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
|
$uri = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
|
||||||
@@ -14,6 +14,19 @@ if (in_array($ext, ['css', 'js', 'png', 'jpg', 'jpeg', 'gif', 'ico', 'svg', 'wof
|
|||||||
return false; // serve directly
|
return false; // serve directly
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Admin panel: serve files directly
|
||||||
|
if (str_starts_with($uri, '/admin')) {
|
||||||
|
// Rewrite /admin → /admin/index.php
|
||||||
|
$file = __DIR__ . '/public' . $uri;
|
||||||
|
if (is_dir($file)) {
|
||||||
|
$file .= '/index.php';
|
||||||
|
}
|
||||||
|
if (file_exists($file)) {
|
||||||
|
include $file;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Send everything else through the front controller
|
// Send everything else through the front controller
|
||||||
$_SERVER['SCRIPT_NAME'] = '/index.php';
|
$_SERVER['SCRIPT_NAME'] = '/index.php';
|
||||||
require __DIR__ . '/public/index.php';
|
require __DIR__ . '/public/index.php';
|
||||||
|
|||||||
Reference in New Issue
Block a user