From 840f74f5c6804f5226c59e3897dc2f46e13ea3a6 Mon Sep 17 00:00:00 2001 From: Antonio de la Rosa Date: Sat, 30 Apr 2022 23:19:21 +0200 Subject: [PATCH] Fixes in routers for permissions --- libraries/Routes.php | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/libraries/Routes.php b/libraries/Routes.php index d339f49..beb9657 100644 --- a/libraries/Routes.php +++ b/libraries/Routes.php @@ -7,6 +7,8 @@ class Config { static public $home_module='welcome'; + static public $modules_allowed=['welcome' => false]; + } function get_controller($controller, $args=[]) { @@ -49,8 +51,12 @@ function get_route($path_info) { case 1: $controller='modules/'.$arr_path[1].'/controllers/index.php'; + echo 'pepe'; + if(Config::$modules_allowed[$arr_path[1]]==true) { - return \PhangoApp\PhaRouter\get_controller($controller, []); + return \PhangoApp\PhaRouter\get_controller($controller, []); + + } break; @@ -58,7 +64,11 @@ function get_route($path_info) { $controller='modules/'.$arr_path[1].'/controllers/'.$arr_path[2].'.php'; - return \PhangoApp\PhaRouter\get_controller($controller, []); + if(Config::$modules_allowed[$arr_path[1]]==true) { + + return \PhangoApp\PhaRouter\get_controller($controller, []); + + } break; @@ -66,9 +76,13 @@ function get_route($path_info) { $controller='modules/'.$arr_path[1].'/controllers/'.$arr_path[2].'.php'; - $args=array_slice($arr_path, 2, count($arr_path)); - - return \PhangoApp\PhaRouter\get_controller($controller, $args); + if(Config::$modules_allowed[$arr_path[1]]==true) { + + $args=array_slice($arr_path, 2, count($arr_path)); + + return \PhangoApp\PhaRouter\get_controller($controller, $args); + + } break; @@ -82,6 +96,14 @@ function get_route($path_info) { return \PhangoApp\PhaRouter\get_controller($controller, []); } + + //If not return, page not found. + + echo 'Page not found'; + + http_response_code(404); + + exit(1); }