Seite 1 von 1

"User im Chat" mit Profillink, versteckt, Farben..

Verfasst: 06.12.2004 17:04
von BZebra
Hallo,

bei den Mods ChatBox und ChatSpot werden ja im Forenindex unten die Usernamen aufgelistet, die sich gerade im Chat befinden; das allerdings nur schwarz und als reiner Text.

Gibt es eine Möglichkeit die Usernamen genauso darzustellen, wie es bei den "Registrierten Benutzern" der Fall ist, sprich mit Link zum Profil, mit verschiedenen Farben für Admin, Moderator und normale User und daß versteckte User nicht angezeigt werden?

Hat das vielleicht schon jemand gemacht oder weiß wie das geht?

Verfasst: 07.12.2004 02:12
von BZebra
Also, ich schreib mal hier rein, bis wohin ich gekommen bin:

In der index_body.tpl stehen die Variablen
  1. {LOGGED_IN_USER_LIST}
  2. {CHATTERS_LIST}
In der page_header.php findet sich zu LOGGED_IN_USER_LIST das hier:

Code: Alles auswählen

'LOGGED_IN_USER_LIST' => $online_userlist,
und zu $online_userlist dies hier:

Code: Alles auswählen

//
// Get basic (usernames + totals) online
// situation
//
$logged_visible_online = 0;
$logged_hidden_online = 0;
$guests_online = 0;
$online_userlist = '';

if (defined('SHOW_ONLINE'))
{

	$user_forum_sql = ( !empty($forum_id) ) ? "AND s.session_page = " . intval($forum_id) : '';
	$sql = "SELECT u.username, u.user_id, u.user_allow_viewonline, u.user_level, s.session_logged_in, s.session_ip
		FROM ".USERS_TABLE." u, ".SESSIONS_TABLE." s
		WHERE u.user_id = s.session_user_id
			AND s.session_time >= ".( time() - 300 ) . "
			$user_forum_sql
		ORDER BY u.username ASC, s.session_ip ASC";
	if( !($result = $db->sql_query($sql)) )
	{
		message_die(GENERAL_ERROR, 'Could not obtain user/online information', '', __LINE__, __FILE__, $sql);
	}

	$userlist_ary = array();
	$userlist_visible = array();

	$prev_user_id = 0;
	$prev_user_ip = '';

	while( $row = $db->sql_fetchrow($result) )
	{
		// User is logged in and therefor not a guest
		if ( $row['session_logged_in'] )
		{
			// Skip multiple sessions for one user
			if ( $row['user_id'] != $prev_user_id )
			{
				$style_color = '';
				if ( $row['user_level'] == ADMIN )
				{
					$row['username'] = '<b>' . $row['username'] . '</b>';
					$style_color = 'style="color:#' . $theme['fontcolor3'] . '"';
				}
				else if ( $row['user_level'] == MOD )
				{
					$row['username'] = '<b>' . $row['username'] . '</b>';
					$style_color = 'style="color:#' . $theme['fontcolor2'] . '"';
				}

				if ( $row['user_allow_viewonline'] )
				{
					$user_online_link = '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=" . $row['user_id']) . '"' . $style_color .'>' . $row['username'] . '</a>';
					$logged_visible_online++;
				}
				else
				{
					$user_online_link = '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=" . $row['user_id']) . '"' . $style_color .'><i>' . $row['username'] . '</i></a>';
					$logged_hidden_online++;
				}

				if ( $row['user_allow_viewonline'] || $userdata['user_level'] == ADMIN )
				{
					$online_userlist .= ( $online_userlist != '' ) ? ', ' . $user_online_link : $user_online_link;
				}
			}

			$prev_user_id = $row['user_id'];
		}
		else
		{
			// Skip multiple sessions for one user
			if ( $row['session_ip'] != $prev_session_ip )
			{
				$guests_online++;
			}
		}

		$prev_session_ip = $row['session_ip'];
	}
	$db->sql_freeresult($result);

	if ( empty($online_userlist) )
	{
		$online_userlist = $lang['None'];
	}
	$online_userlist = ( ( isset($forum_id) ) ? $lang['Browsing_forum'] : $lang['Registered_users'] ) . ' ' . $online_userlist;

	$total_online_users = $logged_visible_online + $logged_hidden_online + $guests_online;

	if ( $total_online_users > $board_config['record_online_users'])
	{
		$board_config['record_online_users'] = $total_online_users;
		$board_config['record_online_date'] = time();

		$sql = "UPDATE " . CONFIG_TABLE . "
			SET config_value = '$total_online_users'
			WHERE config_name = 'record_online_users'";
		if ( !$db->sql_query($sql) )
		{
			message_die(GENERAL_ERROR, 'Could not update online user record (nr of users)', '', __LINE__, __FILE__, $sql);
		}

		$sql = "UPDATE " . CONFIG_TABLE . "
			SET config_value = '" . $board_config['record_online_date'] . "'
			WHERE config_name = 'record_online_date'";
		if ( !$db->sql_query($sql) )
		{
			message_die(GENERAL_ERROR, 'Could not update online user record (date)', '', __LINE__, __FILE__, $sql);
		}
	}

	if ( $total_online_users == 0 )
	{
		$l_t_user_s = $lang['Online_users_zero_total'];
	}
	else if ( $total_online_users == 1 )
	{
		$l_t_user_s = $lang['Online_user_total'];
	}
	else
	{
		$l_t_user_s = $lang['Online_users_total'];
	}

	if ( $logged_visible_online == 0 )
	{
		$l_r_user_s = $lang['Reg_users_zero_total'];
	}
	else if ( $logged_visible_online == 1 )
	{
		$l_r_user_s = $lang['Reg_user_total'];
	}
	else
	{
		$l_r_user_s = $lang['Reg_users_total'];
	}

	if ( $logged_hidden_online == 0 )
	{
		$l_h_user_s = $lang['Hidden_users_zero_total'];
	}
	else if ( $logged_hidden_online == 1 )
	{
		$l_h_user_s = $lang['Hidden_user_total'];
	}
	else
	{
		$l_h_user_s = $lang['Hidden_users_total'];
	}

	if ( $guests_online == 0 )
	{
		$l_g_user_s = $lang['Guest_users_zero_total'];
	}
	else if ( $guests_online == 1 )
	{
		$l_g_user_s = $lang['Guest_user_total'];
	}
	else
	{
		$l_g_user_s = $lang['Guest_users_total'];
	}

	$l_online_users = sprintf($l_t_user_s, $total_online_users);
	$l_online_users .= sprintf($l_r_user_s, $logged_visible_online);
	$l_online_users .= sprintf($l_h_user_s, $logged_hidden_online);
	$l_online_users .= sprintf($l_g_user_s, $guests_online);
}

