= u.user_lastvisit ORDER BY p.post_time ASC LIMIT 1"; if ( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, 'Could not obtain newer/older topic information', '', __LINE__, __FILE__, $sql); } if ( !($row = $db->sql_fetchrow($result)) ) { message_die(GENERAL_MESSAGE, 'No_new_posts_last_visit'); } $post_id = $row['post_id']; if (isset($HTTP_GET_VARS['sid'])) { redirect("viewtopic.$phpEx?sid=$session_id&" . POST_POST_URL . "=$post_id#$post_id"); } else { redirect("viewtopic.$phpEx?" . POST_POST_URL . "=$post_id#$post_id"); } } } redirect(append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id", true)); } else if ( $HTTP_GET_VARS['view'] == 'next' || $HTTP_GET_VARS['view'] == 'previous' ) { $sql_condition = ( $HTTP_GET_VARS['view'] == 'next' ) ? '>' : '<'; $sql_ordering = ( $HTTP_GET_VARS['view'] == 'next' ) ? 'ASC' : 'DESC'; $sql = "SELECT t.topic_id FROM " . TOPICS_TABLE . " t, " . TOPICS_TABLE . " t2 WHERE t2.topic_id = $topic_id AND t.forum_id = t2.forum_id AND t.topic_moved_id = 0 AND t.topic_last_post_id $sql_condition t2.topic_last_post_id ORDER BY t.topic_last_post_id $sql_ordering LIMIT 1"; if ( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, "Could not obtain newer/older topic information", '', __LINE__, __FILE__, $sql); } if ( $row = $db->sql_fetchrow($result) ) { $topic_id = intval($row['topic_id']); } else { $message = ( $HTTP_GET_VARS['view'] == 'next' ) ? 'No_newer_topics' : 'No_older_topics'; message_die(GENERAL_MESSAGE, $message); } } } // // 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 t.topic_id = p.topic_id AND p2.topic_id = p.topic_id 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, t.topic_vote, t.topic_last_post_id, f.forum_name, f.forum_status, f.forum_id, f.auth_view, f.auth_read, f.auth_post, f.auth_reply, f.auth_edit, f.auth_delete, f.auth_sticky, f.auth_announce, f.auth_pollcreate, f.auth_vote, f.auth_attachments ORDER BY p.post_id ASC"; $sql = "SELECT t.topic_id, t.topic_title, t.topic_status, t.topic_replies, t.topic_views, t.topic_time, t.topic_type, t.topic_vote, t.topic_last_post_id, f.forum_name, f.forum_status, f.forum_id, f.auth_view, f.auth_read, f.auth_post, f.auth_reply, f.auth_edit, f.auth_delete, f.auth_sticky, f.auth_announce, f.auth_pollcreate, f.auth_vote, f.auth_attachments" . $count_sql . " FROM " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f" . $join_sql_table . " WHERE $join_sql AND f.forum_id = t.forum_id $order_sql"; if ( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, "Could not obtain topic information", '', __LINE__, __FILE__, $sql); } if ( !($forum_topic_data = $db->sql_fetchrow($result)) ) { message_die(GENERAL_MESSAGE, 'Topic_post_not_exist'); } $forum_id = intval($forum_topic_data['forum_id']); // // Start session management // $userdata = session_pagestart($user_ip, $forum_id); init_userprefs($userdata); // // End session management // if ( $download ) { $sql_download = ( $download != -1 ) ? " AND p.post_id = " . intval($download) . " " : ''; $orig_word = array(); $replacement_word = array(); obtain_word_list($orig_word, $replacement_word); $sql = "SELECT u.*, p.*, pt.post_text, pt.post_subject, pt.bbcode_uid FROM " . POSTS_TABLE . " p, " . USERS_TABLE . " u, " . POSTS_TEXT_TABLE . " pt WHERE p.topic_id = $topic_id $sql_download AND pt.post_id = p.post_id AND u.user_id = p.poster_id ORDER BY p.post_time ASC, p.post_id ASC"; if ( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, "Could not create download stream for post.", '', __LINE__, __FILE__, $sql); } $download_file = ''; $is_auth_read = array(); while ( $row = $db->sql_fetchrow($result) ) { $is_auth_read = auth(AUTH_ALL, $row['forum_id'], $userdata); $poster_id = $row['user_id']; $poster = ( $poster_id == ANONYMOUS ) ? $lang['Guest'] : $row['username']; $post_date = create_date($board_config['default_dateformat'], $row['post_time'], $board_config['board_timezone']); $post_subject = ( $row['post_subject'] != '' ) ? $row['post_subject'] : ''; $bbcode_uid = $row['bbcode_uid']; $message = $row['post_text']; $message = strip_tags($message); $message = preg_replace("/\[.*?:$bbcode_uid:?.*?\]/si", '', $message); $message = preg_replace('/\[url\]|\[\/url\]/si', '', $message); $message = preg_replace('/\:[0-9a-z\:]+\]/si', ']', $message); $message = unprepare_message($message); $message = preg_replace('/(/', '(', $message); $message = preg_replace('/)/', ')', $message); $message = preg_replace('/:/', ':', $message); $message = preg_replace('/[/', '[', $message); $message = preg_replace('/]/', ']', $message); $message = preg_replace('/{/', '{', $message); $message = preg_replace('/}/', '}', $message); if (count($orig_word)) { $post_subject = preg_replace($orig_word, $replacement_word, $post_subject); $message = str_replace('\"', '"', substr(preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "preg_replace(\$orig_word, \$replacement_word, '\\0')", '>' . $message . '<'), 1, -1)); } $break = "\n\r"; $line = '-----------------------------------'; $download_file .= $break.$line.$break.$poster.$break.$post_date.$break.$break.$post_subject.$break.$line.$break.$message.$break; } $disp_folder = ( $download == -1 ) ? 'Topic_'.$topic_id : 'Post_'.$download; if (!$is_auth_read['auth_read']) { $download_file = sprintf($lang['Sorry_auth_read'], $is_auth_read['auth_read_type']); $disp_folder = 'Download'; } $filename = $board_config['sitename']."_".$disp_folder."_".date("Ymd",time()).".txt"; header('Content-Type: text/x-delimtext; name="'.$filename.'"'); header('Content-Disposition: attachment;filename="'.$filename.'"'); header('Content-Transfer-Encoding: plain/text'); header('Content-Length: '.strlen($download_file)); print $download_file; exit; } // // Start auth check // $is_auth = array(); $is_auth = auth(AUTH_ALL, $forum_id, $userdata, $forum_topic_data); if( !$is_auth['auth_view'] || !$is_auth['auth_read'] ) { if ( !$userdata['session_logged_in'] ) { $redirect = ($post_id) ? POST_POST_URL . "=$post_id" : POST_TOPIC_URL . "=$topic_id"; $redirect .= ($start) ? "&start=$start" : ''; redirect(append_sid("login.$phpEx?redirect=viewtopic.$phpEx&$redirect", true)); } $message = ( !$is_auth['auth_view'] ) ? $lang['Topic_post_not_exist'] : sprintf($lang['Sorry_auth_read'], $is_auth['auth_read_type']); message_die(GENERAL_MESSAGE, $message); } // // End auth check // $forum_name = $forum_topic_data['forum_name']; $topic_title = $forum_topic_data['topic_title']; $topic_id = intval($forum_topic_data['topic_id']); $topic_time = $forum_topic_data['topic_time']; if ($post_id) { $start = floor(($forum_topic_data['prev_posts'] - 1) / intval($board_config['posts_per_page'])) * intval($board_config['posts_per_page']); } // // Is user watching this thread? // if( $userdata['session_logged_in'] ) { $can_watch_topic = TRUE; $sql = "SELECT notify_status FROM " . TOPICS_WATCH_TABLE . " WHERE topic_id = $topic_id AND user_id = " . $userdata['user_id']; if ( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, "Could not obtain topic watch information", '', __LINE__, __FILE__, $sql); } if ( $row = $db->sql_fetchrow($result) ) { if ( isset($HTTP_GET_VARS['unwatch']) ) { if ( $HTTP_GET_VARS['unwatch'] == 'topic' ) { $is_watching_topic = 0; $sql_priority = (SQL_LAYER == "mysql") ? "LOW_PRIORITY" : ''; $sql = "DELETE $sql_priority FROM " . TOPICS_WATCH_TABLE . " WHERE topic_id = $topic_id AND user_id = " . $userdata['user_id']; if ( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, "Could not delete topic watch information", '', __LINE__, __FILE__, $sql); } } $template->assign_vars(array( 'META' => '') ); $message = $lang['No_longer_watching'] . '

' . sprintf($lang['Click_return_topic'], '', ''); message_die(GENERAL_MESSAGE, $message); } else { $is_watching_topic = TRUE; if ( $row['notify_status'] ) { $sql_priority = (SQL_LAYER == "mysql") ? "LOW_PRIORITY" : ''; $sql = "UPDATE $sql_priority " . TOPICS_WATCH_TABLE . " SET notify_status = 0 WHERE topic_id = $topic_id AND user_id = " . $userdata['user_id']; if ( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, "Could not update topic watch information", '', __LINE__, __FILE__, $sql); } } } } else { if ( isset($HTTP_GET_VARS['watch']) ) { if ( $HTTP_GET_VARS['watch'] == 'topic' ) { $is_watching_topic = TRUE; $sql_priority = (SQL_LAYER == "mysql") ? "LOW_PRIORITY" : ''; $sql = "INSERT $sql_priority INTO " . TOPICS_WATCH_TABLE . " (user_id, topic_id, notify_status) VALUES (" . $userdata['user_id'] . ", $topic_id, 0)"; if ( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, "Could not insert topic watch information", '', __LINE__, __FILE__, $sql); } } $template->assign_vars(array( 'META' => '') ); $message = $lang['You_are_watching'] . '

' . sprintf($lang['Click_return_topic'], '', ''); message_die(GENERAL_MESSAGE, $message); } else { $is_watching_topic = 0; } } } else { if ( isset($HTTP_GET_VARS['unwatch']) ) { if ( $HTTP_GET_VARS['unwatch'] == 'topic' ) { redirect(append_sid("login.$phpEx?redirect=viewtopic.$phpEx&" . POST_TOPIC_URL . "=$topic_id&unwatch=topic", true)); } } else { $can_watch_topic = 0; $is_watching_topic = 0; } } // // Generate a 'Show posts in previous x days' select box. If the postdays var is POSTed // then get it's value, find the number of topics with dates newer than it (to properly // handle pagination) and alter the main query // $previous_days = array(0, 1, 7, 14, 30, 90, 180, 364); $previous_days_text = array($lang['All_Posts'], $lang['1_Day'], $lang['7_Days'], $lang['2_Weeks'], $lang['1_Month'], $lang['3_Months'], $lang['6_Months'], $lang['1_Year']); if( !empty($HTTP_POST_VARS['postdays']) || !empty($HTTP_GET_VARS['postdays']) ) { $post_days = ( !empty($HTTP_POST_VARS['postdays']) ) ? intval($HTTP_POST_VARS['postdays']) : intval($HTTP_GET_VARS['postdays']); $min_post_time = time() - (intval($post_days) * 86400); $sql = "SELECT COUNT(p.post_id) AS num_posts FROM " . TOPICS_TABLE . " t, " . POSTS_TABLE . " p WHERE t.topic_id = $topic_id AND p.topic_id = t.topic_id AND p.post_time >= $min_post_time"; if ( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, "Could not obtain limited topics count information", '', __LINE__, __FILE__, $sql); } $total_replies = ( $row = $db->sql_fetchrow($result) ) ? intval($row['num_posts']) : 0; $limit_posts_time = "AND p.post_time >= $min_post_time "; if ( !empty($HTTP_POST_VARS['postdays'])) { $start = 0; } } else { $total_replies = intval($forum_topic_data['topic_replies']) + 1; $limit_posts_time = ''; $post_days = 0; } $select_post_days = ''; // // Decide how to order the post display // if ( !empty($HTTP_POST_VARS['postorder']) || !empty($HTTP_GET_VARS['postorder']) ) { $post_order = (!empty($HTTP_POST_VARS['postorder'])) ? htmlspecialchars($HTTP_POST_VARS['postorder']) : htmlspecialchars($HTTP_GET_VARS['postorder']); $post_time_order = ($post_order == "asc") ? "ASC" : "DESC"; } else { $post_order = 'asc'; $post_time_order = 'ASC'; } $select_post_order = ''; // // Go ahead and pull all data for this topic // $sql = "SELECT u.username, u.user_id, u.user_posts, u.user_occ, u.user_interests , 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,u.user_allow_viewonline, u.user_session_time, p.*, pt.post_text, pt.post_subject, pt.bbcode_uid FROM " . POSTS_TABLE . " p, " . USERS_TABLE . " u, " . POSTS_TEXT_TABLE . " pt WHERE p.topic_id = $topic_id $limit_posts_time AND pt.post_id = p.post_id AND u.user_id = p.poster_id ORDER BY p.post_time $post_time_order LIMIT $start, ".$board_config['posts_per_page']; if ( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, "Could not obtain post/user information.", '', __LINE__, __FILE__, $sql); } $postrow = array(); if ($row = $db->sql_fetchrow($result)) { do { $postrow[] = $row; } while ($row = $db->sql_fetchrow($result)); $db->sql_freeresult($result); $total_posts = count($postrow); } else { include($phpbb_root_path . 'includes/functions_admin.' . $phpEx); sync('topic', $topic_id); message_die(GENERAL_MESSAGE, $lang['No_posts_topic']); } $resync = FALSE; if ($forum_topic_data['topic_replies'] + 1 < $start + count($postrow)) { $resync = TRUE; } elseif ($start + $board_config['posts_per_page'] > $forum_topic_data['topic_replies']) { $row_id = intval($forum_topic_data['topic_replies']) % intval($board_config['posts_per_page']); if ($postrow[$row_id]['post_id'] != $forum_topic_data['topic_last_post_id'] || $start + count($postrow) < $forum_topic_data['topic_replies']) { $resync = TRUE; } } elseif (count($postrow) < $board_config['posts_per_page']) { $resync = TRUE; } if ($resync) { include($phpbb_root_path . 'includes/functions_admin.' . $phpEx); sync('topic', $topic_id); $result = $db->sql_query('SELECT COUNT(post_id) AS total FROM ' . POSTS_TABLE . ' WHERE topic_id = ' . $topic_id); $row = $db->sql_fetchrow($result); $total_replies = $row['total']; } $sql = "SELECT * FROM " . RANKS_TABLE . " ORDER BY rank_special, rank_min"; if ( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, "Could not obtain ranks information.", '', __LINE__, __FILE__, $sql); } $ranksrow = array(); while ( $row = $db->sql_fetchrow($result) ) { $ranksrow[] = $row; } $db->sql_freeresult($result); // // Define censored word matches // $orig_word = array(); $replacement_word = array(); obtain_word_list($orig_word, $replacement_word); // // Censor topic title // if ( count($orig_word) ) { $topic_title = preg_replace($orig_word, $replacement_word, $topic_title); } // // Was a highlight request part of the URI? // $highlight_match = $highlight = ''; if (isset($HTTP_GET_VARS['highlight'])) { // Split words and phrases $words = explode(' ', trim(htmlspecialchars($HTTP_GET_VARS['highlight']))); for($i = 0; $i < sizeof($words); $i++) { if (trim($words[$i]) != '') { $highlight_match .= (($highlight_match != '') ? '|' : '') . str_replace('*', '\w*', preg_quote($words[$i], '#')); } } unset($words); $highlight = urlencode($HTTP_GET_VARS['highlight']); $highlight_match = phpbb_rtrim($highlight_match, "\\"); } // // Post, reply and other URL generation for // templating vars // $new_topic_url = append_sid("posting.$phpEx?mode=newtopic&" . POST_FORUM_URL . "=$forum_id"); $reply_topic_url = append_sid("posting.$phpEx?mode=reply&" . POST_TOPIC_URL . "=$topic_id"); $view_forum_url = append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id"); $view_prev_topic_url = append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&view=previous"); $view_next_topic_url = append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&view=next"); // // Mozilla navigation bar // $nav_links['prev'] = array( 'url' => $view_prev_topic_url, 'title' => $lang['View_previous_topic'] ); $nav_links['next'] = array( 'url' => $view_next_topic_url, 'title' => $lang['View_next_topic'] ); $nav_links['up'] = array( 'url' => $view_forum_url, 'title' => $forum_name ); $reply_img = ( $forum_topic_data['forum_status'] == FORUM_LOCKED || $forum_topic_data['topic_status'] == TOPIC_LOCKED ) ? $images['reply_locked'] : $images['reply_new']; $reply_alt = ( $forum_topic_data['forum_status'] == FORUM_LOCKED || $forum_topic_data['topic_status'] == TOPIC_LOCKED ) ? $lang['Topic_locked'] : $lang['Reply_to_topic']; $post_img = ( $forum_topic_data['forum_status'] == FORUM_LOCKED ) ? $images['post_locked'] : $images['post_new']; $post_alt = ( $forum_topic_data['forum_status'] == FORUM_LOCKED ) ? $lang['Forum_locked'] : $lang['Post_new_topic']; // // Set a cookie for this topic // if ( $userdata['session_logged_in'] ) { $tracking_topics = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) : array(); $tracking_forums = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) : array(); if ( !empty($tracking_topics[$topic_id]) && !empty($tracking_forums[$forum_id]) ) { $topic_last_read = ( $tracking_topics[$topic_id] > $tracking_forums[$forum_id] ) ? $tracking_topics[$topic_id] : $tracking_forums[$forum_id]; } else if ( !empty($tracking_topics[$topic_id]) || !empty($tracking_forums[$forum_id]) ) { $topic_last_read = ( !empty($tracking_topics[$topic_id]) ) ? $tracking_topics[$topic_id] : $tracking_forums[$forum_id]; } else { $topic_last_read = $userdata['user_lastvisit']; } if ( count($tracking_topics) >= 150 && empty($tracking_topics[$topic_id]) ) { asort($tracking_topics); unset($tracking_topics[key($tracking_topics)]); } $tracking_topics[$topic_id] = time(); setcookie($board_config['cookie_name'] . '_t', serialize($tracking_topics), 0, $board_config['cookie_path'], $board_config['cookie_domain'], $board_config['cookie_secure']); } // // Load templates // $template->set_filenames(array( 'body' => 'viewtopic_body.tpl') ); make_jumpbox('viewforum.'.$phpEx, $forum_id); // Fast Move if ( $_POST['moveconfirm'] && $is_auth['auth_mod'] ) { $new_forum_id = intval($HTTP_POST_VARS['new_forum']); $old_forum_id = $forum_id; $sql = "UPDATE " . TOPICS_TABLE . " SET forum_id = $new_forum_id WHERE topic_id = $topic_id"; if ( !$db->sql_query($sql) ) { message_die(GENERAL_ERROR, 'Could not update old topic', '', __LINE__, __FILE__, $sql); } $sql = "UPDATE " . POSTS_TABLE . " SET forum_id = $new_forum_id WHERE topic_id = $topic_id"; if ( !$db->sql_query($sql) ) { message_die(GENERAL_ERROR, 'Could not update post topic ids', '', __LINE__, __FILE__, $sql); } // Sync the forum indexes sync('forum', $new_forum_id); sync('forum', $old_forum_id); $move_url = append_sid("viewtopic.php?t=". $topic_id); $message = $lang['Topics_Moved'] . '

'; $message .= sprintf($lang['Click_return_topic'], '', ''); message_die(GENERAL_MESSAGE, $message); } if ( $is_auth['auth_mod'] ) { $template->assign_block_vars('mod', array( 'L_MOVE_TITLE' => $lang['Move_topic'], 'L_MOVE_TO_FORUM' => $lang['Move_to_forum'], 'L_LEAVESHADOW' => $lang['Leave_shadow_topic'], 'L_YES' => $lang['Yes'], 'S_FORUM_SELECT' => make_forum_select('new_forum', $forum_id), 'S_MOVE_ACTION' => append_sid("viewtopic.php?t=". $topic_id), 'S_HIDDEN_FIELDS' => $hidden_fields) ); } // Fast Move // // Output page header // $page_title = $topic_title; include($phpbb_root_path . 'includes/page_header.'.$phpEx); //Parse smilies to display topic title $topic_title = smilies_pass($topic_title); // // User authorisation levels output // $s_auth_can = ( ( $is_auth['auth_post'] ) ? $lang['Rules_post_can'] : $lang['Rules_post_cannot'] ) . '
'; $s_auth_can .= ( ( $is_auth['auth_reply'] ) ? $lang['Rules_reply_can'] : $lang['Rules_reply_cannot'] ) . '
'; $s_auth_can .= ( ( $is_auth['auth_edit'] ) ? $lang['Rules_edit_can'] : $lang['Rules_edit_cannot'] ) . '
'; $s_auth_can .= ( ( $is_auth['auth_delete'] ) ? $lang['Rules_delete_can'] : $lang['Rules_delete_cannot'] ) . '
'; $s_auth_can .= ( ( $is_auth['auth_vote'] ) ? $lang['Rules_vote_can'] : $lang['Rules_vote_cannot'] ) . '
'; $topic_mod = ''; if ( $is_auth['auth_mod'] ) { $s_auth_can .= sprintf($lang['Rules_moderate'], "', ''); $topic_mod .= "' . $lang['Delete_topic'] . ' '; $topic_mod .= "' . $lang['Move_topic'] . ' '; $topic_mod .= ( $forum_topic_data['topic_status'] == TOPIC_UNLOCKED ) ? "' . $lang['Lock_topic'] . ' ' : "' . $lang['Unlock_topic'] . ' '; $topic_mod .= "' . $lang['Split_topic'] . ' '; } // // Topic watch information // $s_watching_topic = ''; if ( $can_watch_topic ) { if ( $is_watching_topic ) { $s_watching_topic = "' . $lang['Stop_watching_topic'] . ''; $s_watching_topic_img = ( isset($images['topic_un_watch']) ) ? "' . $lang['Stop_watching_topic'] . '' : ''; } else { $s_watching_topic = "' . $lang['Start_watching_topic'] . ''; $s_watching_topic_img = ( isset($images['Topic_watch']) ) ? "' . $lang['Start_watching_topic'] . '' : ''; } } // // If we've got a hightlight set pass it on to pagination, // I get annoyed when I lose my highlight after the first page. // $pagination = ( $highlight != '' ) ? generate_pagination("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&postdays=$post_days&postorder=$post_order&highlight=$highlight", $total_replies, $board_config['posts_per_page'], $start) : generate_pagination("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&postdays=$post_days&postorder=$post_order", $total_replies, $board_config['posts_per_page'], $start); // // Start Thank Post by User Mod // // Set to 1 to use pop-ups instead of using the same window $popup_enabled = 0; if ($popup_enabled == 1) { $thanks_javascript =''; } // // End Thank Post by User Mod // // // Send vars to template // $template->assign_vars(array( 'L_DOWNLOAD_POST' => $lang['Download_post'], 'L_DOWNLOAD_TOPIC' => $lang['Download_topic'], 'DOWNLOAD_TOPIC' => append_sid("viewtopic.$phpEx?download=-1&".POST_TOPIC_URL."=".$topic_id), 'THANKS_JAVASCRIPT' => $thanks_javascript, 'FORUM_ID' => $forum_id, 'FORUM_NAME' => $forum_name, 'TOPIC_ID' => $topic_id, 'TOPIC_TITLE' => $topic_title, 'TOPIC_REPLIES' => $forum_topic_data['topic_replies'], 'TOPIC_VIEWS' => $forum_topic_data['topic_views'] + 1, 'PAGINATION' => $pagination, 'PAGE_NUMBER' => sprintf($lang['Page_of'], ( floor( $start / intval($board_config['posts_per_page']) ) + 1 ), ceil( $total_replies / intval($board_config['posts_per_page']) )), 'POST_IMG' => $post_img, 'REPLY_IMG' => $reply_img, 'L_REPLIES' => $lang['Replies'], 'L_VIEWS' => $lang['Views'], 'L_VIEW_SINGLE' => $lang['View_single_post'], 'L_TOPIC' => $lang['Topic'], 'L_AUTHOR' => $lang['Author'], 'L_MESSAGE' => $lang['Message'], 'L_POSTED' => $lang['Posted'], 'L_POST_SUBJECT' => $lang['Post_subject'], 'L_MEMBER_NUMBER' => $lang['Member_number'], 'L_VIEW_NEXT_TOPIC' => $lang['View_next_topic'], 'L_VIEW_PREVIOUS_TOPIC' => $lang['View_previous_topic'], 'L_POST_NEW_TOPIC' => $post_alt, 'L_POST_REPLY_TOPIC' => $reply_alt, 'L_BACK_TO_TOP' => $lang['Back_to_top'], 'L_DISPLAY_POSTS' => $lang['Display_posts'], 'L_LOCK_TOPIC' => $lang['Lock_topic'], 'L_UNLOCK_TOPIC' => $lang['Unlock_topic'], 'L_MOVE_TOPIC' => $lang['Move_topic'], 'L_SPLIT_TOPIC' => $lang['Split_topic'], 'L_DELETE_TOPIC' => $lang['Delete_topic'], 'L_GOTO_PAGE' => $lang['Goto_page'], 'L_PERM_LIST' => $lang['perm_list'], 'S_TOPIC_LINK' => POST_TOPIC_URL, 'S_SELECT_POST_DAYS' => $select_post_days, 'S_SELECT_POST_ORDER' => $select_post_order, 'S_POST_DAYS_ACTION' => append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . '=' . $topic_id . "&start=$start"), 'S_AUTH_LIST' => $s_auth_can, 'S_TOPIC_ADMIN' => $topic_mod, 'S_WATCH_TOPIC' => $s_watching_topic, "U_TOPIC_BOOKMARK" => 'http://' . $board_config['server_name'] . ( ($board_config['server_port'] != '80') ? ':' . $board_config['server_port'] : '' ) . $board_config['script_path'] . "viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&view=newest", "L_TOPIC_BOOKMARK" => $lang['Topic_bookmark'], 'S_WATCH_TOPIC_IMG' => $s_watching_topic_img, 'U_VIEW_TOPIC' => append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&start=$start&postdays=$post_days&postorder=$post_order&highlight=$highlight"), 'U_VIEW_FORUM' => $view_forum_url, 'U_VIEW_OLDER_TOPIC' => $view_prev_topic_url, 'U_VIEW_NEWER_TOPIC' => $view_next_topic_url, 'U_POST_NEW_TOPIC' => $new_topic_url, 'U_POST_REPLY_TOPIC' => $reply_topic_url) ); // // Does this topic contain a poll? // if ( !empty($forum_topic_data['topic_vote']) ) { $s_hidden_fields = ''; $sql = "SELECT vd.vote_id, vd.vote_text, vd.vote_start, vd.vote_length, vr.vote_option_id, vr.vote_option_text, vr.vote_result FROM " . VOTE_DESC_TABLE . " vd, " . VOTE_RESULTS_TABLE . " vr WHERE vd.topic_id = $topic_id AND vr.vote_id = vd.vote_id ORDER BY vr.vote_option_id ASC"; if ( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, "Could not obtain vote data for this topic", '', __LINE__, __FILE__, $sql); } if ( $vote_info = $db->sql_fetchrowset($result) ) { $db->sql_freeresult($result); $vote_options = count($vote_info); $vote_id = $vote_info[0]['vote_id']; $vote_title = $vote_info[0]['vote_text']; /* $sql = "SELECT vote_id FROM " . VOTE_USERS_TABLE . " WHERE vote_id = $vote_id AND vote_user_id = " . intval($userdata['user_id']); if ( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, "Could not obtain user vote data for this topic", '', __LINE__, __FILE__, $sql); } $user_voted = ( $row = $db->sql_fetchrow($result) ) ? TRUE : 0; */ // // MOD START: View Who Voted - AbelaJohnB -- http://www.phpBB2mods.Com/ // $sql = "SELECT user_id, username FROM " . USERS_TABLE . ", " . VOTE_USERS_TABLE . " WHERE vote_id = '" . $vote_id . "' AND vote_user_id = user_id AND user_active = '1' GROUP BY username, user_id ORDER BY username"; if ( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, "Could not obtain user who have voted for the included poll. ", '', __LINE__, __FILE__, $sql); } $user_voted = false; $who_voted = ''; $first_row = true; while( $row = $db->sql_fetchrow($result) ) { $who_voted .= ($first_row ? '' : ', ') . '' . $row['username'] . ''; if ( $row['user_id'] == $userdata['user_id'] ) { $user_voted = true; } $first_row = false; } // // MOD END: View Who Voted - AbelaJohnB -- http://www.phpBB2mods.Com/ // $db->sql_freeresult($result); if ( isset($HTTP_GET_VARS['vote']) || isset($HTTP_POST_VARS['vote']) ) { $view_result = ( ( ( isset($HTTP_GET_VARS['vote']) ) ? $HTTP_GET_VARS['vote'] : $HTTP_POST_VARS['vote'] ) == 'viewresult' ) ? TRUE : 0; } else { $view_result = 0; } $poll_expired = ( $vote_info[0]['vote_length'] ) ? ( ( $vote_info[0]['vote_start'] + $vote_info[0]['vote_length'] < time() ) ? TRUE : 0 ) : 0; if ( $user_voted || $view_result || $poll_expired || !$is_auth['auth_vote'] || $forum_topic_data['topic_status'] == TOPIC_LOCKED ) { $template->set_filenames(array( 'pollbox' => 'viewtopic_poll_result.tpl') ); $vote_results_sum = 0; for($i = 0; $i < $vote_options; $i++) { $vote_results_sum += $vote_info[$i]['vote_result']; } $vote_graphic = 0; $vote_graphic_max = count($images['voting_graphic']); for($i = 0; $i < $vote_options; $i++) { $vote_percent = ( $vote_results_sum > 0 ) ? $vote_info[$i]['vote_result'] / $vote_results_sum : 0; $vote_graphic_length = round($vote_percent * $board_config['vote_graphic_length']); $vote_graphic_img = $images['voting_graphic'][$vote_graphic]; $vote_graphic = ($vote_graphic < $vote_graphic_max - 1) ? $vote_graphic + 1 : 0; if ( count($orig_word) ) { $vote_info[$i]['vote_option_text'] = preg_replace($orig_word, $replacement_word, $vote_info[$i]['vote_option_text']); } $template->assign_block_vars("poll_option", array( 'POLL_OPTION_CAPTION' => $vote_info[$i]['vote_option_text'], 'POLL_OPTION_RESULT' => $vote_info[$i]['vote_result'], 'POLL_OPTION_PERCENT' => sprintf("%.1d%%", ($vote_percent * 100)), 'POLL_OPTION_IMG' => $vote_graphic_img, 'POLL_OPTION_IMG_WIDTH' => $vote_graphic_length) ); } $template->assign_vars(array( 'L_WHO_VOTED' => $lang['Who_Voted'], 'WHO_VOTED' => $who_voted, 'L_TOTAL_VOTES' => $lang['Total_votes'], 'TOTAL_VOTES' => $vote_results_sum) ); } else { $template->set_filenames(array( 'pollbox' => 'viewtopic_poll_ballot.tpl') ); for($i = 0; $i < $vote_options; $i++) { if ( count($orig_word) ) { $vote_info[$i]['vote_option_text'] = preg_replace($orig_word, $replacement_word, $vote_info[$i]['vote_option_text']); } $template->assign_block_vars("poll_option", array( 'POLL_OPTION_ID' => $vote_info[$i]['vote_option_id'], 'POLL_OPTION_CAPTION' => $vote_info[$i]['vote_option_text']) ); } $template->assign_vars(array( 'L_SUBMIT_VOTE' => $lang['Submit_vote'], 'L_VIEW_RESULTS' => $lang['View_results'], 'U_VIEW_RESULTS' => append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&postdays=$post_days&postorder=$post_order&vote=viewresult")) ); $s_hidden_fields = ''; } if ( count($orig_word) ) { $vote_title = preg_replace($orig_word, $replacement_word, $vote_title); } $s_hidden_fields .= ''; $template->assign_vars(array( 'POLL_QUESTION' => $vote_title, 'S_HIDDEN_FIELDS' => $s_hidden_fields, 'S_POLL_ACTION' => append_sid("posting.$phpEx?mode=vote&" . POST_TOPIC_URL . "=$topic_id")) ); $template->assign_var_from_handle('POLL_DISPLAY', 'pollbox'); } } // // Update the topic view counter // $sql = "UPDATE " . TOPICS_TABLE . " SET topic_views = topic_views + 1 WHERE topic_id = $topic_id"; if ( !$db->sql_query($sql) ) { message_die(GENERAL_ERROR, "Could not update topic views.", '', __LINE__, __FILE__, $sql); } // // Okay, let's do the loop, yeah come on baby let's do the loop // and it goes like this ... // for($i = 0; $i < $total_posts; $i++) { $poster_id = $postrow[$i]['user_id']; $poster = ( $poster_id == ANONYMOUS ) ? $lang['Guest'] : $postrow[$i]['username']; // MOD START MOD_poster_last_5_topics_posts_link_in_viewtopic include('MOD_poster_last_5_topics_posts_link_in_viewtopic.'.$phpEx); // MOD END MOD_poster_last_5_topics_posts_link_in_viewtopic $post_date = create_date($board_config['default_dateformat'], $postrow[$i]['post_time'], $board_config['board_timezone']); $poster_posts = ( $postrow[$i]['user_id'] != ANONYMOUS ) ? $lang['Posts'] . ': ' . $postrow[$i]['user_posts'] : ''; $memberdays = ( $postrow[$i]['user_id'] != ANONYMOUS ) ? $lang['Memberdays'] . ': ' . max(1, round( ( time() - $postrow[$i]['user_regdate'] ) / 86400 )): ''; $poster_from = ( $postrow[$i]['user_from'] && $postrow[$i]['user_id'] != ANONYMOUS ) ? $lang['Location'] . ': ' . $postrow[$i]['user_from'] : ''; $poster_joined = ( $postrow[$i]['user_id'] != ANONYMOUS ) ? $lang['Joined'] . ': ' . create_date($lang['DATE_FORMAT'], $postrow[$i]['user_regdate'], $board_config['board_timezone']) : ''; $ppd_regdate = $postrow[$i]['user_regdate']; $ppd_memberdays = max(1, round( ( time() - $ppd_regdate ) / 86400 )); $posts_per_day = $lang['Post_per_day'] . round(($postrow[$i]['user_posts'] / $ppd_memberdays), 2) ; $poster_occupation = ( $postrow[$i]['user_id'] != ANONYMOUS ) ? $lang['Occupation'] . ': ' . ($postrow[$i]['user_occ']) : ''; $poster_interests = ( $postrow[$i]['user_id'] != ANONYMOUS ) ? $lang['Interests'] . ': ' . ($postrow[$i]['user_interests']) : ''; $poster_avatar = ''; if ( $postrow[$i]['user_avatar_type'] && $poster_id != ANONYMOUS && $postrow[$i]['user_allowavatar'] ) { switch( $postrow[$i]['user_avatar_type'] ) { case USER_AVATAR_UPLOAD: $poster_avatar = ( $board_config['allow_avatar_upload'] ) ? '' : ''; break; case USER_AVATAR_REMOTE: $poster_avatar = ( $board_config['allow_avatar_remote'] ) ? '' : ''; break; case USER_AVATAR_GALLERY: $poster_avatar = ( $board_config['allow_avatar_local'] ) ? '' : ''; break; } } // // Define the little post icon // if ( $userdata['session_logged_in'] && $postrow[$i]['post_time'] > $userdata['user_lastvisit'] && $postrow[$i]['post_time'] > $topic_last_read ) { $mini_post_img = $images['icon_minipost_new']; $mini_post_alt = $lang['New_post']; } else { $mini_post_img = $images['icon_minipost']; $mini_post_alt = $lang['Post']; } $mini_post_url = append_sid("viewtopic.$phpEx?" . POST_POST_URL . '=' . $postrow[$i]['post_id']) . '#' . $postrow[$i]['post_id']; $mini_single_post_url = append_sid("viewpost.$phpEx?" . POST_POST_URL . '=' . $postrow[$i]['post_id']); // // Generate ranks, set them to empty string initially. // $poster_rank = ''; $rank_image = ''; if ( $postrow[$i]['user_id'] == ANONYMOUS ) { } else if ( $postrow[$i]['user_rank'] ) { for($j = 0; $j < count($ranksrow); $j++) { if ( $postrow[$i]['user_rank'] == $ranksrow[$j]['rank_id'] && $ranksrow[$j]['rank_special'] ) { $poster_rank = $ranksrow[$j]['rank_title']; $rank_image = ( $ranksrow[$j]['rank_image'] ) ? '' . $poster_rank . '
' : ''; } } } else { for($j = 0; $j < count($ranksrow); $j++) { if ( $postrow[$i]['user_posts'] >= $ranksrow[$j]['rank_min'] && !$ranksrow[$j]['rank_special'] ) { $poster_rank = $ranksrow[$j]['rank_title']; $rank_image = ( $ranksrow[$j]['rank_image'] ) ? '' . $poster_rank . '
' : ''; } } } // // Handle anon users posting with usernames // if ( $poster_id == ANONYMOUS && $postrow[$i]['post_username'] != '' ) { $poster = $postrow[$i]['post_username']; $poster_rank = $lang['Guest']; } $temp_url = ''; if ( $poster_id != ANONYMOUS ) { $profile_url = append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=$poster_id"); $temp_url = append_sid("privmsg.$phpEx?mode=post&" . POST_USERS_URL . "=$poster_id"); $pm_img = '' . $lang['Send_private_message'] . ''; $pm = '' . $lang['Send_private_message'] . ''; if ( !empty($postrow[$i]['user_viewemail']) || $is_auth['auth_mod'] ) { $email_uri = ( $board_config['board_email_form'] ) ? append_sid("profile.$phpEx?mode=email&" . POST_USERS_URL .'=' . $poster_id) : 'mailto:' . $postrow[$i]['user_email']; $email_img = '' . $lang['Send_email'] . ''; $email = '' . $lang['Send_email'] . ''; } else { $email_img = ''; $email = ''; } $www_img = ( $postrow[$i]['user_website'] ) ? '' . $lang['Visit_website'] . '' : ''; $www = ( $postrow[$i]['user_website'] ) ? '' . $lang['Visit_website'] . '' : ''; if ( !empty($postrow[$i]['user_icq']) ) { $icq_status_img = ''; $icq_img = '' . $lang['ICQ'] . ''; $icq = '' . $lang['ICQ'] . ''; } else { $icq_status_img = ''; $icq_img = ''; $icq = ''; } $aim_img = ( $postrow[$i]['user_aim'] ) ? '' . $lang['AIM'] . '' : ''; $aim = ( $postrow[$i]['user_aim'] ) ? '' . $lang['AIM'] . '' : ''; $temp_url = append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=$poster_id"); $msn_img = ( $postrow[$i]['user_msnm'] ) ? '' . $lang['MSNM'] . '' : ''; $msn = ( $postrow[$i]['user_msnm'] ) ? '' . $lang['MSNM'] . '' : ''; $yim_img = ( $postrow[$i]['user_yim'] ) ? '' . $lang['YIM'] . '' : ''; $yim = ( $postrow[$i]['user_yim'] ) ? '' . $lang['YIM'] . '' : ''; } else { $profile_url = ''; $pm_img = ''; $pm = ''; $email_img = ''; $email = ''; $www_img = ''; $www = ''; $icq_status_img = ''; $icq_img = ''; $icq = ''; $aim_img = ''; $aim = ''; $msn_img = ''; $msn = ''; $yim_img = ''; $yim = ''; } $temp_url = append_sid("posting.$phpEx?mode=quote&" . POST_POST_URL . "=" . $postrow[$i]['post_id']); $quote_img = '' . $lang['Reply_with_quote'] . ''; $quote = '' . $lang['Reply_with_quote'] . ''; $temp_url = append_sid("search.$phpEx?search_author=" . urlencode($postrow[$i]['username']) . "&showresults=posts"); $search_img = '' . sprintf($lang['Search_user_posts'], $postrow[$i]['username']) . ''; $search = '' . sprintf($lang['Search_user_posts'], $postrow[$i]['username']) . ''; // // Start Thank Post by User Mod // $thanks_img = ''; if ( ($userdata['session_logged_in']) && ($userdata['user_id'] != $poster_id) ) { // Posts SQL $sql = "SELECT thanks_from_user_id FROM " . POSTS_TABLE . " WHERE post_id = " . $postrow[$i]['post_id']; if ( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, "Could not obtain post information", '', __LINE__, __FILE__, $sql); } $post_row = $db->sql_fetchrow($result); $db->sql_freeresult($result); $already_thanked = 0; if ($post_row['thanks_from_user_id'] != null) { $thanked_users = explode("|",$post_row['thanks_from_user_id']); $thanked_count = count($thanked_users); // Loop through all users who thanked the post for ($x = 0; $x < $thanked_count; $x++) { if ($thanked_users[$x] == $userdata['user_id']) { $already_thanked = 1; } } } // If the user hasn't thanked this post if ($already_thanked == 0) { $temp_url = append_sid("thanks.$phpEx?p=" . $postrow[$i]['post_id']); if ($popup_enabled == 1) { $thanks_img = '' . $lang['Thanks_text'] . ''; } else { $thanks_img = '' . $lang['Thanks_text'] . ''; } } } // // End Thank Post by User Mod // if ( ( $userdata['user_id'] == $poster_id && $is_auth['auth_edit'] ) || $is_auth['auth_mod'] ) { $temp_url = append_sid("posting.$phpEx?mode=editpost&" . POST_POST_URL . "=" . $postrow[$i]['post_id']); $edit_img = '' . $lang['Edit_delete_post'] . ''; $edit = '' . $lang['Edit_delete_post'] . ''; } else { $edit_img = ''; $edit = ''; } if ( $is_auth['auth_mod'] ) { $temp_url = "modcp.$phpEx?mode=ip&" . POST_POST_URL . "=" . $postrow[$i]['post_id'] . "&" . POST_TOPIC_URL . "=" . $topic_id . "&sid=" . $userdata['session_id']; if( $userdata['user_level'] == ADMIN ) { $ip_img = '' . $lang['View_IP'] . ''; } else { $ip_img = ''; } $ip = '' . $lang['View_IP'] . ''; $temp_url = "posting.$phpEx?mode=delete&" . POST_POST_URL . "=" . $postrow[$i]['post_id'] . "&sid=" . $userdata['session_id']; $delpost_img = '' . $lang['Delete_post'] . ''; $delpost = '' . $lang['Delete_post'] . ''; } else { $ip_img = ''; $ip = ''; if ( $userdata['user_id'] == $poster_id && $is_auth['auth_delete'] && $forum_topic_data['topic_last_post_id'] == $postrow[$i]['post_id'] ) { $temp_url = "posting.$phpEx?mode=delete&" . POST_POST_URL . "=" . $postrow[$i]['post_id'] . "&sid=" . $userdata['session_id']; $delpost_img = '' . $lang['Delete_post'] . ''; $delpost = '' . $lang['Delete_post'] . ''; } else { $delpost_img = ''; $delpost = ''; } } $post_subject = ( $postrow[$i]['post_subject'] != '' ) ? $postrow[$i]['post_subject'] : ''; $change_poster = ($userdata['user_level'] == ADMIN) ? '' . $lang['Change_poster'] . '' : ''; $message = $postrow[$i]['post_text']; $bbcode_uid = $postrow[$i]['bbcode_uid']; $user_sig = ( $postrow[$i]['enable_sig'] && $postrow[$i]['user_sig'] != '' && $board_config['allow_sig']&& $userdata['session_logged_in'] ) ? $postrow[$i]['user_sig'] : ''; $user_sig_bbcode_uid = $postrow[$i]['user_sig_bbcode_uid']; // // Note! The order used for parsing the message _is_ important, moving things around could break any // output // // // If the board has HTML off but the post has HTML // on then we process it, else leave it alone // if ( !$board_config['allow_html'] || !$userdata['user_allowhtml']) { if ( $user_sig != '' ) { $user_sig = preg_replace('#(<)([\/]?.*?)(>)#is', "<\\2>", $user_sig); } if ( $postrow[$i]['enable_html'] ) { $message = preg_replace('#(<)([\/]?.*?)(>)#is', "<\\2>", $message); } } // // Parse message and/or sig for BBCode if reqd // if ($user_sig != '' && $user_sig_bbcode_uid != '') { $user_sig = ($board_config['allow_bbcode']) ? bbencode_second_pass($user_sig, $user_sig_bbcode_uid) : preg_replace("/\:$user_sig_bbcode_uid/si", '', $user_sig); } if ($bbcode_uid != '') { $message = ($board_config['allow_bbcode']) ? bbencode_second_pass($message, $bbcode_uid) : preg_replace("/\:$bbcode_uid/si", '', $message); } if ( $user_sig != '' ) { $user_sig = make_clickable($user_sig); } $message = make_clickable($message); // // Parse smilies // if ( $board_config['allow_smilies'] ) { if ( $postrow[$i]['user_allowsmile'] && $user_sig != '' ) { $user_sig = smilies_pass($user_sig); } if ( $postrow[$i]['enable_smilies'] ) { $message = smilies_pass($message); } } // // Highlight active words (primarily for search) // if ($highlight_match) { // This was shamelessly 'borrowed' from volker at multiartstudio dot de // via php.net's annotated manual $message = str_replace('\"', '"', substr(@preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "@preg_replace('#\b(" . str_replace('\\', '\\\\', addslashes($highlight_match)) . ")\b#i', '\\\\1', '\\0')", '>' . $message . '<'), 1, -1)); } { $message = str_replace("/me "," " .$poster. " ",$message); } { $message = str_replace("/you "," " .$userdata['username']. " ",$message); } // // Replace naughty words // if (count($orig_word)) { $post_subject = preg_replace($orig_word, $replacement_word, $post_subject); if ($user_sig != '') { $user_sig = str_replace('\"', '"', substr(@preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "@preg_replace(\$orig_word, \$replacement_word, '\\0')", '>' . $user_sig . '<'), 1, -1)); } $message = str_replace('\"', '"', substr(@preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "@preg_replace(\$orig_word, \$replacement_word, '\\0')", '>' . $message . '<'), 1, -1)); } // // Replace newlines (we use this rather than nl2br because // till recently it wasn't XHTML compliant) // if ( $user_sig != '' ) { $user_sig = '
توقيع '.$poster.' :

