本文整理汇总了PHP中pathang::redirect方法的典型用法代码示例。如果您正苦于以下问题:PHP pathang::redirect方法的具体用法?PHP pathang::redirect怎么用?PHP pathang::redirect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pathang
的用法示例。
在下文中一共展示了pathang::redirect方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: login
public function login()
{
//get the instances of session and basket
$session = pathang::getInstance('session');
$basket = pathang::getInstance('basket');
//get username from request object
$username = trim(pathang::getInstance('request')->filterHTMLSQL('username'));
//get liveuser from session
$liveuser = $session->get('liveuser');
//if live user is available then load the user
//else if username is available then check for login validation
// else show the login page
if ($liveuser) {
//show the dashboard
pathang::render('userlog', 'loggedin');
} elseif ($username) {
// get the username and password
$password = trim(pathang::getInstance('request')->filterHTMLSQL('password'));
//validate user in userlog model
$status = pathang::getModel('userlog')->validateUser($username, $password);
// if there is no error then load the userdetails into liveuser and store
// it in session
if (!$status->error) {
$liveuser = new stdclass();
//load user details
$liveuser->username = $username;
$liveuser->id = pathang::getModel('userlog')->getUserId($username);
$liveuser->name = pathang::getModel('userlog')->getUserFullName($username);
$liveuser->email = pathang::getModel('userlog')->getUserEmail($username);
$liveuser->type = pathang::getModel('userlog')->getUserType($username);
$liveuser->profile_link = ROOT . $liveuser->username;
$liveuser->image_type = pathang::getModel('userlog')->getUserImageType($username);
$liveuser->image = pathang::getHelper('userlog')->getUserImage($liveuser);
$liveuser->feeds_per_page = pathang::getModel('userlog')->getFeedCount($username);
$liveuser->access_token = pathang::getHelper('userlog')->getToken(pathang::getModel('userlog')->getUserLastLogin($username), $liveuser->id);
//store liveuser in session
$session->set('liveuser', $liveuser);
// show dashboard
pathang::redirect(ROOT);
} else {
//if error in login display error in login page
// Error could be
// error 1 - User not found
// error 2 - Wrong password
// error 3 - User blocked
// error 4 - User not activated
$basket->set('status_message', $status->message);
$basket->set('status_error', $status->error);
$basket->set('username', $username);
//show login page
pathang::render('userlog', 'login');
}
} else {
//show login page
pathang::render('userlog', 'login');
}
}