array('label', 'function', 'is_selected') $subActions = array( 'all' => array(&$txt[303], 'MLAll', $context['listing_by'] == 'all'), 'search' => array(&$txt['mlist_search'], 'MLSearch', $context['listing_by'] == 'search'), ); // Set up the sort links. $context['sort_links'] = array(); foreach ($subActions as $act => $text) $context['sort_links'][] = ($text[2] ? '> ' : '') . '' . $text[0] . ''; $context['sort_links'] = implode(' | ', $context['sort_links']); $context['num_members'] = $modSettings['memberCount']; // Set up the columns... $context['columns'] = array( 'isOnline' => array( 'label' => $txt['online8'], 'width' => '20' ), 'realName' => array( 'label' => $txt[35] ), 'emailAddress' => array( 'label' => $txt[307], 'width' => '25' ), 'websiteUrl' => array( 'label' => $txt[96], 'width' => '25' ), 'ICQ' => array( 'label' => $txt[513], 'width' => '25' ), 'AIM' => array( 'label' => $txt[603], 'width' => '25' ), 'YIM' => array( 'label' => $txt[604], 'width' => '25' ), 'MSN' => array( 'label' => $txt['MSN'], 'width' => '25' ), 'ID_GROUP' => array( 'label' => $txt[87] ), 'registered' => array( 'label' => $txt[233] ), 'posts' => array( 'label' => $txt[21], 'width' => '115', 'colspan' => '2' ) ); $context['linktree'][] = array( 'url' => $scripturl . '?action=mlist', 'name' => &$txt[332] ); $context['can_send_pm'] = allowedTo('pm_send'); // Jump to the sub action. if (isset($subActions[$context['listing_by']])) $subActions[$context['listing_by']][1](); else $subActions['all'][1](); } // List all members, page by page. function MLAll() { global $txt, $scripturl, $db_prefix, $user_info; global $modSettings, $context; // Set defaults for sort (realName) and start. (0) if (!isset($_REQUEST['sort']) || !array_key_exists($_REQUEST['sort'], $context['columns'])) $_REQUEST['sort'] = 'realName'; if (!is_numeric($_REQUEST['start'])) { $_REQUEST['start'] = strtolower(substr($_REQUEST['start'], 0, 1)); if (preg_match('~([\da-z])~', $_REQUEST['start'], $match) == false) fatal_error('Hacker?', false); $request = db_query(" SELECT COUNT(ID_MEMBER) FROM {$db_prefix}members WHERE LOWER(SUBSTRING(realName, 1, 1)) < '$_REQUEST[start]'", __FILE__, __LINE__); list ($_REQUEST['start']) = mysql_fetch_row($request); mysql_free_result($request); } $context['letter_links'] = ''; for ($i = 97; $i < 123; $i++) $context['letter_links'] .= '' . strtoupper(chr($i)) . ' '; // Sort out the column information. foreach ($context['columns'] as $col => $dummy) { $context['columns'][$col]['href'] = $scripturl . '?action=mlist;sort=' . $col . ';start=0'; if (!isset($_REQUEST['desc']) && $col == $_REQUEST['sort']) $context['columns'][$col]['href'] .= ';desc'; $context['columns'][$col]['link'] = '' . $context['columns'][$col]['label'] . ''; $context['columns'][$col]['selected'] = $_REQUEST['sort'] == $col; } $context['sort_by'] = $_REQUEST['sort']; $context['sort_direction'] = !isset($_REQUEST['desc']) ? 'down' : 'up'; // Construct the page index. $context['page_index'] = constructPageIndex($scripturl . '?action=mlist;sort=' . $_REQUEST['sort'] . (isset($_REQUEST['desc']) ? ';desc' : ''), $_REQUEST['start'], $modSettings['memberCount'], $modSettings['defaultMaxMembers']); // Send the data to the template. $context['start'] = $_REQUEST['start'] + 1; $context['end'] = min($_REQUEST['start'] + $modSettings['defaultMaxMembers'], $modSettings['memberCount']); $context['page_title'] = $txt[308] . ' ' . $context['start'] . ' ' . $txt[311] . ' ' . $context['end']; $context['linktree'][] = array( 'url' => $scripturl . '?action=mlist;sort=' . $_REQUEST['sort'] . ';start=' . $_REQUEST['start'], 'name' => &$context['page_title'], 'extra_after' => ' (' . $txt[309] . ' ' . $context['num_members'] . ' ' . $txt[310] . ')' ); // List out the different sorting methods... $sort_methods = array( 'isOnline' => array( 'down' => '(ISNULL(lo.logTime)' . (!allowedTo('moderate_forum') ? ' OR NOT mem.showOnline' : '') . ') ASC, realName ASC', 'up' => '(ISNULL(lo.logTime)' . (!allowedTo('moderate_forum') ? ' OR NOT mem.showOnline' : '') . ') DESC, realName DESC' ), 'realName' => array( 'down' => 'mem.realName ASC', 'up' => 'mem.realName DESC' ), 'emailAddress' => array( 'down' => (allowedTo('moderate_forum') || empty($modSettings['allow_hideEmail'])) ? 'mem.emailAddress ASC' : 'mem.hideEmail ASC, mem.emailAddress ASC', 'up' => (allowedTo('moderate_forum') || empty($modSettings['allow_hideEmail'])) ? 'mem.emailAddress DESC' : 'mem.hideEmail DESC, mem.emailAddress DESC' ), 'websiteUrl' => array( 'down' => 'LENGTH(mem.websiteURL) > 0 DESC, ISNULL(mem.websiteURL) ASC, mem.websiteURL ASC', 'up' => 'LENGTH(mem.websiteURL) > 0 ASC, ISNULL(mem.websiteURL) DESC, mem.websiteURL DESC' ), 'ICQ' => array( 'down' => 'LENGTH(mem.ICQ) > 0 DESC, ISNULL(mem.ICQ) OR mem.ICQ = 0 ASC, mem.ICQ ASC', 'up' => 'LENGTH(mem.ICQ) > 0 ASC, ISNULL(mem.ICQ) OR mem.ICQ = 0 DESC, mem.ICQ DESC' ), 'AIM' => array( 'down' => 'LENGTH(mem.AIM) > 0 DESC, ISNULL(mem.AIM) ASC, mem.AIM ASC', 'up' => 'LENGTH(mem.AIM) > 0 ASC, ISNULL(mem.AIM) DESC, mem.AIM DESC' ), 'YIM' => array( 'down' => 'LENGTH(mem.YIM) > 0 DESC, ISNULL(mem.YIM) ASC, mem.YIM ASC', 'up' => 'LENGTH(mem.YIM) > 0 ASC, ISNULL(mem.YIM) DESC, mem.YIM DESC' ), 'MSN' => array( 'down' => 'LENGTH(mem.MSN) > 0 DESC, ISNULL(mem.MSN) ASC, mem.MSN ASC', 'up' => 'LENGTH(mem.MSN) > 0 ASC, ISNULL(mem.MSN) DESC, mem.MSN DESC' ), 'registered' => array( 'down' => 'mem.dateRegistered ASC', 'up' => 'mem.dateRegistered DESC' ), 'ID_GROUP' => array( 'down' => 'ISNULL(mg.groupName) ASC, mg.groupName ASC', 'up' => 'ISNULL(mg.groupName) DESC, mg.groupName DESC' ), 'posts' => array( 'down' => 'mem.posts DESC', 'up' => 'mem.posts ASC' ) ); // Select the members from the database. $request = db_query(" SELECT mem.memberName, mem.realName, mem.websiteTitle, mem.websiteUrl, mem.posts, mem.ID_GROUP, mem.ICQ, mem.AIM, mem.YIM, mem.MSN, mem.emailAddress, mem.hideEmail, mem.ID_MEMBER, IFNULL(lo.logTime, 0) AS isOnline, IFNULL(mg.groupName, '') AS groupName, mem.showOnline, mem.dateRegistered FROM {$db_prefix}members AS mem LEFT JOIN {$db_prefix}log_online AS lo ON (lo.ID_MEMBER = mem.ID_MEMBER) LEFT JOIN {$db_prefix}membergroups AS mg ON (mg.ID_GROUP = IF(mem.ID_GROUP = 0, mem.ID_POST_GROUP, mem.ID_GROUP)) ORDER BY " . $sort_methods[$_REQUEST['sort']][$context['sort_direction']] . " LIMIT $_REQUEST[start], $modSettings[defaultMaxMembers]", __FILE__, __LINE__); printMemberListRows($request); } // Search for members... function MLSearch() { global $txt, $scripturl, $db_prefix, $context, $user_info, $modSettings; $context['page_title'] = $txt['mlist_search']; // They're searching.. if (isset($_POST['search']) || isset($_REQUEST['fields'])) { $_POST['search'] = isset($_GET['search']) ? $_GET['search'] : $_POST['search']; $_POST['fields'] = isset($_GET['fields']) ? explode(',', $_GET['fields']) : $_POST['fields']; $context['old_search'] = $_REQUEST['search']; $context['old_search_value'] = urlencode($_REQUEST['search']); // No fields? Use default... if (empty($_POST['fields'])) $_POST['fields'] = array('name'); // Search for a name? if (in_array('name', $_POST['fields'])) $fields = array('memberName', 'realName'); else $fields = array(); // Search for messengers... if (in_array('messenger', $_POST['fields']) && (!$user_info['is_guest'] || empty($modSettings['guest_hideContacts']))) $fields += array(3 => 'MSN', 'AIM', 'ICQ', 'YIM'); // Search for websites. if (in_array('website', $_POST['fields'])) $fields += array(7 => 'websiteTitle', 'websiteUrl'); // Search for groups. if (in_array('group', $_POST['fields'])) $fields += array(9 => 'IFNULL(groupName, \'\')'); // Search for an email address? if (in_array('email', $_POST['fields'])) { $fields += array(2 => allowedTo('moderate_forum') ? 'emailAddress' : '(hideEmail = 0 AND emailAddress'); $condition = allowedTo('moderate_forum') ? '' : ')'; } else $condition = ''; $query = $_POST['search'] == '' ? "= ''" : "LIKE '%" . $_POST['search'] . "%'"; $request = db_query(" SELECT COUNT(ID_MEMBER) FROM {$db_prefix}members AS mem LEFT JOIN {$db_prefix}membergroups AS mg ON (mg.ID_GROUP = IF(mem.ID_GROUP = 0, mem.ID_POST_GROUP, mem.ID_GROUP)) WHERE " . implode(" $query OR ", $fields) . " $query$condition", __FILE__, __LINE__); list ($numResults) = mysql_fetch_row($request); mysql_free_result($request); $context['page_index'] = constructPageIndex($scripturl . '?action=mlist;sa=search;search=' . $_POST['search'] . ';fields=' . implode(',', $_POST['fields']), $_REQUEST['start'], $numResults, $modSettings['defaultMaxMembers']); // Find the members from the database. $request = db_query(" SELECT memberName, realName, websiteTitle, websiteUrl, posts, mem.ID_GROUP, ICQ, AIM, YIM, MSN, emailAddress, hideEmail, mem.ID_MEMBER, IFNULL(lo.logTime, 0) AS isOnline, IFNULL(mg.groupName, '') AS groupName, mem.dateRegistered FROM {$db_prefix}members AS mem LEFT JOIN {$db_prefix}log_online AS lo ON (lo.ID_MEMBER = mem.ID_MEMBER) LEFT JOIN {$db_prefix}membergroups AS mg ON (mg.ID_GROUP = IF(mem.ID_GROUP = 0, mem.ID_POST_GROUP, mem.ID_GROUP)) WHERE " . implode(" $query OR ", $fields) . " $query$condition LIMIT $_REQUEST[start], $modSettings[defaultMaxMembers]", __FILE__, __LINE__); printMemberListRows($request); mysql_free_result($request); } else { $context['sub_template'] = 'search'; $context['old_search'] = isset($_REQUEST['search']) ? htmlspecialchars($_REQUEST['search']) : ''; } $context['linktree'][] = array( 'url' => $scripturl . '?action=mlist;sa=search', 'name' => &$context['page_title'] ); } function printMemberListRows($request) { global $scripturl, $txt, $db_prefix, $user_info, $modSettings; global $context, $settings, $months; // Get the most posts. $result = db_query(" SELECT MAX(posts) FROM {$db_prefix}members", __FILE__, __LINE__); list ($MOST_POSTS) = mysql_fetch_row($result); mysql_free_result($result); // Avoid division by zero... if ($MOST_POSTS == 0) $MOST_POSTS = 1; // Load all the members for display. $context['members'] = array(); while ($row = mysql_fetch_assoc($request)) { $is_online = (!empty($row['showOnline']) || allowedTo('moderate_forum')) && $row['isOnline'] > 0; // If contact details are hidden... respect them. if (!empty($modSettings['guest_hideContacts']) && $user_info['is_guest']) { $row['ICQ'] = ''; $row['MSN'] = ''; $row['YIM'] = ''; $row['AOL'] = ''; } $context['members'][$row['ID_MEMBER']] = array( 'username' => $row['memberName'], 'name' => $row['realName'], 'id' => $row['ID_MEMBER'], 'href' => $scripturl . '?action=profile;u=' . $row['ID_MEMBER'], 'link' => '' . $row['realName'] . '', 'online' => array( 'is_online' => $is_online, 'text' => &$txt[$is_online ? 'online2' : 'online3'], 'href' => $scripturl . '?action=pm;sa=send;u=' . $row['ID_MEMBER'], 'link' => '' . $txt[$is_online ? 'online2' : 'online3'] . '', 'image_href' => $settings['images_url'] . ($is_online ? '/useron.gif' : '/useroff.gif'), 'label' => &$txt[$is_online ? 'online4' : 'online5'] ), 'email' => (!empty($modSettings['guest_hideContacts']) && $user_info['is_guest']) || ($row['hideEmail'] && !allowedTo('moderate_forum') && !empty($modSettings['allow_hideEmail'])) ? '' : '' . $txt[69] . '', 'website' => array( 'title' => !isset($row['websiteTitle']) || $row['websiteTitle'] == '' ? $txt[96] : $row['websiteTitle'], 'href' => !isset($row['websiteUrl']) || $row['websiteUrl'] == '' ? '' : $row['websiteUrl'], ), 'icq' => array( 'name' => $row['ICQ'], 'href' => !empty($row['ICQ']) ? 'http://www.icq.com/people/about_me.php?uin=' . $row['ICQ'] : '', 'link' => !empty($row['ICQ']) ? '' . $row['ICQ'] . '' : '' ), 'aim' => array( 'name' => $row['AIM'], 'href' => !empty($row['AIM']) ? 'aim:goim?screenname=' . $row['AIM'] . '&message=' . $txt['aim_default_message'] : '', 'link' => !empty($row['AIM']) ? '' . $row['AIM'] . '' : '' ), 'msn' => array( 'name' => $row['MSN'], 'href' => !empty($row['MSN']) ? 'http://members.msn.com/' . $row['MSN'] : '', 'link' => !empty($row['MSN']) ? '' . $row['MSN'] . '' : '' ), 'yim' => array( 'name' => $row['YIM'], 'href' => !empty($row['YIM']) ? 'http://opi.yahoo.com/online?u=' . $row['YIM'] . '&m=g&t=0' : '', 'link' => !empty($row['YIM']) ? '' . $row['YIM'] . '' : '' ), 'group' => $row['groupName'], 'registered' => strftime('%d %b %Y ' . (strpos($user_info['time_format'], '%H') !== false ? '%I:%M:%S %p' : '%T'), $row['dateRegistered'] + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600), 'posts' => $row['posts'] > 100000 ? $txt[683] : ($row['posts'] == 1337 ? 'leet' : $row['posts']), 'post_percent' => round(($row['posts'] * 100) / $MOST_POSTS) ); $context['members'][$row['ID_MEMBER']]['website']['link'] = $row['websiteUrl'] != '' ? '' . htmlspecialchars($context['members'][$row['ID_MEMBER']]['website']['title']) . '' : ''; } } ?>