Verzeichnisstruktur phpBB-3.0.0


Veröffentlicht
12.12.2007

So funktioniert es


Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück

Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

(Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

memberlist.php

Zuletzt modifiziert: 09.10.2024, 12:50 - Dateigröße: 54.69 KiB


0001  <?php
0002  /**
0003  *
0004  * @package phpBB3
0005  * @version $Id$
0006  * @copyright (c) 2005 phpBB Group
0007  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
0008  *
0009  */
0010   
0011  /**
0012  * @ignore
0013  */
0014  define('IN_PHPBB', true);
0015  $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
0016  $phpEx = substr(strrchr(__FILE__, '.'), 1);
0017  include($phpbb_root_path . 'common.' . $phpEx);
0018  include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
0019   
0020  // Start session management
0021  $user->session_begin();
0022  $auth->acl($user->data);
0023  $user->setup(array('memberlist', 'groups'));
0024   
0025  // Grab data
0026  $mode        = request_var('mode', '');
0027  $action        = request_var('action', '');
0028  $user_id    = request_var('u', ANONYMOUS);
0029  $username    = request_var('un', '', true);
0030  $group_id    = request_var('g', 0);
0031  $topic_id    = request_var('t', 0);
0032   
0033  // Check our mode...
0034  if (!in_array($mode, array('', 'group', 'viewprofile', 'email', 'contact', 'searchuser', 'leaders')))
0035  {
0036      trigger_error('NO_MODE');
0037  }
0038   
0039  switch ($mode)
0040  {
0041      case 'email':
0042      break;
0043   
0044      default:
0045          // Can this user view profiles/memberlist?
0046          if (!$auth->acl_gets('u_viewprofile', 'a_user', 'a_useradd', 'a_userdel'))
0047          {
0048              if ($user->data['user_id'] != ANONYMOUS)
0049              {
0050                  trigger_error('NO_VIEW_USERS');
0051              }
0052   
0053              login_box('', ((isset($user->lang['LOGIN_EXPLAIN_' . strtoupper($mode)])) ? $user->lang['LOGIN_EXPLAIN_' . strtoupper($mode)] : $user->lang['LOGIN_EXPLAIN_MEMBERLIST']));
0054          }
0055      break;
0056  }
0057   
0058  $start    = request_var('start', 0);
0059  $submit = (isset($_POST['submit'])) ? true : false;
0060   
0061  $default_key = 'c';
0062  $sort_key = request_var('sk', $default_key);
0063  $sort_dir = request_var('sd', 'a');
0064   
0065   
0066  // Grab rank information for later
0067  $ranks = $cache->obtain_ranks();
0068   
0069   
0070  // What do you want to do today? ... oops, I think that line is taken ...
0071  switch ($mode)
0072  {
0073      case 'leaders':
0074          // Display a listing of board admins, moderators
0075          include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
0076   
0077          $page_title = $user->lang['THE_TEAM'];
0078          $template_html = 'memberlist_leaders.html';
0079   
0080          $user_ary = $auth->acl_get_list(false, array('a_', 'm_'), false);
0081   
0082          $admin_id_ary = $global_mod_id_ary = $mod_id_ary = $forum_id_ary = array();
0083          foreach ($user_ary as $forum_id => $forum_ary)
0084          {
0085              foreach ($forum_ary as $auth_option => $id_ary)
0086              {
0087                  if (!$forum_id)
0088                  {
0089                      if ($auth_option == 'a_')
0090                      {
0091                          $admin_id_ary = array_merge($admin_id_ary, $id_ary);
0092                      }
0093                      else
0094                      {
0095                          $global_mod_id_ary = array_merge($global_mod_id_ary, $id_ary);
0096                      }
0097                      continue;
0098                  }
0099                  else
0100                  {
0101                      $mod_id_ary = array_merge($mod_id_ary, $id_ary);
0102                  }
0103   
0104                  if ($forum_id)
0105                  {
0106                      foreach ($id_ary as $id)
0107                      {
0108                          $forum_id_ary[$id][] = $forum_id;
0109                      }
0110                  }
0111              }
0112          }
0113   
0114          $admin_id_ary = array_unique($admin_id_ary);
0115          $global_mod_id_ary = array_unique($global_mod_id_ary);
0116   
0117          $mod_id_ary = array_merge($mod_id_ary, $global_mod_id_ary);
0118          $mod_id_ary = array_unique($mod_id_ary);
0119   
0120          // Admin group id...
0121          $sql = 'SELECT group_id
0122              FROM ' . GROUPS_TABLE . "
0123              WHERE group_name = 'ADMINISTRATORS'";
0124          $result = $db->sql_query($sql);
0125          $admin_group_id = (int) $db->sql_fetchfield('group_id');
0126          $db->sql_freeresult($result);
0127   
0128          // Get group memberships for the admin id ary...
0129          $admin_memberships = group_memberships($admin_group_id, $admin_id_ary);
0130   
0131          $admin_user_ids = array();
0132          
0133          if (!empty($admin_memberships))
0134          {
0135              // ok, we only need the user ids...
0136              foreach ($admin_memberships as $row)
0137              {
0138                  $admin_user_ids[$row['user_id']] = true;
0139              }
0140          }
0141          unset($admin_memberships);
0142   
0143          $sql = 'SELECT forum_id, forum_name
0144              FROM ' . FORUMS_TABLE . '
0145              WHERE forum_type = ' . FORUM_POST;
0146          $result = $db->sql_query($sql);
0147          
0148          $forums = array();
0149          while ($row = $db->sql_fetchrow($result))
0150          {
0151              $forums[$row['forum_id']] = $row['forum_name'];
0152          }
0153          $db->sql_freeresult($result);
0154   
0155          $sql = $db->sql_build_query('SELECT', array(
0156              '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',
0157   
0158              'FROM'        => array(
0159                  USERS_TABLE        => 'u',
0160                  GROUPS_TABLE    => 'g'
0161              ),
0162   
0163              'LEFT_JOIN'    => array(
0164                  array(
0165                      'FROM'    => array(USER_GROUP_TABLE => 'ug'),
0166                      'ON'    => 'ug.group_id = g.group_id AND ug.user_pending = 0 AND ug.user_id = ' . $user->data['user_id']
0167                  )
0168              ),
0169   
0170              'WHERE'        => $db->sql_in_set('u.user_id', array_unique(array_merge($admin_id_ary, $mod_id_ary)), false, true) . '
0171                  AND u.group_id = g.group_id',
0172   
0173              'ORDER_BY'    => 'g.group_name ASC, u.username_clean ASC'
0174          ));
0175          $result = $db->sql_query($sql);
0176   
0177          while ($row = $db->sql_fetchrow($result))
0178          {
0179              $which_row = (in_array($row['user_id'], $admin_id_ary)) ? 'admin' : 'mod';
0180   
0181              // We sort out admins not within the 'Administrators' group.
0182              // Else, we will list those as admin only having the permission to view logs for example.
0183              if ($which_row == 'admin' && empty($admin_user_ids[$row['user_id']]))
0184              {
0185                  // Remove from admin_id_ary, because the user may be a mod instead
0186                  unset($admin_id_ary[array_search($row['user_id'], $admin_id_ary)]);
0187   
0188                  if (!in_array($row['user_id'], $mod_id_ary) && !in_array($row['user_id'], $global_mod_id_ary))
0189                  {
0190                      continue;
0191                  }
0192                  else
0193                  {
0194                      $which_row = 'mod';
0195                  }
0196              }
0197   
0198              $s_forum_select = '';
0199              $undisclosed_forum = false;
0200   
0201              if (isset($forum_id_ary[$row['user_id']]) && !in_array($row['user_id'], $global_mod_id_ary))
0202              {
0203                  if ($which_row == 'mod' && sizeof(array_diff(array_keys($forums), $forum_id_ary[$row['user_id']])))
0204                  {
0205                      foreach ($forum_id_ary[$row['user_id']] as $forum_id)
0206                      {
0207                          if (isset($forums[$forum_id]))
0208                          {
0209                              if ($auth->acl_get('f_list', $forum_id))
0210                              {
0211                                  $s_forum_select .= '<option value="">' . $forums[$forum_id] . '</option>';
0212                              }
0213                              else
0214                              {
0215                                  $undisclosed_forum = true;
0216                              }
0217                          }
0218                      }
0219                  }
0220              }
0221   
0222              // If the mod is only moderating non-viewable forums we skip the user. There is no gain in displaying the person then...
0223              if (!$s_forum_select && $undisclosed_forum)
0224              {
0225  //                $s_forum_select = '<option value="">' . $user->lang['FORUM_UNDISCLOSED'] . '</option>';
0226                  continue;
0227              }
0228   
0229              // The person is moderating several "public" forums, therefore the person should be listed, but not giving the real group name if hidden.
0230              if ($row['group_type'] == GROUP_HIDDEN && !$auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel') && $row['ug_user_id'] != $user->data['user_id'])
0231              {
0232                  $group_name = $user->lang['GROUP_UNDISCLOSED'];
0233                  $u_group = '';
0234              }
0235              else
0236              {
0237                  $group_name = ($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name'];
0238                  $u_group = append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&amp;g=' . $row['group_id']);
0239              }
0240   
0241              $rank_title = $rank_img = '';
0242              get_user_rank($row['user_rank'], $row['user_posts'], $rank_title, $rank_img, $rank_img_src);
0243   
0244              $template->assign_block_vars($which_row, array(
0245                  'USER_ID'        => $row['user_id'],
0246                  'FORUMS'        => $s_forum_select,
0247                  'RANK_TITLE'    => $rank_title,
0248                  'GROUP_NAME'    => $group_name,
0249                  'GROUP_COLOR'    => $row['group_colour'],
0250   
0251                  'RANK_IMG'        => $rank_img,
0252                  'RANK_IMG_SRC'    => $rank_img_src,
0253   
0254                  'U_GROUP'            => $u_group,
0255                  '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("{$phpbb_root_path}ucp.$phpEx", 'i=pm&amp;mode=compose&amp;u=' . $row['user_id']) : '',
0256   
0257                  'USERNAME_FULL'        => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']),
0258                  'USERNAME'            => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour']),
0259                  'USER_COLOR'        => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour']),
0260                  'U_VIEW_PROFILE'    => get_username_string('profile', $row['user_id'], $row['username'], $row['user_colour']),
0261              ));
0262          }
0263          $db->sql_freeresult($result);
0264   
0265          $template->assign_vars(array(
0266              'PM_IMG'        => $user->img('icon_contact_pm', $user->lang['SEND_PRIVATE_MESSAGE']))
0267          );
0268      break;
0269   
0270      case 'contact':
0271   
0272          $page_title = $user->lang['IM_USER'];
0273          $template_html = 'memberlist_im.html';
0274   
0275          if (!$auth->acl_get('u_sendim'))
0276          {
0277              trigger_error('NOT_AUTHORISED');
0278          }
0279   
0280          $presence_img = '';
0281          switch ($action)
0282          {
0283              case 'aim':
0284                  $lang = 'AIM';
0285                  $sql_field = 'user_aim';
0286                  $s_select = 'S_SEND_AIM';
0287                  $s_action = '';
0288              break;
0289   
0290              case 'msnm':
0291                  $lang = 'MSNM';
0292                  $sql_field = 'user_msnm';
0293                  $s_select = 'S_SEND_MSNM';
0294                  $s_action = '';
0295              break;
0296   
0297              case 'jabber':
0298                  $lang = 'JABBER';
0299                  $sql_field = 'user_jabber';
0300                  $s_select = (@extension_loaded('xml') && $config['jab_enable']) ? 'S_SEND_JABBER' : 'S_NO_SEND_JABBER';
0301                  $s_action = append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=contact&amp;action=$action&amp;u=$user_id");
0302              break;
0303   
0304              default:
0305                  trigger_error('NO_MODE', E_USER_ERROR);
0306              break;
0307          }
0308   
0309          // Grab relevant data
0310          $sql = "SELECT user_id, username, user_email, user_lang, $sql_field
0311              FROM " . USERS_TABLE . "
0312              WHERE user_id = $user_id
0313                  AND user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ')';
0314          $result = $db->sql_query($sql);
0315          $row = $db->sql_fetchrow($result);
0316          $db->sql_freeresult($result);
0317   
0318          if (!$row)
0319          {
0320              trigger_error('NO_USER');
0321          }
0322          else if (empty($row[$sql_field]))
0323          {
0324              trigger_error('IM_NO_DATA');
0325          }
0326   
0327          // Post data grab actions
0328          switch ($action)
0329          {
0330              case 'jabber':
0331                  add_form_key('memberlist_messaging');
0332   
0333                  if ($submit && @extension_loaded('xml') && $config['jab_enable'])
0334                  {
0335                      if (check_form_key('memberlist_messaging'))
0336                      {
0337   
0338                          include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
0339   
0340                          $subject = sprintf($user->lang['IM_JABBER_SUBJECT'], $user->data['username'], $config['server_name']);
0341                          $message = utf8_normalize_nfc(request_var('message', '', true));
0342   
0343                          if (empty($message))
0344                          {
0345                              trigger_error('EMPTY_MESSAGE_IM');
0346                          }
0347   
0348                          $messenger = new messenger(false);
0349   
0350                          $messenger->template('profile_send_im', $row['user_lang']);
0351                          $messenger->subject(htmlspecialchars_decode($subject));
0352   
0353                          $messenger->replyto($user->data['user_email']);
0354                          $messenger->im($row['user_jabber'], $row['username']);
0355   
0356                          $messenger->assign_vars(array(
0357                              'BOARD_CONTACT'    => $config['board_contact'],
0358                              'FROM_USERNAME'    => htmlspecialchars_decode($user->data['username']),
0359                              'TO_USERNAME'    => htmlspecialchars_decode($row['username']),
0360                              'MESSAGE'        => htmlspecialchars_decode($message))
0361                          );
0362   
0363                          $messenger->send(NOTIFY_IM);
0364   
0365                          $s_select = 'S_SENT_JABBER';
0366                      }
0367                      else
0368                      {
0369                          trigger_error('FORM_INVALID');
0370                      }
0371                  }
0372              break;
0373          }
0374   
0375          // Send vars to the template
0376          $template->assign_vars(array(
0377              'IM_CONTACT'    => $row[$sql_field],
0378              'A_IM_CONTACT'    => addslashes($row[$sql_field]),
0379   
0380              'U_AIM_CONTACT'    => ($action == 'aim') ? 'aim:addbuddy?screenname=' . urlencode($row[$sql_field]) : '',
0381              'U_AIM_MESSAGE'    => ($action == 'aim') ? 'aim:goim?screenname=' . urlencode($row[$sql_field]) . '&amp;message=' . urlencode($config['sitename']) : '',
0382   
0383              'USERNAME'        => $row['username'],
0384              'CONTACT_NAME'    => $row[$sql_field],
0385              'SITENAME'        => $config['sitename'],
0386   
0387              'PRESENCE_IMG'        => $presence_img,
0388   
0389              'L_SEND_IM_EXPLAIN'    => $user->lang['IM_' . $lang],
0390              'L_IM_SENT_JABBER'    => sprintf($user->lang['IM_SENT_JABBER'], $row['username']),
0391   
0392              $s_select            => true,
0393              'S_IM_ACTION'        => $s_action)
0394          );
0395   
0396      break;
0397   
0398      case 'viewprofile':
0399          // Display a profile
0400          if ($user_id == ANONYMOUS && !$username)
0401          {
0402              trigger_error('NO_USER');
0403          }
0404   
0405          // Get user...
0406          $sql = 'SELECT *
0407              FROM ' . USERS_TABLE . '
0408              WHERE ' . (($username) ? "username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'" : "user_id = $user_id");
0409          $result = $db->sql_query($sql);
0410          $member = $db->sql_fetchrow($result);
0411          $db->sql_freeresult($result);
0412   
0413          if (!$member)
0414          {
0415              trigger_error('NO_USER');
0416          }
0417   
0418          // a_user admins and founder are able to view inactive users and bots to be able to manage them more easily
0419          // Normal users are able to see at least users having only changed their profile settings but not yet reactivated.
0420          if (!$auth->acl_get('a_user') && $user->data['user_type'] != USER_FOUNDER)
0421          {
0422              if ($member['user_type'] == USER_IGNORE)
0423              {
0424                  trigger_error('NO_USER');
0425              }
0426              else if ($member['user_type'] == USER_INACTIVE && $member['user_inactive_reason'] != INACTIVE_PROFILE)
0427              {
0428                  trigger_error('NO_USER');
0429              }
0430          }
0431   
0432          $user_id = (int) $member['user_id'];
0433   
0434          // Do the SQL thang
0435          $sql = 'SELECT g.group_id, g.group_name, g.group_type
0436              FROM ' . GROUPS_TABLE . ' g, ' . USER_GROUP_TABLE . " ug
0437              WHERE ug.user_id = $user_id
0438                  AND g.group_id = ug.group_id" . ((!$auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel')) ? ' AND g.group_type <> ' . GROUP_HIDDEN : '') . '
0439                  AND ug.user_pending = 0
0440              ORDER BY g.group_type, g.group_name';
0441          $result = $db->sql_query($sql);
0442   
0443          $group_options = '';
0444          while ($row = $db->sql_fetchrow($result))
0445          {
0446              $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>';
0447          }
0448          $db->sql_freeresult($result);
0449   
0450          // What colour is the zebra
0451          $sql = 'SELECT friend, foe
0452              FROM ' . ZEBRA_TABLE . "
0453              WHERE zebra_id = $user_id
0454                  AND user_id = {$user->data['user_id']}";
0455   
0456          $result = $db->sql_query($sql);
0457          $row = $db->sql_fetchrow($result);
0458          $foe = ($row['foe']) ? true : false;
0459          $friend = ($row['friend']) ? true : false;
0460          $db->sql_freeresult($result);
0461   
0462          if ($config['load_onlinetrack'])
0463          {
0464              $sql = 'SELECT MAX(session_time) AS session_time, MIN(session_viewonline) AS session_viewonline
0465                  FROM ' . SESSIONS_TABLE . "
0466                  WHERE session_user_id = $user_id";
0467              $result = $db->sql_query($sql);
0468              $row = $db->sql_fetchrow($result);
0469              $db->sql_freeresult($result);
0470   
0471              $member['session_time'] = (isset($row['session_time'])) ? $row['session_time'] : 0;
0472              $member['session_viewonline'] = (isset($row['session_viewonline'])) ? $row['session_viewonline'] :    0;
0473              unset($row);
0474          }
0475   
0476          if ($config['load_user_activity'])
0477          {
0478              display_user_activity($member);
0479          }
0480   
0481          // Do the relevant calculations
0482          $memberdays = max(1, round((time() - $member['user_regdate']) / 86400));
0483          $posts_per_day = $member['user_posts'] / $memberdays;
0484          $percentage = ($config['num_posts']) ? min(100, ($member['user_posts'] / $config['num_posts']) * 100) : 0;
0485   
0486   
0487          if ($member['user_sig'])
0488          {
0489              $member['user_sig'] = censor_text($member['user_sig']);
0490   
0491              if ($member['user_sig_bbcode_bitfield'])
0492              {
0493                  include_once($phpbb_root_path . 'includes/bbcode.' . $phpEx);
0494                  $bbcode = new bbcode();
0495                  $bbcode->bbcode_second_pass($member['user_sig'], $member['user_sig_bbcode_uid'], $member['user_sig_bbcode_bitfield']);
0496              }
0497   
0498              $member['user_sig'] = bbcode_nl2br($member['user_sig']);
0499              $member['user_sig'] = smiley_text($member['user_sig']);
0500          }
0501   
0502          $poster_avatar = get_user_avatar($member['user_avatar'], $member['user_avatar_type'], $member['user_avatar_width'], $member['user_avatar_height']);
0503   
0504          $template->assign_vars(show_profile($member));
0505   
0506          // Custom Profile Fields
0507          $profile_fields = array();
0508          if ($config['load_cpf_viewprofile'])
0509          {
0510              include_once($phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx);
0511              $cp = new custom_profile();
0512              $profile_fields = $cp->generate_profile_fields_template('grab', $user_id);
0513              $profile_fields = (isset($profile_fields[$user_id])) ? $cp->generate_profile_fields_template('show', false, $profile_fields[$user_id]) : array();
0514          }
0515   
0516          // We need to check if the module 'zebra' is accessible
0517          $zebra_enabled = false;
0518   
0519          if ($user->data['user_id'] != $user_id && $user->data['is_registered'])
0520          {
0521              include_once($phpbb_root_path . 'includes/functions_module.' . $phpEx);
0522              $module = new p_master();
0523              $module->list_modules('ucp');
0524              $module->set_active('zebra');
0525   
0526              $zebra_enabled = ($module->active_module === false) ? false : true;
0527   
0528              unset($module);
0529          }
0530   
0531          $template->assign_vars(array(
0532              'POSTS_DAY'            => sprintf($user->lang['POST_DAY'], $posts_per_day),
0533              'POSTS_PCT'            => sprintf($user->lang['POST_PCT'], $percentage),
0534   
0535              'OCCUPATION'    => (!empty($member['user_occ'])) ? censor_text($member['user_occ']) : '',
0536              'INTERESTS'        => (!empty($member['user_interests'])) ? censor_text($member['user_interests']) : '',
0537              'SIGNATURE'        => $member['user_sig'],
0538   
0539              'AVATAR_IMG'    => $poster_avatar,
0540              'PM_IMG'        => $user->img('icon_contact_pm', $user->lang['SEND_PRIVATE_MESSAGE']),
0541              'EMAIL_IMG'        => $user->img('icon_contact_email', $user->lang['EMAIL']),
0542              'WWW_IMG'        => $user->img('icon_contact_www', $user->lang['WWW']),
0543              'ICQ_IMG'        => $user->img('icon_contact_icq', $user->lang['ICQ']),
0544              'AIM_IMG'        => $user->img('icon_contact_aim', $user->lang['AIM']),
0545              'MSN_IMG'        => $user->img('icon_contact_msnm', $user->lang['MSNM']),
0546              'YIM_IMG'        => $user->img('icon_contact_yahoo', $user->lang['YIM']),
0547              'JABBER_IMG'    => $user->img('icon_contact_jabber', $user->lang['JABBER']),
0548              'SEARCH_IMG'    => $user->img('icon_user_search', $user->lang['SEARCH']),
0549   
0550              'S_PROFILE_ACTION'    => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group'),
0551              'S_GROUP_OPTIONS'    => $group_options,
0552              'S_CUSTOM_FIELDS'    => (isset($profile_fields['row']) && sizeof($profile_fields['row'])) ? true : false,
0553   
0554              'U_USER_ADMIN'            => ($auth->acl_get('a_user')) ? append_sid("{$phpbb_root_path}adm/index.$phpEx", 'i=users&amp;mode=overview&amp;u=' . $user_id, true, $user->session_id) : '',
0555              'U_SWITCH_PERMISSIONS'    => ($auth->acl_get('a_switchperm') && $user->data['user_id'] != $user_id) ? append_sid("{$phpbb_root_path}ucp.$phpEx", "mode=switch_perm&amp;u={$user_id}") : '',
0556   
0557              'S_ZEBRA'            => ($user->data['user_id'] != $user_id && $user->data['is_registered'] && $zebra_enabled) ? true : false,
0558              'U_ADD_FRIEND'        => (!$friend) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=zebra&amp;add=' . urlencode(htmlspecialchars_decode($member['username']))) : '',
0559              'U_ADD_FOE'            => (!$foe) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=zebra&amp;mode=foes&amp;add=' . urlencode(htmlspecialchars_decode($member['username']))) : '',
0560              'U_REMOVE_FRIEND'    => ($friend) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=zebra&amp;remove=1&amp;usernames[]=' . $user_id) : '',
0561              'U_REMOVE_FOE'        => ($foe) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=zebra&amp;remove=1&amp;mode=foes&amp;usernames[]=' . $user_id) : '',
0562          ));
0563   
0564          if (!empty($profile_fields['row']))
0565          {
0566              $template->assign_vars($profile_fields['row']);
0567          }
0568   
0569          if (!empty($profile_fields['blockrow']))
0570          {
0571              foreach ($profile_fields['blockrow'] as $field_data)
0572              {
0573                  $template->assign_block_vars('custom_fields', $field_data);
0574              }
0575          }
0576   
0577          // Inactive reason/account?
0578          if ($member['user_type'] == USER_INACTIVE)
0579          {
0580              $user->add_lang('acp/common');
0581   
0582              $inactive_reason = $user->lang['INACTIVE_REASON_UNKNOWN'];
0583   
0584              switch ($member['user_inactive_reason'])
0585              {
0586                  case INACTIVE_REGISTER:
0587                      $inactive_reason = $user->lang['INACTIVE_REASON_REGISTER'];
0588                  break;
0589   
0590                  case INACTIVE_PROFILE:
0591                      $inactive_reason = $user->lang['INACTIVE_REASON_PROFILE'];
0592                  break;
0593   
0594                  case INACTIVE_MANUAL:
0595                      $inactive_reason = $user->lang['INACTIVE_REASON_MANUAL'];
0596                  break;
0597   
0598                  case INACTIVE_REMIND:
0599                      $inactive_reason = $user->lang['INACTIVE_REASON_REMIND'];
0600                  break;
0601              }
0602   
0603              $template->assign_vars(array(
0604                  'S_USER_INACTIVE'        => true,
0605                  'USER_INACTIVE_REASON'    => $inactive_reason)
0606              );
0607          }
0608   
0609          // Now generate page title
0610          $page_title = sprintf($user->lang['VIEWING_PROFILE'], $member['username']);
0611          $template_html = 'memberlist_view.html';
0612   
0613      break;
0614   
0615      case 'email':
0616   
0617          // Send an email
0618          $page_title = $user->lang['SEND_EMAIL'];
0619          $template_html = 'memberlist_email.html';
0620   
0621          add_form_key('memberlist_email');
0622   
0623          if (!$config['email_enable'])
0624          {
0625              trigger_error('EMAIL_DISABLED');
0626          }
0627   
0628          if (!$auth->acl_get('u_sendemail'))
0629          {
0630              trigger_error('NO_EMAIL');
0631          }
0632   
0633          // Are we trying to abuse the facility?
0634          if (time() - $user->data['user_emailtime'] < $config['flood_interval'])
0635          {
0636              trigger_error('FLOOD_EMAIL_LIMIT');
0637          }
0638   
0639          // Determine action...
0640          $user_id = request_var('u', 0);
0641          $topic_id = request_var('t', 0);
0642   
0643          // Send email to user...
0644          if ($user_id)
0645          {
0646              if ($user_id == ANONYMOUS || !$config['board_email_form'])
0647              {
0648                  trigger_error('NO_EMAIL');
0649              }
0650   
0651              // Get the appropriate username, etc.
0652              $sql = 'SELECT username, user_email, user_allow_viewemail, user_lang, user_jabber, user_notify_type
0653                  FROM ' . USERS_TABLE . "
0654                  WHERE user_id = $user_id
0655                      AND user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ')';
0656              $result = $db->sql_query($sql);
0657              $row = $db->sql_fetchrow($result);
0658              $db->sql_freeresult($result);
0659   
0660              if (!$row)
0661              {
0662                  trigger_error('NO_USER');
0663              }
0664   
0665              // Can we send email to this user?
0666              if (!$row['user_allow_viewemail'] && !$auth->acl_get('a_user'))
0667              {
0668                  trigger_error('NO_EMAIL');
0669              }
0670          }
0671          else if ($topic_id)
0672          {
0673              // Send topic heads-up to email address
0674              $sql = 'SELECT forum_id, topic_title
0675                  FROM ' . TOPICS_TABLE . "
0676                  WHERE topic_id = $topic_id";
0677              $result = $db->sql_query($sql);
0678              $row = $db->sql_fetchrow($result);
0679              $db->sql_freeresult($result);
0680   
0681              if (!$row)
0682              {
0683                  trigger_error('NO_TOPIC');
0684              }
0685   
0686              if ($row['forum_id'])
0687              {
0688                  if (!$auth->acl_get('f_read', $row['forum_id']))
0689                  {
0690                      trigger_error('SORRY_AUTH_READ');
0691                  }
0692   
0693                  if (!$auth->acl_get('f_email', $row['forum_id']))
0694                  {
0695                      trigger_error('NO_EMAIL');
0696                  }
0697              }
0698              else
0699              {
0700                  // If global announcement, we need to check if the user is able to at least read and email in one forum...
0701                  if (!$auth->acl_getf_global('f_read'))
0702                  {
0703                      trigger_error('SORRY_AUTH_READ');
0704                  }
0705   
0706                  if (!$auth->acl_getf_global('f_email'))
0707                  {
0708                      trigger_error('NO_EMAIL');
0709                  }
0710              }
0711          }
0712          else
0713          {
0714              trigger_error('NO_EMAIL');
0715          }
0716   
0717          $error = array();
0718   
0719          $name        = utf8_normalize_nfc(request_var('name', '', true));
0720          $email        = request_var('email', '');
0721          $email_lang = request_var('lang', $config['default_lang']);
0722          $subject    = utf8_normalize_nfc(request_var('subject', '', true));
0723          $message    = utf8_normalize_nfc(request_var('message', '', true));
0724          $cc            = (isset($_POST['cc_email'])) ? true : false;
0725          $submit        = (isset($_POST['submit'])) ? true : false;
0726   
0727          if ($submit)
0728          {
0729              if (!check_form_key('memberlist_email'))
0730              {
0731                  $error[] = 'FORM_INVALID';
0732              }
0733              if ($user_id)
0734              {
0735                  if (!$subject)
0736                  {
0737                      $error[] = $user->lang['EMPTY_SUBJECT_EMAIL'];
0738                  }
0739   
0740                  if (!$message)
0741                  {
0742                      $error[] = $user->lang['EMPTY_MESSAGE_EMAIL'];
0743                  }
0744   
0745                  $name = $row['username'];
0746                  $email_lang = $row['user_lang'];
0747                  $email = $row['user_email'];
0748              }
0749              else
0750              {
0751                  if (!$email || !preg_match('/^' . get_preg_expression('email') . '$/i', $email))
0752                  {
0753                      $error[] = $user->lang['EMPTY_ADDRESS_EMAIL'];
0754                  }
0755   
0756                  if (!$name)
0757                  {
0758                      $error[] = $user->lang['EMPTY_NAME_EMAIL'];
0759                  }
0760              }
0761   
0762              if (!sizeof($error))
0763              {
0764                  $sql = 'UPDATE ' . USERS_TABLE . '
0765                      SET user_emailtime = ' . time() . '
0766                      WHERE user_id = ' . $user->data['user_id'];
0767                  $result = $db->sql_query($sql);
0768   
0769                  include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
0770                  $messenger = new messenger(false);
0771                  $email_tpl = ($user_id) ? 'profile_send_email' : 'email_notify';
0772   
0773                  $mail_to_users = array();
0774   
0775                  $mail_to_users[] = array(
0776                      'email_lang'        => $email_lang,
0777                      'email'                => $email,
0778                      'name'                => $name,
0779                      'username'            => ($user_id) ? $row['username'] : '',
0780                      'to_name'            => $name,
0781                      'user_jabber'        => ($user_id) ? $row['user_jabber'] : '',
0782                      'user_notify_type'    => ($user_id) ? $row['user_notify_type'] : NOTIFY_EMAIL,
0783                      'topic_title'        => (!$user_id) ? $row['topic_title'] : '',
0784                      'forum_id'            => (!$user_id) ? $row['forum_id'] : 0,
0785                  );
0786   
0787                  // Ok, now the same email if CC specified, but without exposing the users email address
0788                  if ($cc)
0789                  {
0790                      $mail_to_users[] = array(
0791                          'email_lang'        => $user->data['user_lang'],
0792                          'email'                => $user->data['user_email'],
0793                          'name'                => $user->data['username'],
0794                          'username'            => $user->data['username'],
0795                          'to_name'            => $name,
0796                          'user_jabber'        => $user->data['user_jabber'],
0797                          'user_notify_type'    => ($user_id) ? $user->data['user_notify_type'] : NOTIFY_EMAIL,
0798                          'topic_title'        => (!$user_id) ? $row['topic_title'] : '',
0799                          'forum_id'            => (!$user_id) ? $row['forum_id'] : 0,
0800                      );
0801                  }
0802   
0803                  foreach ($mail_to_users as $row)
0804                  {
0805                      $messenger->template($email_tpl, $row['email_lang']);
0806                      $messenger->replyto($user->data['user_email']);
0807                      $messenger->to($row['email'], $row['name']);
0808   
0809                      if ($user_id)
0810                      {
0811                          $messenger->subject(htmlspecialchars_decode($subject));
0812                          $messenger->im($row['user_jabber'], $row['username']);
0813                          $notify_type = $row['user_notify_type'];
0814                      }
0815                      else
0816                      {
0817                          $notify_type = NOTIFY_EMAIL;
0818                      }
0819   
0820                      $messenger->headers('X-AntiAbuse: Board servername - ' . $config['server_name']);
0821                      $messenger->headers('X-AntiAbuse: User_id - ' . $user->data['user_id']);
0822                      $messenger->headers('X-AntiAbuse: Username - ' . $user->data['username']);
0823                      $messenger->headers('X-AntiAbuse: User IP - ' . $user->ip);
0824   
0825                      $messenger->assign_vars(array(
0826                          'BOARD_CONTACT'    => $config['board_contact'],
0827                          'TO_USERNAME'    => htmlspecialchars_decode($row['to_name']),
0828                          'FROM_USERNAME'    => htmlspecialchars_decode($user->data['username']),
0829                          'MESSAGE'        => htmlspecialchars_decode($message))
0830                      );
0831   
0832                      if ($topic_id)
0833                      {
0834                          $messenger->assign_vars(array(
0835                              'TOPIC_NAME'    => htmlspecialchars_decode($row['topic_title']),
0836                              'U_TOPIC'        => generate_board_url() . "/viewtopic.$phpEx?f=" . $row['forum_id'] . "&t=$topic_id")
0837                          );
0838                      }
0839   
0840                      $messenger->send($notify_type);
0841                  }
0842   
0843                  meta_refresh(3, append_sid("{$phpbb_root_path}index.$phpEx"));
0844                  $message = ($user_id) ? sprintf($user->lang['RETURN_INDEX'], '<a href="' . append_sid("{$phpbb_root_path}index.$phpEx") . '">', '</a>') : sprintf($user->lang['RETURN_TOPIC'],  '<a href="' . append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f={$row['forum_id']}&amp;t=$topic_id") . '">', '</a>');
0845                  trigger_error($user->lang['EMAIL_SENT'] . '<br /><br />' . $message);
0846              }
0847          }
0848   
0849          if ($user_id)
0850          {
0851              $template->assign_vars(array(
0852                  'S_SEND_USER'    => true,
0853                  'USERNAME'        => $row['username'],
0854   
0855                  'L_EMAIL_BODY_EXPLAIN'    => $user->lang['EMAIL_BODY_EXPLAIN'],
0856                  'S_POST_ACTION'            => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=email&amp;u=' . $user_id))
0857              );
0858          }
0859          else
0860          {
0861              $template->assign_vars(array(
0862                  'EMAIL'                => $email,
0863                  'NAME'                => $name,
0864                  'S_LANG_OPTIONS'    => language_select($email_lang),
0865   
0866                  'L_EMAIL_BODY_EXPLAIN'    => $user->lang['EMAIL_TOPIC_EXPLAIN'],
0867                  'S_POST_ACTION'            => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=email&amp;t=' . $topic_id))
0868              );
0869          }
0870   
0871          $template->assign_vars(array(
0872              'ERROR_MESSAGE'        => (sizeof($error)) ? implode('<br />', $error) : '')
0873          );
0874   
0875      break;
0876   
0877      case 'group':
0878      default:
0879          // The basic memberlist
0880          $page_title = $user->lang['MEMBERLIST'];
0881          $template_html = 'memberlist_body.html';
0882   
0883          // Sorting
0884          $sort_key_text = array('a' => $user->lang['SORT_USERNAME'], 'b' => $user->lang['SORT_LOCATION'], 'c' => $user->lang['SORT_JOINED'], 'd' => $user->lang['SORT_POST_COUNT'], 'e' => $user->lang['SORT_EMAIL'], 'f' => $user->lang['WEBSITE'], 'g' => $user->lang['ICQ'], 'h' => $user->lang['AIM'], 'i' => $user->lang['MSNM'], 'j' => $user->lang['YIM'], 'k' => $user->lang['JABBER']);
0885   
0886          if ($auth->acl_get('u_viewonline'))
0887          {
0888              $sort_key_text['l'] = $user->lang['SORT_LAST_ACTIVE'];
0889          }
0890          $sort_key_text['m'] = $user->lang['SORT_RANK'];
0891   
0892          $sort_key_sql = array('a' => 'u.username_clean', 'b' => 'u.user_from', 'c' => 'u.user_regdate', 'd' => 'u.user_posts', 'e' => 'u.user_email', 'f' => 'u.user_website', 'g' => 'u.user_icq', 'h' => 'u.user_aim', 'i' => 'u.user_msnm', 'j' => 'u.user_yim', 'k' => 'u.user_jabber');
0893   
0894          if ($auth->acl_get('u_viewonline'))
0895          {
0896              $sort_key_sql['l'] = 'u.user_lastvisit';
0897          }
0898          $sort_key_sql['m'] = 'u.user_rank DESC, u.user_posts';
0899   
0900          $sort_dir_text = array('a' => $user->lang['ASCENDING'], 'd' => $user->lang['DESCENDING']);
0901   
0902          $s_sort_key = '';
0903          foreach ($sort_key_text as $key => $value)
0904          {
0905              $selected = ($sort_key == $key) ? ' selected="selected"' : '';
0906              $s_sort_key .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>';
0907          }
0908   
0909          $s_sort_dir = '';
0910          foreach ($sort_dir_text as $key => $value)
0911          {
0912              $selected = ($sort_dir == $key) ? ' selected="selected"' : '';
0913              $s_sort_dir .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>';
0914          }
0915   
0916          // Additional sorting options for user search ... if search is enabled, if not
0917          // then only admins can make use of this (for ACP functionality)
0918          $sql_select = $sql_where_data = $sql_from = $sql_where = $order_by = '';
0919   
0920   
0921          $form            = request_var('form', '');
0922          $field            = request_var('field', '');
0923          $select_single     = request_var('select_single', false);
0924   
0925          // We validate form and field here, only id/class allowed
0926          $form = (!preg_match('/^[a-z0-9_-]+$/i', $form)) ? '' : $form;
0927          $field = (!preg_match('/^[a-z0-9_-]+$/i', $field)) ? '' : $field;
0928          if ($mode == 'searchuser' && ($config['load_search'] || $auth->acl_get('a_')))
0929          {
0930              $username    = request_var('username', '', true);
0931              $email        = strtolower(request_var('email', ''));
0932              $icq        = request_var('icq', '');
0933              $aim        = request_var('aim', '');
0934              $yahoo        = request_var('yahoo', '');
0935              $msn        = request_var('msn', '');
0936              $jabber        = request_var('jabber', '');
0937              $search_group_id    = request_var('search_group_id', 0);
0938   
0939              $joined_select    = request_var('joined_select', 'lt');
0940              $active_select    = request_var('active_select', 'lt');
0941              $count_select    = request_var('count_select', 'eq');
0942              $joined            = explode('-', request_var('joined', ''));
0943              $active            = explode('-', request_var('active', ''));
0944              $count            = (request_var('count', '') !== '') ? request_var('count', 0) : '';
0945              $ipdomain        = request_var('ip', '');
0946   
0947              $find_key_match = array('lt' => '<', 'gt' => '>', 'eq' => '=');
0948   
0949              $find_count = array('lt' => $user->lang['LESS_THAN'], 'eq' => $user->lang['EQUAL_TO'], 'gt' => $user->lang['MORE_THAN']);
0950              $s_find_count = '';
0951              foreach ($find_count as $key => $value)
0952              {
0953                  $selected = ($count_select == $key) ? ' selected="selected"' : '';
0954                  $s_find_count .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>';
0955              }
0956   
0957              $find_time = array('lt' => $user->lang['BEFORE'], 'gt' => $user->lang['AFTER']);
0958              $s_find_join_time = '';
0959              foreach ($find_time as $key => $value)
0960              {
0961                  $selected = ($joined_select == $key) ? ' selected="selected"' : '';
0962                  $s_find_join_time .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>';
0963              }
0964   
0965              $s_find_active_time = '';
0966              foreach ($find_time as $key => $value)
0967              {
0968                  $selected = ($active_select == $key) ? ' selected="selected"' : '';
0969                  $s_find_active_time .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>';
0970              }
0971   
0972              $sql_where .= ($username) ? ' AND u.username_clean ' . $db->sql_like_expression(str_replace('*', $db->any_char, utf8_clean_string($username))) : '';
0973              $sql_where .= ($email) ? ' AND u.user_email ' . $db->sql_like_expression(str_replace('*', $db->any_char, $email)) . ' ' : '';
0974              $sql_where .= ($icq) ? ' AND u.user_icq ' . $db->sql_like_expression(str_replace('*', $db->any_char, $icq)) . ' ' : '';
0975              $sql_where .= ($aim) ? ' AND u.user_aim ' . $db->sql_like_expression(str_replace('*', $db->any_char, $aim)) . ' ' : '';
0976              $sql_where .= ($yahoo) ? ' AND u.user_yim ' . $db->sql_like_expression(str_replace('*', $db->any_char, $yahoo)) . ' ' : '';
0977              $sql_where .= ($msn) ? ' AND u.user_msnm ' . $db->sql_like_expression(str_replace('*', $db->any_char, $msn)) . ' ' : '';
0978              $sql_where .= ($jabber) ? ' AND u.user_jabber ' . $db->sql_like_expression(str_replace('*', $db->any_char, $jabber)) . ' ' : '';
0979              $sql_where .= (is_numeric($count)) ? ' AND u.user_posts ' . $find_key_match[$count_select] . ' ' . (int) $count . ' ' : '';
0980              $sql_where .= (sizeof($joined) > 1) ? " AND u.user_regdate " . $find_key_match[$joined_select] . ' ' . gmmktime(0, 0, 0, intval($joined[1]), intval($joined[2]), intval($joined[0])) : '';
0981              $sql_where .= ($auth->acl_get('u_viewonline') && sizeof($active) > 1) ? " AND u.user_lastvisit " . $find_key_match[$active_select] . ' ' . gmmktime(0, 0, 0, $active[1], intval($active[2]), intval($active[0])) : '';
0982              $sql_where .= ($search_group_id) ? " AND u.user_id = ug.user_id AND ug.group_id = $search_group_id AND ug.user_pending = 0 " : '';
0983   
0984              if ($search_group_id)
0985              {
0986                  $sql_from = ', ' . USER_GROUP_TABLE . ' ug ';
0987              }
0988   
0989              if ($ipdomain && $auth->acl_getf_global('m_info'))
0990              {
0991                  if (strspn($ipdomain, 'abcdefghijklmnopqrstuvwxyz'))
0992                  {
0993                      $hostnames = gethostbynamel($ipdomain);
0994   
0995                      if ($hostnames !== false)
0996                      {
0997                          $ips = "'" . implode('\', \'', array_map(array($db, 'sql_escape'), preg_replace('#([0-9]{1,3}\.[0-9]{1,3}[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})#', "\\1", gethostbynamel($ipdomain)))) . "'";
0998                      }
0999                      else
1000                      {
1001                          $ips = false;
1002                      }
1003                  }
1004                  else
1005                  {
1006                      $ips = "'" . str_replace('*', '%', $db->sql_escape($ipdomain)) . "'";
1007                  }
1008   
1009                  if ($ips === false)
1010                  {
1011                      // A minor fudge but it does the job :D
1012                      $sql_where .= " AND u.user_id = 0";
1013                  }
1014                  else
1015                  {
1016                      $ip_forums = array_keys($auth->acl_getf('m_info', true));
1017   
1018                      $sql = 'SELECT DISTINCT poster_id
1019                          FROM ' . POSTS_TABLE . '
1020                          WHERE poster_ip ' . ((strpos($ips, '%') !== false) ? 'LIKE' : 'IN') . " ($ips)
1021                              AND forum_id IN (0, " . implode(', ', $ip_forums) . ')';
1022                      $result = $db->sql_query($sql);
1023   
1024                      if ($row = $db->sql_fetchrow($result))
1025                      {
1026                          $ip_sql = array();
1027                          do
1028                          {
1029                              $ip_sql[] = $row['poster_id'];
1030                          }
1031                          while ($row = $db->sql_fetchrow($result));
1032   
1033                          $sql_where .= ' AND ' . $db->sql_in_set('u.user_id', $ip_sql);
1034                      }
1035                      else
1036                      {
1037                          // A minor fudge but it does the job :D
1038                          $sql_where .= " AND u.user_id = 0";
1039                      }
1040                      unset($ip_forums);
1041   
1042                      $db->sql_freeresult($result);
1043                  }
1044              }
1045          }
1046   
1047          $first_char = request_var('first_char', '');
1048   
1049          if ($first_char == 'other')
1050          {
1051              for ($i = 97; $i < 123; $i++)
1052              {
1053                  $sql_where .= ' AND u.username_clean NOT ' . $db->sql_like_expression(chr($i) . $db->any_char);
1054              }
1055          }
1056          else if ($first_char)
1057          {
1058              $sql_where .= ' AND u.username_clean ' . $db->sql_like_expression(substr($first_char, 0, 1) . $db->any_char);
1059          }
1060   
1061          // Are we looking at a usergroup? If so, fetch additional info
1062          // and further restrict the user info query
1063          if ($mode == 'group')
1064          {
1065              // We JOIN here to save a query for determining membership for hidden groups. ;)
1066              $sql = 'SELECT g.*, ug.user_id
1067                  FROM ' . GROUPS_TABLE . ' g
1068                  LEFT JOIN ' . USER_GROUP_TABLE . ' ug ON (ug.user_pending = 0 AND ug.user_id = ' . $user->data['user_id'] . " AND ug.group_id = $group_id)
1069                  WHERE g.group_id = $group_id";
1070              $result = $db->sql_query($sql);
1071              $group_row = $db->sql_fetchrow($result);
1072              $db->sql_freeresult($result);
1073   
1074              if (!$group_row)
1075              {
1076                  trigger_error('NO_GROUP');
1077              }
1078   
1079              switch ($group_row['group_type'])
1080              {
1081                  case GROUP_OPEN:
1082                      $group_row['l_group_type'] = 'OPEN';
1083                  break;
1084   
1085                  case GROUP_CLOSED:
1086                      $group_row['l_group_type'] = 'CLOSED';
1087                  break;
1088   
1089                  case GROUP_HIDDEN:
1090                      $group_row['l_group_type'] = 'HIDDEN';
1091   
1092                      // Check for membership or special permissions
1093                      if (!$auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel') && $group_row['user_id'] != $user->data['user_id'])
1094                      {
1095                          trigger_error('NO_GROUP');
1096                      }
1097                  break;
1098   
1099                  case GROUP_SPECIAL:
1100                      $group_row['l_group_type'] = 'SPECIAL';
1101                  break;
1102   
1103                  case GROUP_FREE:
1104                      $group_row['l_group_type'] = 'FREE';
1105                  break;
1106              }
1107   
1108              // Misusing the avatar function for displaying group avatars...
1109              $avatar_img = get_user_avatar($group_row['group_avatar'], $group_row['group_avatar_type'], $group_row['group_avatar_width'], $group_row['group_avatar_height'], 'GROUP_AVATAR');
1110   
1111              $rank_title = $rank_img = $rank_img_src = '';
1112              if ($group_row['group_rank'])
1113              {
1114                  if (isset($ranks['special'][$group_row['group_rank']]))
1115                  {
1116                      $rank_title = $ranks['special'][$group_row['group_rank']]['rank_title'];
1117                  }
1118                  $rank_img = (!empty($ranks['special'][$group_row['group_rank']]['rank_image'])) ? '<img src="' . $config['ranks_path'] . '/' . $ranks['special'][$group_row['group_rank']]['rank_image'] . '" alt="' . $ranks['special'][$group_row['group_rank']]['rank_title'] . '" title="' . $ranks['special'][$group_row['group_rank']]['rank_title'] . '" /><br />' : '';
1119                  $rank_img_src = (!empty($ranks['special'][$group_row['group_rank']]['rank_image'])) ? $config['ranks_path'] . '/' . $ranks['special'][$group_row['group_rank']]['rank_image'] : '';
1120              }
1121              else
1122              {
1123                  $rank_title = '';
1124                  $rank_img = '';
1125                  $rank_img_src = '';
1126              }
1127   
1128              $template->assign_vars(array(
1129                  'GROUP_DESC'    => generate_text_for_display($group_row['group_desc'], $group_row['group_desc_uid'], $group_row['group_desc_bitfield'], $group_row['group_desc_options']),
1130                  'GROUP_NAME'    => ($group_row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $group_row['group_name']] : $group_row['group_name'],
1131                  'GROUP_COLOR'    => $group_row['group_colour'],
1132                  'GROUP_TYPE'    => $user->lang['GROUP_IS_' . $group_row['l_group_type']],
1133                  'GROUP_RANK'    => $rank_title,
1134   
1135                  'AVATAR_IMG'    => $avatar_img,
1136                  'RANK_IMG'        => $rank_img,
1137                  'RANK_IMG_SRC'    => $rank_img_src,
1138   
1139                  'U_PM'            => ($auth->acl_get('u_sendpm') && $auth->acl_get('u_masspm') && $group_row['group_receive_pm'] && $config['allow_privmsg'] && $config['allow_mass_pm']) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&amp;mode=compose&amp;g=' . $group_id) : '',)
1140              );
1141   
1142              $sql_select = ', ug.group_leader';
1143              $sql_from = ', ' . USER_GROUP_TABLE . ' ug ';
1144              $order_by = 'ug.group_leader DESC, ';
1145   
1146              $sql_where .= " AND ug.user_pending = 0 AND u.user_id = ug.user_id AND ug.group_id = $group_id";
1147              $sql_where_data = " AND u.user_id = ug.user_id AND ug.group_id = $group_id";
1148          }
1149          
1150          // Sorting and order
1151          if (!isset($sort_key_sql[$sort_key]))
1152          {
1153              $sort_key = $default_key;
1154          }
1155   
1156          $order_by .= $sort_key_sql[$sort_key] . ' ' . (($sort_dir == 'a') ? 'ASC' : 'DESC');
1157   
1158          // Count the users ...
1159          if ($sql_where)
1160          {
1161              $sql = 'SELECT COUNT(u.user_id) AS total_users
1162                  FROM ' . USERS_TABLE . " u$sql_from
1163                  WHERE u.user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ")
1164                  $sql_where";
1165              $result = $db->sql_query($sql);
1166              $total_users = (int) $db->sql_fetchfield('total_users');
1167              $db->sql_freeresult($result);
1168          }
1169          else
1170          {
1171              $total_users = $config['num_users'];
1172          }
1173   
1174          $s_char_options = '<option value=""' . ((!$first_char) ? ' selected="selected"' : '') . '>&nbsp; &nbsp;</option>';
1175          for ($i = 97; $i < 123; $i++)
1176          {
1177              $s_char_options .= '<option value="' . chr($i) . '"' . (($first_char == chr($i)) ? ' selected="selected"' : '') . '>' . chr($i-32) . '</option>';
1178          }
1179          $s_char_options .= '<option value="other"' . (($first_char == 'other') ? ' selected="selected"' : '') . '>' . $user->lang['OTHER'] . '</option>';
1180   
1181          // Build a relevant pagination_url
1182          $params = $sort_params = array();
1183   
1184          // We do not use request_var() here directly to save some calls (not all variables are set)
1185          $check_params = array(
1186              'g'                => array('g', 0),
1187              'sk'            => array('sk', $default_key),
1188              'sd'            => array('sd', 'a'),
1189              'form'            => array('form', ''),
1190              'field'            => array('field', ''),
1191              'select_single'    => array('select_single', 0),
1192              'username'        => array('username', '', true),
1193              'email'            => array('email', ''),
1194              'icq'            => array('icq', ''),
1195              'aim'            => array('aim', ''),
1196              'yahoo'            => array('yahoo', ''),
1197              'msn'            => array('msn', ''),
1198              'jabber'        => array('jabber', ''),
1199              'search_group_id'    => array('search_group_id', 0),
1200              'joined_select'    => array('joined_select', 'lt'),
1201              'active_select'    => array('active_select', 'lt'),
1202              'count_select'    => array('count_select', 'eq'),
1203              'joined'        => array('joined', ''),
1204              'active'        => array('active', ''),
1205              'count'            => (request_var('count', '') !== '') ? array('count', 0) : array('count', ''),
1206              'ipdomain'        => array('ip', ''),
1207              'first_char'    => array('first_char', ''),
1208          );
1209   
1210          foreach ($check_params as $key => $call)
1211          {
1212              if (!isset($_REQUEST[$key]))
1213              {
1214                  continue;
1215              }
1216   
1217              $param = call_user_func_array('request_var', $call);
1218              $param = urlencode($key) . '=' . ((is_string($param)) ? urlencode($param) : $param);
1219              $params[] = $param;
1220   
1221              if ($key != 'sk' && $key != 'sd')
1222              {
1223                  $sort_params[] = $param;
1224              }
1225          }
1226   
1227          $u_hide_find_member = append_sid("{$phpbb_root_path}memberlist.$phpEx", implode('&amp;', $params));
1228   
1229          $params[] = "mode=$mode";
1230          $sort_params[] = "mode=$mode";
1231          $pagination_url = append_sid("{$phpbb_root_path}memberlist.$phpEx", implode('&amp;', $params));
1232          $sort_url = append_sid("{$phpbb_root_path}memberlist.$phpEx", implode('&amp;', $sort_params));
1233   
1234          unset($params, $sort_params);
1235   
1236          // Some search user specific data
1237          if ($mode == 'searchuser' && ($config['load_search'] || $auth->acl_get('a_')))
1238          {
1239              $group_selected = request_var('search_group_id', 0);
1240              $s_group_select = '<option value="0"' . ((!$group_selected) ? ' selected="selected"' : '') . '>&nbsp;</option>';
1241   
1242              if ($auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel'))
1243              {
1244                  $sql = 'SELECT group_id, group_name, group_type
1245                      FROM ' . GROUPS_TABLE . '
1246                      ORDER BY group_name ASC';
1247              }
1248              else
1249              {
1250                  $sql = 'SELECT g.group_id, g.group_name, g.group_type
1251                      FROM ' . GROUPS_TABLE . ' g
1252                      LEFT JOIN ' . USER_GROUP_TABLE . ' ug
1253                          ON (
1254                              g.group_id = ug.group_id
1255                              AND ug.user_id = ' . $user->data['user_id'] . '
1256                              AND ug.user_pending = 0
1257                          )
1258                      WHERE (g.group_type <> ' . GROUP_HIDDEN . ' OR ug.user_id = ' . $user->data['user_id'] . ')
1259                      ORDER BY g.group_name ASC';
1260              }
1261              $result = $db->sql_query($sql);
1262   
1263              while ($row = $db->sql_fetchrow($result))
1264              {
1265                  $s_group_select .= '<option value="' . $row['group_id'] . '"' . (($group_selected == $row['group_id']) ? ' selected="selected"' : '') . '>' . (($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name']) . '</option>';
1266              }
1267              $db->sql_freeresult($result);
1268   
1269              $template->assign_vars(array(
1270                  'USERNAME'    => $username,
1271                  'EMAIL'        => $email,
1272                  'ICQ'        => $icq,
1273                  'AIM'        => $aim,
1274                  'YAHOO'        => $yahoo,
1275                  'MSNM'        => $msn,
1276                  'JABBER'    => $jabber,
1277                  'JOINED'    => implode('-', $joined),
1278                  'ACTIVE'    => implode('-', $active),
1279                  'COUNT'        => $count,
1280                  'IP'        => $ipdomain,
1281   
1282                  'S_IP_SEARCH_ALLOWED'    => ($auth->acl_getf_global('m_info')) ? true : false,
1283                  'S_IN_SEARCH_POPUP'        => ($form && $field) ? true : false,
1284                  'S_SEARCH_USER'            => true,
1285                  'S_FORM_NAME'            => $form,
1286                  'S_FIELD_NAME'            => $field,
1287                  'S_SELECT_SINGLE'        => $select_single,
1288                  'S_COUNT_OPTIONS'        => $s_find_count,
1289                  'S_SORT_OPTIONS'        => $s_sort_key,
1290                  'S_JOINED_TIME_OPTIONS'    => $s_find_join_time,
1291                  'S_ACTIVE_TIME_OPTIONS'    => $s_find_active_time,
1292                  'S_GROUP_SELECT'        => $s_group_select,
1293                  'S_USER_SEARCH_ACTION'    => append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=searchuser&amp;form=$form&amp;field=$field"))
1294              );
1295          }
1296   
1297          // Get us some users :D
1298          $sql = "SELECT u.user_id
1299              FROM " . USERS_TABLE . " u
1300                  $sql_from
1301              WHERE u.user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ")
1302                  $sql_where
1303              ORDER BY $order_by";
1304          $result = $db->sql_query_limit($sql, $config['topics_per_page'], $start);
1305   
1306          $user_list = array();
1307          while ($row = $db->sql_fetchrow($result))
1308          {
1309              $user_list[] = (int) $row['user_id'];
1310          }
1311          $db->sql_freeresult($result);
1312   
1313          // So, did we get any users?
1314          if (sizeof($user_list))
1315          {
1316              // Session time?! Session time...
1317              $sql = 'SELECT session_user_id, MAX(session_time) AS session_time
1318                  FROM ' . SESSIONS_TABLE . '
1319                  WHERE session_time >= ' . (time() - $config['session_length']) . '
1320                      AND ' . $db->sql_in_set('session_user_id', $user_list) . '
1321                  GROUP BY session_user_id';
1322              $result = $db->sql_query($sql);
1323   
1324              $session_times = array();
1325              while ($row = $db->sql_fetchrow($result))
1326              {
1327                  $session_times[$row['session_user_id']] = $row['session_time'];
1328              }
1329              $db->sql_freeresult($result);
1330   
1331              // Do the SQL thang
1332              if ($mode == 'group')
1333              {
1334                  $sql = "SELECT u.*
1335                          $sql_select
1336                      FROM " . USERS_TABLE . " u
1337                          $sql_from
1338                      WHERE " . $db->sql_in_set('u.user_id', $user_list) . "
1339                          $sql_where_data";
1340              }
1341              else
1342              {
1343                  $sql = 'SELECT *
1344                      FROM ' . USERS_TABLE . '
1345                      WHERE ' . $db->sql_in_set('user_id', $user_list);
1346              }
1347              $result = $db->sql_query($sql);
1348   
1349              $id_cache = array();
1350              while ($row = $db->sql_fetchrow($result))
1351              {
1352                  $row['session_time'] = (!empty($session_times[$row['user_id']])) ? $session_times[$row['user_id']] : 0;
1353                  $row['last_visit'] = (!empty($row['session_time'])) ? $row['session_time'] : $row['user_lastvisit'];
1354   
1355                  $id_cache[$row['user_id']] = $row;
1356              }
1357              $db->sql_freeresult($result);
1358   
1359              // Load custom profile fields
1360              if ($config['load_cpf_memberlist'])
1361              {
1362                  include_once($phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx);
1363                  $cp = new custom_profile();
1364   
1365                  // Grab all profile fields from users in id cache for later use - similar to the poster cache
1366                  $profile_fields_cache = $cp->generate_profile_fields_template('grab', $user_list);
1367              }
1368   
1369              // If we sort by last active date we need to adjust the id cache due to user_lastvisit not being the last active date...
1370              if ($sort_key == 'l')
1371              {
1372                  $lesser_than = ($sort_dir == 'a') ? -1 : 1;
1373                  uasort($id_cache, create_function('$first, $second', "return (\$first['last_visit'] == \$second['last_visit']) ? 0 : ((\$first['last_visit'] < \$second['last_visit']) ? $lesser_than : ($lesser_than * -1));"));
1374              }
1375   
1376              for ($i = 0, $end = sizeof($user_list); $i < $end; ++$i)
1377              {
1378                  $user_id = $user_list[$i];
1379                  $row =& $id_cache[$user_id];
1380   
1381                  $cp_row = array();
1382                  if ($config['load_cpf_memberlist'])
1383                  {
1384                      $cp_row = (isset($profile_fields_cache[$user_id])) ? $cp->generate_profile_fields_template('show', false, $profile_fields_cache[$user_id]) : array();
1385                  }
1386   
1387                  $memberrow = array_merge(show_profile($row), array(
1388                      'ROW_NUMBER'        => $i + ($start + 1),
1389   
1390                      'S_CUSTOM_PROFILE'    => (isset($cp_row['row']) && sizeof($cp_row['row'])) ? true : false,
1391                      'S_GROUP_LEADER'    => (isset($row['group_leader']) && $row['group_leader']) ? true : false,
1392   
1393                      'U_VIEW_PROFILE'    => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile&amp;u=' . $user_id))
1394                  );
1395   
1396                  if (isset($cp_row['row']) && sizeof($cp_row['row']))
1397                  {
1398                      $memberrow = array_merge($memberrow, $cp_row['row']);
1399                  }
1400   
1401                  $template->assign_block_vars('memberrow', $memberrow);
1402   
1403                  if (isset($cp_row['blockrow']) && sizeof($cp_row['blockrow']))
1404                  {
1405                      foreach ($cp_row['blockrow'] as $field_data)
1406                      {
1407                          $template->assign_block_vars('memberrow.custom_fields', $field_data);
1408                      }
1409                  }
1410   
1411                  unset($id_cache[$user_id]);
1412              }
1413          }
1414   
1415          // Generate page
1416          $template->assign_vars(array(
1417              'PAGINATION'    => generate_pagination($pagination_url, $total_users, $config['topics_per_page'], $start),
1418              'PAGE_NUMBER'    => on_page($total_users, $config['topics_per_page'], $start),
1419              'TOTAL_USERS'    => ($total_users == 1) ? $user->lang['LIST_USER'] : sprintf($user->lang['LIST_USERS'], $total_users),
1420   
1421              'PROFILE_IMG'    => $user->img('icon_user_profile', $user->lang['PROFILE']),
1422              'PM_IMG'        => $user->img('icon_contact_pm', $user->lang['SEND_PRIVATE_MESSAGE']),
1423              'EMAIL_IMG'        => $user->img('icon_contact_email', $user->lang['EMAIL']),
1424              'WWW_IMG'        => $user->img('icon_contact_www', $user->lang['WWW']),
1425              'ICQ_IMG'        => $user->img('icon_contact_icq', $user->lang['ICQ']),
1426              'AIM_IMG'        => $user->img('icon_contact_aim', $user->lang['AIM']),
1427              'MSN_IMG'        => $user->img('icon_contact_msnm', $user->lang['MSNM']),
1428              'YIM_IMG'        => $user->img('icon_contact_yahoo', $user->lang['YIM']),
1429              'JABBER_IMG'    => $user->img('icon_contact_jabber', $user->lang['JABBER']),
1430              'SEARCH_IMG'    => $user->img('icon_user_search', $user->lang['SEARCH']),
1431   
1432              'U_FIND_MEMBER'            => ($config['load_search'] || $auth->acl_get('a_')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser') : '',
1433              'U_HIDE_FIND_MEMBER'    => ($mode == 'searchuser') ? $u_hide_find_member : '',
1434              'U_SORT_USERNAME'        => $sort_url . '&amp;sk=a&amp;sd=' . (($sort_key == 'a' && $sort_dir == 'a') ? 'd' : 'a'),
1435              'U_SORT_FROM'            => $sort_url . '&amp;sk=b&amp;sd=' . (($sort_key == 'b' && $sort_dir == 'a') ? 'd' : 'a'),
1436              'U_SORT_JOINED'            => $sort_url . '&amp;sk=c&amp;sd=' . (($sort_key == 'c' && $sort_dir == 'a') ? 'd' : 'a'),
1437              'U_SORT_POSTS'            => $sort_url . '&amp;sk=d&amp;sd=' . (($sort_key == 'd' && $sort_dir == 'a') ? 'd' : 'a'),
1438              'U_SORT_EMAIL'            => $sort_url . '&amp;sk=e&amp;sd=' . (($sort_key == 'e' && $sort_dir == 'a') ? 'd' : 'a'),
1439              'U_SORT_WEBSITE'        => $sort_url . '&amp;sk=f&amp;sd=' . (($sort_key == 'f' && $sort_dir == 'a') ? 'd' : 'a'),
1440              'U_SORT_LOCATION'        => $sort_url . '&amp;sk=b&amp;sd=' . (($sort_key == 'b' && $sort_dir == 'a') ? 'd' : 'a'),
1441              'U_SORT_ICQ'            => $sort_url . '&amp;sk=g&amp;sd=' . (($sort_key == 'g' && $sort_dir == 'a') ? 'd' : 'a'),
1442              'U_SORT_AIM'            => $sort_url . '&amp;sk=h&amp;sd=' . (($sort_key == 'h' && $sort_dir == 'a') ? 'd' : 'a'),
1443              'U_SORT_MSN'            => $sort_url . '&amp;sk=i&amp;sd=' . (($sort_key == 'i' && $sort_dir == 'a') ? 'd' : 'a'),
1444              'U_SORT_YIM'            => $sort_url . '&amp;sk=j&amp;sd=' . (($sort_key == 'j' && $sort_dir == 'a') ? 'd' : 'a'),
1445              'U_SORT_ACTIVE'            => ($auth->acl_get('u_viewonline')) ? $sort_url . '&amp;sk=l&amp;sd=' . (($sort_key == 'l' && $sort_dir == 'a') ? 'd' : 'a') : '',
1446              'U_SORT_RANK'            => $sort_url . '&amp;sk=m&amp;sd=' . (($sort_key == 'm' && $sort_dir == 'a') ? 'd' : 'a'),
1447              'U_LIST_CHAR'            => $sort_url . '&amp;sk=a&amp;sd=' . (($sort_key == 'l' && $sort_dir == 'a') ? 'd' : 'a'),
1448   
1449              'S_SHOW_GROUP'        => ($mode == 'group') ? true : false,
1450              'S_VIEWONLINE'        => $auth->acl_get('u_viewonline'),
1451              'S_MODE_SELECT'        => $s_sort_key,
1452              'S_ORDER_SELECT'    => $s_sort_dir,
1453              'S_CHAR_OPTIONS'    => $s_char_options,
1454              'S_MODE_ACTION'        => $pagination_url)
1455          );
1456  }
1457   
1458  // Output the page
1459  page_header($page_title);
1460   
1461  $template->set_filenames(array(
1462      'body' => $template_html)
1463  );
1464  make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx"));
1465   
1466  page_footer();
1467   
1468  /**
1469  * Prepare profile data
1470  */
1471  function show_profile($data)
1472  {
1473      global $config, $auth, $template, $user, $phpEx, $phpbb_root_path;
1474   
1475      $username = $data['username'];
1476      $user_id = $data['user_id'];
1477   
1478      $rank_title = $rank_img = $rank_img_src = '';
1479      get_user_rank($data['user_rank'], $data['user_posts'], $rank_title, $rank_img, $rank_img_src);
1480   
1481      if (!empty($data['user_allow_viewemail']) || $auth->acl_get('a_email'))
1482      {
1483          $email = ($config['board_email_form'] && $config['email_enable']) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=email&amp;u=' . $user_id) : (($config['board_hide_emails'] && !$auth->acl_get('a_email')) ? '' : 'mailto:' . $data['user_email']);
1484      }
1485      else
1486      {
1487          $email = '';
1488      }
1489   
1490      if ($config['load_onlinetrack'])
1491      {
1492          $update_time = $config['load_online_time'] * 60;
1493          $online = (time() - $update_time < $data['session_time'] && ((isset($data['session_viewonline']) && $data['session_viewonline']) || $auth->acl_get('u_viewonline'))) ? true : false;
1494      }
1495      else
1496      {
1497          $online = false;
1498      }
1499   
1500      if ($data['user_allow_viewonline'] || $auth->acl_get('u_viewonline'))
1501      {
1502          $last_visit = (!empty($data['session_time'])) ? $data['session_time'] : $data['user_lastvisit'];
1503      }
1504      else
1505      {
1506          $last_visit = '';
1507      }
1508   
1509      $age = '';
1510   
1511      if ($config['allow_birthdays'] && $data['user_birthday'])
1512      {
1513          list($bday_day, $bday_month, $bday_year) = array_map('intval', explode('-', $data['user_birthday']));
1514   
1515          if ($bday_year)
1516          {
1517              $now = getdate(time() + $user->timezone + $user->dst - date('Z'));
1518   
1519              $diff = $now['mon'] - $bday_month;
1520              if ($diff == 0)
1521              {
1522                  $diff = ($now['mday'] - $bday_day < 0) ? 1 : 0;
1523              }
1524              else
1525              {
1526                  $diff = ($diff < 0) ? 1 : 0;
1527              }
1528   
1529              $age = (int) ($now['year'] - $bday_year - $diff);
1530          }
1531      }
1532   
1533      // Dump it out to the template
1534      return array(
1535          'AGE'            => $age,
1536          'RANK_TITLE'    => $rank_title,
1537          'JOINED'        => $user->format_date($data['user_regdate']),
1538          'VISITED'        => (empty($last_visit)) ? ' - ' : $user->format_date($last_visit),
1539          'POSTS'            => ($data['user_posts']) ? $data['user_posts'] : 0,
1540          'WARNINGS'        => isset($data['user_warnings']) ? $data['user_warnings'] : 0,
1541   
1542          'USERNAME_FULL'        => get_username_string('full', $user_id, $username, $data['user_colour']),
1543          'USERNAME'            => get_username_string('username', $user_id, $username, $data['user_colour']),
1544          'USER_COLOR'        => get_username_string('colour', $user_id, $username, $data['user_colour']),
1545          'U_VIEW_PROFILE'    => get_username_string('profile', $user_id, $username, $data['user_colour']),
1546   
1547          'A_USERNAME'        => addslashes(get_username_string('username', $user_id, $username, $data['user_colour'])),
1548   
1549          'ONLINE_IMG'        => (!$config['load_onlinetrack']) ? '' : (($online) ? $user->img('icon_user_online', 'ONLINE') : $user->img('icon_user_offline', 'OFFLINE')),
1550          'S_ONLINE'            => ($config['load_onlinetrack'] && $online) ? true : false,
1551          'RANK_IMG'            => $rank_img,
1552          'RANK_IMG_SRC'        => $rank_img_src,
1553          'ICQ_STATUS_IMG'    => (!empty($data['user_icq'])) ? '<img src="http://web.icq.com/whitepages/online?icq=' . $data['user_icq'] . '&amp;img=5" width="18" height="18" />' : '',
1554          'S_JABBER_ENABLED'    => ($config['jab_enable']) ? true : false,
1555   
1556          'U_SEARCH_USER'    => ($auth->acl_get('u_search')) ? append_sid("{$phpbb_root_path}search.$phpEx", "author_id=$user_id&amp;sr=posts") : '',
1557          'U_NOTES'        => $auth->acl_getf_global('m_') ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&amp;mode=user_notes&amp;u=' . $user_id, true, $user->session_id) : '',
1558          'U_WARN'        => $auth->acl_get('m_warn') ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=warn&amp;mode=warn_user&amp;u=' . $user_id, true, $user->session_id) : '',
1559          'U_PM'            => ($config['allow_privmsg'] && $auth->acl_get('u_sendpm') && ($data['user_allow_pm'] || $auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_'))) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&amp;mode=compose&amp;u=' . $user_id) : '',
1560          'U_EMAIL'        => $email,
1561          'U_WWW'            => (!empty($data['user_website'])) ? $data['user_website'] : '',
1562          'U_ICQ'            => ($data['user_icq']) ? 'http://www.icq.com/people/webmsg.php?to=' . urlencode($data['user_icq']) : '',
1563          'U_AIM'            => ($data['user_aim'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contact&amp;action=aim&amp;u=' . $user_id) : '',
1564          'U_YIM'            => ($data['user_yim']) ? 'http://edit.yahoo.com/config/send_webmesg?.target=' . urlencode($data['user_yim']) . '&amp;.src=pg' : '',
1565          'U_MSN'            => ($data['user_msnm'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contact&amp;action=msnm&amp;u=' . $user_id) : '',
1566          'U_JABBER'        => ($data['user_jabber'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contact&amp;action=jabber&amp;u=' . $user_id) : '',
1567          'LOCATION'        => ($data['user_from']) ? $data['user_from'] : '',
1568   
1569          'USER_ICQ'            => $data['user_icq'],
1570          'USER_AIM'            => $data['user_aim'],
1571          'USER_YIM'            => $data['user_yim'],
1572          'USER_MSN'            => $data['user_msnm'],
1573          'USER_JABBER'        => $data['user_jabber'],
1574          'USER_JABBER_IMG'    => ($data['user_jabber']) ? $user->img('icon_contact_jabber', $data['user_jabber']) : '',
1575   
1576          'L_VIEWING_PROFILE'    => sprintf($user->lang['VIEWING_PROFILE'], $username),
1577      );
1578  }
1579   
1580  ?>