当前位置: 首页>>代码示例>>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;未经允许,请勿转载。