Salve a tutti
vorrei inserire nella mia homepage uno script in cui sono racchiusi i dati del forum phpbb tipo utenti connessi, nascosti, ecc.
il codice che uso è questo:
Codice:
Who's online</center>
<?php
$logged_visible_online = 0;
$logged_hidden_online = 0;
$guests_online = 0;
$online_userlist = '';
$l_online_users = '';
$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 = $prev_session_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("../community/profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=" . $row['user_id']) . '"' . $style_color .'><b>' . $row['username'] . '</b></a>';
$logged_visible_online++;
}
else
{
$user_online_link = '<a href="' . append_sid("../community/profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=" . $row['user_id']) . '"' . $style_color .'><b>' . $row['username'] . '</b></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);
print "<div align=\"Left\"><ul><li>In totale ci sono <font color=\"#FF000\"> $total_online_users </font> utenti in linea</li> <li>gli utenti non registrati online sono: <font color=\"#FF000\"> $guests_online </font> </li><li> gli utenti nascosti online sono: <font color=\"#FF000\"> $logged_hidden_online </font> </li><li>Gli utenti registrati online sono <font color=\"#FF000\"> $logged_visible_online </font>:<br> $online_userlist </li></ul>";
?>
vorrei inserire anche il numero totale degli iscritti, dei post e l'ultimo utente registrato.
Cosa devo aggiungere allo script?
grazie.