本文整理汇总了PHP中URL::topic方法的典型用法代码示例。如果您正苦于以下问题:PHP URL::topic方法的具体用法?PHP URL::topic怎么用?PHP URL::topic使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类URL
的用法示例。
在下文中一共展示了URL::topic方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getLastPosts
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;
}
示例2: LikesByUser
/**
* @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');
}
示例3: getBoardIndex
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();
}
//.........这里部分代码省略.........
示例4: __construct
function __construct($request, $total_items, $not_profile = false)
{
global $context, $txt, $user_info, $scripturl, $options, $memberContext, $modSettings;
if (!isset($context['pageindex_multiplier'])) {
$context['pageindex_multiplier'] = commonAPI::getMessagesPerPage();
}
$cb_name = isset($context['cb_name']) ? $context['cb_name'] : 'topics[]';
while ($row = mysql_fetch_assoc($request)) {
censorText($row['subject']);
$this->topic_ids[] = $row['id_topic'];
$f_post_mem_href = !empty($row['id_member']) ? URL::user($row['id_member'], $row['first_member_name']) : '';
$t_href = URL::topic($row['id_topic'], $row['subject'], 0);
$l_post_mem_href = !empty($row['id_member_updated']) ? URL::user($row['id_member_updated'], $row['last_real_name']) : '';
$l_post_msg_href = URL::topic($row['id_topic'], $row['last_subject'], $user_info['is_guest'] ? !empty($options['view_newest_first']) ? 0 : (int) ($row['num_replies'] / $context['pageindex_multiplier']) * $context['pageindex_multiplier'] : 0, $user_info['is_guest'] ? true : false, $user_info['is_guest'] ? '' : '.msg' . $row['id_last_msg'], $user_info['is_guest'] ? '#msg' . $row['id_last_msg'] : '#new');
$this->topiclist[$row['id_topic']] = array('id' => $row['id_topic'], 'id_member_started' => empty($row['id_member']) ? 0 : $row['id_member'], 'first_post' => array('id' => $row['id_first_msg'], 'member' => array('username' => $row['first_member_name'], 'name' => $row['first_member_name'], 'id' => empty($row['id_member']) ? 0 : $row['id_member'], 'href' => $f_post_mem_href, 'link' => !empty($row['id_member']) ? '<a onclick="getMcard(' . $row['id_member'] . ', $(this));return(false);" href="' . $f_post_mem_href . '" title="' . $txt['profile_of'] . ' ' . $row['first_member_name'] . '">' . $row['first_member_name'] . '</a>' : $row['first_member_name']), 'time' => timeformat($row['first_poster_time']), 'timestamp' => forum_time(true, $row['first_poster_time']), 'subject' => $row['subject'], 'icon' => $row['first_icon'], 'icon_url' => getPostIcon($row['first_icon']), 'href' => $t_href, 'link' => '<a href="' . $t_href . '">' . $row['subject'] . '</a>'), 'last_post' => array('id' => $row['id_last_msg'], 'member' => array('username' => $row['last_real_name'], 'name' => $row['last_real_name'], 'id' => $row['id_member_updated'], 'href' => $l_post_mem_href, 'link' => !empty($row['id_member_updated']) ? '<a onclick="getMcard(' . $row['id_member_updated'] . ', $(this));return(false);" href="' . $l_post_mem_href . '">' . $row['last_real_name'] . '</a>' : $row['last_real_name']), 'time' => timeformat($row['last_post_time']), 'timestamp' => forum_time(true, $row['last_post_time']), 'subject' => $row['last_subject'], 'href' => $l_post_msg_href, 'link' => '<a href="' . $l_post_msg_href . ($row['num_replies'] == 0 ? '' : ' rel="nofollow"') . '>' . $row['last_subject'] . '</a>'), 'checkbox_name' => $cb_name, 'subject' => $row['subject'], 'new' => $row['new_from'] <= $row['id_msg_modified'], 'new_from' => $row['new_from'], 'newtime' => $row['new_from'], 'updated' => timeformat($row['poster_time']), 'new_href' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['new_from'] . '#new', 'new_link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['new_from'] . '#new">' . $row['subject'] . '</a>', 'replies' => comma_format($row['num_replies']), 'views' => comma_format($row['num_views']), 'approved' => $row['approved'], 'unapproved_posts' => $row['unapproved_posts'], 'is_old' => !empty($modSettings['oldTopicDays']) ? $context['time_now'] - $row['last_post_time'] > $modSettings['oldTopicDays'] * 86400 : false, 'is_posted_in' => false, 'prefix' => '', 'pages' => '', 'is_sticky' => !empty($modSettings['enableStickyTopics']) && !empty($row['is_sticky']), 'is_locked' => !empty($row['locked']), 'is_poll' => false, 'is_hot' => $row['num_replies'] >= $modSettings['hotTopicPosts'], 'is_very_hot' => $row['num_replies'] >= $modSettings['hotTopicVeryPosts'], 'board' => isset($row['id_board']) && !empty($row['id_board']) ? array('name' => $row['board_name'], 'id' => $row['id_board'], 'href' => URL::board($row['id_board'], $row['board_name'])) : array('name' => '', 'id' => 0, 'href' => ''));
determineTopicClass($this->topiclist[$row['id_topic']]);
if (!empty($row['id_member']) && ($row['id_member'] != $user_info['id'] || $not_profile)) {
$this->users_to_load[$row['id_member']] = $row['id_member'];
}
}
loadMemberData($this->users_to_load);
foreach ($this->topiclist as &$topic) {
if (!isset($memberContext[$topic['id_member_started']])) {
loadMemberContext($topic['id_member_started']);
}
$topic['first_post']['member']['avatar'] =& $memberContext[$topic['id_member_started']]['avatar']['image'];
}
// figure out whether we have posted in a topic (but only if we are not the topic starter)
if (!empty($modSettings['enableParticipation']) && !$user_info['is_guest'] && !empty($this->topic_ids)) {
$result = smf_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($this->topic_ids), array('current_member' => $user_info['id'], 'topic_list' => $this->topic_ids));
while ($row = mysql_fetch_assoc($result)) {
if ($this->topiclist[$row['id_topic']]['first_post']['member']['id'] != $user_info['id']) {
$this->topiclist[$row['id_topic']]['is_posted_in'] = true;
}
}
mysql_free_result($result);
}
}
示例5: Display
function Display()
{
global $scripturl, $txt, $modSettings, $context, $settings, $memberContext, $output;
global $options, $sourcedir, $user_info, $user_profile, $board_info, $topic, $board;
global $attachments, $messages_request, $topicinfo, $language;
$context['response_prefixlen'] = strlen($txt['response_prefix']);
$context['need_synhlt'] = true;
$context['is_display_std'] = true;
$context['pcache_update_counter'] = !empty($modSettings['use_post_cache']) ? 0 : PCACHE_UPDATE_PER_VIEW + 1;
$context['time_cutoff_ref'] = time();
$context['template_hooks']['display'] = array('header' => '', 'extend_topicheader' => '', 'above_posts' => '', 'below_posts' => '', 'footer' => '');
//EoS_Smarty::getConfigInstance()->registerHookTemplate('postbit_below', 'overrides/foo');
if (!empty($modSettings['karmaMode'])) {
require_once $sourcedir . '/lib/Subs-Ratings.php';
} else {
$context['can_see_like'] = $context['can_give_like'] = false;
}
// What are you gonna display if these are empty?!
if (empty($topic)) {
fatal_lang_error('no_board', false);
}
// Not only does a prefetch make things slower for the server, but it makes it impossible to know if they read it.
if (isset($_SERVER['HTTP_X_MOZ']) && $_SERVER['HTTP_X_MOZ'] == 'prefetch') {
ob_end_clean();
header('HTTP/1.1 403 Prefetch Forbidden');
die;
}
// How much are we sticking on each page?
$context['messages_per_page'] = commonAPI::getMessagesPerPage();
$context['page_number'] = isset($_REQUEST['start']) ? $_REQUEST['start'] / $context['messages_per_page'] : 0;
// Let's do some work on what to search index.
//$context['multiquote_cookiename'] = 'mq_' . $context['current_topic'];
$context['multiquote_posts'] = array();
if (isset($_COOKIE[$context['multiquote_cookiename']]) && strlen($_COOKIE[$context['multiquote_cookiename']]) > 1) {
$context['multiquote_posts'] = explode(',', $_COOKIE[$context['multiquote_cookiename']]);
}
$context['multiquote_posts_count'] = count($context['multiquote_posts']);
if (count($_GET) > 2) {
foreach ($_GET as $k => $v) {
if (!in_array($k, array('topic', '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;
}
// Find the previous or next topic. Make a fuss if there are no more.
if (isset($_REQUEST['prev_next']) && ($_REQUEST['prev_next'] == 'prev' || $_REQUEST['prev_next'] == 'next')) {
// No use in calculating the next topic if there's only one.
if ($board_info['num_topics'] > 1) {
// Just prepare some variables that are used in the query.
$gt_lt = $_REQUEST['prev_next'] == 'prev' ? '>' : '<';
$order = $_REQUEST['prev_next'] == 'prev' ? '' : ' DESC';
$request = smf_db_query('
SELECT t2.id_topic
FROM {db_prefix}topics AS t
INNER JOIN {db_prefix}topics AS t2 ON (' . (empty($modSettings['enableStickyTopics']) ? '
t2.id_last_msg ' . $gt_lt . ' t.id_last_msg' : '
(t2.id_last_msg ' . $gt_lt . ' t.id_last_msg AND t2.is_sticky ' . $gt_lt . '= t.is_sticky) OR t2.is_sticky ' . $gt_lt . ' t.is_sticky') . ')
WHERE t.id_topic = {int:current_topic}
AND t2.id_board = {int:current_board}' . (!$modSettings['postmod_active'] || allowedTo('approve_posts') ? '' : '
AND (t2.approved = {int:is_approved} OR (t2.id_member_started != {int:id_member_started} AND t2.id_member_started = {int:current_member}))') . '
ORDER BY' . (empty($modSettings['enableStickyTopics']) ? '' : ' t2.is_sticky' . $order . ',') . ' t2.id_last_msg' . $order . '
LIMIT 1', array('current_board' => $board, 'current_member' => $user_info['id'], 'current_topic' => $topic, 'is_approved' => 1, 'id_member_started' => 0));
// No more left.
if (mysql_num_rows($request) == 0) {
mysql_free_result($request);
// Roll over - if we're going prev, get the last - otherwise the first.
$request = smf_db_query('
SELECT id_topic
FROM {db_prefix}topics
WHERE id_board = {int:current_board}' . (!$modSettings['postmod_active'] || allowedTo('approve_posts') ? '' : '
AND (approved = {int:is_approved} OR (id_member_started != {int:id_member_started} AND id_member_started = {int:current_member}))') . '
ORDER BY' . (empty($modSettings['enableStickyTopics']) ? '' : ' is_sticky' . $order . ',') . ' id_last_msg' . $order . '
LIMIT 1', array('current_board' => $board, 'current_member' => $user_info['id'], 'is_approved' => 1, 'id_member_started' => 0));
}
// Now you can be sure $topic is the id_topic to view.
list($topic) = mysql_fetch_row($request);
mysql_free_result($request);
$context['current_topic'] = $topic;
}
// Go to the newest message on this topic.
$_REQUEST['start'] = 'new';
}
// Add 1 to the number of views of this topic.
if (empty($_SESSION['last_read_topic']) || $_SESSION['last_read_topic'] != $topic) {
smf_db_query('
UPDATE {db_prefix}topics
SET num_views = num_views + 1
WHERE id_topic = {int:current_topic}', array('current_topic' => $topic));
$_SESSION['last_read_topic'] = $topic;
}
if ($modSettings['tags_active']) {
$dbresult = smf_db_query('
SELECT t.tag,l.ID,t.ID_TAG FROM {db_prefix}tags_log as l, {db_prefix}tags as t
WHERE t.ID_TAG = l.ID_TAG && l.ID_TOPIC = {int:topic}', array('topic' => $topic));
$context['topic_tags'] = array();
while ($row = mysql_fetch_assoc($dbresult)) {
$context['topic_tags'][] = array('ID' => $row['ID'], 'ID_TAG' => $row['ID_TAG'], 'tag' => $row['tag']);
//.........这里部分代码省略.........
示例6: template_boardbit
function template_boardbit(&$board)
{
global $context, $txt, $scripturl, $options, $settings;
if ($board['act_as_cat']) {
return template_boardbit_subcat($board);
}
echo '
<li id="board_', $board['id'], '" class="boardrow gradient_darken_down">';
if (!$board['is_page']) {
echo '
<div class="info">
<div class="icon floatleft">
<a href="', $board['is_redirect'] || $context['user']['is_guest'] ? $board['href'] : $scripturl . '?action=unread;board=' . $board['id'] . '.0;children', '">
<div class="csrcwrapper24px">';
if (!empty($board['boardicon'])) {
echo '
<img src="', $settings['images_url'], '/boards/', $board['boardicon'], '.png" alt="', $txt['new_posts'], '" title="', $txt['new_posts'], '" />';
if ($board['new'] || $board['children_new']) {
echo '<img style="position:absolute;bottom:-4px;right:-3px;" src="', $settings['images_url'], '/new.png" />';
}
} else {
// If the board or children is new, show an indicator.
if ($board['is_redirect']) {
echo '
<img class="clipsrc _redirect" src="', $context['clip_image_src'], '" alt="*" title="*" />';
} else {
echo '
<img class="clipsrc _off" src="', $context['clip_image_src'], '" alt="', $txt['old_posts'], '" title="', $txt['old_posts'], '" />';
}
if ($board['new'] || !empty($board['children_new'])) {
echo '
<img style="position:absolute;bottom:-4px;right:-3px;" src="', $settings['images_url'], '/new.png" />';
}
}
echo '</div>
</a>
</div>
<div style="padding-left:32px;">
<a class="brd_rsslink" href="', $scripturl, '?action=.xml;type=rss;board=', $board['id'], '"> </a>';
// Show the "Moderators: ". Each has name, href, link, and id. (but we're gonna use link_moderators.)
if (!empty($board['moderators'])) {
echo '
<span onclick="brdModeratorsPopup($(this));" class="brd_moderators" title="', $txt['moderated_by'], '"><span class="brd_moderators_chld" style="display:none;">', $txt['moderated_by'], ': ', implode(', ', $board['link_moderators']), '</span></span>';
}
echo '
<h3>
<a class="boardlink easytip" data-tip="tip_b_', $board['id'], '" href="', $board['href'], '" id="b', $board['id'], '">', $board['name'], '</a>
</h3>
<div style="display:none;" id="tip_b_', $board['id'], '">', $board['description'], '</div>';
// Has it outstanding posts for approval?
if ($board['can_approve_posts'] && ($board['unapproved_posts'] || $board['unapproved_topics'])) {
echo '
<a href="', $scripturl, '?action=moderate;area=postmod;sa=', $board['unapproved_topics'] > 0 ? 'topics' : 'posts', ';brd=', $board['id'], ';', $context['session_var'], '=', $context['session_id'], '" title="', sprintf($txt['unapproved_posts'], $board['unapproved_topics'], $board['unapproved_posts']), '" class="moderation_link">(!)</a>';
}
echo '
<div class="tinytext">', $board['posts'], ' <span class="lowcontrast">', $txt['posts'], ' ', $txt['in'], '</span> ', $board['topics'], ' <span class="lowcontrast">', $txt['topics'], '</span></div>
<div class="lastpost tinytext lowcontrast">';
if (!empty($board['last_post']['id'])) {
echo empty($options['post_icons_index']) ? '' : '
<img src="' . $board['first_post']['icon_url'] . '" alt="icon" />', '
', $board['last_post']['prefix'], $board['last_post']['topiclink'], '<br />
<a class="lp_link" title="', $txt['last_post'], '" href="', $board['last_post']['href'], '">', $board['last_post']['time'], '</a>
<span class="tinytext lowcontrast" ', empty($options['post_icons_index']) ? '' : 'style="padding-left:20px;"', '>', $txt['last_post'], ' ', $txt['by'], ': </span>', $board['last_post']['member']['link'];
} else {
echo $txt['not_applicable'];
}
echo '
</div>
</div>
</div>';
} else {
echo '
<div class="info fullwidth">
<div class="icon floatleft">
<div class="csrcwrapper24px"><img class="clipsrc _page" src="', $context['clip_image_src'], '" alt="*" title="*" /></div>
</div>
<div style="padding-left:32px;">
<h3><a class="boardlink" href="', URL::topic(intval(substr($board['redirect'], 1)), $board['name'], 0), '">', $board['name'], '</a></h3>
<div class="tinytext lowcontrast">', $board['description'], '</div>
</div>
</div>';
}
// Show the "Child Boards: ". (there's a link_children but we're going to bold the new ones...)
if (!empty($board['children'])) {
template_board_children($board);
} else {
echo '
<div></div>';
}
echo '
<div class="clear_left"></div>
</li>';
}
示例7: prepareSearchContext
function prepareSearchContext($reset = false)
{
global $txt, $modSettings, $scripturl, $user_info, $sourcedir;
global $memberContext, $context, $options, $messages_request;
global $boards_can, $participants, $output;
// Remember which message this is. (ie. reply #83)
static $counter = null;
if ($counter == null || $reset) {
$counter = $_REQUEST['start'] + 1;
}
// If the query returned false, bail.
if ($messages_request == false) {
return false;
}
// Start from the beginning...
if ($reset) {
return @mysql_data_seek($messages_request, 0);
}
// Attempt to get the next message.
$message = mysql_fetch_assoc($messages_request);
if (!$message) {
return false;
}
// Can't have an empty subject can we?
$message['subject'] = $message['subject'] != '' ? $message['subject'] : $txt['no_subject'];
$message['first_subject'] = $message['first_subject'] != '' ? $message['first_subject'] : $txt['no_subject'];
$message['last_subject'] = $message['last_subject'] != '' ? $message['last_subject'] : $txt['no_subject'];
// If it couldn't load, or the user was a guest.... someday may be done with a guest table.
if (!loadMemberContext($message['id_member'])) {
// Notice this information isn't used anywhere else.... *cough guest table cough*.
$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']]['ip'] = $message['poster_ip'];
// Do the censor thang...
censorText($message['body']);
censorText($message['subject']);
censorText($message['first_subject']);
censorText($message['last_subject']);
// Shorten this message if necessary.
if ($context['compact']) {
// Set the number of characters before and after the searched keyword.
$charLimit = 50;
$message['body'] = strtr($message['body'], array("\n" => ' ', '<br />' => "\n"));
$message['body'] = parse_bbc($message['body'], $message['smileys_enabled'], $message['id_msg']);
$message['body'] = strip_tags(strtr($message['body'], array('</div>' => '<br />', '</li>' => '<br />')), '<br>');
if (commonAPI::strlen($message['body']) > $charLimit) {
if (empty($context['key_words'])) {
$message['body'] = commonAPI::substr($message['body'], 0, $charLimit) . '<strong>...</strong>';
} else {
$matchString = '';
$force_partial_word = false;
foreach ($context['key_words'] as $keyword) {
$keyword = preg_replace('~&#(\\d{1,7}|x[0-9a-fA-F]{1,6});~e', 'commonAPI::entity_fix(\'\\1\')', strtr($keyword, array('\\\'' => '\'', '&' => '&')));
if (preg_match('~[\'\\.,/@%&;:(){}\\[\\]_\\-+\\\\]$~', $keyword) != 0 || preg_match('~^[\'\\.,/@%&;:(){}\\[\\]_\\-+\\\\]~', $keyword) != 0) {
$force_partial_word = true;
}
$matchString .= strtr(preg_quote($keyword, '/'), array('\\*' => '.+?')) . '|';
}
$matchString = substr($matchString, 0, -1);
$message['body'] = un_htmlspecialchars(strtr($message['body'], array(' ' => ' ', '<br />' => "\n", '[' => '[', ']' => ']', ':' => ':', '@' => '@')));
if (empty($modSettings['search_method']) || $force_partial_word) {
preg_match_all('/([^\\s\\W]{' . $charLimit . '}[\\s\\W]|[\\s\\W].{0,' . $charLimit . '}?|^)(' . $matchString . ')(.{0,' . $charLimit . '}[\\s\\W]|[^\\s\\W]{' . $charLimit . '})/isu', $message['body'], $matches);
} else {
preg_match_all('/([^\\s\\W]{' . $charLimit . '}[\\s\\W]|[\\s\\W].{0,' . $charLimit . '}?[\\s\\W]|^)(' . $matchString . ')([\\s\\W].{0,' . $charLimit . '}[\\s\\W]|[\\s\\W][^\\s\\W]{' . $charLimit . '})/isu', $message['body'], $matches);
}
$message['body'] = '';
foreach ($matches[0] as $index => $match) {
$match = strtr(htmlspecialchars($match, ENT_QUOTES), array("\n" => ' '));
$message['body'] .= '<strong>......</strong> ' . $match . ' <strong>......</strong>';
}
}
// Re-fix the international characters.
$message['body'] = preg_replace('~&#(\\d{1,7}|x[0-9a-fA-F]{1,6});~e', 'commonAPI::entity_fix(\'\\1\')', $message['body']);
}
} else {
// Run BBC interpreter on the message.
$message['body'] = parse_bbc($message['body'], $message['smileys_enabled'], $message['id_msg']);
}
// Make sure we don't end up with a practically empty message body.
$message['body'] = preg_replace('~^(?: )+$~', '', $message['body']);
// Do we have quote tag enabled?
$quote_enabled = empty($modSettings['disabledBBC']) || !in_array('quote', explode(',', $modSettings['disabledBBC']));
$href = URL::topic($message['id_topic'], $message['first_subject'], 0);
$mhref = URL::user($message['first_member_id'], $message['first_member_name']);
$lhref = URL::topic($message['id_topic'], $message['last_subject'], 0, $message['num_replies'] == 0 ? true : false, $message['num_replies'] == 0 ? '' : '.msg' . $message['last_msg'], $message['num_replies'] == 0 ? '' : '#msg' . $message['last_msg']);
$lmhref = URL::user($message['last_member_id'], $message['last_member_name']);
$bhref = URL::board($message['id_board'], $message['board_name'], 0, true);
$output = array_merge($context['topics'][$message['id_msg']], array('id' => $message['id_topic'], 'is_sticky' => !empty($modSettings['enableStickyTopics']) && !empty($message['is_sticky']), 'is_locked' => !empty($message['locked']), 'is_poll' => $modSettings['pollMode'] == '1' && $message['id_poll'] > 0, 'is_hot' => $message['num_replies'] >= $modSettings['hotTopicPosts'], 'is_very_hot' => $message['num_replies'] >= $modSettings['hotTopicVeryPosts'], 'posted_in' => !empty($participants[$message['id_topic']]), 'views' => $message['num_views'], 'replies' => $message['num_replies'], 'can_reply' => in_array($message['id_board'], $boards_can['post_reply_any']) || in_array(0, $boards_can['post_reply_any']), 'can_quote' => (in_array($message['id_board'], $boards_can['post_reply_any']) || in_array(0, $boards_can['post_reply_any'])) && $quote_enabled, 'can_mark_notify' => in_array($message['id_board'], $boards_can['mark_any_notify']) || in_array(0, $boards_can['mark_any_notify']) && !$context['user']['is_guest'], 'first_post' => array('id' => $message['first_msg'], 'time' => timeformat($message['first_poster_time']), 'timestamp' => forum_time(true, $message['first_poster_time']), 'subject' => $message['first_subject'], 'href' => $href, 'link' => '<a href="' . $href . '">' . $message['first_subject'] . '</a>', 'icon' => $message['first_icon'], 'icon_url' => getPostIcon($message['first_icon']), 'member' => array('id' => $message['first_member_id'], 'name' => $message['first_member_name'], 'href' => !empty($message['first_member_id']) ? $mhref : '', 'link' => !empty($message['first_member_id']) ? '<a href="' . $mhref . '" title="' . $txt['profile_of'] . ' ' . $message['first_member_name'] . '">' . $message['first_member_name'] . '</a>' : $message['first_member_name'])), 'last_post' => array('id' => $message['last_msg'], 'time' => timeformat($message['last_poster_time']), 'timestamp' => forum_time(true, $message['last_poster_time']), 'subject' => $message['last_subject'], 'href' => $lhref, 'link' => '<a href="' . $lhref . '">' . $message['last_subject'] . '</a>', 'icon' => $message['last_icon'], 'icon_url' => getPostIcon($message['last_icon']), 'member' => array('id' => $message['last_member_id'], 'name' => $message['last_member_name'], 'href' => !empty($message['last_member_id']) ? $lmhref : '', 'link' => !empty($message['last_member_id']) ? '<a href="' . $lmhref . '" title="' . $txt['profile_of'] . ' ' . $message['last_member_name'] . '">' . $message['last_member_name'] . '</a>' : $message['last_member_name'])), 'board' => array('id' => $message['id_board'], 'name' => $message['board_name'], 'href' => $bhref, 'link' => '<a href="' . $bhref . '">' . $message['board_name'] . '</a>'), 'category' => array('id' => $message['id_cat'], 'name' => $message['cat_name'], 'href' => $scripturl . '#c' . $message['id_cat'], 'link' => '<a href="' . $scripturl . '#c' . $message['id_cat'] . '">' . $message['cat_name'] . '</a>')));
determineTopicClass($output);
if ($output['posted_in']) {
$output['class'] = 'my_' . $output['class'];
}
$body_highlighted = $message['body'];
$subject_highlighted = $message['subject'];
if (!empty($options['display_quick_mod'])) {
$started = $output['first_post']['member']['id'] == $user_info['id'];
//.........这里部分代码省略.........
示例8: TopicBans
function TopicBans()
{
global $context, $board_info, $topic, $txt, $memberContext, $user_info;
EoS_Smarty::loadTemplate('modcenter/modcenter_base');
if (isset($_REQUEST['sa']) && ($_REQUEST['sa'] === 'unban' || $_REQUEST['sa'] === 'ban')) {
$is_ban = $_REQUEST['sa'] === 'ban' ? 1 : 0;
$context['page_title'] = $is_ban ? $txt['mc_issue_topic_ban'] : $txt['mc_lift_topic_ban'];
EoS_Smarty::getConfigInstance()->registerHookTemplate('modcenter_content_area', 'modcenter/topicban_issue_or_lift');
$context['op_errors'] = array();
$member = isset($_REQUEST['m']) ? (int) $_REQUEST['m'] : 0;
if (!isset($topic) || empty($topic) || !isset($board_info) || empty($board_info) || 0 == $member) {
$context['op_errors'][] = $txt['mc_lift_topic_ban_missing_data'];
}
if (!allowedTo('moderate_board')) {
$context['op_errors'][] = $txt['mc_lift_topic_ban_not_allowed'];
}
if (loadMemberData($member) != false) {
loadMemberContext($member);
$context['banned_member'] =& $memberContext[$member];
} else {
$context['op_errors'][] = $txt['mc_lift_topic_ban_invalid_member'];
}
// defaults
$context['ban_data'] = array('expire' => 0, 'reason' => '');
if (isset($_REQUEST['save'])) {
$context['ban_data']['expire'] = !empty($_POST['mc_expire']) ? (int) $_POST['mc_expire'] : 0;
$context['ban_data']['reason'] = !empty($_POST['mc_reason']) ? htmlspecialchars($_POST['mc_reason']) : '';
}
$context['ban_row'] = array();
// do not check this for admins - they can do whatever they want and even ban a moderator in his own board. Yes, admins are >> all :)
if ($is_ban && !$user_info['is_admin']) {
if (isUserAllowedTo('moderate_forum', 0, $member) || isUserAllowedTo('moderate_board', $board_info['id'], $member)) {
$context['op_errors'][] = $txt['mc_topicban_not_bannable'];
}
}
$request = smf_db_query('SELECT t.id_topic, ba.id_member, ba.updated, ba.reason, m.subject FROM {db_prefix}topics AS t
LEFT JOIN {db_prefix}topicbans AS ba ON (ba.id_topic = t.id_topic AND ba.id_member = {int:member})
LEFT JOIN {db_prefix}messages AS m ON (m.id_msg = t.id_first_msg)
WHERE t.id_topic = {int:topic}', array('topic' => $topic, 'member' => $member));
if (mysql_num_rows($request) > 0) {
$row = mysql_fetch_assoc($request);
if (!empty($row['reason']) && strpos($row['reason'], '|')) {
list($msg, $reason) = explode('|', $row['reason']);
} else {
$msg = 0;
$reason = '';
}
$context['ban_row'] = array('id_member' => $row['id_member'], 'id_topic' => $row['id_topic'], 'subject' => $row['subject'], 'ban_time' => timeformat($row['updated']), 'href' => URL::topic($topic, $row['subject']), 'is_banned' => $row['id_member'], 'msg' => $msg, 'reason' => $reason);
if ($_REQUEST['sa'] == 'ban' && $context['ban_row']['is_banned']) {
$context['op_errors'][] = $txt['mc_topicban_duplicate'];
} elseif ($_REQUEST['sa'] == 'unban' && $context['ban_row']['is_banned'] == 0) {
$context['op_errors'][] = $txt['mc_lift_ban_not_found'];
}
} else {
$context['op_errors'][] = $txt['mc_lift_ban_not_found'];
}
mysql_free_result($request);
$mid = isset($_REQUEST['mid']) ? (int) $_REQUEST['mid'] : 0;
// save it
$back_to_topic = URL::topic($topic, $context['ban_row']['subject'], 0, false, '.msg' . (int) $_REQUEST['mid'], '#msg' . (int) $_REQUEST['mid']);
if (empty($context['op_errors'])) {
if (isset($_REQUEST['save']) && $is_ban && empty($_POST['mc_reason'])) {
$context['op_errors'][] = $txt['mc_topicban_missing_reason'];
}
if (isset($_REQUEST['save']) && empty($context['op_errors'])) {
checkSession();
$context['success'] = 'Success';
$context['back_url'] = $back_to_topic;
$context['back_label'] = $txt['mc_lift_ban_backtotopic'];
if ($is_ban) {
$ban_expire = isset($_REQUEST['mc_expire']) && !empty($_REQUEST['mc_expire']) ? (int) $_REQUEST['mc_expire'] * 86400 : 0;
$ban_reason = (isset($_REQUEST['mid']) && !empty($_REQUEST['mid']) ? (int) $_REQUEST['mid'] : 0) . '|' . htmlspecialchars($_POST['mc_reason']);
smf_db_insert('', '{db_prefix}topicbans', array('id_topic' => 'int', 'id_member' => 'int', 'updated' => 'int', 'expires' => 'int', 'reason' => 'string-255'), array($topic, $member, $context['time_now'], $ban_expire ? $context['time_now'] + $ban_expire : 0, $ban_reason), array('id'));
} else {
smf_db_query('DELETE FROM {db_prefix}topicbans WHERE id_topic = {int:topic} AND id_member = {int:member}', array('topic' => $topic, 'member' => $member));
}
} else {
$context['submit_url'] = URL::parse('?action=moderate;area=topicbans;sa=' . ($is_ban ? 'ban' : 'unban') . ';topic=' . $topic . ';m=' . $member . ';save' . ';mid=' . $mid);
$context['back_url'] = $back_to_topic;
$context['back_label'] = $txt['mc_lift_ban_backtotopic'];
$context['submit_label'] = $is_ban ? $txt['mc_issue_ban'] : $txt['mc_lift_ban'];
$context['topicban_message'] = $is_ban ? sprintf($txt['mc_topicban_message'], $context['banned_member']['link'], $context['ban_row']['href'], $context['ban_row']['subject']) : sprintf($txt['mc_lift_ban_message'], $context['banned_member']['link'], $context['ban_row']['href'], $context['ban_row']['subject'], $context['ban_row']['ban_time']);
$context['submit'] = true;
$context['is_ban'] = $is_ban;
}
} else {
$context['back_url'] = $back_to_topic;
$context['back_label'] = $txt['mc_lift_ban_backtotopic'];
}
} else {
global $user_info, $context;
$boards = array();
if ($user_info['is_admin'] || allowedTo('moderate_forum')) {
// admins and global moderator can see all topic bans
$board_query = '1=1';
} else {
$boards = boardsAllowedTo('moderate_board');
if (empty($boards)) {
fatal_lang_error('no_access', true);
}
//.........这里部分代码省略.........
示例9: UnreadTopics
function UnreadTopics()
{
global $board, $txt, $scripturl, $sourcedir;
global $user_info, $context, $settings, $modSettings, $options, $memberContext;
// Guests can't have unread things, we don't know anything about them.
is_not_guest();
$context['current_action'] = 'whatsnew';
// Prefetching + lots of MySQL work = bad mojo.
if (isset($_SERVER['HTTP_X_MOZ']) && $_SERVER['HTTP_X_MOZ'] == 'prefetch') {
ob_end_clean();
header('HTTP/1.1 403 Forbidden');
die;
}
$context['showing_all_topics'] = isset($_GET['all']);
$context['start'] = (int) $_REQUEST['start'];
$context['topics_per_page'] = empty($modSettings['disableCustomPerPage']) && !empty($options['topics_per_page']) ? $options['topics_per_page'] : $modSettings['defaultMaxTopics'];
if ($_REQUEST['action'] == 'unread') {
$context['page_title'] = $context['showing_all_topics'] ? $txt['unread_topics_all'] : $txt['unread_topics_visit'];
} else {
$context['page_title'] = $txt['unread_replies'];
}
if ($context['showing_all_topics'] && !empty($context['load_average']) && !empty($modSettings['loadavg_allunread']) && $context['load_average'] >= $modSettings['loadavg_allunread']) {
fatal_lang_error('loadavg_allunread_disabled', false);
} elseif ($_REQUEST['action'] != 'unread' && !empty($context['load_average']) && !empty($modSettings['loadavg_unreadreplies']) && $context['load_average'] >= $modSettings['loadavg_unreadreplies']) {
fatal_lang_error('loadavg_unreadreplies_disabled', false);
} elseif (!$context['showing_all_topics'] && $_REQUEST['action'] == 'unread' && !empty($context['load_average']) && !empty($modSettings['loadavg_unread']) && $context['load_average'] >= $modSettings['loadavg_unread']) {
fatal_lang_error('loadavg_unread_disabled', false);
}
// Parameters for the main query.
$query_parameters = array();
// Are we specifying any specific board?
if (isset($_REQUEST['children']) && (!empty($board) || !empty($_REQUEST['boards']))) {
$boards = array();
if (!empty($_REQUEST['boards'])) {
$_REQUEST['boards'] = explode(',', $_REQUEST['boards']);
foreach ($_REQUEST['boards'] as $b) {
$boards[] = (int) $b;
}
}
if (!empty($board)) {
$boards[] = (int) $board;
}
// The easiest thing is to just get all the boards they can see, but since we've specified the top of tree we ignore some of them
$request = smf_db_query('
SELECT b.id_board, b.id_parent
FROM {db_prefix}boards AS b
WHERE {query_wanna_see_board}
AND b.child_level > {int:no_child}
AND b.id_board NOT IN ({array_int:boards})
ORDER BY child_level ASC
', array('no_child' => 0, 'boards' => $boards));
while ($row = mysql_fetch_assoc($request)) {
if (in_array($row['id_parent'], $boards)) {
$boards[] = $row['id_board'];
}
}
mysql_free_result($request);
if (empty($boards)) {
fatal_lang_error('error_no_boards_selected');
}
$query_this_board = 'id_board IN ({array_int:boards})';
$query_parameters['boards'] = $boards;
$context['querystring_board_limits'] = ';boards=' . implode(',', $boards) . ';start=%d';
} elseif (!empty($board)) {
$query_this_board = 'id_board = {int:board}';
$query_parameters['board'] = $board;
$context['querystring_board_limits'] = ';board=' . $board . '.%1$d';
} elseif (!empty($_REQUEST['boards'])) {
$_REQUEST['boards'] = explode(',', $_REQUEST['boards']);
foreach ($_REQUEST['boards'] as $i => $b) {
$_REQUEST['boards'][$i] = (int) $b;
}
$request = smf_db_query('
SELECT b.id_board
FROM {db_prefix}boards AS b
WHERE {query_see_board}
AND b.id_board IN ({array_int:board_list})', array('board_list' => $_REQUEST['boards']));
$boards = array();
while ($row = mysql_fetch_assoc($request)) {
$boards[] = $row['id_board'];
}
mysql_free_result($request);
if (empty($boards)) {
fatal_lang_error('error_no_boards_selected');
}
$query_this_board = 'id_board IN ({array_int:boards})';
$query_parameters['boards'] = $boards;
$context['querystring_board_limits'] = ';boards=' . implode(',', $boards) . ';start=%1$d';
} elseif (!empty($_REQUEST['c'])) {
$_REQUEST['c'] = explode(',', $_REQUEST['c']);
foreach ($_REQUEST['c'] as $i => $c) {
$_REQUEST['c'][$i] = (int) $c;
}
$see_board = isset($_REQUEST['action']) && $_REQUEST['action'] == 'unreadreplies' ? 'query_see_board' : 'query_wanna_see_board';
$request = smf_db_query('
SELECT b.id_board
FROM {db_prefix}boards AS b
WHERE ' . $user_info[$see_board] . '
AND b.id_cat IN ({array_int:id_cat})', array('id_cat' => $_REQUEST['c']));
$boards = array();
//.........这里部分代码省略.........
示例10: showPosts
function showPosts($memID)
{
global $txt, $user_info, $scripturl, $modSettings;
global $context, $user_profile, $sourcedir, $board, $memberContext, $options;
EoS_Smarty::loadTemplate('profile/profile_base');
$context['need_synhlt'] = true;
// Some initial context.
$context['start'] = (int) $_REQUEST['start'];
$context['current_member'] = $memID;
// Create the tabs for the template.
$context[$context['profile_menu_name']]['tab_data'] = array('title' => $txt['showPosts'], 'description' => $txt['showPosts_help'], 'tabs' => array('messages' => array(), 'topics' => array(), 'attach' => array()));
// Set the page title
$context['page_title'] = $txt['showPosts'] . ' - ' . $user_profile[$memID]['real_name'];
$context['pageindex_multiplier'] = commonAPI::getMessagesPerPage();
$context['can_approve_posts'] = false;
// Is the load average too high to allow searching just now?
if (!empty($context['load_average']) && !empty($modSettings['loadavg_show_posts']) && $context['load_average'] >= $modSettings['loadavg_show_posts']) {
fatal_lang_error('loadavg_show_posts_disabled', false);
}
if (isset($_GET['sa']) && !empty($modSettings['karmaMode']) && ($_GET['sa'] == 'likes' || $_GET['sa'] == 'likesout')) {
require_once $sourcedir . '/Ratings.php';
return LikesByUser($memID);
}
EoS_Smarty::getConfigInstance()->registerHookTemplate('profile_content_area', 'profile/show_content');
$boards_hidden_1 = boardsAllowedTo('see_hidden1');
$boards_hidden_2 = boardsAllowedTo('see_hidden2');
$boards_hidden_3 = boardsAllowedTo('see_hidden3');
// If we're specifically dealing with attachments use that function!
if (isset($_GET['sa']) && $_GET['sa'] == 'attach') {
return showAttachments($memID);
}
// Are we just viewing topics?
$context['is_topics'] = isset($_GET['sa']) && $_GET['sa'] == 'topics' ? true : false;
// If just deleting a message, do it and then redirect back.
if (isset($_GET['delete']) && !$context['is_topics']) {
checkSession('get');
// We need msg info for logging.
$request = smf_db_query('
SELECT subject, id_member, id_topic, id_board
FROM {db_prefix}messages
WHERE id_msg = {int:id_msg}', array('id_msg' => (int) $_GET['delete']));
$info = mysql_fetch_row($request);
mysql_free_result($request);
// Trying to remove a message that doesn't exist.
if (empty($info)) {
redirectexit('action=profile;u=' . $memID . ';area=showposts;start=' . $_GET['start']);
}
// We can be lazy, since removeMessage() will check the permissions for us.
require_once $sourcedir . '/RemoveTopic.php';
removeMessage((int) $_GET['delete']);
// Add it to the mod log.
if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id'])) {
logAction('delete', array('topic' => $info[2], 'subject' => $info[0], 'member' => $info[1], 'board' => $info[3]));
}
// Back to... where we are now ;).
redirectexit('action=profile;u=' . $memID . ';area=showposts;start=' . $_GET['start']);
}
// Default to 10.
if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) {
$_REQUEST['viewscount'] = '10';
}
if ($context['is_topics']) {
$request = smf_db_query('
SELECT COUNT(*)
FROM {db_prefix}topics AS t' . ($user_info['query_see_board'] == '1=1' ? '' : '
INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board AND {query_see_board})') . '
WHERE t.id_member_started = {int:current_member}' . (!empty($board) ? '
AND t.id_board = {int:board}' : '') . (!$modSettings['postmod_active'] || $context['user']['is_owner'] ? '' : '
AND t.approved = {int:is_approved}'), array('current_member' => $memID, 'is_approved' => 1, 'board' => $board));
} else {
$request = smf_db_query('
SELECT COUNT(*)
FROM {db_prefix}messages AS m' . ($user_info['query_see_board'] == '1=1' ? '' : '
INNER JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board AND {query_see_board})') . '
WHERE m.id_member = {int:current_member}' . (!empty($board) ? '
AND m.id_board = {int:board}' : '') . (!$modSettings['postmod_active'] || $context['user']['is_owner'] ? '' : '
AND m.approved = {int:is_approved}'), array('current_member' => $memID, 'is_approved' => 1, 'board' => $board));
}
list($msgCount) = mysql_fetch_row($request);
mysql_free_result($request);
$request = smf_db_query('
SELECT MIN(id_msg), MAX(id_msg)
FROM {db_prefix}messages AS m
WHERE m.id_member = {int:current_member}' . (!empty($board) ? '
AND m.id_board = {int:board}' : '') . (!$modSettings['postmod_active'] || $context['user']['is_owner'] ? '' : '
AND m.approved = {int:is_approved}'), array('current_member' => $memID, 'is_approved' => 1, 'board' => $board));
list($min_msg_member, $max_msg_member) = mysql_fetch_row($request);
mysql_free_result($request);
$reverse = false;
$range_limit = '';
$maxIndex = (int) $modSettings['defaultMaxMessages'];
// Make sure the starting place makes sense and construct our friend the page index.
$context['page_index'] = constructPageIndex($scripturl . '?action=profile;u=' . $memID . ';area=showposts' . ($context['is_topics'] ? ';sa=topics' : '') . (!empty($board) ? ';board=' . $board : ''), $context['start'], $msgCount, $maxIndex);
$context['current_page'] = $context['start'] / $maxIndex;
// Reverse the query if we're past 50% of the pages for better performance.
$start = $context['start'];
$reverse = $_REQUEST['start'] > $msgCount / 2;
if ($reverse && !$context['is_topics']) {
$maxIndex = $msgCount < $context['start'] + $modSettings['defaultMaxMessages'] + 1 && $msgCount > $context['start'] ? $msgCount - $context['start'] : (int) $modSettings['defaultMaxMessages'];
$start = $msgCount < $context['start'] + $modSettings['defaultMaxMessages'] + 1 || $msgCount < $context['start'] + $modSettings['defaultMaxMessages'] ? 0 : $msgCount - $context['start'] - $modSettings['defaultMaxMessages'];
//.........这里部分代码省略.........
示例11: MessageIndex
function MessageIndex()
{
global $txt, $scripturl, $board, $modSettings, $context;
global $options, $settings, $board_info, $user_info, $smcFunc, $sourcedir;
global $memberContext;
// If this is a redirection board head off.
if ($board_info['redirect']) {
smf_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']);
}
EoS_Smarty::loadTemplate('messageindex');
fetchNewsItems($board, 0);
$context['act_as_cat'] = $board_info['allow_topics'] ? false : true;
$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']) ? $options['topics_per_page'] : $modSettings['defaultMaxTopics'];
$context['messages_per_page'] = commonAPI::getMessagesPerPage();
$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(URL::board($board_info['id'], $board_info['name'], '%1$d;sort=' . $_REQUEST['sort'] . (isset($_REQUEST['desc']) ? ';desc' : ''), true), $_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['page_index'] = constructPageIndex(URL::board($board_info['id'], $board_info['name'], '%1$d', true), $_REQUEST['start'], $board_info['total_topics'], $maxindex, true);
}
$context['start'] =& $_REQUEST['start'];
setcookie('smf_topicstart', intval($board) . '_' . $context['start'], time() + 86400, '/');
// Set a canonical URL for this page.
$context['canonical_url'] = URL::board($board, $board_info['name'], $context['start'], true);
$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'] = ' (' . (count($context['link_moderators']) == 1 ? $txt['moderator'] : $txt['moderators']) . ': ' . implode(', ', $context['link_moderators']) . ')';
}
// Mark current and parent boards as seen.
if (!$user_info['is_guest']) {
// We can't know they read it if we allow prefetches.
if (isset($_SERVER['HTTP_X_MOZ']) && $_SERVER['HTTP_X_MOZ'] == 'prefetch') {
ob_end_clean();
header('HTTP/1.1 403 Prefetch Forbidden');
die;
}
smf_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'])) {
smf_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 = smf_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'] = mysql_num_rows($request) != 0;
//.........这里部分代码省略.........