' . str_replace("\n", "\n
\n", $user_sig) .'

'; } $message = str_replace("\n", "\n
\n", $message); // // Editing information // if ( $postrow[$i]['post_edit_count'] ) { $l_edit_time_total = ( $postrow[$i]['post_edit_count'] == 1 ) ? $lang['Edited_time_total'] : $lang['Edited_times_total']; $l_edited_by = '

' . sprintf($l_edit_time_total, $poster, create_date($board_config['default_dateformat'], $postrow[$i]['post_edit_time'], $board_config['board_timezone']), $postrow[$i]['post_edit_count']); } else { $l_edited_by = ''; } $sql = "SELECT COUNT(topic_id) AS topics FROM ". TOPICS_TABLE ." WHERE topic_poster = '". $postrow[$i]['user_id'] ."'"; if ( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, "Could not count topics", '', __LINE__, __FILE__, $sql); } $topics = $db->sql_fetchrow($result); $poster_topics = ( $postrow[$i]['user_id'] != ANONYMOUS ) ? $lang['Topics'] . ': '. ( $topics['topics'] == 0 ? $lang['None'] : $topics['topics'] ) : ''; // // Again this will be handled by the templating // code at some point // $row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2']; $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2']; // // Start Thank Post by User Mod // // If the user isn't anonymous if ($postrow[$i]['user_id'] != ANONYMOUS) { // From Users SQL $sql = "SELECT user_posts, user_thanks_given, user_thanks_received FROM " . USERS_TABLE . " WHERE user_id = " . $postrow[$i]['user_id']; if ( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, "Could not obtain user information", '', __LINE__, __FILE__, $sql); } $user_row = $db->sql_fetchrow($result); $db->sql_freeresult($result); // Thanked Posts SQL $sql = "SELECT COUNT(thanks_count) AS thanks_count FROM " . POSTS_TABLE . " WHERE poster_id = " . $postrow[$i]['user_id'] . " AND thanks_count <> 0"; if ( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, "Could not obtain posts information", '', __LINE__, __FILE__, $sql); } $thanked_post_count = $db->sql_fetchrow($result); $db->sql_freeresult($result); $thanks_given = $lang['Thanks_thanks'] . ': ' . $user_row['user_thanks_given']; $thanks_received = $lang['Thanks_thanked_1'] . ' ' . $user_row['user_thanks_received'] . ' ' . $lang['Thanks_thanked_2'] . ' ' . $thanked_post_count['thanks_count'] . ' ' . $lang['Thanks_thanked_3']; } else { $thanks_given = ""; $thanks_received = ""; } // // End Thank Post by User Mod // $template->assign_block_vars('postrow', array( 'DOWNLOAD_POST' => append_sid("viewtopic.$phpEx?download=".$postrow[$i]['post_id']."&".POST_TOPIC_URL."=".$topic_id), 'POSTER_LAST_POSTS' => $MOD_poster_last_5_posts, 'ROW_COLOR' => '#' . $row_color, 'ROW_CLASS' => $row_class, 'POSTER_NAME' => $poster, 'POSTER_RANK' => $poster_rank, 'RANK_IMAGE' => $rank_image, 'POSTER_USER_ID' => number_format($poster_id-1), 'POSTER_JOINED' => $poster_joined, 'POST_DAY_STATS' => $posts_per_day, 'POSTER_OCCUPATION' => $poster_occupation, 'POSTER_INTERESTS' => $poster_interests, 'POSTER_POSTS' => $poster_posts, 'POSTER_TOPICS' => $poster_topics, 'POSTER_FROM' => $lang['Location'] .': '. GetUserFlag($postrow[$i]['user_from']), 'POSTER_THANKS_GIVEN' => $thanks_given, 'POSTER_THANKS_RECEIVED' => $thanks_received, 'POSTER_AVATAR' => $poster_avatar, 'MEMBERDAYS' => $memberdays, 'POSTER_ONLINE' => (($postrow[$i]['user_session_time'] >= ( time() - 300 )) && ($postrow[$i]['user_allow_viewonline'])) ? '' . $lang['Online'] . '' : '' . $lang['Offline'] . '', 'POST_DATE' => $post_date, 'POST_SUBJECT' => $post_subject, 'MESSAGE' => $message, 'SIGNATURE' => $user_sig, 'EDITED_MESSAGE' => $l_edited_by, 'MINI_POST_IMG' => $mini_post_img, 'PROFILE_URL' => $profile_url, 'SEARCH_IMG' => $search_img, 'SEARCH' => $search, 'PM_IMG' => $pm_img, 'PM' => $pm, 'EMAIL_IMG' => $email_img, 'EMAIL' => $email, 'WWW_IMG' => $www_img, 'WWW' => $www, 'ICQ_STATUS_IMG' => $icq_status_img, 'ICQ_IMG' => $icq_img, 'ICQ' => $icq, 'AIM_IMG' => $aim_img, 'AIM' => $aim, 'MSN_IMG' => $msn_img, 'MSN' => $msn, 'YIM_IMG' => $yim_img, 'YIM' => $yim, 'EDIT_IMG' => $edit_img, 'EDIT' => $edit, 'THANKS_IMG' => $thanks_img, 'QUOTE_IMG' => $quote_img, 'QUOTE' => $quote, 'IP_IMG' => $ip_img, 'IP' => $ip, 'CHANGE_POSTER_IMG' => $change_poster, 'DELETE_IMG' => $delpost_img, 'DELETE' => $delpost, 'L_MINI_POST_ALT' => $mini_post_alt, 'U_MINI_POST' => $mini_post_url, 'U_MINI_SINGLE_POST' => $mini_single_post_url, 'U_SEARCH_USER_POSTS' => append_sid("search.$phpEx?search_author=" . urlencode($postrow[$i]['username']) . "&showresults=posts"), 'U_POST_ID' => $postrow[$i]['post_id']) ); // // Start Thank Post by User Mod // if ($postrow[$i]['thanks_count'] >= 1) { $thanked_by = ""; $thanked_users = explode("|",$postrow[$i]['thanks_from_user_id']); $thanked_count = $postrow[$i]['thanks_count']; // Loop through all users who thanked the post for ($x = 0; $x < $thanked_count; $x++) { // Users SQL $sql = "SELECT user_id, username FROM " . USERS_TABLE . " WHERE user_id = " . $thanked_users[$x]; if ( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, "Could not obtain user information", '', __LINE__, __FILE__, $sql); } $user_row = $db->sql_fetchrow($result); $db->sql_freeresult($result); if ($x >= 1) { $thanked_by .= ", "; } // Add user to thanked by list $temp_url = "profile.$phpEx?mode=viewprofile&u=" . $user_row['user_id']; $thanked_by .= '' . $user_row['username'] . ''; } $template->assign_block_vars('postrow.thanks', array( 'L_THANKS_TEXT' => $lang['Thanks_thanked_by'], 'THANKS_USERS' => $thanked_by) ); } // // End Thank Post by User Mod // } include($phpbb_root_path . 'quick_reply.'.$phpEx); $template->assign_vars(array( "TELL_LINK" => "http://$HTTP_HOST$PHP_SELF?t=$topic_id") ); include($phpbb_root_path . 'includes/functions_related.'.$phpEx); get_related_topics($topic_id); $template->assign_vars(array( "TELL_LINK" => "http://$HTTP_HOST$PHP_SELF?t=$topic_id") ); $template->pparse('body'); include($phpbb_root_path . 'includes/page_tail.'.$phpEx); ?>