當前位置: 首頁>>代碼示例>>PHP>>正文


PHP pathang::redirect方法代碼示例

本文整理匯總了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');
     }
 }
開發者ID:adrixnac,項目名稱:RedSocial,代碼行數:57,代碼來源:userlog.php


注:本文中的pathang::redirect方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。