Server : Apache System : Linux indy02.toastserver.com 3.10.0-962.3.2.lve1.5.85.el7.x86_64 #1 SMP Thu Apr 18 15:18:36 UTC 2024 x86_64 User : palandch ( 1163) PHP Version : 7.1.33 Disable Function : NONE Directory : /home/palandch/www/manager/controllers/default/dashboard/ |
<?php /** * @package modx * @subpackage dashboard */ /** * @package modx * @subpackage dashboard */ class modDashboardWidgetWhoIsOnline extends modDashboardWidgetInterface { public function render() { $timetocheck = (time()-(60*20)); $c = $this->modx->newQuery('modManagerLog'); $c->innerJoin('modUser','User'); $c->where(array( 'occurred:>' => strftime('%Y-%m-%d, %H:%M:%S',$timetocheck), )); $c->where( "occurred = (SELECT MAX(`occurred`) FROM {$this->modx->getTableName('modManagerLog')} AS log2 WHERE `log2`.`user` = `modManagerLog`.`user` GROUP BY `user`)" ); $data['total'] = $this->modx->getCount('modManagerLog',$c); $c->select($this->modx->getSelectColumns('modManagerLog','modManagerLog')); $c->select($this->modx->getSelectColumns('modUser','User','',array('username'))); $c->sortby('occurred','DESC'); $ausers = $this->modx->getIterator('modManagerLog',$c); $users = array(); /** @var modActiveUser $user */ $alt = false; foreach ($ausers as $user) { $userArray = $user->toArray(); $userArray['currentAction'] = $user->get('action'); $userArray['occurred'] = strftime('%b %d, %Y - %I:%M %p',strtotime($user->get('occurred'))+floatval($this->modx->getOption('server_offset_time',null,0)) * 3600); $userArray['class'] = $alt ? 'alt' : ''; $users[] = $this->getFileChunk('dashboard/onlineusers.row.tpl',$userArray); } $output = $this->getFileChunk('dashboard/onlineusers.tpl',array( 'users' => implode("\n",$users), 'curtime' => strftime('%I:%M %p',time()+floatval($this->modx->getOption('server_offset_time',null,0)) * 3600), )); return $output; } } return 'modDashboardWidgetWhoIsOnline';