本文整理汇总了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'));
}
示例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');
}
}
示例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()));
}
}
示例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';
}