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