本文整理汇总了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;
}
示例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;
}
示例3: getOnlineUsers
public static function getOnlineUsers()
{
$sessions = Sessions::model()->findAll();
$temp = array();
foreach ($sessions as $session) {
$temp[] = $session->user;
}
return $temp;
}
示例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;
}
示例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);
}
示例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;
}
}
示例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);
}
}
示例8: onlineStatistics
/**
* 当前在线人数
*/
public function onlineStatistics()
{
return Sessions::model()->count();
}