func_boardstats.php

来自「sabreipb 2.1.6 utf-8中文版本!」· PHP 代码 · 共 513 行 · 第 1/2 页

PHP
513
字号
<?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: 2006-01-30 18:53:19 +0000 (Mon, 30 Jan 2006) $|   > $Revision: 127 $|   > $Author: bfarber $+---------------------------------------------------------------------------||   > Board index functions module|   > Module written by Matt Mecham|   > Date started: 18th November 2003||	> Module Version Number: 1.0.0|   > DBA Checked: Fri 21 May 2004+--------------------------------------------------------------------------*/if ( ! defined( 'IN_IPB' ) ){	print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";	exit();}class func_boardstats{	# Global	var $ipsclass;		var $class    = "";	var $sep_char = '<{ACTIVE_LIST_SEP}>';		var $users_online  = "";	var $total_posts   = "";	var $total_members = "";		/*-------------------------------------------------------------------------*/	// register_class	// ------------------	// Register a $this-> class with this module	/*-------------------------------------------------------------------------*/		function register_class()	{				// NO LONGER NEEDED	}		/*-------------------------------------------------------------------------*/	//	// DISPLAY ACTIVE USERS	//	/*-------------------------------------------------------------------------*/		function active_users()	{		$active = array( 'TOTAL'   => 0 ,						 'NAMES'   => "",						 'GUESTS'  => 0 ,						 'MEMBERS' => 0 ,						 'ANON'    => 0 ,					   );					   		$stats_html = "";				if ( $this->ipsclass->vars['show_active'] )		{			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;			$rows    = array();			$ar_time = time();						if ( $this->ipsclass->member['id'] )			{				$rows = array( $ar_time => array( 'login_type'   => substr($this->ipsclass->member['login_anonymous'],0, 1),												  'running_time' => $ar_time,												  'member_id'    => $this->ipsclass->member['id'],												  'member_name'  => $this->ipsclass->member['members_display_name'],												  'member_group' => $this->ipsclass->member['mgroup'] ) );			}						$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" // Sort in PHP to avoid filesort in SQL												 )      );									$this->ipsclass->DB->simple_exec();						//-----------------------------------------			// FETCH...			//-----------------------------------------						while ( $r = $this->ipsclass->DB->fetch_row() )			{				$rows[ $r['running_time'].'.'.$r['id'] ] = $r;			}						krsort( $rows );						//-----------------------------------------			// 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'] )				{					$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'];						$this->users_online = $active['TOTAL'];						//-----------------------------------------			// Show a link?			//-----------------------------------------						if ($this->ipsclass->vars['allow_online_list'])			{				$active['links'] = $this->ipsclass->compiled_templates['skin_boards']->active_user_links();			}						$this->ipsclass->lang['active_users'] = sprintf( $this->ipsclass->lang['active_users'], $this->ipsclass->vars['au_cutoff'] );						return $this->ipsclass->compiled_templates['skin_boards']->ActiveUsers($active, $this->ipsclass->vars['au_cutoff']);		}			}		/*-------------------------------------------------------------------------*/	//	// SHOW CALENDAR EVENTS	//	/*-------------------------------------------------------------------------*/		function show_calendar_events()	{		if ($this->ipsclass->vars['show_birthdays'] or $this->ipsclass->vars['show_calendar'] )		{			$a = explode( ',', gmdate( 'Y,n,j,G,i,s', time() + $this->ipsclass->get_time_offset() ) );					$day   = $a[2];			$month = $a[1];			$year  = $a[0];						$birthstring = "";			$count       = 0;			$users       = array();						if ( $this->ipsclass->vars['show_birthdays'] )

⌨️ 快捷键说明

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