diff --git a/ajax.php b/controllers/ajax.php similarity index 86% rename from ajax.php rename to controllers/ajax.php index abe638c8e..bc6fbc562 100644 --- a/ajax.php +++ b/controllers/ajax.php @@ -10,7 +10,10 @@ define('BB_SCRIPT', 'ajax'); define('IN_AJAX', true); -require __DIR__ . '/common.php'; +// Skip loading common.php if already loaded (when run through routing system) +if (!defined('IN_TORRENTPIER')) { + require __DIR__ . '/../common.php'; +} // Init Ajax class $ajax = new TorrentPier\Ajax(); diff --git a/src/Presentation/Http/Routes/web.php b/src/Presentation/Http/Routes/web.php index f006ebd24..04fca7efb 100644 --- a/src/Presentation/Http/Routes/web.php +++ b/src/Presentation/Http/Routes/web.php @@ -13,6 +13,7 @@ return function (Router $router): void { // Legacy controller routes (hacky but organized approach) $legacyRoutes = [ + 'ajax.php', 'index.php', 'terms.php', // Add more legacy controllers here as needed: @@ -23,15 +24,15 @@ return function (Router $router): void { foreach ($legacyRoutes as $route) { // Route with .php extension - $router->get('/' . $route, [LegacyController::class, 'handle']); + $router->any('/' . $route, [LegacyController::class, 'handle']); // Route without .php extension (e.g., /terms for /terms.php) $routeWithoutExtension = str_replace('.php', '', $route); - $router->get('/' . $routeWithoutExtension, [LegacyController::class, 'handle']); + $router->any('/' . $routeWithoutExtension, [LegacyController::class, 'handle']); } // Root route should serve the legacy index.php controller - $router->get('/', [LegacyController::class, 'handle']); + $router->any('/', [LegacyController::class, 'handle']); // Future modern routes will be added here };