当前位置: 首页>>代码示例>>PHP>>正文


PHP fAuthorization::getRequestedURL方法代码示例

本文整理汇总了PHP中fAuthorization::getRequestedURL方法的典型用法代码示例。如果您正苦于以下问题:PHP fAuthorization::getRequestedURL方法的具体用法?PHP fAuthorization::getRequestedURL怎么用?PHP fAuthorization::getRequestedURL使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在fAuthorization的用法示例。


在下文中一共展示了fAuthorization::getRequestedURL方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testRequestedUrl

 public function testRequestedUrl()
 {
     fSession::set('fAuthorization::requested_url', 'test_url.php?query_string=TRUE');
     $this->assertEquals('test_url.php?query_string=TRUE', fAuthorization::getRequestedURL(FALSE));
     $this->assertEquals('test_url.php?query_string=TRUE', fAuthorization::getRequestedURL(TRUE));
     $this->assertEquals(NULL, fAuthorization::getRequestedURL(TRUE));
     $this->assertEquals('test_url2.php?query_string=TRUE', fAuthorization::getRequestedURL(TRUE, 'test_url2.php?query_string=TRUE'));
 }
开发者ID:nurulimamnotes,项目名称:flourish-old,代码行数:8,代码来源:fAuthorizationTest.php

示例2: User

$action = fRequest::get('action');
// --------------------------------- //
if ('log_out' == $action) {
    fAuthorization::destroyUserInfo();
    fSession::destroy();
    fMessaging::create('success', User::makeUrl('login'), 'You were successfully logged out');
    fURL::redirect(User::makeUrl('login'));
    // --------------------------------- //
} else {
    if (!fAuthorization::checkLoggedIn()) {
        if (fRequest::isPost()) {
            try {
                $user = new User(array('username' => fRequest::get('username')));
                $valid_pass = fCryptography::checkPasswordHash(fRequest::get('password'), $user->getPassword());
                if (!$valid_pass) {
                    throw new fValidationException('The login or password entered is invalid');
                }
                fAuthorization::setUserToken($user->getEmail());
                fAuthorization::setUserAuthLevel($user->getRole());
                fSession::set('user_id', $user->getUserId());
                fSession::set('user_name', $user->getUsername());
                fURL::redirect(fAuthorization::getRequestedURL(TRUE, 'index.php'));
            } catch (fExpectedException $e) {
                fMessaging::create('error', fURL::get(), $e->getMessage());
            }
        }
        include VIEW_PATH . '/log_in.php';
    } else {
        fURL::redirect('index.php');
    }
}
开发者ID:nagyist,项目名称:Tattle,代码行数:31,代码来源:login.php

示例3: login

 public function login()
 {
     $username = trim(fRequest::get('username', 'string'));
     $password = fRequest::get('password', 'string');
     $password_hash = static::hashPassword($password);
     try {
         if (fRequest::get('action') == '登录') {
             $user = new User($username);
             if ($user->getPassword() == $password_hash) {
                 fAuthorization::setUserToken($user->getUsername());
                 fMessaging::create('success', 'Logged in successfully.');
                 fURL::redirect(fAuthorization::getRequestedURL(TRUE, Util::getReferer()));
             } else {
                 throw new fValidationException('Password mismatch.');
             }
         } else {
             if (fRequest::get('action') == '注册') {
                 if (strlen($username) < 4) {
                     throw new fValidationException('Username is too short.');
                 }
                 if (strlen($username) > 20) {
                     throw new fValidationException('Username is too long.');
                 }
                 if (strlen($password) < 6) {
                     throw new fValidationException('Password is too short.');
                 }
                 if (Util::contains('`~!@#$%^&*()-+=[]\\;\',/{}|:"<>?', $username) or preg_match('/\\s/', $username)) {
                     throw new fValidationException('Username is illegal.');
                 }
                 $realname = trim(fRequest::get('realname', 'string'));
                 $gender = trim(fRequest::get('gender', 'string'));
                 $school = trim(fRequest::get('school', 'string'));
                 $major = trim(fRequest::get('major', 'string'));
                 $grade = trim(fRequest::get('grade', 'integer', NULL));
                 $phone = trim(fRequest::get('phone', 'string'));
                 $qq = trim(fRequest::get('qq', 'string'));
                 if (strlen($realname) < 1) {
                     throw new fValidationException('请填写真实姓名');
                 }
                 if (strlen($gender) < 1) {
                     throw new fValidationException('请选择性别');
                 }
                 if (strlen($phone) < 1) {
                     throw new fValidationException('请填写手机号码');
                 }
                 try {
                     $user = new User($username);
                     throw new fValidationException('User already exists.');
                 } catch (fNotFoundException $e) {
                     $user = new User();
                     $user->setUsername($username);
                     $user->setPassword($password_hash);
                     $user->store();
                     try {
                         $profile = new Profile($username);
                     } catch (fNotFoundException $e) {
                         $profile = new Profile();
                         $profile->setUsername($username);
                     }
                     $profile->setRealname($realname);
                     $profile->setGender($gender);
                     $profile->setSchool($school);
                     $profile->setMajor($major);
                     $profile->setGrade($grade);
                     $profile->setPhoneNumber($phone);
                     $profile->setQq($qq);
                     $profile->store();
                     fAuthorization::setUserToken($user->getUsername());
                     fMessaging::create('success', 'Registered successfully.');
                     Util::redirect('/email/verify');
                 }
             }
         }
     } catch (fException $e) {
         fMessaging::create('error', $e->getMessage());
         fURL::redirect(fAuthorization::getRequestedURL(TRUE, Util::getReferer()));
     }
 }
开发者ID:daerduoCarey,项目名称:oj,代码行数:78,代码来源:UserController.php

示例4:

<?php

include_once __DIR__ . '/inc/init.php';
if (fAuthorization::checkLoggedIn()) {
    fURL::redirect(fAuthorization::getRequestedURL(false, SITE_BASE));
} else {
    $errmsg = '';
    $username = '';
    if (fRequest::isPost()) {
        $username = fRequest::get('username');
        $password = fRequest::get('password');
        if (empty($username)) {
            $errmsg = '请输入用户名';
        } else {
            if (empty($password)) {
                $errmsg = '请输入密码';
            } else {
                if (!login_authenticate($db, $username, $password)) {
                    $errmsg = '登录失败';
                } else {
                    fURL::redirect(fAuthorization::getRequestedURL(false, SITE_BASE));
                }
            }
        }
    }
    include __DIR__ . '/tpl/login.php';
}
开发者ID:daerduoCarey,项目名称:xiaoyou,代码行数:27,代码来源:index.php


注:本文中的fAuthorization::getRequestedURL方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。