Advertisement
NFL

univManager

NFL
Jul 24th, 2011
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.84 KB | None | 0 0
  1. <?php
  2.  
  3. error_reporting(E_ALL);
  4. $scriptPath = '/';
  5. $uri = mb_substr($_SERVER['REQUEST_URI'], mb_strlen($scriptPath));
  6. $parts = explode('/', $uri);
  7. $controller = (!empty($parts[0]) ? $parts[0] : 'index');
  8. $action = (!empty($parts[1]) ? $parts[1] : 'index');
  9. if (file_exists($_SERVER['DOCUMENT_ROOT'] . $scriptPath . 'controllers/' . $controller . 'Controller.php')) {
  10.     require($_SERVER['DOCUMENT_ROOT'] . $scriptPath . 'controllers/' . $controller . 'Controller.php');
  11.     $class = $controller . 'Controller';
  12.     if (method_exists($class, $action)) {
  13.         $obj = new $class;
  14.         $obj->$action();
  15.     }
  16.     else
  17.         throw new Exception("Undefined action: $action");
  18. } else {
  19.     throw new Exception("Invalid controller specified: {$class}");
  20. }
  21.  
  22. /**
  23. #.htaccess
  24. RewriteEngine on
  25. RewriteBase /
  26.  RewriteRule .*$ index.php [L]
  27. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement