注册 登录  
 加关注
查看详情
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

天上人间*bobo之家

有阳光的时段,就有他(她)的博客文章。也许天气并非晴空万里,博主的“博物钟”却是

 
 
 

日志

 
 

显示在线用户方法  

2010-01-26 19:38:44|  分类: typo3 |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

摘自mm_forum之pi6

 /**
  * Determines the amount of registered users who were online today.
  * @author Martin Helmich <
m.helmich@mittwald.de>
  * @return integer The amount of registered users who were online today.
  * @uses getUsersFromTime
  * @uses getTodayDate
  */
 function getTodayUsers() {
  return $this->getUsersFromTime($this->getTodayDate(),FALSE,$this->conf['showPostCount'] && !$this->small);
 }

 /**
  * Determines the unix timestamp of the current day at 0:00.
  * @author Martin Helmich <
m.helmich@mittwald.de>
  * @return integer The unix timestamp of the current day at 0:00.
  */
 function getTodayDate() {
  $today = date('dmy');
  $today = mktime(0,0,1,substr($today,2,2),substr($today,0,2),substr($today,4,4));

  return $today;
 }

 /**
  * Determines all registered users currently online
  * @author Martin Helmich <
m.helmich@mittwald.de>.
  * @return array An array containing information on users logged in.
  * @uses getUsersFromTime
  */
 function getOnlineUsers() {
  return $this->getUsersFromTime(time()-$this->conf['onlineTime'],TRUE,FALSE);
 }

 /**
  * Determines all registered users who were online since a certain point of time.
  * @author Martin Helmich <
m.helmich@mittwald.de>
  * @param  integer $time         The point of time, since when the users are to be counted.
  * @param  boolean $sesBackcheck Determines, of the user status is to be checked by session data.
  * @param  boolean $postCount    Determines, if the amount of posts created since $time is to be determined (can be
  *                               quite time-expensive)
  * @return array                 An array containing information on users who were online today.
  */
 function getUsersFromTime($time, $sesBackcheck=FALSE, $postCount=TRUE) {
  $result = Array(
   'users','mods',"admins",'count'
  );

  if(!t3lib_extMgm::isLoaded('sys_stat')) $sesBackcheck = TRUE;

  if($sesBackcheck) {
   $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
    'u.usergroup, u.'.tx_mmforum_pi1::getUserNameField().', u.uid',
    'fe_users u, fe_sessions s',
    's.ses_tstamp >= "'.$time.'" AND u.deleted=0 AND u.disable=0 AND u.uid=s.ses_userid '.$this->getUserPidQuery('u'),
    'ses_userid',
    'username ASC'
   );
  }
  else {
   $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
    'u.usergroup, u.'.tx_mmforum_pi1::getUserNameField().', u.uid',
    'fe_users u, sys_stat s',
    's.feuser_id != "0" AND u.uid = s.feuser_id AND s.tstamp >= "'.$time.'" '.$this->getUserPidQuery('u'),
    'feuser_id'
   );
  }
  while($arr = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
   if($postCount) {
    $res2 = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
     'COUNT(*)',
     'tx_mmforum_posts',
     'poster_id="'.$arr['uid'].'" AND post_time >= "'.$time.'"'.$this->cObj->enableFields('tx_mmforum_posts').' '.$this->getPidQuery()
    );
    $arr2 = $GLOBALS['TYPO3_DB']->sql_fetch_row($res2);
    $arr['postCount'] = $arr2[0];
   }

    if(t3lib_div::inList($arr['usergroup'],$this->conf['adminGroup'])) $result['admins'][] = $arr;
   elseif(t3lib_div::inList($arr['usergroup'],$this->conf['modGroup'])) $result['mods'][] = $arr;
   else $result['users'][] = $arr;
  }
  $result['count'] = $GLOBALS['TYPO3_DB']->sql_num_rows($res);

  return $result;
 }

 /**
  * Updates the configuration array.
  * @author Martin Helmich <
m.helmich@mittwald.de>
  * @return void
  */
 function getConfig() {
  $this->conf['templateFile'] = $this->conf['templateFile']?$this->conf['templateFile']:'EXT:mm_forum/res/tmpl/default/portalinfo/mm_forum_pi6.tmpl';
  $this->conf['cssFile'] = $this->conf['cssFile']?$this->conf['cssFile']:'typo3conf/ext/mm_forum_portalinfo/stylesheet.css';
  $this->conf['onlineTime'] = $this->conf['onlineTime']?intval($this->conf['onlineTime']):600;
  $this->conf['showGuests'] = ($this->conf['showGuests']=='1')?TRUE:FALSE;
  $this->conf['showPostCount'] = ($this->conf['showPostCount']=='1')?TRUE:FALSE;
  $this->conf['debug'] = (trim($this->conf['debug'])=='1')?TRUE:FALSE;
 }

 /**
  * Delivers a MySQL-WHERE query checking a fe_user record's PID.
  * @param   string $table The table name from which to select. Default 'fe_user'
  * @return  string        The query, following the pattern " AND fe_users.pid=..."
  * @author  Martin Helmich <
m.helmich@mittwald.de>
  * @version 2007-04-16
  */
 function getUserPidQuery($table="fe_users") {
  if($this->conf['userPID']==-1) return "";
  if($this->conf['userPID']=="") return "";
  else return " AND $table.pid='".$this->conf['userPID']."'";
 }


    /**
  * Delivers a MySQL-WHERE query checking the records' PID.
  * This allows it to exclusively select records from a very specific list
  * of pages.
  *
  * NOTE: This function is currently partially disabled.
  *       Instead of defining the PIDs to be checked via the plugin's Starting
  *       Point, the PID is in this version defined in the TS constant
  *       plugin.tx_mmforum.storagePID
  *
  * @param   string $tables The list of tables that are queried
  * @return  string         The query, following the pattern " AND pid IN (...)"
  * @author  Martin Helmich <
m.helmich@mittwald.de>
  * @version 2007-04-03
  */
 function getPidQuery($tables="") {
  if($this->conf['storagePID']==-1) return "";
  if($this->conf['storagePID']=="") return "";
  else {
   if($tables == "")
    return " AND pid='".$this->conf['storagePID']."'";

   $tables = t3lib_div::trimExplode(',',$tables);
   $query = "";

   foreach($tables as $table) {
    $query .= " AND $table.pid='".$this->conf['storagePID']."'";
   }
   return $query;
  }

  评论这张
 
阅读(183)| 评论(0)
推荐 转载

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2018