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


PHP x2base::cleanUpSessions方法代码示例

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


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

示例1: run

 public function run()
 {
     x2base::cleanUpSessions();
     // $criteria = new CDbCriteria(array('condition'=>'','distinct'=>true)
     // $sessions = Session::model()->findAll($criteria);
     // $str = "";
     // foreach($sessions as $session) {
     // if(time()-$session->lastUpdated<(15*60)) {
     // $str.=$session->user.", ";
     // }
     // }
     // if($str!="") {
     // $str=substr($str,0,-2);
     // }
     $onlineUsers = User::getUserLinks(Session::getOnlineUsers());
     $this->render('onlineUsers', array('users' => $onlineUsers));
     //array(
 }
开发者ID:netconstructor,项目名称:X2Engine,代码行数:18,代码来源:OnlineUsers.php

示例2: actionLogin

 public function actionLogin()
 {
     $this->layout = '//layouts/login';
     // echo var_dump(Session::getOnlineUsers());
     if (Yii::app()->user->isInitialized && !Yii::app()->user->isGuest) {
         $this->redirect(Yii::app()->homeUrl);
         return;
     }
     $model = new LoginForm();
     $model->useCaptcha = false;
     // collect user input data
     if (isset($_POST['LoginForm'])) {
         $model->attributes = $_POST['LoginForm'];
         $ip = $this->getRealIp();
         x2base::cleanUpSessions();
         $session = CActiveRecord::model('Session')->findByAttributes(array('user' => $model->username, 'IP' => $ip));
         if (isset($session)) {
             $session->lastUpdated = time();
             if ($session->status < 1) {
                 if ($session->status > -3) {
                     $session->status -= 1;
                 }
             } else {
                 $session->status = -1;
             }
             if ($session->status < -1) {
                 $model->useCaptcha = true;
             }
             if ($session->status < -2) {
                 $model->setScenario('loginWithCaptcha');
             }
         } else {
             $session = new Session();
             $session->user = $model->username;
             $session->lastUpdated = time();
             $session->status = 1;
             $session->IP = $ip;
         }
         if ($model->validate() && $model->login()) {
             $user = User::model()->findByPk(Yii::app()->user->getId());
             $user->login = time();
             $user->save();
             if ($user->username == 'admin') {
                 if (ini_get('allow_url_fopen') == 1) {
                     $context = stream_context_create(array('http' => array('timeout' => 2)));
                     $updateSources = array('http://x2planet.com/updates/versionCheck.php', 'http://x2base.com/updates/versionCheck.php');
                     $newVersion = '';
                     foreach ($updateSources as $url) {
                         $sourceVersion = @file_get_contents($url, 0, $context);
                         if ($sourceVersion !== false) {
                             $newVersion = $sourceVersion;
                             break;
                         }
                     }
                     if (empty($newVersion)) {
                         $newVersion = Yii::app()->params->version;
                     }
                     /* 
                     						// check X2Planet for updates
                     						$x2planetVersion = @file_get_contents('http://x2planet.com/updates/versionCheck.php',0,$context);
                     						if($x2planetVersion !== false)
                     							$newVersion = $x2planetVersion;
                     						else {
                     							// try X2Base if that didn't work
                     							$x2baseVersion = @file_get_contents('http://x2base.com/updates/versionCheck.php',0,$context);
                     							if($x2baseVersion !== false)
                     								$newVersion=$x2baseVersion;
                     							else
                     								$newVersion=Yii::app()->params->version;
                     						} */
                     if (version_compare($newVersion, Yii::app()->params->version) > 0) {
                         // if the latest version is newer than our version
                         Yii::app()->session['versionCheck'] = false;
                         Yii::app()->session['newVersion'] = $newVersion;
                     } else {
                         Yii::app()->session['versionCheck'] = true;
                     }
                 } else {
                     Yii::app()->session['versionCheck'] = true;
                 }
             } else {
                 Yii::app()->session['versionCheck'] = true;
             }
             Yii::app()->session['loginTime'] = time();
             $session->status = 1;
             $session->save();
             if (Yii::app()->user->returnUrl == 'site/index') {
                 $this->redirect('index');
             } else {
                 $this->redirect(Yii::app()->user->returnUrl);
             }
         } else {
             $session->save();
             $model->verifyCode = '';
             if ($model->hasErrors()) {
                 $model->addError('username', Yii::t('app', 'Incorrect username or password.'));
             }
             $model->addError('password', Yii::t('app', 'Incorrect username or password.'));
         }
     }
//.........这里部分代码省略.........
开发者ID:netconstructor,项目名称:X2Engine,代码行数:101,代码来源:SiteController.php

示例3: actionOnline

 public function actionOnline()
 {
     x2base::cleanUpSessions();
     $sessions = Session::model()->findAll();
     $usernames = array();
     $users = array();
     foreach ($sessions as $session) {
         $usernames[] = $session->user;
     }
     foreach ($usernames as $username) {
         $user = User::model()->findByAttributes(array('username' => $username));
         $users[] = $user->firstName . " " . $user->lastName;
     }
     $this->render('online', array('users' => $users));
 }
开发者ID:netconstructor,项目名称:X2Engine,代码行数:15,代码来源:SiteController.php

示例4: getRoutingRules

 public function getRoutingRules($data)
 {
     $admin =& Yii::app()->params->admin;
     //Admin::model()->findByPk(1);
     $online = $admin->onlineOnly;
     x2base::cleanUpSessions();
     $sessions = Session::getOnlineUsers();
     $rules = CActiveRecord::model('LeadRouting')->findAll("", array('order' => 'priority'));
     foreach ($rules as $rule) {
         $arr = LeadRouting::parseCriteria($rule->criteria);
         $flagArr = array();
         foreach ($arr as $criteria) {
             if (isset($data[$criteria['field']])) {
                 $val = $data[$criteria['field']];
                 $operator = $criteria['comparison'];
                 $target = $criteria['value'];
                 if ($operator != 'contains') {
                     switch ($operator) {
                         case '>':
                             $flag = $val >= $target;
                             break;
                         case '<':
                             $flag = $val <= $target;
                             break;
                         case '=':
                             $flag = $val == $target;
                             break;
                         case '!=':
                             $flag = $val != $target;
                             break;
                         default:
                             $flag = false;
                     }
                 } else {
                     $flag = preg_match("/{$target}/i", $val) != 0;
                 }
                 $flagArr[] = $flag;
             }
         }
         if (!in_array(false, $flagArr) && count($flagArr) > 0) {
             $users = $rule->users;
             $users = explode(", ", $users);
             if (is_null($rule->groupType)) {
                 if ($online == 1) {
                     $users = array_intersect($users, $sessions);
                 }
             } else {
                 $groups = $rule->users;
                 $groups = explode(", ", $groups);
                 $users = array();
                 foreach ($groups as $group) {
                     if ($rule->groupType == 0) {
                         $links = GroupToUser::model()->findAllByAttributes(array('groupId' => $group));
                         foreach ($links as $link) {
                             if (array_search(User::model()->findByPk($link->userId)->username, $users) === false) {
                                 $users[] = User::model()->findByPk($link->userId)->username;
                             }
                         }
                     } else {
                         $users[] = $group;
                     }
                 }
                 if ($online == 1 && $rule->groupType == 0) {
                     $users = array_intersect($users, $sessions);
                 }
             }
             $users[] = $rule->rrId;
             $rule->rrId++;
             $rule->save();
             return $users;
         }
     }
 }
开发者ID:netconstructor,项目名称:X2Engine,代码行数:73,代码来源:AdminController.php


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