예제 #1
0
 public function loader()
 {
     /*         * * check the route ** */
     $this->getController();
     /*         * * if the file is not there diaf ** */
     if (is_readable($this->file) == false) {
         $this->file = $this->path . '/error404.php';
         $this->controller = 'error404';
     }
     $rol = new rol();
     if ($this->controller != "index" && $this->controller != "login") {
         $usu_id = $_SESSION['USU_ID'];
         $switch = $rol->validaAcceso($usu_id, $this->controller);
         if ($switch == false) {
             $this->file = $this->path . '/error404.php';
             $this->controller = 'error404';
         }
     }
     /*         * * include the controller ** */
     include $this->file;
     /*         * * a new controller class instance ** */
     $class = $this->controller . 'Controller';
     $controller = new $class($this->registry);
     /*         * * check if the action is callable ** */
     if (is_callable(array($controller, $this->action)) == false) {
         $action = 'index';
     } else {
         $action = $this->action;
     }
     /*         * * run the action ** */
     $controller->{$action}();
 }