ciao a tutti io avevo ricevuto da un amico un codice per vedere guest nascosti e utenti registrati online utilizzando phpBB
prima ho incluso le librerie di phpBB con questo codice:
Codice:
<?php
$me = "../informatica/";
//nome di questo file
define('IN_PHPBB', true);
$phpbb_root_path = '../community/'; // MODIFICARE IN ACCORDO ALLA TUA INSTALLAZIONE
include($phpbb_root_path . 'extension.inc'); // Inclusione nella pagina delle librerie necessarie
include($phpbb_root_path . 'common.'.$phpEx);
//
// Start session management
//
$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);
//
// End session management
//
include "banners.php";
include "../community/config.php";
?>
poi il vero codice per gli users online è questo:
Codice:
<?php
$db = mysql_connect($dbhost, $dbuser, $dbpasswd) or die ("Connessione al database non riuscita");
mysql_select_db($dbname, $db) or die ("Selezione del database non riuscita");
$sql = "SELECT u.user_id, u.username, u.user_allow_viewonline, u.user_level, s.session_logged_in, s.session_time, s.session_page, s.session_ip
FROM ".USERS_TABLE." u, ".SESSIONS_TABLE." s
WHERE u.user_id = s.session_user_id
AND s.session_time >= ".( time() - 300 ) . "
ORDER BY u.username ASC, s.session_ip ASC";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not obtain regd user/online information', '', __LINE__, __FILE__, $sql);
}
$guest_users = 0;
$registered_users = 0;
$hidden_users = 0;
$reg_counter = 0;
$guest_counter = 0;
$prev_user = 0;
$prev_ip = '';
while ( $row = $db->sql_fetchrow($result) )
{
$view_online = false;
if ( $row['session_logged_in'] )
{
$user_id = $row['user_id'];
if ( $user_id != $prev_user )
{
$username = $row['username'];
if ( $row['user_allow_viewonline'] )
{
$registered_users++;
}
else
{
$hidden_users++;
}
if ( $row['user_allow_viewonline'] || ($row['user_id'] == $user->data['user_id']) || ($user->data['user_level'] == ADMIN) || ($user->auth(POST_FORUM_URL, 'auth_mod', intval($row['session_page'])) && ($row['user_level'] != ADMIN)) )
{
$view_online = true;
$style = isset($user_levels[ $row['user_level'] ]) ? $user_levels[ $row['user_level'] ]['style'] : $user_levels[USER]['style'];
$username = sprintf(($row['user_allow_viewonline'] ? (empty($style) ? '%s' : '<span' . $style . '>%s</span>') : '<i' . $style . '>%s</i>'), $row['username']);
}
else
{
$view_online = false;
}
$which_counter = 'reg_counter';
$which_row = 'reg_user_row';
$prev_user = $user_id;
}
}
else
{
if ( $row['session_ip'] != $prev_ip )
{
$username = $lang['Guest'];
$view_online = true;
$guest_users++;
$which_counter = 'guest_counter';
$which_row = 'guest_user_row';
}
}
$prev_ip = $row['session_ip'];
if ( $view_online )
{
if ( ($row['session_page'] < 1) || !$user->auth(POST_FORUM_URL, 'auth_view', intval($row['session_page'])) )
{
switch( $row['session_page'] )
{
case PAGE_INDEX:
$location = $lang['Forum_index'];
$location_url = "index.$phpEx";
break;
case PAGE_POSTING:
$location = $lang['Posting_message'];
$location_url = "index.$phpEx";
break;
case PAGE_LOGIN:
$location = $lang['Logging_on'];
$location_url = "index.$phpEx";
break;
case PAGE_SEARCH:
$location = $lang['Searching_forums'];
$location_url = "search.$phpEx";
break;
case PAGE_PROFILE:
$location = $lang['Viewing_profile'];
$location_url = "index.$phpEx";
break;
case PAGE_VIEWONLINE:
$location = $lang['Viewing_online'];
$location_url = "viewonline.$phpEx";
break;
case PAGE_VIEWMEMBERS:
$location = $lang['Viewing_member_list'];
$location_url = "memberlist.$phpEx";
break;
case PAGE_PRIVMSGS:
$location = $lang['Viewing_priv_msgs'];
$location_url = "privmsg.$phpEx";
break;
case PAGE_FAQ:
$location = $lang['Viewing_FAQ'];
$location_url = "faq.$phpEx";
break;
default:
$location = $lang['Forum_index'];
$location_url = "index.$phpEx";
}
}
else
{
$location_url = $config->url('index', array(POST_FORUM_URL => $row['session_page']), true);
$location = $forum_data[$row['session_page']];
}
$row_color = ( $$which_counter % 2 ) ? $theme['td_color1'] : $theme['td_color2'];
$row_class = ( $$which_counter % 2 ) ? $theme['td_class1'] : $theme['td_class2'];
$$which_counter++;
}
}
$parzial_user = sprintf($l_r_user_s, $registered_users) . sprintf($l_h_user_s, $hidden_users);
$parzial_guest = sprintf($l_g_user_s, $guest_users));
$tot_online_user = $parzial_user + $parzial_guest;
?>
però il codice mi da sempr elo stess errore anke modificando le varie linee e l'errore è questo:
Fatal error: Call to a member function on a non-object