Code: Alles auswählen
##########################################################################################
## 
## MOD Titel:    Wer ist in welchem Forum aktiv - Index
## MOD Version:  1.2.0
## Autor:        Acid
##
## Beschreibung: Dieser Hack zeigt auf dem Index an, welcher User in welchem
##		 Forum aktiv ist.
##
## Dateien zu ändern:  3
##   	               index.php
##      	       language/lang_german/lang_main.php
##                     templates/xxx/index_body.tpl
## 
##########################################################################################
## 
## Notiz: 
## Als erstes sollte man alle betreffenden Dateien sichern.
##
## Der Code stammt teilweise aus der page_header.php.
## Am Ende dieser Datei findet man noch einen optionalen Teil.
##
##########################################################################################
##
## Versionen:
## 
## v1.2.0 - umgeschrieben (weniger Queries)
## v1.0.3 - Junior Admins/Supermoderatoren werden nun auch farblich hervorgehoben
##	  - hatte noch vergessen einen Testcode zu löschen
## v1.0.2 - Fehler in index_body.tpl behoben
## v1.0.1 - Code bereinigt und optionalen Teil hinzugefügt
## v1.0.0 - Veröffentlichung
## 
##########################################################################################
# 
#-----[ ÖFFNEN ]------------------------------------------ 
#
# index.php 
# 
#-----[ FINDE ]------------------------------------------ 
#
	while( $row = $db->sql_fetchrow($result) )
	{
		$forum_moderators[$row['forum_id']][] = '<a href="' . append_sid("groupcp.$phpEx?" . POST_GROUPS_URL . "=" . $row['group_id']) . '">' . $row['group_name'] . '</a>';
	}
	$db->sql_freeresult($result);
# 
#-----[ DARUNTER EINFÜGEN ]------------------------------------------ 
#
	$sql_active = "SELECT u.username, u.user_id, u.user_allow_viewonline, u.user_level, s.session_logged_in, s.session_ip, f.forum_id
		          FROM ". USERS_TABLE ." u, ". SESSIONS_TABLE ." s, ". FORUMS_TABLE ." f
		          WHERE u.user_id = s.session_user_id AND s.session_time >= ". (time() - 300) ." AND s.session_page = f.forum_id
		          ORDER BY u.username ASC, s.session_ip ASC";
	if( !($result_active = $db->sql_query($sql_active)) )
	{
		message_die(GENERAL_ERROR, 'could not obtain user/online information.', '', __LINE__, __FILE__, $sql_active);
	}
	$userlist_ary = array();
	$userlist_visible = array();
	$prev_userid = 0;
	$prev_userip = $prev_sessionip = '';
	while( $active = $db->sql_fetchrow($result_active) )
	{
		if( $active['session_logged_in'] )
		{
			if( $active['user_id'] != $prev_userid )
			{
				if( file_exists(@phpbb_realpath($phpbb_root_path .'includes/functions_color_groups.'.$phpEx)) )
				{
					include_once($phpbb_root_path .'includes/functions_color_groups.'.$phpEx);
					$active['username'] = color_group_colorize_name($active['user_id']);
				}
				else
				{
					if( file_exists(@phpbb_realpath($phpbb_root_path .'includes/functions_jr_admin.'.$phpEx)) )
					{
						include_once($phpbb_root_path .'includes/functions_jr_admin.' . $phpEx);
						$jr_admin_userdata = jr_admin_get_user_info($active['user_id']);
					}
					$style_color = '';
					if( $active['user_level'] == ADMIN )
					{
						$active['username'] = '<b>'. $active['username'] .'</b>';
						$style_color = 'style="color:#'. $theme['fontcolor3'] .'"';
					}
					else if( $active['user_id'] == $jr_admin_userdata['user_id'] || $active['user_level'] == LESS_ADMIN )
					{
						$active['username'] = '<b>'. $active['username'] .'</b>';
						$style_color = 'style="color:#FF0000"';
					}
					else if( $active['user_level'] == MOD )
					{
						$active['username'] = '<b>'. $active['username'] .'</b>';
						$style_color = 'style="color:#'. $theme['fontcolor2'] .'"';
					}
				}
				if( $active['user_allow_viewonline'] )
				{
					$onlinerow[$active['forum_id']][] = '<a href="'. append_sid("profile.$phpEx?mode=viewprofile&". POST_USERS_URL ."=". $active['user_id']) .'" '. $style_color .'>'. $active['username'] .'</a>';
					$logged_visible_active[$active['forum_id']][]++;
				}
				else
				{
					$onlinerow[$active['forum_id']][] = ( $active['user_allow_viewonline'] || $userdata['user_level'] == ADMIN ) ? '<a href="'. append_sid("profile.$phpEx?mode=viewprofile&". POST_USERS_URL ."=". $active['user_id']) .'" '. $style_color .'><i>'. $active['username'] .'</i></a>' : '';
					$logged_hidden_active[$active['forum_id']][]++;
				}
			}
			$prev_userid = $active['user_id'];
		}
		else
		{
			if( $active['session_ip'] != $prev_sessionip )
			{
				$guestrow[$active['forum_id']][] = '';
				$guests_active[$active['forum_id']][]++;
			}
		}
		$prev_sessionip = $active['session_ip'];
	}
	$db->sql_freeresult($result_active);
