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


PHP User::getIpAddress方法代碼示例

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


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

示例1: authenticate

 /**
  * Authenticate a Google user
  *
  * @access public
  * @param  string  $google_id   Google unique id
  * @return boolean
  */
 public function authenticate($google_id)
 {
     $userModel = new User($this->db, $this->event);
     $user = $userModel->getByGoogleId($google_id);
     if ($user) {
         // Create the user session
         $userModel->updateSession($user);
         // Update login history
         $lastLogin = new LastLogin($this->db, $this->event);
         $lastLogin->create(LastLogin::AUTH_GOOGLE, $user['id'], $userModel->getIpAddress(), $userModel->getUserAgent());
         return true;
     }
     return false;
 }
開發者ID:antonivargas,項目名稱:bkpsite,代碼行數:21,代碼來源:google.php

示例2: beforeAction

 /**
  * Method executed before each action
  *
  * @access public
  */
 public function beforeAction($controller, $action)
 {
     // Start the session
     $this->session->open(BASE_URL_DIRECTORY, SESSION_SAVE_PATH);
     // HTTP secure headers
     $this->response->csp();
     $this->response->nosniff();
     $this->response->xss();
     $this->response->hsts();
     $this->response->xframe();
     // Load translations
     $language = $this->config->get('language', 'en_US');
     if ($language !== 'en_US') {
         \Translator\load($language);
     }
     // Set timezone
     date_default_timezone_set($this->config->get('timezone', 'UTC'));
     // Authentication
     if (!$this->acl->isLogged() && !$this->acl->isPublicAction($controller, $action)) {
         // Try the remember me authentication first
         if (!$this->rememberMe->authenticate()) {
             // Redirect to the login form if not authenticated
             $this->response->redirect('?controller=user&action=login');
         } else {
             $this->lastLogin->create(\Model\LastLogin::AUTH_REMEMBER_ME, $this->acl->getUserId(), $this->user->getIpAddress(), $this->user->getUserAgent());
         }
     } else {
         if ($this->rememberMe->hasCookie()) {
             $this->rememberMe->refresh();
         }
     }
     // Check if the user is allowed to see this page
     if (!$this->acl->isPageAccessAllowed($controller, $action)) {
         $this->response->redirect('?controller=user&action=forbidden');
     }
     // Attach events for automatic actions
     $this->action->attachEvents();
 }
開發者ID:antonivargas,項目名稱:bkpsite,代碼行數:43,代碼來源:base.php


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