Code: Select all
<?php
//custom file to display friends that are offline/online
// by PPCW2 [ http://www.phpbb.com/community/memberlist.php?mode=viewprofile&u=978555 ]
// 29th January 2010
// part of code used from ucp.php package from phpBB
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup('ucp');
//sql to get online friends
$update_time = $config['load_online_time'] * 60;
$sql = $db->sql_build_query('SELECT_DISTINCT', array(
'SELECT' => 'u.user_id, u.username, u.username_clean, u.user_colour, MAX(s.session_time) as online_time, MIN(s.session_viewonline) AS viewonline',
'FROM' => array(
USERS_TABLE => 'u',
ZEBRA_TABLE => 'z'
),
'LEFT_JOIN' => array(
array(
'FROM' => array(SESSIONS_TABLE => 's'),
'ON' => 's.session_user_id = z.zebra_id'
)
),
'WHERE' => 'z.user_id = ' . $user->data['user_id'] . '
AND z.friend = 1
AND u.user_id = z.zebra_id',
'GROUP_BY' => 'z.zebra_id, u.user_id, u.username_clean, u.user_colour, u.username',
'ORDER_BY' => 'u.username_clean ASC',
));
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
$which = (time() - $update_time < $row['online_time'] && ($row['viewonline'] || $auth->acl_get('u_viewonline'))) ? 'online' : 'offline';
$template->assign_block_vars("friends_{$which}", array(
'USER_ID' => $row['user_id'],
'U_PROFILE' => get_username_string('profile', $row['user_id'], $row['username'], $row['user_colour']),
'USER_COLOUR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour']),
'USERNAME' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour']),
'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']))
);
}
$db->sql_freeresult($result);
//end of sql to get online friends
// start of code to allow Only registered users beyond this point
if (!$user->data['is_registered'])
{
if ($user->data['is_bot'])
{
redirect(append_sid("{$phpbb_root_path}index.$phpEx"));
}
login_box('', $user->lang['LOGIN_EXPLAIN_UCP']);
}
// end of code to allow Only registered users beyond this point
page_header('My Friends');
$template->set_filenames(array(
'body' => 'friends_body.html',
));
make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx"));
page_footer();
?>
Code: Select all
<!-- INCLUDE overall_header.html -->
<table class="tablebg" width="100%" cellspacing="1">
<tr>
<th>{L_FRIENDS}</th>
</tr>
<tr>
<td class="row1" align="center">
<b class="genmed" style="color:green">{L_FRIENDS_ONLINE}</b>
<ul class="nav" style="margin: 0; padding: 0; list-style-type: none; line-height: 175%;">
<!-- BEGIN friends_online -->
<li>{friends_online.USERNAME_FULL}
<!-- IF S_SHOW_PM_BOX -->
[ <input class="post" style="font-size: 90%;" type="submit" name="add_to[{friends_online.USER_ID}]" value="{L_ADD}" /> ]
<!-- ENDIF -->
</li>
<!-- BEGINELSE -->
<li>{L_NO_FRIENDS_ONLINE}</li>
<!-- END friends_online -->
</ul>
<hr />
<b class="genmed" style="color:red">{L_FRIENDS_OFFLINE}</b>
<ul class="nav" style="margin: 0; padding: 0; list-style-type: none; line-height: 175%;">
<!-- BEGIN friends_offline -->
<li>{friends_offline.USERNAME_FULL}
<!-- IF S_SHOW_PM_BOX -->
[ <input class="post" style="font-size: 90%;" type="submit" name="add_to[{friends_offline.USER_ID}]" value="{L_ADD}" /> ]
<!-- ENDIF -->
</li>
<!-- BEGINELSE -->
<li>{L_NO_FRIENDS_OFFLINE}</li>
<!-- END friends_offline -->
</ul>
</td>
</tr>
</table>
<br>
<!-- INCLUDE jumpbox.html -->
<!-- INCLUDE overall_footer.html -->
Thanks, i eagerly await your brainwavePPCW2 wrote:ahhh i get it now, maybe a new case in memberlist.php to show friends, some thing like : memberlist.php?mode=friends
i'll dig in to this, but some help from the seniors is appreciated
Any ideas yet?PPCW2 wrote:ahhh i get it now, maybe a new case in memberlist.php to show friends, some thing like : memberlist.php?mode=friends
i'll dig in to this, but some help from the seniors is appreciated
any chance you could develop the 'case' for me as i have not got the foggiest clue when it comes to working with queries. i only have confidence with playing around with templates to get them to look how i like etc.RMcGirr83 wrote:You can also do it by changing the $sql_where variable (would require an additional query on the zebra table).
how would .htaccess give me what i am after? sorry if i sound denseSenky wrote:You can do it by .htaccess...
I don't know probably something like this which should remove the users from the memberlist.rcnutterz wrote:any chance you could develop the 'case' for me as i have not got the foggiest clue when it comes to working with queries. i only have confidence with playing around with templates to get them to look how i like etc.RMcGirr83 wrote:You can also do it by changing the $sql_where variable (would require an additional query on the zebra table).
i would be ever so grateful
Code: Select all
// Sorting and order
Code: Select all
// BEGIN Ignore Foes Mod
if (!$auth->acl_get('a_') || !$auth->acl_getf('m_'))
{
$sql = 'SELECT *
FROM ' . ZEBRA_TABLE . '
WHERE foe <> 0 AND user_id = ' . $user->data['user_id'];
$result = $db->sql_query($sql);
$zebra_foes = array();
while($row = $db->sql_fetchrow($result))
{
$zebra_foes[] = (int) $row['zebra_id'];
}
$db->sql_freeresult($result);
// change the sql parameters to not include foes
if (sizeof($zebra_foes))
{
$zebra_foes = implode(', ', $zebra_foes);
$sql_where .= ' AND ' . $db->sql_in_set('u.user_id', $zebra_foes, true);
}
}
// END Ignore Foes Mod
Thanks for the quick reply,RMcGirr83 wrote:I don't know probably something like this which should remove the users from the memberlist.
OPEN
memberlist.php
FIND
BEFORE ADDCode: Select all
// Sorting and order
I haven't tested it though and the above will only apply if the user viewing the memberlist is not an administrator or a moderator, else foes will still be shown.Code: Select all
// BEGIN Ignore Foes Mod if (!$auth->acl_get('a_') || !$auth->acl_getf('m_')) { $sql = 'SELECT * FROM ' . ZEBRA_TABLE . ' WHERE foe <> 0 AND user_id = ' . $user->data['user_id']; $result = $db->sql_query($sql); $zebra_foes = array(); while($row = $db->sql_fetchrow($result)) { $zebra_foes[] = (int) $row['zebra_id']; } $db->sql_freeresult($result); // change the sql parameters to not include foes if (sizeof($zebra_foes)) { $zebra_foes = implode(', ', $zebra_foes); $sql_where .= ' AND ' . $db->sql_in_set('u.user_id', $zebra_foes, true); } } // END Ignore Foes Mod
Thiswould that only ignore people that are on your foes list?