Part of Slepp's ProjectsPastebinTURLImagebinFilebin
Feedback -- English French German Japanese
Create Upload Newest Tools Donate
Sign In | Create Account

Advertising

Paste Description for sanis

View single post

sanis
Monday, October 30th, 2006 at 10:21:21am UTC 

  1. <?php
  2. /***************************************************************************
  3. *                               viewpost.php
  4. *                            -------------------
  5. *   begin                : Saturday, May 06, 2006
  6. *   copyright            : (C) 2006 phpBBModders
  7. *   email                : [email protected]
  8. *
  9. *   $Id: viewpost.php,v 1.0.5.0 2006/8/28 21:36:20 eviL3 Exp $
  10. *
  11. *
  12. ***************************************************************************/
  13.  
  14. /***************************************************************************
  15. *
  16. *   This program is free software; you can redistribute it and/or modify
  17. *   it under the terms of the GNU General Public License as published by
  18. *   the Free Software Foundation; either version 2 of the License, or
  19. *   (at your option) any later version.
  20. *
  21. ***************************************************************************/
  22.  
  23.  /***************************************************************************
  24. *
  25. *   This is a Modified viewtopic.php, that only shows one Post. All credit
  26. *   Goes to the phpBB team. Thanks guys, you're great!
  27. *   eviL<3
  28. *
  29. ***************************************************************************/
  30.  
  31. define('IN_PHPBB', true);
  32. $phpbb_root_path = './';
  33. include($phpbb_root_path . 'extension.inc');
  34. include($phpbb_root_path . 'common.'.$phpEx);
  35. include($phpbb_root_path . 'includes/bbcode.'.$phpEx);
  36.  
  37. //
  38. // Start initial var setup
  39. //
  40.  
  41. if ( isset($HTTP_GET_VARS[POST_POST_URL]))
  42. {
  43.         $post_id = intval($HTTP_GET_VARS[POST_POST_URL]);
  44. }
  45.  
  46.  
  47. $start = ( isset($HTTP_GET_VARS['start']) ) ? intval($HTTP_GET_VARS['start']) : 0;
  48.  
  49. if (!$post_id)
  50. {
  51.         message_die(GENERAL_MESSAGE, 'No_posts_topic');
  52. }
  53.  
  54. //
  55. // This rather complex gaggle of code handles querying for topics but
  56. // also allows for direct linking to a post (and the calculation of which
  57. // page the post is on and the correct display of viewtopic)
  58. //
  59. $join_sql_table = (!$post_id) ? '' : ", " . POSTS_TABLE . " p, " . POSTS_TABLE . " p2 ";
  60. $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";
  61. $count_sql = (!$post_id) ? '' : ", COUNT(p2.post_id) AS prev_posts";
  62.  
  63. $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";
  64.  
  65. $sql = "SELECT 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" . $count_sql . "
  66.         FROM " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f" . $join_sql_table . "
  67.         WHERE $join_sql
  68.                 AND f.forum_id = t.forum_id
  69.                 $order_sql";
  70. if ( !($result = $db->sql_query($sql)) )
  71. {
  72.         message_die(GENERAL_ERROR, "Could not obtain topic information", '', __LINE__, __FILE__, $sql);
  73. }
  74.  
  75. if ( !($forum_topic_data = $db->sql_fetchrow($result)) )
  76. {
  77.         message_die(GENERAL_MESSAGE, 'Topic_post_not_exist');
  78. }
  79.  
  80. $forum_id = intval($forum_topic_data['forum_id']);
  81.  
  82. //
  83. // Start session management
  84. //
  85. $userdata = session_pagestart($user_ip, PAGE_VIEWPOST);
  86. init_userprefs($userdata);
  87. //
  88. // End session management
  89. //
  90.  
  91. //
  92. // Start auth check
  93. //
  94. $is_auth = array();
  95. $is_auth = auth(AUTH_ALL, $forum_id, $userdata, $forum_topic_data);
  96.  
  97. if( !$is_auth['auth_view'] || !$is_auth['auth_read'] )
  98. {
  99.         if ( !$userdata['session_logged_in'] )
  100.         {
  101.                 $redirect = ($post_id) ? POST_POST_URL . "=$post_id" : POST_TOPIC_URL . "=$topic_id";
  102.                 $redirect .= ($start) ? "&start=$start" : '';
  103.                 redirect(append_sid("login.$phpEx?redirect=viewtopic.$phpEx&$redirect", true));
  104.         }
  105.  
  106.         $message = ( !$is_auth['auth_view'] ) ? $lang['Topic_post_not_exist'] : sprintf($lang['Sorry_auth_read'], $is_auth['auth_read_type']);
  107.  
  108.         message_die(GENERAL_MESSAGE, $message);
  109. }
  110. //
  111. // End auth check
  112. //
  113.  
  114. $forum_name = $forum_topic_data['forum_name'];
  115. $topic_title = $forum_topic_data['topic_title'];
  116. $topic_id = intval($forum_topic_data['topic_id']);
  117. $topic_time = $forum_topic_data['topic_time'];
  118.  
  119. if ($post_id)
  120. {
  121.         $start = floor(($forum_topic_data['prev_posts'] - 1) / intval($board_config['posts_per_page'])) * intval($board_config['posts_per_page']);
  122. }
  123.  
  124.  
  125. //
  126. // Go ahead and pull all data for this topic
  127. //
  128. $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_text_compiled, pt.post_subject, pt.bbcode_uid
  129.         FROM " . POSTS_TABLE . " p, " . USERS_TABLE . " u, " . POSTS_TEXT_TABLE . " pt
  130.         WHERE pt.post_id = p.post_id
  131.                 AND u.user_id = p.poster_id
  132.       AND $post_id = p.post_id
  133.    ORDER BY p.post_time $post_time_order";
  134. if ( !($result = $db->sql_query($sql)) )
  135. {
  136.         message_die(GENERAL_ERROR, "Could not obtain post/user information.", '', __LINE__, __FILE__, $sql);
  137. }
  138.  
  139. $postrow = array();
  140. if ($row = $db->sql_fetchrow($result))
  141. {
  142.         $postrow = $row;
  143.         $db->sql_freeresult($result);
  144. }
  145. else
  146. {
  147.    include($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
  148.    sync('topic', $topic_id);
  149.  
  150.    message_die(GENERAL_MESSAGE, $lang['No_posts_topic']);
  151. }
  152.  
  153.  
  154. $sql = "SELECT *
  155.         FROM " . RANKS_TABLE . "
  156.         ORDER BY rank_special, rank_min";
  157. if ( !($result = $db->sql_query($sql)) )
  158. {
  159.         message_die(GENERAL_ERROR, "Could not obtain ranks information.", '', __LINE__, __FILE__, $sql);
  160. }
  161.  
  162. $ranksrow = array();
  163. while ( $row = $db->sql_fetchrow($result) )
  164. {
  165.         $ranksrow[] = $row;
  166. }
  167. $db->sql_freeresult($result);
  168.  
  169. //
  170. // Define censored word matches
  171. //
  172. $orig_word = array();
  173. $replacement_word = array();
  174. obtain_word_list($orig_word, $replacement_word);
  175.  
  176. //
  177. // Censor topic title
  178. //
  179. if ( count($orig_word) )
  180. {
  181.         $topic_title = preg_replace($orig_word, $replacement_word, $topic_title);
  182. }
  183.  
  184. //
  185. // Was a highlight request part of the URI?
  186. //
  187. $highlight_match = $highlight = '';
  188. if (isset($HTTP_GET_VARS['highlight']))
  189. {
  190.         // Split words and phrases
  191.         $words = explode(' ', trim(htmlspecialchars($HTTP_GET_VARS['highlight'])));
  192.  
  193.         for($i = 0; $i < sizeof($words); $i++)
  194.         {
  195.                 if (trim($words[$i]) != '')
  196.                 {
  197.                         $highlight_match .= (($highlight_match != '') ? '|' : '') . str_replace('*', '\w*', preg_quote($words[$i], '#'));
  198.                 }
  199.         }
  200.         unset($words);
  201.  
  202.         $highlight = urlencode($HTTP_GET_VARS['highlight']);
  203.         $highlight_match = phpbb_rtrim($highlight_match, "\\");
  204. }
  205.  
  206. //
  207. // Post, reply and other URL generation for
  208. // templating vars
  209. //
  210. $view_forum_url = append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id");
  211.  
  212.  
  213. //
  214. // Set a cookie for this topic
  215. //
  216. if ( $userdata['session_logged_in'] )
  217. {
  218.         $tracking_topics = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) : array();
  219.         $tracking_forums = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) : array();
  220.  
  221.         if ( !empty($tracking_topics[$topic_id]) && !empty($tracking_forums[$forum_id]) )
  222.         {
  223.                 $topic_last_read = ( $tracking_topics[$topic_id] > $tracking_forums[$forum_id] ) ? $tracking_topics[$topic_id] : $tracking_forums[$forum_id];
  224.         }
  225.         else if ( !empty($tracking_topics[$topic_id]) || !empty($tracking_forums[$forum_id]) )
  226.         {
  227.                 $topic_last_read = ( !empty($tracking_topics[$topic_id]) ) ? $tracking_topics[$topic_id] : $tracking_forums[$forum_id];
  228.         }
  229.         else
  230.         {
  231.                 $topic_last_read = $userdata['user_lastvisit'];
  232.         }
  233.  
  234.         if ( count($tracking_topics) >= 150 && empty($tracking_topics[$topic_id]) )
  235.         {
  236.                 asort($tracking_topics);
  237.                 unset($tracking_topics[key($tracking_topics)]);
  238.         }
  239.  
  240.         $tracking_topics[$topic_id] = time();
  241.  
  242.         setcookie($board_config['cookie_name'] . '_t', serialize($tracking_topics), 0, $board_config['cookie_path'], $board_config['cookie_domain'], $board_config['cookie_secure']);
  243. }
  244.  
  245. //
  246. // Load templates
  247. //
  248. $template->set_filenames(array(
  249.         'body' => 'viewpost_body.tpl')
  250. );
  251.  
  252. //
  253. // Output page header
  254. //
  255. $gen_simple_header = FALSE;
  256. $page_title = $lang['View_single_post'] .' - ' . $topic_title;
  257. include($phpbb_root_path . 'includes/page_header.'.$phpEx);
  258.  
  259.  
  260. //
  261. // Does this topic contain a poll?
  262. //
  263. if ( !empty($forum_topic_data['topic_vote']) )
  264. {
  265.         $s_hidden_fields = '';
  266.  
  267.         $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
  268.                 FROM " . VOTE_DESC_TABLE . " vd, " . VOTE_RESULTS_TABLE . " vr
  269.                 WHERE vd.topic_id = $topic_id
  270.                         AND vr.vote_id = vd.vote_id
  271.                 ORDER BY vr.vote_option_id ASC";
  272.         if ( !($result = $db->sql_query($sql)) )
  273.         {
  274.                 message_die(GENERAL_ERROR, "Could not obtain vote data for this topic", '', __LINE__, __FILE__, $sql);
  275.         }
  276.  
  277.         if ( $vote_info = $db->sql_fetchrowset($result) )
  278.         {
  279.                 $db->sql_freeresult($result);
  280.                 $vote_options = count($vote_info);
  281.  
  282.                 $vote_id = $vote_info[0]['vote_id'];
  283.                 $vote_title = $vote_info[0]['vote_text'];
  284.  
  285.                 $sql = "SELECT vote_id
  286.                         FROM " . VOTE_USERS_TABLE . "
  287.                         WHERE vote_id = $vote_id
  288.                                 AND vote_user_id = " . intval($userdata['user_id']);
  289.                 if ( !($result = $db->sql_query($sql)) )
  290.                 {
  291.                         message_die(GENERAL_ERROR, "Could not obtain user vote data for this topic", '', __LINE__, __FILE__, $sql);
  292.                 }
  293.  
  294.                 $user_voted = ( $row = $db->sql_fetchrow($result) ) ? TRUE : 0;
  295.                 $db->sql_freeresult($result);
  296.  
  297.                 if ( isset($HTTP_GET_VARS['vote']) || isset($HTTP_POST_VARS['vote']) )
  298.                 {
  299.                         $view_result = ( ( ( isset($HTTP_GET_VARS['vote']) ) ? $HTTP_GET_VARS['vote'] : $HTTP_POST_VARS['vote'] ) == 'viewresult' ) ? TRUE : 0;
  300.                 }
  301.                 else
  302.                 {
  303.                         $view_result = 0;
  304.                 }
  305.  
  306.                 $poll_expired = ( $vote_info[0]['vote_length'] ) ? ( ( $vote_info[0]['vote_start'] + $vote_info[0]['vote_length'] < time() ) ? TRUE : 0 ) : 0;
  307.  
  308.                 if ( $user_voted || $view_result || $poll_expired || !$is_auth['auth_vote'] || $forum_topic_data['topic_status'] == TOPIC_LOCKED )
  309.                 {
  310.                         $template->set_filenames(array(
  311.                                 'pollbox' => 'viewtopic_poll_result.tpl')
  312.                         );
  313.  
  314.                         $vote_results_sum = 0;
  315.  
  316.                         for($i = 0; $i < $vote_options; $i++)
  317.                         {
  318.                                 $vote_results_sum += $vote_info[$i]['vote_result'];
  319.                         }
  320.  
  321.                         $vote_graphic = 0;
  322.                         $vote_graphic_max = count($images['voting_graphic']);
  323.  
  324.                         for($i = 0; $i < $vote_options; $i++)
  325.                         {
  326.                                 $vote_percent = ( $vote_results_sum > 0 ) ? $vote_info[$i]['vote_result'] / $vote_results_sum : 0;
  327.                                 $vote_graphic_length = round($vote_percent * $board_config['vote_graphic_length']);
  328.  
  329.                                 $vote_graphic_img = $images['voting_graphic'][$vote_graphic];
  330.                                 $vote_graphic = ($vote_graphic < $vote_graphic_max - 1) ? $vote_graphic + 1 : 0;
  331.  
  332.                                 if ( count($orig_word) )
  333.                                 {
  334.                                         $vote_info[$i]['vote_option_text'] = preg_replace($orig_word, $replacement_word, $vote_info[$i]['vote_option_text']);
  335.                                 }
  336.  
  337.                                 $template->assign_block_vars("poll_option", array(
  338.                                         'POLL_OPTION_CAPTION' => $vote_info[$i]['vote_option_text'],
  339.                                         'POLL_OPTION_RESULT' => $vote_info[$i]['vote_result'],
  340.                                         'POLL_OPTION_PERCENT' => sprintf("%.1d%%", ($vote_percent * 100)),
  341.  
  342.                                         'POLL_OPTION_IMG' => $vote_graphic_img,
  343.                                         'POLL_OPTION_IMG_WIDTH' => $vote_graphic_length)
  344.                                 );
  345.                         }
  346.  
  347.                         $template->assign_vars(array(
  348.                                 'L_TOTAL_VOTES' => $lang['Total_votes'],
  349.                                 'TOTAL_VOTES' => $vote_results_sum)
  350.                         );
  351.  
  352.                 }
  353.                 else
  354.                 {
  355.                         $template->set_filenames(array(
  356.                                 'pollbox' => 'viewtopic_poll_ballot.tpl')
  357.                         );
  358.  
  359.                         for($i = 0; $i < $vote_options; $i++)
  360.                         {
  361.                                 if ( count($orig_word) )
  362.                                 {
  363.                                         $vote_info[$i]['vote_option_text'] = preg_replace($orig_word, $replacement_word, $vote_info[$i]['vote_option_text']);
  364.                                 }
  365.  
  366.                                 $template->assign_block_vars("poll_option", array(
  367.                                         'POLL_OPTION_ID' => $vote_info[$i]['vote_option_id'],
  368.                                         'POLL_OPTION_CAPTION' => $vote_info[$i]['vote_option_text'])
  369.                                 );
  370.                         }
  371.  
  372.                         $template->assign_vars(array(
  373.                                 'L_SUBMIT_VOTE' => $lang['Submit_vote'],
  374.                                 'L_VIEW_RESULTS' => $lang['View_results'],
  375.  
  376.                                 'U_VIEW_RESULTS' => append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;postdays=$post_days&amp;postorder=$post_order&amp;vote=viewresult"))
  377.                         );
  378.  
  379.                         $s_hidden_fields = '<input type="hidden" name="topic_id" value="' . $topic_id . '" /><input type="hidden" name="mode" value="vote" />';
  380.                 }
  381.  
  382.                 if ( count($orig_word) )
  383.                 {
  384.                         $vote_title = preg_replace($orig_word, $replacement_word, $vote_title);
  385.                 }
  386.  
  387.                 $s_hidden_fields .= '<input type="hidden" name="sid" value="' . $userdata['session_id'] . '" />';
  388.  
  389.                 $template->assign_vars(array(
  390.                         'POLL_QUESTION' => $vote_title,
  391.  
  392.                         'S_HIDDEN_FIELDS' => $s_hidden_fields,
  393.                         'S_POLL_ACTION' => append_sid("posting.$phpEx?mode=vote&amp;" . POST_TOPIC_URL . "=$topic_id"))
  394.                 );
  395.  
  396.                 $template->assign_var_from_handle('POLL_DISPLAY', 'pollbox');
  397.         }
  398. }
  399.  
  400.  
  401.  
  402. // Start Removed loop
  403. $poster_id = $postrow['user_id'];
  404. $poster = ( $poster_id == ANONYMOUS ) ? $lang['Guest'] : $postrow['username'];
  405.  
  406. $post_date = create_date($board_config['default_dateformat'], $postrow['post_time'], $board_config['board_timezone']);
  407.  
  408. $poster_avatar = '';
  409. if ( $postrow['user_avatar_type'] && $poster_id != ANONYMOUS && $postrow['user_allowavatar'] )
  410. {
  411.         switch( $postrow['user_avatar_type'] )
  412.         {
  413.                 case USER_AVATAR_UPLOAD:
  414.                         $poster_avatar = ( $board_config['allow_avatar_upload'] ) ? '<img src="' . $board_config['avatar_path'] . '/' . $postrow['user_avatar'] . '" alt="" border="0" />' : '';
  415.                         break;
  416.                 case USER_AVATAR_REMOTE:
  417.                         $poster_avatar = ( $board_config['allow_avatar_remote'] ) ? '<img src="' . $postrow['user_avatar'] . '" alt="" border="0" />' : '';
  418.                         break;
  419.                 case USER_AVATAR_GALLERY:
  420.                         $poster_avatar = ( $board_config['allow_avatar_local'] ) ? '<img src="' . $board_config['avatar_gallery_path'] . '/' . $postrow['user_avatar'] . '" alt="" border="0" />' : '';
  421.                         break;
  422.         }
  423. }
  424. // Added for XS BBCode Parser
  425. $sig_cache = array();
  426.  
  427. //
  428. // Define the little post icon
  429. //
  430. if ( $userdata['session_logged_in'] && $postrow['post_time'] > $userdata['user_lastvisit'] && $postrow['post_time'] > $topic_last_read )
  431. {
  432.         $mini_post_img = $images['icon_minipost_new'];
  433.         $mini_post_alt = $lang['New_post'];
  434. }
  435. else
  436. {
  437.         $mini_post_img = $images['icon_minipost'];
  438.         $mini_post_alt = $lang['Post'];
  439. }
  440.  
  441. $mini_post_url = append_sid("viewtopic.$phpEx?" . POST_POST_URL . '=' . $postrow['post_id']) . '#' . $postrow['post_id'];
  442.  
  443. //
  444. // Generate ranks, set them to empty string initially.
  445. //
  446. $poster_rank = '';
  447. $rank_image = '';
  448. if ( $postrow['user_id'] == ANONYMOUS )
  449. {
  450. }
  451. else if ( $postrow['user_rank'] )
  452. {
  453.         for($j = 0; $j < count($ranksrow); $j++)
  454.         {
  455.                 if ( $postrow['user_rank'] == $ranksrow[$j]['rank_id'] && $ranksrow[$j]['rank_special'] )
  456.                 {
  457.                         $poster_rank = $ranksrow[$j]['rank_title'];
  458.                         $rank_image = ( $ranksrow[$j]['rank_image'] ) ? '<img src="' . $ranksrow[$j]['rank_image'] . '" alt="' . $poster_rank . '" title="' . $poster_rank . '" border="0" /><br />' : '';
  459.                 }
  460.         }
  461. }
  462. else
  463. {
  464.         for($j = 0; $j < count($ranksrow); $j++)
  465.         {
  466.                 if ( $postrow['user_posts'] >= $ranksrow[$j]['rank_min'] && !$ranksrow[$j]['rank_special'] )
  467.                 {
  468.                         $poster_rank = $ranksrow[$j]['rank_title'];
  469.                         $rank_image = ( $ranksrow[$j]['rank_image'] ) ? '<img src="' . $ranksrow[$j]['rank_image'] . '" alt="' . $poster_rank . '" title="' . $poster_rank . '" border="0" /><br />' : '';
  470.                 }
  471.         }
  472. }
  473.  
  474. //
  475. // Handle anon users posting with usernames
  476. //
  477. if ( $poster_id == ANONYMOUS && $postrow['post_username'] != '' )
  478. {
  479.         $poster = $postrow['post_username'];
  480.         $poster_rank = $lang['Guest'];
  481. }
  482.  
  483. $temp_url = '';
  484.  
  485. if ( $poster_id != ANONYMOUS )
  486. {
  487.         $temp_url = append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . "=$poster_id");
  488.         $profile_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_profile'] . '" alt="' . $lang['Read_profile'] . '" title="' . $lang['Read_profile'] . '" border="0" /></a>';
  489.         $profile = '<a href="' . $temp_url . '">' . $lang['Read_profile'] . '</a>';
  490.  
  491.         $temp_url = append_sid("privmsg.$phpEx?mode=post&amp;" . POST_USERS_URL . "=$poster_id");
  492.         $pm_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_pm'] . '" alt="' . $lang['Send_private_message'] . '" title="' . $lang['Send_private_message'] . '" border="0" /></a>';
  493.         $pm = '<a href="' . $temp_url . '">' . $lang['Send_private_message'] . '</a>';
  494.  
  495.         if ( !empty($postrow['user_viewemail']) || $is_auth['auth_mod'] )
  496.         {
  497.                 $email_uri = ( $board_config['board_email_form'] ) ? append_sid("profile.$phpEx?mode=email&amp;" . POST_USERS_URL .'=' . $poster_id) : 'mailto:' . $postrow['user_email'];
  498.  
  499.                 $email_img = '<a href="' . $email_uri . '"><img src="' . $images['icon_email'] . '" alt="' . $lang['Send_email'] . '" title="' . $lang['Send_email'] . '" border="0" /></a>';
  500.                 $email = '<a href="' . $email_uri . '">' . $lang['Send_email'] . '</a>';
  501.         }
  502.         else
  503.         {
  504.                 $email_img = '';
  505.                 $email = '';
  506.         }
  507.  
  508.         $www_img = ( $postrow['user_website'] ) ? '<a href="' . $postrow['user_website'] . '" target="_userwww"><img src="' . $images['icon_www'] . '" alt="' . $lang['Visit_website'] . '" title="' . $lang['Visit_website'] . '" border="0" /></a>' : '';
  509.         $www = ( $postrow['user_website'] ) ? '<a href="' . $postrow['user_website'] . '" target="_userwww">' . $lang['Visit_website'] . '</a>' : '';
  510.  
  511.         if ( !empty($postrow['user_icq']) )
  512.         {
  513.                 $icq_status_img = '<a href="http://wwp.icq.com/' . $postrow['user_icq'] . '#pager"><img src="http://web.icq.com/whitepages/online?icq=' . $postrow['user_icq'] . '&img=5" width="18" height="18" border="0" /></a>';
  514.                 $icq_img = '<a href="http://wwp.icq.com/scripts/search.dll?to=' . $postrow['user_icq'] . '"><img src="' . $images['icon_icq'] . '" alt="' . $lang['ICQ'] . '" title="' . $lang['ICQ'] . '" border="0" /></a>';
  515.                 $icq'<a href="http://wwp.icq.com/scripts/search.dll?to=' . $postrow['user_icq'] . '">' . $lang['ICQ'] . '</a>';
  516.         }
  517.         else
  518.         {
  519.                 $icq_status_img = '';
  520.                 $icq_img = '';
  521.                 $icq = '';
  522.         }
  523.  
  524.         $aim_img = ( $postrow['user_aim'] ) ? '<a href="aim:goim?screenname=' . $postrow['user_aim'] . '&amp;message=Hello+Are+you+there?"><img src="' . $images['icon_aim'] . '" alt="' . $lang['AIM'] . '" title="' . $lang['AIM'] . '" border="0" /></a>' : '';
  525.         $aim = ( $postrow['user_aim'] ) ? '<a href="aim:goim?screenname=' . $postrow['user_aim'] . '&amp;message=Hello+Are+you+there?">' . $lang['AIM'] . '</a>' : '';
  526.  
  527.         $temp_url = append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . "=$poster_id");
  528.         $msn_img = ( $postrow['user_msnm'] ) ? '<a href="' . $temp_url . '"><img src="' . $images['icon_msnm'] . '" alt="' . $lang['MSNM'] . '" title="' . $lang['MSNM'] . '" border="0" /></a>' : '';
  529.         $msn = ( $postrow['user_msnm'] ) ? '<a href="' . $temp_url . '">' . $lang['MSNM'] . '</a>' : '';
  530.  
  531.         $yim_img = ( $postrow['user_yim'] ) ? '<a href="http://edit.yahoo.com/config/send_webmesg?.target=' . $postrow['user_yim'] . '&amp;.src=pg"><img src="' . $images['icon_yim'] . '" alt="' . $lang['YIM'] . '" title="' . $lang['YIM'] . '" border="0" /></a>' : '';
  532.         $yim = ( $postrow['user_yim'] ) ? '<a href="http://edit.yahoo.com/config/send_webmesg?.target=' . $postrow['user_yim'] . '&amp;.src=pg">' . $lang['YIM'] . '</a>' : '';
  533. }
  534. else
  535. {
  536.         $profile_img = '';
  537.         $profile = '';
  538.         $pm_img = '';
  539.         $pm = '';
  540.         $email_img = '';
  541.         $email = '';
  542.         $www_img = '';
  543.         $www = '';
  544.         $icq_status_img = '';
  545.         $icq_img = '';
  546.         $icq = '';
  547.         $aim_img = '';
  548.         $aim = '';
  549.         $msn_img = '';
  550.         $msn = '';
  551.         $yim_img = '';
  552.         $yim = '';
  553. }
  554.  
  555. $temp_url = append_sid("posting.$phpEx?mode=quote&amp;" . POST_POST_URL . "=" . $postrow['post_id']);
  556. $quote_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_quote'] . '" alt="' . $lang['Reply_with_quote'] . '" title="' . $lang['Reply_with_quote'] . '" border="0" /></a>';
  557. $quote = '<a href="' . $temp_url . '">' . $lang['Reply_with_quote'] . '</a>';
  558.  
  559. if ( ( $userdata['user_id'] == $poster_id && $is_auth['auth_edit'] ) || $is_auth['auth_mod'] )
  560. {
  561.         $temp_url = append_sid("posting.$phpEx?mode=editpost&amp;" . POST_POST_URL . "=" . $postrow['post_id']);
  562.         $edit_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_edit'] . '" alt="' . $lang['Edit_delete_post'] . '" title="' . $lang['Edit_delete_post'] . '" border="0" /></a>';
  563.         $edit = '<a href="' . $temp_url . '">' . $lang['Edit_delete_post'] . '</a>';
  564. }
  565. else
  566. {
  567.         $edit_img = '';
  568.         $edit = '';
  569. }
  570.  
  571. if ( $is_auth['auth_mod'] )
  572. {
  573.         $temp_url = "modcp.$phpEx?mode=ip&amp;" . POST_POST_URL . "=" . $postrow['post_id'] . "&amp;" . POST_TOPIC_URL . "=" . $topic_id . "&amp;sid=" . $userdata['session_id'];
  574.         $ip_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_ip'] . '" alt="' . $lang['View_IP'] . '" title="' . $lang['View_IP'] . '" border="0" /></a>';
  575.         $ip = '<a href="' . $temp_url . '">' . $lang['View_IP'] . '</a>';
  576.  
  577.         $temp_url = "posting.$phpEx?mode=delete&amp;" . POST_POST_URL . "=" . $postrow['post_id'] . "&amp;sid=" . $userdata['session_id'];
  578.         $delpost_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_delpost'] . '" alt="' . $lang['Delete_post'] . '" title="' . $lang['Delete_post'] . '" border="0" /></a>';
  579.         $delpost = '<a href="' . $temp_url . '">' . $lang['Delete_post'] . '</a>';
  580. }
  581. else
  582. {
  583.         $ip_img = '';
  584.         $ip = '';
  585.  
  586.         if ( $userdata['user_id'] == $poster_id && $is_auth['auth_delete'] && $forum_topic_data['topic_last_post_id'] == $postrow['post_id'] )
  587.         {
  588.                 $temp_url = "posting.$phpEx?mode=delete&amp;" . POST_POST_URL . "=" . $postrow['post_id'] . "&amp;sid=" . $userdata['session_id'];
  589.                 $delpost_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_delpost'] . '" alt="' . $lang['Delete_post'] . '" title="' . $lang['Delete_post'] . '" border="0" /></a>';
  590.                 $delpost = '<a href="' . $temp_url . '">' . $lang['Delete_post'] . '</a>';
  591.         }
  592.         else
  593.         {
  594.                 $delpost_img = '';
  595.                 $delpost = '';
  596.         }
  597. }
  598.  
  599. $post_subject = ( $postrow['post_subject'] != '' ) ? $postrow['post_subject'] : '';
  600.  
  601. $message = $postrow['post_text'];
  602. // add XS BBCode parser
  603.         if( preg_match('/\[you/i', $message) || preg_match('/\[hide/i', $message) || preg_match('/\[version/i', $message) )
  604.         {
  605.                 $message_compiled = false;
  606.         }
  607.         else
  608.         {
  609.                 $message_compiled = empty($postrow['post_text_compiled']) ? false : $postrow['post_text_compiled'];
  610.         }
  611.  
  612. $bbcode_uid = $postrow['bbcode_uid'];
  613.  
  614. $user_sig = ( $postrow['enable_sig'] && $postrow['user_sig'] != '' && $board_config['allow_sig'] ) ? $postrow['user_sig'] : '';
  615. $user_sig_bbcode_uid = $postrow['user_sig_bbcode_uid'];
  616.  
  617. //
  618. // Note! The order used for parsing the message _is_ important, moving things around could break any
  619. // output
  620. //
  621.  
  622. //
  623.         // Parse message and/or sig for BBCode if reqd
  624.         //
  625.         $xs_bbcode->allow_bbcode = $board_config['allow_bbcode'];
  626.         $xs_bbcode->allow_smilies = $board_config['allow_smilies'];
  627.         $xs_bbcode->allow_remote_urls = $board_config['livelinks_enable'];
  628.         if($user_sig && empty($sig_cache[$postrow['user_id']]))
  629.         {
  630.                 $xs_bbcode->is_sig = true;
  631.                 $user_sig = $xs_bbcode->parse($user_sig, $user_sig_bbcode_uid);
  632.                 $sig_cache[$postrow['user_id']] = $user_sig;
  633.                 $xs_bbcode->is_sig = false;
  634.         }
  635.         elseif($user_sig)
  636.         {
  637.                 $user_sig = $sig_cache[$postrow['user_id']];
  638.         }
  639.         if($message_compiled === false)
  640.         {
  641.                 $xs_bbcode->allow_smilies = $board_config['allow_smilies'] && $postrow['user_allowsmile'] ? true : false;
  642.                 $GLOBALS['code_post_id'] = $postrow['post_id'];
  643.                 $message = $xs_bbcode->parse($message, $bbcode_uid);
  644.                 $GLOBALS['code_post_id'] = 0;
  645.                 // update database
  646.                 $sql = "UPDATE " . POSTS_TEXT_TABLE . " SET post_text_compiled='" . addslashes($message) . "' WHERE post_id='" . $postrow['post_id'] . "'";
  647.                 if( !($db->sql_query($sql)) )
  648.                 {
  649.                         message_die(GENERAL_ERROR, 'Unable to update compiled text for this post: ' . $postrow['post_id'], '', __LINE__, __FILE__, $sql);
  650.                 }
  651.         }
  652.         else
  653.         {
  654.                 $message = $message_compiled;
  655.         }
  656.  
  657. /*
  658. //      original code commented to add CA's BBCode Parser
  659.        
  660.         //
  661.         // If the board has HTML off but the post has HTML
  662.         // on then we process it, else leave it alone
  663.         //
  664.         if ( !$board_config['allow_html'] || !$userdata['user_allowhtml'])
  665.         {
  666.                 if ( $user_sig != '' )
  667.                 {
  668.                         $user_sig = preg_replace('#(<)([\/]?.*?)(>)#is', "&lt;\\2&gt;", $user_sig);
  669.                 }
  670.  
  671.                 if ( $postrow['enable_html'] )
  672.                 {
  673.                         $message = preg_replace('#(<)([\/]?.*?)(>)#is', "&lt;\\2&gt;", $message);
  674.                 }
  675.         }
  676.  
  677.         //
  678.         // Parse message and/or sig for BBCode if reqd
  679.         //
  680.         if ($user_sig != '' && $user_sig_bbcode_uid != '')
  681.         {
  682.                 $user_sig = ($board_config['allow_bbcode']) ? bbencode_second_pass($user_sig, $user_sig_bbcode_uid) : preg_replace("/\:$user_sig_bbcode_uid/si", '', $user_sig);
  683.         }
  684.  
  685.         if ($bbcode_uid != '')
  686.         {
  687.                 $message = ($board_config['allow_bbcode']) ? bbencode_second_pass($message, $bbcode_uid) : preg_replace("/\:$bbcode_uid/si", '', $message);
  688.         }
  689.  
  690.         if ( $user_sig != '' )
  691.         {
  692.                 $user_sig = make_clickable($user_sig);
  693.         }
  694.         $message = make_clickable($message);
  695.  
  696.         //
  697.         // Parse smilies
  698.         //
  699.         if ( $board_config['allow_smilies'] )
  700.         {
  701.                 if ( $postrow['user_allowsmile'] && $user_sig != '' )
  702.                 {
  703.                         $user_sig = smilies_pass($user_sig);
  704.                 }
  705.  
  706.                 if ( $postrow['enable_smilies'] )
  707.                 {
  708.                         $message = smilies_pass($message);
  709.                 }
  710.         }
  711.  
  712. //      end comment
  713. */
  714.  
  715.  
  716. //
  717. // Highlight active words (primarily for search)
  718. //
  719. if ($highlight_match)
  720. {
  721.         // This has been back-ported from 3.0 CVS
  722.         $message = preg_replace('#(?!<.*)(?<!\w)(' . $highlight_match . ')(?!\w|[^<>]*>)#i', '<b style="color:#'.$theme['fontcolor3'].'">\1</b>', $message);
  723. }
  724.  
  725. //
  726. // Replace naughty words
  727. //
  728. if (count($orig_word))
  729. {
  730.         $post_subject = preg_replace($orig_word, $replacement_word, $post_subject);
  731.  
  732.         if ($user_sig != '')
  733.         {
  734.                 $user_sig = str_replace('\"', '"', substr(@preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "@preg_replace(\$orig_word, \$replacement_word, '\\0')", '>' . $user_sig . '<'), 1, -1));
  735.         }
  736.  
  737.         $message = str_replace('\"', '"', substr(@preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "@preg_replace(\$orig_word, \$replacement_word, '\\0')", '>' . $message . '<'), 1, -1));
  738. }
  739.  
  740. //
  741. // Replace newlines (we use this rather than nl2br because
  742. // till recently it wasn't XHTML compliant)
  743. //
  744. if ( $user_sig != '' )
  745. {
  746.         /*
  747. // Commented XS BBCode Parser
  748.                 $user_sig = '<br />_________________<br />' . str_replace("\n", "\n<br />\n", $user_sig);
  749. */
  750.                 $user_sig = '<br />_________________<br />' . $user_sig;
  751.  
  752. }
  753.  
  754. /*
  755. // Start Comment BBCode Parser
  756.         $message = str_replace("\n", "\n<br />\n", $message);
  757. // End Comment BBCode Parser
  758. */
  759. //
  760. // Editing information
  761. //
  762. if ( $postrow['post_edit_count'] )
  763. {
  764.         $l_edit_time_total = ( $postrow['post_edit_count'] == 1 ) ? $lang['Edited_time_total'] : $lang['Edited_times_total'];
  765.  
  766.         $l_edited_by = '<br /><br />' . sprintf($l_edit_time_total, $poster, create_date($board_config['default_dateformat'], $postrow['post_edit_time'], $board_config['board_timezone']), $postrow['post_edit_count']);
  767. }
  768. else
  769. {
  770.         $l_edited_by = '';
  771. }
  772. // Start Edit Notes MOD
  773.  
  774. // End Removed loop
  775.  
  776.  
  777. //
  778. // If we've got a hightlight set pass it on to pagination,
  779. // I get annoyed when I lose my highlight after the first page.
  780. //
  781. $pagination = ( $highlight != '' ) ? generate_pagination("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;postdays=$post_days&amp;postorder=$post_order&amp;highlight=$highlight", $total_replies, $board_config['posts_per_page'], $start) : generate_pagination("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;postdays=$post_days&amp;postorder=$post_order", $total_replies, $board_config['posts_per_page'], $start);
  782.  
  783. //
  784. // Send vars to template
  785. //
  786. $template->assign_vars(array(
  787.   'TOPIC_ID' => $topic_id,
  788.     'TOPIC_TITLE' => $topic_title,
  789.  
  790.         'ROW_COLOR' => '#' . $theme['td_color1'],
  791.         'ROW_CLASS' => $theme['td_class1'],
  792.         'POSTER_NAME' => $poster,
  793.         'POSTER_RANK' => $poster_rank,
  794.         'RANK_IMAGE' => $rank_image,
  795.         'POSTER_AVATAR' => $poster_avatar,
  796.         'POST_DATE' => $post_date,
  797.         'POST_SUBJECT' => $post_subject,
  798.         'MESSAGE' => $message,
  799.         'SIGNATURE' => $user_sig,
  800.         'EDITED_MESSAGE' => $l_edited_by,
  801.  
  802.         'MINI_POST_IMG' => $mini_post_img,
  803.         'PROFILE_IMG' => $profile_img,
  804.         'PROFILE' => $profile,
  805.         'SEARCH_IMG' => $search_img,
  806.         'SEARCH' => $search,
  807.         'PM_IMG' => $pm_img,
  808.         'PM' => $pm,
  809.         'EMAIL_IMG' => $email_img,
  810.         'EMAIL' => $email,
  811.         'WWW_IMG' => $www_img,
  812.         'WWW' => $www,
  813.         'ICQ_STATUS_IMG' => $icq_status_img,
  814.         'ICQ_IMG' => $icq_img,
  815.         'ICQ' => $icq,
  816.         'AIM_IMG' => $aim_img,
  817.         'AIM' => $aim,
  818.         'MSN_IMG' => $msn_img,
  819.         'MSN' => $msn,
  820.         'YIM_IMG' => $yim_img,
  821.         'YIM' => $yim,
  822.         'EDIT_IMG' => $edit_img,
  823.         'EDIT' => $edit,
  824.         'QUOTE_IMG' => $quote_img,
  825.         'QUOTE' => $quote,
  826.         'IP_IMG' => $ip_img,
  827.         'IP' => $ip,
  828.         'DELETE_IMG' => $delpost_img,
  829.         'DELETE' => $delpost,
  830.         'REPLY_IMG' => $reply_img,
  831.  
  832.         'L_VIEW_SINGLE' => $lang['View_single_post'],
  833.         'L_TOPIC' => $lang['Topic'],
  834.         'L_AUTHOR' => $lang['Author'],
  835.         'L_MESSAGE' => $lang['Message'],
  836.         'L_POSTED' => $lang['Posted'],
  837.         'L_POST_SUBJECT' => $lang['Post_subject'],
  838.         'L_MINI_POST_ALT' => $mini_post_alt,
  839.  
  840.         'U_VIEW_TOPIC' => append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;start=$start&amp;postdays=$post_days&amp;postorder=$post_order&amp;highlight=$highlight"),
  841.         'U_MINI_POST' => $mini_post_url,
  842.         'U_POST_ID' => $postrow['post_id'])
  843. );
  844.  
  845.  
  846. //
  847. // Okay, let's NOT do the loop, yeah come on baby let's NOT do the loop
  848. // and it goes NOT like this ... LOL
  849. //
  850.  
  851.         if ( $board_config['edit_notes_enable'] )
  852.         {
  853.                 $mode = ( isset($HTTP_GET_VARS['mode']) ) ? htmlspecialchars($HTTP_GET_VARS['mode']) : htmlspecialchars($HTTP_POST_VARS['mode']);
  854.                 $sid = ( isset($HTTP_GET_VARS['sid']) ) ? htmlspecialchars($HTTP_GET_VARS['sid']) : htmlspecialchars($HTTP_POST_VARS['sid']);
  855.                 $u_post_id = ( isset($HTTP_GET_VARS[POST_POST_URL]) ) ? intval($HTTP_GET_VARS[POST_POST_URL]) : intval($HTTP_POST_VARS[POST_POST_URL]);
  856.                 $u_topic_id = ( isset($HTTP_GET_VARS[POST_TOPIC_URL]) ) ? intval($HTTP_GET_VARS[POST_TOPIC_URL]) : intval($HTTP_POST_VARS[POST_TOPIC_URL]);
  857.                 $u_edit_note_id = ( isset($HTTP_GET_VARS['edit_note_id']) ) ? intval($HTTP_GET_VARS['edit_note_id']) : intval($HTTP_POST_VARS['edit_note_id']);
  858.                 $confirm = isset($HTTP_POST_VARS['confirm']) ? true : false;
  859.                 $cancel = isset($HTTP_POST_VARS['cancel']) ? true : false;
  860.                
  861.                 // Are we trying to delete a note?
  862.                 if ( $mode == 'deletenote' && $sid && $u_edit_note_id && $u_post_id )
  863.                 {
  864.                         // To delete a note requires a session ID. No SID or invalid one? Die to prevent session hijacking.
  865.                         if ( $sid == '' || $sid != $userdata['session_id'] )
  866.                         {
  867.                                 message_die(GENERAL_ERROR, 'Invalid_session');
  868.                         }
  869.                        
  870.                         $sql = 'SELECT user_id FROM ' . EDIT_NOTES_TABLE . " WHERE edit_note_id = $u_edit_note_id";
  871.                        
  872.                         if ( !($result = $db->sql_query($sql)) )
  873.                         {
  874.                                 message_die(GENERAL_ERROR, 'Could not look up user ID for this edit note', '', __LINE__, __FILE__, $sql);
  875.                         }
  876.                        
  877.                         if ( !($row = $db->sql_fetchrow($result)) )
  878.                         {
  879.                                 message_die(GENERAL_ERROR, 'Could not retrieve user ID for this edit note', '', __LINE__, __FILE__, $sql);
  880.                         }
  881.                        
  882.                         $user_id = $row['user_id'];
  883.                        
  884.                         // Auth check. Is the user deleting the note the author or a mod/admin?
  885.                         if ( $is_auth['auth_delete'] != 1 || ( $is_auth['auth_mod'] == 0 && $user_id != $userdata['user_id'] ) )
  886.                         {
  887.                                 message_die(GENERAL_ERROR, $lang['Not_Authorised']);
  888.                         }
  889.                        
  890.                         // Was cancel pressed when deleting a note?
  891.                         if ( $cancel )
  892.                         {
  893.                                 redirect(append_sid("viewtopic.$phpEx?" . POST_POST_URL . "=$u_post_id", true) . "#$u_post_id");
  894.                         }
  895.                        
  896.                         // Confirm edit note deletion
  897.                         if ( !$confirm )
  898.                         {
  899.                                 $s_hidden_fields = '<input type="hidden" name="' . POST_POST_URL . '" value="' . $u_post_id . '" />';
  900.                                 $s_hidden_fields .= '<input type="hidden" name="mode" value="deletenote" />';
  901.                                 $s_hidden_fields .= '<input type="hidden" name="sid" value="' . $sid . '" />';
  902.                                 $s_hidden_fields .= '<input type="hidden" name="edit_note_id" value="' . $u_edit_note_id . '" />';
  903.                                 $l_confirm = $lang['Confirm_delete_edit_note'];
  904.                                
  905.                                 $template->set_filenames(array(
  906.                                         'confirm_body' => 'confirm_body.tpl',
  907.                                 ));
  908.  
  909.                                 $template->assign_vars(array(
  910.                                         'MESSAGE_TITLE' => $lang['Information'],
  911.                                         'MESSAGE_TEXT' => $l_confirm,
  912.                                         'L_YES' => $lang['Yes'],
  913.                                         'L_NO' => $lang['No'],
  914.                                         'S_CONFIRM_ACTION' => append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$u_topic_id"),
  915.                                         'S_HIDDEN_FIELDS' => $s_hidden_fields,
  916.                                 ));
  917.                                
  918.                                 $template->pparse('confirm_body');
  919.                                 include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
  920.                         }
  921.                        
  922.                         // Actually delete the note
  923.                         if ( $confirm )
  924.                         {
  925.                                 $sql = 'DELETE FROM ' . EDIT_NOTES_TABLE . " WHERE edit_note_id = $u_edit_note_id LIMIT 1";
  926.                        
  927.                                 if ( !($result = $db->sql_query($sql)) )
  928.                                 {
  929.                                         message_die(GENERAL_ERROR, 'Could not delete this edit note', '', __LINE__, __FILE__, $sql);
  930.                                 }
  931.                                
  932.                                 $message = $lang['Edit_note_deleted'];
  933.                                 $message .=  '<br /><br />' . sprintf($lang['Click_view_message'], '<a href="' . append_sid("viewtopic.$phpEx?" . POST_POST_URL . "=$u_post_id") . "#$u_post_id" . '">', '</a>');
  934.                                 message_die(GENERAL_MESSAGE, $message);
  935.                         }
  936.                 }
  937.  
  938.                 // Core code. Pull all edit notes for this post.
  939.                 $max_edit_notes = $board_config['max_edit_notes'];
  940.                 $sql = 'SELECT * FROM ' . EDIT_NOTES_TABLE . ' WHERE post_id = ' . $postrow['post_id'] . ' ORDER BY edit_note_time DESC LIMIT ' . $max_edit_notes;
  941.  
  942.                 if ( !($result = $db->sql_query($sql)) )
  943.                 {
  944.                         message_die(GENERAL_ERROR, 'Could not look up edit notes for this post', '', __LINE__, __FILE__, $sql);
  945.                 }
  946.  
  947.                 if ( $db->sql_numrows($result) )
  948.                 {
  949.                         $template->assign_block_vars('postrow.post_edit_notes', array() );
  950.                 }
  951.                
  952.                 while ( $row = $db->sql_fetchrow($result) )
  953.                 {
  954.                         $edit_note_id = $row['edit_note_id'];
  955.                         $user_id = $row['user_id'];
  956.                         $note = htmlspecialchars($row['note']);
  957.                        
  958.                                 // Replace censored words
  959.                                 if ( count($orig_word) )
  960.                                 {
  961.                                         $note = preg_replace($orig_word, $replacement_word, $note);
  962.                                 }
  963.                
  964.                         $ip = decode_ip($row['ip']);
  965.                         $time = create_date($board_config['default_dateformat'], $row['edit_note_time'], $board_config['board_timezone']);
  966.                
  967.                         // Match up user IDs with usernames
  968.                         if ( $user_id != ANONYMOUS )
  969.                         {
  970.                                 $sql2 = 'SELECT username, user_level FROM ' . USERS_TABLE . ' WHERE user_id = ' . $user_id;
  971.        
  972.                                 if ( !($result2 = $db->sql_query($sql2)) )
  973.                                 {
  974.                                         message_die(GENERAL_ERROR, 'Could not look up username for this edit note', '', __LINE__, __FILE__, $sql);
  975.                                 }
  976.  
  977.                                 if ( !($row2 = $db->sql_fetchrow($result2)) )
  978.                                 {
  979.                                         message_die(GENERAL_ERROR, 'Could not retrieve username for this edit note', '', __LINE__, __FILE__, $sql);
  980.                                 }
  981.                
  982.                                 $username = $row2['username'];
  983.                                 $user_level = $row2['user_level'];
  984.                                 $user_style = ( $user_level == ADMIN ) ? ' style="color: #' . $theme['fontcolor3'] . '"' : ( ( $user_level == MOD ) ? ' style="color: #' . $theme['fontcolor2'] . '"' : '' );
  985.                                 $u_user_profile = '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . "=$user_id") . '"' . $user_style . '>' . $username . '</a>';
  986.                         }
  987.        
  988.                         else
  989.                         {
  990.                                 $u_user_profile = $lang['Guest'];
  991.                         }
  992.                
  993.                         // IP / Delete links for the appropriate user level
  994.                         $u_ip = ( $is_auth['auth_mod'] ) ? ' [ ' . $lang['IP'] . ': <a href="http://whois.sc/' . $ip . '" target="_blank">' . $ip . '</a> ]' : '';
  995.                         $u_delete_note = ( $is_auth['auth_mod'] || $user_id == $userdata['user_id'] ) ? ' [ <a href="' . "viewtopic.$phpEx?mode=deletenote&amp" . POST_POST_URL . '=' . $postrow['post_id'] . "&amp;" . POST_TOPIC_URL . "=$topic_id&amp;edit_note_id=$edit_note_id&amp;sid=" . $userdata['session_id'] . '">' . $lang['Delete_note'] . '</a> ]' : '';
  996.                        
  997.                         $template->assign_block_vars('postrow.post_edit_notes.edit_notes_loop', array(
  998.                                 'L_EDITED_BY' => sprintf($lang['Edited_by'], $u_user_profile, $time),
  999.                                 'NOTE' => $note,
  1000.                                 'U_IP' => $u_ip,
  1001.                                 'U_DELETE_NOTE' => $u_delete_note,
  1002.                         ));
  1003.                 }
  1004.         }
  1005.         // End Edit Notes MOD
  1006.  
  1007.  
  1008. $template->pparse('body');
  1009.  
  1010. include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
  1011.  
  1012. ?>

advertising

Update the Post

Either update this post and resubmit it with changes, or make a new post.

You may also comment on this post.

update paste below
details of the post (optional)

Note: Only the paste content is required, though the following information can be useful to others.

Save name / title?

(space separated, optional)



Please note that information posted here will expire by default in one month. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.

comments powered by Disqus
worth-right
worth-right