//
// Obtain number of new private messages
// if user is logged in
//

In der index.php steht zu CHATTERS_LIST das da:

Code: Alles auswählen

'CHATTERS_LIST' => '<b>' . $users_in_chat . '</b>',
und $users_in_chat ist in chatspot_front.php definiert:

Code: Alles auswählen

/* **[DESCRIPTION]*********************************************************************************************************
		- called by the forum's index.php file
		- simply polls all the current chatters from phpBBChatSpot's session list; invisible and dead sessions will not be 
		  returned
		- deletion of ghosts is now performed by phpBBChatSpot upon joining rooms
	************************************************************************************************************************ */

if( !defined( 'IN_PHPBB' ) )
{
	die("Hacking attempt");
}

error_reporting(E_ERROR | E_WARNING | E_PARSE);
set_magic_quotes_runtime(0);

include_once( $phpbb_root_path . 'config.' . $phpEx );
include_once( $phpbb_root_path . 'chatspot/chatspot_config.' . $phpEx );

$table_chatspot_sessions_name = $table_prefix . 'chatspot_sessions';

$expire_time = time() - $chatspot_config[ 'inactive_time' ];

$sql = "SELECT DISTINCT user_id, username FROM " . $table_chatspot_sessions_name . " 
	WHERE last_active >= '" . $expire_time . "' 
	ORDER BY username ASC";

if( $result = $db->sql_query( $sql ) )
{
	$num_users_in_chat = $db->sql_numrows( $result ); // return this

	$users_in_chat = '';

	while( $row = $db->sql_fetchrow( $result ) )
	{
		if( strstr( $online_userlist, $row[ 'username' ] ) )  // invisible users will not be shown, nor will dead sessions
			$users_in_chat .= $row[ 'username' ] . ", ";
	}

	$users_in_chat = rtrim( $users_in_chat, ", " ); // return this

	$db->sql_freeresult( $result );
}

?>
So, kann mir dazu vielleicht jemand was sagen? :-?