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 PrintTopic() { global $db_prefix, $topic, $txt, $scripturl, $context; global $board_info; if (empty($topic)) { fatal_lang_error(472, false); } // Get the topic starter information. $request = db_query("\n\t\tSELECT m.posterTime, IFNULL(mem.realName, m.posterName) AS posterName\n\t\tFROM {$db_prefix}messages AS m\n\t\t\tLEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)\n\t\tWHERE m.ID_TOPIC = {$topic}\n\t\tORDER BY ID_MSG\n\t\tLIMIT 1", __FILE__, __LINE__); if (mysql_num_rows($request) == 0) { fatal_lang_error('smf232'); } $row = mysql_fetch_assoc($request); mysql_free_result($request); // Lets "output" all that info. loadTemplate('Printpage'); $context['template_layers'] = array('print'); $context['board_name'] = $board_info['name']; $context['category_name'] = $board_info['cat']['name']; $context['poster_name'] = $row['posterName']; $context['post_time'] = timeformat($row['posterTime'], false); // Split the topics up so we can print them. $request = db_query("\n\t\tSELECT subject, posterTime, body, IFNULL(mem.realName, posterName) AS posterName\n\t\tFROM {$db_prefix}messages AS m\n\t\t\tLEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)\n\t\tWHERE ID_TOPIC = {$topic}\n\t\tORDER BY ID_MSG", __FILE__, __LINE__); $context['posts'] = array(); while ($row = mysql_fetch_assoc($request)) { // Censor the subject and message. censorText($row['subject']); censorText($row['body']); $context['posts'][] = array('subject' => $row['subject'], 'member' => $row['posterName'], 'time' => timeformat($row['posterTime'], false), 'timestamp' => forum_time(true, $row['posterTime']), 'body' => parse_bbc($row['body'], 'print')); if (!isset($context['topic_subject'])) { $context['topic_subject'] = $row['subject']; } } mysql_free_result($request); }
function PrintTopic() { global $topic, $txt, $scripturl, $context, $user_info; global $board_info, $smcFunc, $modSettings; // Redirect to the boardindex if no valid topic id is provided. if (empty($topic)) { redirectexit(); } // Whatever happens don't index this. $context['robot_no_index'] = true; // Get the topic starter information. $request = $smcFunc['db_query']('', ' SELECT m.poster_time, IFNULL(mem.real_name, m.poster_name) AS poster_name FROM {db_prefix}messages AS m LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member) WHERE m.id_topic = {int:current_topic} ORDER BY m.id_msg LIMIT 1', array('current_topic' => $topic)); // Redirect to the boardindex if no valid topic id is provided. if ($smcFunc['db_num_rows']($request) == 0) { redirectexit(); } $row = $smcFunc['db_fetch_assoc']($request); $smcFunc['db_free_result']($request); // Lets "output" all that info. loadTemplate('Printpage'); $context['template_layers'] = array('print'); $context['board_name'] = $board_info['name']; $context['category_name'] = $board_info['cat']['name']; $context['poster_name'] = $row['poster_name']; $context['post_time'] = timeformat($row['poster_time'], false); $context['parent_boards'] = array(); foreach ($board_info['parent_boards'] as $parent) { $context['parent_boards'][] = $parent['name']; } // Split the topics up so we can print them. $request = $smcFunc['db_query']('', ' SELECT subject, poster_time, body, IFNULL(mem.real_name, poster_name) AS poster_name FROM {db_prefix}messages AS m LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member) WHERE m.id_topic = {int:current_topic}' . ($modSettings['postmod_active'] && !allowedTo('approve_posts') ? ' AND (m.approved = {int:is_approved}' . ($user_info['is_guest'] ? '' : ' OR m.id_member = {int:current_member}') . ')' : '') . ' ORDER BY m.id_msg', array('current_topic' => $topic, 'is_approved' => 1, 'current_member' => $user_info['id'])); $context['posts'] = array(); while ($row = $smcFunc['db_fetch_assoc']($request)) { // Censor the subject and message. censorText($row['subject']); censorText($row['body']); $context['posts'][] = array('subject' => $row['subject'], 'member' => $row['poster_name'], 'time' => timeformat($row['poster_time'], false), 'timestamp' => forum_time(true, $row['poster_time']), 'body' => parse_bbc($row['body'], 'print')); if (!isset($context['topic_subject'])) { $context['topic_subject'] = $row['subject']; } } $smcFunc['db_free_result']($request); // Set a canonical URL for this page. $context['canonical_url'] = $scripturl . '?topic=' . $topic . '.0'; }
function entries($id, $num, $style) { $rows = getposts($id); $entries = count($rows); $count = $entries; while ($count > 0 && $entries - $count < $num) { $currentvalue = $rows[$count - 1]; $DATA = getdbpost($currentvalue); $category = ID_BOARDtoCat($DATA['ID_BOARD']); $filenum = array_search($currentvalue, $rows) + 1; // Content if ($style == 0) { echo " <h2><a class = \"lightbg\" href = \"http://www.turkiball.com/feed/" . $filenum . ".php\">" . $DATA['subject'] . "</a></h2>\n"; echo " <h3>Category: <a class = \"lightbg\" href = \"http://www.turkiball.com/feed/" . $category[1] . ".php\">" . $category[0] . "</a></h3>\n"; echo " <p style = \"text-indent: 0px;\">\n"; echo $DATA['body']; echo " </p>\n"; echo " <h3 style = \"text-align: left;\"><a class = \"lightbg\" href = \"http://www.turkiball.com/board/index.php/topic," . $DATA['ID_TOPIC'] . ".0.html\">Discussion (" . getreplies($DATA['ID_TOPIC']) . " comments)</a></a></h3>\n"; echo " <h3 style = \"text-align: right;\">Posted " . timeformat($DATA['posterTime']) . " by <a class = \"lightbg\" href = \"http://www.turkiball.com/feed/people/index.php?name=" . $DATA['posterName'] . "\">" . $DATA['posterName'] . "</a></h3>\n"; echo " <br><br><br>\n"; echo " <div class = \"contentline\"></div>\n"; } elseif ($style == 1) { echo " <div class = \"newsitem\">\n"; echo " <a href = \"http://www.turkiball.com/feed/" . $category[1] . "/index.php\">\n"; echo " <img src = \"http://www.turkiball.com/images/cat" . $category[1] . "w.jpg\" alt = \"" . $category[0] . "\" width = \"150px\" height = \"30px\" border = \"0\" style = \"position: relative; top: -1px; left: -1px;\">\n"; echo " </a>\n"; echo " <h5>Posted " . dateShrink(timeformat($DATA['posterTime'])) . "</h5>\n"; echo " <h4><a href = \"http://www.turkiball.com/feed/" . $filenum . ".php\">" . $DATA['subject'] . "</a></h4>\n"; echo " <h6>By <a href = \"http://www.turkiball.com/feed/people/index.php?name=" . $DATA['posterName'] . "\">" . $DATA['posterName'] . "</a></h6>\n"; echo " </div>\n"; } elseif ($style == 2) { // Setup the table if ($count == $entries) { echo " <table height=\"87\" cellspacing=\"8\" cellpadding=\"4\" width=\"530\" border=\"0\">\n"; echo " <tbody>\n"; echo " <tr><td><b>Title</b></td>\n"; echo " <td><b>Category</b></td>\n"; echo " <td><b>Date</b></td>\n"; echo " <td><b>By</b></td></tr>\n"; echo " <tr><td> </td><td> </td><td> </td><td> </td></tr>\n"; } echo " <tr><td><a class = \"lightbg\" href = \"http://www.turkiball.com/feed/" . $filenum . ".php\"><b>" . $DATA['subject'] . "</b></a></td>\n"; echo " <td><a class = \"lightbg\" href = \"http://www.turkiball.com/feed/" . $category[1] . ".php\"><b>" . $category[0] . "</b></a></td>\n"; echo " <td><b>" . dateShrink(timeformat($DATA['posterTime'])) . "</b></a></td>\n"; echo " <td><a class = \"lightbg\" href = \"http://www.turkiball.com/feed/people/index.php?name=" . $DATA['posterName'] . "\"><b>" . $DATA['posterName'] . "</b></td></tr>\n"; // Close out the table if ($count == 1) { echo " </tbody>\n"; echo " </table>\n"; } } else { echo "Error: invalid {$style} parameter received\n"; } $count--; } }
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; }
/** * Output a block of XML that contains the details of our draft. * * @param int $draft */ function draftXmlReturn($draft) { if (empty($draft)) { return; } global $txt, $context; header('Content-Type: text/xml; charset=UTF-8'); echo '<', '?xml version="1.0" encoding="UTF-8"?', '> <response> <lastsave id="', $draft, '"><![CDATA[', $txt['last_saved_on'], ': ', timeformat(time()), ']', ']></lastsave> </response>'; obExit(false); }
/** * SMF Arcade * * @package SMF Arcade * @version 2.6 Alpha * @license http://download.smfarcade.info/license.php New-BSD */ function arcadeStats($memID) { global $db_prefix, $scripturl, $txt, $modSettings, $context, $settings, $user_info, $smcFunc, $sourcedir; require_once $sourcedir . '/Arcade.php'; SMFArcade::loadArcade('profile'); $context['arcade']['member_stats'] = array(); $result = $smcFunc['db_query']('', ' SELECT COUNT(*) AS champion FROM {db_prefix}arcade_games WHERE id_champion = {int:member} AND enabled = 1', array('member' => $memID)); $context['arcade']['member_stats'] += $smcFunc['db_fetch_assoc']($result); $smcFunc['db_free_result']($result); $result = $smcFunc['db_query']('', ' SELECT COUNT(*) AS rates, (SUM(rating) / COUNT(*)) AS avg_rating FROM {db_prefix}arcade_rates WHERE id_member = {int:member}', array('member' => $memID)); $context['arcade']['member_stats'] += $smcFunc['db_fetch_assoc']($result); $smcFunc['db_free_result']($result); $result = $smcFunc['db_query']('', ' SELECT s.position, s.score, s.end_time, game.game_name, game.id_game FROM ({db_prefix}arcade_scores AS s, {db_prefix}arcade_games AS game) WHERE id_member = {int:member} AND personal_best = 1 AND s.id_game = game.id_game AND game.enabled = 1 ORDER BY position LIMIT 10', array('member' => $memID)); $context['arcade']['member_stats']['scores'] = array(); while ($row = $smcFunc['db_fetch_assoc']($result)) { $context['arcade']['member_stats']['scores'][] = array('link' => $scripturl . '?action=arcade;game=' . $row['id_game'], 'name' => $row['game_name'], 'score' => comma_format($row['score']), 'position' => $row['position'], 'time' => timeformat($row['end_time'])); } $smcFunc['db_free_result']($result); $result = $smcFunc['db_query']('', ' SELECT s.position, s.score, s.end_time, game.game_name, game.id_game FROM ({db_prefix}arcade_scores AS s, {db_prefix}arcade_games AS game) WHERE id_member = {int:member} AND personal_best = 1 AND s.id_game = game.id_game AND game.enabled = 1 ORDER BY end_time DESC LIMIT 10', array('member' => $memID)); $context['arcade']['member_stats']['latest_scores'] = array(); while ($row = $smcFunc['db_fetch_assoc']($result)) { $context['arcade']['member_stats']['latest_scores'][] = array('link' => $scripturl . '?action=arcade;game=' . $row['id_game'], 'name' => $row['game_name'], 'score' => comma_format($row['score']), 'position' => $row['position'], 'time' => timeformat($row['end_time'])); } $smcFunc['db_free_result']($result); // Layout $context['sub_template'] = 'arcade_user_statistics'; $context['page_title'] = sprintf($txt['arcade_user_stats_title'], $context['member']['name']); }
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; }
function scheduled_paid_subscriptions() { global $txt, $sourcedir, $scripturl, $modSettings, $language; // Start off by checking for removed subscriptions. $request = smf_db_query(' SELECT id_subscribe, id_member FROM {db_prefix}log_subscribed WHERE status = {int:is_active} AND end_time < {int:time_now}', array('is_active' => 1, 'time_now' => time())); while ($row = mysql_fetch_assoc($request)) { require_once $sourcedir . '/ManagePaid.php'; removeSubscription($row['id_subscribe'], $row['id_member']); } mysql_free_result($request); // Get all those about to expire that have not had a reminder sent. $request = smf_db_query(' SELECT ls.id_sublog, m.id_member, m.member_name, m.email_address, m.lngfile, s.name, ls.end_time FROM {db_prefix}log_subscribed AS ls INNER JOIN {db_prefix}subscriptions AS s ON (s.id_subscribe = ls.id_subscribe) INNER JOIN {db_prefix}members AS m ON (m.id_member = ls.id_member) WHERE ls.status = {int:is_active} AND ls.reminder_sent = {int:reminder_sent} AND s.reminder > {int:reminder_wanted} AND ls.end_time < ({int:time_now} + s.reminder * 86400)', array('is_active' => 1, 'reminder_sent' => 0, 'reminder_wanted' => 0, 'time_now' => time())); $subs_reminded = array(); while ($row = mysql_fetch_assoc($request)) { // If this is the first one load the important bits. if (empty($subs_reminded)) { require_once $sourcedir . '/lib/Subs-Post.php'; // Need the below for loadLanguage to work! loadEssentialThemeData(); } $subs_reminded[] = $row['id_sublog']; $replacements = array('PROFILE_LINK' => $scripturl . '?action=profile;area=subscriptions;u=' . $row['id_member'], 'REALNAME' => $row['member_name'], 'SUBSCRIPTION' => $row['name'], 'END_DATE' => strip_tags(timeformat($row['end_time']))); $emaildata = loadEmailTemplate('paid_subscription_reminder', $replacements, empty($row['lngfile']) || empty($modSettings['userLanguage']) ? $language : $row['lngfile']); // Send the actual email. sendmail($row['email_address'], $emaildata['subject'], $emaildata['body'], null, null, false, 2); } mysql_free_result($request); // Mark the reminder as sent. if (!empty($subs_reminded)) { smf_db_query(' UPDATE {db_prefix}log_subscribed SET reminder_sent = {int:reminder_sent} WHERE id_sublog IN ({array_int:subscription_list})', array('subscription_list' => $subs_reminded, 'reminder_sent' => 1)); } return true; }
/** * fetch_data. * Fetch Boards, Topics, Messages and Attaches. */ function fetch_data() { global $context, $smcFunc, $modSettings, $settings, $boardurl, $scripturl, $txt; $boards = !empty($this->cfg['config']['settings']['board']) ? $this->cfg['config']['settings']['board'] : array(); $this->cfg['config']['settings']['total'] = empty($this->cfg['config']['settings']['total']) ? 1 : $this->cfg['config']['settings']['total']; $this->posts = null; $this->attaches = null; $this->imgName = ''; if (!empty($boards)) { // Load the message icons $stable_icons = array('xx', 'thumbup', 'thumbdown', 'exclamation', 'question', 'lamp', 'smiley', 'angry', 'cheesy', 'grin', 'sad', 'wink', 'moved', 'recycled'); $icon_sources = array(); foreach ($stable_icons as $icon) { $icon_sources[$icon] = 'images_url'; } // find the n post from each board $this->cfg['config']['settings']['total'] = empty($this->cfg['config']['settings']['total']) ? 1 : $this->cfg['config']['settings']['total']; $msgids = array(); $curboard = 0; $request = $smcFunc['db_query']('', ' SELECT b.id_board, b.name, t.id_topic, t.num_replies, t.num_views, m.* FROM {db_prefix}topics as t LEFT JOIN {db_prefix}boards as b ON (t.id_board = b.id_board) LEFT JOIN {db_prefix}messages as m ON (t.id_first_msg = m.id_msg) WHERE b.id_board IN ({array_int:boards}) AND {query_wanna_see_board} ' . ($modSettings['postmod_active'] ? ' AND m.approved = {int:approv}' : '') . ' AND t.id_last_msg >= {int:min_msg} ORDER BY b.id_board ASC, t.id_topic DESC', array('boards' => $boards, 'min_msg' => $modSettings['maxMsgID'] - 100 * $this->cfg['config']['settings']['total'], 'approv' => 1)); while ($row = $smcFunc['db_fetch_assoc']($request)) { if ($row['id_board'] != $curboard) { $curboard = $row['id_board']; $max = $this->cfg['config']['settings']['total']; } if (!empty($max)) { $msgids[$row['id_topic']] = $row['id_msg']; $max--; $row['body'] = parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']); // Check that this message icon is there... if (empty($modSettings['messageIconChecks_disable']) && !isset($icon_sources[$row['icon']])) { $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url'; } censorText($row['subject']); censorText($row['body']); // Rescale inline Images ? if (!empty($this->cfg['config']['settings']['rescale']) || empty($this->cfg['config']['settings']['rescale']) && !is_numeric($this->cfg['config']['settings']['rescale'])) { // find all images if (preg_match_all('~<img[^>]*>~iS', $row['body'], $matches) > 0) { // remove smileys foreach ($matches[0] as $i => $data) { if (strpos($data, $modSettings['smileys_url']) !== false) { unset($matches[0][$i]); } } // images found? if (count($matches[0]) > 0) { $this->imgName = $this->cfg['blocktype'] . '-' . $this->cfg['id']; if (empty($this->cfg['config']['settings']['rescale'])) { $fnd = array('~ class?=?"[^"]*"~', '~ alt?=?"[^"]*"~', '~ title?=?"[^"]*"~'); } else { $fnd = array('~ width?=?"\\d+"~', '~ height?=?"\\d+"~', '~ class?=?"[^"]*"~', '~ alt?=?"[^"]*"~', '~ title?=?"[^"]*"~'); } // modify the images for highslide foreach ($matches[0] as $i => $data) { $datlen = strlen($data); preg_match('~src?=?"([^\\"]*\\")~i', $data, $src); $alt = substr(strrchr($src[1], '/'), 1); $alt = str_replace(array('_', '-'), ' ', strtoupper(substr($alt, 0, strrpos($alt, '.')))); $tmp = str_replace($src[0], ' class="' . $this->imgName . '" alt="' . $alt . '" ' . $src[0], preg_replace($fnd, '', $data)); // highslide disabled? if (!empty($context['pmx']['settings']['disableHS']) || !empty($context['pmx']['settings']['disableHSonfront'])) { $row['body'] = substr_replace($row['body'], $tmp, strpos($row['body'], $data), $datlen); } elseif (empty($this->cfg['config']['settings']['disableHSimg']) && empty($context['pmx']['settings']['disableHSonfront'])) { $row['body'] = substr_replace($row['body'], '<a href="' . $boardurl . '" class="' . $this->imgName . ' highslide" title="' . $txt['pmx_hs_expand'] . '" onclick="return hs.expand(this, {src: \'' . str_replace('"', '', $src[1]) . '\', align: \'center\', headingEval: \'this.thumb.alt\'})">' . $tmp . '</a>', strpos($row['body'], $data), $datlen); } else { $row['body'] = substr_replace($row['body'], $tmp, strpos($row['body'], $data), $datlen); } } } } } elseif (is_numeric($this->cfg['config']['settings']['rescale'])) { $row['body'] = PortaMx_revoveLinks($row['body'], false, true); } // teaser enabled ? if (!empty($this->cfg['config']['settings']['teaser'])) { $row['body'] = PortaMx_Tease_posts($row['body'], $this->cfg['config']['settings']['teaser'], '', false, false); } $this->posts[] = array('id_board' => $row['id_board'], 'board_name' => $row['name'], 'id' => $row['id_topic'], 'message_id' => $row['id_msg'], 'icon' => '<img src="' . $settings[$icon_sources[$row['icon']]] . '/post/' . $row['icon'] . '.png" alt="' . $row['icon'] . '" />', 'subject' => $row['subject'], 'time' => timeformat($row['poster_time']), 'timestamp' => forum_time(true, $row['poster_time']), 'body' => $row['body'], 'replies' => $row['num_replies'], 'views' => $row['num_views'], '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']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['poster_name'] . '</a>' : $row['poster_name']), 'locked' => !empty($row['locked'])); } } $smcFunc['db_free_result']($request); // any post found? if (!is_null($this->posts)) { // get attachments if show thumnails set $allow_boards = boardsAllowedTo('view_attachments'); if (!empty($this->cfg['config']['settings']['thumbs']) && !empty($allow_boards)) { $request = $smcFunc['db_query']('', ' SELECT a.id_msg, a.id_attach, a.id_thumb, a.filename, m.id_topic FROM {db_prefix}attachments AS a LEFT JOIN {db_prefix}messages AS m ON (a.id_msg = m.id_msg) WHERE a.id_msg IN({array_int:messages}) AND a.mime_type LIKE {string:like}' . ($allow_boards === array(0) ? '' : (!$modSettings['postmod_active'] || allowedTo('approve_posts') ? '' : ' AND m.approved = 1 AND a.approved = 1') . ' AND m.id_board IN ({array_int:boards})') . ' ORDER BY m.id_msg DESC, a.id_attach ASC', array('messages' => $msgids, 'like' => 'IMAGE%', 'boards' => $allow_boards)); $thumbs = array(); $msgcnt = array(); $saved = !empty($this->cfg['config']['settings']['thumbcnt']) ? $this->cfg['config']['settings']['thumbcnt'] : 0; while ($row = $smcFunc['db_fetch_assoc']($request)) { if (!in_array($row['id_attach'], $thumbs)) { if (!empty($this->cfg['config']['settings']['thumbcnt'])) { if (!in_array($row['id_msg'], $msgcnt)) { $saved = $this->cfg['config']['settings']['thumbcnt']; } elseif (in_array($row['id_msg'], $msgcnt) && empty($saved)) { continue; } } $saved--; $msgcnt[] = $row['id_msg']; $thumbs[] = $row['id_thumb']; $this->attaches[$row['id_msg']][] = array('topic' => $row['id_topic'], 'image' => $row['id_attach'], 'thumb' => empty($row['id_thumb']) ? $row['id_attach'] : $row['id_thumb'], 'fname' => str_replace('_thumb', '', $row['filename'])); } } $smcFunc['db_free_result']($request); } } } }
function template_main() { global $scripturl, $context, $txt, $settings, $modSettings, $user_profile, $memberContext; // Check if the user is an Admin $manage_staff = allowedTo('admin_forum'); $bbc_check = function_exists('parse_bbc'); echo '<div class="tborder">'; echo '<br />'; $totalcols = 1; if ($modSettings['smfstaff_showavatar']) { $totalcols++; } if ($modSettings['smfstaff_showlastactive']) { $totalcols++; } if ($modSettings['smfstaff_showdateregistered']) { $totalcols++; } if ($modSettings['smfstaff_showcontactinfo']) { $totalcols++; } foreach ($context['smfstaff_groups'] as $id => $data) { $count_users = count(@$context['smfstaff_users'][$data['id']]); if ($count_users == 0) { continue; } echo '<table border="0" cellspacing="0" cellpadding="2" width="100%">'; echo '<tr>'; echo '<td class="catbg2" width="30%">', $data['name'], '</td>'; if ($modSettings['smfstaff_showavatar']) { echo '<td class="catbg2" width="25%">', $txt['smfstaff_avatar'], '</td>'; } if ($modSettings['smfstaff_showlastactive']) { echo '<td class="catbg2" width="25%">', $txt['smfstaff_lastactive'], '</td>'; } if ($modSettings['smfstaff_showdateregistered']) { echo '<td class="catbg2" width="25%">', $txt['smfstaff_dateregistered'], '</td>'; } if ($modSettings['smfstaff_showcontactinfo']) { echo '<td class="catbg2" width="30%">', $txt['smfstaff_contact'], '</td>'; } echo '</tr>'; foreach (@$context['smfstaff_users'][$data['id']] as $id => $row2) { echo '<tr>'; echo '<td class="windowbg"><a href="' . $scripturl . '?action=profile;u=' . $row2['ID_MEMBER'] . '"><font color="' . $data['color'] . '">' . $row2['realName'] . '</font></a></td>'; if ($modSettings['smfstaff_showavatar']) { echo '<td class="windowbg">'; // Display the users avatar $memCommID = $row2['ID_MEMBER']; loadMemberData($memCommID); loadMemberContext($memCommID); echo $memberContext[$memCommID]['avatar']['image']; echo '</td>'; } if ($modSettings['smfstaff_showlastactive']) { echo '<td class="windowbg">' . timeformat($row2['lastLogin']) . '</td>'; } if ($modSettings['smfstaff_showdateregistered']) { echo '<td class="windowbg">' . timeformat($row2['dateRegistered']) . '</td>'; } if ($modSettings['smfstaff_showcontactinfo']) { echo '<td class="windowbg">'; //Send email row if ($row2['hideEmail'] == 0) { echo '<a href="mailto:', $row2['emailAddress'], '"><img src="' . $settings['images_url'] . '/email_sm.gif" alt="email" /></a> '; } if ($row2['ICQ'] != '') { echo '<a href="http://www.icq.com/whitepages/about_me.php?uin=' . $row2['ICQ'] . '" target="_blank"><img src="http://status.icq.com/online.gif?img=5&icq=' . $row2['ICQ'] . '" alt="' . $row2['ICQ'] . '" width="18" height="18" border="0" /></a> '; } if ($row2['AIM'] != '') { echo '<a href="aim:goim?screenname=' . urlencode(strtr($row2['AIM'], array(' ' => '%20'))) . '&message=' . $txt['aim_default_message'] . '"><img src="' . $settings['images_url'] . '/aim.gif" alt="' . $row2['AIM'] . '" border="0" /></a> '; } if ($row2['YIM'] != '') { echo '<a href="http://edit.yahoo.com/config/send_webmesg?.target=' . urlencode($row2['YIM']) . '"><img src="http://opi.yahoo.com/online?u=' . urlencode($row2['YIM']) . '&m=g&t=0" alt="' . $row2['YIM'] . '" border="0" /></a> '; } if ($row2['MSN'] != '') { echo '<a href="http://members.msn.com/' . $row2['MSN'] . '" target="_blank"><img src="' . $settings['images_url'] . '/msntalk.gif" alt="' . $row2['MSN'] . '" border="0" /></a> '; } // Send PM row echo '<a href="' . $scripturl . '?action=pm;sa=send;u=' . $row2['ID_MEMBER'] . '">' . $txt['smfstaff_sendpm'] . '</a>'; echo '</td>'; } // End Contact Information echo '</tr>'; } // If they are allowed to manage the staff page give them the option if ($manage_staff) { echo '<tr> <td align="center" colspan="', $totalcols, '" class="windowbg"> <a href="' . $scripturl . '?action=staff;sa=catdown&id=' . $data['id'] . '">' . $txt['smfstaff_down'] . '</a> | <a href="' . $scripturl . '?action=staff;sa=catup&id=' . $data['id'] . '">' . $txt['smfstaff_up'] . '</a> | <a href="' . $scripturl . '?action=staff;sa=delete&id=' . $data['id'] . ';ret">' . $txt['smfstaff_delgroup'] . '</a></td></tr>'; } echo '</table>'; // Seperate the groups from the local mods. echo '<br />'; } // End of Main staff listing if ($modSettings['smfstaff_showlocalmods']) { $localcount = count($context['smfstaff_localmods']); if ($localcount > 0) { echo '<table border="0" cellspacing="0" cellpadding="2" width="100%">'; echo '<tr>'; echo '<td class="catbg2" width="25%">', $txt['smfstaff_local'], '</td>'; if ($modSettings['smfstaff_showavatar']) { echo '<td class="catbg2" width="25%">', $txt['smfstaff_avatar'], '</td>'; } if ($modSettings['smfstaff_showlastactive']) { echo '<td class="catbg2" width="25%">', $txt['smfstaff_lastactive'], '</td>'; } if ($modSettings['smfstaff_showdateregistered']) { echo '<td class="catbg2" width="25%">', $txt['smfstaff_dateregistered'], '</td>'; } echo '<td class="catbg2" width="25%">', $txt['smfstaff_forums'], '</td>'; if ($modSettings['smfstaff_showcontactinfo']) { echo '<td class="catbg2" width="25%">', $txt['smfstaff_contact'], '</td>'; } echo '</tr>'; foreach ($context['smfstaff_localmods'] as $id => $data) { echo '<tr>'; echo '<td class="windowbg"><a href="', $scripturl, '?action=profile;u=', $data['id'], '">', $data['realName'], '</a></td>'; if ($modSettings['smfstaff_showavatar']) { echo '<td class="windowbg">'; //Display the users avatar $memCommID = $data['id']; loadMemberData($memCommID); loadMemberContext($memCommID); echo $memberContext[$memCommID]['avatar']['image']; echo '</td>'; } if ($modSettings['smfstaff_showlastactive']) { echo '<td class="windowbg">', timeformat($data['lastLogin']), '</td>'; } if ($modSettings['smfstaff_showdateregistered']) { echo '<td class="windowbg">', timeformat($data['dateRegistered']), '</td>'; } echo '<td class="windowbg">', $data['forums'], '</td>'; if ($modSettings['smfstaff_showcontactinfo']) { echo '<td class="windowbg" align="center">'; // Send email row if ($data['hideEmail'] == 0) { echo '<a href="mailto:', $data['emailAddress'], '"><img src="', $settings['images_url'], '/email_sm.gif" alt="email" /></a> '; } if ($data['ICQ'] != '') { echo '<a href="http://www.icq.com/whitepages/about_me.php?uin=', $data['ICQ'], '" target="_blank"><img src="http://status.icq.com/online.gif?img=5&icq=', $data['ICQ'], '" alt="', $data['ICQ'], '" width="18" height="18" border="0" /></a> '; } if ($data['AIM'] != '') { echo '<a href="aim:goim?screenname=', urlencode(strtr($data['AIM'], array(' ' => '%20'))), '&message=', $txt['aim_default_message'], '"><img src="', $settings['images_url'], '/aim.gif" alt="', $data['AIM'], '" border="0" /></a> '; } if ($data['YIM'] != '') { echo '<a href="http://edit.yahoo.com/config/send_webmesg?.target=', urlencode($data['YIM']), '"><img src="http://opi.yahoo.com/online?u=', urlencode($data['YIM']), '&m=g&t=0" alt="', $data['YIM'], '" border="0" /></a> '; } if ($data['MSN'] != '') { echo '<a href="http://members.msn.com/', $data['MSN'], '" target="_blank"><img src="', $settings['images_url'], '/msntalk.gif" alt="', $data['MSN'], '" border="0" /></a> '; } //Send PM row echo '<a href="', $scripturl, '?action=pm;sa=send;u=', $data['id'], '">', $txt['smfstaff_sendpm'], '</a>'; echo '</td>'; } // End smfstaff_showcontactinfo echo '</tr>'; } echo '</table>'; } // End of local mods count } // End of modSettings local mods check // If they can manage the staff page show them the link if ($manage_staff) { echo '<div align="center"><a href="', $scripturl, '?action=staff;sa=admin">', $txt['smfstaff_admin'], '</a></div><br />'; } echo '</div>'; // The Copyright is required to remain or contact me to purchase link removal. echo '<div align="center"><a href="http://www.smfhacks.com" target="blank">SMF Staff</a></div>'; }
/** * Show the list of topics in this board, along with any child boards. */ function MessageIndex() { global $txt, $scripturl, $board, $modSettings, $context; global $options, $settings, $board_info, $user_info, $smcFunc, $sourcedir; // If this is a redirection board head off. if ($board_info['redirect']) { $smcFunc['db_query']('', ' UPDATE {db_prefix}boards SET num_posts = num_posts + 1 WHERE id_board = {int:current_board}', array('current_board' => $board)); redirectexit($board_info['redirect']); } if (WIRELESS) { $context['sub_template'] = WIRELESS_PROTOCOL . '_messageindex'; } else { loadTemplate('MessageIndex'); } $context['name'] = $board_info['name']; $context['description'] = $board_info['description']; // How many topics do we have in total? $board_info['total_topics'] = allowedTo('approve_posts') ? $board_info['num_topics'] + $board_info['unapproved_topics'] : $board_info['num_topics'] + $board_info['unapproved_user_topics']; // View all the topics, or just a few? $context['topics_per_page'] = empty($modSettings['disableCustomPerPage']) && !empty($options['topics_per_page']) && !WIRELESS ? $options['topics_per_page'] : $modSettings['defaultMaxTopics']; $context['messages_per_page'] = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) && !WIRELESS ? $options['messages_per_page'] : $modSettings['defaultMaxMessages']; $maxindex = isset($_REQUEST['all']) && !empty($modSettings['enableAllMessages']) ? $board_info['total_topics'] : $context['topics_per_page']; // Right, let's only index normal stuff! if (count($_GET) > 1) { $session_name = session_name(); foreach ($_GET as $k => $v) { if (!in_array($k, array('board', 'start', $session_name))) { $context['robot_no_index'] = true; } } } if (!empty($_REQUEST['start']) && (!is_numeric($_REQUEST['start']) || $_REQUEST['start'] % $context['messages_per_page'] != 0)) { $context['robot_no_index'] = true; } // If we can view unapproved messages and there are some build up a list. if (allowedTo('approve_posts') && ($board_info['unapproved_topics'] || $board_info['unapproved_posts'])) { $untopics = $board_info['unapproved_topics'] ? '<a href="' . $scripturl . '?action=moderate;area=postmod;sa=topics;brd=' . $board . '">' . $board_info['unapproved_topics'] . '</a>' : 0; $unposts = $board_info['unapproved_posts'] ? '<a href="' . $scripturl . '?action=moderate;area=postmod;sa=posts;brd=' . $board . '">' . ($board_info['unapproved_posts'] - $board_info['unapproved_topics']) . '</a>' : 0; $context['unapproved_posts_message'] = sprintf($txt['there_are_unapproved_topics'], $untopics, $unposts, $scripturl . '?action=moderate;area=postmod;sa=' . ($board_info['unapproved_topics'] ? 'topics' : 'posts') . ';brd=' . $board); } // Make sure the starting place makes sense and construct the page index. if (isset($_REQUEST['sort'])) { $context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d;sort=' . $_REQUEST['sort'] . (isset($_REQUEST['desc']) ? ';desc' : ''), $_REQUEST['start'], $board_info['total_topics'], $maxindex, true); } else { $context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d', $_REQUEST['start'], $board_info['total_topics'], $maxindex, true); } $context['start'] =& $_REQUEST['start']; // Set a canonical URL for this page. $context['canonical_url'] = $scripturl . '?board=' . $board . '.' . $context['start']; $context['links'] = array('first' => $_REQUEST['start'] >= $context['topics_per_page'] ? $scripturl . '?board=' . $board . '.0' : '', 'prev' => $_REQUEST['start'] >= $context['topics_per_page'] ? $scripturl . '?board=' . $board . '.' . ($_REQUEST['start'] - $context['topics_per_page']) : '', 'next' => $_REQUEST['start'] + $context['topics_per_page'] < $board_info['total_topics'] ? $scripturl . '?board=' . $board . '.' . ($_REQUEST['start'] + $context['topics_per_page']) : '', 'last' => $_REQUEST['start'] + $context['topics_per_page'] < $board_info['total_topics'] ? $scripturl . '?board=' . $board . '.' . floor(($board_info['total_topics'] - 1) / $context['topics_per_page']) * $context['topics_per_page'] : '', 'up' => $board_info['parent'] == 0 ? $scripturl . '?' : $scripturl . '?board=' . $board_info['parent'] . '.0'); $context['page_info'] = array('current_page' => $_REQUEST['start'] / $context['topics_per_page'] + 1, 'num_pages' => floor(($board_info['total_topics'] - 1) / $context['topics_per_page']) + 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['board_moderator'] . '">' . $mod['name'] . '</a>'; } $context['linktree'][count($context['linktree']) - 1]['extra_after'] = '<span class="board_moderators"> (' . (count($context['link_moderators']) == 1 ? $txt['moderator'] : $txt['moderators']) . ': ' . implode(', ', $context['link_moderators']) . ')</span>'; } // 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; } $smcFunc['db_insert']('replace', '{db_prefix}log_boards', array('id_msg' => 'int', 'id_member' => 'int', 'id_board' => 'int'), array($modSettings['maxMsgID'], $user_info['id'], $board), array('id_member', 'id_board')); if (!empty($board_info['parent_boards'])) { $smcFunc['db_query']('', ' UPDATE {db_prefix}log_boards SET id_msg = {int:id_msg} WHERE id_member = {int:current_member} AND id_board IN ({array_int:board_list})', array('current_member' => $user_info['id'], 'board_list' => array_keys($board_info['parent_boards']), 'id_msg' => $modSettings['maxMsgID'])); // 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 = $smcFunc['db_query']('', ' SELECT sent FROM {db_prefix}log_notify WHERE id_board = {int:current_board} AND id_member = {int:current_member} LIMIT 1', array('current_board' => $board, 'current_member' => $user_info['id'])); $context['is_marked_notify'] = $smcFunc['db_num_rows']($request) != 0; if ($context['is_marked_notify']) { list($sent) = $smcFunc['db_fetch_row']($request); if (!empty($sent)) { $smcFunc['db_query']('', ' UPDATE {db_prefix}log_notify SET sent = {int:is_sent} WHERE id_board = {int:current_board} AND id_member = {int:current_member}', array('current_board' => $board, 'current_member' => $user_info['id'], 'is_sent' => 0)); } } $smcFunc['db_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') || $modSettings['postmod_active'] && allowedTo('post_unapproved_topics'); $context['can_post_poll'] = $modSettings['pollMode'] == '1' && allowedTo('poll_post') && $context['can_post_new']; $context['can_moderate_forum'] = allowedTo('moderate_forum'); $context['can_approve_posts'] = allowedTo('approve_posts'); require_once $sourcedir . '/Subs-BoardIndex.php'; $boardIndexOptions = array('include_categories' => false, 'base_level' => $board_info['child_level'] + 1, 'parent_id' => $board_info['id'], 'set_latest_post' => false, 'countChildPosts' => !empty($modSettings['countChildPosts'])); $context['boards'] = getBoardIndex($boardIndexOptions); // 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 = $smcFunc['db_query']('', ' SELECT lo.id_member, lo.log_time, mem.real_name, mem.member_name, mem.show_online, mg.online_color, mg.id_group, mg.group_name FROM {db_prefix}log_online AS lo LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = lo.id_member) LEFT JOIN {db_prefix}membergroups AS mg ON (mg.id_group = CASE WHEN mem.id_group = {int:reg_member_group} THEN mem.id_post_group ELSE mem.id_group END) WHERE INSTR(lo.url, {string:in_url_string}) > 0 OR lo.session = {string:session}', array('reg_member_group' => 0, 'in_url_string' => 's:5:"board";i:' . $board . ';', 'session' => $user_info['is_guest'] ? 'ip' . $user_info['ip'] : session_id())); while ($row = $smcFunc['db_fetch_assoc']($request)) { if (empty($row['id_member'])) { continue; } if (!empty($row['online_color'])) { $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; } else { $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; } $is_buddy = in_array($row['id_member'], $user_info['buddies']); if ($is_buddy) { $link = '<strong>' . $link . '</strong>'; } if (!empty($row['show_online']) || allowedTo('moderate_forum')) { $context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link; } $context['view_members'][$row['log_time'] . $row['member_name']] = array('id' => $row['id_member'], 'username' => $row['member_name'], 'name' => $row['real_name'], 'group' => $row['id_group'], 'href' => $scripturl . '?action=profile;u=' . $row['id_member'], 'link' => $link, 'is_buddy' => $is_buddy, 'hidden' => empty($row['show_online'])); if (empty($row['show_online'])) { $context['view_num_hidden']++; } } $context['view_num_guests'] = $smcFunc['db_num_rows']($request) - count($context['view_members']); $smcFunc['db_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.real_name, mf.poster_name)', 'last_poster' => 'IFNULL(meml.real_name, ml.poster_name)', 'replies' => 't.num_replies', 'views' => 't.num_views', '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 = (int) $_REQUEST['start']; if ($start > ($board_info['total_topics'] - 1) / 2) { $ascending = !$ascending; $fake_ascending = true; $maxindex = $board_info['total_topics'] < $start + $maxindex + 1 ? $board_info['total_topics'] - $start : $maxindex; $start = $board_info['total_topics'] < $start + $maxindex + 1 ? 0 : $board_info['total_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', 'poll', 'moved', 'recycled', 'wireless', 'clip'); $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 && $maxindex > 0) { $request = $smcFunc['db_query']('', ' SELECT t.id_topic FROM {db_prefix}topics AS t' . ($context['sort_by'] === 'last_poster' ? ' INNER JOIN {db_prefix}messages AS ml ON (ml.id_msg = t.id_last_msg)' : (in_array($context['sort_by'], array('starter', 'subject')) ? ' INNER JOIN {db_prefix}messages AS mf ON (mf.id_msg = t.id_first_msg)' : '')) . ($context['sort_by'] === 'starter' ? ' LEFT JOIN {db_prefix}members AS memf ON (memf.id_member = mf.id_member)' : '') . ($context['sort_by'] === 'last_poster' ? ' LEFT JOIN {db_prefix}members AS meml ON (meml.id_member = ml.id_member)' : '') . ' WHERE t.id_board = {int:current_board}' . (!$modSettings['postmod_active'] || $context['can_approve_posts'] ? '' : ' AND (t.approved = {int:is_approved}' . ($user_info['is_guest'] ? '' : ' OR t.id_member_started = {int:current_member}') . ')') . ' ORDER BY ' . (!empty($modSettings['enableStickyTopics']) ? 'is_sticky' . ($fake_ascending ? '' : ' DESC') . ', ' : '') . $_REQUEST['sort'] . ($ascending ? '' : ' DESC') . ' LIMIT {int:start}, {int:maxindex}', array('current_board' => $board, 'current_member' => $user_info['id'], 'is_approved' => 1, 'id_member_guest' => 0, 'start' => $start, 'maxindex' => $maxindex)); $topic_ids = array(); while ($row = $smcFunc['db_fetch_assoc']($request)) { $topic_ids[] = $row['id_topic']; } } // Grab the appropriate topic information... if (!$pre_query || !empty($topic_ids)) { // For search engine effectiveness we'll link guests differently. $context['pageindex_multiplier'] = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) && !WIRELESS ? $options['messages_per_page'] : $modSettings['defaultMaxMessages']; $result = $smcFunc['db_query']('substring', ' SELECT t.id_topic, t.num_replies, t.locked, t.num_views, t.is_sticky, t.id_poll, t.id_previous_board, ' . ($user_info['is_guest'] ? '0' : 'IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1') . ' AS new_from, t.id_last_msg, t.approved, t.unapproved_posts, t.id_redirect_topic, ml.poster_time AS last_poster_time, ml.id_msg_modified, ml.subject AS last_subject, ml.icon AS last_icon, ml.poster_name AS last_member_name, ml.id_member AS last_id_member, ' . (!empty($settings['avatars_on_indexes']) ? 'meml.avatar,' : '') . ' IFNULL(meml.real_name, ml.poster_name) AS last_display_name, t.id_first_msg, mf.poster_time AS first_poster_time, mf.subject AS first_subject, mf.icon AS first_icon, mf.poster_name AS first_member_name, mf.id_member AS first_id_member, IFNULL(memf.real_name, mf.poster_name) AS first_display_name, ' . (!empty($modSettings['preview_characters']) ? ' SUBSTRING(ml.body, 1, ' . ($modSettings['preview_characters'] + 256) . ') AS last_body, SUBSTRING(mf.body, 1, ' . ($modSettings['preview_characters'] + 256) . ') AS first_body,' : '') . 'ml.smileys_enabled AS last_smileys, mf.smileys_enabled AS first_smileys' . (!empty($settings['avatars_on_indexes']) ? ', IFNULL(a.id_attach, 0) AS id_attach, a.filename, a.attachment_type' : '') . ' FROM {db_prefix}topics AS t INNER JOIN {db_prefix}messages AS ml ON (ml.id_msg = t.id_last_msg) INNER JOIN {db_prefix}messages AS mf ON (mf.id_msg = t.id_first_msg) LEFT JOIN {db_prefix}members AS meml ON (meml.id_member = ml.id_member) LEFT JOIN {db_prefix}members AS memf ON (memf.id_member = mf.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 = {int:current_board} AND lmr.id_member = {int:current_member})') . (!empty($settings['avatars_on_indexes']) ? ' LEFT JOIN {db_prefix}attachments AS a ON (a.id_member = ml.id_member)' : '') . ' WHERE ' . ($pre_query ? 't.id_topic IN ({array_int:topic_list})' : 't.id_board = {int:current_board}') . (!$modSettings['postmod_active'] || $context['can_approve_posts'] ? '' : ' AND (t.approved = {int:is_approved}' . ($user_info['is_guest'] ? '' : ' OR t.id_member_started = {int:current_member}') . ')') . ' ORDER BY ' . ($pre_query ? 'FIND_IN_SET(t.id_topic, {string:find_set_topics})' : (!empty($modSettings['enableStickyTopics']) ? 'is_sticky' . ($fake_ascending ? '' : ' DESC') . ', ' : '') . $_REQUEST['sort'] . ($ascending ? '' : ' DESC')) . ' LIMIT ' . ($pre_query ? '' : '{int:start}, ') . '{int:maxindex}', array('current_board' => $board, 'current_member' => $user_info['id'], 'topic_list' => $topic_ids, 'is_approved' => 1, 'find_set_topics' => implode(',', $topic_ids), 'start' => $start, 'maxindex' => $maxindex)); // Begin 'printing' the message index for current board. while ($row = $smcFunc['db_fetch_assoc']($result)) { if ($row['id_poll'] > 0 && $modSettings['pollMode'] == '0') { continue; } if (!$pre_query) { $topic_ids[] = $row['id_topic']; } // Does the theme support message previews? if (!empty($settings['message_index_preview']) && !empty($modSettings['preview_characters'])) { // Limit them to $modSettings['preview_characters'] characters $row['first_body'] = strip_tags(strtr(parse_bbc($row['first_body'], $row['first_smileys'], $row['id_first_msg']), array('<br />' => ' '))); if ($smcFunc['strlen']($row['first_body']) > $modSettings['preview_characters']) { $row['first_body'] = $smcFunc['substr']($row['first_body'], 0, $modSettings['preview_characters']) . '...'; } $row['last_body'] = strip_tags(strtr(parse_bbc($row['last_body'], $row['last_smileys'], $row['id_last_msg']), array('<br />' => ' '))); if ($smcFunc['strlen']($row['last_body']) > $modSettings['preview_characters']) { $row['last_body'] = $smcFunc['substr']($row['last_body'], 0, $modSettings['preview_characters']) . '...'; } // Censor the subject and message preview. censorText($row['first_subject']); censorText($row['first_body']); // Don't censor them twice! if ($row['id_first_msg'] == $row['id_last_msg']) { $row['last_subject'] = $row['first_subject']; $row['last_body'] = $row['first_body']; } else { censorText($row['last_subject']); censorText($row['last_body']); } } else { $row['first_body'] = ''; $row['last_body'] = ''; censorText($row['first_subject']); if ($row['id_first_msg'] == $row['id_last_msg']) { $row['last_subject'] = $row['first_subject']; } else { censorText($row['last_subject']); } } // Decide how many pages the topic should have. if ($row['num_replies'] + 1 > $context['messages_per_page']) { $pages = '« '; // We can't pass start by reference. $start = -1; $pages .= constructPageIndex($scripturl . '?topic=' . $row['id_topic'] . '.%1$d', $start, $row['num_replies'] + 1, $context['messages_per_page'], true, false); // If we can use all, show all. if (!empty($modSettings['enableAllMessages']) && $row['num_replies'] + 1 < $modSettings['enableAllMessages']) { $pages .= ' <a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;all">' . $txt['all'] . '</a>'; } $pages .= ' »'; } else { $pages = ''; } // We need to check the topic icons exist... if (!empty($modSettings['messageIconChecks_enable'])) { if (!isset($context['icon_sources'][$row['first_icon']])) { $context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.png') ? 'images_url' : 'default_images_url'; } if (!isset($context['icon_sources'][$row['last_icon']])) { $context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.png') ? 'images_url' : 'default_images_url'; } } else { if (!isset($context['icon_sources'][$row['first_icon']])) { $context['icon_sources'][$row['first_icon']] = 'images_url'; } if (!isset($context['icon_sources'][$row['last_icon']])) { $context['icon_sources'][$row['last_icon']] = 'images_url'; } } if (!empty($settings['avatars_on_indexes'])) { // Allow themers to show the latest poster's avatar along with the topic if (!empty($row['avatar'])) { if ($modSettings['avatar_action_too_large'] == 'option_html_resize' || $modSettings['avatar_action_too_large'] == 'option_js_resize') { $avatar_width = !empty($modSettings['avatar_max_width_external']) ? ' width="' . $modSettings['avatar_max_width_external'] . '"' : ''; $avatar_height = !empty($modSettings['avatar_max_height_external']) ? ' height="' . $modSettings['avatar_max_height_external'] . '"' : ''; } else { $avatar_width = ''; $avatar_height = ''; } } } // '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['first_member_name'], 'name' => $row['first_display_name'], 'id' => $row['first_id_member'], 'href' => !empty($row['first_id_member']) ? $scripturl . '?action=profile;u=' . $row['first_id_member'] : '', 'link' => !empty($row['first_id_member']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['first_id_member'] . '" title="' . $txt['profile_of'] . ' ' . $row['first_display_name'] . '" class="preview">' . $row['first_display_name'] . '</a>' : $row['first_display_name']), 'time' => timeformat($row['first_poster_time']), 'timestamp' => forum_time(true, $row['first_poster_time']), 'subject' => $row['first_subject'], 'preview' => $row['first_body'], 'icon' => $row['first_icon'], 'icon_url' => $settings[$context['icon_sources'][$row['first_icon']]] . '/post/' . $row['first_icon'] . '.png', 'href' => $scripturl . '?topic=' . (empty($row['id_redirect_topic']) ? $row['id_topic'] : $row['id_redirect_topic']) . '.0', 'link' => '<a href="' . $scripturl . '?topic=' . (empty($row['id_redirect_topic']) ? $row['id_topic'] : $row['id_redirect_topic']) . '.0">' . $row['first_subject'] . '</a>'), 'last_post' => array('id' => $row['id_last_msg'], 'member' => array('username' => $row['last_member_name'], 'name' => $row['last_display_name'], 'id' => $row['last_id_member'], 'href' => !empty($row['last_id_member']) ? $scripturl . '?action=profile;u=' . $row['last_id_member'] : '', 'link' => !empty($row['last_id_member']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['last_id_member'] . '">' . $row['last_display_name'] . '</a>' : $row['last_display_name']), 'time' => timeformat($row['last_poster_time']), 'timestamp' => forum_time(true, $row['last_poster_time']), 'subject' => $row['last_subject'], 'preview' => $row['last_body'], 'icon' => $row['last_icon'], 'icon_url' => $settings[$context['icon_sources'][$row['last_icon']]] . '/post/' . $row['last_icon'] . '.png', 'href' => $scripturl . '?topic=' . (empty($row['id_redirect_topic']) ? $row['id_topic'] : $row['id_redirect_topic']) . ($user_info['is_guest'] ? '.' . (!empty($options['view_newest_first']) ? 0 : (int) ($row['num_replies'] / $context['pageindex_multiplier']) * $context['pageindex_multiplier']) . '#msg' . $row['id_last_msg'] : ($row['num_replies'] == 0 ? '.0' : '.msg' . $row['id_last_msg']) . '#new'), 'link' => '<a href="' . $scripturl . '?topic=' . (empty($row['id_redirect_topic']) ? $row['id_topic'] : $row['id_redirect_topic']) . ($user_info['is_guest'] ? '.' . (!empty($options['view_newest_first']) ? 0 : (int) ($row['num_replies'] / $context['pageindex_multiplier']) * $context['pageindex_multiplier']) . '#msg' . $row['id_last_msg'] : ($row['num_replies'] == 0 ? '.0' : '.msg' . $row['id_last_msg']) . '#new') . '" ' . ($row['num_replies'] == 0 ? '' : 'rel="nofollow"') . '>' . $row['last_subject'] . '</a>'), 'is_sticky' => !empty($modSettings['enableStickyTopics']) && !empty($row['is_sticky']), 'is_locked' => !empty($row['locked']), 'is_poll' => $modSettings['pollMode'] == '1' && $row['id_poll'] > 0, 'is_hot' => $row['num_replies'] >= $modSettings['hotTopicPosts'], 'is_very_hot' => $row['num_replies'] >= $modSettings['hotTopicVeryPosts'], 'is_posted_in' => false, 'icon' => $row['first_icon'], 'icon_url' => $settings[$context['icon_sources'][$row['first_icon']]] . '/post/' . $row['first_icon'] . '.png', 'subject' => $row['first_subject'], 'new' => $row['new_from'] <= $row['id_msg_modified'], 'new_from' => $row['new_from'], 'newtime' => $row['new_from'], 'new_href' => $scripturl . '?topic=' . (empty($row['id_redirect_topic']) ? $row['id_topic'] : $row['id_redirect_topic']) . '.msg' . $row['new_from'] . '#new', 'pages' => $pages, 'replies' => comma_format($row['num_replies']), 'views' => comma_format($row['num_views']), 'approved' => $row['approved'], 'unapproved_posts' => $row['unapproved_posts']); if (!empty($settings['avatars_on_indexes'])) { $context['topics'][$row['id_topic']]['last_post']['member']['avatar'] = array('name' => $row['avatar'], 'image' => $row['avatar'] == '' ? $row['id_attach'] > 0 ? '<img class="avatar" src="' . (empty($row['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $row['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $row['filename']) . '" alt="" />' : '' : (stristr($row['avatar'], 'http://') ? '<img class="avatar" src="' . $row['avatar'] . '"' . $avatar_width . $avatar_height . ' alt="" />' : '<img class="avatar" src="' . $modSettings['avatar_url'] . '/' . htmlspecialchars($row['avatar']) . '" alt="" />'), 'href' => $row['avatar'] == '' ? $row['id_attach'] > 0 ? empty($row['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $row['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $row['filename'] : '' : (stristr($row['avatar'], 'http://') ? $row['avatar'] : $modSettings['avatar_url'] . '/' . $row['avatar']), 'url' => $row['avatar'] == '' ? '' : (stristr($row['avatar'], 'http://') ? $row['avatar'] : $modSettings['avatar_url'] . '/' . $row['avatar'])); } determineTopicClass($context['topics'][$row['id_topic']]); } $smcFunc['db_free_result']($result); // 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 = $smcFunc['db_query']('', ' SELECT id_topic FROM {db_prefix}messages WHERE id_topic IN ({array_int:topic_list}) AND id_member = {int:current_member} GROUP BY id_topic LIMIT ' . count($topic_ids), array('current_member' => $user_info['id'], 'topic_list' => $topic_ids)); while ($row = $smcFunc['db_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']; } $smcFunc['db_free_result']($result); } } $context['jump_to'] = array('label' => addslashes(un_htmlspecialchars($txt['jump_to'])), 'board_name' => htmlspecialchars(strtr(strip_tags($board_info['name']), array('&' => '&'))), 'child_level' => $board_info['child_level']); // Is Quick Moderation active/needed? if (!empty($options['display_quick_mod']) && !empty($context['topics'])) { $context['can_markread'] = $context['user']['is_logged']; $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'); // Ignore approving own topics as it's unlikely to come up... $context['can_approve'] = $modSettings['postmod_active'] && allowedTo('approve_posts') && !empty($board_info['unapproved_topics']); // Can we restore topics? $context['can_restore'] = allowedTo('move_any') && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] == $board; // Set permissions for all the topics. foreach ($context['topics'] as $t => $topic) { $started = $topic['first_post']['member']['id'] == $user_info['id']; $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'), 'approve' => $context['can_approve'] && $topic['unapproved_posts']); $context['can_lock'] |= $started && allowedTo('lock_own'); $context['can_move'] |= $started && allowedTo('move_own'); $context['can_remove'] |= $started && allowedTo('remove_own'); } // Find the boards/cateogories they can move their topic to. if ($options['display_quick_mod'] == 1 && $context['can_move'] && !empty($context['topics'])) { require_once $sourcedir . '/Subs-MessageIndex.php'; $boardListOptions = array('excluded_boards' => array($board), 'not_redirection' => true, 'use_permissions' => true, 'selected_board' => empty($_SESSION['move_to_topic']) ? null : $_SESSION['move_to_topic']); // With no other boards to see, it's useless to move. if (empty($context['move_to_boards'])) { $context['can_move'] = false; } } // Can we use quick moderation checkboxes? if ($options['display_quick_mod'] == 1) { $context['can_quick_mod'] = $context['user']['is_logged'] || $context['can_approve'] || $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move'] || $context['can_merge'] || $context['can_restore']; } else { $context['can_quick_mod'] = $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move']; } } if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1) { $context['qmod_actions'] = array('approve', 'remove', 'lock', 'sticky', 'move', 'merge', 'restore', 'markread'); call_integration_hook('integrate_quick_mod_actions'); } // 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']; // Build the message index button array. $context['normal_buttons'] = array('new_topic' => array('test' => 'can_post_new', 'text' => 'new_topic', 'image' => 'new_topic.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0', 'active' => true), 'post_poll' => array('test' => 'can_post_poll', 'text' => 'new_poll', 'image' => 'new_poll.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0;poll'), 'notify' => array('test' => 'can_mark_notify', 'text' => $context['is_marked_notify'] ? 'unnotify' : 'notify', 'image' => ($context['is_marked_notify'] ? 'un' : '') . 'notify.png', 'lang' => true, 'custom' => 'onclick="return confirm(\'' . ($context['is_marked_notify'] ? $txt['notification_disable_board'] : $txt['notification_enable_board']) . '\');"', 'url' => $scripturl . '?action=notifyboard;sa=' . ($context['is_marked_notify'] ? 'off' : 'on') . ';board=' . $context['current_board'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']), 'markread' => array('text' => 'mark_read_short', 'image' => 'markread.png', 'lang' => true, 'url' => $scripturl . '?action=markasread;sa=board;board=' . $context['current_board'] . '.0;' . $context['session_var'] . '=' . $context['session_id'])); // Allow adding new buttons easily. call_integration_hook('integrate_messageindex_buttons'); }
function loadMemberContext($user) { global $memberContext, $user_profile, $txt, $scripturl, $user_info; global $context, $modSettings, $ID_MEMBER, $board_info, $settings; global $db_prefix, $func; static $dataLoaded = array(); // If this person's data is already loaded, skip it. if (isset($dataLoaded[$user])) { return true; } // We can't load guests or members not loaded by loadMemberData()! if ($user == 0) { return false; } if (!isset($user_profile[$user])) { trigger_error('loadMemberContext(): member id ' . $user . ' not previously loaded by loadMemberData()', E_USER_WARNING); return false; } // Well, it's loaded now anyhow. $dataLoaded[$user] = true; $profile = $user_profile[$user]; // Censor everything. censorText($profile['signature']); censorText($profile['personalText']); censorText($profile['location']); // Set things up to be used before hand. $gendertxt = $profile['gender'] == 2 ? $txt[239] : ($profile['gender'] == 1 ? $txt[238] : ''); $profile['signature'] = str_replace(array("\n", "\r"), array('<br />', ''), $profile['signature']); $profile['signature'] = parse_bbc($profile['signature'], true, 'sig' . $profile['ID_MEMBER']); $profile['is_online'] = (!empty($profile['showOnline']) || allowedTo('moderate_forum')) && $profile['isOnline'] > 0; $profile['stars'] = empty($profile['stars']) ? array('', '') : explode('#', $profile['stars']); // Setup the buddy status here (One whole in_array call saved :P) $profile['buddy'] = in_array($profile['ID_MEMBER'], $user_info['buddies']); $buddy_list = !empty($profile['buddy_list']) ? explode(',', $profile['buddy_list']) : array(); // If we're always html resizing, assume it's too large. if ($modSettings['avatar_action_too_large'] == 'option_html_resize' || $modSettings['avatar_action_too_large'] == 'option_js_resize') { $avatar_width = !empty($modSettings['avatar_max_width_external']) ? ' width="' . $modSettings['avatar_max_width_external'] . '"' : ''; $avatar_height = !empty($modSettings['avatar_max_height_external']) ? ' height="' . $modSettings['avatar_max_height_external'] . '"' : ''; } else { $avatar_width = ''; $avatar_height = ''; } // What a monstrous array... $memberContext[$user] = array('username' => &$profile['memberName'], 'name' => &$profile['realName'], 'id' => &$profile['ID_MEMBER'], 'is_guest' => $profile['ID_MEMBER'] == 0, 'is_buddy' => $profile['buddy'], 'is_reverse_buddy' => in_array($ID_MEMBER, $buddy_list), 'buddies' => $buddy_list, 'title' => !empty($modSettings['titlesEnable']) ? $profile['usertitle'] : '', 'href' => $scripturl . '?action=profile;u=' . $profile['ID_MEMBER'], 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $profile['ID_MEMBER'] . '" title="' . $txt[92] . ' ' . $profile['realName'] . '">' . $profile['realName'] . '</a>', 'email' => &$profile['emailAddress'], 'hide_email' => $profile['emailAddress'] == '' || !empty($modSettings['guest_hideContacts']) && $user_info['is_guest'] || !empty($profile['hideEmail']) && !empty($modSettings['allow_hideEmail']) && !allowedTo('moderate_forum') && $ID_MEMBER != $profile['ID_MEMBER'], 'email_public' => (empty($profile['hideEmail']) || empty($modSettings['allow_hideEmail'])) && (empty($modSettings['guest_hideContacts']) || !$user_info['is_guest']), 'registered' => empty($profile['dateRegistered']) ? $txt[470] : timeformat($profile['dateRegistered']), 'registered_timestamp' => empty($profile['dateRegistered']) ? 0 : forum_time(true, $profile['dateRegistered']), 'blurb' => &$profile['personalText'], 'gender' => array('name' => $gendertxt, 'image' => !empty($profile['gender']) ? '<img src="' . $settings['images_url'] . '/' . ($profile['gender'] == 1 ? 'Male' : 'Female') . '.gif" alt="' . $gendertxt . '" border="0" />' : ''), 'website' => array('title' => &$profile['websiteTitle'], 'url' => &$profile['websiteUrl']), 'birth_date' => empty($profile['birthdate']) || $profile['birthdate'] === '0001-01-01' ? '0000-00-00' : (substr($profile['birthdate'], 0, 4) === '0004' ? '0000' . substr($profile['birthdate'], 4) : $profile['birthdate']), 'signature' => &$profile['signature'], 'location' => &$profile['location'], 'icq' => $profile['ICQ'] != '' && (empty($modSettings['guest_hideContacts']) || !$user_info['is_guest']) ? array('name' => &$profile['ICQ'], 'href' => 'http://www.icq.com/whitepages/about_me.php?uin=' . $profile['ICQ'], 'link' => '<a href="http://www.icq.com/whitepages/about_me.php?uin=' . $profile['ICQ'] . '" target="_blank"><img src="http://status.icq.com/online.gif?img=5&icq=' . $profile['ICQ'] . '" alt="' . $profile['ICQ'] . '" width="18" height="18" border="0" /></a>', 'link_text' => '<a href="http://www.icq.com/whitepages/about_me.php?uin=' . $profile['ICQ'] . '" target="_blank">' . $profile['ICQ'] . '</a>') : array('name' => '', 'add' => '', 'href' => '', 'link' => '', 'link_text' => ''), 'aim' => $profile['AIM'] != '' && (empty($modSettings['guest_hideContacts']) || !$user_info['is_guest']) ? array('name' => &$profile['AIM'], 'href' => 'aim:goim?screenname=' . urlencode(strtr($profile['AIM'], array(' ' => '%20'))) . '&message=' . $txt['aim_default_message'], 'link' => '<a href="aim:goim?screenname=' . urlencode(strtr($profile['AIM'], array(' ' => '%20'))) . '&message=' . $txt['aim_default_message'] . '"><img src="' . $settings['images_url'] . '/aim.gif" alt="' . $profile['AIM'] . '" border="0" /></a>', 'link_text' => '<a href="aim:goim?screenname=' . urlencode(strtr($profile['AIM'], array(' ' => '%20'))) . '&message=' . $txt['aim_default_message'] . '">' . $profile['AIM'] . '</a>') : array('name' => '', 'href' => '', 'link' => '', 'link_text' => ''), 'yim' => $profile['YIM'] != '' && (empty($modSettings['guest_hideContacts']) || !$user_info['is_guest']) ? array('name' => &$profile['YIM'], 'href' => 'http://edit.yahoo.com/config/send_webmesg?.target=' . urlencode($profile['YIM']), 'link' => '<a href="http://edit.yahoo.com/config/send_webmesg?.target=' . urlencode($profile['YIM']) . '"><img src="http://opi.yahoo.com/online?u=' . urlencode($profile['YIM']) . '&m=g&t=0" alt="' . $profile['YIM'] . '" border="0" /></a>', 'link_text' => '<a href="http://edit.yahoo.com/config/send_webmesg?.target=' . urlencode($profile['YIM']) . '">' . $profile['YIM'] . '</a>') : array('name' => '', 'href' => '', 'link' => '', 'link_text' => ''), 'msn' => $profile['MSN'] != '' && (empty($modSettings['guest_hideContacts']) || !$user_info['is_guest']) ? array('name' => &$profile['MSN'], 'href' => 'http://members.msn.com/' . $profile['MSN'], 'link' => '<a href="http://members.msn.com/' . $profile['MSN'] . '" target="_blank"><img src="' . $settings['images_url'] . '/msntalk.gif" alt="' . $profile['MSN'] . '" border="0" /></a>', 'link_text' => '<a href="http://members.msn.com/' . $profile['MSN'] . '" target="_blank">' . $profile['MSN'] . '</a>') : array('name' => '', 'href' => '', 'link' => '', 'link_text' => ''), 'real_posts' => $profile['posts'], 'posts' => $profile['posts'] > 100000 ? $txt[683] : ($profile['posts'] == 1337 ? 'leet' : comma_format($profile['posts'])), 'avatar' => array('name' => &$profile['avatar'], 'image' => $profile['avatar'] == '' ? $profile['ID_ATTACH'] > 0 ? '<img src="' . (empty($profile['attachmentType']) ? $scripturl . '?action=dlattach;attach=' . $profile['ID_ATTACH'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $profile['filename']) . '" alt="" class="avatar" border="0" />' : '' : (stristr($profile['avatar'], 'http://') ? '<img src="' . $profile['avatar'] . '"' . $avatar_width . $avatar_height . ' alt="" class="avatar" border="0" />' : '<img src="' . $modSettings['avatar_url'] . '/' . htmlspecialchars($profile['avatar']) . '" alt="" class="avatar" border="0" />'), 'href' => $profile['avatar'] == '' ? $profile['ID_ATTACH'] > 0 ? empty($profile['attachmentType']) ? $scripturl . '?action=dlattach;attach=' . $profile['ID_ATTACH'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $profile['filename'] : '' : (stristr($profile['avatar'], 'http://') ? $profile['avatar'] : $modSettings['avatar_url'] . '/' . $profile['avatar']), 'url' => $profile['avatar'] == '' ? '' : (stristr($profile['avatar'], 'http://') ? $profile['avatar'] : $modSettings['avatar_url'] . '/' . $profile['avatar'])), 'last_login' => empty($profile['lastLogin']) ? $txt['never'] : timeformat($profile['lastLogin']), 'last_login_timestamp' => empty($profile['lastLogin']) ? 0 : forum_time(0, $profile['lastLogin']), 'karma' => array('good' => &$profile['karmaGood'], 'bad' => &$profile['karmaBad'], 'allow' => !$user_info['is_guest'] && $user_info['posts'] >= $modSettings['karmaMinPosts'] && allowedTo('karma_edit') && !empty($modSettings['karmaMode']) && $ID_MEMBER != $user), 'ip' => htmlspecialchars($profile['memberIP']), 'ip2' => htmlspecialchars($profile['memberIP2']), 'online' => array('is_online' => $profile['is_online'], 'text' => &$txt[$profile['is_online'] ? 'online2' : 'online3'], 'href' => $scripturl . '?action=pm;sa=send;u=' . $profile['ID_MEMBER'], 'link' => '<a href="' . $scripturl . '?action=pm;sa=send;u=' . $profile['ID_MEMBER'] . '">' . $txt[$profile['is_online'] ? 'online2' : 'online3'] . '</a>', 'image_href' => $settings['images_url'] . '/' . ($profile['buddy'] ? 'buddy_' : '') . ($profile['is_online'] ? 'useron' : 'useroff') . '.gif', 'label' => &$txt[$profile['is_online'] ? 'online4' : 'online5']), 'language' => $func['ucwords'](strtr($profile['lngfile'], array('_' => ' ', '-utf8' => ''))), 'is_activated' => isset($profile['is_activated']) ? $profile['is_activated'] : 1, 'is_banned' => isset($profile['is_activated']) ? $profile['is_activated'] >= 10 : 0, 'options' => $profile['options'], 'is_guest' => false, 'group' => $profile['member_group'], 'group_color' => $profile['member_group_color'], 'group_id' => $profile['ID_GROUP'], 'post_group' => $profile['post_group'], 'post_group_color' => $profile['post_group_color'], 'group_stars' => str_repeat('<img src="' . str_replace('$language', $context['user']['language'], isset($profile['stars'][1]) ? $settings['images_url'] . '/' . $profile['stars'][1] : '') . '" alt="*" border="0" />', empty($profile['stars'][0]) || empty($profile['stars'][1]) ? 0 : $profile['stars'][0]), 'local_time' => timeformat(time() + ($profile['timeOffset'] - $user_info['time_offset']) * 3600, false)); return true; }
/** * @param $memID int id_member * * fetch all likes received by the given user and display them * part of the profile -> show content area. */ function LikesByUser($memID) { global $context, $user_info, $scripturl, $memberContext, $txt, $modSettings, $options; if ($memID != $user_info['id']) { isAllowedTo('can_view_ratings'); } // let us use the same value as for topics per page here. $perpage = empty($modSettings['disableCustomPerPage']) && !empty($options['topics_per_page']) ? $options['topics_per_page'] : $modSettings['defaultMaxTopics']; $out = $_GET['sa'] === 'likesout'; // display likes *given* instead of received ones $is_owner = $user_info['id'] == $memID; // we are the owner of this profile, this is important for proper formatting (you/yours etc.) $boards_like_see = boardsAllowedTo('like_see'); // respect permissions $start = isset($_REQUEST['start']) ? (int) $_REQUEST['start'] : 0; if (!($user_info['is_admin'] || allowedTo('moderate_forum'))) { // admins and global mods can see everything $bq = ' AND b.id_board IN({array_int:boards})'; } else { $bq = ''; } $q = $out ? 'l.id_user = {int:id_user}' : 'l.id_receiver = {int:id_user}'; $request = smf_db_query('SELECT count(l.id_msg) FROM {db_prefix}likes AS l INNER JOIN {db_prefix}messages AS m ON (m.id_msg = l.id_msg) 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) WHERE ' . $q . ' AND {query_see_board}' . $bq, array('id_user' => $memID, 'boards' => $boards_like_see)); list($context['total_likes']) = mysql_fetch_row($request); mysql_free_result($request); $request = smf_db_query('SELECT m.subject, m.id_topic, l.id_user, l.id_receiver, l.updated, l.id_msg, l.rtype, mfirst.subject AS first_subject, SUBSTRING(m.body, 1, 150) AS body FROM {db_prefix}likes AS l INNER JOIN {db_prefix}messages AS m ON (m.id_msg = l.id_msg) INNER JOIN {db_prefix}topics AS t ON (t.id_topic = m.id_topic) INNER JOIN {db_prefix}messages AS mfirst ON (mfirst.id_msg = t.id_first_msg) INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board) WHERE ' . $q . ' AND {query_see_board} ' . $bq . ' ORDER BY l.id_like DESC LIMIT {int:startwith}, {int:perpage}', array('id_user' => $memID, 'startwith' => $start, 'perpage' => $perpage, 'boards' => $boards_like_see)); $context['results_count'] = 0; $context['likes'] = array(); $context['displaymode'] = $out ? true : false; $context['pages'] = ''; if ($context['total_likes'] > $perpage) { $context['pages'] = constructPageIndex($scripturl . '?action=profile;area=showposts;sa=' . $_GET['sa'] . ';u=' . trim($memID), $start, $context['total_likes'], $perpage); } $users = array(); while ($row = mysql_fetch_assoc($request)) { $context['results_count']++; $thref = URL::topic($row['id_topic'], $row['first_subject'], 0); $phref = URL::topic($row['id_topic'], $row['subject'], 0, false, '.msg' . $row['id_msg'], '#msg' . $row['id_msg']); $users[] = $out ? $row['id_receiver'] : $row['id_user']; $context['likes'][] = array('id_user' => $out ? $row['id_receiver'] : $row['id_user'], 'time' => timeformat($row['updated']), 'topic' => array('href' => $thref, 'link' => '<a href="' . $thref . '">' . $row['first_subject'] . '</a>', 'subject' => $row['first_subject']), 'post' => array('href' => $phref, 'link' => '<a href="' . $phref . '">' . $row['subject'] . '</a>', 'subject' => $row['subject'], 'id' => $row['id_msg']), 'rtype' => $row['rtype'], 'teaser' => strip_tags(preg_replace('~[[\\/\\!]*?[^\\[\\]]*?]~si', '', $row['body'])) . '...', 'morelink' => URL::parse('?msg=' . $row['id_msg'] . ';perma')); } loadMemberData(array_unique($users)); foreach ($context['likes'] as &$like) { loadMemberContext($like['id_user']); $like['member'] =& $memberContext[$like['id_user']]; $like['text'] = $out ? $is_owner ? sprintf($txt['liked_a_post'], $is_owner ? $txt['you_liker'] : $memberContext[$memID]['name'], $memberContext[$like['id_user']]['link'], $like['post']['href'], $like['topic']['link'], $modSettings['ratings'][$like['rtype']]['text']) : sprintf($txt['liked_a_post'], $is_owner ? $txt['you_liker'] : $memberContext[$memID]['name'], $memberContext[$like['id_user']]['link'], $like['post']['href'], $like['topic']['link'], $modSettings['ratings'][$like['rtype']]['text']) : ($is_owner ? sprintf($txt['liked_your_post'], $like['id_user'] == $user_info['id'] ? $txt['you_liker'] : $like['member']['link'], $like['post']['href'], $like['topic']['link'], $modSettings['ratings'][$like['rtype']]['text']) : sprintf($txt['liked_a_post'], $like['id_user'] == $user_info['id'] ? $txt['you_liker'] : $like['member']['link'], $memberContext[$memID]['name'], $like['post']['href'], $like['topic']['link'], $modSettings['ratings'][$like['rtype']]['text'])); } mysql_free_result($request); EoS_Smarty::getConfigInstance()->registerHookTemplate('profile_content_area', 'ratings/profile_display'); }
function prepareDisplayContext($reset = false) { global $settings, $txt, $modSettings, $scripturl, $options, $user_info, $smcFunc; global $memberContext, $context, $messages_request, $topic, $attachments, $topicinfo; static $counter = null; // If the query returned false, bail. if ($messages_request == false) { return false; } // Remember which message this is. (ie. reply #83) if ($counter === null || $reset) { $counter = empty($options['view_newest_first']) ? $context['start'] : $context['total_visible_posts'] - $context['start']; } // Start from the beginning... if ($reset) { return @$smcFunc['db_data_seek']($messages_request, 0); } // Attempt to get the next message. $message = $smcFunc['db_fetch_assoc']($messages_request); if (!$message) { $smcFunc['db_free_result']($messages_request); return false; } // $context['icon_sources'] says where each icon should come from - here we set up the ones which will always exist! if (empty($context['icon_sources'])) { $stable_icons = array('xx', 'thumbup', 'thumbdown', 'exclamation', 'question', 'lamp', 'smiley', 'angry', 'cheesy', 'grin', 'sad', 'wink', 'moved', 'recycled', 'wireless', 'clip'); $context['icon_sources'] = array(); foreach ($stable_icons as $icon) { $context['icon_sources'][$icon] = 'images_url'; } } // Message Icon Management... check the images exist. if (empty($modSettings['messageIconChecks_disable'])) { // If the current icon isn't known, then we need to do something... if (!isset($context['icon_sources'][$message['icon']])) { $context['icon_sources'][$message['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['icon'] . '.gif') ? 'images_url' : 'default_images_url'; } } elseif (!isset($context['icon_sources'][$message['icon']])) { $context['icon_sources'][$message['icon']] = 'images_url'; } // If you're a lazy bum, you probably didn't give a subject... $message['subject'] = $message['subject'] != '' ? $message['subject'] : $txt['no_subject']; // Are you allowed to remove at least a single reply? $context['can_remove_post'] |= allowedTo('delete_own') && (empty($modSettings['edit_disable_time']) || max($message['modified_time'], $message['poster_time']) + $modSettings['edit_disable_time'] * 60 >= time()) && $message['id_member'] == $user_info['id']; // If it couldn't load, or the user was a guest.... someday may be done with a guest table. if (!loadMemberContext($message['id_member'], true)) { // Notice this information isn't used anywhere else.... $memberContext[$message['id_member']]['name'] = $message['poster_name']; $memberContext[$message['id_member']]['id'] = 0; $memberContext[$message['id_member']]['group'] = $txt['guest_title']; $memberContext[$message['id_member']]['link'] = $message['poster_name']; $memberContext[$message['id_member']]['email'] = $message['poster_email']; $memberContext[$message['id_member']]['show_email'] = showEmailAddress(true, 0); $memberContext[$message['id_member']]['is_guest'] = true; } else { $memberContext[$message['id_member']]['can_view_profile'] = allowedTo('profile_view_any') || $message['id_member'] == $user_info['id'] && allowedTo('profile_view_own'); $memberContext[$message['id_member']]['is_topic_starter'] = $message['id_member'] == $context['topic_starter_id']; $memberContext[$message['id_member']]['can_see_warning'] = !isset($context['disabled_fields']['warning_status']) && $memberContext[$message['id_member']]['warning_status'] && ($context['user']['can_mod'] || !$user_info['is_guest'] && !empty($modSettings['warning_show']) && ($modSettings['warning_show'] > 1 || $message['id_member'] == $user_info['id'])); } $memberContext[$message['id_member']]['ip'] = $message['poster_ip']; // Do the censor thang. censorText($message['body']); censorText($message['subject']); // Run BBC interpreter on the message. $message['body'] = parse_bbc($message['body'], $message['smileys_enabled'], $message['id_msg']); // Compose the memory eat- I mean message array. $output = array('attachment' => loadAttachmentContext($message['id_msg']), 'alternate' => $counter % 2, 'id' => $message['id_msg'], 'href' => $scripturl . '?topic=' . $topic . '.msg' . $message['id_msg'] . '#msg' . $message['id_msg'], 'link' => '<a href="' . $scripturl . '?topic=' . $topic . '.msg' . $message['id_msg'] . '#msg' . $message['id_msg'] . '" rel="nofollow">' . $message['subject'] . '</a>', 'member' => &$memberContext[$message['id_member']], 'icon' => $message['icon'], 'icon_url' => $settings[$context['icon_sources'][$message['icon']]] . '/post/' . $message['icon'] . '.gif', 'subject' => $message['subject'], 'time' => timeformat($message['poster_time']), 'timestamp' => forum_time(true, $message['poster_time']), 'counter' => $counter, 'modified' => array('time' => timeformat($message['modified_time']), 'timestamp' => forum_time(true, $message['modified_time']), 'name' => $message['modified_name']), 'body' => $message['body'], 'new' => empty($message['is_read']), 'approved' => $message['approved'], 'first_new' => isset($context['start_from']) && $context['start_from'] == $counter, 'is_ignored' => !empty($modSettings['enable_buddylist']) && !empty($options['posts_apply_ignore_list']) && in_array($message['id_member'], $context['user']['ignoreusers']), 'can_approve' => !$message['approved'] && $context['can_approve'], 'can_unapprove' => $message['approved'] && $context['can_approve'], 'can_modify' => (!$context['is_locked'] || allowedTo('moderate_board')) && (allowedTo('modify_any') || allowedTo('modify_replies') && $context['user']['started'] || allowedTo('modify_own') && $message['id_member'] == $user_info['id'] && (empty($modSettings['edit_disable_time']) || !$message['approved'] || max($message['modified_time'], $message['poster_time']) + $modSettings['edit_disable_time'] * 60 > time())), 'can_remove' => allowedTo('delete_any') || allowedTo('delete_replies') && $context['user']['started'] || allowedTo('delete_own') && $message['id_member'] == $user_info['id'] && (empty($modSettings['edit_disable_time']) || max($message['modified_time'], $message['poster_time']) + $modSettings['edit_disable_time'] * 60 > time()), 'can_see_ip' => allowedTo('moderate_forum') || $message['id_member'] == $user_info['id'] && !empty($user_info['id'])); // Is this user the message author? $output['is_message_author'] = $message['id_member'] == $user_info['id']; if (empty($options['view_newest_first'])) { $counter++; } else { $counter--; } return $output; }
function loadMemberContext($user, $display_custom_fields = false) { global $memberContext, $user_profile, $txt, $scripturl, $user_info; global $context, $modSettings, $settings; static $dataLoaded = array(); // If this person's data is already loaded, skip it. if (isset($dataLoaded[$user])) { return true; } // We can't load guests or members not loaded by loadMemberData()! if ($user == 0) { return false; } if (!isset($user_profile[$user])) { trigger_error('loadMemberContext(): member id ' . $user . ' not previously loaded by loadMemberData()', E_USER_WARNING); return false; } // Well, it's loaded now anyhow. $dataLoaded[$user] = true; $profile = $user_profile[$user]; // Censor everything. censorText($profile['signature']); censorText($profile['personal_text']); censorText($profile['location']); // Set things up to be used before hand. $gendertxt = $profile['gender'] == 2 ? $txt['female'] : ($profile['gender'] == 1 ? $txt['male'] : ''); $profile['signature'] = str_replace(array("\n", "\r"), array('<br />', ''), $profile['signature']); $profile['signature'] = parse_bbc($profile['signature'], true, 'sig' . $profile['id_member']); $profile['is_online'] = (!empty($profile['show_online']) || allowedTo('moderate_forum')) && $profile['is_online'] > 0; $profile['stars'] = empty($profile['stars']) ? array('', '') : explode('#', $profile['stars']); // Setup the buddy status here (One whole in_array call saved :P) $profile['buddy'] = in_array($profile['id_member'], $user_info['buddies']); $buddy_list = !empty($profile['buddy_list']) ? explode(',', $profile['buddy_list']) : array(); // If we're always html resizing, assume it's too large. if ($modSettings['avatar_action_too_large'] == 'option_html_resize' || $modSettings['avatar_action_too_large'] == 'option_js_resize') { $avatar_width = !empty($modSettings['avatar_max_width_external']) ? ' width="' . $modSettings['avatar_max_width_external'] . '"' : ''; $avatar_height = !empty($modSettings['avatar_max_height_external']) ? ' height="' . $modSettings['avatar_max_height_external'] . '"' : ''; } else { $avatar_width = ''; $avatar_height = ''; } $m_href = URL::user($profile['id_member'], $profile['real_name']); // What a monstrous array... $memberContext[$user] = array('username' => $profile['member_name'], 'name' => $profile['real_name'], 'id' => $profile['id_member'], 'is_buddy' => $profile['buddy'], 'is_reverse_buddy' => in_array($user_info['id'], $buddy_list), 'buddies' => $buddy_list, 'title' => !empty($modSettings['titlesEnable']) ? $profile['usertitle'] : '', 'href' => $m_href, 'link' => '<a class="member group_' . (empty($profile['id_group']) ? $profile['id_post_group'] : $profile['id_group']) . '" onclick="getMcard(' . $profile['id_member'] . ');return(false);" href="' . $m_href . '" title="' . $txt['profile_of'] . ' ' . $profile['real_name'] . '">' . $profile['real_name'] . '</a>', 'email' => $profile['email_address'], 'show_email' => showEmailAddress(!empty($profile['hide_email']), $profile['id_member']), 'registered' => empty($profile['date_registered']) ? $txt['not_applicable'] : timeformat($profile['date_registered']), 'blurb' => $profile['personal_text'], 'gender' => array('name' => $gendertxt, 'image' => !empty($profile['gender']) ? '<img class="gender" src="' . $settings['images_url'] . '/' . ($profile['gender'] == 1 ? 'Male' : 'Female') . '.gif" alt="' . $gendertxt . '" />' : ''), 'birth_date' => empty($profile['birthdate']) || $profile['birthdate'] === '0001-01-01' ? '0000-00-00' : (substr($profile['birthdate'], 0, 4) === '0004' ? '0000' . substr($profile['birthdate'], 4) : $profile['birthdate']), 'signature' => $profile['signature'], 'location' => $profile['location'], 'real_posts' => $profile['posts'], 'posts' => comma_format($profile['posts']), 'avatar' => array('name' => $profile['avatar'], 'image' => $profile['avatar'] == '' ? $profile['id_attach'] > 0 ? '<img class="avatar" src="' . (empty($profile['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $profile['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $profile['filename']) . '" alt="" />' : '' : (stristr($profile['avatar'], 'http://') ? '<img class="avatar" src="' . $profile['avatar'] . '"' . $avatar_width . $avatar_height . ' alt="" />' : '<img class="avatar" src="' . $modSettings['avatar_url'] . '/' . htmlspecialchars($profile['avatar']) . '" alt="" />'), 'href' => $profile['avatar'] == '' ? $profile['id_attach'] > 0 ? empty($profile['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $profile['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $profile['filename'] : '' : (stristr($profile['avatar'], 'http://') ? $profile['avatar'] : $modSettings['avatar_url'] . '/' . $profile['avatar']), 'url' => $profile['avatar'] == '' ? '' : (stristr($profile['avatar'], 'http://') ? $profile['avatar'] : $modSettings['avatar_url'] . '/' . $profile['avatar'])), 'last_login' => empty($profile['last_login']) ? $txt['never'] : !empty($profile['show_online']) || allowedTo('moderate_forum') ? timeformat($profile['last_login']) : $txt['hidden'], 'ip' => htmlspecialchars($profile['member_ip']), 'ip2' => htmlspecialchars($profile['member_ip2']), 'online' => array('is_online' => $profile['is_online'], 'text' => $txt[$profile['is_online'] ? 'online' : 'offline'], 'href' => $scripturl . '?action=pm;sa=send;u=' . $profile['id_member'], 'link' => '<a href="' . $scripturl . '?action=pm;sa=send;u=' . $profile['id_member'] . '">' . $txt[$profile['is_online'] ? 'online' : 'offline'] . '</a>', 'image_href' => $settings['images_url'] . '/' . ($profile['buddy'] ? 'buddy_' : '') . ($profile['is_online'] ? 'useron' : 'useroff') . '.gif', 'label' => $txt[$profile['is_online'] ? 'online' : 'offline']), 'language' => commonAPI::ucwords(strtr($profile['lngfile'], array('_' => ' ', '-utf8' => ''))), 'is_activated' => isset($profile['is_activated']) ? $profile['is_activated'] : 1, 'is_banned' => isset($profile['is_activated']) ? $profile['is_activated'] >= 10 : 0, 'options' => $profile['options'], 'is_guest' => false, 'group' => $profile['member_group'], 'group_id' => $profile['id_group'], 'post_group_id' => $profile['id_post_group'], 'post_group' => $profile['post_group'], 'group_stars' => str_repeat('<img src="' . str_replace('$language', $context['user']['language'], isset($profile['stars'][1]) ? $settings['images_url'] . '/' . $profile['stars'][1] : '') . '" alt="*" />', empty($profile['stars'][0]) || empty($profile['stars'][1]) ? 0 : $profile['stars'][0]), 'warning' => $profile['warning'], 'warning_status' => !empty($modSettings['warning_mute']) && $modSettings['warning_mute'] <= $profile['warning'] ? 'mute' : (!empty($modSettings['warning_moderate']) && $modSettings['warning_moderate'] <= $profile['warning'] ? 'moderate' : (!empty($modSettings['warning_watch']) && $modSettings['warning_watch'] <= $profile['warning'] ? 'watch' : '')), 'local_time' => timeformat_static(time() + ($profile['time_offset'] - $user_info['time_offset']) * 3600, false), 'liked' => isset($profile['liked']) ? $profile['liked'] : 0, 'likesgiven' => isset($profile['likesgiven']) ? $profile['likesgiven'] : 0, 'notify_optout' => isset($profile['notify_optout']) ? $profile['notify_optout'] : ''); if ($memberContext[$user]['avatar']['name'] == 'gravatar') { $hash = md5(strtolower(trim($memberContext[$user]['email']))); $memberContext[$user]['avatar']['image'] = '<img class="avatar" alt="avatar" src="http://www.gravatar.com/avatar/' . $hash . '" />'; $memberContext[$user]['avatar']['href'] = 'http://www.gravatar.com/avatar/' . $hash; $memberContext[$user]['avatar']['url'] = $memberContext[$user]['avatar']['href']; } // First do a quick run through to make sure there is something to be shown. $memberContext[$user]['has_messenger'] = false; // Are we also loading the members custom fields into context? if ($display_custom_fields && !empty($modSettings['displayFields'])) { $memberContext[$user]['custom_fields'] = array(); if (!isset($context['display_fields'])) { $context['display_fields'] = unserialize($modSettings['displayFields']); } foreach ($context['display_fields'] as $custom) { if (empty($custom['title']) || empty($profile['options'][$custom['colname']])) { continue; } $value = $profile['options'][$custom['colname']]; // BBC? if ($custom['bbc']) { $value = parse_bbc($value); } elseif (isset($custom['type']) && $custom['type'] == 'check') { $value = $value ? $txt['yes'] : $txt['no']; } // Enclosing the user input within some other text? if (!empty($custom['enclose'])) { $value = strtr($custom['enclose'], array('{SCRIPTURL}' => $scripturl, '{IMAGES_URL}' => $settings['images_url'], '{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], '{INPUT}' => $value)); } $memberContext[$user]['custom_fields'][] = array('title' => $custom['title'], 'colname' => $custom['colname'], 'value' => $value, 'placement' => !empty($custom['placement']) ? $custom['placement'] : 0); } } HookAPI::callHook('integrate_loadmembercontext', array(&$memberContext[$user], &$profile)); return true; }
function Who() { global $db_prefix, $context, $scripturl, $user_info, $txt, $modSettings, $ID_MEMBER, $memberContext; // Permissions, permissions, permissions. isAllowedTo('who_view'); // You can't do anything if this is off. if (empty($modSettings['who_enabled'])) { fatal_lang_error('who_off', false); } // Load the 'Who' template. loadTemplate('Who'); // Sort out... the column sorting. $sort_methods = array('user' => 'mem.realName', 'time' => 'lo.logTime'); // By default order by last time online. if (!isset($_REQUEST['sort']) || !isset($sort_methods[$_REQUEST['sort']])) { $context['sort_by'] = 'time'; $_REQUEST['sort'] = 'lo.logTime'; } else { $context['sort_by'] = $_REQUEST['sort']; $_REQUEST['sort'] = $sort_methods[$_REQUEST['sort']]; } $context['sort_direction'] = isset($_REQUEST['asc']) ? 'up' : 'down'; // Get the total amount of members online. $request = db_query("\n\t\tSELECT COUNT(*)\n\t\tFROM {$db_prefix}log_online AS lo\n\t\t\tLEFT JOIN {$db_prefix}members AS mem ON (lo.ID_MEMBER = mem.ID_MEMBER)" . (!allowedTo('moderate_forum') ? "\n\t\tWHERE IFNULL(mem.showOnline, 1) = 1" : ''), __FILE__, __LINE__); list($totalMembers) = mysql_fetch_row($request); mysql_free_result($request); // Prepare some page index variables. $context['page_index'] = constructPageIndex($scripturl . '?action=who;sort=' . $context['sort_by'] . (isset($_REQUEST['asc']) ? ';asc' : ''), $_REQUEST['start'], $totalMembers, $modSettings['defaultMaxMembers']); $context['start'] = $_REQUEST['start']; // Look for people online, provided they don't mind if you see they are. $request = db_query("\n\t\tSELECT\n\t\t\t(UNIX_TIMESTAMP(lo.logTime) - UNIX_TIMESTAMP() + " . time() . ") AS logTime,\n\t\t\tlo.ID_MEMBER, lo.url, INET_NTOA(lo.ip) AS ip, mem.realName, lo.session,\n\t\t\tmg.onlineColor, IFNULL(mem.showOnline, 1) AS showOnline\n\t\tFROM {$db_prefix}log_online AS lo\n\t\t\tLEFT JOIN {$db_prefix}members AS mem ON (lo.ID_MEMBER = mem.ID_MEMBER)\n\t\t\tLEFT JOIN {$db_prefix}membergroups AS mg ON (mg.ID_GROUP = IF(mem.ID_GROUP = 0, mem.ID_POST_GROUP, mem.ID_GROUP))" . (!allowedTo('moderate_forum') ? "\n\t\tWHERE IFNULL(mem.showOnline, 1) = 1" : '') . "\n\t\tORDER BY {$_REQUEST['sort']} " . (isset($_REQUEST['asc']) ? 'ASC' : 'DESC') . "\n\t\tLIMIT {$context['start']}, {$modSettings['defaultMaxMembers']}", __FILE__, __LINE__); $context['members'] = array(); $member_ids = array(); $url_data = array(); while ($row = mysql_fetch_assoc($request)) { $actions = @unserialize($row['url']); if ($actions === false) { continue; } // Send the information to the template. $context['members'][$row['session']] = array('id' => $row['ID_MEMBER'], 'ip' => allowedTo('moderate_forum') ? $row['ip'] : '', 'time' => strtr(timeformat($row['logTime']), array($txt['smf10'] => '', $txt['smf10b'] => '')), 'timestamp' => forum_time(true, $row['logTime']), 'query' => $actions, 'is_hidden' => $row['showOnline'] == 0, 'color' => empty($row['onlineColor']) ? '' : $row['onlineColor']); $url_data[$row['session']] = array($row['url'], $row['ID_MEMBER']); $member_ids[] = $row['ID_MEMBER']; } mysql_free_result($request); // Load the user data for these members. loadMemberData($member_ids); // Load up the guest user. $memberContext[0] = array('id' => 0, 'name' => $txt[28], 'group' => $txt[28], 'href' => '', 'link' => $txt[28], 'email' => $txt[28], 'is_guest' => true); $url_data = determineActions($url_data); // Setup the linktree and page title (do it down here because the language files are now loaded..) $context['page_title'] = $txt['who_title']; $context['linktree'][] = array('url' => $scripturl . '?action=who', 'name' => $txt['who_title']); // Put it in the context variables. foreach ($context['members'] as $i => $member) { if ($member['id'] != 0) { $member['id'] = loadMemberContext($member['id']) ? $member['id'] : 0; } // Keep the IP that came from the database. $memberContext[$member['id']]['ip'] = $member['ip']; $context['members'][$i]['action'] = isset($url_data[$i]) ? $url_data[$i] : $txt['who_hidden']; $context['members'][$i] += $memberContext[$member['id']]; } // Some people can't send personal messages... $context['can_send_pm'] = allowedTo('pm_send'); }
function createList($listOptions) { global $context, $settings, $options, $txt, $modSettings, $scripturl; assert(isset($listOptions['id'])); assert(isset($listOptions['columns'])); assert(is_array($listOptions['columns'])); assert(empty($listOptions['items_per_page']) || isset($listOptions['get_count']['function'], $listOptions['base_href']) && is_numeric($listOptions['items_per_page'])); assert(empty($listOptions['default_sort_col']) || isset($listOptions['columns'][$listOptions['default_sort_col']])); assert(!isset($listOptions['form']) || isset($listOptions['form']['href'])); // All the context data will be easily accessible by using a reference. $context[$listOptions['id']] = array(); $list_context =& $context[$listOptions['id']]; // Figure out the sort. if (empty($listOptions['default_sort_col'])) { $list_context['sort'] = array(); $sort = '1=1'; } else { $request_var_sort = isset($listOptions['request_vars']['sort']) ? $listOptions['request_vars']['sort'] : 'sort'; $request_var_desc = isset($listOptions['request_vars']['desc']) ? $listOptions['request_vars']['desc'] : 'desc'; if (isset($_REQUEST[$request_var_sort], $listOptions['columns'][$_REQUEST[$request_var_sort]], $listOptions['columns'][$_REQUEST[$request_var_sort]]['sort'])) { $list_context['sort'] = array('id' => $_REQUEST[$request_var_sort], 'desc' => isset($_REQUEST[$request_var_desc]) && isset($listOptions['columns'][$_REQUEST[$request_var_sort]]['sort']['reverse'])); } else { $list_context['sort'] = array('id' => $listOptions['default_sort_col'], 'desc' => !empty($listOptions['default_sort_dir']) && $listOptions['default_sort_dir'] == 'desc' || !empty($listOptions['columns'][$listOptions['default_sort_col']]['sort']['default']) && substr($listOptions['columns'][$listOptions['default_sort_col']]['sort']['default'], -4, 4) == 'desc' ? true : false); } // Set the database column sort. $sort = $listOptions['columns'][$list_context['sort']['id']]['sort'][$list_context['sort']['desc'] ? 'reverse' : 'default']; } $list_context['start_var_name'] = isset($listOptions['start_var_name']) ? $listOptions['start_var_name'] : 'start'; // In some cases the full list must be shown, regardless of the amount of items. if (empty($listOptions['items_per_page'])) { $list_context['start'] = 0; $list_context['items_per_page'] = 0; } else { // First get an impression of how many items to expect. if (isset($listOptions['get_count']['file'])) { require_once $listOptions['get_count']['file']; } $list_context['total_num_items'] = call_user_func_array($listOptions['get_count']['function'], empty($listOptions['get_count']['params']) ? array() : $listOptions['get_count']['params']); // Default the start to the beginning...sounds logical. $list_context['start'] = isset($_REQUEST[$list_context['start_var_name']]) ? (int) $_REQUEST[$list_context['start_var_name']] : 0; $list_context['items_per_page'] = $listOptions['items_per_page']; // Then create a page index. $list_context['page_index'] = constructPageIndex($listOptions['base_href'] . (empty($list_context['sort']) ? '' : ';' . $request_var_sort . '=' . $list_context['sort']['id'] . ($list_context['sort']['desc'] ? ';' . $request_var_desc : '')) . ($list_context['start_var_name'] != 'start' ? ';' . $list_context['start_var_name'] . '=%1$d' : ''), $list_context['start'], $list_context['total_num_items'], $list_context['items_per_page'], $list_context['start_var_name'] != 'start'); } // Prepare the headers of the table. $list_context['headers'] = array(); foreach ($listOptions['columns'] as $column_id => $column) { $list_context['headers'][] = array('id' => $column_id, 'label' => isset($column['header']['eval']) ? eval($column['header']['eval']) : (isset($column['header']['value']) ? $column['header']['value'] : ''), 'href' => empty($listOptions['default_sort_col']) || empty($column['sort']) ? '' : $listOptions['base_href'] . ';' . $request_var_sort . '=' . $column_id . ($column_id === $list_context['sort']['id'] && !$list_context['sort']['desc'] && isset($column['sort']['reverse']) ? ';' . $request_var_desc : '') . (empty($list_context['start']) ? '' : ';' . $list_context['start_var_name'] . '=' . $list_context['start']), 'sort_image' => empty($listOptions['default_sort_col']) || empty($column['sort']) || $column_id !== $list_context['sort']['id'] ? null : ($list_context['sort']['desc'] ? 'down' : 'up'), 'class' => isset($column['header']['class']) ? $column['header']['class'] : '', 'style' => isset($column['header']['style']) ? $column['header']['style'] : '', 'colspan' => isset($column['header']['colspan']) ? $column['header']['colspan'] : ''); } // We know the amount of columns, might be useful for the template. $list_context['num_columns'] = count($listOptions['columns']); $list_context['width'] = isset($listOptions['width']) ? $listOptions['width'] : '0'; // Get the file with the function for the item list. if (isset($listOptions['get_items']['file'])) { require_once $listOptions['get_items']['file']; } // Call the function and include which items we want and in what order. $list_items = call_user_func_array($listOptions['get_items']['function'], array_merge(array($list_context['start'], $list_context['items_per_page'], $sort), empty($listOptions['get_items']['params']) ? array() : $listOptions['get_items']['params'])); // Loop through the list items to be shown and construct the data values. $list_context['rows'] = array(); foreach ($list_items as $item_id => $list_item) { $cur_row = array(); foreach ($listOptions['columns'] as $column_id => $column) { $cur_data = array(); // A value straight from the database? if (isset($column['data']['db'])) { $cur_data['value'] = $list_item[$column['data']['db']]; } elseif (isset($column['data']['db_htmlsafe'])) { $cur_data['value'] = htmlspecialchars($list_item[$column['data']['db_htmlsafe']]); } elseif (isset($column['data']['sprintf'])) { $params = array(); foreach ($column['data']['sprintf']['params'] as $sprintf_param => $htmlsafe) { $params[] = $htmlsafe ? htmlspecialchars($list_item[$sprintf_param]) : $list_item[$sprintf_param]; } $cur_data['value'] = vsprintf($column['data']['sprintf']['format'], $params); } elseif (isset($column['data']['function'])) { $cur_data['value'] = $column['data']['function']($list_item); } elseif (isset($column['data']['eval'])) { $cur_data['value'] = eval(preg_replace('~%([a-zA-Z0-9\\-_]+)%~', '$list_item[\'$1\']', $column['data']['eval'])); } elseif (isset($column['data']['value'])) { $cur_data['value'] = $column['data']['value']; } else { $cur_data['value'] = ''; } // Allow for basic formatting. if (!empty($column['data']['comma_format'])) { $cur_data['value'] = comma_format($cur_data['value']); } elseif (!empty($column['data']['timeformat'])) { $cur_data['value'] = timeformat($cur_data['value']); } // Set a style class for this column? if (isset($column['data']['class'])) { $cur_data['class'] = $column['data']['class']; } // Fully customized styling for the cells in this column only. if (isset($column['data']['style'])) { $cur_data['style'] = $column['data']['style']; } // Add the data cell properties to the current row. $cur_row[$column_id] = $cur_data; } // Insert the row into the list. $list_context['rows'][$item_id] = $cur_row; } // The title is currently optional. if (isset($listOptions['title'])) { $list_context['title'] = $listOptions['title']; } // In case there's a form, share it with the template context. if (isset($listOptions['form'])) { $list_context['form'] = $listOptions['form']; if (!isset($list_context['form']['hidden_fields'])) { $list_context['form']['hidden_fields'] = array(); } // Always add a session check field. $list_context['form']['hidden_fields'][$context['session_var']] = $context['session_id']; // Include the starting page as hidden field? if (!empty($list_context['form']['include_start']) && !empty($list_context['start'])) { $list_context['form']['hidden_fields'][$list_context['start_var_name']] = $list_context['start']; } // If sorting needs to be the same after submitting, add the parameter. if (!empty($list_context['form']['include_sort']) && !empty($list_context['sort'])) { $list_context['form']['hidden_fields']['sort'] = $list_context['sort']['id']; if ($list_context['sort']['desc']) { $list_context['form']['hidden_fields']['desc'] = 1; } } } // Wanna say something nice in case there are no items? if (isset($listOptions['no_items_label'])) { $list_context['no_items_label'] = $listOptions['no_items_label']; $list_context['no_items_align'] = isset($listOptions['no_items_align']) ? $listOptions['no_items_align'] : ''; } // A list can sometimes need a few extra rows above and below. if (isset($listOptions['additional_rows'])) { $list_context['additional_rows'] = array(); foreach ($listOptions['additional_rows'] as $row) { if (empty($row)) { continue; } // Supported row positions: top_of_list, after_title, // above_column_headers, below_table_data, bottom_of_list. if (!isset($list_context['additional_rows'][$row['position']])) { $list_context['additional_rows'][$row['position']] = array(); } $list_context['additional_rows'][$row['position']][] = $row; } } // Add an option for inline JavaScript. if (isset($listOptions['javascript'])) { $list_context['javascript'] = $listOptions['javascript']; } // We want a menu. if (isset($listOptions['list_menu'])) { $list_context['list_menu'] = $listOptions['list_menu']; } // Make sure the template is loaded. loadTemplate('GenericList'); }
function is_not_banned($forceCheck = false) { global $txt, $modSettings, $context, $user_info; global $sourcedir, $cookiename, $user_settings, $smcFunc; // You cannot be banned if you are an admin - doesn't help if you log out. if ($user_info['is_admin']) { return; } // Only check the ban every so often. (to reduce load.) if ($forceCheck || !isset($_SESSION['ban']) || empty($modSettings['banLastUpdated']) || $_SESSION['ban']['last_checked'] < $modSettings['banLastUpdated'] || $_SESSION['ban']['id_member'] != $user_info['id'] || $_SESSION['ban']['ip'] != $user_info['ip'] || $_SESSION['ban']['ip2'] != $user_info['ip2'] || isset($user_info['email'], $_SESSION['ban']['email']) && $_SESSION['ban']['email'] != $user_info['email']) { // Innocent until proven guilty. (but we know you are! :P) $_SESSION['ban'] = array('last_checked' => time(), 'id_member' => $user_info['id'], 'ip' => $user_info['ip'], 'ip2' => $user_info['ip2'], 'email' => $user_info['email']); $ban_query = array(); $ban_query_vars = array('current_time' => time()); $flag_is_activated = false; // Check both IP addresses. foreach (array('ip', 'ip2') as $ip_number) { // Check if we have a valid IP address. if (preg_match('/^(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})$/', $user_info[$ip_number], $ip_parts) == 1) { $ban_query[] = '((' . $ip_parts[1] . ' BETWEEN bi.ip_low1 AND bi.ip_high1) AND (' . $ip_parts[2] . ' BETWEEN bi.ip_low2 AND bi.ip_high2) AND (' . $ip_parts[3] . ' BETWEEN bi.ip_low3 AND bi.ip_high3) AND (' . $ip_parts[4] . ' BETWEEN bi.ip_low4 AND bi.ip_high4))'; // IP was valid, maybe there's also a hostname... if (empty($modSettings['disableHostnameLookup'])) { $hostname = host_from_ip($user_info[$ip_number]); if (strlen($hostname) > 0) { $ban_query[] = '({string:hostname} LIKE bi.hostname)'; $ban_query_vars['hostname'] = $hostname; } } } elseif ($user_info['ip'] == 'unknown') { $ban_query[] = '(bi.ip_low1 = 255 AND bi.ip_high1 = 255 AND bi.ip_low2 = 255 AND bi.ip_high2 = 255 AND bi.ip_low3 = 255 AND bi.ip_high3 = 255 AND bi.ip_low4 = 255 AND bi.ip_high4 = 255)'; } } // Is their email address banned? if (strlen($user_info['email']) != 0) { $ban_query[] = '({string:email} LIKE bi.email_address)'; $ban_query_vars['email'] = $user_info['email']; } // How about this user? if (!$user_info['is_guest'] && !empty($user_info['id'])) { $ban_query[] = 'bi.id_member = {int:id_member}'; $ban_query_vars['id_member'] = $user_info['id']; } // Check the ban, if there's information. if (!empty($ban_query)) { $restrictions = array('cannot_access', 'cannot_login', 'cannot_post', 'cannot_register'); $request = $smcFunc['db_query']('', ' SELECT bi.id_ban, bi.email_address, bi.id_member, bg.cannot_access, bg.cannot_register, bg.cannot_post, bg.cannot_login, bg.reason, IFNULL(bg.expire_time, 0) AS expire_time FROM {db_prefix}ban_items AS bi INNER JOIN {db_prefix}ban_groups AS bg ON (bg.id_ban_group = bi.id_ban_group AND (bg.expire_time IS NULL OR bg.expire_time > {int:current_time})) WHERE (' . implode(' OR ', $ban_query) . ')', $ban_query_vars); // Store every type of ban that applies to you in your session. while ($row = $smcFunc['db_fetch_assoc']($request)) { foreach ($restrictions as $restriction) { if (!empty($row[$restriction])) { $_SESSION['ban'][$restriction]['reason'] = $row['reason']; $_SESSION['ban'][$restriction]['ids'][] = $row['id_ban']; if (!isset($_SESSION['ban']['expire_time']) || $_SESSION['ban']['expire_time'] != 0 && ($row['expire_time'] == 0 || $row['expire_time'] > $_SESSION['ban']['expire_time'])) { $_SESSION['ban']['expire_time'] = $row['expire_time']; } if (!$user_info['is_guest'] && $restriction == 'cannot_access' && ($row['id_member'] == $user_info['id'] || $row['email_address'] == $user_info['email'])) { $flag_is_activated = true; } } } } $smcFunc['db_free_result']($request); } // Mark the cannot_access and cannot_post bans as being 'hit'. if (isset($_SESSION['ban']['cannot_access']) || isset($_SESSION['ban']['cannot_post']) || isset($_SESSION['ban']['cannot_login'])) { log_ban(array_merge(isset($_SESSION['ban']['cannot_access']) ? $_SESSION['ban']['cannot_access']['ids'] : array(), isset($_SESSION['ban']['cannot_post']) ? $_SESSION['ban']['cannot_post']['ids'] : array(), isset($_SESSION['ban']['cannot_login']) ? $_SESSION['ban']['cannot_login']['ids'] : array())); } // If for whatever reason the is_activated flag seems wrong, do a little work to clear it up. if ($user_info['id'] && ($user_settings['is_activated'] >= 10 && !$flag_is_activated || $user_settings['is_activated'] < 10 && $flag_is_activated)) { require_once $sourcedir . '/ManageBans.php'; updateBanMembers(); } } // Hey, I know you! You're ehm... if (!isset($_SESSION['ban']['cannot_access']) && !empty($_COOKIE[$cookiename . '_'])) { $bans = explode(',', $_COOKIE[$cookiename . '_']); foreach ($bans as $key => $value) { $bans[$key] = (int) $value; } $request = $smcFunc['db_query']('', ' SELECT bi.id_ban, bg.reason FROM {db_prefix}ban_items AS bi INNER JOIN {db_prefix}ban_groups AS bg ON (bg.id_ban_group = bi.id_ban_group) WHERE bi.id_ban IN ({array_int:ban_list}) AND (bg.expire_time IS NULL OR bg.expire_time > {int:current_time}) AND bg.cannot_access = {int:cannot_access} LIMIT ' . count($bans), array('cannot_access' => 1, 'ban_list' => $bans, 'current_time' => time())); while ($row = $smcFunc['db_fetch_assoc']($request)) { $_SESSION['ban']['cannot_access']['ids'][] = $row['id_ban']; $_SESSION['ban']['cannot_access']['reason'] = $row['reason']; } $smcFunc['db_free_result']($request); // My mistake. Next time better. if (!isset($_SESSION['ban']['cannot_access'])) { require_once $sourcedir . '/Subs-Auth.php'; $cookie_url = url_parts(!empty($modSettings['localCookies']), !empty($modSettings['globalCookies'])); setcookie($cookiename . '_', '', time() - 3600, $cookie_url[1], $cookie_url[0], 0); } } // If you're fully banned, it's end of the story for you. if (isset($_SESSION['ban']['cannot_access'])) { // We don't wanna see you! if (!$user_info['is_guest']) { $smcFunc['db_query']('', ' DELETE FROM {db_prefix}log_online WHERE id_member = {int:current_member}', array('current_member' => $user_info['id'])); } // 'Log' the user out. Can't have any funny business... (save the name!) $old_name = isset($user_info['name']) && $user_info['name'] != '' ? $user_info['name'] : $txt['guest_title']; $user_info['name'] = ''; $user_info['username'] = ''; $user_info['is_guest'] = true; $user_info['is_admin'] = false; $user_info['permissions'] = array(); $user_info['id'] = 0; $context['user'] = array('id' => 0, 'username' => '', 'name' => $txt['guest_title'], 'is_guest' => true, 'is_logged' => false, 'is_admin' => false, 'is_mod' => false, 'can_mod' => false, 'language' => $user_info['language']); // A goodbye present. require_once $sourcedir . '/Subs-Auth.php'; $cookie_url = url_parts(!empty($modSettings['localCookies']), !empty($modSettings['globalCookies'])); setcookie($cookiename . '_', implode(',', $_SESSION['ban']['cannot_access']['ids']), time() + 3153600, $cookie_url[1], $cookie_url[0], 0); // Don't scare anyone, now. $_GET['action'] = ''; $_GET['board'] = ''; $_GET['topic'] = ''; writeLog(true); // You banned, sucka! fatal_error(sprintf($txt['your_ban'], $old_name) . (empty($_SESSION['ban']['cannot_access']['reason']) ? '' : '<br />' . $_SESSION['ban']['cannot_access']['reason']) . '<br />' . (!empty($_SESSION['ban']['expire_time']) ? sprintf($txt['your_ban_expires'], timeformat($_SESSION['ban']['expire_time'], false)) : $txt['your_ban_expires_never']), 'user'); // If we get here, something's gone wrong.... but let's try anyway. trigger_error('Hacking attempt...', E_USER_ERROR); } elseif (isset($_SESSION['ban']['cannot_login']) && !$user_info['is_guest']) { // We don't wanna see you! $smcFunc['db_query']('', ' DELETE FROM {db_prefix}log_online WHERE id_member = {int:current_member}', array('current_member' => $user_info['id'])); // 'Log' the user out. Can't have any funny business... (save the name!) $old_name = isset($user_info['name']) && $user_info['name'] != '' ? $user_info['name'] : $txt['guest_title']; $user_info['name'] = ''; $user_info['username'] = ''; $user_info['is_guest'] = true; $user_info['is_admin'] = false; $user_info['permissions'] = array(); $user_info['id'] = 0; $context['user'] = array('id' => 0, 'username' => '', 'name' => $txt['guest_title'], 'is_guest' => true, 'is_logged' => false, 'is_admin' => false, 'is_mod' => false, 'can_mod' => false, 'language' => $user_info['language']); // SMF's Wipe 'n Clean(r) erases all traces. $_GET['action'] = ''; $_GET['board'] = ''; $_GET['topic'] = ''; writeLog(true); require_once $sourcedir . '/LogInOut.php'; Logout(true, false); fatal_error(sprintf($txt['your_ban'], $old_name) . (empty($_SESSION['ban']['cannot_login']['reason']) ? '' : '<br />' . $_SESSION['ban']['cannot_login']['reason']) . '<br />' . (!empty($_SESSION['ban']['expire_time']) ? sprintf($txt['your_ban_expires'], timeformat($_SESSION['ban']['expire_time'], false)) : $txt['your_ban_expires_never']) . '<br />' . $txt['ban_continue_browse'], 'user'); } // Fix up the banning permissions. if (isset($user_info['permissions'])) { banPermissions(); } }
function Who() { global $context, $scripturl, $user_info, $txt, $modSettings, $memberContext, $smcFunc; // Permissions, permissions, permissions. isAllowedTo('who_view'); // You can't do anything if this is off. if (empty($modSettings['who_enabled'])) { fatal_lang_error('who_off', false); } // Load the 'Who' template. loadTemplate('Who'); loadLanguage('Who'); // Sort out... the column sorting. $sort_methods = array('user' => 'mem.real_name', 'time' => 'lo.log_time'); $show_methods = array('members' => '(lo.id_member != 0)', 'guests' => '(lo.id_member = 0)', 'all' => '1=1'); // Store the sort methods and the show types for use in the template. $context['sort_methods'] = array('user' => $txt['who_user'], 'time' => $txt['who_time']); $context['show_methods'] = array('all' => $txt['who_show_all'], 'members' => $txt['who_show_members_only'], 'guests' => $txt['who_show_guests_only']); // Can they see spiders too? if (!empty($modSettings['show_spider_online']) && ($modSettings['show_spider_online'] == 2 || allowedTo('admin_forum')) && !empty($modSettings['spider_name_cache'])) { $show_methods['spiders'] = '(lo.id_member = 0 AND lo.id_spider > 0)'; $show_methods['guests'] = '(lo.id_member = 0 AND lo.id_spider = 0)'; $context['show_methods']['spiders'] = $txt['who_show_spiders_only']; } elseif (empty($modSettings['show_spider_online']) && isset($_SESSION['who_online_filter']) && $_SESSION['who_online_filter'] == 'spiders') { unset($_SESSION['who_online_filter']); } // Does the user prefer a different sort direction? if (isset($_REQUEST['sort']) && isset($sort_methods[$_REQUEST['sort']])) { $context['sort_by'] = $_SESSION['who_online_sort_by'] = $_REQUEST['sort']; $sort_method = $sort_methods[$_REQUEST['sort']]; } elseif (isset($_SESSION['who_online_sort_by'])) { $context['sort_by'] = $_SESSION['who_online_sort_by']; $sort_method = $sort_methods[$_SESSION['who_online_sort_by']]; } else { $context['sort_by'] = $_SESSION['who_online_sort_by'] = 'time'; $sort_method = 'lo.log_time'; } $context['sort_direction'] = isset($_REQUEST['asc']) || isset($_REQUEST['sort_dir']) && $_REQUEST['sort_dir'] == 'asc' ? 'up' : 'down'; $conditions = array(); if (!allowedTo('moderate_forum')) { $conditions[] = '(IFNULL(mem.show_online, 1) = 1)'; } // Fallback to top filter? if (isset($_REQUEST['submit_top']) && isset($_REQUEST['show_top'])) { $_REQUEST['show'] = $_REQUEST['show_top']; } // Does the user wish to apply a filter? if (isset($_REQUEST['show']) && isset($show_methods[$_REQUEST['show']])) { $context['show_by'] = $_SESSION['who_online_filter'] = $_REQUEST['show']; $conditions[] = $show_methods[$_REQUEST['show']]; } elseif (isset($_SESSION['who_online_filter'])) { $context['show_by'] = $_SESSION['who_online_filter']; $conditions[] = $show_methods[$_SESSION['who_online_filter']]; } else { $context['show_by'] = $_SESSION['who_online_filter'] = 'all'; } // Get the total amount of members online. $request = $smcFunc['db_query']('', ' SELECT COUNT(*) FROM {db_prefix}log_online AS lo LEFT JOIN {db_prefix}members AS mem ON (lo.id_member = mem.id_member)' . (!empty($conditions) ? ' WHERE ' . implode(' AND ', $conditions) : ''), array()); list($totalMembers) = $smcFunc['db_fetch_row']($request); $smcFunc['db_free_result']($request); // Prepare some page index variables. $context['page_index'] = constructPageIndex($scripturl . '?action=who;sort=' . $context['sort_by'] . ($context['sort_direction'] == 'up' ? ';asc' : '') . ';show=' . $context['show_by'], $_REQUEST['start'], $totalMembers, $modSettings['defaultMaxMembers']); $context['start'] = $_REQUEST['start']; // Look for people online, provided they don't mind if you see they are. $request = $smcFunc['db_query']('', ' SELECT lo.log_time, lo.id_member, lo.url, INET_NTOA(lo.ip) AS ip, mem.real_name, lo.session, mg.online_color, IFNULL(mem.show_online, 1) AS show_online, lo.id_spider FROM {db_prefix}log_online AS lo LEFT JOIN {db_prefix}members AS mem ON (lo.id_member = mem.id_member) LEFT JOIN {db_prefix}membergroups AS mg ON (mg.id_group = CASE WHEN mem.id_group = {int:regular_member} THEN mem.id_post_group ELSE mem.id_group END)' . (!empty($conditions) ? ' WHERE ' . implode(' AND ', $conditions) : '') . ' ORDER BY {raw:sort_method} {raw:sort_direction} LIMIT {int:offset}, {int:limit}', array('regular_member' => 0, 'sort_method' => $sort_method, 'sort_direction' => $context['sort_direction'] == 'up' ? 'ASC' : 'DESC', 'offset' => $context['start'], 'limit' => $modSettings['defaultMaxMembers'])); $context['members'] = array(); $member_ids = array(); $url_data = array(); while ($row = $smcFunc['db_fetch_assoc']($request)) { $actions = @unserialize($row['url']); if ($actions === false) { continue; } // Send the information to the template. $context['members'][$row['session']] = array('id' => $row['id_member'], 'ip' => allowedTo('moderate_forum') ? $row['ip'] : '', 'time' => strtr(timeformat($row['log_time']), array($txt['today'] => '', $txt['yesterday'] => '')), 'timestamp' => forum_time(true, $row['log_time']), 'query' => $actions, 'is_hidden' => $row['show_online'] == 0, 'id_spider' => $row['id_spider'], 'color' => empty($row['online_color']) ? '' : $row['online_color']); $url_data[$row['session']] = array($row['url'], $row['id_member']); $member_ids[] = $row['id_member']; } $smcFunc['db_free_result']($request); // Load the user data for these members. loadMemberData($member_ids); // Load up the guest user. $memberContext[0] = array('id' => 0, 'name' => $txt['guest_title'], 'group' => $txt['guest_title'], 'href' => '', 'link' => $txt['guest_title'], 'email' => $txt['guest_title'], 'is_guest' => true); // Are we showing spiders? $spiderContext = array(); if (!empty($modSettings['show_spider_online']) && ($modSettings['show_spider_online'] == 2 || allowedTo('admin_forum')) && !empty($modSettings['spider_name_cache'])) { foreach (unserialize($modSettings['spider_name_cache']) as $id => $name) { $spiderContext[$id] = array('id' => 0, 'name' => $name, 'group' => $txt['spiders'], 'href' => '', 'link' => $name, 'email' => $name, 'is_guest' => true); } } $url_data = determineActions($url_data); // Setup the linktree and page title (do it down here because the language files are now loaded..) $context['page_title'] = $txt['who_title']; $context['linktree'][] = array('url' => $scripturl . '?action=who', 'name' => $txt['who_title']); // Put it in the context variables. foreach ($context['members'] as $i => $member) { if ($member['id'] != 0) { $member['id'] = loadMemberContext($member['id']) ? $member['id'] : 0; } // Keep the IP that came from the database. $memberContext[$member['id']]['ip'] = $member['ip']; $context['members'][$i]['action'] = isset($url_data[$i]) ? $url_data[$i] : $txt['who_hidden']; if ($member['id'] == 0 && isset($spiderContext[$member['id_spider']])) { $context['members'][$i] += $spiderContext[$member['id_spider']]; } else { $context['members'][$i] += $memberContext[$member['id']]; } } // Some people can't send personal messages... $context['can_send_pm'] = allowedTo('pm_send'); // any profile fields disabled? $context['disabled_fields'] = isset($modSettings['disabled_profile_fields']) ? array_flip(explode(',', $modSettings['disabled_profile_fields'])) : array(); }
function list_getGroupRequests($start, $items_per_page, $sort, $where, $where_parameters) { global $smcFunc, $txt, $scripturl; $request = $smcFunc['db_query']('', ' SELECT lgr.id_request, lgr.id_member, lgr.id_group, lgr.time_applied, lgr.reason, mem.member_name, mg.group_name, mg.online_color, mem.real_name FROM {db_prefix}log_group_requests AS lgr INNER JOIN {db_prefix}members AS mem ON (mem.id_member = lgr.id_member) INNER JOIN {db_prefix}membergroups AS mg ON (mg.id_group = lgr.id_group) WHERE ' . $where . ' ORDER BY {raw:sort} LIMIT ' . $start . ', ' . $items_per_page, array_merge($where_parameters, array('sort' => $sort))); $group_requests = array(); while ($row = $smcFunc['db_fetch_assoc']($request)) { if (!empty($row['id_member'])) { $context['MemberColor_ID_MEMBER'][$row['id_member']] = $row['id_member']; } $group_requests[] = array('id' => $row['id_request'], 'id_member' => $row['id_member'], 'member_link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>', 'group_link' => '<span style="color: ' . $row['online_color'] . '">' . $row['group_name'] . '</span>', 'reason' => censorText($row['reason']), 'time_submitted' => timeformat($row['time_applied'])); } $smcFunc['db_free_result']($request); //Give me some Colors baby ;D global $modSettings; if (!empty($modSettings['MemberColorModCenter']) && !empty($context['MemberColor_ID_MEMBER']) && !empty($group_requests)) { $colorDatas = load_onlineColors($context['MemberColor_ID_MEMBER']); foreach ($group_requests as $key => $item) { if (!empty($colorDatas[$item['id_member']]['colored_link'])) { $group_requests[$key]['member_link'] = $colorDatas[$item['id_member']]['colored_link']; } } } return $group_requests; }
function adk_aportes_automaticos($array = '', $limit_body = '', $limit_query = '') { global $context, $scripturl, $txt, $settings, $smcFunc, $boardurl, $adkportal, $current_load; global $modSettings; if (empty($array)) { $array = $adkportal['auto_news_id_boards']; } if (empty($limit_body)) { $limit_body = $adkportal['auto_news_limit_body']; } if (empty($limit_query)) { $limit_query = $adkportal['auto_news_limit_topics']; } if (!empty($adkportal['auto_news_size_img'])) { $size_img = 'style="max-width: ' . $adkportal['auto_news_size_img'] . 'px;"'; } $context['start'] = isset($_REQUEST['adk']) && !empty($_REQUEST['start']) && !empty($_REQUEST['id']) && $_REQUEST['id'] == $context['block']['id'] ? (int) $_REQUEST['start'] : 0; $sql = $smcFunc['db_query']('', ' SELECT COUNT(*) AS total FROM {db_prefix}topics AS t INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board) WHERE ' . (!empty($array) ? 'b.id_board IN ({array_int:boards}) AND' : '') . ' {query_wanna_see_board}', array('boards' => explode(',', $array))); $row = $smcFunc['db_fetch_assoc']($sql); $smcFunc['db_free_result']($sql); $total = $row['total']; $context['page_index'] = constructPageIndex($scripturl . '?adk;id=' . $context['block']['id'], $context['start'], $total, $limit_query); $sql = $smcFunc['db_query']('', ' SELECT m.id_topic, m.poster_time, m.id_member, m.poster_name, m.subject, m.body, m.icon, mg.online_color, t.num_replies, t.num_views, mem.real_name, mem.avatar, IFNULL(a.id_attach, 0) AS id_attach, a.filename, a.attachment_type FROM {db_prefix}messages AS m LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member) LEFT JOIN {db_prefix}attachments AS a ON (a.id_member = mem.id_member) LEFT JOIN {db_prefix}membergroups AS mg ON (mg.id_group = CASE WHEN mem.id_group = {int:reg_mem_group} THEN mem.id_post_group ELSE mem.id_group END) INNER JOIN {db_prefix}topics AS t ON (t.id_first_msg = m.id_msg) INNER JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board) WHERE ' . (!empty($array) ? 'm.id_board IN ({array_int:boards}) AND' : '') . ' {query_wanna_see_board} ORDER BY m.id_topic DESC LIMIT {int:uno}, {int:limit} ', array('limit' => $limit_query, 'uno' => $context['start'], 'boards' => explode(',', $array), 'reg_mem_group' => 0)); $img = 'plugin.png'; $topics = array(); while ($row = $smcFunc['db_fetch_assoc']($sql)) { if (!empty($row['id_member'])) { $member = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; } else { $member = $row['poster_name']; } $body = Adk_truncate(parse_bbc($row['body']), $limit_body, '...', false, true); if (!empty($size_img)) { $body = str_replace('class="', 'class="resize_auto_new ', $body); $body = str_replace('<img ', '<img ' . $size_img . '', $body); } $topics[] = array('v' => $row['num_views'], 'r' => $row['num_replies'], 'avatar' => $row['avatar'] == '' ? $row['id_attach'] > 0 ? '<img width="30" height="30" 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="30" height="30" src="' . $row['avatar'] . '" alt="" border="0" />' : '<img width="30" height="30" src="' . $modSettings['avatar_url'] . '/' . $smcFunc['htmlspecialchars']($row['avatar']) . '" alt="" border="0" />'), 'id_topic' => $row['id_topic'], 'img' => '<img style="vertical-align: middle;" src="' . $settings['images_url'] . '/post/' . $row['icon'] . '.gif" alt="" />', 'href' => $row['subject'], 'time' => timeformat($row['poster_time']), 'member' => $member, 'body' => $body); } //$averiguar = $avatar2,1,4); $smcFunc['db_free_result']($sql); foreach ($topics as $topic) { $title = '<a href="' . $scripturl . '?topic=' . $topic['id_topic'] . '.0"><b>' . $topic['href'] . '</b></a>'; if (!empty($context['block']['b'])) { echo ' <span class="clear upperframe"> <span> </span> </span> <div class="roundframe"> <div> ' . $topic['img'] . ' <strong>' . $title . '</strong> <hr />'; } else { echo ' ' . $topic['img'] . ' <strong>' . $title . '</strong> <hr />'; } echo ' <div style="height: 40px;"> <div class="smalltext adk_float_r">' . $txt['by'] . ' ' . $topic['member'] . ' - ' . $topic['time'] . '</div>'; if (!empty($topic['avatar'])) { echo ' <div class="adk_float_l">', $topic['avatar'], '</div>'; } echo ' </div> <div class="adk_padding_8"> ' . $topic['body'] . ' </div> <br />'; if (!empty($adkportal['adk_bookmarks_autonews'])) { adk_bookmarks('right', 'auto_news', $topic['id_topic']); } echo ' <div class="smalltext adk_padding_5"> <hr /> <a href="' . $scripturl . '?topic=' . $topic['id_topic'] . '.0"><strong>' . $txt['adkmod_block_readmore'] . '...</strong></a> <div class="adk_float_r"> ' . $txt['views'] . ': ' . $topic['v'] . ' ' . $txt['replies'] . ': ' . $topic['r'] . ' </div> <br /><br /> </div> <div class="adk_height_3"></div>'; if (!empty($context['block']['b'])) { echo ' </div> </div> <span class="lowerframe"> <span> </span> </span>'; } else { echo ' <hr /><div class="adk_height_1"></div>'; } } if ($current_load[0] == 'default') { if (!empty($context['block']['b'])) { echo ' <span class="clear upperframe"> <span> </span> </span> <div class="roundframe"> <div>'; } echo ' <div class="adk_align_right">' . $txt['pages'] . ': ' . $context['page_index'] . '</div> <div class="adk_height_1"></div>'; if (!empty($context['block']['b'])) { echo ' </div> </div> <span class="lowerframe"> <span> </span> </span>'; } } }
/** * An error in the message... * * @param $error_types * @param $named_recipients * @param $recipient_ids */ function messagePostError($error_types, $named_recipients, $recipient_ids = array()) { global $txt, $context, $scripturl, $modSettings; global $smcFunc, $user_info, $sourcedir; if (!isset($_REQUEST['xml'])) { $context['menu_data_' . $context['pm_menu_id']]['current_area'] = 'send'; } if (!WIRELESS && !isset($_REQUEST['xml'])) { $context['sub_template'] = 'send'; } elseif (isset($_REQUEST['xml'])) { $context['sub_template'] = 'pm'; } $context['page_title'] = $txt['send_message']; // Got some known members? $context['recipients'] = array('to' => array(), 'bcc' => array()); if (!empty($recipient_ids['to']) || !empty($recipient_ids['bcc'])) { $allRecipients = array_merge($recipient_ids['to'], $recipient_ids['bcc']); $request = $smcFunc['db_query']('', ' SELECT id_member, real_name FROM {db_prefix}members WHERE id_member IN ({array_int:member_list})', array('member_list' => $allRecipients)); while ($row = $smcFunc['db_fetch_assoc']($request)) { $recipientType = in_array($row['id_member'], $recipient_ids['bcc']) ? 'bcc' : 'to'; $context['recipients'][$recipientType][] = array('id' => $row['id_member'], 'name' => $row['real_name']); } $smcFunc['db_free_result']($request); } // Set everything up like before.... $context['subject'] = isset($_REQUEST['subject']) ? $smcFunc['htmlspecialchars']($_REQUEST['subject']) : ''; $context['message'] = isset($_REQUEST['message']) ? str_replace(array(' '), array(' '), $smcFunc['htmlspecialchars']($_REQUEST['message'])) : ''; $context['copy_to_outbox'] = !empty($_REQUEST['outbox']); $context['reply'] = !empty($_REQUEST['replied_to']); if ($context['reply']) { $_REQUEST['replied_to'] = (int) $_REQUEST['replied_to']; $request = $smcFunc['db_query']('', ' SELECT pm.id_pm, CASE WHEN pm.id_pm_head = {int:no_id_pm_head} THEN pm.id_pm ELSE pm.id_pm_head END AS pm_head, pm.body, pm.subject, pm.msgtime, mem.member_name, IFNULL(mem.id_member, 0) AS id_member, IFNULL(mem.real_name, pm.from_name) AS real_name FROM {db_prefix}personal_messages AS pm' . ($context['folder'] == 'sent' ? '' : ' INNER JOIN {db_prefix}pm_recipients AS pmr ON (pmr.id_pm = {int:replied_to})') . ' LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = pm.id_member_from) WHERE pm.id_pm = {int:replied_to}' . ($context['folder'] == 'sent' ? ' AND pm.id_member_from = {int:current_member}' : ' AND pmr.id_member = {int:current_member}') . ' LIMIT 1', array('current_member' => $user_info['id'], 'no_id_pm_head' => 0, 'replied_to' => $_REQUEST['replied_to'])); if ($smcFunc['db_num_rows']($request) == 0) { if (!isset($_REQUEST['xml'])) { fatal_lang_error('pm_not_yours', false); } else { $error_types[] = 'pm_not_yours'; } } $row_quoted = $smcFunc['db_fetch_assoc']($request); $smcFunc['db_free_result']($request); censorText($row_quoted['subject']); censorText($row_quoted['body']); $context['quoted_message'] = array('id' => $row_quoted['id_pm'], 'pm_head' => $row_quoted['pm_head'], 'member' => array('name' => $row_quoted['real_name'], 'username' => $row_quoted['member_name'], 'id' => $row_quoted['id_member'], 'href' => !empty($row_quoted['id_member']) ? $scripturl . '?action=profile;u=' . $row_quoted['id_member'] : '', 'link' => !empty($row_quoted['id_member']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row_quoted['id_member'] . '">' . $row_quoted['real_name'] . '</a>' : $row_quoted['real_name']), 'subject' => $row_quoted['subject'], 'time' => timeformat($row_quoted['msgtime']), 'timestamp' => forum_time(true, $row_quoted['msgtime']), 'body' => parse_bbc($row_quoted['body'], true, 'pm' . $row_quoted['id_pm'])); } // Build the link tree.... $context['linktree'][] = array('url' => $scripturl . '?action=pm;sa=send', 'name' => $txt['new_message']); // Set each of the errors for the template. loadLanguage('Errors'); $context['error_type'] = 'minor'; $context['post_error'] = array('messages' => array(), 'error_type' => ''); foreach ($error_types as $error_type) { $context['post_error'][$error_type] = true; if (isset($txt['error_' . $error_type])) { if ($error_type == 'long_message') { $txt['error_' . $error_type] = sprintf($txt['error_' . $error_type], $modSettings['max_messageLength']); } $context['post_error']['messages'][] = $txt['error_' . $error_type]; } // If it's not a minor error flag it as such. if (!in_array($error_type, array('new_reply', 'not_approved', 'new_replies', 'old_topic', 'need_qr_verification', 'no_subject'))) { $context['error_type'] = 'serious'; } } // Need to reset draft capability once again $context['drafts_pm_save'] = !empty($modSettings['drafts_pm_enabled']) && allowedTo('pm_draft'); $context['drafts_autosave'] = !empty($context['drafts_pm_save']) && !empty($modSettings['drafts_autosave_enabled']) && allowedTo('pm_autosave_draft'); // We need to load the editor once more. require_once $sourcedir . '/Subs-Editor.php'; // Create it... $editorOptions = array('id' => 'message', 'value' => $context['message'], 'width' => '90%', 'labels' => array('post_button' => $txt['send_message']), 'preview_type' => 2); create_control_richedit($editorOptions); // ... and store the ID again... $context['post_box_name'] = $editorOptions['id']; // Check whether we need to show the code again. $context['require_verification'] = !$user_info['is_admin'] && !empty($modSettings['pm_posts_verification']) && $user_info['posts'] < $modSettings['pm_posts_verification']; if ($context['require_verification'] && !isset($_REQUEST['xml'])) { require_once $sourcedir . '/Subs-Editor.php'; $verificationOptions = array('id' => 'pm'); $context['require_verification'] = create_control_verification($verificationOptions); $context['visual_verification_id'] = $verificationOptions['id']; } $context['to_value'] = empty($named_recipients['to']) ? '' : '"' . implode('", "', $named_recipients['to']) . '"'; $context['bcc_value'] = empty($named_recipients['bcc']) ? '' : '"' . implode('", "', $named_recipients['bcc']) . '"'; // No check for the previous submission is needed. checkSubmitOnce('free'); // Acquire a new form sequence number. checkSubmitOnce('register'); }
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 StaffReport() { global $sourcedir, $context, $txt, $smcFunc; require_once $sourcedir . '/Subs-Members.php'; // Fetch all the board names. $request = $smcFunc['db_query']('', ' SELECT id_board, name FROM {db_prefix}boards', array()); $boards = array(); while ($row = $smcFunc['db_fetch_assoc']($request)) { $boards[$row['id_board']] = $row['name']; } $smcFunc['db_free_result']($request); // Get every moderator. $request = $smcFunc['db_query']('', ' SELECT mods.id_board, mods.id_member FROM {db_prefix}moderators AS mods', array()); $moderators = array(); $local_mods = array(); while ($row = $smcFunc['db_fetch_assoc']($request)) { $moderators[$row['id_member']][] = $row['id_board']; $local_mods[$row['id_member']] = $row['id_member']; } $smcFunc['db_free_result']($request); // Get a list of global moderators (i.e. members with moderation powers). $global_mods = array_intersect(membersAllowedTo('moderate_board', 0), membersAllowedTo('approve_posts', 0), membersAllowedTo('remove_any', 0), membersAllowedTo('modify_any', 0)); // How about anyone else who is special? $allStaff = array_merge(membersAllowedTo('admin_forum'), membersAllowedTo('manage_membergroups'), membersAllowedTo('manage_permissions'), $local_mods, $global_mods); // Make sure everyone is there once - no admin less important than any other! $allStaff = array_unique($allStaff); // This is a bit of a cop out - but we're protecting their forum, really! if (count($allStaff) > 300) { fatal_lang_error('report_error_too_many_staff'); } // Get all the possible membergroups! $request = $smcFunc['db_query']('', ' SELECT id_group, group_name, online_color FROM {db_prefix}membergroups', array()); $groups = array(0 => $txt['full_member']); while ($row = $smcFunc['db_fetch_assoc']($request)) { $groups[$row['id_group']] = empty($row['online_color']) ? $row['group_name'] : '<span style="color: ' . $row['online_color'] . '">' . $row['group_name'] . '</span>'; } $smcFunc['db_free_result']($request); // All the fields we'll show. $staffSettings = array('position' => $txt['report_staff_position'], 'moderates' => $txt['report_staff_moderates'], 'posts' => $txt['report_staff_posts'], 'last_login' => $txt['report_staff_last_login']); // Do it in columns, it's just easier. setKeys('cols'); // Get each member! $request = $smcFunc['db_query']('', ' SELECT id_member, real_name, id_group, posts, last_login FROM {db_prefix}members WHERE id_member IN ({array_int:staff_list}) ORDER BY real_name', array('staff_list' => $allStaff)); while ($row = $smcFunc['db_fetch_assoc']($request)) { // Each member gets their own table!. newTable($row['real_name'], '', 'left', 'auto', 'left', 200, 'center'); // First off, add in the side key. addData($staffSettings); // Create the main data array. $staffData = array('position' => isset($groups[$row['id_group']]) ? $groups[$row['id_group']] : $groups[0], 'posts' => $row['posts'], 'last_login' => timeformat($row['last_login']), 'moderates' => array()); // What do they moderate? if (in_array($row['id_member'], $global_mods)) { $staffData['moderates'] = '<em>' . $txt['report_staff_all_boards'] . '</em>'; } elseif (isset($moderators[$row['id_member']])) { // Get the names foreach ($moderators[$row['id_member']] as $board) { if (isset($boards[$board])) { $staffData['moderates'][] = $boards[$board]; } } $staffData['moderates'] = implode(', ', $staffData['moderates']); } else { $staffData['moderates'] = '<em>' . $txt['report_staff_no_boards'] . '</em>'; } // Next add the main data. addData($staffData); } $smcFunc['db_free_result']($request); }
function template_header() { global $txt, $modSettings, $context, $settings, $user_info, $boarddir, $cachedir; setupThemeContext(); // Print stuff to prevent caching of pages (except on attachment errors, etc.) if (empty($context['no_last_modified'])) { header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // Are we debugging the template/html content? if (!isset($_REQUEST['xml']) && isset($_GET['debug']) && !$context['browser']['is_ie'] && !WIRELESS) { header('Content-Type: application/xhtml+xml'); } elseif (!isset($_REQUEST['xml']) && !WIRELESS) { header('Content-Type: text/html; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); } } header('Content-Type: text/' . (isset($_REQUEST['xml']) ? 'xml' : 'html') . '; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); $checked_securityFiles = false; $showed_banned = false; foreach ($context['template_layers'] as $layer) { loadSubTemplate($layer . '_above', true); // May seem contrived, but this is done in case the body and main layer aren't there... if (in_array($layer, array('body', 'main')) && allowedTo('admin_forum') && !$user_info['is_guest'] && !$checked_securityFiles) { $checked_securityFiles = true; $securityFiles = array('install.php', 'webinstall.php', 'upgrade.php', 'convert.php', 'repair_paths.php', 'repair_settings.php', 'Settings.php~', 'Settings_bak.php~'); foreach ($securityFiles as $i => $securityFile) { if (!file_exists($boarddir . '/' . $securityFile)) { unset($securityFiles[$i]); } } if (!empty($securityFiles) || !empty($modSettings['cache_enable']) && !is_writable($cachedir)) { echo ' <div class="errorbox"> <p class="alert">!!</p> <h3>', empty($securityFiles) ? $txt['cache_writable_head'] : $txt['security_risk'], '</h3> <p>'; foreach ($securityFiles as $securityFile) { echo ' ', $txt['not_removed'], '<strong>', $securityFile, '</strong>!<br />'; if ($securityFile == 'Settings.php~' || $securityFile == 'Settings_bak.php~') { echo ' ', sprintf($txt['not_removed_extra'], $securityFile, substr($securityFile, 0, -1)), '<br />'; } } if (!empty($modSettings['cache_enable']) && !is_writable($cachedir)) { echo ' <strong>', $txt['cache_writable'], '</strong><br />'; } echo ' </p> </div>'; } } elseif (in_array($layer, array('main', 'body')) && isset($_SESSION['ban']['cannot_post']) && !$showed_banned) { $showed_banned = true; echo ' <div class="windowbg alert" style="margin: 2ex; padding: 2ex; border: 2px dashed red;"> ', sprintf($txt['you_are_post_banned'], $user_info['is_guest'] ? $txt['guest_title'] : $user_info['name']); if (!empty($_SESSION['ban']['cannot_post']['reason'])) { echo ' <div style="padding-left: 4ex; padding-top: 1ex;">', $_SESSION['ban']['cannot_post']['reason'], '</div>'; } if (!empty($_SESSION['ban']['expire_time'])) { echo ' <div>', sprintf($txt['your_ban_expires'], timeformat($_SESSION['ban']['expire_time'], false)), '</div>'; } else { echo ' <div>', $txt['your_ban_expires_never'], '</div>'; } echo ' </div>'; } } if (isset($settings['use_default_images']) && $settings['use_default_images'] == 'defaults' && isset($settings['default_template'])) { $settings['theme_url'] = $settings['default_theme_url']; $settings['images_url'] = $settings['default_images_url']; $settings['theme_dir'] = $settings['default_theme_dir']; } }
/** * Function for editing a task. * * @uses ManageScheduledTasks template, edit_scheduled_tasks sub-template */ function EditTask() { global $context, $txt, $sourcedir, $smcFunc, $user_info, $modSettings; // Just set up some lovely context stuff. $context[$context['admin_menu_name']]['current_subsection'] = 'tasks'; $context['sub_template'] = 'edit_scheduled_tasks'; $context['page_title'] = $txt['scheduled_task_edit']; $context['server_time'] = timeformat(time(), false, 'server'); // Cleaning... if (!isset($_GET['tid'])) { fatal_lang_error('no_access', false); } $_GET['tid'] = (int) $_GET['tid']; // Saving? if (isset($_GET['save'])) { checkSession(); validateToken('admin-st'); // We'll need this for calculating the next event. require_once $sourcedir . '/ScheduledTasks.php'; // Do we have a valid offset? preg_match('~(\\d{1,2}):(\\d{1,2})~', $_POST['offset'], $matches); // If a half is empty then assume zero offset! if (!isset($matches[2]) || $matches[2] > 59) { $matches[2] = 0; } if (!isset($matches[1]) || $matches[1] > 23) { $matches[1] = 0; } // Now the offset is easy; easy peasy - except we need to offset by a few hours... $offset = $matches[1] * 3600 + $matches[2] * 60 - date('Z'); // The other time bits are simple! $interval = max((int) $_POST['regularity'], 1); $unit = in_array(substr($_POST['unit'], 0, 1), array('m', 'h', 'd', 'w')) ? substr($_POST['unit'], 0, 1) : 'd'; // Don't allow one minute intervals. if ($interval == 1 && $unit == 'm') { $interval = 2; } // Is it disabled? $disabled = !isset($_POST['enabled']) ? 1 : 0; // Do the update! $smcFunc['db_query']('', ' UPDATE {db_prefix}scheduled_tasks SET disabled = {int:disabled}, time_offset = {int:time_offset}, time_unit = {string:time_unit}, time_regularity = {int:time_regularity} WHERE id_task = {int:id_task}', array('disabled' => $disabled, 'time_offset' => $offset, 'time_regularity' => $interval, 'id_task' => $_GET['tid'], 'time_unit' => $unit)); // Check the next event. CalculateNextTrigger($_GET['tid'], true); // Return to the main list. redirectexit('action=admin;area=scheduledtasks'); } // Load the task, understand? Que? Que? $request = $smcFunc['db_query']('', ' SELECT id_task, next_time, time_offset, time_regularity, time_unit, disabled, task FROM {db_prefix}scheduled_tasks WHERE id_task = {int:id_task}', array('id_task' => $_GET['tid'])); // Should never, ever, happen! if ($smcFunc['db_num_rows']($request) == 0) { fatal_lang_error('no_access', false); } while ($row = $smcFunc['db_fetch_assoc']($request)) { $context['task'] = array('id' => $row['id_task'], 'function' => $row['task'], 'name' => isset($txt['scheduled_task_' . $row['task']]) ? $txt['scheduled_task_' . $row['task']] : $row['task'], 'desc' => isset($txt['scheduled_task_desc_' . $row['task']]) ? $txt['scheduled_task_desc_' . $row['task']] : '', 'next_time' => $row['disabled'] ? $txt['scheduled_tasks_na'] : timeformat($row['next_time'] == 0 ? time() : $row['next_time'], true, 'server'), 'disabled' => $row['disabled'], 'offset' => $row['time_offset'], 'regularity' => $row['time_regularity'], 'offset_formatted' => date('H:i', $row['time_offset']), 'unit' => $row['time_unit']); } $smcFunc['db_free_result']($request); createToken('admin-st'); }
function template_singleshout($row) { global $scripturl, $context, $settings, $txt; $layoutOptions = array('0' => ' <div style="padding-bottom: 5px;"> <div class="tp_shoutcontainer"> <div class="tp_shoutavatar"> <div class="avy2"><a href="' . $scripturl . '?action=profile;u=' . $row['value5'] . '">' . $row['avatar'] . '</a></div> ' . (allowedTo('tp_can_admin_shout') ? ' <div style="float: right; margin-bottom: 3px;"> <a href="' . $scripturl . '?action=tpmod;shout=admin;s=' . $row['id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '"><img src="' . $settings['tp_images_url'] . '/TPmodify.gif" alt="' . $txt['tp-edit'] . '" /></a> <a onclick="TPupdateShouts(\'del\', ' . $row['id'] . '); return false;" class="shout_delete" title="' . $txt['tp-delete'] . '" href="' . $scripturl . '?action=tpmod;shout=del;s=' . $row['id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '"><img src="' . $settings['tp_images_url'] . '/tp-delete_shout.gif" alt="' . $txt['tp-delete'] . '" /></a> </div>' : '') . ' <h4><a href="' . $scripturl . '?action=profile;u=' . $row['value5'] . '">' . $row['realName'] . '</a></h4> <div class="smalltext clear" style="padding-top: .5em;">' . timeformat($row['value2']) . '</div> </div> <div class="bubble speech">' . $row['value1'] . '</div> </div> </div>', '1' => ' <div style="padding-bottom: 5px;"> <div class="tp_shoutcontainer"> <div class="shout_options"> ' . $row['realName'] . ': ' . (allowedTo('tp_can_admin_shout') ? ' <a href="' . $scripturl . '?action=tpmod;shout=admin;s=' . $row['id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '"><img src="' . $settings['tp_images_url'] . '/TPmodify.gif" alt="' . $txt['tp-edit'] . '" /></a> <a onclick="TPupdateShouts(\'del\', ' . $row['id'] . '); return false;" class="shout_delete" title="' . $txt['tp-delete'] . '" href="' . $scripturl . '?action=tpmod;shout=del;s=' . $row['id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '"><img src="' . $settings['tp_images_url'] . '/tp-delete_shout.gif" alt="' . $txt['tp-delete'] . '" /></a>' : '') . ' </div> <div class="shout_date">' . date('M. d Y - g:ia', $row['value2']) . '</div> <div class="shoutbody_layout1">' . $row['value1'] . '</div> </div> </div>'); return $layoutOptions[$context['TPortal']['shoutbox_layout']]; }
function ViewErrorLog() { global $scripturl, $txt, $context, $modSettings, $user_profile, $filter, $boarddir, $sourcedir, $themedir, $smcFunc; // Viewing contents of a file? if (isset($_GET['file'])) { return ViewFile(); } // Check for the administrative permission to do this. isAllowedTo('admin_forum'); // Templates, etc... loadLanguage('ManageMaintenance'); loadTemplate('Errors'); // You can filter by any of the following columns: $filters = array('id_member' => $txt['username'], 'ip' => $txt['ip_address'], 'session' => $txt['session'], 'url' => $txt['error_url'], 'message' => $txt['error_message'], 'error_type' => $txt['error_type'], 'file' => $txt['file'], 'line' => $txt['line']); // Set up the filtering... if (isset($_GET['value'], $_GET['filter']) && isset($filters[$_GET['filter']])) { $filter = array('variable' => $_GET['filter'], 'value' => array('sql' => in_array($_GET['filter'], array('message', 'url', 'file')) ? base64_decode(strtr($_GET['value'], array(' ' => '+'))) : $smcFunc['db_escape_wildcard_string']($_GET['value'])), 'href' => ';filter=' . $_GET['filter'] . ';value=' . $_GET['value'], 'entity' => $filters[$_GET['filter']]); } // Deleting, are we? if (isset($_POST['delall']) || isset($_POST['delete'])) { deleteErrors(); } // Just how many errors are there? $result = $smcFunc['db_query']('', ' SELECT COUNT(*) FROM {db_prefix}log_errors' . (isset($filter) ? ' WHERE ' . $filter['variable'] . ' LIKE {string:filter}' : ''), array('filter' => isset($filter) ? $filter['value']['sql'] : '')); list($num_errors) = $smcFunc['db_fetch_row']($result); $smcFunc['db_free_result']($result); // If this filter is empty... if ($num_errors == 0 && isset($filter)) { redirectexit('action=admin;area=logs;sa=errorlog' . (isset($_REQUEST['desc']) ? ';desc' : '')); } // Clean up start. if (!isset($_GET['start']) || $_GET['start'] < 0) { $_GET['start'] = 0; } // Do we want to reverse error listing? $context['sort_direction'] = isset($_REQUEST['desc']) ? 'down' : 'up'; // Set the page listing up. $context['page_index'] = constructPageIndex($scripturl . '?action=admin;area=logs;sa=errorlog' . ($context['sort_direction'] == 'down' ? ';desc' : '') . (isset($filter) ? $filter['href'] : ''), $_GET['start'], $num_errors, $modSettings['defaultMaxMessages']); $context['start'] = $_GET['start']; // Find and sort out the errors. $request = $smcFunc['db_query']('', ' SELECT id_error, id_member, ip, url, log_time, message, session, error_type, file, line FROM {db_prefix}log_errors' . (isset($filter) ? ' WHERE ' . $filter['variable'] . ' LIKE {string:filter}' : '') . ' ORDER BY id_error ' . ($context['sort_direction'] == 'down' ? 'DESC' : '') . ' LIMIT ' . $_GET['start'] . ', ' . $modSettings['defaultMaxMessages'], array('filter' => isset($filter) ? $filter['value']['sql'] : '')); $context['errors'] = array(); $members = array(); for ($i = 0; $row = $smcFunc['db_fetch_assoc']($request); $i++) { $search_message = preg_replace('~<span class="remove">(.+?)</span>~', '%', $smcFunc['db_escape_wildcard_string']($row['message'])); if ($search_message == $filter['value']['sql']) { $search_message = $smcFunc['db_escape_wildcard_string']($row['message']); } $show_message = strtr(strtr(preg_replace('~<span class="remove">(.+?)</span>~', '$1', $row['message']), array("\r" => '', '<br />' => "\n", '<' => '<', '>' => '>', '"' => '"')), array("\n" => '<br />')); $context['errors'][$row['id_error']] = array('alternate' => $i % 2 == 0, 'member' => array('id' => $row['id_member'], 'ip' => $row['ip'], 'session' => $row['session']), 'time' => timeformat($row['log_time']), 'timestamp' => $row['log_time'], 'url' => array('html' => htmlspecialchars((substr($row['url'], 0, 1) == '?' ? $scripturl : '') . $row['url']), 'href' => base64_encode($smcFunc['db_escape_wildcard_string']($row['url']))), 'message' => array('html' => $show_message, 'href' => base64_encode($search_message)), 'id' => $row['id_error'], 'error_type' => array('type' => $row['error_type'], 'name' => isset($txt['errortype_' . $row['error_type']]) ? $txt['errortype_' . $row['error_type']] : $row['error_type']), 'file' => array()); if (!empty($row['file']) && !empty($row['line'])) { // Eval'd files rarely point to the right location and cause havoc for linking, so don't link them. $linkfile = strpos($row['file'], 'eval') === false || strpos($row['file'], '?') === false; // De Morgan's Law. Want this true unless both are present. $context['errors'][$row['id_error']]['file'] = array('file' => $row['file'], 'line' => $row['line'], 'href' => $scripturl . '?action=admin;area=logs;sa=errorlog;file=' . base64_encode($row['file']) . ';line=' . $row['line'], 'link' => $linkfile ? '<a href="' . $scripturl . '?action=admin;area=logs;sa=errorlog;file=' . base64_encode($row['file']) . ';line=' . $row['line'] . '" onclick="return reqWin(this.href, 600, 400, false);">' . $row['file'] . '</a>' : $row['file'], 'search' => base64_encode($row['file'])); } // Make a list of members to load later. $members[$row['id_member']] = $row['id_member']; } $smcFunc['db_free_result']($request); // Load the member data. if (!empty($members)) { // Get some additional member info... $request = $smcFunc['db_query']('', ' SELECT id_member, member_name, real_name FROM {db_prefix}members WHERE id_member IN ({array_int:member_list}) LIMIT ' . count($members), array('member_list' => $members)); while ($row = $smcFunc['db_fetch_assoc']($request)) { $members[$row['id_member']] = $row; } $smcFunc['db_free_result']($request); // This is a guest... $members[0] = array('id_member' => 0, 'member_name' => '', 'real_name' => $txt['guest_title']); // Go through each error and tack the data on. foreach ($context['errors'] as $id => $dummy) { $memID = $context['errors'][$id]['member']['id']; $context['errors'][$id]['member']['username'] = $members[$memID]['member_name']; $context['errors'][$id]['member']['name'] = $members[$memID]['real_name']; $context['errors'][$id]['member']['href'] = empty($memID) ? '' : $scripturl . '?action=profile;u=' . $memID; $context['errors'][$id]['member']['link'] = empty($memID) ? $txt['guest_title'] : '<a href="' . $scripturl . '?action=profile;u=' . $memID . '">' . $context['errors'][$id]['member']['name'] . '</a>'; } } // Filtering anything? if (isset($filter)) { $context['filter'] =& $filter; // Set the filtering context. if ($filter['variable'] == 'id_member') { $id = $filter['value']['sql']; loadMemberData($id, false, 'minimal'); $context['filter']['value']['html'] = '<a href="' . $scripturl . '?action=profile;u=' . $id . '">' . $user_profile[$id]['real_name'] . '</a>'; } elseif ($filter['variable'] == 'url') { $context['filter']['value']['html'] = '\'' . strtr(htmlspecialchars((substr($filter['value']['sql'], 0, 1) == '?' ? $scripturl : '') . $filter['value']['sql']), array('\\_' => '_')) . '\''; } elseif ($filter['variable'] == 'message') { $context['filter']['value']['html'] = '\'' . strtr(htmlspecialchars($filter['value']['sql']), array("\n" => '<br />', '<br />' => '<br />', "\t" => ' ', '\\_' => '_', '\\%' => '%', '\\\\' => '\\')) . '\''; $context['filter']['value']['html'] = preg_replace('~&lt;span class=&quot;remove&quot;&gt;(.+?)&lt;/span&gt;~', '$1', $context['filter']['value']['html']); } elseif ($filter['variable'] == 'error_type') { $context['filter']['value']['html'] = '\'' . strtr(htmlspecialchars($filter['value']['sql']), array("\n" => '<br />', '<br />' => '<br />', "\t" => ' ', '\\_' => '_', '\\%' => '%', '\\\\' => '\\')) . '\''; } else { $context['filter']['value']['html'] =& $filter['value']['sql']; } } $context['error_types'] = array(); $context['error_types']['all'] = array('label' => $txt['errortype_all'], 'description' => isset($txt['errortype_all_desc']) ? $txt['errortype_all_desc'] : '', 'url' => $scripturl . '?action=admin;area=logs;sa=errorlog' . ($context['sort_direction'] == 'down' ? ';desc' : ''), 'is_selected' => empty($filter)); $sum = 0; // What type of errors do we have and how many do we have? $request = $smcFunc['db_query']('', ' SELECT error_type, COUNT(*) AS num_errors FROM {db_prefix}log_errors GROUP BY error_type ORDER BY error_type = {string:critical_type} DESC, error_type ASC', array('critical_type' => 'critical')); while ($row = $smcFunc['db_fetch_assoc']($request)) { // Total errors so far? $sum += $row['num_errors']; $context['error_types'][$sum] = array('label' => (isset($txt['errortype_' . $row['error_type']]) ? $txt['errortype_' . $row['error_type']] : $row['error_type']) . ' (' . $row['num_errors'] . ')', 'description' => isset($txt['errortype_' . $row['error_type'] . '_desc']) ? $txt['errortype_' . $row['error_type'] . '_desc'] : '', 'url' => $scripturl . '?action=admin;area=logs;sa=errorlog' . ($context['sort_direction'] == 'down' ? ';desc' : '') . ';filter=error_type;value=' . $row['error_type'], 'is_selected' => isset($filter) && $filter['value']['sql'] == $smcFunc['db_escape_wildcard_string']($row['error_type'])); } $smcFunc['db_free_result']($request); // Update the all errors tab with the total number of errors $context['error_types']['all']['label'] .= ' (' . $sum . ')'; // Finally, work out what is the last tab! if (isset($context['error_types'][$sum])) { $context['error_types'][$sum]['is_last'] = true; } else { $context['error_types']['all']['is_last'] = true; } // And this is pretty basic ;). $context['page_title'] = $txt['errlog']; $context['has_filter'] = isset($filter); $context['sub_template'] = 'error_log'; }
function list_getModLogEntries($start, $items_per_page, $sort, $query_string = '', $query_params = array(), $log_type = 1) { global $context, $scripturl, $txt, $smcFunc, $user_info; $modlog_query = allowedTo('admin_forum') || $user_info['mod_cache']['bq'] == '1=1' ? '1=1' : ($user_info['mod_cache']['bq'] == '0=1' ? 'lm.id_board = 0 AND lm.id_topic = 0' : strtr($user_info['mod_cache']['bq'], array('id_board' => 'b.id_board')) . ' AND ' . strtr($user_info['mod_cache']['bq'], array('id_board' => 't.id_board'))); // Do a little bit of self protection. if (!isset($context['hoursdisable'])) { $context['hoursdisable'] = 24; } // Can they see the IP address? $seeIP = allowedTo('moderate_forum'); // Here we have the query getting the log details. $result = $smcFunc['db_query']('', ' SELECT lm.id_action, lm.id_member, lm.ip, lm.log_time, lm.action, lm.id_board, lm.id_topic, lm.id_msg, lm.extra, mem.real_name, mg.group_name FROM {db_prefix}log_actions AS lm LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = lm.id_member) LEFT JOIN {db_prefix}membergroups AS mg ON (mg.id_group = CASE WHEN mem.id_group = {int:reg_group_id} THEN mem.id_post_group ELSE mem.id_group END) LEFT JOIN {db_prefix}boards AS b ON (b.id_board = lm.id_board) LEFT JOIN {db_prefix}topics AS t ON (t.id_topic = lm.id_topic) WHERE id_log = {int:log_type} AND {raw:modlog_query}' . (!empty($query_string) ? ' AND ' . $query_string : '') . ' ORDER BY ' . $sort . ' LIMIT ' . $start . ', ' . $items_per_page, array_merge($query_params, array('reg_group_id' => 0, 'log_type' => $log_type, 'modlog_query' => $modlog_query))); // Arrays for decoding objects into. $topics = array(); $boards = array(); $members = array(); $messages = array(); $entries = array(); while ($row = $smcFunc['db_fetch_assoc']($result)) { $row['extra'] = @unserialize($row['extra']); // Corrupt? $row['extra'] = is_array($row['extra']) ? $row['extra'] : array(); // Add on some of the column stuff info if (!empty($row['id_board'])) { if ($row['action'] == 'move') { $row['extra']['board_to'] = $row['id_board']; } else { $row['extra']['board'] = $row['id_board']; } } if (!empty($row['id_topic'])) { $row['extra']['topic'] = $row['id_topic']; } if (!empty($row['id_msg'])) { $row['extra']['message'] = $row['id_msg']; } // Is this associated with a topic? if (isset($row['extra']['topic'])) { $topics[(int) $row['extra']['topic']][] = $row['id_action']; } if (isset($row['extra']['new_topic'])) { $topics[(int) $row['extra']['new_topic']][] = $row['id_action']; } // How about a member? if (isset($row['extra']['member'])) { // Guests don't have names! if (empty($row['extra']['member'])) { $row['extra']['member'] = $txt['modlog_parameter_guest']; } else { // Try to find it... $members[(int) $row['extra']['member']][] = $row['id_action']; } } // Associated with a board? if (isset($row['extra']['board_to'])) { $boards[(int) $row['extra']['board_to']][] = $row['id_action']; } if (isset($row['extra']['board_from'])) { $boards[(int) $row['extra']['board_from']][] = $row['id_action']; } if (isset($row['extra']['board'])) { $boards[(int) $row['extra']['board']][] = $row['id_action']; } // A message? if (isset($row['extra']['message'])) { $messages[(int) $row['extra']['message']][] = $row['id_action']; } // IP Info? if (isset($row['extra']['ip_range'])) { if ($seeIP) { $row['extra']['ip_range'] = '<a href="' . $scripturl . '?action=trackip;searchip=' . $row['extra']['ip_range'] . '">' . $row['extra']['ip_range'] . '</a>'; } else { $row['extra']['ip_range'] = $txt['logged']; } } // Email? if (isset($row['extra']['email'])) { $row['extra']['email'] = '<a href="mailto:' . $row['extra']['email'] . '">' . $row['extra']['email'] . '</a>'; } // Bans are complex. if ($row['action'] == 'ban') { $row['action_text'] = $txt['modlog_ac_ban']; foreach (array('member', 'email', 'ip_range', 'hostname') as $type) { if (isset($row['extra'][$type])) { $row['action_text'] .= $txt['modlog_ac_ban_trigger_' . $type]; } } } // The array to go to the template. Note here that action is set to a "default" value of the action doesn't match anything in the descriptions. Allows easy adding of logging events with basic details. $entries[$row['id_action']] = array('id' => $row['id_action'], 'ip' => $seeIP ? $row['ip'] : $txt['logged'], 'position' => empty($row['real_name']) && empty($row['group_name']) ? $txt['guest'] : $row['group_name'], 'moderator_link' => $row['id_member'] ? '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>' : (empty($row['real_name']) ? $txt['guest'] . (!empty($row['extra']['member_acted']) ? ' (' . $row['extra']['member_acted'] . ')' : '') : $row['real_name']), 'time' => timeformat($row['log_time']), 'timestamp' => forum_time(true, $row['log_time']), 'editable' => time() > $row['log_time'] + $context['hoursdisable'] * 3600, 'extra' => $row['extra'], 'action' => $row['action'], 'action_text' => isset($row['action_text']) ? $row['action_text'] : ''); } $smcFunc['db_free_result']($result); if (!empty($boards)) { $request = $smcFunc['db_query']('', ' SELECT id_board, name FROM {db_prefix}boards WHERE id_board IN ({array_int:board_list}) LIMIT ' . count(array_keys($boards)), array('board_list' => array_keys($boards))); while ($row = $smcFunc['db_fetch_assoc']($request)) { foreach ($boards[$row['id_board']] as $action) { // Make the board number into a link - dealing with moving too. if (isset($entries[$action]['extra']['board_to']) && $entries[$action]['extra']['board_to'] == $row['id_board']) { $entries[$action]['extra']['board_to'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; } elseif (isset($entries[$action]['extra']['board_from']) && $entries[$action]['extra']['board_from'] == $row['id_board']) { $entries[$action]['extra']['board_from'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; } elseif (isset($entries[$action]['extra']['board']) && $entries[$action]['extra']['board'] == $row['id_board']) { $entries[$action]['extra']['board'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; } } } $smcFunc['db_free_result']($request); } if (!empty($topics)) { $request = $smcFunc['db_query']('', ' SELECT ms.subject, t.id_topic FROM {db_prefix}topics AS t INNER JOIN {db_prefix}messages AS ms ON (ms.id_msg = t.id_first_msg) WHERE t.id_topic IN ({array_int:topic_list}) LIMIT ' . count(array_keys($topics)), array('topic_list' => array_keys($topics))); while ($row = $smcFunc['db_fetch_assoc']($request)) { foreach ($topics[$row['id_topic']] as $action) { $this_action =& $entries[$action]; // This isn't used in the current theme. $this_action['topic'] = array('id' => $row['id_topic'], 'subject' => $row['subject'], 'href' => $scripturl . '?topic=' . $row['id_topic'] . '.0', 'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['subject'] . '</a>'); // Make the topic number into a link - dealing with splitting too. if (isset($this_action['extra']['topic']) && $this_action['extra']['topic'] == $row['id_topic']) { $this_action['extra']['topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>'; } elseif (isset($this_action['extra']['new_topic']) && $this_action['extra']['new_topic'] == $row['id_topic']) { $this_action['extra']['new_topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>'; } } } $smcFunc['db_free_result']($request); } if (!empty($messages)) { $request = $smcFunc['db_query']('', ' SELECT id_msg, subject FROM {db_prefix}messages WHERE id_msg IN ({array_int:message_list}) LIMIT ' . count(array_keys($messages)), array('message_list' => array_keys($messages))); while ($row = $smcFunc['db_fetch_assoc']($request)) { foreach ($messages[$row['id_msg']] as $action) { $this_action =& $entries[$action]; // This isn't used in the current theme. $this_action['message'] = array('id' => $row['id_msg'], 'subject' => $row['subject'], 'href' => $scripturl . '?msg=' . $row['id_msg'], 'link' => '<a href="' . $scripturl . '?msg=' . $row['id_msg'] . '">' . $row['subject'] . '</a>'); // Make the message number into a link. if (isset($this_action['extra']['message']) && $this_action['extra']['message'] == $row['id_msg']) { $this_action['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; } } } $smcFunc['db_free_result']($request); } if (!empty($members)) { $request = $smcFunc['db_query']('', ' SELECT real_name, id_member FROM {db_prefix}members WHERE id_member IN ({array_int:member_list}) LIMIT ' . count(array_keys($members)), array('member_list' => array_keys($members))); while ($row = $smcFunc['db_fetch_assoc']($request)) { foreach ($members[$row['id_member']] as $action) { // Not used currently. $entries[$action]['member'] = array('id' => $row['id_member'], 'name' => $row['real_name'], 'href' => $scripturl . '?action=profile;u=' . $row['id_member'], 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'); // Make the member number into a name. $entries[$action]['extra']['member'] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; } } $smcFunc['db_free_result']($request); } // Do some formatting of the action string. foreach ($entries as $k => $entry) { // Make any message info links so its easier to go find that message. if (isset($entry['extra']['message']) && (empty($entry['message']) || empty($entry['message']['id']))) { $entries[$k]['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $entry['extra']['message'] . '">' . $entry['extra']['message'] . '</a>'; } // Mark up any deleted members, topics and boards. foreach (array('board', 'board_from', 'board_to', 'member', 'topic', 'new_topic') as $type) { if (!empty($entry['extra'][$type]) && is_numeric($entry['extra'][$type])) { $entries[$k]['extra'][$type] = sprintf($txt['modlog_id'], $entry['extra'][$type]); } } if (empty($entries[$k]['action_text'])) { $entries[$k]['action_text'] = isset($txt['modlog_ac_' . $entry['action']]) ? $txt['modlog_ac_' . $entry['action']] : $entry['action']; } $entries[$k]['action_text'] = preg_replace('~\\{([A-Za-z\\d_]+)\\}~ie', 'isset($entries[$k][\'extra\'][\'$1\']) ? $entries[$k][\'extra\'][\'$1\'] : \'\'', $entries[$k]['action_text']); } // Back we go! return $entries; }