public static function boardindex() { global $context, $txt, $sourcedir, $user_info; $data = array(); if (($data = CacheAPI::getCache('github-feed-index', 1800)) === null) { $f = curl_init(); if ($f) { curl_setopt_array($f, array(CURLOPT_URL => self::$my_git_api_url, CURLOPT_HEADER => false, CURLOPT_RETURNTRANSFER => true, CURLOPT_SSL_VERIFYPEER => false)); $json_response = curl_exec($f); $data = json_decode($json_response, true); CacheAPI::putCache('github-feed-index', $data, 1800); curl_close($f); } } $n = 0; foreach ($data as $commit) { if (is_array($commit) && isset($commit['commit'])) { $context['gitfeed'][] = array('message_short' => shorten_subject($commit['commit']['message'], 60), 'message' => nl2br($commit['commit']['message']), 'dateline' => timeformat(strtotime($commit['commit']['committer']['date'])), 'sha' => $commit['sha'], 'href' => self::$my_git_url . 'commit/' . $commit['sha']); } if (++$n > 5) { break; } } if (!empty($data)) { /* * add our plugin directory to the list of directories to search for templates * and register the template hook. * only do this if we actually have something to display */ EoS_Smarty::addTemplateDir(dirname(__FILE__)); EoS_Smarty::getConfigInstance()->registerHookTemplate('sidebar_below_userblock', 'gitfeed_sidebar_top'); $context['gitfeed_global']['see_all']['href'] = self::$my_git_url . 'commits/master'; $context['gitfeed_global']['see_all']['txt'] = 'Browse all commits'; } }
function getLastPost() { global $user_info, $scripturl, $modSettings, $smcFunc; // Find it by the board - better to order by board than sort the entire messages table. $request = $smcFunc['db_query']('substring', ' SELECT ml.poster_time, ml.subject, ml.id_topic, ml.poster_name, SUBSTRING(ml.body, 1, 385) AS body, ml.smileys_enabled FROM {db_prefix}boards AS b INNER JOIN {db_prefix}messages AS ml ON (ml.id_msg = b.id_last_msg) WHERE {query_wanna_see_board}' . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? ' AND b.id_board != {int:recycle_board}' : '') . ' AND ml.approved = {int:is_approved} ORDER BY b.id_msg_updated DESC LIMIT 1', array('recycle_board' => $modSettings['recycle_board'], 'is_approved' => 1)); if ($smcFunc['db_num_rows']($request) == 0) { return array(); } $row = $smcFunc['db_fetch_assoc']($request); $smcFunc['db_free_result']($request); // Censor the subject and post... censorText($row['subject']); censorText($row['body']); $row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileys_enabled']), array('<br />' => ' '))); if ($smcFunc['strlen']($row['body']) > 128) { $row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...'; } // Send the data. return array('topic' => $row['id_topic'], 'subject' => $row['subject'], 'short_subject' => shorten_subject($row['subject'], 24), 'preview' => $row['body'], 'time' => timeformat($row['poster_time']), 'timestamp' => forum_time(true, $row['poster_time']), 'href' => $scripturl . '?topic=' . $row['id_topic'] . '.new;topicseen#new', 'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.new;topicseen#new">' . $row['subject'] . '</a>'); }
function getLastPosts($latestPostOptions) { global $scripturl, $txt, $user_info, $modSettings, $smcFunc, $context; // Find all the posts. Newer ones will have higher IDs. (assuming the last 20 * number are accessable...) // !!!SLOW This query is now slow, NEEDS to be fixed. Maybe break into two? $request = $smcFunc['db_query']('substring', ' SELECT m.poster_time, m.subject, m.id_topic, m.id_member, m.id_msg, IFNULL(mem.real_name, m.poster_name) AS poster_name, t.id_board, b.name AS board_name, SUBSTRING(m.body, 1, 385) AS body, m.smileys_enabled FROM {db_prefix}messages AS m INNER JOIN {db_prefix}topics AS t ON (t.id_topic = m.id_topic) INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board) LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member) WHERE m.id_msg >= {int:likely_max_msg}' . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? ' AND b.id_board != {int:recycle_board}' : '') . ' AND {query_wanna_see_board}' . ($modSettings['postmod_active'] ? ' AND t.approved = {int:is_approved} AND m.approved = {int:is_approved}' : '') . ' ORDER BY m.id_msg DESC LIMIT ' . $latestPostOptions['number_posts'], array('likely_max_msg' => max(0, $modSettings['maxMsgID'] - 50 * $latestPostOptions['number_posts']), 'recycle_board' => $modSettings['recycle_board'], 'is_approved' => 1)); $posts = array(); $context['MemberColor_ID_MEMBER'] = array(); while ($row = $smcFunc['db_fetch_assoc']($request)) { // Censor the subject and post for the preview ;). censorText($row['subject']); censorText($row['body']); $row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']), array('<br />' => ' '))); if ($smcFunc['strlen']($row['body']) > 128) { $row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...'; } // Build the array. $posts[] = array('board' => array('id' => $row['id_board'], 'name' => $row['board_name'], 'href' => $scripturl . '?board=' . $row['id_board'] . '.0', 'link' => '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['board_name'] . '</a>'), 'topic' => $row['id_topic'], 'poster' => array('id' => $row['id_member'], 'name' => $row['poster_name'], 'href' => empty($row['id_member']) ? '' : $scripturl . '?action=profile;u=' . $row['id_member'], 'link' => empty($row['id_member']) ? (!empty($modSettings['MemberColorGuests']) ? '<span style="color:' . $modSettings['MemberColorGuests'] . ';">' : '') . $row['poster_name'] . (!empty($modSettings['MemberColorGuests']) ? '</span>' : '') : '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" title="' . $txt['profile_of'] . ' ' . $row['poster_name'] . '">' . $row['poster_name'] . '</a>'), 'subject' => $row['subject'], 'short_subject' => shorten_subject($row['subject'], 24), 'preview' => $row['body'], 'time' => timeformat($row['poster_time']), 'timestamp' => forum_time(true, $row['poster_time']), 'raw_timestamp' => $row['poster_time'], 'href' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . ';topicseen#msg' . $row['id_msg'], 'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . ';topicseen#msg' . $row['id_msg'] . '" rel="nofollow">' . $row['subject'] . '</a>'); //The Last Posters id for the MemberColor. if (!empty($modSettings['MemberColorRecentLastPost']) && !empty($row['id_member'])) { $context['MemberColor_ID_MEMBER'][$row['id_member']] = $row['id_member']; } } $smcFunc['db_free_result']($request); // Know set the colors for the Recent posts... if (!empty($context['MemberColor_ID_MEMBER'])) { $colorDatas = load_onlineColors($context['MemberColor_ID_MEMBER']); //So Let's Color The Recent Posts ;) if (!empty($modSettings['MemberColorRecentLastPost']) && is_array($posts)) { foreach ($posts as $postkey => $postid_memcolor) { if (!empty($colorDatas[$postid_memcolor['poster']['id']]['colored_link'])) { $posts[$postkey]['poster']['link'] = $colorDatas[$postid_memcolor['poster']['id']]['colored_link']; } } } } return $posts; }
function getLastPosts($showlatestcount) { global $scripturl, $txt, $db_prefix, $user_info, $modSettings, $func; // Find all the posts. Newer ones will have higher IDs. (assuming the last 20 * number are accessable...) // !!!SLOW This query is now slow, NEEDS to be fixed. Maybe break into two? $request = db_query("\n\t\tSELECT\n\t\t\tm.posterTime, m.subject, m.ID_TOPIC, m.ID_MEMBER, m.ID_MSG,\n\t\t\tIFNULL(mem.realName, m.posterName) AS posterName, t.ID_BOARD, b.name AS bName,\n\t\t\tLEFT(m.body, 384) AS body, m.smileysEnabled\n\t\tFROM ({$db_prefix}messages AS m, {$db_prefix}topics AS t, {$db_prefix}boards AS b)\n\t\t\tLEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)\n\t\tWHERE m.ID_MSG >= " . max(0, $modSettings['maxMsgID'] - 20 * $showlatestcount) . "\n\t\t\tAND t.ID_TOPIC = m.ID_TOPIC\n\t\t\tAND b.ID_BOARD = t.ID_BOARD" . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? "\n\t\t\tAND b.ID_BOARD != {$modSettings['recycle_board']}" : '') . "\n\t\t\tAND {$user_info['query_see_board']}\n\t\tORDER BY m.ID_MSG DESC\n\t\tLIMIT {$showlatestcount}", __FILE__, __LINE__); $posts = array(); while ($row = mysql_fetch_assoc($request)) { // Censor the subject and post for the preview ;). censorText($row['subject']); censorText($row['body']); $row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileysEnabled'], $row['ID_MSG']), array('<br />' => ' '))); if ($func['strlen']($row['body']) > 128) { $row['body'] = $func['substr']($row['body'], 0, 128) . '...'; } // Build the array. $posts[] = array('board' => array('id' => $row['ID_BOARD'], 'name' => $row['bName'], 'href' => $scripturl . '?board=' . $row['ID_BOARD'] . '.0', 'link' => '<a href="' . $scripturl . '?board=' . $row['ID_BOARD'] . '.0">' . $row['bName'] . '</a>'), 'topic' => $row['ID_TOPIC'], 'poster' => array('id' => $row['ID_MEMBER'], 'name' => $row['posterName'], 'href' => empty($row['ID_MEMBER']) ? '' : $scripturl . '?action=profile;u=' . $row['ID_MEMBER'], 'link' => empty($row['ID_MEMBER']) ? $row['posterName'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['posterName'] . '</a>'), 'subject' => $row['subject'], 'short_subject' => shorten_subject($row['subject'], 24), 'preview' => $row['body'], 'time' => timeformat($row['posterTime']), 'timestamp' => forum_time(true, $row['posterTime']), 'raw_timestamp' => $row['posterTime'], 'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['ID_MSG'] . ';topicseen#msg' . $row['ID_MSG'], 'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['ID_MSG'] . ';topicseen#msg' . $row['ID_MSG'] . '">' . $row['subject'] . '</a>'); } mysql_free_result($request); return $posts; }
function getLastPosts($latestPostOptions) { global $scripturl, $txt, $user_info, $modSettings, $smcFunc, $context; // Find all the posts. Newer ones will have higher IDs. (assuming the last 20 * number are accessable...) // !!!SLOW This query is now slow, NEEDS to be fixed. Maybe break into two? $request = smf_db_query(' SELECT m.poster_time, m.subject, m.id_topic, m.id_member, m.id_msg, b.name, m1.subject AS first_subject, IFNULL(mem.real_name, m.poster_name) AS poster_name, t.id_board, b.name AS board_name, SUBSTRING(m.body, 1, 385) AS body, m.smileys_enabled FROM {db_prefix}messages AS m INNER JOIN {db_prefix}topics AS t ON (t.id_topic = m.id_topic) INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board) INNER JOIN {db_prefix}messages AS m1 ON (m1.id_msg = t.id_first_msg) LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member) WHERE m.id_msg >= {int:likely_max_msg}' . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? ' AND b.id_board != {int:recycle_board}' : '') . ' AND {query_wanna_see_board}' . ($modSettings['postmod_active'] ? ' AND t.approved = {int:is_approved} AND m.approved = {int:is_approved}' : '') . ' ORDER BY m.id_msg DESC LIMIT ' . $latestPostOptions['number_posts'], array('likely_max_msg' => max(0, $modSettings['maxMsgID'] - 50 * $latestPostOptions['number_posts']), 'recycle_board' => $modSettings['recycle_board'], 'is_approved' => 1)); $posts = array(); while ($row = mysql_fetch_assoc($request)) { // Censor the subject and post for the preview ;). censorText($row['subject']); censorText($row['body']); $row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']), array('<br />' => ' '))); if (commonAPI::strlen($row['body']) > 128) { $row['body'] = commonAPI::substr($row['body'], 0, 128) . '...'; } $bhref = URL::board($row['id_board'], $row['board_name'], 0, true); $mhref = URL::user($row['id_member'], $row['poster_name']); $thref = URL::topic($row['id_topic'], $row['first_subject'], 0, false, '.msg' . $row['id_msg'], ';topicseen#msg' . $row['id_msg']); // Build the array. $posts[] = array('board' => array('id' => $row['id_board'], 'name' => $row['board_name'], 'href' => $bhref, 'link' => '<a href="' . $bhref . '">' . $row['board_name'] . '</a>'), 'topic' => $row['id_topic'], 'poster' => array('id' => $row['id_member'], 'name' => $row['poster_name'], 'href' => empty($row['id_member']) ? '' : $mhref, 'link' => empty($row['id_member']) ? $row['poster_name'] : '<a href="' . $mhref . '">' . $row['poster_name'] . '</a>'), 'subject' => $row['subject'], 'short_subject' => shorten_subject($row['subject'], 35), 'preview' => $row['body'], 'time' => timeformat($row['poster_time']), 'timestamp' => forum_time(true, $row['poster_time']), 'raw_timestamp' => $row['poster_time'], 'href' => $thref, 'link' => '<a href="' . $thref . '" rel="nofollow">' . $row['first_subject'] . '</a>'); } mysql_free_result($request); return $posts; }
/** * Loads in a group of drafts for the user of a given type (0/posts, 1/pm's) * loads a specific draft for forum use if selected. * Used in the posting screens to allow draft selection * WIll load a draft if selected is supplied via post * * @param type $member_id * @param type $topic * @param type $draft_type * @return boolean */ function ShowDrafts($member_id, $topic = false, $draft_type = 0) { global $smcFunc, $scripturl, $context, $txt, $modSettings; // Permissions if ($draft_type === 0 && empty($context['drafts_save']) || $draft_type === 1 && empty($context['drafts_pm_save']) || empty($member_id)) { return false; } $context['drafts'] = array(); // has a specific draft has been selected? Load it up if there is not a message already in the editor if (isset($_REQUEST['id_draft']) && empty($_POST['subject']) && empty($_POST['message'])) { ReadDraft((int) $_REQUEST['id_draft'], $draft_type, true, true); } // load the drafts this user has available $request = $smcFunc['db_query']('', ' SELECT * FROM {db_prefix}user_drafts WHERE id_member = {int:id_member}' . (!empty($topic) && empty($draft_type) ? ' AND id_topic = {int:id_topic}' : (!empty($topic) ? ' AND id_reply = {int:id_topic}' : '')) . ' AND type = {int:draft_type}' . (!empty($modSettings['drafts_keep_days']) ? ' AND poster_time > {int:time}' : '') . ' ORDER BY poster_time DESC', array('id_member' => $member_id, 'id_topic' => (int) $topic, 'draft_type' => $draft_type, 'time' => !empty($modSettings['drafts_keep_days']) ? time() - $modSettings['drafts_keep_days'] * 86400 : 0)); // add them to the draft array for display while ($row = $smcFunc['db_fetch_assoc']($request)) { // Post drafts if ($draft_type === 0) { $context['drafts'][] = array('subject' => censorText(shorten_subject(stripslashes($row['subject']), 24)), 'poster_time' => timeformat($row['poster_time']), 'link' => '<a href="' . $scripturl . '?action=post;board=' . $row['id_board'] . ';' . (!empty($row['id_topic']) ? 'topic=' . $row['id_topic'] . '.0;' : '') . 'id_draft=' . $row['id_draft'] . '">' . $row['subject'] . '</a>'); } elseif ($draft_type === 1) { $context['drafts'][] = array('subject' => censorText(shorten_subject(stripslashes($row['subject']), 24)), 'poster_time' => timeformat($row['poster_time']), 'link' => '<a href="' . $scripturl . '?action=pm;sa=send;id_draft=' . $row['id_draft'] . '">' . (!empty($row['subject']) ? $row['subject'] : $txt['drafts_none']) . '</a>'); } } $smcFunc['db_free_result']($request); }
function getBoardIndex($boardIndexOptions) { global $smcFunc, $scripturl, $user_info, $modSettings, $txt; global $settings, $context, $show_archived; //xxx show archived boards if ($boardIndexOptions['include_categories']) { if (isset($_GET['show_archived'])) { $_SESSION['show_archived'] = $_GET['show_archived'] == 0 ? 0 : 1; } $show_archived = !empty($user_info['possibly_robot']) || isset($_SESSION['show_archived']) && $_SESSION['show_archived'] == 1; } //xxx end show archived boards // For performance, track the latest post while going through the boards. if (!empty($boardIndexOptions['set_latest_post'])) { $latest_post = array('timestamp' => 0, 'ref' => 0); } // Find all boards and categories, as well as related information. This will be sorted by the natural order of boards and categories, which we control. $result_boards = $smcFunc['db_query']('boardindex_fetch_boards', ' SELECT' . ($boardIndexOptions['include_categories'] ? ' c.id_cat, c.name AS cat_name,' : '') . ' b.id_board, b.name AS board_name, b.description, CASE WHEN b.redirect != {string:blank_string} THEN 1 ELSE 0 END AS is_redirect, b.num_posts, b.num_topics, b.unapproved_posts, b.unapproved_topics, b.id_parent, IFNULL(m.poster_time, 0) AS poster_time, IFNULL(mem.member_name, m.poster_name) AS poster_name, m.subject, m.id_topic, IFNULL(mem.real_name, m.poster_name) AS real_name, ' . ($user_info['is_guest'] ? ' 1 AS is_read, 0 AS new_from,' : ' (IFNULL(lb.id_msg, 0) >= b.id_msg_updated) AS is_read, IFNULL(lb.id_msg, -1) + 1 AS new_from,' . ($boardIndexOptions['include_categories'] ? ' c.can_collapse, IFNULL(cc.id_member, 0) AS is_collapsed,' : '')) . ' IFNULL(mem.id_member, 0) AS id_member, m.id_msg, IFNULL(mods_mem.id_member, 0) AS id_moderator, mods_mem.real_name AS mod_real_name FROM {db_prefix}boards AS b' . ($boardIndexOptions['include_categories'] ? ' LEFT JOIN {db_prefix}categories AS c ON (c.id_cat = b.id_cat)' : '') . ' LEFT JOIN {db_prefix}messages AS m ON (m.id_msg = b.id_last_msg) LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)' . ($user_info['is_guest'] ? '' : ' LEFT JOIN {db_prefix}log_boards AS lb ON (lb.id_board = b.id_board AND lb.id_member = {int:current_member})' . ($boardIndexOptions['include_categories'] ? ' LEFT JOIN {db_prefix}collapsed_categories AS cc ON (cc.id_cat = c.id_cat AND cc.id_member = {int:current_member})' : '')) . ' LEFT JOIN {db_prefix}moderators AS mods ON (mods.id_board = b.id_board) LEFT JOIN {db_prefix}members AS mods_mem ON (mods_mem.id_member = mods.id_member) WHERE {query_see_board}' . (empty($boardIndexOptions['countChildPosts']) ? empty($boardIndexOptions['base_level']) ? '' : ' AND b.child_level >= {int:child_level}' : ' AND b.child_level BETWEEN ' . $boardIndexOptions['base_level'] . ' AND ' . ($boardIndexOptions['base_level'] + 1)) . (isset($show_archived) && !$show_archived ? ' AND c.forumid = 1' : '') . ' ORDER BY ' . ($boardIndexOptions['include_categories'] ? 'c.cat_order, ' : '') . 'b.board_order', array('current_member' => $user_info['id'], 'child_level' => $boardIndexOptions['base_level'], 'blank_string' => '')); // Start with an empty array. if ($boardIndexOptions['include_categories']) { $categories = array(); } else { $this_category = array(); } // Run through the categories and boards (or only boards).... while ($row_board = $smcFunc['db_fetch_assoc']($result_boards)) { // Perhaps we are ignoring this board? $ignoreThisBoard = in_array($row_board['id_board'], $user_info['ignoreboards']); $row_board['is_read'] = !empty($row_board['is_read']) || $ignoreThisBoard ? '1' : '0'; if ($boardIndexOptions['include_categories']) { // Haven't set this category yet. if (empty($categories[$row_board['id_cat']])) { $categories[$row_board['id_cat']] = array('id' => $row_board['id_cat'], 'name' => $row_board['cat_name'], 'is_collapsed' => isset($row_board['can_collapse']) && $row_board['can_collapse'] == 1 && $row_board['is_collapsed'] > 0, 'can_collapse' => isset($row_board['can_collapse']) && $row_board['can_collapse'] == 1, 'collapse_href' => isset($row_board['can_collapse']) ? $scripturl . '?action=collapse;c=' . $row_board['id_cat'] . ';sa=' . ($row_board['is_collapsed'] > 0 ? 'expand;' : 'collapse;') . $context['session_var'] . '=' . $context['session_id'] . '#c' . $row_board['id_cat'] : '', 'collapse_image' => isset($row_board['can_collapse']) ? '<img src="' . $settings['images_url'] . '/' . $context['theme_variant_url'] . ($row_board['is_collapsed'] > 0 ? 'expand.gif" alt="+"' : 'collapse.gif" alt="-"') . ' />' : '', 'href' => $scripturl . '?action=forum#c' . $row_board['id_cat'], 'boards' => array(), 'new' => false); $categories[$row_board['id_cat']]['link'] = '<a id="c' . $row_board['id_cat'] . '"></a>' . ($categories[$row_board['id_cat']]['can_collapse'] ? '<a href="' . $categories[$row_board['id_cat']]['collapse_href'] . '">' . $row_board['cat_name'] . '</a>' : $row_board['cat_name']); } // If this board has new posts in it (and isn't the recycle bin!) then the category is new. if (empty($modSettings['recycle_enable']) || $modSettings['recycle_board'] != $row_board['id_board']) { $categories[$row_board['id_cat']]['new'] |= empty($row_board['is_read']) && $row_board['poster_name'] != ''; } // Avoid showing category unread link where it only has redirection boards. $categories[$row_board['id_cat']]['show_unread'] = !empty($categories[$row_board['id_cat']]['show_unread']) ? 1 : !$row_board['is_redirect']; // Collapsed category - don't do any of this. if ($categories[$row_board['id_cat']]['is_collapsed']) { continue; } // Let's save some typing. Climbing the array might be slower, anyhow. $this_category =& $categories[$row_board['id_cat']]['boards']; } // This is a parent board. if ($row_board['id_parent'] == $boardIndexOptions['parent_id']) { // Is this a new board, or just another moderator? if (!isset($this_category[$row_board['id_board']])) { // Not a child. $isChild = false; $this_category[$row_board['id_board']] = array('new' => empty($row_board['is_read']), 'id' => $row_board['id_board'], 'name' => $row_board['board_name'], 'description' => $row_board['description'], 'moderators' => array(), 'link_moderators' => array(), 'children' => array(), 'link_children' => array(), 'children_new' => false, 'topics' => $row_board['num_topics'], 'posts' => $row_board['num_posts'], 'is_redirect' => $row_board['is_redirect'], 'unapproved_topics' => $row_board['unapproved_topics'], 'unapproved_posts' => $row_board['unapproved_posts'] - $row_board['unapproved_topics'], 'can_approve_posts' => !empty($user_info['mod_cache']['ap']) && ($user_info['mod_cache']['ap'] == array(0) || in_array($row_board['id_board'], $user_info['mod_cache']['ap'])), 'href' => $scripturl . '?board=' . $row_board['id_board'] . '.0', 'link' => '<a href="' . $scripturl . '?board=' . $row_board['id_board'] . '.0">' . $row_board['board_name'] . '</a>'); } if (!empty($row_board['id_moderator'])) { $this_category[$row_board['id_board']]['moderators'][$row_board['id_moderator']] = array('id' => $row_board['id_moderator'], 'name' => $row_board['mod_real_name'], 'href' => $scripturl . '?action=profile;u=' . $row_board['id_moderator'], 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_board['id_moderator'] . '" title="' . $txt['board_moderator'] . '">' . $row_board['mod_real_name'] . '</a>'); $this_category[$row_board['id_board']]['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $row_board['id_moderator'] . '" title="' . $txt['board_moderator'] . '">' . $row_board['mod_real_name'] . '</a>'; } } elseif (isset($this_category[$row_board['id_parent']]['children']) && !isset($this_category[$row_board['id_parent']]['children'][$row_board['id_board']])) { // A valid child! $isChild = true; $this_category[$row_board['id_parent']]['children'][$row_board['id_board']] = array('id' => $row_board['id_board'], 'name' => $row_board['board_name'], 'description' => $row_board['description'], 'new' => empty($row_board['is_read']) && $row_board['poster_name'] != '', 'topics' => $row_board['num_topics'], 'posts' => $row_board['num_posts'], 'is_redirect' => $row_board['is_redirect'], 'unapproved_topics' => $row_board['unapproved_topics'], 'unapproved_posts' => $row_board['unapproved_posts'] - $row_board['unapproved_topics'], 'can_approve_posts' => !empty($user_info['mod_cache']['ap']) && ($user_info['mod_cache']['ap'] == array(0) || in_array($row_board['id_board'], $user_info['mod_cache']['ap'])), 'href' => $scripturl . '?board=' . $row_board['id_board'] . '.0', 'link' => '<a href="' . $scripturl . '?board=' . $row_board['id_board'] . '.0">' . $row_board['board_name'] . '</a>'); // Counting child board posts is... slow :/. if (!empty($boardIndexOptions['countChildPosts']) && !$row_board['is_redirect']) { $this_category[$row_board['id_parent']]['posts'] += $row_board['num_posts']; $this_category[$row_board['id_parent']]['topics'] += $row_board['num_topics']; } // Does this board contain new boards? $this_category[$row_board['id_parent']]['children_new'] |= empty($row_board['is_read']); // This is easier to use in many cases for the theme.... $this_category[$row_board['id_parent']]['link_children'][] =& $this_category[$row_board['id_parent']]['children'][$row_board['id_board']]['link']; } elseif (!empty($boardIndexOptions['countChildPosts'])) { if (!isset($parent_map)) { $parent_map = array(); } if (!isset($parent_map[$row_board['id_parent']])) { foreach ($this_category as $id => $board) { if (!isset($board['children'][$row_board['id_parent']])) { continue; } $parent_map[$row_board['id_parent']] = array(&$this_category[$id], &$this_category[$id]['children'][$row_board['id_parent']]); $parent_map[$row_board['id_board']] = array(&$this_category[$id], &$this_category[$id]['children'][$row_board['id_parent']]); break; } } if (isset($parent_map[$row_board['id_parent']]) && !$row_board['is_redirect']) { $parent_map[$row_board['id_parent']][0]['posts'] += $row_board['num_posts']; $parent_map[$row_board['id_parent']][0]['topics'] += $row_board['num_topics']; $parent_map[$row_board['id_parent']][1]['posts'] += $row_board['num_posts']; $parent_map[$row_board['id_parent']][1]['topics'] += $row_board['num_topics']; continue; } continue; } else { continue; } // Prepare the subject, and make sure it's not too long. censorText($row_board['subject']); $row_board['short_subject'] = shorten_subject($row_board['subject'], 24); $this_last_post = array('id' => $row_board['id_msg'], 'time' => $row_board['poster_time'] > 0 ? timeformat($row_board['poster_time']) : $txt['not_applicable'], 'timestamp' => forum_time(true, $row_board['poster_time']), 'subject' => $row_board['short_subject'], 'member' => array('id' => $row_board['id_member'], 'username' => $row_board['poster_name'] != '' ? $row_board['poster_name'] : $txt['not_applicable'], 'name' => $row_board['real_name'], 'href' => $row_board['poster_name'] != '' && !empty($row_board['id_member']) ? $scripturl . '?action=profile;u=' . $row_board['id_member'] : '', 'link' => $row_board['poster_name'] != '' ? !empty($row_board['id_member']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row_board['id_member'] . '">' . $row_board['real_name'] . '</a>' : $row_board['real_name'] : $txt['not_applicable']), 'start' => 'msg' . $row_board['new_from'], 'topic' => $row_board['id_topic']); // Provide the href and link. if ($row_board['subject'] != '') { $this_last_post['href'] = $scripturl . '?topic=' . $row_board['id_topic'] . '.msg' . ($user_info['is_guest'] ? $row_board['id_msg'] : $row_board['new_from']) . (empty($row_board['is_read']) ? ';boardseen' : '') . '#new'; $this_last_post['link'] = '<a href="' . $this_last_post['href'] . '" title="' . $row_board['subject'] . '">' . $row_board['short_subject'] . '</a>'; } else { $this_last_post['href'] = ''; $this_last_post['link'] = $txt['not_applicable']; } // Set the last post in the parent board. if ($row_board['id_parent'] == $boardIndexOptions['parent_id'] || $isChild && !empty($row_board['poster_time']) && $this_category[$row_board['id_parent']]['last_post']['timestamp'] < forum_time(true, $row_board['poster_time'])) { $this_category[$isChild ? $row_board['id_parent'] : $row_board['id_board']]['last_post'] = $this_last_post; } // Just in the child...? if ($isChild) { $this_category[$row_board['id_parent']]['children'][$row_board['id_board']]['last_post'] = $this_last_post; // If there are no posts in this board, it really can't be new... $this_category[$row_board['id_parent']]['children'][$row_board['id_board']]['new'] &= $row_board['poster_name'] != ''; } elseif ($row_board['poster_name'] == '') { $this_category[$row_board['id_board']]['new'] = false; } // Determine a global most recent topic. if (!empty($boardIndexOptions['set_latest_post']) && !empty($row_board['poster_time']) && $row_board['poster_time'] > $latest_post['timestamp'] && !$ignoreThisBoard) { $latest_post = array('timestamp' => $row_board['poster_time'], 'ref' => &$this_category[$isChild ? $row_board['id_parent'] : $row_board['id_board']]['last_post']); } } $smcFunc['db_free_result']($result_boards); // By now we should know the most recent post...if we wanna know it that is. if (!empty($boardIndexOptions['set_latest_post']) && !empty($latest_post['ref'])) { $context['latest_post'] = $latest_post['ref']; } return $boardIndexOptions['include_categories'] ? $categories : $this_category; }
function template_boardindex_outer_below() { global $modSettings; // Info center collapse object. echo '</td></tr></tbody></table>'; if (!empty($modSettings['sideright'])) { echo '<td valign="top" id="upshrinkRightBarTD"> <div id="upshrinkRightBar" style="width:', $modSettings['siderightwidth'] ? $modSettings['siderightwidth'] : '200px', '; overflow:hidden;"> ', empty($modSettings['sideright1']) ? '' : '<div class="cat_bar"><h3 class="catbg">' . $modSettings['righthtmlbaslik'] . '</h3></div>' . $modSettings['sideright1'] . '', ' ', empty($modSettings['siderightphp']) ? '' : '<div class="cat_bar"><h3 class="catbg">' . $modSettings['rightphpbaslik'] . '</h3></div>'; eval($modSettings['siderightphp']); if (!empty($modSettings['siderighthaberetkin'])) { $array = ssi_boardNews($modSettings['siderighthaber'], $modSettings['siderightsay'], null, 1000, 'array'); echo '<div class="cat_bar"> <h3 class="catbg">', $modSettings['rbaslik'], '</h3> </div>'; global $memberContext; foreach ($array as $news) { loadMemberData($news['poster']['id']); loadMemberContext($news['poster']['id']); echo '<div class="sidehaber"> <div class="sideBaslik"> <h3><a href="', $news['href'], '"><span class="generic_icons sort_up"></span> ', shorten_subject($news['subject'], 30), '</a></h3> </div> <div class="snrj"> ', $memberContext[$news['poster']['id']]['avatar']['image'], ' <p>', $txt['by'], '', $news['poster']['link'], '</p> </div> </div>'; } } echo '</div> </td> <td valign="top"> <button type="button" onclick="rightPanel.toggle();" id="teknoright"></button> </td>'; } echo '</td> </tr></tbody></table>'; template_info_center(); }
function adk_ultimosmensajes() { global $context, $settings, $scripturl, $txt, $db_prefix, $user_info; global $modSettings, $smcFunc, $adkportal, $boardurl, $adkFolder; //SSI FUNCTION $exclude_boards = null; $include_boards = null; $num_recent = !empty($adkportal['adk_two_column']) ? $adkportal['ultimos_mensajes'] * 2 : $adkportal['ultimos_mensajes']; $output_method = 'array'; if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) { $exclude_boards = array($modSettings['recycle_board']); } else { $exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards)); } // Only some boards?. if (is_array($include_boards) || (int) $include_boards === $include_boards) { $include_boards = is_array($include_boards) ? $include_boards : array($include_boards); } elseif ($include_boards != null) { $output_method = $include_boards; $include_boards = array(); } $stable_icons = array('xx', 'thumbup', 'thumbdown', 'exclamation', 'question', 'lamp', 'smiley', 'angry', 'cheesy', 'grin', 'sad', 'wink', 'moved', 'recycled', 'wireless'); $icon_sources = array(); foreach ($stable_icons as $icon) { $icon_sources[$icon] = 'images_url'; } // Find all the posts in distinct topics. Newer ones will have higher IDs. $request = $smcFunc['db_query']('substring', ' SELECT m.poster_time, ms.subject, m.id_topic, m.id_member, m.id_msg, b.id_board, b.name AS board_name, t.num_replies, t.num_views, mem.avatar, mg.online_color, IFNULL(a.id_attach, 0) AS id_attach, a.filename, a.attachment_type, IFNULL(mem.real_name, m.poster_name) AS poster_name, ' . ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' : ' IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= m.id_msg_modified AS is_read, IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from') . ', SUBSTRING(m.body, 1, 384) AS body, m.smileys_enabled, m.icon FROM {db_prefix}topics AS t INNER JOIN {db_prefix}messages AS m ON (m.id_msg = t.id_last_msg) INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board) INNER JOIN {db_prefix}messages AS ms ON (ms.id_msg = t.id_first_msg) LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)' . (!$user_info['is_guest'] ? ' LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = t.id_topic AND lt.id_member = {int:current_member}) LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = {int:current_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 = CASE WHEN mem.id_group = {int:reg_mem_group} THEN mem.id_post_group ELSE mem.id_group END) WHERE t.id_last_msg >= {int:min_message_id} ' . (empty($exclude_boards) ? '' : ' AND b.id_board NOT IN ({array_int:exclude_boards})') . ' ' . (empty($include_boards) ? '' : ' AND b.id_board IN ({array_int:include_boards})') . ' AND {query_wanna_see_board}' . ($modSettings['postmod_active'] ? ' AND t.approved = {int:is_approved} AND m.approved = {int:is_approved}' : '') . ' ORDER BY t.id_last_msg DESC LIMIT ' . $num_recent, array('current_member' => $user_info['id'], 'include_boards' => empty($include_boards) ? '' : $include_boards, 'exclude_boards' => empty($exclude_boards) ? '' : $exclude_boards, 'min_message_id' => $modSettings['maxMsgID'] - 35 * min($num_recent, 5), 'is_approved' => 1, 'reg_mem_group' => 0)); $posts = array(); while ($row = $smcFunc['db_fetch_assoc']($request)) { $row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']), array('<br />' => ' '))); if ($smcFunc['strlen']($row['body']) > 128) { $row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...'; } // Censor the subject. censorText($row['subject']); censorText($row['body']); if (empty($modSettings['messageIconChecks_disable']) && !isset($icon_sources[$row['icon']])) { $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.gif') ? 'images_url' : 'default_images_url'; } // Build the array. $posts[] = array('board' => array('id' => $row['id_board'], 'name' => $row['board_name'], 'href' => $scripturl . '?board=' . $row['id_board'] . '.0', 'link' => '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['board_name'] . '</a>'), 'avatar' => $row['avatar'] == '' ? $row['id_attach'] > 0 ? '<img width="50" height="50" src="' . (empty($row['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $row['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $row['filename']) . '" alt="" border="0" />' : '' : (stristr($row['avatar'], 'http://') ? '<img width="50" height="50" src="' . $row['avatar'] . '" alt="" border="0" />' : '<img width="50" height="50" src="' . $modSettings['avatar_url'] . '/' . $smcFunc['htmlspecialchars']($row['avatar']) . '" alt="" border="0" />'), 'topic' => $row['id_topic'], 'poster' => array('id' => $row['id_member'], 'name' => $row['poster_name'], 'href' => empty($row['id_member']) ? '' : $scripturl . '?action=profile;u=' . $row['id_member'], 'link' => empty($row['id_member']) ? '<b>' . $row['poster_name'] . '</b>' : '<a style="color: ' . $row['online_color'] . '; font-weight: bold;" href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['poster_name'] . '</a>'), 'online_color' => $row['online_color'], 'subject' => $row['subject'], 'replies' => $row['num_replies'], 'views' => $row['num_views'], 'short_subject' => shorten_subject($row['subject'], 25), 'preview' => $row['body'], 'time' => timeformat($row['poster_time']), 'timestamp' => forum_time(true, $row['poster_time']), 'href' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . ';topicseen#new', 'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#new" rel="nofollow">' . $row['subject'] . '</a>', 'new' => !empty($row['is_read']), 'is_new' => empty($row['is_read']), 'new_from' => $row['new_from'], 'icon' => '<img src="' . $settings[$icon_sources[$row['icon']]] . '/post/' . $row['icon'] . '.gif" align="middle" alt="' . $row['icon'] . '" border="0" />'); } $smcFunc['db_free_result']($request); echo ' <table style="width: 100%;">'; if (!empty($adkportal['adk_two_column'])) { $i = 0; echo ' <tr>'; } if (!empty($posts)) { $u = 1; $totales = count($posts); foreach ($posts as $Output) { $ID_TOPIC = $Output['topic']; $subject = $Output['subject']; $posterTime = !empty($adkportal['adk_two_column']) ? timeformat($Output['timestamp'], '%d/%m - %H:%M:%S') : $Output['time']; $id_member = $Output['poster']['id']; $href_last = $Output['href']; if ($id_member == 0) { $MEMBER_STARTED = $Output['poster']['link']; $avatar = '<img src="' . $adkFolder['images'] . '/noavatar.jpg" class="adk_avatar" alt="" />'; } else { $MEMBER_STARTED = $Output['poster']['link']; if (!empty($Output['avatar'])) { $avatar = $Output['avatar']; } else { $avatar = '<img src="' . $adkFolder['images'] . '/noavatar.jpg" class="adk_avatar" alt="" />'; } } if (!empty($adkportal['adk_two_column'])) { if ($i == 2) { echo '</tr>', $totales >= $u - 2 ? '<tr><td colspan="2"><hr /></td></tr>' : '', '<tr>'; $i = 0; } } else { echo '<tr>'; } echo ' <td style="width: 50%"> <table style="width: 100%;" cellspacing="0"> <tr> <td style="width: 55px"> <div> ' . $avatar . ' </div> </td> <td> <a style="text-decoration: none;" href="' . $scripturl . '?topic=' . $ID_TOPIC . '.0" title="' . $subject . '"><b>' . $subject . '</b></a> ', !$Output['is_new'] ? '' : '<a href="' . $scripturl . '?topic=' . $Output['topic'] . '.msg' . $Output['new_from'] . ';topicseen#new" rel="nofollow"><img src="' . $settings['lang_images_url'] . '/new.gif" alt="' . $txt['new'] . '" border="0" /></a>', ' <div style="float: right;padding-right: 5px;"> <a href="' . $href_last . '"> <img alt="" src="' . $settings['images_url'] . '/icons/last_post.gif" /> </a> </div> <br /> <span class="smalltext">' . $txt['adkmod_block_last_updated'] . ': ' . $posterTime . '</span> <br /> <span class="smalltext">' . $txt['post_by'] . ': ' . $MEMBER_STARTED . '</span> <br /> <span class="smalltext">' . $txt['adkmod_forum'] . ': ' . $Output['board']['link'] . '</span> </td> </tr> </table> </td>'; if (!empty($adkportal['adk_two_column'])) { $i++; } else { echo '</tr>'; if ($totales >= $u + 1) { echo '<tr><td colspan="2"><hr /></td></tr>'; } } $u++; } } else { echo ' <td> <div style="text-align: center;"> <strong>' . $txt['adkmod_block_no_post_see'] . '</strong> </div> </td>'; } if (!empty($adkportal['adk_two_column'])) { echo ' </tr>'; } echo ' </table>'; }
function tp_recentTopics($num_recent = 8, $exclude_boards = null, $include_boards = null, $output_method = 'echo') { global $context, $settings, $scripturl, $txt, $db_prefix, $user_info; global $modSettings, $smcFunc; if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) { $exclude_boards = array($modSettings['recycle_board']); } else { $exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards)); } // Only some boards?. if (is_array($include_boards) || (int) $include_boards === $include_boards) { $include_boards = is_array($include_boards) ? $include_boards : array($include_boards); } elseif ($include_boards != null) { $output_method = $include_boards; $include_boards = array(); } // Find all the posts in distinct topics. Newer ones will have higher IDs. $request = $smcFunc['db_query']('substring', ' SELECT m.poster_time, ms.subject, m.id_topic, m.id_member, m.id_msg, b.id_board, b.name AS board_name, t.num_replies, t.num_views, IFNULL(mem.real_name, m.poster_name) AS poster_name, ' . ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' : ' IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= m.id_msg_modified AS is_read, IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from') . ', SUBSTRING(m.body, 1, 384) AS body, m.smileys_enabled, m.icon, IFNULL(a.id_attach, 0) AS ID_ATTACH, a.filename, a.attachment_type as attachmentType, mem.avatar as avy FROM {db_prefix}topics AS t INNER JOIN {db_prefix}messages AS m ON (m.id_msg = t.id_last_msg) INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board) INNER JOIN {db_prefix}messages AS ms ON (ms.id_msg = t.id_first_msg) LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)' . (!$user_info['is_guest'] ? ' LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = t.id_topic AND lt.id_member = {int:current_member}) LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = {int:current_member})' : '') . ' LEFT JOIN {db_prefix}attachments AS a ON (a.id_member = mem.id_member) WHERE t.id_last_msg >= {int:min_message_id} ' . (empty($exclude_boards) ? '' : ' AND b.id_board NOT IN ({array_int:exclude_boards})') . ' ' . (empty($include_boards) ? '' : ' AND b.id_board IN ({array_int:include_boards})') . ' AND {query_wanna_see_board}' . ($modSettings['postmod_active'] ? ' AND t.approved = {int:is_approved} AND m.approved = {int:is_approved}' : '') . ' ORDER BY t.id_last_msg DESC LIMIT ' . $num_recent, array('current_member' => $user_info['id'], 'include_boards' => empty($include_boards) ? '' : $include_boards, 'exclude_boards' => empty($exclude_boards) ? '' : $exclude_boards, 'min_message_id' => $modSettings['maxMsgID'] - 35 * min($num_recent, 5), 'is_approved' => 1)); $posts = array(); while ($row = $smcFunc['db_fetch_assoc']($request)) { $row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']), array('<br />' => ' '))); if ($smcFunc['strlen']($row['body']) > 128) { $row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...'; } // Censor the subject. censorText($row['subject']); censorText($row['body']); // Build the array. $posts[] = array('board' => array('id' => $row['id_board'], 'name' => $row['board_name'], 'href' => $scripturl . '?board=' . $row['id_board'] . '.0', 'link' => '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['board_name'] . '</a>'), 'topic' => $row['id_topic'], 'poster' => array('id' => $row['id_member'], 'name' => $row['poster_name'], 'href' => empty($row['id_member']) ? '' : $scripturl . '?action=profile;u=' . $row['id_member'], 'link' => empty($row['id_member']) ? $row['poster_name'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['poster_name'] . '</a>', 'avatar' => $row['avy'] == '' ? $row['ID_ATTACH'] > 0 ? '<img src="' . (empty($row['attachmentType']) ? $scripturl . '?action=dlattach;attach=' . $row['ID_ATTACH'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $row['filename']) . '" alt="" class="recent_avatar" border="0" />' : '' : (stristr($row['avy'], 'http://') ? '<img src="' . $row['avy'] . '" alt="" class="recent_avatar" border="0" />' : '<img src="' . $modSettings['avatar_url'] . '/' . $smcFunc['htmlspecialchars']($row['avy'], ENT_QUOTES) . '" alt="" class="recent_avatar" border="0" />')), 'subject' => $row['subject'], 'short_subject' => shorten_subject($row['subject'], 25), 'time' => timeformat($row['poster_time']), 'timestamp' => forum_time(true, $row['poster_time']), 'href' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . ';topicseen#new', 'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#new" rel="nofollow">' . $row['subject'] . '</a>', 'new' => !empty($row['is_read']), 'is_new' => empty($row['is_read']), 'new_from' => $row['new_from']); } $smcFunc['db_free_result']($request); return $posts; }
/** * Gets tickets based on supplied criteria; this is a helper function not really intended to be called directly. * * @todo Finish writing and documenting this function. * @param string $query_where SQL clauses to be supplied to the query in addition to {query_see_ticket} - note 'AND' is not required at the start. * @param array $query_where_params Key/value associative array to be injected into the query, related to $query_where. * @param int $query_limit Number of items to limit the query to. * @param string $query_order The clause to order tickets by, defaults to tickets by order of creation. * @return array An array of arrays, each primary item containing the following: * <ul> * <li>id: Main ticket id</li> * <li>display_id: Formatted ticket id in [0000x] format</li> * <li>subject: Ticket subject</li> * <li>short_subject: Shortened version of ticket subject</li> * <li>href: Ticket href</li> * <li>opener: array of details about the ticket starter: * <ul> * <li>id: user id of the person who opened the ticket</li> * <li>name: username of the person who opened the ticket</li> * <li>link: link to the profile of the person who opened the ticket</li> * </ul> * </li> * <li>replier: array of details about the last person to reply to the ticket: * <ul> * <li>id: user id of the last person to reply to the ticket</li> * <li>name: username of the last person to reply to the ticket</li> * <li>link: link to the profile of the last person to reply to the ticket</li> * </ul> * </li> * <li>assigned: array of details about the person who the ticket is assigned to: * <ul> * <li>id: user id of the person who the ticket is assigned to</li> * <li>name: username of the person who the ticket is assigned to or 'Unassigned' otherwise</li> * <li>link: link to the profile of the person who the ticket is assigned to or 'Unassigned' otherwise</li> * </ul> * </li> * <li>num_replies: Number of replies in the ticket</li> * <li>start_time: Formatted string of time the ticket was opened</li> * <li>start_timestamp: Raw timestamp (adjusted for timezones) of ticket being opened</li> * <li>last_time: Formatted string of time the ticket was last replied to</li> * <li>last_timestamp: Raw timestamp (adjusted for timezones) of ticket's last reply</li> * <li>private: Whether the ticket is private or not</li> * <li>urgency_id: Number representing ticket urgency</li> * <li>urgency_string: String representing ticket urgency</li> * <li>status_id: Number representing ticket status</li> * <li>status_text: String representing ticket status</li> * <li>department: Number representing ticket department ID</li> * </ul> * @since 2.0 */ function ssi_getSDTickets($query_where, $query_where_params = array(), $query_limit = 0, $query_order = 'hdt.id_ticket ASC', $output_method = 'echo') { global $smcFunc, $scripturl, $txt, $modSettings; $query_limit = (int) $query_limit; $query = shd_db_query('', ' SELECT hdt.id_ticket, hdt.subject, hdt.num_replies, hdt.private, hdt.urgency, hdt.status, hdt.dept, hdtr_first.poster_time AS start_time, hdt.last_updated AS last_time, IFNULL(mem.real_name, hdtr_first.poster_name) AS starter_name, IFNULL(mem.id_member, 0) AS starter_id, IFNULL(ma.real_name, 0) AS assigned_name, IFNULL(ma.id_member, 0) AS assigned_id, IFNULL(mm.real_name, hdtr_last.modified_name) AS modified_name, IFNULL(mm.id_member, 0) AS modified_id FROM {db_prefix}helpdesk_tickets AS hdt INNER JOIN {db_prefix}helpdesk_ticket_replies AS hdtr_first ON (hdt.id_first_msg = hdtr_first.id_msg) INNER JOIN {db_prefix}helpdesk_ticket_replies AS hdtr_last ON (hdt.id_last_msg = hdtr_last.id_msg) LEFT JOIN {db_prefix}members AS mem ON (hdt.id_member_started = mem.id_member) LEFT JOIN {db_prefix}members AS ma ON (hdt.id_member_assigned = ma.id_member) LEFT JOIN {db_prefix}members AS mm ON (hdt.id_member_updated = mm.id_member) WHERE {query_see_ticket} AND ' . $query_where . ' ORDER BY ' . $query_order . ' ' . ($query_limit == 0 ? '' : 'LIMIT ' . $query_limit), array_merge($query_where_params, array())); $tickets = array(); while ($row = $smcFunc['db_fetch_assoc']($query)) { censorText($row['subject']); $tickets[] = array('id' => $row['id_ticket'], 'display_id' => str_pad($row['id_ticket'], $modSettings['shd_zerofill'], '0', STR_PAD_LEFT), 'subject' => $row['subject'], 'short_subject' => shorten_subject($row['subject'], 25), 'href' => $scripturl . '?action=helpdesk;sa=ticket;ticket=' . $row['id_ticket'], 'opener' => array('id' => $row['starter_id'], 'name' => $row['starter_name'], 'link' => shd_profile_link($row['starter_name'], $row['starter_id'])), 'replier' => array('id' => $row['modified_id'], 'name' => $row['modified_name'], 'link' => shd_profile_link($row['modified_name'], $row['modified_id'])), 'assigned' => array('id' => $row['assigned_id'], 'name' => empty($row['assigned_name']) ? $txt['shd_unassigned'] : $row['assigned_name'], 'link' => empty($row['assigned_name']) ? '<span class="error">' . $txt['shd_unassigned'] . '</span>' : shd_profile_link($row['assigned_name'], $row['assigned_id'])), 'start_time' => timeformat($row['start_time']), 'start_timestamp' => forum_time(true, $row['start_time']), 'last_time' => timeformat($row['last_time']), 'last_timestamp' => forum_time(true, $row['last_time']), 'num_replies' => $row['num_replies'], 'private' => !empty($row['private']), 'urgency_id' => $row['urgency'], 'urgency_string' => $txt['shd_urgency_' . $row['urgency']], 'status_id' => $row['status'], 'status_text' => $txt['shd_status_' . $row['status']], 'department' => $row['dept']); } $smcFunc['db_free_result']($query); if (empty($tickets) || $output_method != 'echo') { return $tickets; } // output this stuff echo ' <table border="0" class="ssi_table">'; foreach ($tickets as $ticket) { echo ' <tr> <td align="right" valign="top" nowrap="nowrap"> [', $ticket['status_text'], '] </td> <td valign="top"> <a href="', $ticket['href'], '">', $ticket['subject'], '</a> ', $txt['by'], ' ', $ticket['replier']['link'], ' </td> <td align="right" nowrap="nowrap"> ', $ticket['last_time'], ' </td> </tr>'; } echo ' </table>'; }
function BoardIndex() { global $txt, $scripturl, $db_prefix, $ID_MEMBER, $user_info, $sourcedir; global $modSettings, $context, $settings; // For wireless, we use the Wireless template... if (WIRELESS) { $context['sub_template'] = WIRELESS_PROTOCOL . '_boardindex'; } else { loadTemplate('BoardIndex'); } // Remember the most recent topic for optimizing the recent posts feature. $most_recent_topic = array('timestamp' => 0, 'ref' => null); // Find all boards and categories, as well as related information. This will be sorted by the natural order of boards and categories, which we control. $result_boards = db_query("\n\t\tSELECT\n\t\t\tc.name AS catName, c.ID_CAT, b.ID_BOARD, b.name AS boardName, b.description,\n\t\t\tb.numPosts, b.numTopics, b.ID_PARENT, IFNULL(m.posterTime, 0) AS posterTime,\n\t\t\tIFNULL(mem.memberName, m.posterName) AS posterName, m.subject, m.ID_TOPIC,\n\t\t\tIFNULL(mem.realName, m.posterName) AS realName," . ($user_info['is_guest'] ? "\n\t\t\t1 AS isRead, 0 AS new_from" : "\n\t\t\t(IFNULL(lb.ID_MSG, 0) >= b.ID_MSG_UPDATED) AS isRead, IFNULL(lb.ID_MSG, -1) + 1 AS new_from,\n\t\t\tc.canCollapse, IFNULL(cc.ID_MEMBER, 0) AS isCollapsed") . ",\n\t\t\tIFNULL(mem.ID_MEMBER, 0) AS ID_MEMBER, m.ID_MSG,\n\t\t\tIFNULL(mods_mem.ID_MEMBER, 0) AS ID_MODERATOR, mods_mem.realName AS modRealName\n\t\tFROM {$db_prefix}boards AS b\n\t\t\tLEFT JOIN {$db_prefix}categories AS c ON (c.ID_CAT = b.ID_CAT)\n\t\t\tLEFT JOIN {$db_prefix}messages AS m ON (m.ID_MSG = b.ID_LAST_MSG)\n\t\t\tLEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)" . (!$user_info['is_guest'] ? "\n\t\t\tLEFT JOIN {$db_prefix}log_boards AS lb ON (lb.ID_BOARD = b.ID_BOARD AND lb.ID_MEMBER = {$ID_MEMBER})\n\t\t\tLEFT JOIN {$db_prefix}collapsed_categories AS cc ON (cc.ID_CAT = c.ID_CAT AND cc.ID_MEMBER = {$ID_MEMBER})" : '') . "\n\t\t\tLEFT JOIN {$db_prefix}moderators AS mods ON (mods.ID_BOARD = b.ID_BOARD)\n\t\t\tLEFT JOIN {$db_prefix}members AS mods_mem ON (mods_mem.ID_MEMBER = mods.ID_MEMBER)\n\t\tWHERE {$user_info['query_see_board']}" . (empty($modSettings['countChildPosts']) ? "\n\t\t\tAND b.childLevel <= 1" : ''), __FILE__, __LINE__); // Run through the categories and boards.... $context['categories'] = array(); while ($row_board = mysql_fetch_assoc($result_boards)) { // Haven't set this category yet. if (empty($context['categories'][$row_board['ID_CAT']])) { $context['categories'][$row_board['ID_CAT']] = array('id' => $row_board['ID_CAT'], 'name' => $row_board['catName'], 'is_collapsed' => isset($row_board['canCollapse']) && $row_board['canCollapse'] == 1 && $row_board['isCollapsed'] > 0, 'can_collapse' => isset($row_board['canCollapse']) && $row_board['canCollapse'] == 1, 'collapse_href' => isset($row_board['canCollapse']) ? $scripturl . '?action=collapse;c=' . $row_board['ID_CAT'] . ';sa=' . ($row_board['isCollapsed'] > 0 ? 'expand' : 'collapse;') . '#' . $row_board['ID_CAT'] : '', 'collapse_image' => isset($row_board['canCollapse']) ? '<img src="' . $settings['images_url'] . '/' . ($row_board['isCollapsed'] > 0 ? 'expand.gif" alt="+"' : 'collapse.gif" alt="-"') . ' border="0" />' : '', 'href' => $scripturl . '#' . $row_board['ID_CAT'], 'boards' => array(), 'new' => false); $context['categories'][$row_board['ID_CAT']]['link'] = '<a name="' . $row_board['ID_CAT'] . '" href="' . (isset($row_board['canCollapse']) ? $context['categories'][$row_board['ID_CAT']]['collapse_href'] : $context['categories'][$row_board['ID_CAT']]['href']) . '">' . $row_board['catName'] . '</a>'; } // If this board has new posts in it (and isn't the recycle bin!) then the category is new. if (empty($modSettings['recycle_enable']) || $modSettings['recycle_board'] != $row_board['ID_BOARD']) { $context['categories'][$row_board['ID_CAT']]['new'] |= empty($row_board['isRead']) && $row_board['posterName'] != ''; } // Collapsed category - don't do any of this. if ($context['categories'][$row_board['ID_CAT']]['is_collapsed']) { continue; } // Let's save some typing. Climbing the array might be slower, anyhow. $this_category =& $context['categories'][$row_board['ID_CAT']]['boards']; // This is a parent board. if (empty($row_board['ID_PARENT'])) { // Is this a new board, or just another moderator? if (!isset($this_category[$row_board['ID_BOARD']])) { // Not a child. $isChild = false; $this_category[$row_board['ID_BOARD']] = array('new' => empty($row_board['isRead']), 'id' => $row_board['ID_BOARD'], 'name' => $row_board['boardName'], 'description' => $row_board['description'], 'moderators' => array(), 'link_moderators' => array(), 'children' => array(), 'link_children' => array(), 'children_new' => false, 'topics' => $row_board['numTopics'], 'posts' => $row_board['numPosts'], 'href' => $scripturl . '?board=' . $row_board['ID_BOARD'] . '.0', 'link' => '<a href="' . $scripturl . '?board=' . $row_board['ID_BOARD'] . '.0">' . $row_board['boardName'] . '</a>'); } if (!empty($row_board['ID_MODERATOR'])) { $this_category[$row_board['ID_BOARD']]['moderators'][$row_board['ID_MODERATOR']] = array('id' => $row_board['ID_MODERATOR'], 'name' => $row_board['modRealName'], 'href' => $scripturl . '?action=profile;u=' . $row_board['ID_MODERATOR'], 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_board['ID_MODERATOR'] . '" title="' . $txt[62] . '">' . $row_board['modRealName'] . '</a>'); $this_category[$row_board['ID_BOARD']]['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $row_board['ID_MODERATOR'] . '" title="' . $txt[62] . '">' . $row_board['modRealName'] . '</a>'; } } elseif (isset($this_category[$row_board['ID_PARENT']]['children']) && !isset($this_category[$row_board['ID_PARENT']]['children'][$row_board['ID_BOARD']])) { // A valid child! $isChild = true; $this_category[$row_board['ID_PARENT']]['children'][$row_board['ID_BOARD']] = array('id' => $row_board['ID_BOARD'], 'name' => $row_board['boardName'], 'description' => $row_board['description'], 'new' => empty($row_board['isRead']) && $row_board['posterName'] != '', 'topics' => $row_board['numTopics'], 'posts' => $row_board['numPosts'], 'href' => $scripturl . '?board=' . $row_board['ID_BOARD'] . '.0', 'link' => '<a href="' . $scripturl . '?board=' . $row_board['ID_BOARD'] . '.0">' . $row_board['boardName'] . '</a>'); // Counting child board posts is... slow :/. if (!empty($modSettings['countChildPosts'])) { $this_category[$row_board['ID_PARENT']]['posts'] += $row_board['numPosts']; $this_category[$row_board['ID_PARENT']]['topics'] += $row_board['numTopics']; } // Does this board contain new boards? $this_category[$row_board['ID_PARENT']]['children_new'] |= empty($row_board['isRead']); // This is easier to use in many cases for the theme.... $this_category[$row_board['ID_PARENT']]['link_children'][] =& $this_category[$row_board['ID_PARENT']]['children'][$row_board['ID_BOARD']]['link']; } elseif (!empty($modSettings['countChildPosts'])) { if (!isset($parent_map)) { $parent_map = array(); } if (!isset($parent_map[$row_board['ID_PARENT']])) { foreach ($this_category as $id => $board) { if (!isset($board['children'][$row_board['ID_PARENT']])) { continue; } $parent_map[$row_board['ID_PARENT']] = array(&$this_category[$id], &$this_category[$id]['children'][$row_board['ID_PARENT']]); $parent_map[$row_board['ID_BOARD']] = array(&$this_category[$id], &$this_category[$id]['children'][$row_board['ID_PARENT']]); break; } } if (isset($parent_map[$row_board['ID_PARENT']])) { $parent_map[$row_board['ID_PARENT']][0]['posts'] += $row_board['numPosts']; $parent_map[$row_board['ID_PARENT']][0]['topics'] += $row_board['numTopics']; $parent_map[$row_board['ID_PARENT']][1]['posts'] += $row_board['numPosts']; $parent_map[$row_board['ID_PARENT']][1]['topics'] += $row_board['numTopics']; continue; } continue; } else { continue; } // Prepare the subject, and make sure it's not too long. censorText($row_board['subject']); $row_board['short_subject'] = shorten_subject($row_board['subject'], 24); $this_last_post = array('id' => $row_board['ID_MSG'], 'time' => $row_board['posterTime'] > 0 ? timeformat($row_board['posterTime']) : $txt[470], 'timestamp' => forum_time(true, $row_board['posterTime']), 'subject' => $row_board['short_subject'], 'member' => array('id' => $row_board['ID_MEMBER'], 'username' => $row_board['posterName'] != '' ? $row_board['posterName'] : $txt[470], 'name' => $row_board['realName'], 'href' => $row_board['posterName'] != '' && !empty($row_board['ID_MEMBER']) ? $scripturl . '?action=profile;u=' . $row_board['ID_MEMBER'] : '', 'link' => $row_board['posterName'] != '' ? !empty($row_board['ID_MEMBER']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row_board['ID_MEMBER'] . '">' . $row_board['realName'] . '</a>' : $row_board['realName'] : $txt[470]), 'start' => 'msg' . $row_board['new_from'], 'topic' => $row_board['ID_TOPIC']); // Provide the href and link. if ($row_board['subject'] != '') { $this_last_post['href'] = $scripturl . '?topic=' . $row_board['ID_TOPIC'] . '.msg' . ($user_info['is_guest'] ? $modSettings['maxMsgID'] : $row_board['new_from']) . (empty($row_board['isRead']) ? ';boardseen' : '') . '#new'; $this_last_post['link'] = '<a href="' . $this_last_post['href'] . '" title="' . $row_board['subject'] . '">' . $row_board['short_subject'] . '</a>'; } else { $this_last_post['href'] = ''; $this_last_post['link'] = $txt[470]; } // Set the last post in the parent board. if (empty($row_board['ID_PARENT']) || $isChild && !empty($row_board['posterTime']) && $this_category[$row_board['ID_PARENT']]['last_post']['timestamp'] < forum_time(true, $row_board['posterTime'])) { $this_category[$isChild ? $row_board['ID_PARENT'] : $row_board['ID_BOARD']]['last_post'] = $this_last_post; } // Just in the child...? if ($isChild) { $this_category[$row_board['ID_PARENT']]['children'][$row_board['ID_BOARD']]['last_post'] = $this_last_post; // If there are no posts in this board, it really can't be new... $this_category[$row_board['ID_PARENT']]['children'][$row_board['ID_BOARD']]['new'] &= $row_board['posterName'] != ''; } elseif ($row_board['posterName'] == '') { $this_category[$row_board['ID_BOARD']]['new'] = false; } // Determine a global most recent topic. if (!empty($row_board['posterTime']) && forum_time(true, $row_board['posterTime']) > $most_recent_topic['timestamp']) { $most_recent_topic = array('timestamp' => forum_time(true, $row_board['posterTime']), 'ref' => &$this_category[$isChild ? $row_board['ID_PARENT'] : $row_board['ID_BOARD']]['last_post']); } } mysql_free_result($result_boards); // Load the users online right now. $result = db_query("\n\t\tSELECT\n\t\t\tlo.ID_MEMBER, lo.logTime, mem.realName, mem.memberName, mem.showOnline,\n\t\t\tmg.onlineColor, mg.ID_GROUP, mg.groupName\n\t\tFROM {$db_prefix}log_online AS lo\n\t\t\tLEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = lo.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))", __FILE__, __LINE__); $context['users_online'] = array(); $context['list_users_online'] = array(); $context['online_groups'] = array(); $context['num_guests'] = 0; $context['num_buddies'] = 0; $context['num_users_hidden'] = 0; $context['show_buddies'] = !empty($user_info['buddies']); while ($row = mysql_fetch_assoc($result)) { if (empty($row['realName'])) { $context['num_guests']++; continue; } elseif (empty($row['showOnline']) && !allowedTo('moderate_forum')) { $context['num_users_hidden']++; continue; } // Some basic color coding... if (!empty($row['onlineColor'])) { $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '" style="color: ' . $row['onlineColor'] . ';">' . $row['realName'] . '</a>'; } else { $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['realName'] . '</a>'; } $is_buddy = in_array($row['ID_MEMBER'], $user_info['buddies']); if ($is_buddy) { $context['num_buddies']++; $link = '<b>' . $link . '</b>'; } $context['users_online'][$row['logTime'] . $row['memberName']] = array('id' => $row['ID_MEMBER'], 'username' => $row['memberName'], 'name' => $row['realName'], 'group' => $row['ID_GROUP'], 'href' => $scripturl . '?action=profile;u=' . $row['ID_MEMBER'], 'link' => $link, 'is_buddy' => $is_buddy, 'hidden' => empty($row['showOnline'])); $context['list_users_online'][$row['logTime'] . $row['memberName']] = empty($row['showOnline']) ? '<i>' . $link . '</i>' : $link; if (!isset($context['online_groups'][$row['ID_GROUP']])) { $context['online_groups'][$row['ID_GROUP']] = array('id' => $row['ID_GROUP'], 'name' => $row['groupName'], 'color' => $row['onlineColor']); } } mysql_free_result($result); krsort($context['users_online']); krsort($context['list_users_online']); ksort($context['online_groups']); $context['num_users_online'] = count($context['users_online']) + $context['num_users_hidden']; // Track most online statistics? if (!empty($modSettings['trackStats'])) { // Determine the most users online - both all time and per day. $total_users = $context['num_guests'] + $context['num_users_online']; // More members on now than ever were? Update it! if (!isset($modSettings['mostOnline']) || $total_users >= $modSettings['mostOnline']) { updateSettings(array('mostOnline' => $total_users, 'mostDate' => time())); } $date = strftime('%Y-%m-%d', forum_time(false)); // One or more stats are not up-to-date? if (!isset($modSettings['mostOnlineUpdated']) || $modSettings['mostOnlineUpdated'] != $date) { $request = db_query("\n\t\t\t\tSELECT mostOn\n\t\t\t\tFROM {$db_prefix}log_activity\n\t\t\t\tWHERE date = '{$date}'\n\t\t\t\tLIMIT 1", __FILE__, __LINE__); // The log_activity hasn't got an entry for today? if (mysql_num_rows($request) == 0) { db_query("\n\t\t\t\t\tINSERT IGNORE INTO {$db_prefix}log_activity\n\t\t\t\t\t\t(date, mostOn)\n\t\t\t\t\tVALUES ('{$date}', {$total_users})", __FILE__, __LINE__); } else { list($modSettings['mostOnlineToday']) = mysql_fetch_row($request); if ($total_users > $modSettings['mostOnlineToday']) { trackStats(array('mostOn' => $total_users)); } $total_users = max($total_users, $modSettings['mostOnlineToday']); } mysql_free_result($request); updateSettings(array('mostOnlineUpdated' => $date, 'mostOnlineToday' => $total_users)); } elseif ($total_users > $modSettings['mostOnlineToday']) { trackStats(array('mostOn' => $total_users)); updateSettings(array('mostOnlineUpdated' => $date, 'mostOnlineToday' => $total_users)); } } // Set the latest member. $context['latest_member'] =& $context['common_stats']['latest_member']; // Load the most recent post? if (!empty($settings['number_recent_posts']) && $settings['number_recent_posts'] == 1 || $settings['show_sp1_info']) { $context['latest_post'] = $most_recent_topic['ref']; } if (!empty($settings['number_recent_posts']) && $settings['number_recent_posts'] > 1) { require_once $sourcedir . '/Recent.php'; if (($context['latest_posts'] = cache_get_data('boardindex-latest_posts:' . md5($user_info['query_see_board'] . $user_info['language']), 180)) == null) { $context['latest_posts'] = getLastPosts($settings['number_recent_posts']); cache_put_data('boardindex-latest_posts:' . md5($user_info['query_see_board'] . $user_info['language']), $context['latest_posts'], 180); } // We have to clean up the cached data a bit. foreach ($context['latest_posts'] as $k => $post) { $context['latest_posts'][$k]['time'] = timeformat($post['raw_timestamp']); $context['latest_posts'][$k]['timestamp'] = forum_time(true, $post['raw_timestamp']); } } $settings['display_recent_bar'] = !empty($settings['number_recent_posts']) ? $settings['number_recent_posts'] : 0; $settings['show_member_bar'] &= allowedTo('view_mlist'); $context['show_stats'] = allowedTo('view_stats') && !empty($modSettings['trackStats']); $context['show_member_list'] = allowedTo('view_mlist'); $context['show_who'] = allowedTo('who_view') && !empty($modSettings['who_enabled']); // Set some permission related settings. $context['show_login_bar'] = $user_info['is_guest'] && !empty($modSettings['enableVBStyleLogin']); $context['show_calendar'] = allowedTo('calendar_view') && !empty($modSettings['cal_enabled']); // Load the calendar? if ($context['show_calendar']) { $context['show_calendar'] = calendarDoIndex(); } $context['page_title'] = $txt[18]; }
function tp_recentTopics($num_recent = 8, $exclude_boards = null, $output_method = 'echo') { global $context, $scripturl, $user_info, $modSettings, $smcFunc; if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) { $exclude_boards = array($modSettings['recycle_board']); } else { $exclude_boards = empty($exclude_boards) ? array() : $exclude_boards; } // !!! // Why the use of SMF 1.0/1.1 naming scheme? // Find all the posts in distinct topics. Newer ones will have higher IDs. $request = $smcFunc['db_query']('', ' SELECT m.poster_time as posterTime, ms.subject, m.id_topic as ID_TOPIC, m.id_member as ID_MEMBER, m.id_msg as ID_MSG, b.id_board as ID_BOARD, b.name AS bName, IFNULL(mem.real_name, m.poster_name) AS posterName, ' . ($user_info['is_guest'] ? '1 AS isRead, 0 AS new_from' : ' IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= m.id_msg_modified AS isRead, IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from') . ', IFNULL(a.id_attach, 0) AS ID_ATTACH, a.filename, a.attachment_type as attachmentType, mem.avatar as avy FROM ({db_prefix}messages AS m, {db_prefix}topics AS t, {db_prefix}boards AS b, {db_prefix}messages AS ms) LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)' . (!$user_info['is_guest'] ? ' LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = t.id_topic AND lt.id_member = ' . $context['user']['id'] . ') LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = ' . $context['user']['id'] . ')' : '') . ' LEFT JOIN {db_prefix}attachments AS a ON (a.id_member = mem.id_member) WHERE t.id_last_msg >= ' . ($modSettings['maxMsgID'] - 35 * min($num_recent, 5)) . ' AND t.id_last_msg = m.id_msg AND b.id_board = t.id_board' . (empty($exclude_boards) ? '' : ' AND b.id_board NOT IN ({string:exclude})') . ' AND {query_see_board}' . ($modSettings['postmod_active'] ? ' AND t.approved = {int:is_approved} AND m.approved = {int:is_approved}' : '') . ' AND ms.id_msg = t.id_first_msg ORDER BY t.id_last_msg DESC LIMIT {int:num_recent}', array('exclude' => implode(', ', $exclude_boards), 'num_recent' => $num_recent, 'is_approved' => 1)); $posts = array(); while ($row = $smcFunc['db_fetch_assoc']($request)) { // Censor the subject. censorText($row['subject']); // Build the array. $posts[] = array('board' => array('id' => $row['ID_BOARD'], 'name' => $row['bName'], 'href' => $scripturl . '?board=' . $row['ID_BOARD'] . '.0', 'link' => '<a href="' . $scripturl . '?board=' . $row['ID_BOARD'] . '.0">' . $row['bName'] . '</a>'), 'topic' => $row['ID_TOPIC'], 'poster' => array('id' => $row['ID_MEMBER'], 'name' => $row['posterName'], 'href' => empty($row['ID_MEMBER']) ? '' : $scripturl . '?action=profile;u=' . $row['ID_MEMBER'], 'link' => empty($row['ID_MEMBER']) ? $row['posterName'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['posterName'] . '</a>', 'avatar' => $row['avy'] == '' ? $row['ID_ATTACH'] > 0 ? '<img src="' . (empty($row['attachmentType']) ? $scripturl . '?action=dlattach;attach=' . $row['ID_ATTACH'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $row['filename']) . '" alt="" class="recent_avatar" border="0" />' : '' : (stristr($row['avy'], 'http://') ? '<img src="' . $row['avy'] . '" alt="" class="recent_avatar" border="0" />' : '<img src="' . $modSettings['avatar_url'] . '/' . $smcFunc['htmlspecialchars']($row['avy'], ENT_QUOTES) . '" alt="" class="recent_avatar" border="0" />')), 'subject' => $row['subject'], 'short_subject' => shorten_subject($row['subject'], 25), 'time' => timeformat($row['posterTime']), 'timestamp' => forum_time(true, $row['posterTime']), 'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['ID_MSG'] . ';topicseen#new', 'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['ID_MSG'] . '#new">' . $row['subject'] . '</a>', 'new' => !empty($row['isRead']), 'new_from' => $row['new_from']); } $smcFunc['db_free_result']($request); return $posts; }
function Who() { global $context, $scripturl, $user_info, $txt, $modSettings, $memberContext, $sourcedir; // Permissions, permissions, permissions. isAllowedTo('who_view'); require_once $sourcedir . '/lib/Subs-MembersOnline.php'; $context['sef_full_rewrite'] = true; // 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'); EoS_Smarty::loadTemplate('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']; } // 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 = smf_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) = mysql_fetch_row($request); mysql_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 = smf_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 = 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['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'], 'id_unique' => base64_encode($row['session']), 'color' => empty($row['online_color']) ? '' : $row['online_color']); $url = @unserialize($row['url']); $context['members'][$row['session']]['user_agent'] = isset($url['USER_AGENT']) ? $url['USER_AGENT'] : ''; $context['members'][$row['session']]['user_agent_short'] = isset($url['USER_AGENT']) ? shorten_subject(substr($url['USER_AGENT'], 0, strpos($url['USER_AGENT'], ' ')), 25) : ''; $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['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' => URL::action($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 template_body_above() { global $context, $settings, $scripturl, $txt, $modSettings; // Wrapper div now echoes permanently for better layout options. h1 a is now target for "Go up" links. echo ' <div id="ust"> <div class="frame">'; // If the user is logged in, display some things that might be useful. if ($context['user']['is_logged']) { // Firstly, the user's menu echo ' <ul class="floatleft" id="top_info"> <li> <a href="', $scripturl, '?action=profile"', !empty($context['self_profile']) ? ' class="active"' : '', ' id="profile_menu_top" onclick="return false;">'; if (!empty($context['user']['avatar'])) { echo $context['user']['avatar']['image']; } echo $context['user']['name'], ' ▼</a> <div id="profile_menu" class="top_menu"></div> </li>'; // Secondly, PMs if we're doing them if ($context['allow_pm']) { echo ' <li> <a href="', $scripturl, '?action=pm"', !empty($context['self_pm']) ? ' class="active"' : '', ' id="pm_menu_top">', $txt['pm_short'], !empty($context['user']['unread_messages']) ? ' <span class="amt">' . $context['user']['unread_messages'] . '</span>' : '', '</a> <div id="pm_menu" class="top_menu scrollable"></div> </li>'; } // Thirdly, alerts echo ' <li> <a href="', $scripturl, '?action=profile;area=showalerts;u=', $context['user']['id'], '"', !empty($context['self_alerts']) ? ' class="active"' : '', ' id="alerts_menu_top">', $txt['alerts'], !empty($context['user']['alerts']) ? ' <span class="amt">' . $context['user']['alerts'] . '</span>' : '', '</a> <div id="alerts_menu" class="top_menu scrollable"></div> </li>'; // And now we're done. echo ' </ul>'; } else { echo ' <ul class="floatleft welcome"> <li>', sprintf($txt[$context['can_register'] ? 'welcome_guest_register' : 'welcome_guest'], $txt['guest_title'], $context['forum_name_html_safe'], $scripturl . '?action=login', 'return reqOverlayDiv(this.href, ' . JavaScriptEscape($txt['login']) . ');', $scripturl . '?action=signup'), '</li> </ul>'; } // Show a random news item? (or you could pick one from news_lines...) if (!empty($settings['enable_news']) && !empty($context['random_news_line'])) { echo ' <div class="news"> <h2>', $txt['news'], ': </h2> <p>', $context['random_news_line'], '</p> </div>'; } global $db_prefix, $scripturl, $smcFunc; $request = $smcFunc['db_query']('', "SELECT f.ID_FILE, f.ID_MEMBER, f.date, f.ID_CAT, f.totaldownloads, f.title AS ftitle,\n\t c.title, m.real_Name, m.ID_MEMBER AS mID_MEMBER\n\t FROM {$db_prefix}down_file AS f, {$db_prefix}down_cat AS c, {$db_prefix}members AS m\n\t WHERE f.ID_CAT = '7'\n\t AND f.approved = '1'\n\t AND f.ID_MEMBER = m.ID_MEMBER\n\t ORDER BY RAND()\n\t LIMIT 1"); while ($row = $smcFunc['db_fetch_assoc']($request)) { echo ' <div class="solborder rightla"><a href="', $scripturl, '?action=downloads;sa=view;id=', $row['ID_FILE'], '" title="', $row['ftitle'], '">' . shorten_subject($row['ftitle'], 30) . '</a></div>'; } echo ' </div> </div>'; echo ' <div class="menuyeri"> <div id="mcolor" class="floatright"> <a class="mor" href="', $scripturl, '?variant=mor" title=""></a> <a class="red" href="', $scripturl, '?variant=red" title=""></a> <a class="blue" href="', $scripturl, '?variant=blue" title=""></a> <a class="green" href="', $scripturl, '?variant=green" title=""></a> <a class="orange" href="', $scripturl, '?variant=orange" title=""></a> <a class="black" href="', $scripturl, '?variant=black" title=""></a> </div> <div class="frame"> <a href="', $scripturl, '" title="Smf Destek"><img id="logos" src="' . $settings['images_url'] . '/theme/logo.png" alt="smfdestek" title="Smf Destek"></a>'; template_menu(); if ($context['allow_search']) { echo ' <form id="aramaz" class="floatright" action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '"> <input type="search" name="search" value="" class="aramaz"> '; // Search within current topic? if (!empty($context['current_topic'])) { echo ' <input type="hidden" name="sd_topic" value="', $context['current_topic'], '">'; } elseif (!empty($context['current_board'])) { echo ' <input type="hidden" name="sd_brd[', $context['current_board'], ']" value="', $context['current_board'], '">'; } echo ' </form>'; } echo ' </div> </div>'; echo ' <div id="wrapper"> <div id="inner_section">'; // Show the menu here, according to the menu sub template, followed by the navigation tree. theme_linktree(); echo ' </div>'; // The main content should go here. }
/** * A complicated but relatively quick internal search. */ function AdminSearchInternal() { global $context, $txt, $helptxt, $scripturl, $sourcedir; // Try to get some more memory. setMemoryLimit('128M'); // Load a lot of language files. $language_files = array('Help', 'ManageMail', 'ManageSettings', 'ManageCalendar', 'ManageBoards', 'ManagePaid', 'ManagePermissions', 'Search', 'Login', 'ManageSmileys'); // All the files we need to include. $include_files = array('ManageSettings', 'ManageBoards', 'ManageNews', 'ManageAttachments', 'ManageCalendar', 'ManageMail', 'ManagePaid', 'ManagePermissions', 'ManagePosts', 'ManageRegistration', 'ManageSearch', 'ManageSearchEngines', 'ManageServer', 'ManageSmileys', 'ManageLanguages'); // This is a special array of functions that contain setting data - we query all these to simply pull all setting bits! $settings_search = array(array('ModifyCoreFeatures', 'area=corefeatures'), array('ModifyBasicSettings', 'area=featuresettings;sa=basic'), array('ModifyLayoutSettings', 'area=featuresettings;sa=layout'), array('ModifyKarmaSettings', 'area=featuresettings;sa=karma'), array('ModifySignatureSettings', 'area=featuresettings;sa=sig'), array('ModifyGeneralSecuritySettings', 'area=securitysettings;sa=general'), array('ModifySpamSettings', 'area=securitysettings;sa=spam'), array('ModifyModerationSettings', 'area=securitysettings;sa=moderation'), array('ModifyGeneralModSettings', 'area=modsettings;sa=general'), array('ManageAttachmentSettings', 'area=manageattachments;sa=attachments'), array('ManageAvatarSettings', 'area=manageattachments;sa=avatars'), array('ModifyCalendarSettings', 'area=managecalendar;sa=settings'), array('EditBoardSettings', 'area=manageboards;sa=settings'), array('ModifyMailSettings', 'area=mailqueue;sa=settings'), array('ModifyNewsSettings', 'area=news;sa=settings'), array('GeneralPermissionSettings', 'area=permissions;sa=settings'), array('ModifyPostSettings', 'area=postsettings;sa=posts'), array('ModifyBBCSettings', 'area=postsettings;sa=bbc'), array('ModifyTopicSettings', 'area=postsettings;sa=topics'), array('EditSearchSettings', 'area=managesearch;sa=settings'), array('EditSmileySettings', 'area=smileys;sa=settings'), array('ModifyGeneralSettings', 'area=serversettings;sa=general'), array('ModifyDatabaseSettings', 'area=serversettings;sa=database'), array('ModifyCookieSettings', 'area=serversettings;sa=cookie'), array('ModifyCacheSettings', 'area=serversettings;sa=cache'), array('ModifyLanguageSettings', 'area=languages;sa=settings'), array('ModifyRegistrationSettings', 'area=regcenter;sa=settings'), array('ManageSearchEngineSettings', 'area=sengines;sa=settings'), array('ModifySubscriptionSettings', 'area=paidsubscribe;sa=settings'), array('ModifyPruningSettings', 'area=logs;sa=pruning')); call_integration_hook('integrate_admin_search', array(&$language_files, &$include_files, &$settings_search)); loadLanguage(implode('+', $language_files)); foreach ($include_files as $file) { require_once $sourcedir . '/' . $file . '.php'; } /* This is the huge array that defines everything... it's a huge array of items formatted as follows: 0 = Language index (Can be array of indexes) to search through for this setting. 1 = URL for this indexes page. 2 = Help index for help associated with this item (If different from 0) */ $search_data = array('sections' => array(), 'settings' => array(array('COPPA', 'area=regcenter;sa=settings'), array('CAPTCHA', 'area=securitysettings;sa=spam'))); // Go through the admin menu structure trying to find suitably named areas! foreach ($context[$context['admin_menu_name']]['sections'] as $section) { foreach ($section['areas'] as $menu_key => $menu_item) { $search_data['sections'][] = array($menu_item['label'], 'area=' . $menu_key); if (!empty($menu_item['subsections'])) { foreach ($menu_item['subsections'] as $key => $sublabel) { if (isset($sublabel['label'])) { $search_data['sections'][] = array($sublabel['label'], 'area=' . $menu_key . ';sa=' . $key); } } } } } foreach ($settings_search as $setting_area) { // Get a list of their variables. $config_vars = $setting_area[0](true); foreach ($config_vars as $var) { if (!empty($var[1]) && !in_array($var[0], array('permissions', 'switch'))) { $search_data['settings'][] = array($var[isset($var[2]) && in_array($var[2], array('file', 'db')) ? 0 : 1], $setting_area[1]); } } } $context['page_title'] = $txt['admin_search_results']; $context['search_results'] = array(); $search_term = strtolower(un_htmlspecialchars($context['search_term'])); // Go through all the search data trying to find this text! foreach ($search_data as $section => $data) { foreach ($data as $item) { $found = false; if (!is_array($item[0])) { $item[0] = array($item[0]); } foreach ($item[0] as $term) { if (stripos($term, $search_term) !== false || isset($txt[$term]) && stripos($txt[$term], $search_term) !== false || isset($txt['setting_' . $term]) && stripos($txt['setting_' . $term], $search_term) !== false) { $found = $term; break; } } if ($found) { // Format the name - and remove any descriptions the entry may have. $name = isset($txt[$found]) ? $txt[$found] : (isset($txt['setting_' . $found]) ? $txt['setting_' . $found] : $found); $name = preg_replace('~<(?:div|span)\\sclass="smalltext">.+?</(?:div|span)>~', '', $name); $context['search_results'][] = array('url' => (substr($item[1], 0, 4) == 'area' ? $scripturl . '?action=admin;' . $item[1] : $item[1]) . ';' . $context['session_var'] . '=' . $context['session_id'] . (substr($item[1], 0, 4) == 'area' && $section == 'settings' ? '#' . $item[0][0] : ''), 'name' => $name, 'type' => $section, 'help' => shorten_subject(isset($item[2]) ? strip_tags($helptxt[$item[2]]) : (isset($helptxt[$found]) ? strip_tags($helptxt[$found]) : ''), 255)); } } } }
function action_get_new_topic() { global $context, $settings, $scripturl, $db_prefix, $user_info, $topic_per_page, $start_num; global $modSettings, $smcFunc; $num_recent = $topic_per_page; $exclude_boards = null; $include_boards = null; if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) { $exclude_boards = array($modSettings['recycle_board']); } else { $exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards)); } // Only some boards?. if (is_array($include_boards) || (int) $include_boards === $include_boards) { $include_boards = is_array($include_boards) ? $include_boards : array($include_boards); } elseif ($include_boards != null) { $output_method = $include_boards; $include_boards = array(); } $stable_icons = array('xx', 'thumbup', 'thumbdown', 'exclamation', 'question', 'lamp', 'smiley', 'angry', 'cheesy', 'grin', 'sad', 'wink', 'moved', 'recycled', 'wireless'); $icon_sources = array(); foreach ($stable_icons as $icon) { $icon_sources[$icon] = 'images_url'; } // Find all the posts in distinct topics. Newer ones will have higher IDs. $request = $smcFunc['db_query']('substring', ' SELECT m.poster_time, m.body, m.smileys_enabled, m.icon, ms.subject, m.id_topic, m.id_member, m.id_msg, b.id_board, b.name AS board_name, t.num_replies, t.num_views, t.id_member_started, t.approved, t.is_sticky, locked, t.id_topic, IFNULL(mem.real_name, m.poster_name) AS poster_name, mem.avatar as avatar_last' . ($user_info['is_guest'] ? ', 1 AS is_read, 0 AS new_from' : ', IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= m.id_msg_modified AS is_read, IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from, IFNULL(al.id_attach, 0) AS id_attach_last, al.filename as filename_last, al.attachment_type as attachment_type_last') . ' FROM {db_prefix}topics AS t INNER JOIN {db_prefix}messages AS m ON (m.id_msg = t.id_last_msg) INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board) INNER JOIN {db_prefix}messages AS ms ON (ms.id_msg = t.id_first_msg) LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)' . (!$user_info['is_guest'] ? ' LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = t.id_topic AND lt.id_member = {int:current_member}) LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = {int:current_member}) LEFT JOIN {db_prefix}attachments AS al ON (al.id_member = mem.id_member)' : '') . ' WHERE t.id_last_msg >= {int:min_message_id} ' . (empty($exclude_boards) ? '' : ' AND b.id_board NOT IN ({array_int:exclude_boards})') . ' ' . (empty($include_boards) ? '' : ' AND b.id_board IN ({array_int:include_boards})') . ' AND {query_wanna_see_board}' . ($modSettings['postmod_active'] ? ' AND t.approved = {int:is_approved} AND m.approved = {int:is_approved}' : '') . ' ORDER BY t.id_last_msg DESC LIMIT {int:offset}, {int:items_per_page}', array('current_member' => $user_info['id'], 'include_boards' => empty($include_boards) ? '' : $include_boards, 'exclude_boards' => empty($exclude_boards) ? '' : $exclude_boards, 'min_message_id' => $modSettings['maxMsgID'] - 35 * min($num_recent, 5), 'is_approved' => 1, 'offset' => $start_num, 'items_per_page' => $topic_per_page)); $perms_action_array = array('mark_notify', 'remove_any', 'remove_own', 'lock_any', 'lock_own', 'make_sticky', 'move_any', 'move_own', 'modify_any', 'modify_own', 'approve_posts'); $mobi_permission = array(); $posts = array(); while ($row = $smcFunc['db_fetch_assoc']($request)) { $row['body'] = basic_clean($row['body'], 200, 1); // $row['body'] = preg_replace('/\[img.*?\].*?\[\/img\]/si', '###img###', $row['body']); // $row['body'] = strip_tags(strtr(mobiquo_parse_bbc($row['body'], false, $row['id_msg']), array('<br />' => ' '))); // $row['body'] = preg_replace('/###img###/si', '[img]', $row['body']); // if ($smcFunc['strlen']($row['body']) > 128) // $row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...'; // Censor the subject. censorText($row['subject']); censorText($row['body']); if (empty($modSettings['messageIconChecks_disable']) && !isset($icon_sources[$row['icon']])) { $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.gif') ? 'images_url' : 'default_images_url'; } // Check for notifications on this topic $req = $smcFunc['db_query']('', ' SELECT sent, id_topic FROM {db_prefix}log_notify WHERE id_topic = {int:current_topic} AND id_member = {int:current_member} LIMIT 1', array('current_member' => $user_info['id'], 'current_topic' => $row['id_topic'])); $started = $row['id_member_started'] == $user_info['id']; $fid = $row['id_board']; foreach ($perms_action_array as $perm) { if (!isset($mobi_permission[$fid][$perm])) { $mobi_permission[$fid][$perm] = allowedTo($perm, $fid); } } // Build the array. $posts[] = array('board' => array('id' => $row['id_board'], 'name' => $row['board_name'], 'href' => $scripturl . '?board=' . $row['id_board'] . '.0', 'link' => '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['board_name'] . '</a>'), 'topic' => $row['id_topic'], 'poster' => array('id' => $row['id_member'], 'name' => $row['poster_name'], 'href' => empty($row['id_member']) ? '' : $scripturl . '?action=profile;u=' . $row['id_member'], 'link' => empty($row['id_member']) ? $row['poster_name'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['poster_name'] . '</a>', 'avatar' => $row['avatar_last'] == '' ? $row['id_attach_last'] > 0 ? empty($row['attachment_type_last']) ? $scripturl . '?action=dlattach;attach=' . $row['id_attach_last'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $row['filename_last'] : '' : (stristr($row['avatar_last'], 'http://') ? $row['avatar_last'] : $modSettings['avatar_url'] . '/' . $row['avatar_last'])), 'subject' => $row['subject'], 'replies' => $row['num_replies'], 'views' => $row['num_views'], 'short_subject' => shorten_subject($row['subject'], 25), 'preview' => $row['body'], 'time' => timeformat($row['poster_time']), 'timestamp' => $row['poster_time'], 'href' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . ';topicseen#new', 'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#new" rel="nofollow">' . $row['subject'] . '</a>', 'new' => !empty($row['is_read']), 'is_new' => empty($row['is_read']), 'new_from' => $row['new_from'], 'icon' => $settings[$icon_sources[$row['icon']]] . '/post/' . $row['icon'] . '.gif" align="middle" alt="' . $row['icon'], 'can_lock' => $mobi_permission[$fid]['lock_any'] || $started && $mobi_permission[$fid]['lock_own'], 'can_sticky' => $mobi_permission[$fid]['make_sticky'] && !empty($modSettings['enableStickyTopics']), 'can_move' => $mobi_permission[$fid]['move_any'] || $started && $mobi_permission[$fid]['move_own'], 'can_modify' => $mobi_permission[$fid]['modify_any'] || $started && $mobi_permission[$fid]['modify_own'], 'can_remove' => $mobi_permission[$fid]['remove_any'] || $started && $mobi_permission[$fid]['remove_own'], 'can_approve' => $mobi_permission[$fid]['approve_posts'], 'can_mark_notify' => $mobi_permission[$fid]['mark_notify'] && !$user_info['is_guest'], 'is_sticky' => !empty($modSettings['enableStickyTopics']) && !empty($row['is_sticky']), 'is_locked' => !empty($row['locked']), 'is_approved' => !empty($row['approved']), 'is_marked_notify' => $smcFunc['db_num_rows']($req) ? true : false); $smcFunc['db_free_result']($req); } $smcFunc['db_free_result']($request); $context['posts'] = $posts; }
function upSSI_BoardNews($num_recent = 8, $exclude_boards = null, $include_boards = null, $length, $bkcall = '') { global $context, $settings, $scripturl, $txt, $user_info, $modSettings, $smcFunc; loadLanguage('Stats'); if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) { $exclude_boards = array($modSettings['recycle_board']); } else { $exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards)); } // Only some boards?. if (is_array($include_boards) || (int) $include_boards === $include_boards) { $include_boards = is_array($include_boards) ? $include_boards : array($include_boards); } elseif ($include_boards != null) { $output_method = $include_boards; $include_boards = array(); } $stable_icons = array('xx', 'thumbup', 'thumbdown', 'exclamation', 'question', 'lamp', 'smiley', 'angry', 'cheesy', 'grin', 'sad', 'wink', 'moved', 'recycled', 'wireless'); $icon_sources = array(); foreach ($stable_icons as $icon) { $icon_sources[$icon] = 'images_url'; } //Prepare the constructPageIndex() function $start = !empty($_REQUEST['sa']) && $_REQUEST['sa'] == $bkcall . 'boardnews' ? (int) $_REQUEST['start'] : 0; $db_count = $smcFunc['db_query']('', ' SELECT count(m.id_topic) FROM {db_prefix}topics AS t INNER JOIN {db_prefix}messages AS m ON (m.id_msg = t.id_first_msg) INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board) INNER JOIN {db_prefix}messages AS ms ON (ms.id_msg = t.id_first_msg) LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)' . (!$user_info['is_guest'] ? ' LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = t.id_topic AND lt.id_member = {int:current_member}) LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = {int:current_member})' : '') . ' WHERE m.id_topic > 0 ' . (empty($exclude_boards) ? '' : ' AND b.id_board NOT IN ({array_int:exclude_boards})') . ' ' . (empty($include_boards) ? '' : ' AND b.id_board IN ({array_int:include_boards})') . ' AND {query_wanna_see_board}' . ($modSettings['postmod_active'] ? ' AND t.approved = {int:is_approved} AND m.approved = {int:is_approved}' : '') . ' ORDER BY t.id_first_msg DESC', array('current_member' => $user_info['id'], 'include_boards' => empty($include_boards) ? '' : $include_boards, 'exclude_boards' => empty($exclude_boards) ? '' : $exclude_boards, 'is_approved' => 1)); $numNews = array(); list($numNews) = $smcFunc['db_fetch_row']($db_count); $smcFunc['db_free_result']($db_count); $context['page_index'] = constructPageIndex($scripturl . '?sa=' . $bkcall . 'boardnews', $start, $numNews, $num_recent); // Find all the posts in distinct topics. Newer ones will have higher IDs. $request = $smcFunc['db_query']('', ' SELECT m.poster_time, ms.subject, m.id_topic, m.id_member, m.id_msg, b.id_board, b.name AS board_name, t.num_replies, t.num_views, t.locked, IFNULL(mem.real_name, m.poster_name) AS poster_name, ' . ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' : ' IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= m.id_msg_modified AS is_read, IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from') . ', m.body AS body, m.smileys_enabled, m.icon FROM {db_prefix}topics AS t INNER JOIN {db_prefix}messages AS m ON (m.id_msg = t.id_first_msg) INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board) INNER JOIN {db_prefix}messages AS ms ON (ms.id_msg = t.id_first_msg) LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)' . (!$user_info['is_guest'] ? ' LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = t.id_topic AND lt.id_member = {int:current_member}) LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = {int:current_member})' : '') . ' WHERE m.id_topic > 0 ' . (empty($exclude_boards) ? '' : ' AND b.id_board NOT IN ({array_int:exclude_boards})') . ' ' . (empty($include_boards) ? '' : ' AND b.id_board IN ({array_int:include_boards})') . ' AND {query_wanna_see_board}' . ($modSettings['postmod_active'] ? ' AND t.approved = {int:is_approved} AND m.approved = {int:is_approved}' : '') . ' ORDER BY t.id_first_msg DESC ' . ($num_recent < 0 ? "" : " LIMIT {int:start}, {int:limit} ") . '', array('current_member' => $user_info['id'], 'include_boards' => empty($include_boards) ? '' : $include_boards, 'exclude_boards' => empty($exclude_boards) ? '' : $exclude_boards, 'is_approved' => 1, 'start' => $start, 'limit' => $num_recent)); $return = array(); while ($row = $smcFunc['db_fetch_assoc']($request)) { // If we want to limit the length of the post. if (!empty($length) && $smcFunc['strlen']($row['body']) > $length) { $row['body'] = $smcFunc['substr']($row['body'], 0, $length); // The first space or line break. (<br />, etc.) $cutoff = max(strrpos($row['body'], ' '), strrpos($row['body'], '<')); if ($cutoff !== false) { $row['body'] = $smcFunc['substr']($row['body'], 0, $cutoff); } $row['body'] .= '...'; } $row['body'] = parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']); // Censor the subject. censorText($row['subject']); censorText($row['body']); if (empty($modSettings['messageIconChecks_disable']) && !isset($icon_sources[$row['icon']])) { $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.gif') ? 'images_url' : 'default_images_url'; } // Build the array. $return[] = array('board' => array('id' => $row['id_board'], 'name' => $row['board_name'], 'href' => $scripturl . '?board=' . $row['id_board'] . '.0', 'link' => '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['board_name'] . '</a>'), 'topic' => $row['id_topic'], 'poster' => array('id' => $row['id_member'], 'name' => $row['poster_name'], 'href' => empty($row['id_member']) ? '' : $scripturl . '?action=profile;u=' . $row['id_member'], 'link' => empty($row['id_member']) ? $row['poster_name'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['poster_name'] . '</a>'), 'subject' => $row['subject'], 'replies' => $row['num_replies'], 'views' => $row['num_views'], 'short_subject' => shorten_subject($row['subject'], 25), 'preview' => $row['body'], 'time' => timeformat($row['poster_time']), 'timestamp' => forum_time(true, $row['poster_time']), 'href' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . ';topicseen#new', 'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#new" rel="nofollow">' . $row['subject'] . '</a>', 'new' => !empty($row['is_read']), 'is_new' => empty($row['is_read']), 'new_from' => $row['new_from'], 'icon' => '<img src="' . $settings[$icon_sources[$row['icon']]] . '/post/' . $row['icon'] . '.gif" align="middle" alt="' . $row['icon'] . '" border="0" />', 'comment_link' => !empty($row['locked']) ? '' : '<a href="' . $scripturl . '?action=post;topic=' . $row['id_topic'] . '.' . $row['num_replies'] . ';num_replies=' . $row['num_replies'] . '">' . $txt['ssi_write_comment'] . '</a>'); } $smcFunc['db_free_result']($request); //ok return now return $return; }
function ssi_recentTopics($num_recent = 8, $exclude_boards = null, $include_boards = null, $output_method = 'echo') { global $context, $settings, $scripturl, $txt, $db_prefix, $user_info; global $modSettings, $smcFunc; if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) { $exclude_boards = array($modSettings['recycle_board']); } else { $exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards)); } // Only some boards?. if (is_array($include_boards) || (int) $include_boards === $include_boards) { $include_boards = is_array($include_boards) ? $include_boards : array($include_boards); } elseif ($include_boards != null) { $output_method = $include_boards; $include_boards = array(); } $stable_icons = array('xx', 'thumbup', 'thumbdown', 'exclamation', 'question', 'lamp', 'smiley', 'angry', 'cheesy', 'grin', 'sad', 'wink', 'moved', 'recycled', 'wireless'); $icon_sources = array(); foreach ($stable_icons as $icon) { $icon_sources[$icon] = 'images_url'; } // Find all the posts in distinct topics. Newer ones will have higher IDs. $request = $smcFunc['db_query']('substring', ' SELECT m.poster_time, ms.subject, m.id_topic, m.id_member, m.id_msg, b.id_board, b.name AS board_name, t.num_replies, t.num_views, IFNULL(mem.real_name, m.poster_name) AS poster_name, ' . ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' : ' IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= m.id_msg_modified AS is_read, IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from') . ', SUBSTRING(m.body, 1, 384) AS body, m.smileys_enabled, m.icon FROM {db_prefix}topics AS t INNER JOIN {db_prefix}messages AS m ON (m.id_msg = t.id_last_msg) INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board) INNER JOIN {db_prefix}messages AS ms ON (ms.id_msg = t.id_first_msg) LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)' . (!$user_info['is_guest'] ? ' LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = t.id_topic AND lt.id_member = {int:current_member}) LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = {int:current_member})' : '') . ' WHERE t.id_last_msg >= {int:min_message_id} ' . (empty($exclude_boards) ? '' : ' AND b.id_board NOT IN ({array_int:exclude_boards})') . ' ' . (empty($include_boards) ? '' : ' AND b.id_board IN ({array_int:include_boards})') . ' AND {query_wanna_see_board}' . ($modSettings['postmod_active'] ? ' AND t.approved = {int:is_approved} AND m.approved = {int:is_approved}' : '') . ' ORDER BY t.id_last_msg DESC LIMIT ' . $num_recent, array('current_member' => $user_info['id'], 'include_boards' => empty($include_boards) ? '' : $include_boards, 'exclude_boards' => empty($exclude_boards) ? '' : $exclude_boards, 'min_message_id' => $modSettings['maxMsgID'] - 35 * min($num_recent, 5), 'is_approved' => 1)); $posts = array(); while ($row = $smcFunc['db_fetch_assoc']($request)) { $row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']), array('<br />' => ' '))); if (commonAPI::strlen($row['body']) > 128) { $row['body'] = commonAPI::substr($row['body'], 0, 128) . '...'; } // Censor the subject. censorText($row['subject']); censorText($row['body']); if (empty($modSettings['messageIconChecks_disable']) && !isset($icon_sources[$row['icon']])) { $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.gif') ? 'images_url' : 'default_images_url'; } // Build the array. $posts[] = array('board' => array('id' => $row['id_board'], 'name' => $row['board_name'], 'href' => $scripturl . '?board=' . $row['id_board'] . '.0', 'link' => '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['board_name'] . '</a>'), 'topic' => $row['id_topic'], 'poster' => array('id' => $row['id_member'], 'name' => $row['poster_name'], 'href' => empty($row['id_member']) ? '' : $scripturl . '?action=profile;u=' . $row['id_member'], 'link' => empty($row['id_member']) ? $row['poster_name'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['poster_name'] . '</a>'), 'subject' => $row['subject'], 'replies' => $row['num_replies'], 'views' => $row['num_views'], 'short_subject' => shorten_subject($row['subject'], 25), 'preview' => $row['body'], 'time' => timeformat($row['poster_time']), 'timestamp' => forum_time(true, $row['poster_time']), 'href' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . ';topicseen#new', 'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#new" rel="nofollow">' . $row['subject'] . '</a>', 'new' => !empty($row['is_read']), 'is_new' => empty($row['is_read']), 'new_from' => $row['new_from'], 'icon' => '<img src="' . $settings[$icon_sources[$row['icon']]] . '/post/' . $row['icon'] . '.gif" align="middle" alt="' . $row['icon'] . '" />'); } $smcFunc['db_free_result']($request); // Just return it. if ($output_method != 'echo' || empty($posts)) { return $posts; } echo ' <table border="0" class="ssi_table">'; foreach ($posts as $post) { echo ' <tr> <td align="right" valign="top" nowrap="nowrap"> [', $post['board']['link'], '] </td> <td valign="top"> <a href="', $post['href'], '">', $post['subject'], '</a> ', $txt['by'], ' ', $post['poster']['link'], ' ', !$post['is_new'] ? '' : '<a href="' . $scripturl . '?topic=' . $post['topic'] . '.msg' . $post['new_from'] . ';topicseen#new" rel="nofollow"><img src="' . $settings['images_url'] . '/new.png" alt="' . $txt['new'] . '" /></a>', ' </td> <td align="right" nowrap="nowrap"> ', $post['time'], ' </td> </tr>'; } echo ' </table>'; }
function MessageIndex() { global $txt, $scripturl, $board, $db_prefix; global $modSettings, $ID_MEMBER; global $context, $options, $settings, $board_info, $user_info, $func; if (WIRELESS) { $context['sub_template'] = WIRELESS_PROTOCOL . '_messageindex'; } else { loadTemplate('MessageIndex'); } $context['name'] = $board_info['name']; $context['description'] = $board_info['description']; // View all the topics, or just a few? $maxindex = isset($_REQUEST['all']) && !empty($modSettings['enableAllMessages']) ? $board_info['num_topics'] : $modSettings['defaultMaxTopics']; // Make sure the starting place makes sense and construct the page index. if (isset($_REQUEST['sort'])) { $context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%d;sort=' . $_REQUEST['sort'] . (isset($_REQUEST['desc']) ? ';desc' : ''), $_REQUEST['start'], $board_info['num_topics'], $maxindex, true); } else { $context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%d', $_REQUEST['start'], $board_info['num_topics'], $maxindex, true); } $context['start'] =& $_REQUEST['start']; $context['links'] = array('first' => $_REQUEST['start'] >= $modSettings['defaultMaxTopics'] ? $scripturl . '?board=' . $board . '.0' : '', 'prev' => $_REQUEST['start'] >= $modSettings['defaultMaxTopics'] ? $scripturl . '?board=' . $board . '.' . ($_REQUEST['start'] - $modSettings['defaultMaxTopics']) : '', 'next' => $_REQUEST['start'] + $modSettings['defaultMaxTopics'] < $board_info['num_topics'] ? $scripturl . '?board=' . $board . '.' . ($_REQUEST['start'] + $modSettings['defaultMaxTopics']) : '', 'last' => $_REQUEST['start'] + $modSettings['defaultMaxTopics'] < $board_info['num_topics'] ? $scripturl . '?board=' . $board . '.' . floor(($board_info['num_topics'] - 1) / $modSettings['defaultMaxTopics']) * $modSettings['defaultMaxTopics'] : '', 'up' => $board_info['parent'] == 0 ? $scripturl . '?' : $scripturl . '?board=' . $board_info['parent'] . '.0'); $context['page_info'] = array('current_page' => $_REQUEST['start'] / $modSettings['defaultMaxTopics'] + 1, 'num_pages' => floor(($board_info['num_topics'] - 1) / $modSettings['defaultMaxTopics']) + 1); if (isset($_REQUEST['all']) && !empty($modSettings['enableAllMessages']) && $maxindex > $modSettings['enableAllMessages']) { $maxindex = $modSettings['enableAllMessages']; $_REQUEST['start'] = 0; } // Build a list of the board's moderators. $context['moderators'] =& $board_info['moderators']; $context['link_moderators'] = array(); if (!empty($board_info['moderators'])) { foreach ($board_info['moderators'] as $mod) { $context['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt[62] . '">' . $mod['name'] . '</a>'; } $context['linktree'][count($context['linktree']) - 1]['extra_after'] = ' (' . (count($context['link_moderators']) == 1 ? $txt[298] : $txt[299]) . ': ' . implode(', ', $context['link_moderators']) . ')'; } // Mark current and parent boards as seen. if (!$user_info['is_guest']) { // We can't know they read it if we allow prefetches. if (isset($_SERVER['HTTP_X_MOZ']) && $_SERVER['HTTP_X_MOZ'] == 'prefetch') { ob_end_clean(); header('HTTP/1.1 403 Prefetch Forbidden'); die; } db_query("\n\t\t\tREPLACE INTO {$db_prefix}log_boards\n\t\t\t\t(ID_MSG, ID_MEMBER, ID_BOARD)\n\t\t\tVALUES ({$modSettings['maxMsgID']}, {$ID_MEMBER}, {$board})", __FILE__, __LINE__); if (!empty($board_info['parent_boards'])) { db_query("\n\t\t\t\tUPDATE {$db_prefix}log_boards\n\t\t\t\tSET ID_MSG = {$modSettings['maxMsgID']}\n\t\t\t\tWHERE ID_MEMBER = {$ID_MEMBER}\n\t\t\t\t\tAND ID_BOARD IN (" . implode(',', array_keys($board_info['parent_boards'])) . ")\n\t\t\t\tLIMIT " . count($board_info['parent_boards']), __FILE__, __LINE__); // We've seen all these boards now! foreach ($board_info['parent_boards'] as $k => $dummy) { if (isset($_SESSION['topicseen_cache'][$k])) { unset($_SESSION['topicseen_cache'][$k]); } } } if (isset($_SESSION['topicseen_cache'][$board])) { unset($_SESSION['topicseen_cache'][$board]); } $request = db_query("\n\t\t\tSELECT sent\n\t\t\tFROM {$db_prefix}log_notify\n\t\t\tWHERE ID_BOARD = {$board}\n\t\t\t\tAND ID_MEMBER = {$ID_MEMBER}\n\t\t\tLIMIT 1", __FILE__, __LINE__); $context['is_marked_notify'] = mysql_num_rows($request) != 0; if ($context['is_marked_notify']) { list($sent) = mysql_fetch_row($request); if (!empty($sent)) { db_query("\n\t\t\t\t\tUPDATE {$db_prefix}log_notify\n\t\t\t\t\tSET sent = 0\n\t\t\t\t\tWHERE ID_BOARD = {$board}\n\t\t\t\t\t\tAND ID_MEMBER = {$ID_MEMBER}\n\t\t\t\t\tLIMIT 1", __FILE__, __LINE__); } } mysql_free_result($request); } else { $context['is_marked_notify'] = false; } // 'Print' the header and board info. $context['page_title'] = strip_tags($board_info['name']); // Set the variables up for the template. $context['can_mark_notify'] = allowedTo('mark_notify') && !$user_info['is_guest']; $context['can_post_new'] = allowedTo('post_new'); $context['can_post_poll'] = $modSettings['pollMode'] == '1' && allowedTo('poll_post'); $context['can_moderate_forum'] = allowedTo('moderate_forum'); // Aren't children wonderful things? $result = db_query("\n\t\tSELECT\n\t\t\tb.ID_BOARD, b.name, b.description, b.numTopics, b.numPosts,\n\t\t\tm.posterName, m.posterTime, m.subject, m.ID_MSG, m.ID_TOPIC,\n\t\t\tIFNULL(mem.realName, m.posterName) AS realName, " . (!$user_info['is_guest'] ? "\n\t\t\t(IFNULL(lb.ID_MSG, 0) >= b.ID_MSG_UPDATED) AS isRead," : "1 AS isRead,") . "\n\t\t\tIFNULL(mem.ID_MEMBER, 0) AS ID_MEMBER, IFNULL(mem2.ID_MEMBER, 0) AS ID_MODERATOR,\n\t\t\tmem2.realName AS modRealName\n\t\tFROM {$db_prefix}boards AS b\n\t\t\tLEFT JOIN {$db_prefix}messages AS m ON (m.ID_MSG = b.ID_LAST_MSG)\n\t\t\tLEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)" . (!$user_info['is_guest'] ? "\n\t\t\tLEFT JOIN {$db_prefix}log_boards AS lb ON (lb.ID_BOARD = b.ID_BOARD AND lb.ID_MEMBER = {$ID_MEMBER})" : '') . "\n\t\t\tLEFT JOIN {$db_prefix}moderators AS mods ON (mods.ID_BOARD = b.ID_BOARD)\n\t\t\tLEFT JOIN {$db_prefix}members AS mem2 ON (mem2.ID_MEMBER = mods.ID_MEMBER)\n\t\tWHERE b.ID_PARENT = {$board}\n\t\t\tAND {$user_info['query_see_board']}", __FILE__, __LINE__); if (mysql_num_rows($result) != 0) { $theboards = array(); while ($row_board = mysql_fetch_assoc($result)) { if (!isset($context['boards'][$row_board['ID_BOARD']])) { $theboards[] = $row_board['ID_BOARD']; // Make sure the subject isn't too long. censorText($row_board['subject']); $short_subject = shorten_subject($row_board['subject'], 24); $context['boards'][$row_board['ID_BOARD']] = array('id' => $row_board['ID_BOARD'], 'last_post' => array('id' => $row_board['ID_MSG'], 'time' => $row_board['posterTime'] > 0 ? timeformat($row_board['posterTime']) : $txt[470], 'timestamp' => forum_time(true, $row_board['posterTime']), 'subject' => $short_subject, 'member' => array('id' => $row_board['ID_MEMBER'], 'username' => $row_board['posterName'] != '' ? $row_board['posterName'] : $txt[470], 'name' => $row_board['realName'], 'href' => !empty($row_board['ID_MEMBER']) ? $scripturl . '?action=profile;u=' . $row_board['ID_MEMBER'] : '', 'link' => $row_board['posterName'] != '' ? !empty($row_board['ID_MEMBER']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row_board['ID_MEMBER'] . '">' . $row_board['realName'] . '</a>' : $row_board['realName'] : $txt[470]), 'start' => 'new', 'topic' => $row_board['ID_TOPIC'], 'href' => $row_board['subject'] != '' ? $scripturl . '?topic=' . $row_board['ID_TOPIC'] . '.new' . (empty($row_board['isRead']) ? ';boardseen' : '') . '#new' : '', 'link' => $row_board['subject'] != '' ? '<a href="' . $scripturl . '?topic=' . $row_board['ID_TOPIC'] . '.new' . (empty($row_board['isRead']) ? ';boardseen' : '') . '#new" title="' . $row_board['subject'] . '">' . $short_subject . '</a>' : $txt[470]), 'new' => empty($row_board['isRead']) && $row_board['posterName'] != '', 'name' => $row_board['name'], 'description' => $row_board['description'], 'moderators' => array(), 'link_moderators' => array(), 'children' => array(), 'link_children' => array(), 'children_new' => false, 'topics' => $row_board['numTopics'], 'posts' => $row_board['numPosts'], 'href' => $scripturl . '?board=' . $row_board['ID_BOARD'] . '.0', 'link' => '<a href="' . $scripturl . '?board=' . $row_board['ID_BOARD'] . '.0">' . $row_board['name'] . '</a>'); } if (!empty($row_board['ID_MODERATOR'])) { $context['boards'][$row_board['ID_BOARD']]['moderators'][$row_board['ID_MODERATOR']] = array('id' => $row_board['ID_MODERATOR'], 'name' => $row_board['modRealName'], 'href' => $scripturl . '?action=profile;u=' . $row_board['ID_MODERATOR'], 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_board['ID_MODERATOR'] . '" title="' . $txt[62] . '">' . $row_board['modRealName'] . '</a>'); $context['boards'][$row_board['ID_BOARD']]['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $row_board['ID_MODERATOR'] . '" title="' . $txt[62] . '">' . $row_board['modRealName'] . '</a>'; } } mysql_free_result($result); // Load up the child boards. $result = db_query("\n\t\t\tSELECT\n\t\t\t\tb.ID_BOARD, b.ID_PARENT, b.name, b.description, b.numTopics, b.numPosts,\n\t\t\t\tm.posterName, IFNULL(m.posterTime, 0) AS posterTime, m.subject, m.ID_MSG, m.ID_TOPIC,\n\t\t\t\tIFNULL(mem.realName, m.posterName) AS realName, ID_PARENT, \n\t\t\t\t" . ($user_info['is_guest'] ? '1' : '(IFNULL(lb.ID_MSG, 0) >= b.ID_MSG_UPDATED)') . " AS isRead,\n\t\t\t\tIFNULL(mem.ID_MEMBER, 0) AS ID_MEMBER\n\t\t\tFROM {$db_prefix}boards AS b\n\t\t\t\tLEFT JOIN {$db_prefix}messages AS m ON (m.ID_MSG = b.ID_LAST_MSG)\n\t\t\t\tLEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)" . (!$user_info['is_guest'] ? "\n\t\t\t\tLEFT JOIN {$db_prefix}log_boards AS lb ON (lb.ID_BOARD = b.ID_BOARD AND lb.ID_MEMBER = {$ID_MEMBER})" : '') . "\n\t\t\tWHERE " . (empty($modSettings['countChildPosts']) ? "b.ID_PARENT IN (" . implode(',', $theboards) . ")" : "childLevel > 0") . "\n\t\t\t\tAND {$user_info['query_see_board']}", __FILE__, __LINE__); $parent_map = array(); while ($row = mysql_fetch_assoc($result)) { // We've got a child of a child, then... possibly. if (!in_array($row['ID_PARENT'], $theboards)) { if (!isset($parent_map[$row['ID_PARENT']])) { continue; } $parent_map[$row['ID_PARENT']][0]['posts'] += $row['numPosts']; $parent_map[$row['ID_PARENT']][0]['topics'] += $row['numTopics']; $parent_map[$row['ID_PARENT']][1]['posts'] += $row['numPosts']; $parent_map[$row['ID_PARENT']][1]['topics'] += $row['numTopics']; $parent_map[$row['ID_BOARD']] = $parent_map[$row['ID_PARENT']]; continue; } if ($context['boards'][$row['ID_PARENT']]['last_post']['timestamp'] < forum_time(true, $row['posterTime'])) { // Make sure the subject isn't too long. censorText($row['subject']); $short_subject = shorten_subject($row['subject'], 24); $context['boards'][$row['ID_PARENT']]['last_post'] = array('id' => $row['ID_MSG'], 'time' => $row['posterTime'] > 0 ? timeformat($row['posterTime']) : $txt[470], 'timestamp' => forum_time(true, $row['posterTime']), 'subject' => $short_subject, 'member' => array('username' => $row['posterName'] != '' ? $row['posterName'] : $txt[470], 'name' => $row['realName'], 'id' => $row['ID_MEMBER'], 'href' => !empty($row['ID_MEMBER']) ? $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] : '', 'link' => $row['posterName'] != '' ? !empty($row['ID_MEMBER']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['realName'] . '</a>' : $row['realName'] : $txt[470]), 'start' => 'new', 'topic' => $row['ID_TOPIC'], 'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.new' . (empty($row['isRead']) ? ';boardseen' : '') . '#new'); $context['boards'][$row['ID_PARENT']]['last_post']['link'] = $row['subject'] != '' ? '<a href="' . $context['boards'][$row['ID_PARENT']]['last_post']['href'] . '" title="' . $row['subject'] . '">' . $short_subject . '</a>' : $txt[470]; } $context['boards'][$row['ID_PARENT']]['children'][$row['ID_BOARD']] = array('id' => $row['ID_BOARD'], 'name' => $row['name'], 'description' => $row['description'], 'new' => empty($row['isRead']) && $row['posterName'] != '', 'topics' => $row['numTopics'], 'posts' => $row['numPosts'], 'href' => $scripturl . '?board=' . $row['ID_BOARD'] . '.0', 'link' => '<a href="' . $scripturl . '?board=' . $row['ID_BOARD'] . '.0">' . $row['name'] . '</a>'); $context['boards'][$row['ID_PARENT']]['link_children'][] = '<a href="' . $scripturl . '?board=' . $row['ID_BOARD'] . '.0">' . $row['name'] . '</a>'; $context['boards'][$row['ID_PARENT']]['children_new'] |= empty($row['isRead']) && $row['posterName'] != ''; if (!empty($modSettings['countChildPosts'])) { $context['boards'][$row['ID_PARENT']]['posts'] += $row['numPosts']; $context['boards'][$row['ID_PARENT']]['topics'] += $row['numTopics']; $parent_map[$row['ID_BOARD']] = array(&$context['boards'][$row['ID_PARENT']], &$context['boards'][$row['ID_PARENT']]['children'][$row['ID_BOARD']]); } } } mysql_free_result($result); // Nosey, nosey - who's viewing this topic? if (!empty($settings['display_who_viewing'])) { $context['view_members'] = array(); $context['view_members_list'] = array(); $context['view_num_hidden'] = 0; $request = db_query("\n\t\t\tSELECT\n\t\t\t\tlo.ID_MEMBER, lo.logTime, mem.realName, mem.memberName, mem.showOnline,\n\t\t\t\tmg.onlineColor, mg.ID_GROUP, mg.groupName\n\t\t\tFROM {$db_prefix}log_online AS lo\n\t\t\t\tLEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = lo.ID_MEMBER)\n\t\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))\n\t\t\tWHERE INSTR(lo.url, 's:5:\"board\";i:{$board};') OR lo.session = '" . ($user_info['is_guest'] ? 'ip' . $user_info['ip'] : session_id()) . "'", __FILE__, __LINE__); while ($row = mysql_fetch_assoc($request)) { if (empty($row['ID_MEMBER'])) { continue; } if (!empty($row['onlineColor'])) { $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '" style="color: ' . $row['onlineColor'] . ';">' . $row['realName'] . '</a>'; } else { $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['realName'] . '</a>'; } $is_buddy = in_array($row['ID_MEMBER'], $user_info['buddies']); if ($is_buddy) { $link = '<b>' . $link . '</b>'; } if (!empty($row['showOnline']) || allowedTo('moderate_forum')) { $context['view_members_list'][$row['logTime'] . $row['memberName']] = empty($row['showOnline']) ? '<i>' . $link . '</i>' : $link; } $context['view_members'][$row['logTime'] . $row['memberName']] = array('id' => $row['ID_MEMBER'], 'username' => $row['memberName'], 'name' => $row['realName'], 'group' => $row['ID_GROUP'], 'href' => $scripturl . '?action=profile;u=' . $row['ID_MEMBER'], 'link' => $link, 'is_buddy' => $is_buddy, 'hidden' => empty($row['showOnline'])); if (empty($row['showOnline'])) { $context['view_num_hidden']++; } } $context['view_num_guests'] = mysql_num_rows($request) - count($context['view_members']); mysql_free_result($request); // Put them in "last clicked" order. krsort($context['view_members_list']); krsort($context['view_members']); } // Default sort methods. $sort_methods = array('subject' => 'mf.subject', 'starter' => 'IFNULL(memf.realName, mf.posterName)', 'last_poster' => 'IFNULL(meml.realName, ml.posterName)', 'replies' => 't.numReplies', 'views' => 't.numViews', 'first_post' => 't.ID_TOPIC', 'last_post' => 't.ID_LAST_MSG'); // They didn't pick one, default to by last post descending. if (!isset($_REQUEST['sort']) || !isset($sort_methods[$_REQUEST['sort']])) { $context['sort_by'] = 'last_post'; $_REQUEST['sort'] = 'ID_LAST_MSG'; $ascending = isset($_REQUEST['asc']); } else { $context['sort_by'] = $_REQUEST['sort']; $_REQUEST['sort'] = $sort_methods[$_REQUEST['sort']]; $ascending = !isset($_REQUEST['desc']); } $context['sort_direction'] = $ascending ? 'up' : 'down'; // Calculate the fastest way to get the topics. $start = $_REQUEST['start']; if ($start > ($board_info['num_topics'] - 1) / 2) { $ascending = !$ascending; $fake_ascending = true; $maxindex = $board_info['num_topics'] < $start + $maxindex + 1 ? $board_info['num_topics'] - $start : $maxindex; $start = $board_info['num_topics'] < $start + $maxindex + 1 ? 0 : $board_info['num_topics'] - $start - $maxindex; } else { $fake_ascending = false; } // Setup the default topic icons... $stable_icons = array('xx', 'thumbup', 'thumbdown', 'exclamation', 'question', 'lamp', 'smiley', 'angry', 'cheesy', 'grin', 'sad', 'wink', 'moved', 'recycled', 'wireless'); $context['icon_sources'] = array(); foreach ($stable_icons as $icon) { $context['icon_sources'][$icon] = 'images_url'; } $topic_ids = array(); $context['topics'] = array(); // Sequential pages are often not optimized, so we add an additional query. $pre_query = $start > 0; if ($pre_query) { $request = db_query("\n\t\t\tSELECT t.ID_TOPIC\n\t\t\tFROM ({$db_prefix}topics AS t" . ($context['sort_by'] === 'last_poster' ? ", {$db_prefix}messages AS ml" : (in_array($context['sort_by'], array('starter', 'subject')) ? ", {$db_prefix}messages AS mf" : '')) . ')' . ($context['sort_by'] === 'starter' ? "\n\t\t\t\tLEFT JOIN {$db_prefix}members AS memf ON (memf.ID_MEMBER = mf.ID_MEMBER)" : '') . ($context['sort_by'] === 'last_poster' ? "\n\t\t\t\tLEFT JOIN {$db_prefix}members AS meml ON (meml.ID_MEMBER = ml.ID_MEMBER)" : '') . "\n\t\t\tWHERE t.ID_BOARD = {$board}" . ($context['sort_by'] === 'last_poster' ? "\n\t\t\t\tAND ml.ID_MSG = t.ID_LAST_MSG" : (in_array($context['sort_by'], array('starter', 'subject')) ? "\n\t\t\t\tAND mf.ID_MSG = t.ID_FIRST_MSG" : '')) . "\n\t\t\tORDER BY " . (!empty($modSettings['enableStickyTopics']) ? 'isSticky' . ($fake_ascending ? '' : ' DESC') . ', ' : '') . $_REQUEST['sort'] . ($ascending ? '' : ' DESC') . "\n\t\t\tLIMIT {$start}, {$maxindex}", __FILE__, __LINE__); $topic_ids = array(); while ($row = mysql_fetch_assoc($request)) { $topic_ids[] = $row['ID_TOPIC']; } } // Grab the appropriate topic information... if (!$pre_query || !empty($topic_ids)) { $result = db_query("\n\t\t\tSELECT\n\t\t\t\tt.ID_TOPIC, t.numReplies, t.locked, t.numViews, t.isSticky, t.ID_POLL,\n\t\t\t\t" . ($user_info['is_guest'] ? '0' : 'IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, -1)) + 1') . " AS new_from,\n\t\t\t\tt.ID_LAST_MSG, ml.posterTime AS lastPosterTime, ml.ID_MSG_MODIFIED,\n\t\t\t\tml.subject AS lastSubject, ml.icon AS lastIcon, ml.posterName AS lastMemberName,\n\t\t\t\tml.ID_MEMBER AS lastID_MEMBER, IFNULL(meml.realName, ml.posterName) AS lastDisplayName,\n\t\t\t\tt.ID_FIRST_MSG, mf.posterTime AS firstPosterTime,\n\t\t\t\tmf.subject AS firstSubject, mf.icon AS firstIcon, mf.posterName AS firstMemberName,\n\t\t\t\tmf.ID_MEMBER AS firstID_MEMBER, IFNULL(memf.realName, mf.posterName) AS firstDisplayName,\n\t\t\t\tLEFT(ml.body, 384) AS lastBody, LEFT(mf.body, 384) AS firstBody, ml.smileysEnabled AS lastSmileys,\n\t\t\t\tmf.smileysEnabled AS firstSmileys\n\t\t\tFROM ({$db_prefix}topics AS t, {$db_prefix}messages AS ml, {$db_prefix}messages AS mf)\n\t\t\t\tLEFT JOIN {$db_prefix}members AS meml ON (meml.ID_MEMBER = ml.ID_MEMBER)\n\t\t\t\tLEFT JOIN {$db_prefix}members AS memf ON (memf.ID_MEMBER = mf.ID_MEMBER)" . ($user_info['is_guest'] ? '' : "\n\t\t\t\tLEFT JOIN {$db_prefix}log_topics AS lt ON (lt.ID_TOPIC = t.ID_TOPIC AND lt.ID_MEMBER = {$ID_MEMBER})\n\t\t\t\tLEFT JOIN {$db_prefix}log_mark_read AS lmr ON (lmr.ID_BOARD = {$board} AND lmr.ID_MEMBER = {$ID_MEMBER})") . "\n\t\t\tWHERE " . ($pre_query ? 't.ID_TOPIC IN (' . implode(', ', $topic_ids) . ')' : "t.ID_BOARD = {$board}") . "\n\t\t\t\tAND ml.ID_MSG = t.ID_LAST_MSG\n\t\t\t\tAND mf.ID_MSG = t.ID_FIRST_MSG\n\t\t\tORDER BY " . ($pre_query ? "FIND_IN_SET(t.ID_TOPIC, '" . implode(',', $topic_ids) . "')" : (!empty($modSettings['enableStickyTopics']) ? 'isSticky' . ($fake_ascending ? '' : ' DESC') . ', ' : '') . $_REQUEST['sort'] . ($ascending ? '' : ' DESC')) . "\n\t\t\tLIMIT " . ($pre_query ? '' : "{$start}, ") . "{$maxindex}", __FILE__, __LINE__); // Begin 'printing' the message index for current board. while ($row = mysql_fetch_assoc($result)) { if ($row['ID_POLL'] > 0 && $modSettings['pollMode'] == '0') { continue; } if (!$pre_query) { $topic_ids[] = $row['ID_TOPIC']; } // Limit them to 128 characters - do this FIRST because it's a lot of wasted censoring otherwise. $row['firstBody'] = strip_tags(strtr(parse_bbc($row['firstBody'], $row['firstSmileys'], $row['ID_FIRST_MSG']), array('<br />' => ' '))); if ($func['strlen']($row['firstBody']) > 128) { $row['firstBody'] = $func['substr']($row['firstBody'], 0, 128) . '...'; } $row['lastBody'] = strip_tags(strtr(parse_bbc($row['lastBody'], $row['lastSmileys'], $row['ID_LAST_MSG']), array('<br />' => ' '))); if ($func['strlen']($row['lastBody']) > 128) { $row['lastBody'] = $func['substr']($row['lastBody'], 0, 128) . '...'; } // Censor the subject and message preview. censorText($row['firstSubject']); censorText($row['firstBody']); // Don't censor them twice! if ($row['ID_FIRST_MSG'] == $row['ID_LAST_MSG']) { $row['lastSubject'] = $row['firstSubject']; $row['lastBody'] = $row['firstBody']; } else { censorText($row['lastSubject']); censorText($row['lastBody']); } // Decide how many pages the topic should have. $topic_length = $row['numReplies'] + 1; if ($topic_length > $modSettings['defaultMaxMessages']) { $tmppages = array(); $tmpa = 1; for ($tmpb = 0; $tmpb < $topic_length; $tmpb += $modSettings['defaultMaxMessages']) { $tmppages[] = '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.' . $tmpb . '">' . $tmpa . '</a>'; $tmpa++; } // Show links to all the pages? if (count($tmppages) <= 5) { $pages = '« ' . implode(' ', $tmppages); } else { $pages = '« ' . $tmppages[0] . ' ' . $tmppages[1] . ' ... ' . $tmppages[count($tmppages) - 2] . ' ' . $tmppages[count($tmppages) - 1]; } if (!empty($modSettings['enableAllMessages']) && $topic_length < $modSettings['enableAllMessages']) { $pages .= ' <a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;all">' . $txt[190] . '</a>'; } $pages .= ' »'; } else { $pages = ''; } // We need to check the topic icons exist... if (empty($modSettings['messageIconChecks_disable'])) { if (!isset($context['icon_sources'][$row['firstIcon']])) { $context['icon_sources'][$row['firstIcon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['firstIcon'] . '.gif') ? 'images_url' : 'default_images_url'; } if (!isset($context['icon_sources'][$row['lastIcon']])) { $context['icon_sources'][$row['lastIcon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['lastIcon'] . '.gif') ? 'images_url' : 'default_images_url'; } } else { if (!isset($context['icon_sources'][$row['firstIcon']])) { $context['icon_sources'][$row['firstIcon']] = 'images_url'; } if (!isset($context['icon_sources'][$row['lastIcon']])) { $context['icon_sources'][$row['lastIcon']] = 'images_url'; } } // 'Print' the topic info. $context['topics'][$row['ID_TOPIC']] = array('id' => $row['ID_TOPIC'], 'first_post' => array('id' => $row['ID_FIRST_MSG'], 'member' => array('username' => $row['firstMemberName'], 'name' => $row['firstDisplayName'], 'id' => $row['firstID_MEMBER'], 'href' => !empty($row['firstID_MEMBER']) ? $scripturl . '?action=profile;u=' . $row['firstID_MEMBER'] : '', 'link' => !empty($row['firstID_MEMBER']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['firstID_MEMBER'] . '" title="' . $txt[92] . ' ' . $row['firstDisplayName'] . '">' . $row['firstDisplayName'] . '</a>' : $row['firstDisplayName']), 'time' => timeformat($row['firstPosterTime']), 'timestamp' => forum_time(true, $row['firstPosterTime']), 'subject' => $row['firstSubject'], 'preview' => $row['firstBody'], 'icon' => $row['firstIcon'], 'icon_url' => $settings[$context['icon_sources'][$row['firstIcon']]] . '/post/' . $row['firstIcon'] . '.gif', 'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0', 'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0">' . $row['firstSubject'] . '</a>'), 'last_post' => array('id' => $row['ID_LAST_MSG'], 'member' => array('username' => $row['lastMemberName'], 'name' => $row['lastDisplayName'], 'id' => $row['lastID_MEMBER'], 'href' => !empty($row['lastID_MEMBER']) ? $scripturl . '?action=profile;u=' . $row['lastID_MEMBER'] : '', 'link' => !empty($row['lastID_MEMBER']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['lastID_MEMBER'] . '">' . $row['lastDisplayName'] . '</a>' : $row['lastDisplayName']), 'time' => timeformat($row['lastPosterTime']), 'timestamp' => forum_time(true, $row['lastPosterTime']), 'subject' => $row['lastSubject'], 'preview' => $row['lastBody'], 'icon' => $row['lastIcon'], 'icon_url' => $settings[$context['icon_sources'][$row['lastIcon']]] . '/post/' . $row['lastIcon'] . '.gif', 'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['ID_LAST_MSG']) . '#new', 'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['ID_LAST_MSG']) . '#new">' . $row['lastSubject'] . '</a>'), 'tagCount' => 0, 'is_sticky' => !empty($modSettings['enableStickyTopics']) && !empty($row['isSticky']), 'is_locked' => !empty($row['locked']), 'is_poll' => $modSettings['pollMode'] == '1' && $row['ID_POLL'] > 0, 'is_hot' => $row['numReplies'] >= $modSettings['hotTopicPosts'], 'is_very_hot' => $row['numReplies'] >= $modSettings['hotTopicVeryPosts'], 'is_posted_in' => false, 'icon' => $row['firstIcon'], 'icon_url' => $settings[$context['icon_sources'][$row['firstIcon']]] . '/post/' . $row['firstIcon'] . '.gif', 'subject' => $row['firstSubject'], 'new' => $row['new_from'] <= $row['ID_MSG_MODIFIED'], 'new_from' => $row['new_from'], 'newtime' => $row['new_from'], 'new_href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['new_from'] . '#new', 'pages' => $pages, 'replies' => $row['numReplies'], 'views' => $row['numViews']); determineTopicClass($context['topics'][$row['ID_TOPIC']]); } mysql_free_result($result); // Tagging system if ($modSettings['smftags_set_display_messageindex'] && in_array($context['current_board'], explode(" ", $modSettings['smftags_set_taggable'])) && !empty($topic_ids)) { // this query is seperated due to lack of optimisation if integrated in to the main query above $result = db_query(' SELECT ID_TOPIC, COUNT(ID_TAG) AS tagCount FROM smf_tags_log WHERE ID_TOPIC IN (' . implode(', ', $topic_ids) . ') GROUP BY ID_TOPIC ', __FILE__, __LINE__); while ($row = mysql_fetch_assoc($result)) { $context['topics'][$row['ID_TOPIC']]['tagCount'] = !empty($row['tagCount']) ? $row['tagCount'] : 0; } mysql_free_result($result); } // End tagging system // Fix the sequence of topics if they were retrieved in the wrong order. (for speed reasons...) if ($fake_ascending) { $context['topics'] = array_reverse($context['topics'], true); } if (!empty($modSettings['enableParticipation']) && !$user_info['is_guest'] && !empty($topic_ids)) { $result = db_query("\n\t\t\t\tSELECT ID_TOPIC\n\t\t\t\tFROM {$db_prefix}messages\n\t\t\t\tWHERE ID_TOPIC IN (" . implode(', ', $topic_ids) . ")\n\t\t\t\t\tAND ID_MEMBER = {$ID_MEMBER}\n\t\t\t\tGROUP BY ID_TOPIC\n\t\t\t\tLIMIT " . count($topic_ids), __FILE__, __LINE__); while ($row = mysql_fetch_assoc($result)) { $context['topics'][$row['ID_TOPIC']]['is_posted_in'] = true; $context['topics'][$row['ID_TOPIC']]['class'] = 'my_' . $context['topics'][$row['ID_TOPIC']]['class']; } mysql_free_result($result); } } loadJumpTo(); // Is Quick Moderation active? if (!empty($options['display_quick_mod'])) { $context['can_lock'] = allowedTo('lock_any'); $context['can_sticky'] = allowedTo('make_sticky') && !empty($modSettings['enableStickyTopics']); $context['can_move'] = allowedTo('move_any'); $context['can_remove'] = allowedTo('remove_any'); $context['can_merge'] = allowedTo('merge_any'); // Set permissions for all the topics. foreach ($context['topics'] as $t => $topic) { $started = $topic['first_post']['member']['id'] == $ID_MEMBER; $context['topics'][$t]['quick_mod'] = array('lock' => allowedTo('lock_any') || $started && allowedTo('lock_own'), 'sticky' => allowedTo('make_sticky') && !empty($modSettings['enableStickyTopics']), 'move' => allowedTo('move_any') || $started && allowedTo('move_own'), 'modify' => allowedTo('modify_any') || $started && allowedTo('modify_own'), 'remove' => allowedTo('remove_any') || $started && allowedTo('remove_own')); $context['can_lock'] |= $started && allowedTo('lock_own'); $context['can_move'] |= $started && allowedTo('move_own'); $context['can_remove'] |= $started && allowedTo('remove_own'); } $board_count = 0; foreach ($context['jump_to'] as $id => $cat) { if (!empty($_SESSION['move_to_topic']) && isset($context['jump_to'][$id]['boards'][$_SESSION['move_to_topic']])) { $context['jump_to'][$id]['boards'][$_SESSION['move_to_topic']]['selected'] = true; } $board_count += count($context['jump_to'][$id]['boards']); } // You can only see just this one board? if ($board_count <= 1) { $context['can_move'] = false; } } // If there are children, but no topics and no ability to post topics... $context['no_topic_listing'] = !empty($context['boards']) && empty($context['topics']) && !$context['can_post_new']; }
function top10() { global $context, $smcFunc, $txt, $scripturl, $modSettings; //smf.teknoromi.com En c*k Konu acan top 10 if (($members = cache_get_data('stats_top_starters', 360)) == null) { $request = $smcFunc['db_query']('', ' SELECT id_member_started, COUNT(*) AS hits FROM {db_prefix}topics' . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? ' WHERE id_board != {int:recycle_board}' : '') . ' GROUP BY id_member_started ORDER BY hits DESC LIMIT 10', array('recycle_board' => $modSettings['recycle_board'])); $members = array(); while ($row = $smcFunc['db_fetch_assoc']($request)) { $members[$row['id_member_started']] = $row['hits']; } $smcFunc['db_free_result']($request); cache_put_data('stats_top_starters', $members, 360); } if (empty($members)) { $members = array(0 => 0); } $members_result = $smcFunc['db_query']('', ' SELECT id_member, real_name FROM {db_prefix}members WHERE id_member IN ({array_int:member_list}) ORDER BY FIND_IN_SET(id_member, {string:top_topic_posters}) LIMIT 10', array('member_list' => array_keys($members), 'top_topic_posters' => implode(',', array_keys($members)))); $context['top_starters'] = array(); $max_num_topics = 1; while ($row_members = $smcFunc['db_fetch_assoc']($members_result)) { $context['top_starters'][] = array('name' => $row_members['real_name'], 'id' => $row_members['id_member'], 'num_topics' => $members[$row_members['id_member']], 'href' => $scripturl . '?action=profile;u=' . $row_members['id_member'], 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_members['id_member'] . '">' . $row_members['real_name'] . '</a>'); if ($max_num_topics < $members[$row_members['id_member']]) { $max_num_topics = $members[$row_members['id_member']]; } if (!empty($modSettings['MemberColorStats'])) { $context['MemberColor_ID_MEMBER'][$row_members['id_member']] = $row_members['id_member']; } } $smcFunc['db_free_result']($members_result); foreach ($context['top_starters'] as $i => $topic) { $context['top_starters'][$i]['post_percent'] = round($topic['num_topics'] * 100 / $max_num_topics); $context['top_starters'][$i]['num_topics'] = comma_format($context['top_starters'][$i]['num_topics']); } //smf.teknoromi.com En c*k Konu acan top 10 Bitti //smf.teknoromi.com Yeni uyeler top 10 $members_result = $smcFunc['db_query']('', ' SELECT id_member, real_name, posts FROM {db_prefix}members ORDER BY id_member DESC LIMIT 10', array()); $context['new_members'] = array(); while ($row_members = $smcFunc['db_fetch_assoc']($members_result)) { $context['new_members'][] = array('name' => $row_members['real_name'], 'id' => $row_members['id_member'], 'href' => $scripturl . '?action=profile;u=' . $row_members['id_member'], 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_members['id_member'] . '">' . $row_members['real_name'] . '</a>'); } $smcFunc['db_free_result']($members_result); //smf.teknoromi.com Yeni uyeler top 10 bitti //smf.teknoromi.com En c*k mesaj atan top 10. $members_result = $smcFunc['db_query']('', ' SELECT id_member, real_name, posts FROM {db_prefix}members WHERE posts > {int:no_posts} ORDER BY posts DESC LIMIT 10', array('no_posts' => 0)); $context['top_posters'] = array(); $max_num_posts = 1; $context['MemberColor_ID_MEMBER'] = array(); while ($row_members = $smcFunc['db_fetch_assoc']($members_result)) { $context['top_posters'][] = array('name' => $row_members['real_name'], 'id' => $row_members['id_member'], 'num_posts' => $row_members['posts'], 'href' => $scripturl . '?action=profile;u=' . $row_members['id_member'], 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_members['id_member'] . '">' . $row_members['real_name'] . '</a>'); if ($max_num_posts < $row_members['posts']) { $max_num_posts = $row_members['posts']; } if (!empty($modSettings['MemberColorStats']) && !empty($row_members['id_member'])) { $context['MemberColor_ID_MEMBER'][$row_members['id_member']] = $row_members['id_member']; } } $smcFunc['db_free_result']($members_result); foreach ($context['top_posters'] as $i => $poster) { $context['top_posters'][$i]['post_percent'] = round($poster['num_posts'] * 100 / $max_num_posts); $context['top_posters'][$i]['num_posts'] = comma_format($context['top_posters'][$i]['num_posts']); } //smf.teknoromi.com En c*k mesaj atan top 10 Bitti //smf.teknoromi.com En c*k yanitlananlar top 10. $topic_ids = array(); $topic_reply_result = $smcFunc['db_query']('', ' SELECT m.subject, t.num_replies, t.id_board, t.id_topic, b.name FROM {db_prefix}topics AS t INNER JOIN {db_prefix}messages AS m ON (m.id_msg = t.id_first_msg) INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board' . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? ' AND b.id_board != {int:recycle_board}' : '') . ') WHERE {query_see_board}' . (!empty($topic_ids) ? ' AND t.id_topic IN ({array_int:topic_list})' : ($modSettings['postmod_active'] ? ' AND t.approved = {int:is_approved}' : '')) . ' ORDER BY t.num_replies DESC LIMIT 10', array('topic_list' => $topic_ids, 'recycle_board' => $modSettings['recycle_board'], 'is_approved' => 1)); $context['top_topics_replies'] = array(); $max_num_replies = 1; while ($row_topic_reply = $smcFunc['db_fetch_assoc']($topic_reply_result)) { censorText($row_topic_reply['subject']); $context['top_topics_replies'][] = array('id' => $row_topic_reply['id_topic'], 'board' => array('id' => $row_topic_reply['id_board'], 'name' => $row_topic_reply['name'], 'href' => $scripturl . '?board=' . $row_topic_reply['id_board'] . '.0', 'link' => '<a href="' . $scripturl . '?board=' . $row_topic_reply['id_board'] . '.0">' . $row_topic_reply['name'] . '</a>'), 'subject' => $row_topic_reply['subject'], 'num_replies' => $row_topic_reply['num_replies'], 'href' => $scripturl . '?topic=' . $row_topic_reply['id_topic'] . '.0', 'link' => '<a href="' . $scripturl . '?topic=' . $row_topic_reply['id_topic'] . '.0">' . $row_topic_reply['subject'] . '</a>'); if ($max_num_replies < $row_topic_reply['num_replies']) { $max_num_replies = $row_topic_reply['num_replies']; } } $smcFunc['db_free_result']($topic_reply_result); foreach ($context['top_topics_replies'] as $i => $topic) { $context['top_topics_replies'][$i]['post_percent'] = round($topic['num_replies'] * 100 / $max_num_replies); $context['top_topics_replies'][$i]['num_replies'] = comma_format($context['top_topics_replies'][$i]['num_replies']); } //smf.teknoromi.com En c*k yanitlananlar top 10 Bitti //smf.teknoromi.com En c*k goruntulenenler top 10 $topic_view_result = $smcFunc['db_query']('', ' SELECT m.subject, t.num_views, t.id_board, t.id_topic, b.name FROM {db_prefix}topics AS t INNER JOIN {db_prefix}messages AS m ON (m.id_msg = t.id_first_msg) INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board' . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? ' AND b.id_board != {int:recycle_board}' : '') . ') WHERE {query_see_board}' . (!empty($topic_ids) ? ' AND t.id_topic IN ({array_int:topic_list})' : ($modSettings['postmod_active'] ? ' AND t.approved = {int:is_approved}' : '')) . ' ORDER BY t.num_views DESC LIMIT 10', array('topic_list' => $topic_ids, 'recycle_board' => $modSettings['recycle_board'], 'is_approved' => 1)); $context['top_topics_views'] = array(); $max_num_views = 1; while ($row_topic_views = $smcFunc['db_fetch_assoc']($topic_view_result)) { censorText($row_topic_views['subject']); $context['top_topics_views'][] = array('id' => $row_topic_views['id_topic'], 'board' => array('id' => $row_topic_views['id_board'], 'name' => $row_topic_views['name'], 'href' => $scripturl . '?board=' . $row_topic_views['id_board'] . '.0', 'link' => '<a href="' . $scripturl . '?board=' . $row_topic_views['id_board'] . '.0">' . $row_topic_views['name'] . '</a>'), 'subject' => $row_topic_views['subject'], 'num_views' => $row_topic_views['num_views'], 'href' => $scripturl . '?topic=' . $row_topic_views['id_topic'] . '.0', 'link' => '<a href="' . $scripturl . '?topic=' . $row_topic_views['id_topic'] . '.0">' . shorten_subject($row_topic_views['subject'], 24) . '</a>'); if ($max_num_views < $row_topic_views['num_views']) { $max_num_views = $row_topic_views['num_views']; } } $smcFunc['db_free_result']($topic_view_result); foreach ($context['top_topics_views'] as $i => $topic) { $context['top_topics_views'][$i]['post_percent'] = round($topic['num_views'] * 100 / $max_num_views); $context['top_topics_views'][$i]['num_views'] = comma_format($context['top_topics_views'][$i]['num_views']); } // smf.teknoromi.com En c*k goruntulenenler top 10 Bitti //smf.teknoromi.com Likes. // Liked messages top 10. $context['stats_blocks']['liked_messages'] = array(); $max_liked_message = 1; $liked_messages = $smcFunc['db_query']('', ' SELECT m.id_msg, m.subject, m.likes, m.id_board, m.id_topic, t.approved FROM {db_prefix}messages as m INNER JOIN {db_prefix}topics AS t ON (m.id_topic = t.id_topic) INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board' . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? ' AND b.id_board != {int:recycle_board}' : '') . ') WHERE {query_see_board}' . ($modSettings['postmod_active'] ? ' AND t.approved = {int:is_approved}' : '') . ' ORDER BY m.likes DESC LIMIT 10', array('recycle_board' => $modSettings['recycle_board'], 'is_approved' => 1)); while ($row_liked_message = $smcFunc['db_fetch_assoc']($liked_messages)) { censorText($row_liked_message['subject']); $context['stats_blocks']['liked_messages'][] = array('id' => $row_liked_message['id_topic'], 'subject' => $row_liked_message['subject'], 'num' => $row_liked_message['likes'], 'href' => $scripturl . '?msg=' . $row_liked_message['id_msg'], 'link' => '<a href="' . $scripturl . '?msg=' . $row_liked_message['id_msg'] . '">' . $row_liked_message['subject'] . '</a>'); if ($max_liked_message < $row_liked_message['likes']) { $max_liked_message = $row_liked_message['likes']; } } $smcFunc['db_free_result']($liked_messages); foreach ($context['stats_blocks']['liked_messages'] as $i => $liked_messages) { $context['stats_blocks']['liked_messages'][$i]['percent'] = round($liked_messages['num'] * 100 / $max_liked_message); } //smf.teknoromi.com Likes Bitti global $context, $scripturl, $settings, $txt, $modSettings; // Teknoromi bar. echo '<div id="recent_posts_content">'; echo '<dl style="width: 100%;"><dt class="teknoromistats"> <section class="tab-area tabs-checked"> <input checked="checked" name="tab" id="tab-A" type="radio"> <input name="tab" id="tab-B" type="radio"> <input name="tab" id="tab-C" type="radio"> <input name="tab" id="tab-D" type="radio"> <label class="tab-link up_contain" for="tab-A">', $txt['teknoromi1'], '</label> <label class="tab-link up_contain" for="tab-B">', $txt['teknoromi2'], '</label> <label class="tab-link up_contain" for="tab-C">', $txt['teknoromi3'], '</label>'; if (!empty($modSettings['enable_likes'])) { echo '<label class="tab-link up_contain" for="tab-D">', $txt['teknoromi7'], '</label>'; } echo '<article class="tab up_contain"><dl>'; if (!empty($context['latest_posts'])) { foreach ($context['latest_posts'] as $post) { echo '<dt class="silboard"><span style="background-position: 0px -110px;"> </span><a href="', $post['href'], '">', $post['short_subject'], '</a></dt><dd class="silboard1">', $post['board']['link'], '</dd><dd class="sil">', $post['poster']['link'], '</dd>'; } } echo '</dl></article> <article class="tab up_contain"><dl>'; foreach ($context['top_topics_replies'] as $topic) { echo '<dt><span style="background-position: 0px -154px;"> </span>', $topic['link'], '</dt><dd class="fmavi"><span class="fmavi1">', $topic['num_replies'], '</span></dd>'; } echo '</dl></article> <article class="tab up_contain"><dl>'; foreach ($context['top_topics_views'] as $topic) { echo '<dt><span style="background-position: 0px -132px;"> </span>', $topic['link'], '</dt><dd class="fmavi"><span class="fmavi1">', $topic['num_views'], '</span></dd>'; } echo '</dl></article>'; if (!empty($modSettings['enable_likes'])) { echo '<article class="tab up_contain"><dl>'; foreach ($context['stats_blocks']['liked_messages'] as $topic) { echo '<dt><span style="background-position: 0px -132px;"> </span>', $topic['link'], '</dt><dd class="fmavi"><span class="fmavi1">', $topic['num'], '</span></dd>'; } echo '</dl></article>'; } echo '</section></dt><dd class="teknoromistats1"> <section class="tab-area tabs-checked"> <input checked="checked" name="tab" id="tab-E" type="radio"> <input name="tab" id="tab-F" type="radio"> <input name="tab" id="tab-G" type="radio"> <input name="tab" id="tab-Z" type="radio"> <label class="tab-link up_contain" for="tab-E">', $txt['teknoromi4'], '</label> <label class="tab-link up_contain" for="tab-F">', $txt['teknoromi5'], '</label> <label class="tab-link up_contain" for="tab-G">', $txt['teknoromi6'], '</label> <label class="tab-link up_contain" for="tab-Z"></label> <article class="tab up_contain"><dl>'; foreach ($context['top_starters'] as $poster) { echo '<dt><span style="background-position: 0px -22px;"> </span>', $poster['link'], '</dt><dd class="fmavi"><span class="fmavi1">', $poster['num_topics'], '</span></dd>'; } echo '</dl></article> <article class="tab up_contain"><dl>'; foreach ($context['top_posters'] as $poster) { echo '<dt><span style="background-position: 0px 0px;"> </span>', $poster['link'], '</dt><dd class="fmavi"><span class="fmavi1">', $poster['num_posts'], '</span></dd>'; } echo '</dl></article> <article class="tab up_contain">'; foreach ($context['new_members'] as $poster) { echo '<dt><span style="background-position: 0px -88px;"> </span>', $poster['link'], '</dt><dd> </dd>'; } echo '</article> </section></dd></dl>'; echo ' </div>'; }
function getBoardIndex($boardIndexOptions) { global $smcFunc, $scripturl, $user_info, $modSettings, $txt; global $settings, $context; // For performance, track the latest post while going through the boards. if (!empty($boardIndexOptions['set_latest_post'])) { $latest_post = array('timestamp' => 0, 'ref' => 0); } // Find all boards and categories, as well as related information. This will be sorted by the natural order of boards and categories, which we control. $result_boards = smf_db_query(' SELECT' . ($boardIndexOptions['include_categories'] ? ' c.id_cat, c.name AS cat_name, c.description AS cat_desc,' : '') . ' b.id_board, b.name AS board_name, b.description, b.redirect, b.icon AS boardicon, CASE WHEN b.redirect != {string:blank_string} THEN 1 ELSE 0 END AS is_redirect, b.num_posts, b.num_topics, b.unapproved_posts, b.unapproved_topics, b.id_parent, b.allow_topics, IFNULL(m.poster_time, 0) AS poster_time, IFNULL(mem.member_name, m.poster_name) AS poster_name, m.subject, m1.subject AS first_subject, m.id_topic, t.id_first_msg AS id_first_msg, t.id_prefix, m1.icon AS icon, IFNULL(mem.real_name, m.poster_name) AS real_name, p.name as topic_prefix, ' . ($user_info['is_guest'] ? ' 1 AS is_read, 0 AS new_from,' : ' (IFNULL(lb.id_msg, 0) >= b.id_msg_updated) AS is_read, IFNULL(lb.id_msg, -1) + 1 AS new_from,' . ($boardIndexOptions['include_categories'] ? ' c.can_collapse, IFNULL(cc.id_member, 0) AS is_collapsed,' : '')) . ' IFNULL(mem.id_member, 0) AS id_member, m.id_msg, IFNULL(mods_mem.id_member, 0) AS id_moderator, mods_mem.real_name AS mod_real_name FROM {db_prefix}boards AS b' . ($boardIndexOptions['include_categories'] ? ' LEFT JOIN {db_prefix}categories AS c ON (c.id_cat = b.id_cat)' : '') . ' LEFT JOIN {db_prefix}messages AS m ON (m.id_msg = b.id_last_msg) LEFT JOIN {db_prefix}topics AS t ON (t.id_topic = m.id_topic) LEFT JOIN {db_prefix}prefixes AS p ON (p.id_prefix = t.id_prefix) LEFT JOIN {db_prefix}messages AS m1 ON (m1.id_msg = t.id_first_msg) LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)' . ($user_info['is_guest'] ? '' : ' LEFT JOIN {db_prefix}log_boards AS lb ON (lb.id_board = b.id_board AND lb.id_member = {int:current_member})' . ($boardIndexOptions['include_categories'] ? ' LEFT JOIN {db_prefix}collapsed_categories AS cc ON (cc.id_cat = c.id_cat AND cc.id_member = {int:current_member})' : '')) . ' LEFT JOIN {db_prefix}moderators AS mods ON (mods.id_board = b.id_board) LEFT JOIN {db_prefix}members AS mods_mem ON (mods_mem.id_member = mods.id_member) WHERE {query_see_board}' . (empty($boardIndexOptions['countChildPosts']) ? empty($boardIndexOptions['base_level']) ? '' : ' AND b.child_level >= {int:child_level}' : ' AND b.child_level BETWEEN ' . $boardIndexOptions['base_level'] . ' AND ' . ($boardIndexOptions['base_level'] + 1)), array('current_member' => $user_info['id'], 'child_level' => $boardIndexOptions['base_level'], 'blank_string' => '')); // Start with an empty array. if ($boardIndexOptions['include_categories']) { $categories = array(); } else { $this_category = array(); } $total_ignored_boards = 0; // Run through the categories and boards (or only boards).... while ($row_board = mysql_fetch_assoc($result_boards)) { // Perhaps we are ignoring this board? $ignoreThisBoard = in_array($row_board['id_board'], $user_info['ignoreboards']); $total_ignored_boards += $ignoreThisBoard ? 1 : 0; $row_board['is_read'] = !empty($row_board['is_read']) || $ignoreThisBoard ? '1' : '0'; if ($boardIndexOptions['include_categories']) { // Haven't set this category yet. if (empty($categories[$row_board['id_cat']])) { $categories[$row_board['id_cat']] = array('id' => $row_board['id_cat'], 'name' => $row_board['cat_name'], 'desc' => $row_board['cat_desc'], 'is_collapsed' => isset($row_board['can_collapse']) && $row_board['can_collapse'] == 1 && $row_board['is_collapsed'] > 0, 'can_collapse' => isset($row_board['can_collapse']) && $row_board['can_collapse'] == 1, 'collapse_href' => isset($row_board['can_collapse']) ? $scripturl . '?action=collapse;c=' . $row_board['id_cat'] . ';sa=' . ($row_board['is_collapsed'] > 0 ? 'expand;' : 'collapse;') . $context['session_var'] . '=' . $context['session_id'] . '#c' . $row_board['id_cat'] : '', 'collapse_image' => isset($row_board['can_collapse']) ? '<img class="clipsrc ' . ($row_board['is_collapsed'] ? ' _expand' : '_collapse') . '" src="' . $settings['images_url'] . '/clipsrc.png" alt="-" />' : '', 'href' => $scripturl . '#c' . $row_board['id_cat'], 'boards' => array(), 'is_root' => $row_board['cat_name'][0] === '!' ? true : false, 'new' => false); $categories[$row_board['id_cat']]['link'] = '<a id="c' . $row_board['id_cat'] . '"></a>' . ($categories[$row_board['id_cat']]['can_collapse'] ? '<a href="' . $categories[$row_board['id_cat']]['collapse_href'] . '">' . $row_board['cat_name'] . '</a>' : $row_board['cat_name']); } // If this board has new posts in it (and isn't the recycle bin!) then the category is new. if (empty($modSettings['recycle_enable']) || $modSettings['recycle_board'] != $row_board['id_board']) { $categories[$row_board['id_cat']]['new'] |= empty($row_board['is_read']) && $row_board['poster_name'] != ''; } // Avoid showing category unread link where it only has redirection boards. $categories[$row_board['id_cat']]['show_unread'] = !empty($categories[$row_board['id_cat']]['show_unread']) ? 1 : !$row_board['is_redirect']; // Collapsed category - don't do any of this. //if ($categories[$row_board['id_cat']]['is_collapsed']) // continue; // Let's save some typing. Climbing the array might be slower, anyhow. $this_category =& $categories[$row_board['id_cat']]['boards']; } // This is a parent board. if ($row_board['id_parent'] == $boardIndexOptions['parent_id']) { // Is this a new board, or just another moderator? if (!isset($this_category[$row_board['id_board']])) { // Not a child. $isChild = false; $href = URL::board($row_board['id_board'], $row_board['board_name'], 0, false); $this_category[$row_board['id_board']] = array('new' => empty($row_board['is_read']), 'id' => $row_board['id_board'], 'name' => $row_board['board_name'], 'description' => $row_board['description'], 'moderators' => array(), 'link_moderators' => array(), 'children' => array(), 'link_children' => array(), 'children_new' => false, 'topics' => $row_board['num_topics'], 'posts' => $row_board['num_posts'], 'is_redirect' => $row_board['is_redirect'], 'is_page' => !empty($row_board['redirect']) && $row_board['redirect'][0] === '%' && intval(substr($row_board['redirect'], 1)) > 0, 'redirect' => $row_board['redirect'], 'boardicon' => $row_board['boardicon'], 'unapproved_topics' => $row_board['unapproved_topics'], 'unapproved_posts' => $row_board['unapproved_posts'] - $row_board['unapproved_topics'], 'can_approve_posts' => !empty($user_info['mod_cache']['ap']) && ($user_info['mod_cache']['ap'] == array(0) || in_array($row_board['id_board'], $user_info['mod_cache']['ap'])), 'href' => $href, 'link' => '<a href="' . $href . '">' . $row_board['board_name'] . '</a>', 'act_as_cat' => $row_board['allow_topics'] ? false : true, 'ignored' => $ignoreThisBoard); $this_category[$row_board['id_board']]['page_link'] = $this_category[$row_board['id_board']]['is_page'] ? URL::topic(intval(substr($this_category[$row_board['id_board']]['redirect'], 1)), $this_category[$row_board['id_board']]['name'], 0) : ''; } if (!empty($row_board['id_moderator'])) { $this_category[$row_board['id_board']]['moderators'][$row_board['id_moderator']] = array('id' => $row_board['id_moderator'], 'name' => $row_board['mod_real_name'], 'href' => $scripturl . '?action=profile;u=' . $row_board['id_moderator'], 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_board['id_moderator'] . '" title="' . $txt['board_moderator'] . '">' . $row_board['mod_real_name'] . '</a>'); $this_category[$row_board['id_board']]['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $row_board['id_moderator'] . '" title="' . $txt['board_moderator'] . '">' . $row_board['mod_real_name'] . '</a>'; } } elseif (isset($this_category[$row_board['id_parent']]['children']) && !isset($this_category[$row_board['id_parent']]['children'][$row_board['id_board']])) { // A valid child! $isChild = true; $href = URL::board($row_board['id_board'], $row_board['board_name'], 0, false); $this_category[$row_board['id_parent']]['children'][$row_board['id_board']] = array('id' => $row_board['id_board'], 'name' => $row_board['board_name'], 'description' => $row_board['description'], 'short_description' => !empty($row_board['description']) ? $modSettings['child_board_desc_shortened'] ? '(' . commonAPI::substr($row_board['description'], 0, $modSettings['child_board_desc_shortened']) . '...)' : '(' . $row_board['description'] . ')' : '', 'new' => empty($row_board['is_read']) && $row_board['poster_name'] != '', 'topics' => $row_board['num_topics'], 'posts' => $row_board['num_posts'], 'is_redirect' => $row_board['is_redirect'], 'is_page' => !empty($row_board['redirect']) && $row_board['redirect'][0] === '%' && intval(substr($row_board['redirect'], 1)) > 0, 'redirect' => $row_board['redirect'], 'boardicon' => $row_board['boardicon'], 'unapproved_topics' => $row_board['unapproved_topics'], 'unapproved_posts' => $row_board['unapproved_posts'] - $row_board['unapproved_topics'], 'can_approve_posts' => !empty($user_info['mod_cache']['ap']) && ($user_info['mod_cache']['ap'] == array(0) || in_array($row_board['id_board'], $user_info['mod_cache']['ap'])), 'href' => $href, 'link' => '<a href="' . $href . '">' . $row_board['board_name'] . '</a>', 'act_as_cat' => $row_board['allow_topics'] ? false : true, 'ignored' => $ignoreThisBoard); $this_category[$row_board['id_parent']]['children'][$row_board['id_board']]['page_link'] = $this_category[$row_board['id_parent']]['children'][$row_board['id_board']]['is_page'] ? URL::topic(intval(substr($this_category[$row_board['id_parent']]['children'][$row_board['id_board']]['redirect'], 1)), $this_category[$row_board['id_parent']]['children'][$row_board['id_board']]['name'], 0) : ''; // Counting child board posts is... slow :/. if (!empty($boardIndexOptions['countChildPosts']) && !$row_board['is_redirect']) { $this_category[$row_board['id_parent']]['posts'] += $row_board['num_posts']; $this_category[$row_board['id_parent']]['topics'] += $row_board['num_topics']; } // Does this board contain new boards? $this_category[$row_board['id_parent']]['children_new'] |= empty($row_board['is_read']); // This is easier to use in many cases for the theme.... $this_category[$row_board['id_parent']]['link_children'][] =& $this_category[$row_board['id_parent']]['children'][$row_board['id_board']]['link']; } elseif (!empty($boardIndexOptions['countChildPosts'])) { if (!isset($parent_map)) { $parent_map = array(); } if (!isset($parent_map[$row_board['id_parent']])) { foreach ($this_category as $id => $board) { if (!isset($board['children'][$row_board['id_parent']])) { continue; } $parent_map[$row_board['id_parent']] = array(&$this_category[$id], &$this_category[$id]['children'][$row_board['id_parent']]); $parent_map[$row_board['id_board']] = array(&$this_category[$id], &$this_category[$id]['children'][$row_board['id_parent']]); break; } } if (isset($parent_map[$row_board['id_parent']]) && !$row_board['is_redirect']) { $parent_map[$row_board['id_parent']][0]['posts'] += $row_board['num_posts']; $parent_map[$row_board['id_parent']][0]['topics'] += $row_board['num_topics']; $parent_map[$row_board['id_parent']][1]['posts'] += $row_board['num_posts']; $parent_map[$row_board['id_parent']][1]['topics'] += $row_board['num_topics']; continue; } continue; } else { continue; } // Prepare the subject, and make sure it's not too long. censorText($row_board['subject']); $mhref = $row_board['poster_name'] != '' && !empty($row_board['id_member']) ? URL::user($row_board['id_member'], $row_board['real_name']) : ''; $this_last_post = array('id' => $row_board['id_msg'], 'time' => $row_board['poster_time'] > 0 ? timeformat($row_board['poster_time']) : $txt['not_applicable'], 'timestamp' => forum_time(true, $row_board['poster_time']), 'member' => array('id' => $row_board['id_member'], 'username' => $row_board['poster_name'] != '' ? $row_board['poster_name'] : $txt['not_applicable'], 'name' => $row_board['real_name'], 'href' => $mhref, 'link' => $row_board['poster_name'] != '' ? !empty($row_board['id_member']) ? '<a onclick="getMcard(' . $row_board['id_member'] . ', $(this));return(false);" href="' . $mhref . '">' . $row_board['real_name'] . '</a>' : $row_board['real_name'] : $txt['not_applicable']), 'start' => 'msg' . $row_board['new_from'], 'topic' => $row_board['id_topic'], 'prefix' => !empty($row_board['topic_prefix']) ? html_entity_decode($row_board['topic_prefix']) . ' ' : ''); $row_board['short_subject'] = shorten_subject($row_board['subject'], 50); $this_last_post['subject'] = $row_board['short_subject']; $this_first_post = array('id' => $row_board['id_first_msg'], 'icon' => $row_board['icon'], 'icon_url' => getPostIcon($row_board['icon'])); // Provide the href and link. if ($row_board['subject'] != '') { $this_last_post['href'] = URL::topic($row_board['id_topic'], $row_board['first_subject'], 0, false, '.msg' . ($user_info['is_guest'] ? $row_board['id_msg'] : $row_board['new_from']), '#new'); if (empty($row_board['is_read'])) { $this_last_post['href'] = URL::addParam($this_last_post['href'], 'boardseen'); } //$this_last_post['href'] = $scripturl . '?topic=' . $row_board['id_topic'] . '.msg' . ($user_info['is_guest'] ? $row_board['id_msg'] : $row_board['new_from']) . (empty($row_board['is_read']) ? ';boardseen' : '') . '#new'; $this_last_post['link'] = '<a rel="nofollow" href="' . $this_last_post['href'] . '" title="' . $row_board['subject'] . '">' . $row_board['short_subject'] . '</a>'; $this_last_post['topichref'] = URL::topic($row_board['id_topic'], $row_board['first_subject'], 0); // $scripturl . '?topic=' . $row_board['id_topic']; $this_last_post['topiclink'] = '<a href="' . $this_last_post['topichref'] . '" title="' . $row_board['first_subject'] . '">' . $row_board['short_subject'] . '</a>'; } else { $this_last_post['href'] = ''; $this_last_post['link'] = $txt['not_applicable']; $this_last_post['topiclink'] = $txt['not_applicable']; } // Set the last post in the parent board. if ($row_board['id_parent'] == $boardIndexOptions['parent_id'] || $isChild && !empty($row_board['poster_time']) && $this_category[$row_board['id_parent']]['last_post']['timestamp'] < forum_time(true, $row_board['poster_time'])) { $this_category[$isChild ? $row_board['id_parent'] : $row_board['id_board']]['last_post'] = $this_last_post; $this_category[$isChild ? $row_board['id_parent'] : $row_board['id_board']]['first_post'] = $this_first_post; } // Just in the child...? if ($isChild) { $this_category[$row_board['id_parent']]['children'][$row_board['id_board']]['last_post'] = $this_last_post; $this_category[$row_board['id_parent']]['children'][$row_board['id_board']]['first_post'] = $this_first_post; // If there are no posts in this board, it really can't be new... $this_category[$row_board['id_parent']]['children'][$row_board['id_board']]['new'] &= $row_board['poster_name'] != ''; } elseif ($row_board['poster_name'] == '') { $this_category[$row_board['id_board']]['new'] = false; } // Determine a global most recent topic. if (!empty($boardIndexOptions['set_latest_post']) && !empty($row_board['poster_time']) && $row_board['poster_time'] > $latest_post['timestamp'] && !$ignoreThisBoard) { $latest_post = array('timestamp' => $row_board['poster_time'], 'ref' => &$this_category[$isChild ? $row_board['id_parent'] : $row_board['id_board']]['last_post']); } } mysql_free_result($result_boards); // By now we should know the most recent post...if we wanna know it that is. if (!empty($boardIndexOptions['set_latest_post']) && !empty($latest_post['ref'])) { $context['latest_post'] = $latest_post['ref']; } $hidden_boards = $visible_boards = 0; $context['hidden_boards']['id'] = $context['hidden_boards']['is_collapsed'] = 0; // only run this if we actually have some boards on the ignore list to save cycles. if ($total_ignored_boards) { if ($boardIndexOptions['include_categories']) { foreach ($categories as &$cat) { $hidden_boards += hideIgnoredBoards($cat['boards']); } } else { if (count($this_category)) { $hidden_boards += hideIgnoredBoards($this_category); } } $context['hidden_boards']['notice'] = $txt[$hidden_boards > 1 ? 'hidden_boards_notice_many' : 'hidden_boards_notice_one']; $context['hidden_boards']['setup_notice'] = sprintf($txt['hidden_boards_setup_notice'], $scripturl . '?action=profile;area=ignoreboards'); } $context['hidden_boards']['hidden_count'] = $hidden_boards; $context['hidden_boards']['visible_count'] = $visible_boards; return $boardIndexOptions['include_categories'] ? $categories : $this_category; }
function ssi_recentTopics($num_recent = 8, $exclude_boards = null, $output_method = 'echo') { global $context, $settings, $scripturl, $txt, $db_prefix, $ID_MEMBER; global $user_info, $modSettings, $func; if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) { $exclude_boards = array($modSettings['recycle_board']); } else { $exclude_boards = empty($exclude_boards) ? array() : $exclude_boards; } $stable_icons = array('xx', 'thumbup', 'thumbdown', 'exclamation', 'question', 'lamp', 'smiley', 'angry', 'cheesy', 'grin', 'sad', 'wink', 'moved', 'recycled', 'wireless'); $icon_sources = array(); foreach ($stable_icons as $icon) { $icon_sources[$icon] = 'images_url'; } // Find all the posts in distinct topics. Newer ones will have higher IDs. $request = db_query("\n\t\tSELECT\n\t\t\tm.posterTime, ms.subject, m.ID_TOPIC, m.ID_MEMBER, m.ID_MSG, b.ID_BOARD, b.name AS bName,\n\t\t\tIFNULL(mem.realName, m.posterName) AS posterName, " . ($user_info['is_guest'] ? '1 AS isRead, 0 AS new_from' : ' IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, 0)) >= m.ID_MSG_MODIFIED AS isRead, IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, -1)) + 1 AS new_from') . ", LEFT(m.body, 384) AS body, m.smileysEnabled, m.icon\n\t\tFROM ({$db_prefix}messages AS m, {$db_prefix}topics AS t, {$db_prefix}boards AS b, {$db_prefix}messages AS ms)\n\t\t\tLEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)" . (!$user_info['is_guest'] ? "\n\t\t\tLEFT JOIN {$db_prefix}log_topics AS lt ON (lt.ID_TOPIC = t.ID_TOPIC AND lt.ID_MEMBER = {$ID_MEMBER})\n\t\t\tLEFT JOIN {$db_prefix}log_mark_read AS lmr ON (lmr.ID_BOARD = b.ID_BOARD AND lmr.ID_MEMBER = {$ID_MEMBER})" : '') . "\n\t\tWHERE t.ID_LAST_MSG >= " . ($modSettings['maxMsgID'] - 35 * min($num_recent, 5)) . "\n\t\t\tAND t.ID_LAST_MSG = m.ID_MSG\n\t\t\tAND b.ID_BOARD = t.ID_BOARD" . (empty($exclude_boards) ? '' : "\n\t\t\tAND b.ID_BOARD NOT IN (" . implode(', ', $exclude_boards) . ")") . "\n\t\t\tAND {$user_info['query_see_board']}\n\t\t\tAND ms.ID_MSG = t.ID_FIRST_MSG\n\t\tORDER BY t.ID_LAST_MSG DESC\n\t\tLIMIT {$num_recent}", __FILE__, __LINE__); $posts = array(); while ($row = mysql_fetch_assoc($request)) { $row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileysEnabled'], $row['ID_MSG']), array('<br />' => ' '))); if ($func['strlen']($row['body']) > 128) { $row['body'] = $func['substr']($row['body'], 0, 128) . '...'; } // Censor the subject. censorText($row['subject']); censorText($row['body']); if (empty($modSettings['messageIconChecks_disable']) && !isset($icon_sources[$row['icon']])) { $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.gif') ? 'images_url' : 'default_images_url'; } // Build the array. $posts[] = array('board' => array('id' => $row['ID_BOARD'], 'name' => $row['bName'], 'href' => $scripturl . '?board=' . $row['ID_BOARD'] . '.0', 'link' => '<a href="' . $scripturl . '?board=' . $row['ID_BOARD'] . '.0">' . $row['bName'] . '</a>'), 'topic' => $row['ID_TOPIC'], 'poster' => array('id' => $row['ID_MEMBER'], 'name' => $row['posterName'], 'href' => empty($row['ID_MEMBER']) ? '' : $scripturl . '?action=profile;u=' . $row['ID_MEMBER'], 'link' => empty($row['ID_MEMBER']) ? $row['posterName'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['posterName'] . '</a>'), 'subject' => $row['subject'], 'short_subject' => shorten_subject($row['subject'], 25), 'preview' => $row['body'], 'time' => timeformat($row['posterTime']), 'timestamp' => forum_time(true, $row['posterTime']), 'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['ID_MSG'] . ';topicseen#new', 'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['ID_MSG'] . '#new">' . $row['subject'] . '</a>', 'new' => !empty($row['isRead']), 'new_from' => $row['new_from'], 'icon' => '<img src="' . $settings[$icon_sources[$row['icon']]] . '/post/' . $row['icon'] . '.gif" align="middle" alt="' . $row['icon'] . '" border="0" />'); } mysql_free_result($request); // Just return it. if ($output_method != 'echo' || empty($posts)) { return $posts; } echo ' <table border="0" class="ssi_table">'; foreach ($posts as $post) { echo ' <tr> <td align="right" valign="top" nowrap="nowrap"> [', $post['board']['link'], '] </td> <td valign="top"> <a href="', $post['href'], '">', $post['subject'], '</a> ', $txt[525], ' ', $post['poster']['link'], ' ', $post['new'] ? '' : '<a href="' . $scripturl . '?topic=' . $post['topic'] . '.msg' . $post['new_from'] . ';topicseen#new"><img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/new.gif" alt="' . $txt[302] . '" border="0" /></a>', ' </td> <td align="right" nowrap="nowrap"> ', $post['time'], ' </td> </tr>'; } echo ' </table>'; }