| 1 |
<?php
|
| 2 |
/**
|
| 3 |
*
|
| 4 |
* @package phpBB3
|
| 5 |
* @version $Id: memberlist.php 9064 2008-11-13 13:04:54Z toonarmy $
|
| 6 |
* @copyright (c) 2005 phpBB Group
|
| 7 |
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
| 8 |
*
|
| 9 |
*/
|
| 10 |
|
| 11 |
/**
|
| 12 |
* @ignore
|
| 13 |
*/
|
| 14 |
define('IN_PHPBB', true);
|
| 15 |
if (!defined('PHPBB_ROOT_PATH')) define('PHPBB_ROOT_PATH', './');
|
| 16 |
if (!defined('PHP_EXT')) define('PHP_EXT', substr(strrchr(__FILE__, '.'), 1));
|
| 17 |
include(PHPBB_ROOT_PATH . 'common.' . PHP_EXT);
|
| 18 |
include(PHPBB_ROOT_PATH . 'includes/functions_display.' . PHP_EXT);
|
| 19 |
|
| 20 |
// Start session management
|
| 21 |
$user->session_begin();
|
| 22 |
$auth->acl($user->data);
|
| 23 |
$user->setup(array('memberlist', 'groups'));
|
| 24 |
|
| 25 |
// Grab data
|
| 26 |
$mode = request_var('mode', '');
|
| 27 |
$action = request_var('action', '');
|
| 28 |
$user_id = request_var('u', ANONYMOUS);
|
| 29 |
$username = request_var('un', '', true);
|
| 30 |
$group_id = request_var('g', 0);
|
| 31 |
$topic_id = request_var('t', 0);
|
| 32 |
|
| 33 |
// Check our mode...
|
| 34 |
if (!in_array($mode, array('', 'group', 'viewprofile', 'email', 'contact', 'searchuser', 'leaders')))
|
| 35 |
{
|
| 36 |
trigger_error('NO_MODE');
|
| 37 |
}
|
| 38 |
|
| 39 |
switch ($mode)
|
| 40 |
{
|
| 41 |
case 'email':
|
| 42 |
break;
|
| 43 |
|
| 44 |
default:
|
| 45 |
// Can this user view profiles/memberlist?
|
| 46 |
if (!$auth->acl_gets('u_viewprofile', 'a_user', 'a_useradd', 'a_userdel'))
|
| 47 |
{
|
| 48 |
if ($user->data['user_id'] != ANONYMOUS)
|
| 49 |
{
|
| 50 |
trigger_error('NO_VIEW_USERS');
|
| 51 |
}
|
| 52 |
|
| 53 |
login_box('', ((isset($user->lang['LOGIN_EXPLAIN_' . strtoupper($mode)])) ? $user->lang['LOGIN_EXPLAIN_' . strtoupper($mode)] : $user->lang['LOGIN_EXPLAIN_MEMBERLIST']));
|
| 54 |
}
|
| 55 |
break;
|
| 56 |
}
|
| 57 |
|
| 58 |
$start = request_var('start', 0);
|
| 59 |
$submit = (isset($_POST['submit'])) ? true : false;
|
| 60 |
|
| 61 |
$default_key = 'c';
|
| 62 |
$sort_key = request_var('sk', $default_key);
|
| 63 |
$sort_dir = request_var('sd', 'a');
|
| 64 |
|
| 65 |
|
| 66 |
// Grab rank information for later
|
| 67 |
$ranks = cache::obtain_ranks();
|
| 68 |
|
| 69 |
|
| 70 |
// What do you want to do today? ... oops, I think that line is taken ...
|
| 71 |
switch ($mode)
|
| 72 |
{
|
| 73 |
case 'leaders':
|
| 74 |
// Display a listing of board admins, moderators
|
| 75 |
include(PHPBB_ROOT_PATH . 'includes/functions_user.' . PHP_EXT);
|
| 76 |
|
| 77 |
$page_title = $user->lang['THE_TEAM'];
|
| 78 |
$template_html = 'memberlist_leaders.html';
|
| 79 |
|
| 80 |
$user_ary = $auth->acl_get_list(false, array('a_', 'm_'), false);
|
| 81 |
|
| 82 |
$admin_id_ary = $global_mod_id_ary = $mod_id_ary = $forum_id_ary = array();
|
| 83 |
foreach ($user_ary as $forum_id => $forum_ary)
|
| 84 |
{
|
| 85 |
foreach ($forum_ary as $auth_option => $id_ary)
|
| 86 |
{
|
| 87 |
if (!$forum_id)
|
| 88 |
{
|
| 89 |
if ($auth_option == 'a_')
|
| 90 |
{
|
| 91 |
$admin_id_ary = array_merge($admin_id_ary, $id_ary);
|
| 92 |
}
|
| 93 |
else
|
| 94 |
{
|
| 95 |
$global_mod_id_ary = array_merge($global_mod_id_ary, $id_ary);
|
| 96 |
}
|
| 97 |
continue;
|
| 98 |
}
|
| 99 |
else
|
| 100 |
{
|
| 101 |
$mod_id_ary = array_merge($mod_id_ary, $id_ary);
|
| 102 |
}
|
| 103 |
|
| 104 |
if ($forum_id)
|
| 105 |
{
|
| 106 |
foreach ($id_ary as $id)
|
| 107 |
{
|
| 108 |
$forum_id_ary[$id][] = $forum_id;
|
| 109 |
}
|
| 110 |
}
|
| 111 |
}
|
| 112 |
}
|
| 113 |
|
| 114 |
$admin_id_ary = array_unique($admin_id_ary);
|
| 115 |
$global_mod_id_ary = array_unique($global_mod_id_ary);
|
| 116 |
|
| 117 |
$mod_id_ary = array_merge($mod_id_ary, $global_mod_id_ary);
|
| 118 |
$mod_id_ary = array_unique($mod_id_ary);
|
| 119 |
|
| 120 |
// Admin group id...
|
| 121 |
$sql = 'SELECT group_id
|
| 122 |
FROM ' . GROUPS_TABLE . "
|
| 123 |
WHERE group_name = 'ADMINISTRATORS'";
|
| 124 |
$result = $db->sql_query($sql);
|
| 125 |
$admin_group_id = (int) $db->sql_fetchfield('group_id');
|
| 126 |
$db->sql_freeresult($result);
|
| 127 |
|
| 128 |
// Get group memberships for the admin id ary...
|
| 129 |
$admin_memberships = group_memberships($admin_group_id, $admin_id_ary);
|
| 130 |
|
| 131 |
$admin_user_ids = array();
|
| 132 |
|
| 133 |
if (!empty($admin_memberships))
|
| 134 |
{
|
| 135 |
// ok, we only need the user ids...
|
| 136 |
foreach ($admin_memberships as $row)
|
| 137 |
{
|
| 138 |
$admin_user_ids[$row['user_id']] = true;
|
| 139 |
}
|
| 140 |
}
|
| 141 |
unset($admin_memberships);
|
| 142 |
|
| 143 |
$sql = 'SELECT forum_id, forum_name
|
| 144 |
FROM ' . FORUMS_TABLE;
|
| 145 |
$result = $db->sql_query($sql);
|
| 146 |
|
| 147 |
$forums = array();
|
| 148 |
while ($row = $db->sql_fetchrow($result))
|
| 149 |
{
|
| 150 |
$forums[$row['forum_id']] = $row['forum_name'];
|
| 151 |
}
|
| 152 |
$db->sql_freeresult($result);
|
| 153 |
|
| 154 |
$sql = $db->sql_build_query('SELECT', array(
|
| 155 |
'SELECT' => 'u.user_id, u.group_id as default_group, u.username, u.username_clean, u.user_colour, u.user_rank, u.user_posts, u.user_allow_pm, g.group_id, g.group_name, g.group_colour, g.group_type, ug.user_id as ug_user_id',
|
| 156 |
|
| 157 |
'FROM' => array(
|
| 158 |
USERS_TABLE => 'u',
|
| 159 |
GROUPS_TABLE => 'g'
|
| 160 |
),
|
| 161 |
|
| 162 |
'LEFT_JOIN' => array(
|
| 163 |
array(
|
| 164 |
'FROM' => array(USER_GROUP_TABLE => 'ug'),
|
| 165 |
'ON' => 'ug.group_id = g.group_id AND ug.user_pending = 0 AND ug.user_id = ' . $user->data['user_id']
|
| 166 |
)
|
| 167 |
),
|
| 168 |
|
| 169 |
'WHERE' => $db->sql_in_set('u.user_id', array_unique(array_merge($admin_id_ary, $mod_id_ary)), false, true) . '
|
| 170 |
AND u.group_id = g.group_id',
|
| 171 |
|
| 172 |
'ORDER_BY' => 'g.group_name ASC, u.username_clean ASC'
|
| 173 |
));
|
| 174 |
$result = $db->sql_query($sql);
|
| 175 |
|
| 176 |
while ($row = $db->sql_fetchrow($result))
|
| 177 |
{
|
| 178 |
$which_row = (in_array($row['user_id'], $admin_id_ary)) ? 'admin' : 'mod';
|
| 179 |
|
| 180 |
// We sort out admins not within the 'Administrators' group.
|
| 181 |
// Else, we will list those as admin only having the permission to view logs for example.
|
| 182 |
if ($which_row == 'admin' && empty($admin_user_ids[$row['user_id']]))
|
| 183 |
{
|
| 184 |
// Remove from admin_id_ary, because the user may be a mod instead
|
| 185 |
unset($admin_id_ary[array_search($row['user_id'], $admin_id_ary)]);
|
| 186 |
|
| 187 |
if (!in_array($row['user_id'], $mod_id_ary) && !in_array($row['user_id'], $global_mod_id_ary))
|
| 188 |
{
|
| 189 |
continue;
|
| 190 |
}
|
| 191 |
else
|
| 192 |
{
|
| 193 |
$which_row = 'mod';
|
| 194 |
}
|
| 195 |
}
|
| 196 |
|
| 197 |
$s_forum_select = '';
|
| 198 |
$undisclosed_forum = false;
|
| 199 |
|
| 200 |
if (isset($forum_id_ary[$row['user_id']]) && !in_array($row['user_id'], $global_mod_id_ary))
|
| 201 |
{
|
| 202 |
if ($which_row == 'mod' && sizeof(array_diff(array_keys($forums), $forum_id_ary[$row['user_id']])))
|
| 203 |
{
|
| 204 |
foreach ($forum_id_ary[$row['user_id']] as $forum_id)
|
| 205 |
{
|
| 206 |
if (isset($forums[$forum_id]))
|
| 207 |
{
|
| 208 |
if ($auth->acl_get('f_list', $forum_id))
|
| 209 |
{
|
| 210 |
$s_forum_select .= '<option value="">' . $forums[$forum_id] . '</option>';
|
| 211 |
}
|
| 212 |
else
|
| 213 |
{
|
| 214 |
$undisclosed_forum = true;
|
| 215 |
}
|
| 216 |
}
|
| 217 |
}
|
| 218 |
}
|
| 219 |
}
|
| 220 |
|
| 221 |
// If the mod is only moderating non-viewable forums we skip the user. There is no gain in displaying the person then...
|
| 222 |
if (!$s_forum_select && $undisclosed_forum)
|
| 223 |
{
|
| 224 |
// $s_forum_select = '<option value="">' . $user->lang['FORUM_UNDISCLOSED'] . '</option>';
|
| 225 |
continue;
|
| 226 |
}
|
| 227 |
|
| 228 |
// The person is moderating several "public" forums, therefore the person should be listed, but not giving the real group name if hidden.
|
| 229 |
if ($row['group_type'] == GROUP_HIDDEN && !$auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel') && $row['ug_user_id'] != $user->data['user_id'])
|
| 230 |
{
|
| 231 |
$group_name = $user->lang['GROUP_UNDISCLOSED'];
|
| 232 |
$u_group = '';
|
| 233 |
}
|
| 234 |
else
|
| 235 |
{
|
| 236 |
$group_name = ($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name'];
|
| 237 |
$u_group = append_sid('memberlist', 'mode=group&g=' . $row['group_id']);
|
| 238 |
}
|
| 239 |
|
| 240 |
$rank_title = $rank_img = '';
|
| 241 |
get_user_rank($row['user_rank'], $row['user_posts'], $rank_title, $rank_img, $rank_img_src);
|
| 242 |
|
| 243 |
$template->assign_block_vars($which_row, array(
|
| 244 |
'USER_ID' => $row['user_id'],
|
| 245 |
'FORUMS' => $s_forum_select,
|
| 246 |
'RANK_TITLE' => $rank_title,
|
| 247 |
'GROUP_NAME' => $group_name,
|
| 248 |
'GROUP_COLOR' => $row['group_colour'],
|
| 249 |
|
| 250 |
'RANK_IMG' => $rank_img,
|
| 251 |
'RANK_IMG_SRC' => $rank_img_src,
|
| 252 |
|
| 253 |
'U_GROUP' => $u_group,
|
| 254 |
'U_PM' => ($config['allow_privmsg'] && $auth->acl_get('u_sendpm') && ($row['user_allow_pm'] || $auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_'))) ? append_sid('ucp', 'i=pm&mode=compose&u=' . $row['user_id']) : '',
|
| 255 |
|
| 256 |
'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']),
|
| 257 |
'USERNAME' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour']),
|
| 258 |
'USER_COLOR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour']),
|
| 259 |
'U_VIEW_PROFILE' => get_username_string('profile', $row['user_id'], $row['username'], $row['user_colour']),
|
| 260 |
));
|
| 261 |
}
|
| 262 |
$db->sql_freeresult($result);
|
| 263 |
|
| 264 |
$template->assign_vars(array(
|
| 265 |
'PM_IMG' => $user->img('icon_contact_pm', $user->lang['SEND_PRIVATE_MESSAGE']))
|
| 266 |
);
|
| 267 |
break;
|
| 268 |
|
| 269 |
case 'contact':
|
| 270 |
|
| 271 |
$page_title = $user->lang['IM_USER'];
|
| 272 |
$template_html = 'memberlist_im.html';
|
| 273 |
|
| 274 |
if (!$auth->acl_get('u_sendim'))
|
| 275 |
{
|
| 276 |
trigger_error('NOT_AUTHORISED');
|
| 277 |
}
|
| 278 |
|
| 279 |
$presence_img = '';
|
| 280 |
switch ($action)
|
| 281 |
{
|
| 282 |
case 'aim':
|
| 283 |
$lang = 'AIM';
|
| 284 |
$sql_field = 'user_aim';
|
| 285 |
$s_select = 'S_SEND_AIM';
|
| 286 |
$s_action = '';
|
| 287 |
break;
|
| 288 |
|
| 289 |
case 'msnm':
|
| 290 |
$lang = 'MSNM';
|
| 291 |
$sql_field = 'user_msnm';
|
| 292 |
$s_select = 'S_SEND_MSNM';
|
| 293 |
$s_action = '';
|
| 294 |
break;
|
| 295 |
|
| 296 |
case 'jabber':
|
| 297 |
$lang = 'JABBER';
|
| 298 |
$sql_field = 'user_jabber';
|
| 299 |
$s_select = (@extension_loaded('xml') && $config['jab_enable']) ? 'S_SEND_JABBER' : 'S_NO_SEND_JABBER';
|
| 300 |
$s_action = append_sid('memberlist', "mode=contact&action=$action&u=$user_id");
|
| 301 |
break;
|
| 302 |
|
| 303 |
default:
|
| 304 |
trigger_error('NO_MODE', E_USER_ERROR);
|
| 305 |
break;
|
| 306 |
}
|
| 307 |
|
| 308 |
// Grab relevant data
|
| 309 |
$sql = "SELECT user_id, username, user_email, user_lang, $sql_field
|
| 310 |
FROM " . USERS_TABLE . "
|
| 311 |
WHERE user_id = $user_id
|
| 312 |
AND user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ')';
|
| 313 |
$result = $db->sql_query($sql);
|
| 314 |
$row = $db->sql_fetchrow($result);
|
| 315 |
$db->sql_freeresult($result);
|
| 316 |
|
| 317 |
if (!$row)
|
| 318 |
{
|
| 319 |
trigger_error('NO_USER');
|
| 320 |
}
|
| 321 |
else if (empty($row[$sql_field]))
|
| 322 |
{
|
| 323 |
trigger_error('IM_NO_DATA');
|
| 324 |
}
|
| 325 |
|
| 326 |
// Post data grab actions
|
| 327 |
switch ($action)
|
| 328 |
{
|
| 329 |
case 'jabber':
|
| 330 |
add_form_key('memberlist_messaging');
|
| 331 |
|
| 332 |
if ($submit && @extension_loaded('xml') && $config['jab_enable'])
|
| 333 |
{
|
| 334 |
if (check_form_key('memberlist_messaging'))
|
| 335 |
{
|
| 336 |
|
| 337 |
include_once(PHPBB_ROOT_PATH . 'includes/functions_messenger.' . PHP_EXT);
|
| 338 |
|
| 339 |
$subject = sprintf($user->lang['IM_JABBER_SUBJECT'], $user->data['username'], $config['server_name']);
|
| 340 |
$message = utf8_normalize_nfc(request_var('message', '', true));
|
| 341 |
|
| 342 |
if (empty($message))
|
| 343 |
{
|
| 344 |
trigger_error('EMPTY_MESSAGE_IM');
|
| 345 |
}
|
| 346 |
|
| 347 |
$messenger = new messenger(false);
|
| 348 |
|
| 349 |
$messenger->template('profile_send_im', $row['user_lang']);
|
| 350 |
$messenger->subject(htmlspecialchars_decode($subject));
|
| 351 |
|
| 352 |
$messenger->replyto($user->data['user_email']);
|
| 353 |
$messenger->im($row['user_jabber'], $row['username']);
|
| 354 |
|
| 355 |
$messenger->assign_vars(array(
|
| 356 |
'BOARD_CONTACT' => $config['board_contact'],
|
| 357 |
'FROM_USERNAME' => htmlspecialchars_decode($user->data['username']),
|
| 358 |
'TO_USERNAME' => htmlspecialchars_decode($row['username']),
|
| 359 |
'MESSAGE' => htmlspecialchars_decode($message))
|
| 360 |
);
|
| 361 |
|
| 362 |
$messenger->send(NOTIFY_IM);
|
| 363 |
|
| 364 |
$s_select = 'S_SENT_JABBER';
|
| 365 |
}
|
| 366 |
else
|
| 367 |
{
|
| 368 |
trigger_error('FORM_INVALID');
|
| 369 |
}
|
| 370 |
}
|
| 371 |
break;
|
| 372 |
}
|
| 373 |
|
| 374 |
// Send vars to the template
|
| 375 |
$template->assign_vars(array(
|
| 376 |
'IM_CONTACT' => $row[$sql_field],
|
| 377 |
'A_IM_CONTACT' => addslashes($row[$sql_field]),
|
| 378 |
|
| 379 |
'U_AIM_CONTACT' => ($action == 'aim') ? 'aim:addbuddy?screenname=' . urlencode($row[$sql_field]) : '',
|
| 380 |
'U_AIM_MESSAGE' => ($action == 'aim') ? 'aim:goim?screenname=' . urlencode($row[$sql_field]) . '&message=' . urlencode($config['sitename']) : '',
|
| 381 |
|
| 382 |
'USERNAME' => $row['username'],
|
| 383 |
'CONTACT_NAME' => $row[$sql_field],
|
| 384 |
'SITENAME' => $config['sitename'],
|
| 385 |
|
| 386 |
'PRESENCE_IMG' => $presence_img,
|
| 387 |
|
| 388 |
'L_SEND_IM_EXPLAIN' => $user->lang['IM_' . $lang],
|
| 389 |
'L_IM_SENT_JABBER' => sprintf($user->lang['IM_SENT_JABBER'], $row['username']),
|
| 390 |
|
| 391 |
$s_select => true,
|
| 392 |
'S_IM_ACTION' => $s_action)
|
| 393 |
);
|
| 394 |
|
| 395 |
break;
|
| 396 |
|
| 397 |
case 'viewprofile':
|
| 398 |
// Display a profile
|
| 399 |
if ($user_id == ANONYMOUS && !$username)
|
| 400 |
{
|
| 401 |
trigger_error('NO_USER');
|
| 402 |
}
|
| 403 |
|
| 404 |
// Get user...
|
| 405 |
$sql = 'SELECT *
|
| 406 |
FROM ' . USERS_TABLE . '
|
| 407 |
WHERE ' . (($username) ? "username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'" : "user_id = $user_id");
|
| 408 |
$result = $db->sql_query($sql);
|
| 409 |
$member = $db->sql_fetchrow($result);
|
| 410 |
$db->sql_freeresult($result);
|
| 411 |
|
| 412 |
if (!$member)
|
| 413 |
{
|
| 414 |
trigger_error('NO_USER');
|
| 415 |
}
|
| 416 |
|
| 417 |
// a_user admins and founder are able to view inactive users and bots to be able to manage them more easily
|
| 418 |
// Normal users are able to see at least users having only changed their profile settings but not yet reactivated.
|
| 419 |
if (!$auth->acl_get('a_user') && $user->data['user_type'] != USER_FOUNDER)
|
| 420 |
{
|
| 421 |
if ($member['user_type'] == USER_IGNORE)
|
| 422 |
{
|
| 423 |
trigger_error('NO_USER');
|
| 424 |
}
|
| 425 |
else if ($member['user_type'] == USER_INACTIVE && $member['user_inactive_reason'] != INACTIVE_PROFILE)
|
| 426 |
{
|
| 427 |
trigger_error('NO_USER');
|
| 428 |
}
|
| 429 |
}
|
| 430 |
|
| 431 |
$user_id = (int) $member['user_id'];
|
| 432 |
|
| 433 |
// Do the SQL thang
|
| 434 |
$sql = 'SELECT g.group_id, g.group_name, g.group_type
|
| 435 |
FROM ' . GROUPS_TABLE . ' g, ' . USER_GROUP_TABLE . " ug
|
| 436 |
WHERE ug.user_id = $user_id
|
| 437 |
AND g.group_id = ug.group_id" . ((!$auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel')) ? ' AND g.group_type <> ' . GROUP_HIDDEN : '') . '
|
| 438 |
AND ug.user_pending = 0
|
| 439 |
ORDER BY g.group_type, g.group_name';
|
| 440 |
$result = $db->sql_query($sql);
|
| 441 |
|
| 442 |
$group_options = '';
|
| 443 |
while ($row = $db->sql_fetchrow($result))
|
| 444 |
{
|
| 445 |
$group_options .= '<option value="' . $row['group_id'] . '"' . (($row['group_id'] == $member['group_id']) ? ' selected="selected"' : '') . '>' . (($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name']) . '</option>';
|
| 446 |
}
|
| 447 |
$db->sql_freeresult($result);
|
| 448 |
|
| 449 |
// What colour is the zebra
|
| 450 |
$sql = 'SELECT friend, foe
|
| 451 |
FROM ' . ZEBRA_TABLE . "
|
| 452 |
WHERE zebra_id = $user_id
|
| 453 |
AND user_id = {$user->data['user_id']}";
|
| 454 |
|
| 455 |
$result = $db->sql_query($sql);
|
| 456 |
$row = $db->sql_fetchrow($result);
|
| 457 |
$foe = ($row['foe']) ? true : false;
|
| 458 |
$friend = ($row['friend']) ? true : false;
|
| 459 |
$db->sql_freeresult($result);
|
| 460 |
|
| 461 |
if ($config['load_onlinetrack'])
|
| 462 |
{
|
| 463 |
$sql = 'SELECT MAX(session_time) AS session_time, MIN(session_viewonline) AS session_viewonline
|
| 464 |
FROM ' . SESSIONS_TABLE . "
|
| 465 |
WHERE session_user_id = $user_id";
|
| 466 |
$result = $db->sql_query($sql);
|
| 467 |
$row = $db->sql_fetchrow($result);
|
| 468 |
$db->sql_freeresult($result);
|
| 469 |
|
| 470 |
$member['session_time'] = (isset($row['session_time'])) ? $row['session_time'] : 0;
|
| 471 |
$member['session_viewonline'] = (isset($row['session_viewonline'])) ? $row['session_viewonline'] : 0;
|
| 472 |
unset($row);
|
| 473 |
}
|
| 474 |
|
| 475 |
if ($config['load_user_activity'])
|
| 476 |
{
|
| 477 |
display_user_activity($member);
|
| 478 |
}
|
| 479 |
|
| 480 |
// Do the relevant calculations
|
| 481 |
$memberdays = max(1, round((time() - $member['user_regdate']) / 86400));
|
| 482 |
$posts_per_day = $member['user_posts'] / $memberdays;
|
| 483 |
$percentage = ($config['num_posts']) ? min(100, ($member['user_posts'] / $config['num_posts']) * 100) : 0;
|
| 484 |
|
| 485 |
|
| 486 |
if ($member['user_sig'])
|
| 487 |
{
|
| 488 |
$member['user_sig'] = censor_text($member['user_sig']);
|
| 489 |
|
| 490 |
if ($member['user_sig_bbcode_bitfield'])
|
| 491 |
{
|
| 492 |
include_once(PHPBB_ROOT_PATH . 'includes/bbcode.' . PHP_EXT);
|
| 493 |
$bbcode = new bbcode();
|
| 494 |
$bbcode->bbcode_second_pass($member['user_sig'], $member['user_sig_bbcode_uid'], $member['user_sig_bbcode_bitfield']);
|
| 495 |
}
|
| 496 |
|
| 497 |
$member['user_sig'] = bbcode_nl2br($member['user_sig']);
|
| 498 |
$member['user_sig'] = smiley_text($member['user_sig']);
|
| 499 |
}
|
| 500 |
|
| 501 |
$poster_avatar = get_user_avatar($member['user_avatar'], $member['user_avatar_type'], $member['user_avatar_width'], $member['user_avatar_height']);
|
| 502 |
|
| 503 |
$template->assign_vars(show_profile($member));
|
| 504 |
|
| 505 |
// Custom Profile Fields
|
| 506 |
$profile_fields = array();
|
| 507 |
if ($config['load_cpf_viewprofile'])
|
| 508 |
{
|
| 509 |
include_once(PHPBB_ROOT_PATH . 'includes/functions_profile_fields.' . PHP_EXT);
|
| 510 |
$cp = new custom_profile();
|
| 511 |
$profile_fields = $cp->generate_profile_fields_template('grab', $user_id);
|
| 512 |
$profile_fields = (isset($profile_fields[$user_id])) ? $cp->generate_profile_fields_template('show', false, $profile_fields[$user_id]) : array();
|
| 513 |
}
|
| 514 |
|
| 515 |
// We need to check if the module 'zebra' is accessible
|
| 516 |
$zebra_enabled = false;
|
| 517 |
|
| 518 |
if ($user->data['user_id'] != $user_id && $user->data['is_registered'])
|
| 519 |
{
|
| 520 |
include_once(PHPBB_ROOT_PATH . 'includes/functions_module.' . PHP_EXT);
|
| 521 |
$module = new p_master();
|
| 522 |
$module->list_modules('ucp');
|
| 523 |
$module->set_active('zebra');
|
| 524 |
|
| 525 |
$zebra_enabled = ($module->active_module === false) ? false : true;
|
| 526 |
|
| 527 |
unset($module);
|
| 528 |
}
|
| 529 |
|
| 530 |
// If the user has m_approve permission or a_user permission, then list then display unapproved posts
|
| 531 |
if ($auth->acl_getf_global('m_approve') || $auth->acl_get('a_user'))
|
| 532 |
{
|
| 533 |
$sql = 'SELECT COUNT(post_id) as posts_in_queue
|
| 534 |
FROM ' . POSTS_TABLE . '
|
| 535 |
WHERE poster_id = ' . $user_id . '
|
| 536 |
AND post_approved = 0';
|
| 537 |
$result = $db->sql_query($sql);
|
| 538 |
$member['posts_in_queue'] = (int) $db->sql_fetchfield('posts_in_queue');
|
| 539 |
$db->sql_freeresult($result);
|
| 540 |
}
|
| 541 |
else
|
| 542 |
{
|
| 543 |
$member['posts_in_queue'] = 0;
|
| 544 |
}
|
| 545 |
|
| 546 |
$template->assign_vars(array(
|
| 547 |
'L_POSTS_IN_QUEUE' => $user->lang('NUM_POSTS_IN_QUEUE', $member['posts_in_queue']),
|
| 548 |
|
| 549 |
'POSTS_DAY' => sprintf($user->lang['POST_DAY'], $posts_per_day),
|
| 550 |
'POSTS_PCT' => sprintf($user->lang['POST_PCT'], $percentage),
|
| 551 |
|
| 552 |
'OCCUPATION' => (!empty($member['user_occ'])) ? censor_text($member['user_occ']) : '',
|
| 553 |
'INTERESTS' => (!empty($member['user_interests'])) ? censor_text($member['user_interests']) : '',
|
| 554 |
'SIGNATURE' => $member['user_sig'],
|
| 555 |
'POSTS_IN_QUEUE'=> $member['posts_in_queue'],
|
| 556 |
|
| 557 |
'AVATAR_IMG' => $poster_avatar,
|
| 558 |
'PM_IMG' => $user->img('icon_contact_pm', $user->lang['SEND_PRIVATE_MESSAGE']),
|
| 559 |
'EMAIL_IMG' => $user->img('icon_contact_email', $user->lang['EMAIL']),
|
| 560 |
'WWW_IMG' => $user->img('icon_contact_www', $user->lang['WWW']),
|
| 561 |
'ICQ_IMG' => $user->img('icon_contact_icq', $user->lang['ICQ']),
|
| 562 |
'AIM_IMG' => $user->img('icon_contact_aim', $user->lang['AIM']),
|
| 563 |
'MSN_IMG' => $user->img('icon_contact_msnm', $user->lang['MSNM']),
|
| 564 |
'YIM_IMG' => $user->img('icon_contact_yahoo', $user->lang['YIM']),
|
| 565 |
'JABBER_IMG' => $user->img('icon_contact_jabber', $user->lang['JABBER']),
|
| 566 |
'SEARCH_IMG' => $user->img('icon_user_search', $user->lang['SEARCH']),
|
| 567 |
|
| 568 |
'S_PROFILE_ACTION' => append_sid('memberlist', 'mode=group'),
|
| 569 |
'S_GROUP_OPTIONS' => $group_options,
|
| 570 |
'S_CUSTOM_FIELDS' => (isset($profile_fields['row']) && sizeof($profile_fields['row'])) ? true : false,
|
| 571 |
|
| 572 |
'U_USER_ADMIN' => ($auth->acl_get('a_user')) ? append_sid(CONFIG_ADM_FOLDER . '/index', 'i=users&mode=overview&u=' . $user_id, true, $user->session_id) : '',
|
| 573 |
'U_USER_BAN' => ($auth->acl_get('m_ban')) ? append_sid('mcp', 'i=ban&mode=user&u=' . $user_id, true, $user->session_id) : '',
|
| 574 |
'U_SWITCH_PERMISSIONS' => ($auth->acl_get('a_switchperm') && $user->data['user_id'] != $user_id) ? append_sid('ucp', "mode=switch_perm&u={$user_id}") : '',
|
| 575 |
'U_MCP_QUEUE' => ($auth->acl_getf_global('m_approve')) ? append_sid('mcp', 'i=queue', true, $user->session_id) : '',
|
| 576 |
|
| 577 |
'S_ZEBRA' => ($user->data['user_id'] != $user_id && $user->data['is_registered'] && $zebra_enabled) ? true : false,
|
| 578 |
'U_ADD_FRIEND' => (!$friend) ? append_sid('ucp', 'i=zebra&add=' . urlencode(htmlspecialchars_decode($member['username']))) : '',
|
| 579 |
'U_ADD_FOE' => (!$foe) ? append_sid('ucp', 'i=zebra&mode=foes&add=' . urlencode(htmlspecialchars_decode($member['username']))) : '',
|
| 580 |
'U_REMOVE_FRIEND' => ($friend) ? append_sid('ucp', 'i=zebra&remove=1&usernames[]=' . $user_id) : '',
|
| 581 |
'U_REMOVE_FOE' => ($foe) ? append_sid('ucp', 'i=zebra&remove=1&mode=foes&usernames[]=' . $user_id) : '',
|
| 582 |
));
|
| 583 |
|
| 584 |
if (!empty($profile_fields['row']))
|
| 585 |
{
|
| 586 |
$template->assign_vars($profile_fields['row']);
|
| 587 |
}
|
| 588 |
|
| 589 |
if (!empty($profile_fields['blockrow']))
|
| 590 |
{
|
| 591 |
foreach ($profile_fields['blockrow'] as $field_data)
|
| 592 |
{
|
| 593 |
$template->assign_block_vars('custom_fields', $field_data);
|
| 594 |
}
|
| 595 |
}
|
| 596 |
|
| 597 |
// Inactive reason/account?
|
| 598 |
if ($member['user_type'] == USER_INACTIVE)
|
| 599 |
{
|
| 600 |
$user->add_lang('acp/common');
|
| 601 |
|
| 602 |
$inactive_reason = $user->lang['INACTIVE_REASON_UNKNOWN'];
|
| 603 |
|
| 604 |
switch ($member['user_inactive_reason'])
|
| 605 |
{
|
| 606 |
case INACTIVE_REGISTER:
|
| 607 |
$inactive_reason = $user->lang['INACTIVE_REASON_REGISTER'];
|
| 608 |
break;
|
| 609 |
|
| 610 |
case INACTIVE_PROFILE:
|
| 611 |
$inactive_reason = $user->lang['INACTIVE_REASON_PROFILE'];
|
| 612 |
break;
|
| 613 |
|
| 614 |
case INACTIVE_MANUAL:
|
| 615 |
$inactive_reason = $user->lang['INACTIVE_REASON_MANUAL'];
|
| 616 |
break;
|
| 617 |
|
| 618 |
case INACTIVE_REMIND:
|
| 619 |
$inactive_reason = $user->lang['INACTIVE_REASON_REMIND'];
|
| 620 |
break;
|
| 621 |
}
|
| 622 |
|
| 623 |
$template->assign_vars(array(
|
| 624 |
'S_USER_INACTIVE' => true,
|
| 625 |
'USER_INACTIVE_REASON' => $inactive_reason)
|
| 626 |
);
|
| 627 |
}
|
| 628 |
|
| 629 |
// Now generate page title
|
| 630 |
$page_title = sprintf($user->lang['VIEWING_PROFILE'], $member['username']);
|
| 631 |
$template_html = 'memberlist_view.html';
|
| 632 |
|
| 633 |
break;
|
| 634 |
|
| 635 |
case 'email':
|
| 636 |
|
| 637 |
// Send an email
|
| 638 |
$page_title = $user->lang['SEND_EMAIL'];
|
| 639 |
$template_html = 'memberlist_email.html';
|
| 640 |
|
| 641 |
add_form_key('memberlist_email');
|
| 642 |
|
| 643 |
if (!$config['email_enable'])
|
| 644 |
{
|
| 645 |
trigger_error('EMAIL_DISABLED');
|
| 646 |
}
|
| 647 |
|
| 648 |
if (!$auth->acl_get('u_sendemail'))
|
| 649 |
{
|
| 650 |
trigger_error('NO_EMAIL');
|
| 651 |
}
|
| 652 |
|
| 653 |
// Are we trying to abuse the facility?
|
| 654 |
if (time() - $user->data['user_emailtime'] < $config['flood_interval'])
|
| 655 |
{
|
| 656 |
trigger_error('FLOOD_EMAIL_LIMIT');
|
| 657 |
}
|
| 658 |
|
| 659 |
// Determine action...
|
| 660 |
$user_id = request_var('u', 0);
|
| 661 |
$topic_id = request_var('t', 0);
|
| 662 |
|
| 663 |
// Send email to user...
|
| 664 |
if ($user_id)
|
| 665 |
{
|
| 666 |
if ($user_id == ANONYMOUS || !$config['board_email_form'])
|
| 667 |
{
|
| 668 |
trigger_error('NO_EMAIL');
|
| 669 |
}
|
| 670 |
|
| 671 |
// Get the appropriate username, etc.
|
| 672 |
$sql = 'SELECT username, user_email, user_allow_viewemail, user_lang, user_jabber, user_notify_type
|
| 673 |
FROM ' . USERS_TABLE . "
|
| 674 |
WHERE user_id = $user_id
|
| 675 |
AND user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ')';
|
| 676 |
$result = $db->sql_query($sql);
|
| 677 |
$row = $db->sql_fetchrow($result);
|
| 678 |
$db->sql_freeresult($result);
|
| 679 |
|
| 680 |
if (!$row)
|
| 681 |
{
|
| 682 |
trigger_error('NO_USER');
|
| 683 |
}
|
| 684 |
|
| 685 |
// Can we send email to this user?
|
| 686 |
if (!$row['user_allow_viewemail'] && !$auth->acl_get('a_user'))
|
| 687 |
{
|
| 688 |
trigger_error('NO_EMAIL');
|
| 689 |
}
|
| 690 |
}
|
| 691 |
else if ($topic_id)
|
| 692 |
{
|
| 693 |
// Send topic heads-up to email address
|
| 694 |
$sql = 'SELECT forum_id, topic_title
|
| 695 |
FROM ' . TOPICS_TABLE . "
|
| 696 |
WHERE topic_id = $topic_id";
|
| 697 |
$result = $db->sql_query($sql);
|
| 698 |
$row = $db->sql_fetchrow($result);
|
| 699 |
$db->sql_freeresult($result);
|
| 700 |
|
| 701 |
if (!$row)
|
| 702 |
{
|
| 703 |
trigger_error('NO_TOPIC');
|
| 704 |
}
|
| 705 |
|
| 706 |
if ($row['forum_id'])
|
| 707 |
{
|
| 708 |
if (!$auth->acl_get('f_read', $row['forum_id']))
|
| 709 |
{
|
| 710 |
trigger_error('SORRY_AUTH_READ');
|
| 711 |
}
|
| 712 |
|
| 713 |
if (!$auth->acl_get('f_email', $row['forum_id']))
|
| 714 |
{
|
| 715 |
trigger_error('NO_EMAIL');
|
| 716 |
}
|
| 717 |
}
|
| 718 |
else
|
| 719 |
{
|
| 720 |
// If global announcement, we need to check if the user is able to at least read and email in one forum...
|
| 721 |
if (!$auth->acl_getf_global('f_read'))
|
| 722 |
{
|
| 723 |
trigger_error('SORRY_AUTH_READ');
|
| 724 |
}
|
| 725 |
|
| 726 |
if (!$auth->acl_getf_global('f_email'))
|
| 727 |
{
|
| 728 |
trigger_error('NO_EMAIL');
|
| 729 |
}
|
| 730 |
}
|
| 731 |
}
|
| 732 |
else
|
| 733 |
{
|
| 734 |
trigger_error('NO_EMAIL');
|
| 735 |
}
|
| 736 |
|
| 737 |
$error = array();
|
| 738 |
|
| 739 |
$name = utf8_normalize_nfc(request_var('name', '', true));
|
| 740 |
$email = request_var('email', '');
|
| 741 |
$email_lang = request_var('lang', $config['default_lang']);
|
| 742 |
$subject = utf8_normalize_nfc(request_var('subject', '', true));
|
| 743 |
$message = utf8_normalize_nfc(request_var('message', '', true));
|
| 744 |
$cc = (isset($_POST['cc_email'])) ? true : false;
|
| 745 |
$submit = (isset($_POST['submit'])) ? true : false;
|
| 746 |
|
| 747 |
if ($submit)
|
| 748 |
{
|
| 749 |
if (!check_form_key('memberlist_email'))
|
| 750 |
{
|
| 751 |
$error[] = 'FORM_INVALID';
|
| 752 |
}
|
| 753 |
if ($user_id)
|
| 754 |
{
|
| 755 |
if (!$subject)
|
| 756 |
{
|
| 757 |
$error[] = $user->lang['EMPTY_SUBJECT_EMAIL'];
|
| 758 |
}
|
| 759 |
|
| 760 |
if (!$message)
|
| 761 |
{
|
| 762 |
$error[] = $user->lang['EMPTY_MESSAGE_EMAIL'];
|
| 763 |
}
|
| 764 |
|
| 765 |
$name = $row['username'];
|
| 766 |
$email_lang = $row['user_lang'];
|
| 767 |
$email = $row['user_email'];
|
| 768 |
}
|
| 769 |
else
|
| 770 |
{
|
| 771 |
if (!$email || !preg_match('/^' . get_preg_expression('email') . '$/i', $email))
|
| 772 |
{
|
| 773 |
$error[] = $user->lang['EMPTY_ADDRESS_EMAIL'];
|
| 774 |
}
|
| 775 |
|
| 776 |
if (!$name)
|
| 777 |
{
|
| 778 |
$error[] = $user->lang['EMPTY_NAME_EMAIL'];
|
| 779 |
}
|
| 780 |
}
|
| 781 |
|
| 782 |
if (!sizeof($error))
|
| 783 |
{
|
| 784 |
$sql = 'UPDATE ' . USERS_TABLE . '
|
| 785 |
SET user_emailtime = ' . time() . '
|
| 786 |
WHERE user_id = ' . $user->data['user_id'];
|
| 787 |
$result = $db->sql_query($sql);
|
| 788 |
|
| 789 |
include_once(PHPBB_ROOT_PATH . 'includes/functions_messenger.' . PHP_EXT);
|
| 790 |
$messenger = new messenger(false);
|
| 791 |
$email_tpl = ($user_id) ? 'profile_send_email' : 'email_notify';
|
| 792 |
|
| 793 |
$mail_to_users = array();
|
| 794 |
|
| 795 |
$mail_to_users[] = array(
|
| 796 |
'email_lang' => $email_lang,
|
| 797 |
'email' => $email,
|
| 798 |
'name' => $name,
|
| 799 |
'username' => ($user_id) ? $row['username'] : '',
|
| 800 |
'to_name' => $name,
|
| 801 |
'user_jabber' => ($user_id) ? $row['user_jabber'] : '',
|
| 802 |
'user_notify_type' => ($user_id) ? $row['user_notify_type'] : NOTIFY_EMAIL,
|
| 803 |
'topic_title' => (!$user_id) ? $row['topic_title'] : '',
|
| 804 |
'forum_id' => (!$user_id) ? $row['forum_id'] : 0,
|
| 805 |
);
|
| 806 |
|
| 807 |
// Ok, now the same email if CC specified, but without exposing the users email address
|
| 808 |
if ($cc)
|
| 809 |
{
|
| 810 |
$mail_to_users[] = array(
|
| 811 |
'email_lang' => $user->data['user_lang'],
|
| 812 |
'email' => $user->data['user_email'],
|
| 813 |
'name' => $user->data['username'],
|
| 814 |
'username' => $user->data['username'],
|
| 815 |
'to_name' => $name,
|
| 816 |
'user_jabber' => $user->data['user_jabber'],
|
| 817 |
'user_notify_type' => ($user_id) ? $user->data['user_notify_type'] : NOTIFY_EMAIL,
|
| 818 |
'topic_title' => (!$user_id) ? $row['topic_title'] : '',
|
| 819 |
'forum_id' => (!$user_id) ? $row['forum_id'] : 0,
|
| 820 |
);
|
| 821 |
}
|
| 822 |
|
| 823 |
foreach ($mail_to_users as $row)
|
| 824 |
{
|
| 825 |
$messenger->template($email_tpl, $row['email_lang']);
|
| 826 |
$messenger->replyto($user->data['user_email']);
|
| 827 |
$messenger->to($row['email'], $row['name']);
|
| 828 |
|
| 829 |
if ($user_id)
|
| 830 |
{
|
| 831 |
$messenger->subject(htmlspecialchars_decode($subject));
|
| 832 |
$messenger->im($row['user_jabber'], $row['username']);
|
| 833 |
$notify_type = $row['user_notify_type'];
|
| 834 |
}
|
| 835 |
else
|
| 836 |
{
|
| 837 |
$notify_type = NOTIFY_EMAIL;
|
| 838 |
}
|
| 839 |
|
| 840 |
$messenger->headers('X-AntiAbuse: Board servername - ' . $config['server_name']);
|
| 841 |
$messenger->headers('X-AntiAbuse: User_id - ' . $user->data['user_id']);
|
| 842 |
$messenger->headers('X-AntiAbuse: Username - ' . $user->data['username']);
|
| 843 |
$messenger->headers('X-AntiAbuse: User IP - ' . $user->ip);
|
| 844 |
|
| 845 |
$messenger->assign_vars(array(
|
| 846 |
'BOARD_CONTACT' => $config['board_contact'],
|
| 847 |
'TO_USERNAME' => htmlspecialchars_decode($row['to_name']),
|
| 848 |
'FROM_USERNAME' => htmlspecialchars_decode($user->data['username']),
|
| 849 |
'MESSAGE' => htmlspecialchars_decode($message))
|
| 850 |
);
|
| 851 |
|
| 852 |
if ($topic_id)
|
| 853 |
{
|
| 854 |
$messenger->assign_vars(array(
|
| 855 |
'TOPIC_NAME' => htmlspecialchars_decode($row['topic_title']),
|
| 856 |
'U_TOPIC' => generate_board_url() . '/viewtopic.' . PHP_EXT . '?f=' . $row['forum_id'] . "&t=$topic_id")
|
| 857 |
);
|
| 858 |
}
|
| 859 |
|
| 860 |
$messenger->send($notify_type);
|
| 861 |
}
|
| 862 |
|
| 863 |
meta_refresh(3, append_sid('index'));
|
| 864 |
$message = ($user_id) ? sprintf($user->lang['RETURN_INDEX'], '<a href="' . append_sid('index') . '">', '</a>') : sprintf($user->lang['RETURN_TOPIC'], '<a href="' . append_sid('viewtopic', "f={$row['forum_id']}&t=$topic_id") . '">', '</a>');
|
| 865 |
trigger_error($user->lang['EMAIL_SENT'] . '<br /><br />' . $message);
|
| 866 |
}
|
| 867 |
}
|
| 868 |
|
| 869 |
if ($user_id)
|
| 870 |
{
|
| 871 |
$template->assign_vars(array(
|
| 872 |
'S_SEND_USER' => true,
|
| 873 |
'USERNAME' => $row['username'],
|
| 874 |
|
| 875 |
'L_EMAIL_BODY_EXPLAIN' => $user->lang['EMAIL_BODY_EXPLAIN'],
|
| 876 |
'S_POST_ACTION' => append_sid('memberlist', 'mode=email&u=' . $user_id))
|
| 877 |
);
|
| 878 |
}
|
| 879 |
else
|
| 880 |
{
|
| 881 |
$template->assign_vars(array(
|
| 882 |
'EMAIL' => $email,
|
| 883 |
'NAME' => $name,
|
| 884 |
'S_LANG_OPTIONS' => language_select($email_lang),
|
| 885 |
|
| 886 |
'L_EMAIL_BODY_EXPLAIN' => $user->lang['EMAIL_TOPIC_EXPLAIN'],
|
| 887 |
'S_POST_ACTION' => append_sid('memberlist', 'mode=email&t=' . $topic_id))
|
| 888 |
);
|
| 889 |
}
|
| 890 |
|
| 891 |
$template->assign_vars(array(
|
| 892 |
'ERROR_MESSAGE' => (sizeof($error)) ? implode('<br />', $error) : '')
|
| 893 |
);
|
| 894 |
|