Advertisement
Sungper

Php Route A jour

Jun 24th, 2019
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.73 KB | None | 0 0
  1. <?php
  2. include_once('Router.php');
  3. include_once('routes.php');
  4. $configs = include('config.php');
  5. $requestURI = explode('/', $_SERVER['REQUEST_URI']);
  6. $scriptName = explode('/',$_SERVER['SCRIPT_NAME']);
  7. for ($i= 0; $i < sizeof($scriptName); $i++)
  8. {
  9.     if ($requestURI[$i] == $scriptName[$i])
  10.     {
  11.         unset($requestURI[$i]);
  12.     }
  13. }
  14. $command = array_values($requestURI);
  15. $url = '/'.implode('/',$command).'/';
  16. if($url == '//'){
  17.     include_once($configs['pages'].'/'.$configs['home']);
  18.     return;
  19. }
  20. $routes = Router::getArray();
  21. foreach ($routes as $route) {
  22.     if($url == $route['link']){
  23.         include_once($configs['pages'].'/'.$route['url']);
  24.         return;
  25.     }
  26. }
  27. include_once('handler/'.$configs['handler']);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement