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


PHP CWebUser::init方法代碼示例

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


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

示例1: init

 public function init()
 {
     parent::init();
     //Normalize user IP
     $this->ip = $_SERVER['REMOTE_ADDR'];
     $this->ip = preg_replace('/^[^\\d]*/', '', $this->ip);
     if (!$this->getIsGuest()) {
         if (md5($this->model->password) != $this->getState('token')) {
             Yii::log('Invalid cookie token for ' . $this->name . '. Logging out.');
             $this->logout(true);
             Yii::app()->getRequest()->redirect(CHtml::normalizeUrl(array('/site')));
         }
         $stateIp = $this->getState('ip');
         if ($this->ip != $stateIp && $stateIp != 'ignore') {
             Yii::log('Invalid cookie IP for ' . $this->name . '. Logging out.');
             $this->logout(true);
             Yii::app()->getRequest()->redirect(CHtml::normalizeUrl(array('/site')));
         }
         if (@Yii::app()->params['installer'] != 'show' && isset($this->model->lang) && preg_match('/^[a-zA-Z_]+$/', $this->model->lang)) {
             Yii::app()->language = $this->model->lang;
         }
     }
     if ($this->isSuperuser() && @strlen(Yii::app()->params['admin_ips'])) {
         if (!$this->checkIp(Yii::app()->params['admin_ips'])) {
             Yii::log('Superuser access denied for ' . $this->name . ' (IP ' . $this->ip . ')');
             $this->logout(true);
             Yii::app()->getRequest()->redirect(CHtml::normalizeUrl(array('/site')));
         }
     }
 }
開發者ID:Jmainguy,項目名稱:multicraft_install,代碼行數:30,代碼來源:WebUser.php

示例2: afterLogin

 /**
  * Actions to be taken after logging in.
  * Overloads the parent method in order to mark superusers.
  * @param boolean whether the login is based on cookie.
  */
 public function afterLogin($fromCookie)
 {
     parent::init($fromCookie);
     // Mark the user as a superuser if necessary.
     if (Rights::getAuthorizer()->isSuperuser($this->getId()) === true) {
         $this->isSuperuser = true;
     }
 }
開發者ID:BackupTheBerlios,項目名稱:swahili-dict,代碼行數:13,代碼來源:RightsWebUser.php

示例3: init

 /**
  * Инициализация компонента:
  *
  * @return parent::init()
  **/
 public function init()
 {
     $this->allowAutoLogin = true;
     $this->authTimeout = 24 * 2600;
     $this->autoRenewCookie = true;
     $this->loginUrl = Yii::app()->createUrl($this->loginUrl);
     return parent::init();
 }
開發者ID:sherifflight,項目名稱:yupe,代碼行數:13,代碼來源:YWebUser.php

示例4: init

 public function init()
 {
     parent::init();
     if (!$this->isGuest) {
         /** @var $u User */
         $u = User::model()->findByPk($this->id);
         $this->_profile = $u;
     }
 }
開發者ID:bartaakos,項目名稱:yii-shard-poc,代碼行數:9,代碼來源:MyWebUser.php

示例5: init

 /**
  * @inheritDoc
  */
 public function init()
 {
     parent::init();
     if (!$this->isGuest) {
         // Note that saveAttributes can return false if the account is active twice the same second
         // because no attributes are updated, therefore we cannot throw an exception if save fails.
         $this->loadAccount()->saveAttributes(array('lastActiveAt' => Helper::sqlNow()));
     }
 }
開發者ID:azamath,項目名稱:yii-account,代碼行數:12,代碼來源:WebUser.php

示例6: init

 public function init()
 {
     $account = Ibos::app()->setting->get("setting/account");
     $this->account = $account;
     $isAutologin = MainUtil::getCookie("autologin");
     if (!$isAutologin) {
         $this->authTimeout = (int) $account["timeout"] * 60;
     }
     parent::init();
 }
開發者ID:AxelPanda,項目名稱:ibos,代碼行數:10,代碼來源:ICUser.php

示例7: init

 public function init()
 {
     parent::init();
     if ($this->getIsGuest() === FALSE) {
         // Если юзер залогинен то обновляю его инфу
         $this->_user = Users::model()->with('profile')->find('auth_hash = :auth_hash', array('auth_hash' => $this->getState('auth_hash')));
         if (!$this->_user) {
             $this->logout();
         }
     }
 }
開發者ID:mmorpg2015,項目名稱:ghtweb5,代碼行數:11,代碼來源:WebUser.php

示例8: init

 /**
  * Initializes the application component.
  *
  * This method will determine how long user sessions are configured to last, and whether the current request
  * has requested to not extend the current user session, before calling {@link \CWebUser::init()}.
  *
  * @return null
  */
 public function init()
 {
     if (!craft()->isConsole()) {
         // Set the authTimeout based on whether the current identity was created with "Remember Me" checked.
         $data = $this->getIdentityCookieValue();
         $this->authTimeout = craft()->config->getUserSessionDuration($data ? $data[3] : false);
         // Should we skip auto login and cookie renewal?
         $this->_dontExtendSession = !$this->shouldExtendSession();
         $this->autoRenewCookie = !$this->_dontExtendSession;
         parent::init();
     }
 }
開發者ID:codeforamerica,項目名稱:oakland-beta,代碼行數:20,代碼來源:UserSessionService.php

示例9: init

 /**
  * Initialisation Method
  *
  * @access public
  * @return void
  */
 public function init()
 {
     parent::init();
     // Raise an "onEndUser" event.
     $this->onStartUser(new Event($this));
     // Is the user logged in or not?
     if (!$this->getState('isGuest')) {
         // Load the database model for the currently logged in user so we can use their information throughout
         // the request.
         $this->user = User::model()->findByPk($this->getState('id'));
         // Raise an "onAuthenticated" event; specifying that the end-user is logged in.
         $this->onAuthenticated(new Event($this));
     } else {
         // Raise an "onGuest" event; specifying that the end-user is not logged in.
         $this->onGuest(new Event($this));
     }
 }
開發者ID:mynameiszanders,項目名稱:yiiskeleton,代碼行數:23,代碼來源:WebUser.php

示例10: testLoginLogout

 /**
  * @runInSeparateProcess
  * @outputBuffering enabled
  * @dataProvider booleanProvider
  */
 public function testLoginLogout($destroySession)
 {
     $identity = new CUserIdentity('testUser', 'testPassword');
     $user = new CWebUser();
     $user->init();
     // be guest before login
     $this->assertTrue($user->isGuest);
     // do a login
     $this->assertTrue($user->login($identity));
     // don't be guest after login
     $this->assertFalse($user->isGuest);
     $this->assertEquals('testUser', $user->getId());
     $this->assertEquals('testUser', $user->getName());
     $user->logout($destroySession);
     // be guest after logout
     $this->assertNull($user->getId());
     $this->assertEquals($user->guestName, $user->getName());
 }
開發者ID:super-d2,項目名稱:codeigniter_demo,代碼行數:23,代碼來源:CWebUserTest.php

示例11: init

 /**
  * Initializes the component.
  */
 public function init()
 {
     parent::init();
     //$this->setIsAdmin(in_array($this->name, Yii::app()->authManager->admins));
 }
開發者ID:GsHatRed,項目名稱:Yiitest,代碼行數:8,代碼來源:AuthWebUser.php

示例12: init

 public function init()
 {
     parent::init();
 }
開發者ID:AndressJose,項目名稱:bolsa-proyecto-integrado,代碼行數:4,代碼來源:CrugeWebUser.php

示例13: init

 /**
  * Initializes the component.
  */
 public function init()
 {
     parent::init();
     $this->setIsAdmin(in_array($this->name, $this->admins));
 }
開發者ID:lhfcainiao,項目名稱:basic,代碼行數:8,代碼來源:AuthWebUser.php

示例14: init

 public function init()
 {
     parent::init();
     $this->module = Yii::app()->getModule('userAccount');
 }
開發者ID:vasiliy-pdk,項目名稱:aes,代碼行數:5,代碼來源:UAccWebUser.php

示例15: init

 public function init()
 {
     parent::init();
     $this->ini = new WebUserIni();
 }
開發者ID:norayr,項目名稱:notabenoid,代碼行數:5,代碼來源:WebUser.php


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