Exemplo n.º 1
0
 public function testDelete()
 {
     fSession::open();
     $_SESSION['delete'] = TRUE;
     fSession::delete('delete');
     $this->assertEquals(FALSE, isset($_SESSION['delete']));
 }
Exemplo n.º 2
0
 /**
  * Retrieves and removes a message from the session
  *
  * @param  string $name       The name of the message to retrieve
  * @param  string $recipient  The intended recipient
  * @return string  The message contents
  */
 public static function retrieve($name, $recipient = NULL)
 {
     if ($recipient === NULL) {
         $recipient = '{default}';
     }
     $key = __CLASS__ . '::' . $recipient . '::' . $name;
     $message = fSession::get($key, NULL);
     fSession::delete($key);
     return $message;
 }
 /**
  * Returns the URL requested before the user was redirected to the login page
  *
  * @param  boolean $clear        If the requested url should be cleared from the session after it is retrieved
  * @param  string  $default_url  The default URL to return if the user was not redirected
  * @return string  The URL that was requested before they were redirected to the login page
  */
 public static function getRequestedURL($clear, $default_url = NULL)
 {
     $requested_url = fSession::get(__CLASS__ . '::requested_url', $default_url);
     if ($clear) {
         fSession::delete(__CLASS__ . '::requested_url');
     }
     return $requested_url;
 }
Exemplo n.º 4
0
$errmsg = '';
if (fRequest::isPost()) {
    $old_password = fRequest::get('old-password');
    $new_password = fRequest::get('new-password');
    $confirm_password = fRequest::get('confirm-password');
    $token = fAuthorization::getUserToken();
    $username = $token['name'];
    $user_id = $token['id'];
    if (empty($old_password) or empty($new_password) or empty($confirm_password)) {
        $errmsg = '密码不能为空';
    } else {
        if ($new_password != $confirm_password) {
            $errmsg = '两次输入的新密码不一致';
        } else {
            if (login_check_credential($db, $username, $old_password) == false) {
                $errmsg = '旧密码错误';
            } else {
                if (login_change_password($db, $user_id, $new_password)) {
                    fURL::redirect(fSession::delete('change-password-referer', SITE_BASE));
                } else {
                    $errmsg = '修改密码失败';
                }
            }
        }
    }
} else {
    if (fSession::get('change-password-referer') == null) {
        fSession::set('change-password-referer', login_get_referer(SITE_BASE));
    }
}
include __DIR__ . '/tpl/change-password.php';
Exemplo n.º 5
0
 public function testDeleteNestedArraySyntax()
 {
     fSession::open();
     $_SESSION['delete'] = array('foo' => array('bar' => 'baz'));
     $this->assertEquals('baz', fSession::delete('delete[foo][bar]'));
     $this->assertEquals(array('foo' => array()), $_SESSION['delete']);
 }