本文整理匯總了PHP中WebApp::forceRedirect方法的典型用法代碼示例。如果您正苦於以下問題:PHP WebApp::forceRedirect方法的具體用法?PHP WebApp::forceRedirect怎麽用?PHP WebApp::forceRedirect使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類WebApp
的用法示例。
在下文中一共展示了WebApp::forceRedirect方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: check
public function check()
{
$this->parent->parent->debug($this::name_space . ': Checking for login token...');
if (!$this->parent->parent->config->config['core']['database']) {
return false;
}
// Check for token cookie
if (Cookie::get('ltkn') === NULL) {
$this->parent->parent->debug($this::name_space . ': Login token not found!');
return false;
}
$this->parent->parent->debug($this::name_space . ': Found token');
$token = Cookie::get('ltkn');
$sessID = Session::getID();
$userID = Session::get('WebApp.User', 'userID');
// It does exist so...
// Find token in database where userID = the userID in the token
$this->parent->parent->debug($this::name_space . ': Checking sessions table for:');
$this->parent->parent->debug('T: ' . $token . '/ S: ' . $sessID . '/ U: ' . $userID);
$token_query = $this->mySQL_r->prepare("SELECT INET_NTOA(`IP`), `auth` FROM `core_sessions` WHERE `token`=? AND `session`=? AND `user`=?");
$token_query->bind_param('ssi', $token, $sessID, $userID);
$token_query->execute();
$token_query->store_result();
if ($token_query->num_rows != 1) {
$this->parent->parent->debug($this::name_space . ': Failed to find session.');
return false;
}
$token_query->bind_result($ip, $auth);
$token_query->fetch();
if (Server::get('remote_addr') != $ip || $auth) {
$update_query = $this->mySQL_w->prepare("UPDATE `core_sessions` SET `auth`=1 WHERE `token`=?");
$update_query->bind_param('s', $token);
$update_query->execute();
WebApp::forceRedirect('/user/auth?r=' . urlencode(Server::get('request_uri')));
}
$this->parent->parent->debug($this::name_space . ': Found session. Token Check successful!');
return true;
}
示例2: __construct
function __construct($parent)
{
$this->parent = $parent;
$this->mySQL_r = $parent->mySQL_r;
$this->mySQL_w = $parent->mySQL_w;
$this->parent->debug('***** ' . $this::name_space . ' *****');
$this->parent->debug($this::name_space . ': Version ' . $this::version);
$this->session = new SessionTokeniser($this);
// Is a user logged in?
if (Session::get($this::name_space, 'loggedIn') !== true) {
$this->parent->debug($this::name_space . ': No user logged in, using anoymous');
$this->_fetchDetails();
return;
}
if ($this->session->check()) {
$this->parent->debug($this::name_space . ': User logged in');
$this->loggedIn = true;
$this->username = Session::get($this::name_space, 'username');
$this->userID = Session::get($this::name_space, 'userID');
$this->session->update();
} else {
Session::del($this::name_space, 'loggedIn');
Session::del($this::name_space, 'username');
Session::del($this::name_space, 'userID');
}
// Create user data
$this->_fetchDetails();
if ($this->enabled == false) {
$this->parent->debug($this::name_space . ': User disabled... logging out');
$this->logout();
header("Location: /user/login");
exit;
} elseif (Server::get('request_uri') != "/user/profile/password" && $this->changePwd == 1) {
$this->parent->debug($this::name_space . ': User must change password');
WebApp::forceRedirect('/user/profile/password');
}
}