当前位置: 首页>>代码示例>>PHP>>正文


PHP Sessions::model方法代码示例

本文整理汇总了PHP中Sessions::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Sessions::model方法的具体用法?PHP Sessions::model怎么用?PHP Sessions::model使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Sessions的用法示例。


在下文中一共展示了Sessions::model方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: authenticate

 public function authenticate()
 {
     $nick = strtolower($this->username);
     $user = Users::model()->find('LOWER(email)=?', array($nick));
     if ($user === null) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     } elseif (!$user->validatePassword($this->password, $user->salt)) {
         $this->errorCode = self::ERROR_PASSWORD_INVALID;
     } elseif ($user->status == 0) {
         $this->errorCode = self::ERROR_PASSWORD_INVALID;
         return 2;
     } elseif ($user->status == 4) {
         // user is banned
         $this->errorCode = self::ERROR_PASSWORD_INVALID;
         return 3;
     } else {
         $this->_id = $user->id;
         $this->username = $user->email;
         $this->setState('isAdmin', $user->status == 3);
         $this->setState('permissions', $user->status);
         $this->setState('nick', $user->nick);
         $this->setState('session_key', md5($user->email . time() . uniqid() . $user->salt));
         $this->setState('user_ip', Yii::app()->request->userHostAddress);
         Sessions::model()->deleteAllByAttributes(array('user_id' => $user->id));
         $this->errorCode = self::ERROR_NONE;
     }
     return $this->errorCode == self::ERROR_NONE;
 }
开发者ID:mrtos,项目名称:OpenNVR,代码行数:28,代码来源:UserIdentity.php

示例2: checkLoginState

 /**
  * 检查用户是否已经登录
  * @param unknown_type $username
  */
 public function checkLoginState($username)
 {
     $string = 's:' . strlen($username) . ':"' . $username . '"';
     $criteria = new CDbCriteria();
     $criteria->addSearchCondition('data', $string);
     $model = Sessions::model()->find($criteria);
     return $model;
 }
开发者ID:yunsite,项目名称:my-advertise,代码行数:12,代码来源:LoginForm.php

示例3: getOnlineUsers

 public static function getOnlineUsers()
 {
     $sessions = Sessions::model()->findAll();
     $temp = array();
     foreach ($sessions as $session) {
         $temp[] = $session->user;
     }
     return $temp;
 }
开发者ID:netconstructor,项目名称:X2Engine,代码行数:9,代码来源:SessionChild.php

示例4: afterDelete

 public function afterDelete()
 {
     parent::afterDelete();
     $shared = Shared::model()->findAllByAttributes(array('cam_id' => $this->id));
     foreach ($shared as $s) {
         Notifications::model()->deleteAllByAttributes(array('shared_id' => $s->id, 'status' => 1));
         $s->delete();
     }
     Sessions::model()->deleteAllByAttributes(array('real_id' => $this->id));
     Sessions::model()->deleteAllByAttributes(array('real_id' => $this->id . '_low'));
     return true;
 }
开发者ID:mrtos,项目名称:OpenNVR,代码行数:12,代码来源:Cams.php

示例5: actionCheck

 public function actionCheck($id = '', $clientAddr = '')
 {
     if (!$id && !$clientAddr && isset($_POST['data'])) {
         $data = json_decode($_POST['data'], 1);
         $id = $data['id'];
         $clientAddr = $data['clientAddr'];
     }
     $response = array('result' => 'fail', 'id' => '');
     if (empty($id) && $this->validateRequest('id', $id)) {
         $response['id'] = 'empty or invalid id';
         $this->renderJSON($response);
     }
     if (empty($clientAddr) && $this->validateRequest('ip', $clientAddr)) {
         $response['id'] = 'empty or invalid ip';
         $this->renderJSON($response);
     }
     $session_id = Sessions::model()->findByAttributes(array('session_id' => $id), array('select' => 'real_id, ip'));
     if ($session_id) {
         $cam = Cams::model()->findByPK($session_id->real_id);
         if ($cam->is_public) {
             $response['result'] = 'success';
             $response['id'] = $session_id->real_id;
         } elseif ($session_id->ip == $clientAddr) {
             $response['result'] = 'success';
             $response['id'] = $session_id->real_id;
         } else {
             $response['id'] = 'huge fail';
         }
     } else {
         $cam = Cams::model()->findByPK($id);
         if ($cam && $cam->is_public) {
             $response['result'] = 'success';
             $response['id'] = $id;
         } else {
             $response['id'] = 'huge fail';
         }
     }
     $this->renderJSON($response);
 }
开发者ID:mrtos,项目名称:OpenNVR,代码行数:39,代码来源:CamsController.php

示例6: _checkSessionKey

 /**
  * This function checks if the XML-RPC session key is valid. If yes returns true, otherwise false and sends an error message with error code 1
  *
  * @access protected
  * @param string $sSessionKey Auth credentials
  * @return bool
  */
 protected function _checkSessionKey($sSessionKey)
 {
     $criteria = new CDbCriteria();
     $criteria->condition = 'expire < ' . time();
     Sessions::model()->deleteAll($criteria);
     $oResult = Sessions::model()->findByPk($sSessionKey);
     if (is_null($oResult)) {
         return false;
     } else {
         $this->_jumpStartSession($oResult->data);
         return true;
     }
 }
开发者ID:rawaludin,项目名称:LimeSurvey,代码行数:20,代码来源:remotecontrol.php

示例7: actionCheckLoginState

 /**
  * 检查登录状态
  */
 public function actionCheckLoginState()
 {
     $username = $_GET['username'];
     $string = 's:' . strlen($username) . ':"' . $username . '"';
     $criteria = new CDbCriteria();
     $criteria->addSearchCondition('data', $string);
     $model = Sessions::model()->find($criteria);
     if ($model) {
         $session = UtilSession::parseSession(Yii::app()->session->readSession($model->id));
         $ip = $session['loginIp'];
         //			$ip = '125.68.51.203';
         $region = UtilNet::getIPLoc($ip);
         $result = array('id' => $model->id, 'msg' => "<b>检测到您的帐号当前已经在" . $region->province . '.' . $region->city . '.' . $region->district . "登录</b><br />是否要注销,重新登录");
         echo json_encode($result);
     } else {
         $result = array('msg' => 'false');
         echo json_encode($result);
     }
 }
开发者ID:yunsite,项目名称:my-advertise,代码行数:22,代码来源:SiteController.php

示例8: onlineStatistics

 /**
  * 当前在线人数
  */
 public function onlineStatistics()
 {
     return Sessions::model()->count();
 }
开发者ID:yunsite,项目名称:my-advertise,代码行数:7,代码来源:Statistics.php


注:本文中的Sessions::model方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。