public function logout() { Session::createSession(); Session::destroySession(); Session::unsetAll(); $this->view->load('admin/login'); }
public function loader() { /* * * check the route ** */ $this->getController(); $this->getAction(); $loggedin = $this->cek_session(); if (!$loggedin && !$this->controller instanceof AuthController && $this->method != 'index') { Session::createSession(); Session::destroySession(); Session::unsetAll(); $this->controller = new AuthController($this->registry); $this->method = 'index'; } //echo $this->role.",".$this->url[0].",".$this->method; //var_dump($this->registry->auth->is_allowed($this->role,$this->url[0],$this->method)); if (!$this->registry->auth->is_allowed($this->role, $this->url[0], $this->method) && $this->role != 'guest') { $this->controller = new Index($this->registry); $this->method = 'index'; } else { if (!$this->registry->auth->is_allowed($this->role, $this->url[0], $this->method) && $this->role == 'guest') { $this->controller = new AuthController($this->registry); $this->method = 'index'; } } /* * * check if the action is callable ** */ if (is_callable(array($this->controller, $this->method)) == false) { $action = 'index'; } else { $action = $this->method; } /* * * load arguments for action ** */ $arguments = array(); $i = 0; // var_dump($this->url); foreach ($this->url as $key => $val) { if ($i > 1) { $arguments[] = $val; // var_dump($arguments); // $i++; } $i++; } Session::sessionUpdated(); if ($i > 1) { call_user_func_array(array($this->controller, $action), $arguments); } else { call_user_func(array($this->controller, $action), $arguments); } }