Posted By

GeekOfWeb on 03/10/11


Tagged

test


Versions (?)

test


 / Published in: PHP
 

  1. require_once '../library/configs/config.php';
  2.  
  3. $url = explode('/',$_SERVER['REQUEST_URI']);
  4. $controller = $url[1] ? $url[1] : 'index';
  5. $action = $url[2] ? $url[2] : 'index';
  6.  
  7. if(preg_match('/[^0-9A-Za-z]/', $controller)){
  8. $controller = 'index';
  9. }
  10.  
  11. if(preg_match('/[^0-9A-Za-z]/', $action)){
  12. $action = 'index';
  13. }
  14.  
  15. $view->setController($controller);
  16. $view->setAction($action);
  17.  
  18. $page = '../public/pages/'.$controller.'/'.$action.'.php';
  19.  
  20. if(!SpoonFile::exists($page))
  21. {
  22. throw new Exception("The page {$controller}/{$action} doenst't exists");
  23. }
  24.  
  25. require_once $page;

Report this snippet  

You need to login to post a comment.