online_users.php

来自「sabreipb 2.1.6 utf-8中文版本!」· PHP 代码 · 共 263 行

PHP
263
字号
<?php/*+--------------------------------------------------------------------------|   Invision Power Board v2.1.5|   =============================================|   by Matthew Mecham|   (c) 2001 - 2005 Invision Power Services, Inc.|   |   =============================================|   Web: |   Time: Wed, 01 Mar 2006 19:11:29 GMT|   Release: |   Licence Info: +---------------------------------------------------------------------------|   > $Date: 2005-10-10 14:08:54 +0100 (Mon, 10 Oct 2005) $|   > $Revision: 23 $|   > $Author: matt $+---------------------------------------------------------------------------||   > PORTAL PLUG IN MODULE: SHOW ONLINE USERS|   > Module written by Matt Mecham|   > Date started: Tuesday 2nd August 2005 (12:56)+--------------------------------------------------------------------------*//*** Portal Plug In Module** This module shows the online users** @package		InvisionPowerBoard* @subpackage	PortalPlugIn* @author		Matt Mecham* @copyright	Invision Power Services, Inc.* @version		2.1*//*** Portal Plug In Module** This module shows the online users* Each class name MUST be in the format of:* ppi_{file_name_minus_dot_php}** @package		InvisionPowerBoard* @subpackage	PortalPlugIn* @author		Matt Mecham* @copyright	Invision Power Services, Inc.* @version		2.1*/class ppi_online_users{	/**	* IPS Global object	*	* @var string	*/	var $ipsclass;	/**	* Array of portal objects including:	* good_forum, bad_forum	*	* @var array	*/	var $portal_object = array();		/*-------------------------------------------------------------------------*/ 	// INIT	/*-------------------------------------------------------------------------*/ 	/**	* This function must be available always	* Add any set up here, such as loading language and skins, etc	*	*/ 	function init() 	{ 	} 		/*-------------------------------------------------------------------------*/	// MAIN FUNCTION	/*-------------------------------------------------------------------------*/	/**	* Main function	*	* @return VOID	*/	function online_users_show()	{ 		$this->sep_char = '<{ACTIVE_LIST_SEP}>'; 		 		//-----------------------------------------		// Get the users from the DB		//-----------------------------------------				$time = time() - ( ($this->ipsclass->vars['au_cutoff'] ? $this->ipsclass->vars['au_cutoff'] : 15) * 60 );				$this->ipsclass->DB->simple_construct( array( 'select' => 'id, member_id, member_name, login_type, running_time, member_group',													  'from'   => 'sessions',													  'where'  => "running_time > $time",													  'order'  => "running_time DESC"											 )      );							 		$this->ipsclass->DB->simple_exec();				//-----------------------------------------		// Cache all printed members		//-----------------------------------------				if ($this->ipsclass->vars['au_cutoff'] == "")		{			$this->ipsclass->vars['au_cutoff'] = 15;		}				//-----------------------------------------		// Get the users from the DB		//-----------------------------------------				$cut_off = $this->ipsclass->vars['au_cutoff'] * 60;		$time    = time() - $cut_off;		$qe      = "";		$rows    = array( 0 => array( 'login_type'   => substr($this->ipsclass->member['login_anonymous'],0, 1),									  'running_time' => time(),									  'member_id'    => $this->ipsclass->member['id'],									  'member_name'  => $this->ipsclass->member['members_display_name'],									  'member_group' => $this->ipsclass->member['mgroup'] ) );				if ( $this->ipsclass->member['id'] )		{			$qe = "member_id !=".intval($this->ipsclass->member['id'])." AND ";		}				$this->ipsclass->DB->simple_construct( array( 'select' => 'id, member_id, member_name, login_type, running_time, member_group',													  'from'   => 'sessions',													  'where'  => $qe." running_time > $time",													  'order'  => "running_time DESC"											 )      );						$this->ipsclass->DB->simple_exec();				//-----------------------------------------		// FETCH...		//-----------------------------------------				while ($r = $this->ipsclass->DB->fetch_row() )		{			$rows[] = $r;		}				//-----------------------------------------		// cache all printed members so we		// don't double print them		//-----------------------------------------				$cached = array();				foreach ( $rows as $result )		{			$last_date = $this->ipsclass->get_time( $result['running_time'] );						//-----------------------------------------			// Bot?			//-----------------------------------------						if ( strstr( $result['id'], '_session' ) )			{				//-----------------------------------------				// Seen bot of this type yet?				//-----------------------------------------								$botname = preg_replace( '/^(.+?)=/', "\\1", $result['id'] );								if ( ! $cached[ $result['member_name'] ] )				{					if ( $this->ipsclass->vars['spider_anon'] )					{						if ( $this->ipsclass->member['mgroup'] == $this->ipsclass->vars['admin_group'] )						{							$active['NAMES'] .= "{$result['member_name']}*{$this->sep_char} \n";						}					}					else					{						$active['NAMES'] .= "{$result['member_name']}{$this->sep_char} \n";					}										$cached[ $result['member_name'] ] = 1;				}				else				{					//-----------------------------------------					// Yup, count others as guest					//-----------------------------------------										$active['GUESTS']++;				}			}						//-----------------------------------------			// Guest?			//-----------------------------------------						else if ($result['member_id'] == 0 )			{				$active['GUESTS']++;			}						//-----------------------------------------			// Member?			//-----------------------------------------						else			{				if ( empty( $cached[ $result['member_id'] ] ) )				{					$cached[ $result['member_id'] ] = 1;										$result['prefix'] = $this->ipsclass->cache['group_cache'][ $result['member_group'] ]['prefix'];					$result['suffix'] = $this->ipsclass->cache['group_cache'][ $result['member_group'] ]['suffix'];										if ($result['login_type'])					{						if ( ($this->ipsclass->member['mgroup'] == $this->ipsclass->vars['admin_group']) and ($this->ipsclass->vars['disable_admin_anon'] != 1) )						{							$active['NAMES'] .= "<a href='{$this->ipsclass->base_url}showuser={$result['member_id']}' title='$last_date'>{$result['prefix']}{$result['member_name']}{$result['suffix']}</a>*{$this->sep_char} \n";							$active['ANON']++;						}						else						{							$active['ANON']++;						}					}					else					{						$active['MEMBERS']++;						$active['NAMES'] .= "<a href='{$this->ipsclass->base_url}showuser={$result['member_id']}' title='$last_date'>{$result['prefix']}{$result['member_name']}{$result['suffix']}</a>{$this->sep_char} \n";					}				}			}		}				$active['names'] = preg_replace( "/".preg_quote($this->sep_char)."$/", "", trim($active['NAMES']) );				$active['total']    = $active['MEMBERS'] + $active['GUESTS'] + $active['ANON'];		$active['visitors'] = $active['GUESTS']  + $active['ANON'];		$active['members']  = $active['MEMBERS'];				//-----------------------------------------		// Parse language		//-----------------------------------------				$breakdown = sprintf( $this->ipsclass->lang['online_breakdown'], intval($active['total']) );		$split     = sprintf( $this->ipsclass->lang['online_split']    , intval($active['members']), intval($active['visitors']) );		 		 		return $this->ipsclass->compiled_templates['skin_portal']->tmpl_onlineusers($breakdown, $split, $active['names']); 	}}?>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?