diff options
Diffstat (limited to 'phpBB/viewtopic.php')
-rw-r--r-- | phpBB/viewtopic.php | 183 |
1 files changed, 92 insertions, 91 deletions
diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 17b19b3be7..c9245e2399 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -40,9 +40,11 @@ if (isset($_GET['view']) && empty($post_id)) { if ($_GET['view'] == 'newest') { - if (isset($_COOKIE[$config['cookie_name'] . '_sid'])) + if (!empty($_COOKIE[$config['cookie_name'] . '_sid']) || !empty($_GET['sid'])) { - $session_id = $_COOKIE[$config['cookie_name'] . '_sid']; + $session_id = (!empty($_COOKIE[$config['cookie_name'] . '_sid'])) ? $_COOKIE[$config['cookie_name'] . '_sid'] : $_GET['sid']; + + $SID = '?sid=' . ((!empty($_GET['sid'])) ? $session_id : ''); if ($session_id) { @@ -59,7 +61,7 @@ if (isset($_GET['view']) && empty($post_id)) if (!($row = $db->sql_fetchrow($result))) { - message_die(MESSAGE, 'No_new_posts_last_visit'); + trigger_error('No_new_posts_last_visit'); } $post_id = $row['post_id']; @@ -67,7 +69,7 @@ if (isset($_GET['view']) && empty($post_id)) } } - redirect("index.$phpEx$SID"); + redirect("index.$phpEx"); } else if ($_GET['view'] == 'next' || $_GET['view'] == 'previous') { @@ -85,8 +87,8 @@ if (isset($_GET['view']) && empty($post_id)) if (!($row = $db->sql_fetchrow($result))) { - $message = ( $_GET['view'] == 'next' ) ? 'No_newer_topics' : 'No_older_topics'; - message_die(MESSAGE, $message); + $message = ($_GET['view'] == 'next') ? 'No_newer_topics' : 'No_older_topics'; + trigger_error($message); } else { @@ -101,7 +103,7 @@ $user->start(); if ($user->data['user_id'] != ANONYMOUS) { - if (isset($_POST['rating']) ) + if (isset($_POST['rating'])) { $sql = "SELECT rating FROM " . TOPICS_RATINGS_TABLE . " @@ -111,14 +113,14 @@ if ($user->data['user_id'] != ANONYMOUS) $rating = ($row = $db->sql_fetchrow($result)) ? $row['rating'] : ''; - if ( empty($_POST['rating_value']) && $rating != '' ) + if ( empty($_POST['rating_value']) && $rating != '') { } else { $new_rating = intval($_POST['rating']); - $sql = ( $rating != '' ) ? "UPDATE " . TOPICS_RATING_TABLE . " SET rating = $new_rating WHERE user_id = " . $user->data['user_id'] . " AND topic_id = $topic_id" : "INSERT INTO " . TOPICS_RATING_TABLE . " (topic_id, user_id, rating) VALUES ($topic_id, " . $user->data['user_id'] . ", $new_rating)"; + $sql = ($rating != '') ? "UPDATE " . TOPICS_RATING_TABLE . " SET rating = $new_rating WHERE user_id = " . $user->data['user_id'] . " AND topic_id = $topic_id" : "INSERT INTO " . TOPICS_RATING_TABLE . " (topic_id, user_id, rating) VALUES ($topic_id, " . $user->data['user_id'] . ", $new_rating)"; } } else if (isset($_POST['castvote'])) @@ -133,10 +135,10 @@ if ($user->data['user_id'] != ANONYMOUS) // This rather complex gaggle of code handles querying for topics but // also allows for direct linking to a post (and the calculation of which // page the post is on and the correct display of viewtopic) -$join_sql_table = ( !$post_id ) ? '' : ', ' . POSTS_TABLE . ' p, ' . POSTS_TABLE . ' p2 '; -$join_sql = ( !$post_id ) ? "t.topic_id = $topic_id" : "p.post_id = $post_id AND p.post_approved = " . TRUE . " AND t.topic_id = p.topic_id AND p2.topic_id = p.topic_id AND p2.post_approved = " . TRUE . " AND p2.post_id <= $post_id"; -$count_sql = ( !$post_id ) ? '' : ", COUNT(p2.post_id) AS prev_posts"; -$order_sql = ( !$post_id ) ? '' : "GROUP BY p.post_id, t.topic_id, t.topic_title, t.topic_status, t.topic_replies, t.topic_time, t.topic_type, f.forum_name, f.forum_status, f.forum_id, f.forum_style ORDER BY p.post_id ASC"; +$join_sql_table = (!$post_id) ? '' : ', ' . POSTS_TABLE . ' p, ' . POSTS_TABLE . ' p2 '; +$join_sql = (!$post_id) ? "t.topic_id = $topic_id" : "p.post_id = $post_id AND p.post_approved = " . TRUE . " AND t.topic_id = p.topic_id AND p2.topic_id = p.topic_id AND p2.post_approved = " . TRUE . " AND p2.post_id <= $post_id"; +$count_sql = (!$post_id) ? '' : ", COUNT(p2.post_id) AS prev_posts"; +$order_sql = (!$post_id) ? '' : "GROUP BY p.post_id, t.topic_id, t.topic_title, t.topic_status, t.topic_replies, t.topic_time, t.topic_type, f.forum_name, f.forum_status, f.forum_id, f.forum_style ORDER BY p.post_id ASC"; $sql = "SELECT t.topic_id, t.topic_title, t.topic_status, t.topic_replies, t.topic_time, t.topic_type, t.poll_start, t.poll_length, t.poll_title, f.forum_name, f.forum_status, f.forum_id, f.forum_style" . $count_sql . " FROM " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f" . $join_sql_table . " @@ -151,12 +153,12 @@ if (!(extract($db->sql_fetchrow($result)))) } // Configure style, language, etc. -$user->setup(false, $forum_style); -$auth->acl($user->data, $forum_id); +$user->setup(false, intval($forum_style)); +$auth->acl($user->data, intval($forum_id)); // End configure // Start auth check -if (!$auth->acl_get('f_read', $forum_id)) +if (!$auth->acl_gets('f_read', 'm_', 'a_', intval($forum_id))) { if ($user->data['user_id'] == ANONYMOUS) { @@ -206,8 +208,8 @@ if (isset($_POST['sort'])) $topic_replies++; } - $sort_key = ( isset($_POST['sort_key']) ) ? $_POST['sort_key'] : $_GET['sort_key']; - $sort_dir = ( isset($_POST['sort_dir']) ) ? $_POST['sort_dir'] : $_GET['sort_dir']; + $sort_key = (isset($_POST['sort_key'])) ? $_POST['sort_key'] : $_GET['sort_key']; + $sort_dir = (isset($_POST['sort_dir'])) ? $_POST['sort_dir'] : $_GET['sort_dir']; } else { @@ -219,12 +221,12 @@ else $sort_dir = 'a'; } -$sort_order = $sort_by[$sort_key] . ' ' . ( ( $sort_dir == 'd' ) ? 'DESC' : 'ASC' ); +$sort_order = $sort_by[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC'); $select_sort_days = '<select name="sort_days">'; foreach ($previous_days as $day => $text) { - $selected = ( $sort_days == $day ) ? ' selected="selected"' : ''; + $selected = ($sort_days == $day) ? ' selected="selected"' : ''; $select_sort_days .= '<option value="' . $day . '"' . $selected . '>' . $text . '</option>'; } $select_sort_days .= '</select>'; @@ -232,13 +234,13 @@ $select_sort_days .= '</select>'; $select_sort = '<select name="sort_key">'; foreach ($sort_by_text as $key => $text) { - $selected = ( $sort_key == $key ) ? ' selected="selected"' : ''; + $selected = ($sort_key == $key) ? ' selected="selected"' : ''; $select_sort .= '<option value="' . $key . '"' . $selected . '>' . $text . '</option>'; } $select_sort .= '</select>'; $select_sort_dir = '<select name="sort_dir">'; -$select_sort_dir .= ( $sort_dir == 'a' ) ? '<option value="a" selected="selected">' . $user->lang['Ascending'] . '</option><option value="d">' . $user->lang['Descending'] . '</option>' : '<option value="a">' . $user->lang['Ascending'] . '</option><option value="d" selected="selected">' . $user->lang['Descending'] . '</option>'; +$select_sort_dir .= ($sort_dir == 'a') ? '<option value="a" selected="selected">' . $user->lang['Ascending'] . '</option><option value="d">' . $user->lang['Descending'] . '</option>' : '<option value="a">' . $user->lang['Ascending'] . '</option><option value="d" selected="selected">' . $user->lang['Descending'] . '</option>'; $select_sort_dir .= '</select>'; $select_post_days = '<select name="postdays">'; @@ -271,12 +273,12 @@ if ($user->data['user_id'] != ANONYMOUS) AND user_id = " . $user->data['user_id']; $result = $db->sql_query($sql); - $user_rating = ( $row = $db->sql_fetchrow($result) ) ? $row['rating'] : 0; + $user_rating = ($row = $db->sql_fetchrow($result)) ? $row['rating'] : 0; for($i = -5; $i < 6; $i++) { - $selected = ( $user_rating == $i ) ? ' selected="selected"' : ''; - $rating .= '<option value="' . $i . '"' . $selected . '>' . $i . ( ( !empty($rating_text[$i]) ) ? ' > ' . $rating_text[$i] : '' ) . '</option>'; + $selected = ($user_rating == $i) ? ' selected="selected"' : ''; + $rating .= '<option value="' . $i . '"' . $selected . '>' . $i . ((!empty($rating_text[$i])) ? ' > ' . $rating_text[$i] : '') . '</option>'; } $rating = '<select name="rating">' . $rating . '</select>'; @@ -295,7 +297,7 @@ if (isset($_GET['highlight'])) { if (trim($word) != '') { - $highlight_match .= (($highlight_match != '') ? '|' : '') . str_replace('*', '([\w]+)?', preg_quote($word, '#')); + $highlight_match .= (($highlight_match != '') ? '|' : '') . str_replace('*', '\w*', preg_quote($word, '#')); } } unset($words); @@ -306,11 +308,11 @@ $s_forum_rules = ''; get_forum_rules('topic', $s_forum_rules, $forum_id); $topic_mod = ''; -$topic_mod .= ( $auth->acl_get('m_lock', $forum_id) ) ? ( ( $topic_status == TOPIC_UNLOCKED ) ? '<option value="lock">' . $user->lang['Lock_topic'] . '</option>' : '<option value="unlock">' . $user->lang['Unlock_topic'] . '</option>' ) : ''; -$topic_mod .= ( $auth->acl_get('m_delete', $forum_id) ) ? '<option value="delete">' . $user->lang['Delete_topic'] . '</option>' : ''; -$topic_mod .= ( $auth->acl_get('m_move', $forum_id) ) ? '<option value="move">' . $user->lang['Move_topic'] . '</option>' : ''; -$topic_mod .= ( $auth->acl_get('m_split', $forum_id) ) ? '<option value="split">' . $user->lang['Split_topic'] . '</option>' : ''; -$topic_mod .= ( $auth->acl_get('m_merge', $forum_id) ) ? '<option value="merge">' . $user->lang['Merge_topic'] . '</option>' : ''; +$topic_mod .= ($auth->acl_gets('m_lock', 'a_', $forum_id)) ? ((intval($topic_status) == TOPIC_UNLOCKED) ? '<option value="lock">' . $user->lang['Lock_topic'] . '</option>' : '<option value="unlock">' . $user->lang['Unlock_topic'] . '</option>') : ''; +$topic_mod .= ($auth->acl_gets('m_delete', 'a_', $forum_id)) ? '<option value="delete">' . $user->lang['Delete_topic'] . '</option>' : ''; +$topic_mod .= ($auth->acl_gets('m_move', 'a_', $forum_id)) ? '<option value="move">' . $user->lang['Move_topic'] . '</option>' : ''; +$topic_mod .= ($auth->acl_gets('m_split', 'a_', $forum_id)) ? '<option value="split">' . $user->lang['Split_topic'] . '</option>' : ''; +$topic_mod .= ($auth->acl_gets('m_merge', 'a_', $forum_id)) ? '<option value="merge">' . $user->lang['Merge_topic'] . '</option>' : ''; // If we've got a hightlight set pass it on to pagination. $pagination = ($highlight_match) ? generate_pagination("viewtopic.$phpEx$SID&t=$topic_id&postdays=$post_days&postorder=$post_order&highlight=" . $_GET['highlight'], $topic_replies, $config['posts_per_page'], $start) : generate_pagination("viewtopic.$phpEx$SID&t=$topic_id&postdays=$post_days&postorder=$post_order", $topic_replies, $config['posts_per_page'], $start); @@ -323,13 +325,13 @@ $view_forum_url = 'viewforum.' . $phpEx . $SID . '&f=' . $forum_id; $view_prev_topic_url = 'viewtopic.' . $phpEx . $SID . '&f=' . $forum_id . '&t=' . $topic_id . '&view=previous'; $view_next_topic_url = 'viewtopic.' . $phpEx . $SID . '&f=' . $forum_id . '&t=' . $topic_id . '&view=next'; -$reply_img = ( $forum_status == FORUM_LOCKED || $topic_status == TOPIC_LOCKED ) ? $user->img('reply_locked', $user->lang['Topic_locked']) : $user->img('reply_new', $user->lang['Reply_to_topic']); -$post_img = ( $forum_status == FORUM_LOCKED ) ? $user->img('post_locked', $user->lang['Forum_locked']) : $user->img('post_new', $user->lang['Post_new_topic']); +$reply_img = ($forum_status == ITEM_LOCKED || $topic_status == ITEM_LOCKED) ? $user->img('reply_locked', $user->lang['Topic_locked']) : $user->img('reply_new', $user->lang['Reply_to_topic']); +$post_img = ($forum_status == ITEM_LOCKED) ? $user->img('post_locked', $user->lang['Forum_locked']) : $user->img('post_new', $user->lang['Post_new_topic']); // Set a cookie for this topic if ($user->data['user_id'] != ANONYMOUS) { - $mark_topics = ( isset($_COOKIE[$config['cookie_name'] . '_t']) ) ? unserialize(stripslashes($_COOKIE[$config['cookie_name'] . '_t'])) : array(); + $mark_topics = (isset($_COOKIE[$config['cookie_name'] . '_t'])) ? unserialize(stripslashes($_COOKIE[$config['cookie_name'] . '_t'])) : array(); $mark_topics[$forum_id][$topic_id] = 0; setcookie($config['cookie_name'] . '_t', serialize($mark_topics), 0, $config['cookie_path'], $config['cookie_domain'], $config['cookie_secure']); @@ -354,7 +356,7 @@ $template->assign_vars(array( 'TOPIC_TITLE' => $topic_title, 'PAGINATION' => $pagination, 'PAGE_NUMBER' => sprintf($user->lang['Page_of'], ( floor( $start / $config['posts_per_page'] ) + 1 ), ceil( $topic_replies / $config['posts_per_page'] )), - 'MOD_CP' => ( $auth->acl_get('a_') || $auth->acl_get('m_', $forum_id) ) ? sprintf($user->lang['MCP'], '<a href="modcp.' . $phpEx . $SID . '&f=' . $forum_id . '">', '</a>') : '', + 'MOD_CP' => ($auth->acl_gets('m_', 'a_', $forum_id)) ? sprintf($user->lang['MCP'], '<a href="modcp.' . $phpEx . $SID . '&f=' . $forum_id . '">', '</a>') : '', 'POST_IMG' => $post_img, 'REPLY_IMG' => $reply_img, @@ -384,7 +386,7 @@ $template->assign_vars(array( 'S_SELECT_RATING' => $rating, 'S_TOPIC_ACTION' => "viewtopic.$phpEx$SID&t=" . $topic_id . "&start=$start", 'S_AUTH_LIST' => $s_forum_rules, - 'S_TOPIC_MOD' => ( $topic_mod != '' ) ? '<select name="mode">' . $topic_mod . '</select>' : '', + 'S_TOPIC_MOD' => ($topic_mod != '') ? '<select name="mode">' . $topic_mod . '</select>' : '', 'S_MOD_ACTION' => "modcp.$phpEx$SID", 'S_WATCH_TOPIC' => $s_watching_topic, @@ -419,7 +421,7 @@ if (!empty($poll_start)) ORDER BY poll_option_id"; $result = $db->sql_query($sql); - while ( $row = $db->sql_fetchrow($result)) + while ($row = $db->sql_fetchrow($result)) { $poll_info[] = $row; } @@ -434,7 +436,7 @@ if (!empty($poll_start)) $voted_id = ($row = $db->sql_fetchrow($result)) ? $row['poll_option_id'] : false; $db->sql_freeresult($result); - $display_results = ($voted_id || ($poll_length != 0 && $poll_start + $poll_length < time()) || $_GET['vote'] == 'viewresult' || !$auth->acl_get('f_vote', $forum_id) || $topic_status == TOPIC_LOCKED) ? true : false; + $display_results = ($voted_id || ($poll_length != 0 && $poll_start + $poll_length < time()) || $_GET['vote'] == 'viewresult' || !$auth->acl_gets('f_vote', 'm_', 'a_', $forum_id) || $topic_status == ITEM_LOCKED || $forum_status == ITEM_LOCKED) ? true : false; $poll_total = 0; foreach ($poll_info as $poll_option) @@ -479,6 +481,7 @@ if (!empty($poll_start)) // Container for user details, only process once $poster_details = array(); +$i = 0; // Go ahead and pull all data for this topic $sql = "SELECT u.username, u.user_id, u.user_posts, u.user_from, u.user_website, u.user_email, u.user_icq, u.user_aim, u.user_yim, u.user_regdate, u.user_msnm, u.user_viewemail, u.user_rank, u.user_sig, u.user_sig_bbcode_uid, u.user_avatar, u.user_avatar_type, u.user_allowavatar, u.user_allowsmile, p.*, pt.post_text, pt.post_subject, pt.bbcode_uid @@ -497,31 +500,31 @@ if ($row = $db->sql_fetchrow($result)) do { $poster_id = $row['user_id']; - $poster = ( !$poster_id ) ? $user->lang['Guest'] : $row['username']; + $poster = (!$poster_id) ? $user->lang['Guest'] : $row['username']; - $poster_posts = ( $row['user_id'] ) ? $user->lang['Posts'] . ': ' . $row['user_posts'] : ''; + $poster_posts = ($row['user_id']) ? $user->lang['Posts'] . ': ' . $row['user_posts'] : ''; - $poster_from = ( $row['user_from'] && $row['user_id'] ) ? $user->lang['Location'] . ': ' . $row['user_from'] : ''; + $poster_from = ($row['user_from'] && $row['user_id']) ? $user->lang['Location'] . ': ' . $row['user_from'] : ''; - if ( !isset($poster_details[$poster_id]['joined']) ) + if (!isset($poster_details[$poster_id]['joined'])) { - $poster_details[$poster_id]['joined'] = ( $row['user_id'] ) ? $user->lang['Joined'] . ': ' . $user->format_date($row['user_regdate'], $user->lang['DATE_FORMAT']) : ''; + $poster_details[$poster_id]['joined'] = ($row['user_id']) ? $user->lang['Joined'] . ': ' . $user->format_date($row['user_regdate'], $user->lang['DATE_FORMAT']) : ''; } - if ( !isset($poster_details[$poster_id]['avatar']) ) + if (isset($poster_details[$poster_id]['avatar'])) { - if ( $row['user_avatar_type'] && $poster_id && $row['user_allowavatar'] ) + if ($row['user_avatar_type'] && $poster_id && $row['user_allowavatar']) { - switch( $row['user_avatar_type'] ) + switch ($row['user_avatar_type']) { case USER_AVATAR_UPLOAD: - $poster_details[$poster_id]['avatar'] = ( $config['allow_avatar_upload'] ) ? '<img src="' . $config['avatar_path'] . '/' . $row['user_avatar'] . '" width="' . $row['user_avatar_width'] . '" height="' . $row['user_avatar_height'] . '" border="0" alt="" />' : ''; + $poster_details[$poster_id]['avatar'] = ($config['allow_avatar_upload']) ? '<img src="' . $config['avatar_path'] . '/' . $row['user_avatar'] . '" width="' . $row['user_avatar_width'] . '" height="' . $row['user_avatar_height'] . '" border="0" alt="" />' : ''; break; case USER_AVATAR_REMOTE: - $poster_details[$poster_id]['avatar'] = ( $config['allow_avatar_remote'] ) ? '<img src="' . $row['user_avatar'] . '" width="' . $row['user_avatar_width'] . '" height="' . $row['user_avatar_height'] . '" border="0" alt="" />' : ''; + $poster_details[$poster_id]['avatar'] = ($config['allow_avatar_remote']) ? '<img src="' . $row['user_avatar'] . '" width="' . $row['user_avatar_width'] . '" height="' . $row['user_avatar_height'] . '" border="0" alt="" />' : ''; break; case USER_AVATAR_GALLERY: - $poster_details[$poster_id]['avatar'] = ( $config['allow_avatar_local'] ) ? '<img src="' . $config['avatar_gallery_path'] . '/' . $row['user_avatar'] . '" width="' . $row['user_avatar_width'] . '" height="' . $row['user_avatar_height'] . '" border="0" alt="" />' : ''; + $poster_details[$poster_id]['avatar'] = ($config['allow_avatar_local']) ? '<img src="' . $config['avatar_gallery_path'] . '/' . $row['user_avatar'] . '" width="' . $row['user_avatar_width'] . '" height="' . $row['user_avatar_height'] . '" border="0" alt="" />' : ''; break; } } @@ -532,16 +535,16 @@ if ($row = $db->sql_fetchrow($result)) } // Generate ranks, set them to empty string initially. - if ( !isset($poster_details[$poster_id]['rank_title']) ) + if (!isset($poster_details[$poster_id]['rank_title']) ) { - if ( $row['user_rank'] ) + if ($row['user_rank'] ) { for($j = 0; $j < count($ranksrow); $j++) { - if ( $row['user_rank'] == $ranksrow[$j]['rank_id'] && $ranksrow[$j]['rank_special'] ) + if ($row['user_rank'] == $ranksrow[$j]['rank_id'] && $ranksrow[$j]['rank_special']) { $poster_details[$poster_id]['rank_title'] = $ranksrow[$j]['rank_title']; - $poster_details[$poster_id]['rank_image'] = ( $ranksrow[$j]['rank_image'] ) ? '<img src="' . $ranksrow[$j]['rank_image'] . '" border="0" alt="' . $poster_rank . '" title="' . $poster_rank . '" /><br />' : ''; + $poster_details[$poster_id]['rank_image'] = ($ranksrow[$j]['rank_image']) ? '<img src="' . $ranksrow[$j]['rank_image'] . '" border="0" alt="' . $poster_rank . '" title="' . $poster_rank . '" /><br />' : ''; } } } @@ -549,23 +552,23 @@ if ($row = $db->sql_fetchrow($result)) { for($j = 0; $j < count($ranksrow); $j++) { - if ( $row['user_posts'] >= $ranksrow[$j]['rank_min'] && !$ranksrow[$j]['rank_special'] ) + if ($row['user_posts'] >= $ranksrow[$j]['rank_min'] && !$ranksrow[$j]['rank_special']) { $poster_details[$poster_id]['rank_title'] = $ranksrow[$j]['rank_title']; - $poster_details[$poster_id]['rank_image'] = ( $ranksrow[$j]['rank_image'] ) ? '<img src="' . $ranksrow[$j]['rank_image'] . '" border="0" alt="' . $poster_rank . '" title="' . $poster_rank . '" /><br />' : ''; + $poster_details[$poster_id]['rank_image'] = ($ranksrow[$j]['rank_image']) ? '<img src="' . $ranksrow[$j]['rank_image'] . '" border="0" alt="' . $poster_rank . '" title="' . $poster_rank . '" /><br />' : ''; } } } } // Handle anon users posting with usernames - if ( !$poster_id && $row['post_username'] != '' ) + if (!$poster_id && $row['post_username'] != '') { $poster = $row['post_username']; $poster_rank = $user->lang['Guest']; } - if ( !isset($poster_details[$poster_id]['profile']) && $poster_id ) + if (!isset($poster_details[$poster_id]['profile']) && $poster_id) { $temp_url = "profile.$phpEx$SID&mode=viewprofile&u=$poster_id"; $poster_details[$poster_id]['profile_img'] = '<a href="' . $temp_url . '">' . $user->img('icon_profile', $user->lang['Read_profile']) . '</a>'; @@ -575,9 +578,9 @@ if ($row = $db->sql_fetchrow($result)) $poster_details[$poster_id]['pm_img'] = '<a href="' . $temp_url . '">' . $user->img('icon_pm', $user->lang['Send_private_message']) . '</a>'; $poster_details[$poster_id]['pm'] = '<a href="' . $temp_url . '">' . $user->lang['Send_private_message'] . '</a>'; - if ( !empty($row['user_viewemail']) || $auth->acl_get('m_', $forum_id) ) + if (!empty($row['user_viewemail']) || $auth->acl_get('m_', $forum_id)) { - $email_uri = ( $config['board_email_form'] ) ? "profile.$phpEx$SID&mode=email&u=" . $poster_id : 'mailto:' . $row['user_email']; + $email_uri = ($config['board_email_form'] && $config['email_enable']) ? "profile.$phpEx$SID&mode=email&u=" . $poster_id : 'mailto:' . $row['user_email']; $poster_details[$poster_id]['email_img'] = '<a href="' . $email_uri . '">' . $user->img('icon_email', $user->lang['Send_email']) . '</a>'; $poster_details[$poster_id]['email'] = '<a href="' . $email_uri . '">' . $user->lang['Send_email'] . '</a>'; @@ -591,7 +594,7 @@ if ($row = $db->sql_fetchrow($result)) $poster_details[$poster_id]['www_img'] = ( $row['user_website'] ) ? '<a href="' . $row['user_website'] . '" target="_userwww">' . $user->img('icon_www', $user->lang['Visit_website']) . '</a>' : ''; $poster_details[$poster_id]['www'] = ( $row['user_website'] ) ? '<a href="' . $row['user_website'] . '" target="_userwww">' . $user->lang['Visit_website'] . '</a>' : ''; - if ( !empty($row['user_icq']) ) + if (!empty($row['user_icq'])) { $poster_details[$poster_id]['icq_status_img'] = '<a href="http://wwp.icq.com/' . $row['user_icq'] . '#pager"><img src="http://web.icq.com/whitepages/online?icq=' . $row['user_icq'] . '&img=5" width="18" height="18" border="0" /></a>'; $poster_details[$poster_id]['icq_img'] = '<a href="http://wwp.icq.com/scripts/search.dll?to=' . $row['user_icq'] . '">' . $user->img('icon_icq', $user->lang['ICQ']) . '</a>'; @@ -604,17 +607,17 @@ if ($row = $db->sql_fetchrow($result)) $poster_details[$poster_id]['icq'] = ''; } - $poster_details[$poster_id]['aim_img'] = ( $row['user_aim'] ) ? '<a href="aim:goim?screenname=' . $row['user_aim'] . '&message=Hello+Are+you+there?">' . $user->img('icon_aim', $user->lang['AIM']) . '</a>' : ''; - $poster_details[$poster_id]['aim'] = ( $row['user_aim'] ) ? '<a href="aim:goim?screenname=' . $row['user_aim'] . '&message=Hello+Are+you+there?">' . $user->lang['AIM'] . '</a>' : ''; + $poster_details[$poster_id]['aim_img'] = ($row['user_aim']) ? '<a href="aim:goim?screenname=' . $row['user_aim'] . '&message=Hello+Are+you+there?">' . $user->img('icon_aim', $user->lang['AIM']) . '</a>' : ''; + $poster_details[$poster_id]['aim'] = ($row['user_aim']) ? '<a href="aim:goim?screenname=' . $row['user_aim'] . '&message=Hello+Are+you+there?">' . $user->lang['AIM'] . '</a>' : ''; $temp_url = "profile.$phpEx$SID&mode=viewprofile&u=$poster_id"; - $poster_details[$poster_id]['msn_img'] = ( $row['user_msnm'] ) ? '<a href="' . $temp_url . '">' . $user->img('icon_msnm', $user->lang['MSNM']) . '</a>' : ''; - $poster_details[$poster_id]['msn'] = ( $row['user_msnm'] ) ? '<a href="' . $temp_url . '">' . $user->lang['MSNM'] . '</a>' : ''; + $poster_details[$poster_id]['msn_img'] = ($row['user_msnm']) ? '<a href="' . $temp_url . '">' . $user->img('icon_msnm', $user->lang['MSNM']) . '</a>' : ''; + $poster_details[$poster_id]['msn'] = ($row['user_msnm']) ? '<a href="' . $temp_url . '">' . $user->lang['MSNM'] . '</a>' : ''; - $poster_details[$poster_id]['yim_img'] = ( $row['user_yim'] ) ? '<a href="http://edit.yahoo.com/config/send_webmesg?.target=' . $row['user_yim'] . '&.src=pg">' . $user->img('icon_yim', $user->lang['YIM']) . '</a>' : ''; - $poster_details[$poster_id]['yim'] = ( $row['user_yim'] ) ? '<a href="http://edit.yahoo.com/config/send_webmesg?.target=' . $row['user_yim'] . '&.src=pg">' . $user->lang['YIM'] . '</a>' : ''; + $poster_details[$poster_id]['yim_img'] = ($row['user_yim']) ? '<a href="http://edit.yahoo.com/config/send_webmesg?.target=' . $row['user_yim'] . '&.src=pg">' . $user->img('icon_yim', $user->lang['YIM']) . '</a>' : ''; + $poster_details[$poster_id]['yim'] = ($row['user_yim']) ? '<a href="http://edit.yahoo.com/config/send_webmesg?.target=' . $row['user_yim'] . '&.src=pg">' . $user->lang['YIM'] . '</a>' : ''; - if ( $auth->acl_get('f_search', $forum_id) ) + if ($auth->acl_get('f_search', $forum_id)) { $temp_url = 'search.' . $phpEx . $SID . '&search_author=' . urlencode($row['username']) .'"&showresults=posts'; $search_img = '<a href="' . $temp_url . '">' . $user->img('icon_search', $user->lang['Search_user_posts']) . '</a>'; @@ -627,7 +630,7 @@ if ($row = $db->sql_fetchrow($result)) } } - else if ( !$poster_id ) + else if (!$poster_id) { $poster_details[$poster_id]['profile_img'] = ''; $poster_details[$poster_id]['profile'] = ''; @@ -653,7 +656,7 @@ if ($row = $db->sql_fetchrow($result)) $quote_img = '<a href="' . $temp_url . '">' . $user->img('icon_quote', $user->lang['Reply_with_quote']) . '</a>'; $quote = '<a href="' . $temp_url . '">' . $user->lang['Reply_with_quote'] . '</a>'; - if ( ( $user->data['user_id'] == $poster_id && $auth->acl_get('f_edit', $forum_id) ) || $auth->acl_get('m_edit', $forum_id) || $auth->acl_get('a_') ) + if (($user->data['user_id'] == $poster_id && $auth->acl_get('f_edit', $forum_id)) || $auth->acl_gets('m_edit', 'a_', $forum_id)) { $temp_url = "posting.$phpEx$SID&mode=edit&f=" . $row['forum_id'] . "&p=" . $row['post_id']; $edit_img = '<a href="' . $temp_url . '">' . $user->img('icon_edit', $user->lang['Edit_delete_post']) . '</a>'; @@ -665,7 +668,7 @@ if ($row = $db->sql_fetchrow($result)) $edit = ''; } - if ( $auth->acl_get('m_ip', $forum_id) ) + if ($auth->acl_gets('m_ip', 'a_', $forum_id)) { $temp_url = "modcp.$phpEx$SID&mode=ip&p=" . $row['post_id'] . "&t=" . $topic_id; $ip_img = '<a href="' . $temp_url . '">' . $user->img('icon_ip', $user->lang['View_IP']) . '</a>'; @@ -677,7 +680,7 @@ if ($row = $db->sql_fetchrow($result)) $ip = ''; } - if ( ( $user->data['user_id'] == $poster_id && $auth->acl_get('f_delete', $forum_id) && $forum_topic_data['topic_last_post_id'] == $row['post_id'] ) || $auth->acl_get('m_delete', $forum_id) ) + if (($user->data['user_id'] == $poster_id && $auth->acl_get('f_delete', $forum_id) && $forum_topic_data['topic_last_post_id'] == $row['post_id']) || $auth->acl_gets('m_delete', 'a_', $forum_id)) { $temp_url = "posting.$phpEx$SID&mode=delete&p=" . $row['post_id']; $delpost_img = '<a href="' . $temp_url . '">' . $user->img('icon_delete', $user->lang['Delete_post']) . '</a>'; @@ -710,34 +713,34 @@ if ($row = $db->sql_fetchrow($result)) // $message = ( $auth->acl_get('f_bbcode', $forum_id) ) ? bbencode_second_pass($message, $bbcode_uid, $auth->acl_get('f_img', $forum_id)) : preg_replace('/\:[0-9a-z\:]+\]/si', ']', $message); } + // If we allow users to disable display of emoticons + // we'll need an appropriate check and preg_replace here + if ($row['enable_smilies']) + { + $message = str_replace('<img src="{SMILE_PATH}', '<img src="' . $config['smilies_path'], $message); + } + // Highlight active words (primarily for search) -/* if ($highlight_match) + if ($highlight_match) { // This was shamelessly 'borrowed' from volker at multiartstudio dot de // via php.net's annotated manual - $message = substr(preg_replace('#(\>(((?>[^><]+)|(?R))*)\<)#ie', "preg_replace('/(?>($highlight_match)+)/i','<span style=\"color:red\">\\1</span>', '\\0')", '>' . $message . '<'), 1, -1); + $message = str_replace('\"', '"', substr(preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "preg_replace('#\b(" . $highlight_match . ")\b#i', '<span class=\"hilit\">\\\\1</span>', '\\0')", '>' . $message . '<'), 1, -1)); } -*/ - // Replace naughty words + + // Replace naughty words such as farty pants if (count($orig_word)) { $post_subject = preg_replace($orig_word, $replacement_word, $post_subject); $message = preg_replace($orig_word, $replacement_word, $message); } - // If we allow users to disable display of emoticons - // we'll need an appropriate check and preg_replace here - if ($row['enable_smilies']) - { - $message = str_replace('<img src="{SMILE_PATH}', '<img src="' . $config['smilies_path'], $message); - } - $message = nl2br($message); // Editing information - if ($row['post_edit_count']) + if (intval($row['post_edit_count'])) { - $l_edit_time_total = ($row['post_edit_count'] == 1) ? $user->lang['Edited_time_total'] : $user->lang['Edited_times_total']; + $l_edit_time_total = (intval($row['post_edit_count']) == 1) ? $user->lang['Edited_time_total'] : $user->lang['Edited_times_total']; $l_edited_by = '<br /><br />' . sprintf($l_edit_time_total, $poster, $user->format_date($row['post_edit_time']), $row['post_edit_count']); } @@ -747,14 +750,14 @@ if ($row = $db->sql_fetchrow($result)) } // Signature - if ( !isset($poster_details[$poster_id]['sig']) ) + if (!isset($poster_details[$poster_id]['sig'])) { - $user_sig = ($row['enable_sig'] && $row['user_sig'] != '' && $config['allow_sig'] ) ? $row['user_sig'] : ''; + $user_sig = ($row['enable_sig'] && $row['user_sig'] != '' && $config['allow_sig']) ? $row['user_sig'] : ''; $user_sig_bbcode_uid = $row['user_sig_bbcode_uid']; - if ($user_sig != '' && $user_sig_bbcode_uid != '' && $auth->acl_get('f_sigs', $forum_id) ) + if ($user_sig != '' && $user_sig_bbcode_uid != '' && $auth->acl_get('f_sigs', $forum_id)) { - if ( !$auth->acl_get('f_html', $forum_id) && $user->data['user_allowhtml'] ) + if (!$auth->acl_get('f_html', $forum_id) && $user->data['user_allowhtml']) { $user_sig = preg_replace('#(<)([\/]?.*?)(>)#is', "<\\2>", $user_sig); } @@ -832,13 +835,11 @@ if ($row = $db->sql_fetchrow($result)) 'L_MINI_POST_ALT' => $mini_post_alt, - 'S_ROW_COUNT' => $i, + 'S_ROW_COUNT' => $i++, 'U_MINI_POST' => $mini_post_url, 'U_POST_ID' => $row['post_id']) ); - - $i++; } while ($row = $db->sql_fetchrow($result)); } |