Seite 1 von 1

Änderung für Forenstatistik in Signatur

Verfasst: 22.05.2005 08:35
von An-Ja
Hallo,

in der Forenstatistik in der Signatur wird angezeigt, wieviele User online sind, leider nur die registrierten User. Weiss jemand, was ich an folgendem Code ändern müsste, damit die Anzahl aller Online-User (sowohl die registrierten als auch die Gäste) angezeigt wird ?

define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);

// Get basic (usernames + totals) online
// situation
//
$user_forum_sql = ( !empty($forum_id) ) ? "AND s.session_page = " . intval($forum_id) : '';
$sql = "SELECT u.username, u.user_id, 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);
}

$logged_online = 0;
$prev_user_id = 0;

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 )
{
$logged_online++;
}

$prev_user_id = $row['user_id'];
}
}

$sql = 'SELECT max(topic_id)
FROM ' . TOPICS_TABLE;

if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Couldn\'t retrieve max of Topic_id data', '', __LINE__, __FILE__, $sql);
}

while ( $row = $db->sql_fetchrow($result))
{
$max_topic_id = $row['max(topic_id)'];
}


$image = "images/signature.png";
$im = imagecreatefrompng($image);
$tc = ImageColorAllocate ($im, 0, 0, 0);
$red = ImageColorAllocate ($im, 255, 153, 0);
$blue = ImageColorAllocate ($im, 0, 102, 153);
$sitename = $board_config['sitename'];
$total_users = get_db_stat('usercount');
$total_posts = get_db_stat('postcount');
$total_topics = get_db_stat('topiccount');
$j = strlen($total_users);
$leerzeichen = $j*6+237;

ImageString($im, 2, $leerzeichen, 15, "Online: $logged_online", $red);

header("Content-Type: image/png");
Imagepng($im,'',100);
ImageDestroy ($im);
Dankeschön im voraus :)

Verfasst: 23.05.2005 13:17
von An-Ja
Kann bitte jemand helfen ? :)

Verfasst: 24.05.2005 08:40
von An-Ja
Weiss denn wirklich keiner, wie aus registrierten Usern alle Besucher werden ?????????? :o

Verfasst: 24.05.2005 09:30
von John Doe
Hiermit geht das

Code: Alles auswählen

<?php 

define('IN_PHPBB', true); 
$phpbb_root_path = './'; 
include($phpbb_root_path . 'extension.inc'); 
include($phpbb_root_path . 'common.'.$phpEx); 

$user_forum_sql = ( !empty($forum_id) ) ? "AND s.session_page = " . intval($forum_id) : ''; 
$sql = "SELECT u.username, u.user_id, 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); 
} 

$sql2 = " SELECT session_time " 
. " FROM " . SESSIONS_TABLE 
. " WHERE session_logged_in = 0 " 
. " AND session_time >= " . ( time() - 300 ) 
. " ORDER BY session_time DESC"; 
if(!$result2 = $db->sql_query($sql2)) 
{ 
message_die(GENERAL_ERROR, "Couldn't obtain guest user/online information.", "", __LINE__, __FILE__, $sql2); 
} 
$onlinerow_guest = $db->sql_fetchrowset($result2); 
$guests_online = count($onlinerow_guest); 

$total_online_users = $registered_user_online + $guests_online; 

$logged_online = 0; 

$prev_user_id = 0; 

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 ) 
{ 
$logged_online++; 
} 

$prev_user_id = $row['user_id']; 
} 
} 

$image = "images/signature.png"; 
$im = imagecreatefrompng($image); 
$tc = ImageColorAllocate ($im, 0, 0, 0); 
$red = ImageColorAllocate ($im, 255, 0, 0); 
$green = ImageColorAllocate ($im, 23, 124, 17); 
$dblue = ImageColorAllocate ($im, 0, 0, 255); 
$version = '2'.$board_config['version']; 
$sitename = $board_config['sitename']; 
$total_users = get_db_stat('usercount'); 
$total_posts = get_db_stat('postcount'); 
$total_topics = get_db_stat('topiccount'); 

$j = strlen($total_users); 
$leerzeichen = $j*6+237; 
$newest_userdata = get_db_stat('newestuser'); 
$newest_user = $newest_userdata['username']; 
ImageString($im, 3, 148, 2, "Statistics for $sitename", $dblue); 
ImageString($im, 2, 148, 15, "phpBB Version: $version - ", $tc); 
ImageString($im, 2, 148, 25, "Total Members: $total_users - ", $tc); 
ImageString($im, 2, $leerzeichen, 25, "   Members Online: $logged_online - Guests: $guests_online", $red); 
ImageString($im, 2, 148, 35, "We have a total of $total_posts Posts in $total_topics Topics", $tc); 
ImageString($im, 2, 148, 45, "Newest [your site name here] Member :  $newest_user", $green); 
header("Content-Type: image/png"); 
Imagepng($im,'',100); 
ImageDestroy ($im); 
?> 

Verfasst: 24.05.2005 10:00
von An-Ja
Dankeschön, das funktioniert prima :)