PageRenderTime 55ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 1ms

/includes/topic_review.php

https://github.com/MightyGorgon/icy_phoenix
PHP | 238 lines | 175 code | 34 blank | 29 comment | 28 complexity | cceec0f4e3472ef2e0ad625f46d25c40 MD5 | raw file
Possible License(s): AGPL-1.0
  1. <?php
  2. /**
  3. *
  4. * @package Icy Phoenix
  5. * @version $Id$
  6. * @copyright (c) 2008 Icy Phoenix
  7. * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  8. *
  9. */
  10. /**
  11. *
  12. * @Icy Phoenix is based on phpBB
  13. * @copyright (c) 2008 phpBB Group
  14. *
  15. */
  16. if (!defined('IN_ICYPHOENIX'))
  17. {
  18. die('Hacking attempt');
  19. }
  20. function topic_review($forum_id, $topic_id, $is_inline_review)
  21. {
  22. global $db, $config, $auth, $user, $lang, $template, $images, $theme, $bbcode, $tree;
  23. global $user_ip, $starttime, $gen_simple_header;
  24. if (!$is_inline_review)
  25. {
  26. if (!isset($topic_id) || !$topic_id)
  27. {
  28. if (!defined('STATUS_404')) define('STATUS_404', true);
  29. message_die(GENERAL_MESSAGE, 'NO_TOPIC');
  30. }
  31. // Get topic info ...
  32. $sql = "SELECT t.topic_title, t.topic_calendar_time, t.topic_calendar_duration, t.topic_first_post_id, 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
  33. FROM " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f
  34. WHERE t.topic_id = $topic_id
  35. AND f.forum_id = t.forum_id";
  36. $tmp = '';
  37. attach_setup_viewtopic_auth($tmp, $sql);
  38. $result = $db->sql_query($sql);
  39. if (!($forum_row = $db->sql_fetchrow($result)))
  40. {
  41. if (!defined('STATUS_404')) define('STATUS_404', true);
  42. message_die(GENERAL_MESSAGE, 'NO_TOPIC');
  43. }
  44. $db->sql_freeresult($result);
  45. $forum_id = $forum_row['forum_id'];
  46. $topic_title = $forum_row['topic_title'];
  47. $topic_calendar_time = intval($forum_row['topic_calendar_time']);
  48. $topic_first_post_id = intval($forum_row['topic_first_post_id']);
  49. $topic_calendar_duration = intval($forum_row['topic_calendar_duration']);
  50. // Start session management
  51. $user->session_begin();
  52. $auth->acl($user->data);
  53. $user->setup();
  54. // End session management
  55. $is_auth = array();
  56. $is_auth = auth(AUTH_ALL, $forum_id, $user->data, $forum_row);
  57. if (!$is_auth['auth_read'])
  58. {
  59. message_die(GENERAL_MESSAGE, sprintf($lang['Sorry_auth_read'], $is_auth['auth_read_type']));
  60. }
  61. $gen_simple_header = true;
  62. $meta_content['page_title'] = $lang['Topic_review'] . ' - ' . $topic_title;
  63. $meta_content['description'] = '';
  64. $meta_content['keywords'] = '';
  65. page_header($meta_content['page_title'], true);
  66. $template->set_filenames(array('reviewbody' => 'posting_topic_review.tpl'));
  67. }
  68. // Go ahead and pull all data for this topic
  69. $sql = "SELECT u.username, u.user_id, p.*
  70. FROM " . POSTS_TABLE . " p, " . USERS_TABLE . " u
  71. WHERE p.topic_id = $topic_id
  72. AND p.poster_id = u.user_id
  73. ORDER BY p.post_time DESC
  74. LIMIT " . $config['posts_per_page'];
  75. $result = $db->sql_query($sql);
  76. if (!empty($is_auth))
  77. {
  78. init_display_review_attachments($is_auth);
  79. }
  80. // Okay, let's do the loop, yeah come on baby let's do the loop and it goes like this ...
  81. if ($row = $db->sql_fetchrow($result))
  82. {
  83. //Begin Lo-Fi Mod
  84. global $lofi;
  85. //End Lo-Fi Mod
  86. $mini_post_img = $images['icon_minipost'];
  87. $mini_post_alt = $lang['Post'];
  88. $i = 0;
  89. do
  90. {
  91. $poster_id = $row['user_id'];
  92. $poster = $row['username'];
  93. $post_date = create_date($config['default_dateformat'], $row['post_time'], $config['board_timezone']);
  94. // Handle anon users posting with usernames
  95. if(($poster_id == ANONYMOUS) && ($row['post_username'] != ''))
  96. {
  97. $poster = $row['post_username'];
  98. $poster_rank = $lang['Guest'];
  99. }
  100. elseif ($poster_id == ANONYMOUS)
  101. {
  102. $poster = $lang['Guest'];
  103. $poster_rank = '';
  104. }
  105. $post_subject = ($row['post_subject'] != '') ? $row['post_subject'] : '';
  106. $message = $row['post_text'];
  107. // Quick Quote - BEGIN
  108. $look_up_array = array(
  109. '\"',
  110. '"',
  111. "<",
  112. ">",
  113. "\n",
  114. chr(13),
  115. );
  116. $replacement_array = array(
  117. '&q_mg;',
  118. '\"',
  119. "&lt_mg;",
  120. "&gt_mg;",
  121. "\\n",
  122. "",
  123. );
  124. $plain_message = $row['post_text'];
  125. $plain_message = strtr($plain_message, array_flip(get_html_translation_table(HTML_ENTITIES)));
  126. //Hide MOD
  127. if(preg_match('/\[hide/i', $plain_message))
  128. {
  129. $search = array("/\[hide\](.*?)\[\/hide\]/");
  130. $replace = array('[hide]' . $lang['xs_bbc_hide_quote_message'] . '[/hide]');
  131. $plain_message = preg_replace($search, $replace, $plain_message);
  132. }
  133. //Hide MOD
  134. $plain_message = censor_text($plain_message);
  135. $plain_message = str_replace($look_up_array, $replacement_array, $plain_message);
  136. // Quick Quote - END
  137. $post_subject = censor_text($post_subject);
  138. $message = censor_text($message);
  139. $bbcode->allow_html = (($config['allow_html'] && $row['enable_bbcode']) ? true : false);
  140. $bbcode->allow_bbcode = (($config['allow_bbcode'] && $row['enable_bbcode']) ? true : false);
  141. $bbcode->allow_smilies = (($config['allow_smilies'] && $row['enable_smilies']) ? true : false);
  142. $message = $bbcode->parse($message);
  143. if ($row['enable_autolinks_acronyms'])
  144. {
  145. $message = $bbcode->acronym_pass($message);
  146. $message = $bbcode->autolink_text($message, $forum_id);
  147. }
  148. //$message = kb_word_wrap_pass ($message);
  149. if (!empty($topic_calendar_time) && ($topic_first_post_id == $row['post_id']))
  150. {
  151. $post_subject .= get_calendar_title($topic_calendar_time, $topic_calendar_duration);
  152. }
  153. // Again this will be handled by the templating code at some point
  154. $row_class = (!($i % 2)) ? $theme['td_class1'] : $theme['td_class2'];
  155. // Strip iframe from $message... we need this to avoid the topic review "iframe" being broken from BBCodes like YouTube
  156. $strip_array = array(
  157. '@<iframe[^>]*?>.*?</iframe>@si' // Strip out iframe
  158. );
  159. $message = preg_replace($strip_array, '', $message);
  160. $template->assign_block_vars('postrow', array(
  161. 'ROW_CLASS' => $row_class,
  162. 'MINI_POST_IMG' => $mini_post_img,
  163. 'POSTER_NAME' => $poster,
  164. 'POST_DATE' => $post_date,
  165. 'POST_SUBJECT' => $post_subject,
  166. 'MESSAGE' => $message,
  167. 'U_POST_ID' => $row['post_id'],
  168. 'PLAIN_MESSAGE' => $plain_message,
  169. 'L_MINI_POST_ALT' => $mini_post_alt
  170. )
  171. );
  172. if (!empty($is_auth))
  173. {
  174. display_review_attachments($row['post_id'], $row['post_attachment'], $is_auth);
  175. }
  176. $i++;
  177. }
  178. while ($row = $db->sql_fetchrow($result));
  179. }
  180. else
  181. {
  182. if (!defined('STATUS_404')) define('STATUS_404', true);
  183. message_die(GENERAL_MESSAGE, 'NO_TOPIC', '', __LINE__, __FILE__, $sql);
  184. }
  185. $db->sql_freeresult($result);
  186. $template->assign_vars(array(
  187. 'L_AUTHOR' => $lang['Author'],
  188. 'L_MESSAGE' => $lang['Message'],
  189. 'L_POSTED' => $lang['Posted'],
  190. 'L_POST_SUBJECT' => $lang['Post_subject'],
  191. 'IMG_QUICK_QUOTE' => $images['icon_quote'],
  192. 'IMG_OFFTOPIC' => $images['icon_offtopic'],
  193. 'L_QUICK_QUOTE' => $lang['QuickQuote'],
  194. 'L_OFFTOPIC' => $lang['OffTopic'],
  195. 'L_TOPIC_REVIEW' => $lang['Topic_review']
  196. )
  197. );
  198. if (!$is_inline_review)
  199. {
  200. $template->pparse('reviewbody');
  201. page_footer(true, '', true);
  202. }
  203. }
  204. ?>