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


PHP UserDB::getAuthUserById方法代碼示例

本文整理匯總了PHP中UserDB::getAuthUserById方法的典型用法代碼示例。如果您正苦於以下問題:PHP UserDB::getAuthUserById方法的具體用法?PHP UserDB::getAuthUserById怎麽用?PHP UserDB::getAuthUserById使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在UserDB的用法示例。


在下文中一共展示了UserDB::getAuthUserById方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: run

 public static function run(array $requestData)
 {
     //Make sure we have a session
     if (session_status() == PHP_SESSION_NONE) {
         session_start();
     }
     /*
     //Count hits
     if (isset($_SESSION['Stippers']['hits']))
         $_SESSION['Stippers']['hits']++;
     else
         $_SESSION['Stippers']['hits'] = 0;
     echo $_SESSION['Stippers']['hits'];
     */
     //If we have login in our post this means we are on the login page in and we must call the login controller.
     //The login controller will load
     if (isset($_POST['login'])) {
         LoginController::post();
     }
     $errorGettingUser = false;
     $errorGettingBrowser = false;
     //Check if we have data about a user in session, in which case renew it.
     //Also check if we're not logging in because then we already have fresh user data.
     if (isset($_SESSION['Stippers']['user']) && !isset($_POST['login'])) {
         try {
             //Gets user from database. This gets the user only if he's a member this year or if it's the admin account.
             $newUser = UserDB::getAuthUserById($_SESSION['Stippers']['user']->userId);
             //If the user's password has changed we immediately log out!
             if ($_SESSION['Stippers']['user']->passwordHash != $newUser->passwordHash) {
                 session_destroy();
                 ForcedLogoutController::get();
                 return false;
             } else {
                 $_SESSION['Stippers']['user'] = $newUser;
             }
         } catch (Exception $ex) {
             session_destroy();
             ForcedLogoutController::get();
             return false;
         }
     }
     //Get the browser data for this browser
     if (isset($_COOKIE['stippersAuthorization'])) {
         try {
             $_SESSION['Stippers']['browser'] = BrowserDB::getBasicBrowserByUuid($_COOKIE['stippersAuthorization']);
         } catch (BrowserDBException $ex) {
             //unset because we don't want to use old data
             unset($_SESSION['Stippers']['browser']);
             if ($ex->getCode() != BrowserDBException::NOBROWSERFORUUID) {
                 $errorGettingBrowser = true;
             }
         } catch (Exception $ex) {
             //unset because we don't want to use old data
             unset($_SESSION['Stippers']['browser']);
             $errorGettingBrowser = true;
         }
     }
     //We can now check the page access permissions.
     require_once __DIR__ . '/../config/PageAccessPermissions.php';
     //Default to inaccessible for everyone
     $everyone = false;
     $member = false;
     $admin = false;
     $userManager = false;
     $hintManager = false;
     $browserManager = false;
     $moneyManager = false;
     $addRenewUserBrowser = false;
     $checkInBrowser = false;
     $cashRegisterBrowser = false;
     $apiKey = false;
     //If permissions for the requested page are defined we override the
     //defaults with these.
     if (isset($_PERMISSIONS[$requestData['requestedPage']])) {
         $permissions = $_PERMISSIONS[$requestData['requestedPage']];
         if (isset($permissions['EVERYONE'])) {
             $everyone = $permissions['EVERYONE'];
         }
         if (isset($permissions['MEMBER'])) {
             $member = $permissions['MEMBER'];
         }
         if (isset($permissions['ADMIN'])) {
             $admin = $permissions['ADMIN'];
         }
         if (isset($permissions['USERMANAGER'])) {
             $userManager = $permissions['USERMANAGER'];
         }
         if (isset($permissions['HINTMANAGER'])) {
             $hintManager = $permissions['HINTMANAGER'];
         }
         if (isset($permissions['BROWSERMANAGER'])) {
             $browserManager = $permissions['BROWSERMANAGER'];
         }
         if (isset($permissions['MONEYMANAGER'])) {
             $moneyManager = $permissions['MONEYMANAGER'];
         }
         if (isset($permissions['ADDRENEWUSERBROWSER'])) {
             $addRenewUserBrowser = $permissions['ADDRENEWUSERBROWSER'];
         }
         if (isset($permissions['CHECKINBROWSER'])) {
//.........這裏部分代碼省略.........
開發者ID:JHDeStip,項目名稱:Stippers,代碼行數:101,代碼來源:Authorization.php


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