/**
  * Closes the user session
  *
  * @global Object $CONFIG
  */
 private function logout()
 {
     global $CONFIG;
     session_unset();
     session_destroy();
     RoutingHelper::redirect($CONFIG->wwwroot);
 }
 /**
  * Checks if an extra_action is available and updates the action attribute
  * accordingly, if the caller is admin, and if the required action exists
  *
  * @global Object $CONFIG
  * @param String $action
  * @param Array $params
  * @param String $extra_action
  */
 public function __construct($action, $params, $extra_action = null)
 {
     global $CONFIG;
     // if the extra action is defined update action
     isset($extra_action) ? $action = $action . '_' . $extra_action : null;
     // check if is admin and if the required action is defined
     if ($this->check_role('admin') && method_exists($this, $action)) {
         $this->{$action}($params);
     } else {
         RoutingHelper::redirect($CONFIG->wwwroot . '/error/notfound');
     }
 }
 /**
  * Checks the role and if the called action exists
  *
  * @global Object $CONFIG
  * @param String $action
  * @param Array $params
  */
 public function __construct($action, $params, $extra_action = null)
 {
     global $CONFIG;
     $this->_data->user = UserModel::find_by_identifier($_SESSION['user']);
     // if the extra action is defined update action
     isset($extra_action) ? $action = $action . '_' . $extra_action : null;
     // check if is admin and if the required action is defined
     if ($this->check_role('user') && method_exists($this, $action)) {
         $this->{$action}($params);
     } else {
         RoutingHelper::redirect($CONFIG->wwwroot . '/error/notfound');
     }
 }
Пример #4
0
                    require_once ROOT . '/app/helpers/' . $class . '.php';
                } else {
                    if (file_exists(ROOT . '/lib/' . $class . '.php')) {
                        require_once ROOT . '/lib/' . $class . '.php';
                    } else {
                        if (file_exists(ROOT . '/app/views/' . $class . '.php')) {
                            require_once ROOT . '/app/views/' . $class . '.php';
                        } else {
                            if (file_exists(ROOT . '/app/views/admin/' . $class . '.php')) {
                                require_once ROOT . '/app/views/admin/' . $class . '.php';
                            } else {
                                if (file_exists(ROOT . '/app/views/user/' . $class . '.php')) {
                                    require_once ROOT . '/app/views/user/' . $class . '.php';
                                } else {
                                    //redirect to 404 page
                                    RoutingHelper::redirect($CONFIG->wwwroot . '/error/notfound');
                                }
                            }
                        }
                    }
                }
            }
        }
    }
});
// set up the database connection
DB::setUp($CONFIG);
// parse the request
$url = isset($_GET['url']) ? $_GET['url'] : null;
$role = isset($_SESSION['role']) ? $_SESSION['role'] : null;
if ($url == null && $role == null) {