diff --git a/exam/.htaccess b/exam/.htaccess new file mode 100644 index 0000000..172d75e --- /dev/null +++ b/exam/.htaccess @@ -0,0 +1,35 @@ +RewriteEngine On + +## +## You may need to uncomment the following line for some hosting environments, +## if you have installed to a subdirectory, enter the name here also. +## +RewriteBase /phpCourse/exam + +## +## Black listed folders +## +RewriteRule ^phpCourse/exam/config/.* index.php [L,NC] +RewriteRule ^phpCourse/exam/vendor/.* index.php [L,NC] +RewriteRule ^phpCourse/exam/routes/.* index.php [L,NC] + +## +## White listed folders +## +RewriteCond %{REQUEST_FILENAME} -f +RewriteCond %{REQUEST_FILENAME} !/api/docs/.* +RewriteCond %{REQUEST_FILENAME} !/pages/.* +RewriteRule !^index.php index.php [L,NC] + +## +## Block all PHP files, except index +## +RewriteCond %{REQUEST_FILENAME} -f +RewriteCond %{REQUEST_FILENAME} \.php$ +RewriteRule !^index.php index.php [L,NC] + +## +## Standard routes +## +RewriteCond %{REQUEST_FILENAME} !-f +RewriteRule ^ index.php [L] \ No newline at end of file diff --git a/exam/Api/Login/Login.php b/exam/Api/Login/Login.php new file mode 100644 index 0000000..758c78b --- /dev/null +++ b/exam/Api/Login/Login.php @@ -0,0 +1,11 @@ +register(EventHandler::EVENT_ADD_ROUTE, function (EventArgument $event) use ($basePath) { + $route = $event->route; + // Skip routes added by group as these will inherit the url + if ($event->isSubRoute) { + return; + } + // Prepend based on what type of Route + switch (true) { + case $route instanceof ILoadableRoute: + $route->prependUrl($basePath); + break; + case $route instanceof IGroupRoute: + $route->prependPrefix($basePath); + break; + } +}); +// Add the handler +SimpleRouter::addEventHandler($eventHandler); +// Load external routes file +require_once __DIR__ . '/routes/routes.php'; +// Start the routing +SimpleRouter::start(); diff --git a/exam/routes/.htaccess b/exam/routes/.htaccess new file mode 100644 index 0000000..872a3ce --- /dev/null +++ b/exam/routes/.htaccess @@ -0,0 +1,3 @@ +Order deny,allow +Deny from all +Allow from 127.0.0.1 \ No newline at end of file diff --git a/exam/routes/routes.php b/exam/routes/routes.php new file mode 100644 index 0000000..a8e779e --- /dev/null +++ b/exam/routes/routes.php @@ -0,0 +1,12 @@ +