Example #1
0
 public function execute($action_name)
 {
     $this->header_content_type(static::CONTENT_TYPE);
     try {
         $this->before_execute();
         $this->action_name = $action_name;
         $action_method = "{$action_name}_action";
         //action not found
         if (!method_exists($this, $action_method)) {
             $this->header_notfound();
             return;
         }
         //create session
         $this->session = $this->create_session();
         //need auth?
         if (empty($this->without_auth_actions) || array_search($action_name, $this->without_auth_actions) === false && array_search('*', $this->without_auth_actions) === false) {
             //check auth
             if (!$this->session->is_valid()) {
                 throw new Exception\Auth('auth verify failed', Errno::AUTH_FAILED);
             }
         }
         //call action
         $data = $this->{$action_method}();
         //render
         return $this->render($data);
     } catch (Exception\Auth $e) {
         $this->set_cookie(self::SESSION_KEY_NAME, '');
         return $this->render_auth_error($e->getMessage(), $e->getCode());
     } catch (Exception $e) {
         return $this->render_error($e->getMessage(), $e->getCode());
     }
 }
Example #2
0
 public static function update()
 {
     if ($_GET['session_id']) {
         $session = new Session($_GET['session_id'], true);
     } else {
         $session = new Session(null, true);
     }
     $session_valid_array = $session->is_valid();
     if ($session_valid_array[0] === true) {
         self::install();
     } else {
         self::login();
     }
 }
 public function session_info($id_)
 {
     $args = func_get_args();
     // func_get_args(): Can't be used as a function parameter before PHP 5.3.0
     $res = $this->__call('session_info', $args);
     if ($res === null) {
         return null;
     }
     $s = new Session($res);
     if (!$s->is_valid()) {
         return null;
     }
     return $s;
 }
Example #4
0
require_once "core/include/base/system/system_handler.class.php";
require_once "core/include/base/security/security.class.php";
require_once "core/include/base/security/session.class.php";
require_once "core/include/base/system/autoload.function.php";
SystemConfig::load_module_config();
if ($_GET['session_id'] and $_GET['file_id']) {
    $transaction = new Transaction();
    try {
        $system_handler = new SystemHandler(false);
    } catch (Exception $e) {
        die("Exception");
    }
    Security::protect_session();
    $session = new Session($_GET['session_id']);
    $user = new User($session->get_user_id());
    $session_valid_array = $session->is_valid();
    if ($session_valid_array[0] === true) {
        try {
            $image_cache = new ImageCache($_GET['file_id']);
        } catch (Exception $e) {
            die("Exception");
        }
        if ($_GET['max_width']) {
            $image_cache->set_max_width($_GET['max_width']);
        }
        if ($_GET['max_height']) {
            $image_cache->set_max_height($_GET['max_height']);
        }
        if ($_GET['width']) {
            $file_path = constant("BASE_DIR") . "/filesystem/temp/" . $image_cache->get_image($_GET['width']);
        } elseif ($_GET['height']) {
Example #5
0
 /**
  * @see AuthInterface::logout()
  * @param integer $user_id
  * @param string $session_id
  * @return bool
  */
 public function logout($user_id, $session_id)
 {
     $session = new Session($session_id);
     Session::check_all();
     $session_valid_array = $session->is_valid($user_id);
     if ($session_valid_array[0] === true) {
         if ($session->destroy() === true) {
             return true;
         } else {
             return false;
         }
     } else {
         if ($session->is_dead() === true) {
             return true;
         } else {
             return false;
         }
     }
 }