function Who() { global $db_prefix, $context, $scripturl, $user_info, $txt, $modSettings, $ID_MEMBER, $memberContext; // Permissions, permissions, permissions. isAllowedTo('who_view'); // You can't do anything if this is off. if (empty($modSettings['who_enabled'])) { fatal_lang_error('who_off', false); } // Load the 'Who' template. loadTemplate('Who'); // Sort out... the column sorting. $sort_methods = array('user' => 'mem.realName', 'time' => 'lo.logTime'); // By default order by last time online. if (!isset($_REQUEST['sort']) || !isset($sort_methods[$_REQUEST['sort']])) { $context['sort_by'] = 'time'; $_REQUEST['sort'] = 'lo.logTime'; } else { $context['sort_by'] = $_REQUEST['sort']; $_REQUEST['sort'] = $sort_methods[$_REQUEST['sort']]; } $context['sort_direction'] = isset($_REQUEST['asc']) ? 'up' : 'down'; // Get the total amount of members online. $request = db_query("\n\t\tSELECT COUNT(*)\n\t\tFROM {$db_prefix}log_online AS lo\n\t\t\tLEFT JOIN {$db_prefix}members AS mem ON (lo.ID_MEMBER = mem.ID_MEMBER)" . (!allowedTo('moderate_forum') ? "\n\t\tWHERE IFNULL(mem.showOnline, 1) = 1" : ''), __FILE__, __LINE__); list($totalMembers) = mysql_fetch_row($request); mysql_free_result($request); // Prepare some page index variables. $context['page_index'] = constructPageIndex($scripturl . '?action=who;sort=' . $context['sort_by'] . (isset($_REQUEST['asc']) ? ';asc' : ''), $_REQUEST['start'], $totalMembers, $modSettings['defaultMaxMembers']); $context['start'] = $_REQUEST['start']; // Look for people online, provided they don't mind if you see they are. $request = db_query("\n\t\tSELECT\n\t\t\t(UNIX_TIMESTAMP(lo.logTime) - UNIX_TIMESTAMP() + " . time() . ") AS logTime,\n\t\t\tlo.ID_MEMBER, lo.url, INET_NTOA(lo.ip) AS ip, mem.realName, lo.session,\n\t\t\tmg.onlineColor, IFNULL(mem.showOnline, 1) AS showOnline\n\t\tFROM {$db_prefix}log_online AS lo\n\t\t\tLEFT JOIN {$db_prefix}members AS mem ON (lo.ID_MEMBER = mem.ID_MEMBER)\n\t\t\tLEFT JOIN {$db_prefix}membergroups AS mg ON (mg.ID_GROUP = IF(mem.ID_GROUP = 0, mem.ID_POST_GROUP, mem.ID_GROUP))" . (!allowedTo('moderate_forum') ? "\n\t\tWHERE IFNULL(mem.showOnline, 1) = 1" : '') . "\n\t\tORDER BY {$_REQUEST['sort']} " . (isset($_REQUEST['asc']) ? 'ASC' : 'DESC') . "\n\t\tLIMIT {$context['start']}, {$modSettings['defaultMaxMembers']}", __FILE__, __LINE__); $context['members'] = array(); $member_ids = array(); $url_data = array(); while ($row = mysql_fetch_assoc($request)) { $actions = @unserialize($row['url']); if ($actions === false) { continue; } // Send the information to the template. $context['members'][$row['session']] = array('id' => $row['ID_MEMBER'], 'ip' => allowedTo('moderate_forum') ? $row['ip'] : '', 'time' => strtr(timeformat($row['logTime']), array($txt['smf10'] => '', $txt['smf10b'] => '')), 'timestamp' => forum_time(true, $row['logTime']), 'query' => $actions, 'is_hidden' => $row['showOnline'] == 0, 'color' => empty($row['onlineColor']) ? '' : $row['onlineColor']); $url_data[$row['session']] = array($row['url'], $row['ID_MEMBER']); $member_ids[] = $row['ID_MEMBER']; } mysql_free_result($request); // Load the user data for these members. loadMemberData($member_ids); // Load up the guest user. $memberContext[0] = array('id' => 0, 'name' => $txt[28], 'group' => $txt[28], 'href' => '', 'link' => $txt[28], 'email' => $txt[28], 'is_guest' => true); $url_data = determineActions($url_data); // Setup the linktree and page title (do it down here because the language files are now loaded..) $context['page_title'] = $txt['who_title']; $context['linktree'][] = array('url' => $scripturl . '?action=who', 'name' => $txt['who_title']); // Put it in the context variables. foreach ($context['members'] as $i => $member) { if ($member['id'] != 0) { $member['id'] = loadMemberContext($member['id']) ? $member['id'] : 0; } // Keep the IP that came from the database. $memberContext[$member['id']]['ip'] = $member['ip']; $context['members'][$i]['action'] = isset($url_data[$i]) ? $url_data[$i] : $txt['who_hidden']; $context['members'][$i] += $memberContext[$member['id']]; } // Some people can't send personal messages... $context['can_send_pm'] = allowedTo('pm_send'); }
function SpiderLogs() { global $context, $txt, $sourcedir, $scripturl, $smcFunc, $modSettings; // Load the template and language just incase. loadLanguage('Search'); loadTemplate('ManageSearch'); // Did they want to delete some entries? if (!empty($_POST['delete_entries']) && isset($_POST['older'])) { checkSession(); $deleteTime = time() - (int) $_POST['older'] * 24 * 60 * 60; // Delete the entires. $smcFunc['db_query']('', ' DELETE FROM {db_prefix}log_spider_hits WHERE log_time < {int:delete_period}', array('delete_period' => $deleteTime)); } $listOptions = array('id' => 'spider_logs', 'items_per_page' => 20, 'title' => $txt['spider_logs'], 'no_items_label' => $txt['spider_logs_empty'], 'base_href' => $context['admin_area'] == 'sengines' ? $scripturl . '?action=admin;area=sengines;sa=logs' : $scripturl . '?action=admin;area=logs;sa=spiderlog', 'default_sort_col' => 'log_time', 'get_items' => array('function' => 'list_getSpiderLogs'), 'get_count' => array('function' => 'list_getNumSpiderLogs'), 'columns' => array('name' => array('header' => array('value' => $txt['spider']), 'data' => array('db' => 'spider_name'), 'sort' => array('default' => 's.spider_name', 'reverse' => 's.spider_name DESC')), 'log_time' => array('header' => array('value' => $txt['spider_time']), 'data' => array('function' => create_function('$rowData', ' return timeformat($rowData[\'log_time\']); ')), 'sort' => array('default' => 'sl.id_hit DESC', 'reverse' => 'sl.id_hit')), 'viewing' => array('header' => array('value' => $txt['spider_viewing']), 'data' => array('db' => 'url'))), 'additional_rows' => array(array('position' => 'after_title', 'value' => $txt['spider_logs_info'], 'class' => 'smalltext'))); require_once $sourcedir . '/Subs-List.php'; createList($listOptions); // Now determine the actions of the URLs. if (!empty($context['spider_logs']['rows'])) { $urls = array(); // Grab the current /url. foreach ($context['spider_logs']['rows'] as $k => $row) { // Feature disabled? if (empty($row['viewing']['value']) && isset($modSettings['spider_mode']) && $modSettings['spider_mode'] < 3) { $context['spider_logs']['rows'][$k]['viewing']['value'] = '<em>' . $txt['spider_disabled'] . '</em>'; } else { $urls[$k] = array($row['viewing']['value'], -1); } } // Now stick in the new URLs. require_once $sourcedir . '/Who.php'; $urls = determineActions($urls, 'whospider_'); foreach ($urls as $k => $new_url) { $context['spider_logs']['rows'][$k]['viewing']['value'] = $new_url; } } $context['page_title'] = $txt['spider_logs']; $context['sub_template'] = 'show_spider_logs'; $context['default_list'] = 'spider_logs'; }
function Who() { global $context, $scripturl, $user_info, $txt, $modSettings, $memberContext, $smcFunc; // Permissions, permissions, permissions. isAllowedTo('who_view'); // You can't do anything if this is off. if (empty($modSettings['who_enabled'])) { fatal_lang_error('who_off', false); } // Load the 'Who' template. loadTemplate('Who'); loadLanguage('Who'); // Sort out... the column sorting. $sort_methods = array('user' => 'mem.real_name', 'time' => 'lo.log_time'); $show_methods = array('members' => '(lo.id_member != 0)', 'guests' => '(lo.id_member = 0)', 'all' => '1=1'); // Store the sort methods and the show types for use in the template. $context['sort_methods'] = array('user' => $txt['who_user'], 'time' => $txt['who_time']); $context['show_methods'] = array('all' => $txt['who_show_all'], 'members' => $txt['who_show_members_only'], 'guests' => $txt['who_show_guests_only']); // Can they see spiders too? if (!empty($modSettings['show_spider_online']) && ($modSettings['show_spider_online'] == 2 || allowedTo('admin_forum')) && !empty($modSettings['spider_name_cache'])) { $show_methods['spiders'] = '(lo.id_member = 0 AND lo.id_spider > 0)'; $show_methods['guests'] = '(lo.id_member = 0 AND lo.id_spider = 0)'; $context['show_methods']['spiders'] = $txt['who_show_spiders_only']; } elseif (empty($modSettings['show_spider_online']) && isset($_SESSION['who_online_filter']) && $_SESSION['who_online_filter'] == 'spiders') { unset($_SESSION['who_online_filter']); } // Does the user prefer a different sort direction? if (isset($_REQUEST['sort']) && isset($sort_methods[$_REQUEST['sort']])) { $context['sort_by'] = $_SESSION['who_online_sort_by'] = $_REQUEST['sort']; $sort_method = $sort_methods[$_REQUEST['sort']]; } elseif (isset($_SESSION['who_online_sort_by'])) { $context['sort_by'] = $_SESSION['who_online_sort_by']; $sort_method = $sort_methods[$_SESSION['who_online_sort_by']]; } else { $context['sort_by'] = $_SESSION['who_online_sort_by'] = 'time'; $sort_method = 'lo.log_time'; } $context['sort_direction'] = isset($_REQUEST['asc']) || isset($_REQUEST['sort_dir']) && $_REQUEST['sort_dir'] == 'asc' ? 'up' : 'down'; $conditions = array(); if (!allowedTo('moderate_forum')) { $conditions[] = '(IFNULL(mem.show_online, 1) = 1)'; } // Fallback to top filter? if (isset($_REQUEST['submit_top']) && isset($_REQUEST['show_top'])) { $_REQUEST['show'] = $_REQUEST['show_top']; } // Does the user wish to apply a filter? if (isset($_REQUEST['show']) && isset($show_methods[$_REQUEST['show']])) { $context['show_by'] = $_SESSION['who_online_filter'] = $_REQUEST['show']; $conditions[] = $show_methods[$_REQUEST['show']]; } elseif (isset($_SESSION['who_online_filter'])) { $context['show_by'] = $_SESSION['who_online_filter']; $conditions[] = $show_methods[$_SESSION['who_online_filter']]; } else { $context['show_by'] = $_SESSION['who_online_filter'] = 'all'; } // Get the total amount of members online. $request = $smcFunc['db_query']('', ' SELECT COUNT(*) FROM {db_prefix}log_online AS lo LEFT JOIN {db_prefix}members AS mem ON (lo.id_member = mem.id_member)' . (!empty($conditions) ? ' WHERE ' . implode(' AND ', $conditions) : ''), array()); list($totalMembers) = $smcFunc['db_fetch_row']($request); $smcFunc['db_free_result']($request); // Prepare some page index variables. $context['page_index'] = constructPageIndex($scripturl . '?action=who;sort=' . $context['sort_by'] . ($context['sort_direction'] == 'up' ? ';asc' : '') . ';show=' . $context['show_by'], $_REQUEST['start'], $totalMembers, $modSettings['defaultMaxMembers']); $context['start'] = $_REQUEST['start']; // Look for people online, provided they don't mind if you see they are. $request = $smcFunc['db_query']('', ' SELECT lo.log_time, lo.id_member, lo.url, INET_NTOA(lo.ip) AS ip, mem.real_name, lo.session, mg.online_color, IFNULL(mem.show_online, 1) AS show_online, lo.id_spider FROM {db_prefix}log_online AS lo LEFT JOIN {db_prefix}members AS mem ON (lo.id_member = mem.id_member) LEFT JOIN {db_prefix}membergroups AS mg ON (mg.id_group = CASE WHEN mem.id_group = {int:regular_member} THEN mem.id_post_group ELSE mem.id_group END)' . (!empty($conditions) ? ' WHERE ' . implode(' AND ', $conditions) : '') . ' ORDER BY {raw:sort_method} {raw:sort_direction} LIMIT {int:offset}, {int:limit}', array('regular_member' => 0, 'sort_method' => $sort_method, 'sort_direction' => $context['sort_direction'] == 'up' ? 'ASC' : 'DESC', 'offset' => $context['start'], 'limit' => $modSettings['defaultMaxMembers'])); $context['members'] = array(); $member_ids = array(); $url_data = array(); while ($row = $smcFunc['db_fetch_assoc']($request)) { $actions = @unserialize($row['url']); if ($actions === false) { continue; } // Send the information to the template. $context['members'][$row['session']] = array('id' => $row['id_member'], 'ip' => allowedTo('moderate_forum') ? $row['ip'] : '', 'time' => strtr(timeformat($row['log_time']), array($txt['today'] => '', $txt['yesterday'] => '')), 'timestamp' => forum_time(true, $row['log_time']), 'query' => $actions, 'is_hidden' => $row['show_online'] == 0, 'id_spider' => $row['id_spider'], 'color' => empty($row['online_color']) ? '' : $row['online_color']); $url_data[$row['session']] = array($row['url'], $row['id_member']); $member_ids[] = $row['id_member']; } $smcFunc['db_free_result']($request); // Load the user data for these members. loadMemberData($member_ids); // Load up the guest user. $memberContext[0] = array('id' => 0, 'name' => $txt['guest_title'], 'group' => $txt['guest_title'], 'href' => '', 'link' => $txt['guest_title'], 'email' => $txt['guest_title'], 'is_guest' => true); // Are we showing spiders? $spiderContext = array(); if (!empty($modSettings['show_spider_online']) && ($modSettings['show_spider_online'] == 2 || allowedTo('admin_forum')) && !empty($modSettings['spider_name_cache'])) { foreach (unserialize($modSettings['spider_name_cache']) as $id => $name) { $spiderContext[$id] = array('id' => 0, 'name' => $name, 'group' => $txt['spiders'], 'href' => '', 'link' => $name, 'email' => $name, 'is_guest' => true); } } $url_data = determineActions($url_data); // Setup the linktree and page title (do it down here because the language files are now loaded..) $context['page_title'] = $txt['who_title']; $context['linktree'][] = array('url' => $scripturl . '?action=who', 'name' => $txt['who_title']); // Put it in the context variables. foreach ($context['members'] as $i => $member) { if ($member['id'] != 0) { $member['id'] = loadMemberContext($member['id']) ? $member['id'] : 0; } // Keep the IP that came from the database. $memberContext[$member['id']]['ip'] = $member['ip']; $context['members'][$i]['action'] = isset($url_data[$i]) ? $url_data[$i] : $txt['who_hidden']; if ($member['id'] == 0 && isset($spiderContext[$member['id_spider']])) { $context['members'][$i] += $spiderContext[$member['id_spider']]; } else { $context['members'][$i] += $memberContext[$member['id']]; } } // Some people can't send personal messages... $context['can_send_pm'] = allowedTo('pm_send'); // any profile fields disabled? $context['disabled_fields'] = isset($modSettings['disabled_profile_fields']) ? array_flip(explode(',', $modSettings['disabled_profile_fields'])) : array(); }
function summary($memID) { global $context, $memberContext, $txt, $modSettings, $user_info, $user_profile, $sourcedir, $scripturl, $smcFunc; // Attempt to load the member's profile data. if (!loadMemberContext($memID) || !isset($memberContext[$memID])) { fatal_lang_error('not_a_user', false); } // Set up the stuff and load the user. $context += array('page_title' => sprintf($txt['profile_of_username'], $memberContext[$memID]['name']), 'can_send_pm' => allowedTo('pm_send'), 'can_have_buddy' => allowedTo('profile_identity_own') && !empty($modSettings['enable_buddylist']), 'can_issue_warning' => in_array('w', $context['admin_features']) && allowedTo('issue_warning') && $modSettings['warning_settings'][0] == 1); $context['member'] =& $memberContext[$memID]; $context['can_view_warning'] = in_array('w', $context['admin_features']) && (allowedTo('issue_warning') && !$context['user']['is_owner']) || !empty($modSettings['warning_show']) && ($modSettings['warning_show'] > 1 || $context['user']['is_owner']); // Set a canonical URL for this page. $context['canonical_url'] = $scripturl . '?action=profile;u=' . $memID; // Are there things we don't show? $context['disabled_fields'] = isset($modSettings['disabled_profile_fields']) ? array_flip(explode(',', $modSettings['disabled_profile_fields'])) : array(); // See if they have broken any warning levels... list($modSettings['warning_enable'], $modSettings['user_limit']) = explode(',', $modSettings['warning_settings']); if (!empty($modSettings['warning_mute']) && $modSettings['warning_mute'] <= $context['member']['warning']) { $context['warning_status'] = $txt['profile_warning_is_muted']; } elseif (!empty($modSettings['warning_moderate']) && $modSettings['warning_moderate'] <= $context['member']['warning']) { $context['warning_status'] = $txt['profile_warning_is_moderation']; } elseif (!empty($modSettings['warning_watch']) && $modSettings['warning_watch'] <= $context['member']['warning']) { $context['warning_status'] = $txt['profile_warning_is_watch']; } // They haven't even been registered for a full day!? $days_registered = (int) ((time() - $user_profile[$memID]['date_registered']) / (3600 * 24)); if (empty($user_profile[$memID]['date_registered']) || $days_registered < 1) { $context['member']['posts_per_day'] = $txt['not_applicable']; } else { $context['member']['posts_per_day'] = comma_format($context['member']['real_posts'] / $days_registered, 3); } // Set the age... if (empty($context['member']['birth_date'])) { $context['member'] += array('age' => $txt['not_applicable'], 'today_is_birthday' => false); } else { list($birth_year, $birth_month, $birth_day) = sscanf($context['member']['birth_date'], '%d-%d-%d'); $datearray = getdate(forum_time()); $context['member'] += array('age' => $birth_year <= 4 ? $txt['not_applicable'] : $datearray['year'] - $birth_year - ($datearray['mon'] > $birth_month || $datearray['mon'] == $birth_month && $datearray['mday'] >= $birth_day ? 0 : 1), 'today_is_birthday' => $datearray['mon'] == $birth_month && $datearray['mday'] == $birth_day); } if (allowedTo('moderate_forum')) { // Make sure it's a valid ip address; otherwise, don't bother... if (preg_match('/^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$/', $memberContext[$memID]['ip']) == 1 && empty($modSettings['disableHostnameLookup'])) { $context['member']['hostname'] = host_from_ip($memberContext[$memID]['ip']); } else { $context['member']['hostname'] = ''; } $context['can_see_ip'] = true; } else { $context['can_see_ip'] = false; } if (!empty($modSettings['who_enabled'])) { include_once $sourcedir . '/Who.php'; $action = determineActions($user_profile[$memID]['url']); if ($action !== false) { $context['member']['action'] = $action; } } // If the user is awaiting activation, and the viewer has permission - setup some activation context messages. if ($context['member']['is_activated'] % 10 != 1 && allowedTo('moderate_forum')) { $context['activate_type'] = $context['member']['is_activated']; // What should the link text be? $context['activate_link_text'] = in_array($context['member']['is_activated'], array(3, 4, 5, 13, 14, 15)) ? $txt['account_approve'] : $txt['account_activate']; // Should we show a custom message? $context['activate_message'] = isset($txt['account_activate_method_' . $context['member']['is_activated'] % 10]) ? $txt['account_activate_method_' . $context['member']['is_activated'] % 10] : $txt['account_not_activated']; } // Is the signature even enabled on this forum? $context['signature_enabled'] = substr($modSettings['signature_settings'], 0, 1) == 1; // How about, are they banned? $context['member']['bans'] = array(); if (allowedTo('moderate_forum')) { // Can they edit the ban? $context['can_edit_ban'] = allowedTo('manage_bans'); $ban_query = array(); $ban_query_vars = array('time' => time()); $ban_query[] = 'id_member = ' . $context['member']['id']; // Valid IP? if (preg_match('/^(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})$/', $memberContext[$memID]['ip'], $ip_parts) == 1) { $ban_query[] = '((' . $ip_parts[1] . ' BETWEEN bi.ip_low1 AND bi.ip_high1) AND (' . $ip_parts[2] . ' BETWEEN bi.ip_low2 AND bi.ip_high2) AND (' . $ip_parts[3] . ' BETWEEN bi.ip_low3 AND bi.ip_high3) AND (' . $ip_parts[4] . ' BETWEEN bi.ip_low4 AND bi.ip_high4))'; // Do we have a hostname already? if (!empty($context['member']['hostname'])) { $ban_query[] = '({string:hostname} LIKE hostname)'; $ban_query_vars['hostname'] = $context['member']['hostname']; } } elseif ($memberContext[$memID]['ip'] == 'unknown') { $ban_query[] = '(bi.ip_low1 = 255 AND bi.ip_high1 = 255 AND bi.ip_low2 = 255 AND bi.ip_high2 = 255 AND bi.ip_low3 = 255 AND bi.ip_high3 = 255 AND bi.ip_low4 = 255 AND bi.ip_high4 = 255)'; } // Check their email as well... if (strlen($context['member']['email']) != 0) { $ban_query[] = '({string:email} LIKE bi.email_address)'; $ban_query_vars['email'] = $context['member']['email']; } // So... are they banned? Dying to know! $request = $smcFunc['db_query']('', ' SELECT bg.id_ban_group, bg.name, bg.cannot_access, bg.cannot_post, bg.cannot_register, bg.cannot_login, bg.reason FROM {db_prefix}ban_items AS bi INNER JOIN {db_prefix}ban_groups AS bg ON (bg.id_ban_group = bi.id_ban_group AND (bg.expire_time IS NULL OR bg.expire_time > {int:time})) WHERE (' . implode(' OR ', $ban_query) . ')', $ban_query_vars); while ($row = $smcFunc['db_fetch_assoc']($request)) { // Work out what restrictions we actually have. $ban_restrictions = array(); foreach (array('access', 'register', 'login', 'post') as $type) { if ($row['cannot_' . $type]) { $ban_restrictions[] = $txt['ban_type_' . $type]; } } // No actual ban in place? if (empty($ban_restrictions)) { continue; } // Prepare the link for context. $ban_explanation = sprintf($txt['user_cannot_due_to'], implode(', ', $ban_restrictions), '<a href="' . $scripturl . '?action=admin;area=ban;sa=edit;bg=' . $row['id_ban_group'] . '">' . $row['name'] . '</a>'); $context['member']['bans'][$row['id_ban_group']] = array('reason' => empty($row['reason']) ? '' : '<br /><br /><strong>' . $txt['ban_reason'] . ':</strong> ' . $row['reason'], 'cannot' => array('access' => !empty($row['cannot_access']), 'register' => !empty($row['cannot_register']), 'post' => !empty($row['cannot_post']), 'login' => !empty($row['cannot_login'])), 'explanation' => $ban_explanation); } $smcFunc['db_free_result']($request); } loadCustomFields($memID); }
function getMembersOnline() { global $mobdb, $user_info, $scripturl, $modSettings, $txt; $return = array(); // Load the users online right now. $result = $mobdb->query(' SELECT lo.ID_MEMBER AS id_member, lo.logTime AS log_time, mem.realName AS real_name, mem.memberName AS member_name, mem.showOnline AS show_online, lo.session, lo.url, mg.onlineColor AS online_color, mg.ID_GROUP AS id_group, mg.groupName AS group_name, mem.avatar as avatar, IFNULL(a.ID_ATTACH, 0) AS id_attach, a.filename, a.attachmentType AS attachment_type FROM {db_prefix}log_online AS lo LEFT JOIN {db_prefix}members AS mem ON (mem.ID_MEMBER = lo.ID_MEMBER) LEFT JOIN {db_prefix}attachments AS a ON (a.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))', array()); $return['users_online'] = array(); $return['list_users_online'] = array(); $return['online_groups'] = array(); $return['num_guests'] = 0; $return['num_buddies'] = 0; $return['num_users_hidden'] = 0; $return['show_buddies'] = !empty($user_info['buddies']); $url_data = array(); while ($row = $mobdb->fetch_assoc()) { if (empty($row['real_name'])) { $return['num_guests']++; continue; } elseif (empty($row['show_online']) && !allowedTo('moderate_forum')) { $return['num_users_hidden']++; continue; } $is_buddy = in_array($row['id_member'], $user_info['buddies']); $return['users_online'][$row['session']] = array('id' => $row['id_member'], 'username' => $row['member_name'], 'name' => $row['real_name'], 'group' => $row['id_group'], 'is_buddy' => $is_buddy, 'hidden' => empty($row['show_online']), 'avatar' => get_avatar($row)); $url_data[$row['session']] = array($row['url'], $row['id_member']); } $mobdb->free_result(); $url_data = determineActions($url_data); foreach ($return['users_online'] as $i => $member) { $return['users_online'][$i]['action'] = isset($url_data[$i]) ? $url_data[$i] : $txt['who_hidden']; } return $return; }
function summary($memID) { global $context, $memberContext, $txt, $modSettings, $user_info, $user_profile, $sourcedir, $db_prefix, $scripturl; // Attempt to load the member's profile data. if (!loadMemberContext($memID) || !isset($memberContext[$memID])) { fatal_error($txt[453] . ' - ' . $memID, false); } // Set up the stuff and load the user. $context += array('allow_hide_email' => !empty($modSettings['allow_hideEmail']), 'page_title' => $txt[92] . ' ' . $memberContext[$memID]['name'], 'can_send_pm' => allowedTo('pm_send'), 'can_have_buddy' => allowedTo('profile_identity_own') && !empty($modSettings['enable_buddylist'])); $context['member'] =& $memberContext[$memID]; // They haven't even been registered for a full day!? $days_registered = (int) ((time() - $user_profile[$memID]['dateRegistered']) / (3600 * 24)); if (empty($user_profile[$memID]['dateRegistered']) || $days_registered < 1) { $context['member']['posts_per_day'] = $txt[470]; } else { $context['member']['posts_per_day'] = comma_format($context['member']['real_posts'] / $days_registered, 3); } // Set the age... if (empty($context['member']['birth_date'])) { $context['member'] += array('age' => &$txt[470], 'today_is_birthday' => false); } else { list($birth_year, $birth_month, $birth_day) = sscanf($context['member']['birth_date'], '%d-%d-%d'); $datearray = getdate(forum_time()); $context['member'] += array('age' => $birth_year <= 4 ? $txt[470] : $datearray['year'] - $birth_year - ($datearray['mon'] > $birth_month || $datearray['mon'] == $birth_month && $datearray['mday'] >= $birth_day ? 0 : 1), 'today_is_birthday' => $datearray['mon'] == $birth_month && $datearray['mday'] == $birth_day); } if (allowedTo('moderate_forum')) { // Make sure it's a valid ip address; otherwise, don't bother... if (preg_match('/^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$/', $memberContext[$memID]['ip']) == 1 && empty($modSettings['disableHostnameLookup'])) { $context['member']['hostname'] = host_from_ip($memberContext[$memID]['ip']); } else { $context['member']['hostname'] = ''; } $context['can_see_ip'] = true; } else { $context['can_see_ip'] = false; } if (!empty($modSettings['who_enabled'])) { include_once $sourcedir . '/Who.php'; $action = determineActions($user_profile[$memID]['url']); if ($action !== false) { $context['member']['action'] = $action; } } // If the user is awaiting activation, and the viewer has permission - setup some activation context messages. if ($context['member']['is_activated'] % 10 != 1 && allowedTo('moderate_forum')) { $context['activate_type'] = $context['member']['is_activated']; // What should the link text be? $context['activate_link_text'] = in_array($context['member']['is_activated'], array(3, 4, 5, 13, 14, 15)) ? $txt['account_approve'] : $txt['account_activate']; // Should we show a custom message? $context['activate_message'] = isset($txt['account_activate_method_' . $context['member']['is_activated'] % 10]) ? $txt['account_activate_method_' . $context['member']['is_activated'] % 10] : $txt['account_not_activated']; } // How about, are they banned? $context['member']['bans'] = array(); if (allowedTo('moderate_forum')) { // Can they edit the ban? $context['can_edit_ban'] = allowedTo('manage_bans'); $ban_query = array(); $ban_query[] = "ID_MEMBER = " . $context['member']['id']; // Valid IP? if (preg_match('/^(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})$/', $memberContext[$memID]['ip'], $ip_parts) == 1) { $ban_query[] = "(({$ip_parts['1']} BETWEEN bi.ip_low1 AND bi.ip_high1)\n\t\t\t\t\t\tAND ({$ip_parts['2']} BETWEEN bi.ip_low2 AND bi.ip_high2)\n\t\t\t\t\t\tAND ({$ip_parts['3']} BETWEEN bi.ip_low3 AND bi.ip_high3)\n\t\t\t\t\t\tAND ({$ip_parts['4']} BETWEEN bi.ip_low4 AND bi.ip_high4))"; // Do we have a hostname already? if (!empty($context['member']['hostname'])) { $ban_query[] = "('" . addslashes($context['member']['hostname']) . "' LIKE hostname)"; } } elseif ($memberContext[$memID]['ip'] == 'unknown') { $ban_query[] = "(bi.ip_low1 = 255 AND bi.ip_high1 = 255\n\t\t\t\t\t\tAND bi.ip_low2 = 255 AND bi.ip_high2 = 255\n\t\t\t\t\t\tAND bi.ip_low3 = 255 AND bi.ip_high3 = 255\n\t\t\t\t\t\tAND bi.ip_low4 = 255 AND bi.ip_high4 = 255)"; } // Check their email as well... if (strlen($context['member']['email']) != 0) { $ban_query[] = "('" . addslashes($context['member']['email']) . "' LIKE bi.email_address)"; } // So... are they banned? Dying to know! $request = db_query("\n\t\t\tSELECT bg.ID_BAN_GROUP, bg.name, bg.cannot_access, bg.cannot_post, bg.cannot_register,\n\t\t\t\tbg.cannot_login, bg.reason\n\t\t\tFROM ({$db_prefix}ban_items AS bi, {$db_prefix}ban_groups AS bg)\n\t\t\tWHERE bg.ID_BAN_GROUP = bi.ID_BAN_GROUP\n\t\t\t\tAND (bg.expire_time IS NULL OR bg.expire_time > " . time() . ")\n\t\t\t\tAND (" . implode(' OR ', $ban_query) . ') GROUP BY bg.ID_BAN_GROUP', __FILE__, __LINE__); while ($row = mysql_fetch_assoc($request)) { // Work out what restrictions we actually have. $ban_restrictions = array(); foreach (array('access', 'register', 'login', 'post') as $type) { if ($row['cannot_' . $type]) { $ban_restrictions[] = $txt['ban_type_' . $type]; } } // No actual ban in place? if (empty($ban_restrictions)) { continue; } // Prepare the link for context. $ban_explanation = sprintf($txt['user_cannot_due_to'], implode(', ', $ban_restrictions), '<a href="' . $scripturl . '?action=ban;sa=edit;bg=' . $row['ID_BAN_GROUP'] . '">' . $row['name'] . '</a>'); $context['member']['bans'][] = array('reason' => empty($row['reason']) ? '' : '<br /><br /><b>' . $txt['ban_reason'] . ':</b> ' . $row['reason'], 'cannot' => array('access' => !empty($row['cannot_access']), 'register' => !empty($row['cannot_register']), 'post' => !empty($row['cannot_post']), 'login' => !empty($row['cannot_login'])), 'explanation' => $ban_explanation); } mysql_free_result($request); } }
/** * Who's online, and what are they doing? * This function prepares the who's online data for the Who template. * It requires the who_view permission. * It is enabled with the who_enabled setting. * It is accessed via ?action=who. * * @uses Who template, main sub-template * @uses Who language file. */ public function action_who() { global $context, $scripturl, $txt, $modSettings, $memberContext; // Permissions, permissions, permissions. isAllowedTo('who_view'); // You can't do anything if this is off. if (empty($modSettings['who_enabled'])) { fatal_lang_error('who_off', false); } // Load the 'Who' template. loadTemplate('Who'); loadLanguage('Who'); // Sort out... the column sorting. $sort_methods = array('user' => 'mem.real_name', 'time' => 'lo.log_time'); $show_methods = array('members' => '(lo.id_member != 0)', 'guests' => '(lo.id_member = 0)', 'all' => '1=1'); // Store the sort methods and the show types for use in the template. $context['sort_methods'] = array('user' => $txt['who_user'], 'time' => $txt['who_time']); $context['show_methods'] = array('all' => $txt['who_show_all'], 'members' => $txt['who_show_members_only'], 'guests' => $txt['who_show_guests_only']); // Can they see spiders too? if (!empty($modSettings['show_spider_online']) && ($modSettings['show_spider_online'] == 2 || allowedTo('admin_forum')) && !empty($modSettings['spider_name_cache'])) { $show_methods['spiders'] = '(lo.id_member = 0 AND lo.id_spider > 0)'; $show_methods['guests'] = '(lo.id_member = 0 AND lo.id_spider = 0)'; $context['show_methods']['spiders'] = $txt['who_show_spiders_only']; } elseif (empty($modSettings['show_spider_online']) && isset($_SESSION['who_online_filter']) && $_SESSION['who_online_filter'] == 'spiders') { unset($_SESSION['who_online_filter']); } // Does the user prefer a different sort direction? if (isset($_REQUEST['sort']) && isset($sort_methods[$_REQUEST['sort']])) { $context['sort_by'] = $_SESSION['who_online_sort_by'] = $_REQUEST['sort']; $sort_method = $sort_methods[$_REQUEST['sort']]; } elseif (isset($_SESSION['who_online_sort_by'])) { $context['sort_by'] = $_SESSION['who_online_sort_by']; $sort_method = $sort_methods[$_SESSION['who_online_sort_by']]; } else { $context['sort_by'] = $_SESSION['who_online_sort_by'] = 'time'; $sort_method = 'lo.log_time'; } $context['sort_direction'] = isset($_REQUEST['asc']) || isset($_REQUEST['sort_dir']) && $_REQUEST['sort_dir'] == 'asc' ? 'up' : 'down'; $conditions = array(); if (!allowedTo('moderate_forum')) { $conditions[] = '(IFNULL(mem.show_online, 1) = 1)'; } // Fallback to top filter? if (isset($_REQUEST['submit_top']) && isset($_REQUEST['show_top'])) { $_REQUEST['show'] = $_REQUEST['show_top']; } // Does the user wish to apply a filter? if (isset($_REQUEST['show']) && isset($show_methods[$_REQUEST['show']])) { $context['show_by'] = $_SESSION['who_online_filter'] = $_REQUEST['show']; $conditions[] = $show_methods[$_REQUEST['show']]; } elseif (isset($_SESSION['who_online_filter'])) { $context['show_by'] = $_SESSION['who_online_filter']; $conditions[] = $show_methods[$_SESSION['who_online_filter']]; } else { $context['show_by'] = $_SESSION['who_online_filter'] = 'all'; } require_once SUBSDIR . '/Members.subs.php'; $totalMembers = countMembersOnline($conditions); // Prepare some page index variables. $context['page_index'] = constructPageIndex($scripturl . '?action=who;sort=' . $context['sort_by'] . ($context['sort_direction'] == 'up' ? ';asc' : '') . ';show=' . $context['show_by'], $_REQUEST['start'], $totalMembers, $modSettings['defaultMaxMembers']); $context['start'] = $_REQUEST['start']; $context['sub_template'] = 'whos_online'; Template_Layers::getInstance()->add('whos_selection'); // Look for people online, provided they don't mind if you see they are. $members = onlineMembers($conditions, $sort_method, $context['sort_direction'], $context['start']); $context['members'] = array(); $member_ids = array(); $url_data = array(); foreach ($members as $row) { $actions = @unserialize($row['url']); if ($actions === false) { continue; } // Send the information to the template. $context['members'][$row['session']] = array('id' => $row['id_member'], 'ip' => allowedTo('moderate_forum') ? $row['ip'] : '', 'time' => standardTime($row['log_time'], true), 'html_time' => htmlTime($row['log_time']), 'timestamp' => forum_time(true, $row['log_time']), 'query' => $actions, 'is_hidden' => $row['show_online'] == 0, 'id_spider' => $row['id_spider'], 'color' => empty($row['online_color']) ? '' : $row['online_color']); $url_data[$row['session']] = array($row['url'], $row['id_member']); $member_ids[] = $row['id_member']; } // Load the user data for these members. loadMemberData($member_ids); // Load up the guest user. $memberContext[0] = array('id' => 0, 'name' => $txt['guest_title'], 'group' => $txt['guest_title'], 'href' => '', 'link' => $txt['guest_title'], 'email' => $txt['guest_title'], 'is_guest' => true); // Are we showing spiders? $spiderContext = array(); if (!empty($modSettings['show_spider_online']) && ($modSettings['show_spider_online'] == 2 || allowedTo('admin_forum')) && !empty($modSettings['spider_name_cache'])) { foreach (unserialize($modSettings['spider_name_cache']) as $id => $name) { $spiderContext[$id] = array('id' => 0, 'name' => $name, 'group' => $txt['spiders'], 'href' => '', 'link' => $name, 'email' => $name, 'is_guest' => true); } } require_once SUBSDIR . '/Who.subs.php'; $url_data = determineActions($url_data); // Setup the linktree and page title (do it down here because the language files are now loaded..) $context['page_title'] = $txt['who_title']; $context['linktree'][] = array('url' => $scripturl . '?action=who', 'name' => $txt['who_title']); // Put it in the context variables. foreach ($context['members'] as $i => $member) { if ($member['id'] != 0) { $member['id'] = loadMemberContext($member['id']) ? $member['id'] : 0; } // Keep the IP that came from the database. $memberContext[$member['id']]['ip'] = $member['ip']; $context['members'][$i]['action'] = isset($url_data[$i]) ? $url_data[$i] : $txt['who_hidden']; if ($member['id'] == 0 && isset($spiderContext[$member['id_spider']])) { $context['members'][$i] += $spiderContext[$member['id_spider']]; } else { $context['members'][$i] += $memberContext[$member['id']]; } } // Some people can't send personal messages... $context['can_send_pm'] = allowedTo('pm_send'); $context['can_send_email'] = allowedTo('send_email_to_members'); // Any profile fields disabled? $context['disabled_fields'] = isset($modSettings['disabled_profile_fields']) ? array_flip(explode(',', $modSettings['disabled_profile_fields'])) : array(); }
function mob_get_user_info($rpcmsg) { global $mobdb, $context, $modSettings, $memberContext, $user_profile, $sourcedir, $txt, $user_info; $username = $rpcmsg->getParam(0) ? $rpcmsg->getScalarValParam(0) : null; $id_user = $rpcmsg->getParam(1) ? $rpcmsg->getScalarValParam(1) : null; if (empty($username) && empty($id_user)) { $id_user = $user_info['id']; } $id_user = intval($id_user); require_once $sourcedir . '/Subs-Auth.php'; // If we have an user ID, use it otherwise search for the user if (!is_null($id_user)) { $request = $mobdb->query(' SELECT ID_MEMBER FROM {db_prefix}members WHERE ID_MEMBER = {int:member}', array('member' => $id_user)); if ($mobdb->num_rows($request) == 0) { $id_user = null; } else { list($id_user) = $mobdb->fetch_row($request); } $mobdb->free_result($request); } // Otherwise search from the DB, if (is_null($id_user)) { $username = utf8ToAscii($username); $members = findMembers($username); if (empty($members)) { mob_error('user not found'); } $member_ids = array_keys($members); $id_user = $members[$member_ids[0]]['id']; } loadMemberData($id_user); loadMemberContext($id_user); $member = $memberContext[$id_user]; // Is the guy banned? $request = $mobdb->query(' SELECT COUNT(*) FROM {db_prefix}ban_items AS bi INNER JOIN {db_prefix}ban_groups AS bg ON (bg.ID_BAN_GROUP = bi.ID_BAN_GROUP) WHERE bi.ID_MEMBER = {int:member} AND (bg.expire_time IS NULL OR bg.expire_time > {int:time}) AND bg.cannot_access != 0', array('member' => $member['id'], 'time' => time())); $banned = false; list($count) = $mobdb->fetch_row($request); if ($count > 0) { $banned = true; } $mobdb->free_result($request); loadLanguage('Profile'); // Load the current action $current_action = determineActions($user_profile[$id_user]['url']); // Figure out all the custom fields $custom_fields = array(); $custom_fields[] = new xmlrpcval(array('name' => new xmlrpcval($txt[87], 'base64'), 'value' => new xmlrpcval(!empty($member['group']) ? $member['group'] : $member['post_group'], 'base64')), 'struct'); // Custom communication fields $fields = array('icq', 'aim', 'msn', 'yim'); $_fields = array($txt[513], $txt[603], $txt['MSN'], $txt[604]); foreach ($fields as $k => $field) { if (!empty($member[$field]['name'])) { $custom_fields[] = new xmlrpcval(array('name' => new xmlrpcval(processSubject($_fields[$k]), 'base64'), 'value' => new xmlrpcval(processSubject($member[$field]['name']), 'base64')), 'struct'); } } if ($modSettings['karmaMode'] == '1' || $modSettings['karmaMode'] == '2') { $custom_fields[] = new xmlrpcval(array('name' => new xmlrpcval(processSubject($modSettings['karmaLabel']), 'base64'), 'value' => new xmlrpcval(processSubject($modSettings['karmaMode'] == '1' ? $member['karma']['good'] - $member['karma']['bad'] : '+' . $member['karma']['good'] . '/-' . $member['karma']['bad']), 'base64')), 'struct'); } if (!empty($member['gender']['name'])) { $custom_fields[] = new xmlrpcval(array('name' => new xmlrpcval(processSubject($txt[231]), 'base64'), 'value' => new xmlrpcval(processSubject($member['gender']['name']), 'base64')), 'struct'); } if (!empty($member['location'])) { $custom_fields[] = new xmlrpcval(array('name' => new xmlrpcval(processSubject($txt[227]), 'base64'), 'value' => new xmlrpcval(processSubject($member['location']), 'base64')), 'struct'); } if (!empty($member['signature'])) { $custom_fields[] = new xmlrpcval(array('name' => new xmlrpcval(processSubject($txt[85]), 'base64'), 'value' => new xmlrpcval(processSubject($member['signature']), 'base64')), 'struct'); } $response = array('user_id' => new xmlrpcval($member['id'], 'string'), 'user_name' => new xmlrpcval(processUsername(!empty($member['name']) ? $member['name'] : $member['username']), 'base64'), 'display_name' => new xmlrpcval(processUsername(!empty($member['name']) ? $member['name'] : $member['username']), 'base64'), 'post_count' => new xmlrpcval($member['posts'], 'int'), 'reg_time' => new xmlrpcval(mobiquo_time($member['registered_timestamp']), 'dateTime.iso8601'), 'is_online' => new xmlrpcval(!empty($user_profile[$id_user]['isOnline']), 'boolean'), 'accept_pm' => new xmlrpcval(true, 'boolean'), 'display_text' => new xmlrpcval(processSubject($member['title']), 'base64'), 'icon_url' => new xmlrpcval($member['avatar']['href'], 'string'), 'current_activity' => new xmlrpcval(processSubject($current_action), 'base64'), 'current_action' => new xmlrpcval(processSubject($current_action), 'base64'), 'is_ban' => new xmlrpcval($banned, 'boolean'), 'can_ban' => new xmlrpcval(allowedTo('manage_bans'), 'boolean'), 'custom_fields_list' => new xmlrpcval($custom_fields, 'array')); if ($banned) { $response['user_type'] = new xmlrpcval('banned', 'base64'); } // Return the response return new xmlrpcresp(new xmlrpcval($response, 'struct')); }
/** * See what spiders have been up to. */ public function action_logs() { global $context, $txt, $scripturl, $modSettings; // Load the template and language just incase. loadLanguage('Search'); loadTemplate('ManageSearch'); // Did they want to delete some or all entries? if (!empty($_POST['delete_entries']) && isset($_POST['older']) || !empty($_POST['removeAll'])) { checkSession(); validateToken('admin-sl'); $since = isset($_POST['older']) ? (int) $_POST['older'] : 0; $deleteTime = time() - $since * 24 * 60 * 60; // Delete the entires. require_once SUBSDIR . '/SearchEngines.subs.php'; removeSpiderOldLogs($deleteTime); } // Build out the spider log list $listOptions = array('id' => 'spider_logs', 'items_per_page' => 20, 'title' => $txt['spider_logs'], 'no_items_label' => $txt['spider_logs_empty'], 'base_href' => $context['admin_area'] == 'sengines' ? $scripturl . '?action=admin;area=sengines;sa=logs' : $scripturl . '?action=admin;area=logs;sa=spiderlog', 'default_sort_col' => 'log_time', 'get_items' => array('function' => 'getSpiderLogs'), 'get_count' => array('function' => 'getNumSpiderLogs', 'file' => SUBSDIR . '/SearchEngines.subs.php'), 'columns' => array('name' => array('header' => array('value' => $txt['spider']), 'data' => array('db' => 'spider_name'), 'sort' => array('default' => 's.spider_name', 'reverse' => 's.spider_name DESC')), 'log_time' => array('header' => array('value' => $txt['spider_time']), 'data' => array('function' => create_function('$rowData', ' return standardTime($rowData[\'log_time\']); ')), 'sort' => array('default' => 'sl.id_hit DESC', 'reverse' => 'sl.id_hit')), 'viewing' => array('header' => array('value' => $txt['spider_viewing']), 'data' => array('db' => 'url'))), 'form' => array('token' => 'admin-sl', 'href' => $scripturl . '?action=admin;area=sengines;sa=logs'), 'additional_rows' => array(array('position' => 'after_title', 'value' => $txt['spider_logs_info'], 'class' => 'windowbg2'), array('position' => 'below_table_data', 'value' => '<input type="submit" name="removeAll" value="' . $txt['spider_log_empty_log'] . '" onclick="return confirm(\'' . $txt['spider_log_empty_log_confirm'] . '\');" class="right_submit" />'))); createToken('admin-sl'); require_once SUBSDIR . '/GenericList.class.php'; createList($listOptions); // Now determine the actions of the URLs. if (!empty($context['spider_logs']['rows'])) { $urls = array(); // Grab the current /url. foreach ($context['spider_logs']['rows'] as $k => $row) { // Feature disabled? if (empty($row['viewing']['value']) && isset($modSettings['spider_mode']) && $modSettings['spider_mode'] < 3) { $context['spider_logs']['rows'][$k]['viewing']['value'] = '<em>' . $txt['spider_disabled'] . '</em>'; } else { $urls[$k] = array($row['viewing']['value'], -1); } } // Now stick in the new URLs. require_once SUBSDIR . '/Who.subs.php'; $urls = determineActions($urls, 'whospider_'); foreach ($urls as $k => $new_url) { $context['spider_logs']['rows'][$k]['viewing']['value'] = $new_url; } } $context['page_title'] = $txt['spider_logs']; $context['sub_template'] = 'show_spider_logs'; }
/** * View the user profile summary. * * @uses ProfileInfo template */ public function action_summary() { global $context, $memberContext, $txt, $modSettings, $user_info, $user_profile, $scripturl, $settings; $memID = currentMemberID(); // Attempt to load the member's profile data. if (!loadMemberContext($memID) || !isset($memberContext[$memID])) { fatal_lang_error('not_a_user', false); } loadTemplate('ProfileInfo'); // Set up the stuff and load the user. $context += array('page_title' => sprintf($txt['profile_of_username'], $memberContext[$memID]['name']), 'can_send_pm' => allowedTo('pm_send'), 'can_send_email' => allowedTo('send_email_to_members'), 'can_have_buddy' => allowedTo('profile_identity_own') && !empty($modSettings['enable_buddylist']), 'can_issue_warning' => in_array('w', $context['admin_features']) && allowedTo('issue_warning') && !empty($modSettings['warning_enable'])); $context['member'] =& $memberContext[$memID]; $context['can_view_warning'] = in_array('w', $context['admin_features']) && (allowedTo('issue_warning') && !$context['user']['is_owner']) || !empty($modSettings['warning_show']) && ($modSettings['warning_show'] > 1 || $context['user']['is_owner']); // Set a canonical URL for this page. $context['canonical_url'] = $scripturl . '?action=profile;u=' . $memID; // Are there things we don't show? $context['disabled_fields'] = isset($modSettings['disabled_profile_fields']) ? array_flip(explode(',', $modSettings['disabled_profile_fields'])) : array(); // Menu tab $context[$context['profile_menu_name']]['tab_data'] = array(); // Tab information for use in the summary page // Each tab template defines a div, the value of which are the template(s) to load in that div // Templates are named template_profile_block_YOURNAME $context['summarytabs'] = array('summary' => array('name' => $txt['summary'], 'templates' => array(array('summary', 'user_info'), array('contact', 'other_info'), array('user_customprofileinfo', 'moderation')), 'active' => true), 'recent' => array('name' => $txt['profile_recent_activity'], 'templates' => array('posts', 'topics', 'attachments'), 'active' => true), 'buddies' => array('name' => $txt['buddies'], 'templates' => array('buddies'), 'active' => !empty($modSettings['enable_buddylist']) && $context['user']['is_owner'])); // Let addons add or remove to the tabs array call_integration_hook('integrate_profile_summary', array($memID)); // Go forward with whats left $summary_areas = ''; foreach ($context['summarytabs'] as $id => $tab) { // If the tab is active we add it if ($tab['active'] !== true) { unset($context['summarytabs'][$id]); } else { // All the active templates, used to prevent processing data we don't need foreach ($tab['templates'] as $template) { $summary_areas .= is_array($template) ? implode(',', $template) : ',' . $template; } } } $summary_areas = explode(',', $summary_areas); // See if they have broken any warning levels... if (!empty($modSettings['warning_mute']) && $modSettings['warning_mute'] <= $context['member']['warning']) { $context['warning_status'] = $txt['profile_warning_is_muted']; } elseif (!empty($modSettings['warning_moderate']) && $modSettings['warning_moderate'] <= $context['member']['warning']) { $context['warning_status'] = $txt['profile_warning_is_moderation']; } elseif (!empty($modSettings['warning_watch']) && $modSettings['warning_watch'] <= $context['member']['warning']) { $context['warning_status'] = $txt['profile_warning_is_watch']; } // They haven't even been registered for a full day!? $days_registered = (int) ((time() - $user_profile[$memID]['date_registered']) / (3600 * 24)); if (empty($user_profile[$memID]['date_registered']) || $days_registered < 1) { $context['member']['posts_per_day'] = $txt['not_applicable']; } else { $context['member']['posts_per_day'] = comma_format($context['member']['real_posts'] / $days_registered, 3); } // Set the age... if (empty($context['member']['birth_date'])) { $context['member'] += array('age' => $txt['not_applicable'], 'today_is_birthday' => false); } else { list($birth_year, $birth_month, $birth_day) = sscanf($context['member']['birth_date'], '%d-%d-%d'); $datearray = getdate(forum_time()); $context['member'] += array('age' => $birth_year <= 4 ? $txt['not_applicable'] : $datearray['year'] - $birth_year - ($datearray['mon'] > $birth_month || $datearray['mon'] == $birth_month && $datearray['mday'] >= $birth_day ? 0 : 1), 'today_is_birthday' => $datearray['mon'] == $birth_month && $datearray['mday'] == $birth_day); } if (allowedTo('moderate_forum')) { // Make sure it's a valid ip address; otherwise, don't bother... if (preg_match('/^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$/', $memberContext[$memID]['ip']) == 1 && empty($modSettings['disableHostnameLookup'])) { $context['member']['hostname'] = host_from_ip($memberContext[$memID]['ip']); } else { $context['member']['hostname'] = ''; } $context['can_see_ip'] = true; } else { $context['can_see_ip'] = false; } if (!empty($modSettings['who_enabled']) && $context['member']['online']['is_online']) { include_once SUBSDIR . '/Who.subs.php'; $action = determineActions($user_profile[$memID]['url']); loadLanguage('index'); if ($action !== false) { $context['member']['action'] = $action; } } // If the user is awaiting activation, and the viewer has permission - setup some activation context messages. if ($context['member']['is_activated'] % 10 != 1 && allowedTo('moderate_forum')) { $context['activate_type'] = $context['member']['is_activated']; // What should the link text be? $context['activate_link_text'] = in_array($context['member']['is_activated'], array(3, 4, 5, 13, 14, 15)) ? $txt['account_approve'] : $txt['account_activate']; // Should we show a custom message? $context['activate_message'] = isset($txt['account_activate_method_' . $context['member']['is_activated'] % 10]) ? $txt['account_activate_method_' . $context['member']['is_activated'] % 10] : $txt['account_not_activated']; $context['activate_url'] = $scripturl . '?action=profile;save;area=activateaccount;u=' . $memID . ';' . $context['session_var'] . '=' . $context['session_id'] . ';' . $context['profile-aa' . $memID . '_token_var'] . '=' . $context['profile-aa' . $memID . '_token']; } // Is the signature even enabled on this forum? $context['signature_enabled'] = substr($modSettings['signature_settings'], 0, 1) == 1; // How about, are they banned? if (allowedTo('moderate_forum')) { require_once SUBSDIR . '/Bans.subs.php'; $hostname = !empty($context['member']['hostname']) ? $context['member']['hostname'] : ''; $email = !empty($context['member']['email']) ? $context['member']['email'] : ''; $context['member']['bans'] = BanCheckUser($memID, $hostname, $email); // Can they edit the ban? $context['can_edit_ban'] = allowedTo('manage_bans'); } // Load up the most recent attachments for this user for use in profile views etc. $context['thumbs'] = array(); if (!empty($modSettings['attachmentEnable']) && !empty($settings['attachments_on_summary']) && in_array('attachments', $summary_areas)) { $boardsAllowed = boardsAllowedTo('view_attachments'); if (empty($boardsAllowed)) { $boardsAllowed = array(-1); } $attachments = $this->list_getAttachments(0, $settings['attachments_on_summary'], 'm.poster_time DESC', $boardsAllowed, $memID); // Some generic images for mime types $mime_images_url = $settings['default_images_url'] . '/mime_images/'; $mime_path = $settings['default_theme_dir'] . '/images/mime_images/'; // Load them in to $context for use in the template for ($i = 0, $count = count($attachments); $i < $count; $i++) { $context['thumbs'][$i] = array('url' => $scripturl . '?action=dlattach;topic=' . $attachments[$i]['topic'] . '.0;attach=' . $attachments[$i]['id'], 'img' => '', 'filename' => $attachments[$i]['filename'], 'downloads' => $attachments[$i]['downloads'], 'subject' => $attachments[$i]['subject'], 'id' => $attachments[$i]['id']); // Show a thumbnail image as well? if ($attachments[$i]['is_image'] && !empty($modSettings['attachmentShowImages']) && !empty($modSettings['attachmentThumbnails'])) { if (!empty($attachments[$i]['id_thumb'])) { $context['thumbs'][$i]['img'] = '<img id="thumb_' . $attachments[$i]['id'] . '" src="' . $scripturl . '?action=dlattach;topic=' . $attachments[$i]['topic'] . '.0;attach=' . $attachments[$i]['id_thumb'] . ';image" title="" alt="" />'; } else { // No thumbnail available ... use html instead if (!empty($modSettings['attachmentThumbWidth']) && !empty($modSettings['attachmentThumbHeight'])) { if ($attachments[$i]['width'] > $modSettings['attachmentThumbWidth'] || $attachments[$i]['height'] > $modSettings['attachmentThumbHeight']) { $context['thumbs'][$i]['img'] = '<img id="thumb_' . $attachments[$i]['id'] . '" src="' . $scripturl . '?action=dlattach;topic=' . $attachments[$i]['topic'] . '.0;attach=' . $attachments[$i]['id'] . '" title="" alt="" width="' . $modSettings['attachmentThumbWidth'] . '" height="' . $modSettings['attachmentThumbHeight'] . '" />'; } else { $context['thumbs'][$i]['img'] = '<img id="thumb_' . $attachments[$i]['id'] . '" src="' . $scripturl . '?action=dlattach;topic=' . $attachments[$i]['topic'] . '.0;attach=' . $attachments[$i]['id'] . '" title="" alt="" width="' . $attachments[$i]['width'] . '" height="' . $attachments[$i]['height'] . '" />'; } } } } else { if (!empty($modSettings['attachmentThumbWidth']) && !empty($modSettings['attachmentThumbHeight']) && (128 > $modSettings['attachmentThumbWidth'] || 128 > $modSettings['attachmentThumbHeight'])) { $context['thumbs'][$i]['img'] = '<img src="' . $mime_images_url . (!file_exists($mime_path . $attachments[$i]['fileext'] . '.png') ? 'default' : $attachments[$i]['fileext']) . '.png" title="" alt="" width="' . $modSettings['attachmentThumbWidth'] . '" height="' . $modSettings['attachmentThumbHeight'] . '" />'; } else { $context['thumbs'][$i]['img'] = '<img src="' . $mime_images_url . (!file_exists($mime_path . $attachments[$i]['fileext'] . '.png') ? 'default' : $attachments[$i]['fileext']) . '.png" title="" alt="" />'; } } } } // Would you be mine? Could you be mine? Be my buddy :D if (!empty($modSettings['enable_buddylist']) && $context['user']['is_owner'] && !empty($user_info['buddies']) && in_array('buddies', $summary_areas)) { $context['buddies'] = array(); loadMemberData($user_info['buddies'], false, 'profile'); // Get the info for this buddy foreach ($user_info['buddies'] as $buddy) { loadMemberContext($buddy, true); $context['buddies'][$buddy] = $memberContext[$buddy]; } } // How about thier most recent posts? if (in_array('posts', $summary_areas)) { // Is the load average too high just now, then let them know if (!empty($modSettings['loadavg_show_posts']) && $modSettings['current_load'] >= $modSettings['loadavg_show_posts']) { $context['loadaverage'] = true; } else { // Set up to get the last 10 psots of this member $msgCount = count_user_posts($memID); $range_limit = ''; $maxIndex = 10; $start = (int) $_REQUEST['start']; // If they are a frequent poster, we guess the range to help minimize what the query work if ($msgCount > 1000) { list($min_msg_member, $max_msg_member) = findMinMaxUserMessage($memID); $margin = floor(($max_msg_member - $min_msg_member) * (($start + $modSettings['defaultMaxMessages']) / $msgCount) + 0.1 * ($max_msg_member - $min_msg_member)); $range_limit = 'm.id_msg > ' . ($max_msg_member - $margin); } // Find this user's most recent posts $rows = load_user_posts($memID, 0, $maxIndex, $range_limit); $context['posts'] = array(); foreach ($rows as $row) { // Censor.... censorText($row['body']); censorText($row['subject']); // Do the code. $row['body'] = parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']); $preview = strip_tags(strtr($row['body'], array('<br />' => ' '))); $preview = Util::shorten_text($preview, !empty($modSettings['ssi_preview_length']) ? $modSettings['ssi_preview_length'] : 128); $short_subject = Util::shorten_text($row['subject'], !empty($modSettings['ssi_subject_length']) ? $modSettings['ssi_subject_length'] : 24); // And the array... $context['posts'][] = array('body' => $preview, 'board' => array('name' => $row['bname'], 'link' => '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['bname'] . '</a>'), 'subject' => $row['subject'], 'short_subject' => $short_subject, 'time' => standardTime($row['poster_time']), 'html_time' => htmlTime($row['poster_time']), 'timestamp' => forum_time(true, $row['poster_time']), 'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '" rel="nofollow">' . $short_subject . '</a>'); } } } // How about the most recent topics that they started? if (in_array('topics', $summary_areas)) { // Is the load average still too high? if (!empty($modSettings['loadavg_show_posts']) && $modSettings['current_load'] >= $modSettings['loadavg_show_posts']) { $context['loadaverage'] = true; } else { // Set up to get the last 10 topics of this member $topicCount = count_user_topics($memID); $range_limit = ''; $maxIndex = 10; // If they are a frequent topic starter we guess the range to help the query if ($topicCount > 1000) { list($min_topic_member, $max_topic_member) = findMinMaxUserTopic($memID); $margin = floor(($max_topic_member - $min_topic_member) * (($start + $modSettings['defaultMaxMessages']) / $topicCount) + 0.1 * ($max_topic_member - $min_topic_member)); $margin *= 5; $range_limit = 't.id_first_msg > ' . ($max_topic_member - $margin); } // Find this user's most recent topics $rows = load_user_topics($memID, 0, $maxIndex, $range_limit); $context['topics'] = array(); foreach ($rows as $row) { // Censor.... censorText($row['body']); censorText($row['subject']); // Do the code. $short_subject = Util::shorten_text($row['subject'], !empty($modSettings['ssi_subject_length']) ? $modSettings['ssi_subject_length'] : 24); // And the array... $context['topics'][] = array('board' => array('name' => $row['bname'], 'link' => '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['bname'] . '</a>'), 'subject' => $row['subject'], 'short_subject' => $short_subject, 'time' => standardTime($row['poster_time']), 'html_time' => htmlTime($row['poster_time']), 'timestamp' => forum_time(true, $row['poster_time']), 'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '" rel="nofollow">' . $short_subject . '</a>'); } } } // To finish this off, custom profile fields. require_once SUBSDIR . '/Profile.subs.php'; loadCustomFields($memID); // To make tabs work, we need jQueryUI $modSettings['jquery_include_ui'] = true; addInlineJavascript(' $(function() {$( "#tabs" ).tabs();});', true); }