# 
#-----[ FIND ]------------------------------------------ 
#
							$template->assign_block_vars('catrow.forumrow',   array( 
								'ROW_COLOR' => '#' . $row_color,
# 
#-----[ REPLACE WITH ]------------------------------------------ 
#
							if( count($onlinerow[$forum_id]) > '0' )
							{
								$users_total_guests = count($guests_active[$forum_id]);
								$l_guests_total = ( $users_total_guests != '0' ) ? (( $users_total_guests == '1' ) ? $lang['Forum_one_guest_active'] : $lang['Forum_more_guests_active']) : '';
							}
							else
							{
								$users_total_guests = ' ';
								$l_guests_total = '';
							}
							if( count($onlinerow[$forum_id]) > '0' )
							{
								$users_total = count($onlinerow[$forum_id]);
								$users_total_hidden = count($logged_hidden_active[$forum_id]);
								$users_active = implode(', ', $onlinerow[$forum_id]);
								$l_active_total = ( $users_total == '1' ) ? $lang['Forum_one_active'] : $lang['Forum_more_active'];
								$l_hidden_total = ( ($users_total_hidden != '0' ) ? ( $userdata['user_level'] == ADMIN ) ? '' : (( $users_total_hidden == '1' ) ? $lang['Forum_one_hidden_active'] : $lang['Forum_more_hidden_active']) : '');
							}
							else
							{
								$users_total = ' ';
								$users_total_hidden = ' ';
								$users_active = ' ';
								$l_active_total = $lang['Forum_no_active'];
								$l_hidden_total = '';
							}
							$template->assign_block_vars('catrow.forumrow',   array( 
								'ACTIVE' => $users_active,
								'ACTIVE_TOTAL' => sprintf($l_active_total, ($users_total+$users_total_guests)),
								'ACTIVE_INFO' => sprintf($l_hidden_total, $users_total_hidden).sprintf($l_guests_total, $users_total_guests),
# 
#-----[ ÖFFNEN ]------------------------------------------ 
#
# language/lang_german/lang_main.php 
# 
#-----[ FINDE ]------------------------------------------ 
#
$lang['Moderators'] = 'Moderatoren';
# 
#-----[ DARUNTER EINFÜGEN ]------------------------------------------ 
#
// wenn man keine "0 users" anzeigen will, muss man die Auskommentierung (//) der
// folgenden Zeile entfernen und die Slashes vor die darauffolgende Zeile einfügen
// $lang['Forum_no_active'] = '';
$lang['Forum_no_active'] = '<b>0</b> User aktiv'; // <-- diese
$lang['Forum_one_active'] = '<b>%d</b> User aktiv: ';
$lang['Forum_more_active'] = '<b>%d</b> User aktiv: ';
$lang['Forum_one_hidden_active'] = '<b>%d</b> versteckter';
$lang['Forum_more_hidden_active'] = '<b>%d</b> versteckte';
$lang['Forum_one_guest_active'] = '<b>%d</b> Gast';
$lang['Forum_more_guests_active'] = '<b>%d</b> Gäste';
# 
#-----[ ÖFFNEN ]------------------------------------------ 
#
# templates/xxx/index_body.tpl 
# 
#-----[ FINDE ]------------------------------------------ 
#
  </span><span class="gensmall">{catrow.forumrow.L_MODERATOR} {catrow.forumrow.MODERATORS}</span></td>
# 
#-----[ MIT FOLGENDEM ERSETZEN ]------------------------------------------ 
# falls man ein anderes Template als subSilver benutzt und/oder den obigen Code nicht
# finden kann, muss man nach nur einem Teil von diesem suchen
  </span><span class="gensmall">{catrow.forumrow.L_MODERATOR} {catrow.forumrow.MODERATORS}</span><br /> 
  <span class="gensmall">{catrow.forumrow.ACTIVE_TOTAL} {catrow.forumrow.ACTIVE} {catrow.forumrow.ACTIVE_INFO}</span></td>
##########################################################################################
# 
#-----[ OPTIONALER TEIL ]--------------------------------------------- 
#
# wenn man den "Junior Admin" oder "Supermoderator" MOD installiert hat und die angezeigte
# Farbe ändern möchte
# 
#-----[ FINDE (index.php) ]------------------------------------------ 
# 
# ersetze #FF0000 mit der jeweiligen Farbe
	else if( $active['user_id'] == $jr_admin_userdata['user_id'] || $active['user_level'] == LESS_ADMIN )
	{
		$active['username'] = '<b>'. $active['username'] .'</b>';
		$style_color = 'style="color:#FF0000"';
	}
#
#------------------------------------------------------------------- 
#
# wenn diese Aktivitäten nur für Admins angezeigt werden sollen
#
#-----[ FINDE (index.php) ]------------------------------------------ 
# 
			if( count($onlinerow[$forum_id]) > '0' )
# 
#-----[ MIT FOLGENDEM ERSETZEN ]------------------------------------------ 
# 
			if( count($onlinerow[$forum_id]) > '0' && $userdata['user_level'] == ADMIN )
#
#------------------------------------------------------------------- 
#
# wenn diese Aktivitäten jeweils nur für den jeweiligen Moderator
# des Forums angezeigt werden sollen
# 
#-----[ FINDE (index.php) ]------------------------------------------ 
# 
			if( count($onlinerow[$forum_id]) > '0' )
# 
#-----[ MIT FOLGENDEM ERSETZEN ]------------------------------------------ 
# 
			$is_auth = array();
			$is_auth = auth(AUTH_ALL, $forum_id, $userdata, $forum_topic_data);
			if( count($onlinerow[$forum_id]) > '0' && $is_auth['auth_mod'] )
##########################################################################################
##########################################################################################
##########################################################################################