From 89b05effb2eb45382762fcfcfae2373b7754caa7 Mon Sep 17 00:00:00 2001 From: vincent-peugnet Date: Mon, 12 Nov 2018 11:11:58 +0100 Subject: url-cleaning-redirect-correct-id --- app/class/routes.php | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'app/class/routes.php') diff --git a/app/class/routes.php b/app/class/routes.php index 89f82e6..71b75d6 100644 --- a/app/class/routes.php +++ b/app/class/routes.php @@ -12,16 +12,17 @@ class Routes if(!empty(Config::basepath())) { $router->setBasePath(DIRECTORY_SEPARATOR . Config::basepath()); } + $router->addMatchTypes(array('cid' => '[a-zA-Z0-9-_+,\'!%@&.$€=\(\|\)]+')); $router->addRoutes([ ['GET|POST', '/', 'Backrouter#run', 'backrouter'], - ['GET', '/[a:art]/', 'Controllerart#read', 'artread/'], - ['GET', '/[a:art]', 'Controllerart#read', 'artread'], - ['GET', '/[a:art]/add', 'Controllerart#add', 'artadd'], - ['GET', '/[a:art]/edit', 'Controllerart#edit', 'artedit'], - ['GET', '/[a:art]/log', 'Controllerart#log', 'artlog'], - ['POST', '/[a:art]/edit', 'Controllerart#update', 'artupdate'], - ['GET', '/[a:art]/delete', 'Controllerart#confirmdelete', 'artconfirmdelete'], - ['POST', '/[a:art]/delete', 'Controllerart#delete', 'artdelete'], + ['GET', '/[cid:art]/', 'Controllerart#read', 'artread/'], + ['GET', '/[cid:art]', 'Controllerart#read', 'artread'], + ['GET', '/[cid:art]/add', 'Controllerart#add', 'artadd'], + ['GET', '/[cid:art]/edit', 'Controllerart#edit', 'artedit'], + ['GET', '/[cid:art]/log', 'Controllerart#log', 'artlog'], + ['POST', '/[cid:art]/edit', 'Controllerart#update', 'artupdate'], + ['GET', '/[cid:art]/delete', 'Controllerart#confirmdelete', 'artconfirmdelete'], + ['POST', '/[cid:art]/delete', 'Controllerart#delete', 'artdelete'], ]); $match = $router->match(); @@ -36,7 +37,12 @@ class Routes } //404 else { - header($_SERVER["SERVER_PROTOCOL"] . ' 404 Not Found'); + if(!empty(Config::route404())) { + $controller = new Controller($router); + $controller->routedirect('artread/', ['art' => Config::route404()]); + } else { + header($_SERVER["SERVER_PROTOCOL"] . ' 404 Not Found'); + } } } } \ No newline at end of file -- cgit v1.2.3