Просмотр файла viewtopic.php

Размер файла: 38.73Kb
  1. <?php
  2. /***************************************************************************
  3. * mides.ru
  4. * -------------------
  5. ***************************************************************************/
  6. define('IN_PHPBB', true);
  7. $phpbb_root_path = './';
  8. include($phpbb_root_path . 'extension.inc');
  9. include($phpbb_root_path . 'common.'.$phpEx);
  10. include($phpbb_root_path . 'includes/bbcode.'.$phpEx);
  11. include($phpbb_root_path . 'includes/functions_post.'.$phpEx);
  12.  
  13. $topic_id = $post_id = 0;
  14. if ( isset($HTTP_GET_VARS[POST_TOPIC_URL]) )
  15. {
  16. $topic_id = intval($HTTP_GET_VARS[POST_TOPIC_URL]);
  17. }
  18. else if ( isset($HTTP_GET_VARS['topic']) )
  19. {
  20. $topic_id = intval($HTTP_GET_VARS['topic']);
  21. }
  22.  
  23. if ( isset($HTTP_GET_VARS[POST_POST_URL]))
  24. {
  25. $post_id = intval($HTTP_GET_VARS[POST_POST_URL]);
  26. }
  27.  
  28. $download = ( isset($HTTP_GET_VARS['download']) ) ? $HTTP_GET_VARS['download'] : '';
  29.  
  30. if (!$topic_id && !$post_id)
  31. {
  32. message_die(GENERAL_MESSAGE, 'Topic_post_not_exist');
  33. }
  34.  
  35. if ( isset($HTTP_GET_VARS['view']) && empty($HTTP_GET_VARS[POST_POST_URL]) )
  36. {
  37. if ( $HTTP_GET_VARS['view'] == 'newest' )
  38. {
  39. if ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_sid']) || isset($HTTP_GET_VARS['sid']) )
  40. {
  41. $session_id = isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_sid']) ? $HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_sid'] : $HTTP_GET_VARS['sid'];
  42.  
  43. if (!preg_match('/^[A-Za-z0-9]*$/', $session_id))
  44. {
  45. $session_id = '';
  46. }
  47.  
  48. if ( $session_id )
  49. {
  50. $sql = "SELECT p.post_id
  51. FROM " . POSTS_TABLE . " p, " . SESSIONS_TABLE . " s, " . USERS_TABLE . " u
  52. WHERE s.session_id = '$session_id'
  53. AND u.user_id = s.session_user_id
  54. AND p.topic_id = $topic_id
  55. AND p.post_time >= u.user_lastvisit
  56. ORDER BY p.post_time ASC
  57. LIMIT 1";
  58. if ( !($result = $db->sql_query($sql)) )
  59. {
  60. message_die(GENERAL_ERROR, 'Could not obtain newer/older topic information', '', __LINE__, __FILE__, $sql);
  61. }
  62.  
  63. if ( !($row = $db->sql_fetchrow($result)) )
  64. {
  65. message_die(GENERAL_MESSAGE, 'No_new_posts_last_visit');
  66. }
  67.  
  68. $post_id = $row['post_id'];
  69.  
  70. if (isset($HTTP_GET_VARS['sid']))
  71. {
  72. redirect("viewtopic.$phpEx?sid=$session_id&" . POST_POST_URL . "=$post_id#$post_id");
  73. }
  74. else
  75. {
  76. redirect("viewtopic.$phpEx?" . POST_POST_URL . "=$post_id#$post_id");
  77. }
  78. }
  79. }
  80.  
  81. redirect(append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id", true));
  82. }
  83. else if ( $HTTP_GET_VARS['view'] == 'next' || $HTTP_GET_VARS['view'] == 'previous' )
  84. {
  85. $sql_condition = ( $HTTP_GET_VARS['view'] == 'next' ) ? '>' : '<';
  86. $sql_ordering = ( $HTTP_GET_VARS['view'] == 'next' ) ? 'ASC' : 'DESC';
  87.  
  88. $sql = "SELECT t.topic_id
  89. FROM " . TOPICS_TABLE . " t, " . TOPICS_TABLE . " t2
  90. WHERE t2.topic_id = $topic_id
  91. AND t.forum_id = t2.forum_id
  92. AND t.topic_moved_id = 0
  93. AND t.topic_last_post_id $sql_condition t2.topic_last_post_id
  94. ORDER BY t.topic_last_post_id $sql_ordering
  95. LIMIT 1";
  96. if ( !($result = $db->sql_query($sql)) )
  97. {
  98. message_die(GENERAL_ERROR, "Could not obtain newer/older topic information", '', __LINE__, __FILE__, $sql);
  99. }
  100.  
  101. if ( $row = $db->sql_fetchrow($result) )
  102. {
  103. $topic_id = intval($row['topic_id']);
  104. }
  105. else
  106. {
  107. $message = ( $HTTP_GET_VARS['view'] == 'next' ) ? 'No_newer_topics' : 'No_older_topics';
  108. message_die(GENERAL_MESSAGE, $message);
  109. }
  110. }
  111. }
  112.  
  113. $join_sql_table = (!$post_id) ? '' : ", " . POSTS_TABLE . " p, " . POSTS_TABLE . " p2 ";
  114. $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";
  115. $count_sql = (!$post_id) ? '' : ", COUNT(p2.post_id) AS prev_posts";
  116.  
  117. $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";
  118.  
  119. $sql = "SELECT t.topic_id, t.topic_title, t.topic_poster, 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 . "
  120. FROM " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f" . $join_sql_table . "
  121. WHERE $join_sql
  122. AND f.forum_id = t.forum_id
  123. $order_sql";
  124. attach_setup_viewtopic_auth($order_sql, $sql);
  125. if ( !($result = $db->sql_query($sql)) )
  126. {
  127. message_die(GENERAL_ERROR, "Could not obtain topic information", '', __LINE__, __FILE__, $sql);
  128. }
  129.  
  130. if ( !($forum_topic_data = $db->sql_fetchrow($result)) )
  131. {
  132. message_die(GENERAL_MESSAGE, 'Topic_post_not_exist');
  133. }
  134.  
  135. $forum_id = intval($forum_topic_data['forum_id']);
  136.  
  137. $userdata = session_pagestart($user_ip, $forum_id);
  138. init_userprefs($userdata);
  139.  
  140. if ( isset($HTTP_POST_VARS['start1']) )
  141. {
  142. $start1 = abs(intval($HTTP_POST_VARS['start1']));
  143. $start = (($start1 - 1) * $board_config['posts_per_page']);
  144. } else {
  145. $start = ( isset($HTTP_GET_VARS['start']) ) ? intval($HTTP_GET_VARS['start']) : 0;
  146. $start = ($start < 0) ? 0 : $start;
  147. }
  148.  
  149. $is_auth = array();
  150. $is_auth = auth(AUTH_ALL, $forum_id, $userdata, $forum_topic_data);
  151.  
  152. if ( $download )
  153. {
  154. $sql_download = ( $download != -1 ) ? " AND p.post_id = " . intval($download) . " " : '';
  155.  
  156. $orig_word = array();
  157. $replacement_word = array();
  158. obtain_word_list($orig_word, $replacement_word);
  159.  
  160. $sql = "SELECT u.*, p.*, pt.post_text, pt.post_subject, pt.bbcode_uid
  161. FROM " . POSTS_TABLE . " p, " . USERS_TABLE . " u, " . POSTS_TEXT_TABLE . " pt
  162. WHERE p.topic_id = $topic_id
  163. $sql_download
  164. AND pt.post_id = p.post_id
  165. AND u.user_id = p.poster_id
  166. ORDER BY p.post_time ASC, p.post_id ASC";
  167. if ( !($result = $db->sql_query($sql)) )
  168. {
  169. message_die(GENERAL_ERROR, "Could not create download stream for post.", '', __LINE__, __FILE__, $sql);
  170. }
  171.  
  172. $download_file = '';
  173.  
  174. $is_auth_read = array();
  175.  
  176. while ( $row = $db->sql_fetchrow($result) )
  177. {
  178. $is_auth_read = auth(AUTH_ALL, $row['forum_id'], $userdata);
  179.  
  180. $poster_id = $row['user_id'];
  181. $poster = ( $poster_id == ANONYMOUS ) ? $lang['Guest'] : $row['username'];
  182.  
  183. $post_date = create_date($board_config['default_dateformat'], $row['post_time'], $board_config['board_timezone']);
  184.  
  185. $post_subject = ( $row['post_subject'] != '' ) ? $row['post_subject'] : '';
  186.  
  187. $bbcode_uid = $row['bbcode_uid'];
  188. $message = $row['post_text'];
  189. $message = strip_tags($message);
  190. $message = preg_replace("/\[.*?:$bbcode_uid:?.*?\]/si", '', $message);
  191. $message = preg_replace('/\[url\]|\[\/url\]/si', '', $message);
  192. $message = preg_replace('/\:[0-9a-z\:]+\]/si', ']', $message);
  193.  
  194. $message = unprepare_message($message);
  195. $message = preg_replace('/&#40;/', '(', $message);
  196. $message = preg_replace('/&#41;/', ')', $message);
  197. $message = preg_replace('/&#58;/', ':', $message);
  198. $message = preg_replace('/&#91;/', '[', $message);
  199. $message = preg_replace('/&#93;/', ']', $message);
  200. $message = preg_replace('/&#123;/', '{', $message);
  201. $message = preg_replace('/&#125;/', '}', $message);
  202.  
  203. if (count($orig_word))
  204. {
  205. $post_subject = str_replace($orig_word, $replacement_word, $post_subject);
  206.  
  207. $message = str_replace($orig_word, $replacement_word, $message);
  208. }
  209.  
  210. $break = "\n";
  211. $line = '---------------';
  212. $download_file .= $post_subject.$break.$poster.$break.$post_date.$break.$message.$break.$line;
  213. }
  214.  
  215. $disp_folder = ( $download == -1 ) ? 'topic_'.$topic_id : 'post_'.$download;
  216.  
  217. if (!$is_auth_read['auth_read'])
  218. {
  219. $download_file = sprintf($lang['Sorry_auth_read'], $is_auth_read['auth_read_type']);
  220. $disp_folder = 'Download';
  221. }
  222.  
  223. $filename = $board_config['sitename'] . '_' . $disp_folder . '_' . date("Ymd",time()) . '.txt';
  224. header('Content-Type: text/plain; name="'.$filename.'"');
  225. header('Content-Disposition: attachment;filename="'.$filename.'"');
  226. header('Content-Transfer-Encoding: plain/text');
  227. header('Content-Length: '.strlen($download_file));
  228. print $download_file;
  229.  
  230. exit;
  231. }
  232.  
  233. if( !$is_auth['auth_view'] || !$is_auth['auth_read'] )
  234. {
  235. if ( !$userdata['session_logged_in'] )
  236. {
  237. $redirect = ($post_id) ? POST_POST_URL . "=$post_id" : POST_TOPIC_URL . "=$topic_id";
  238. $redirect .= ($start) ? "&start=$start" : '';
  239. redirect(append_sid("login.$phpEx?redirect=viewtopic.$phpEx&$redirect", true));
  240. }
  241.  
  242. $message = ( !$is_auth['auth_view'] ) ? $lang['Topic_post_not_exist'] : sprintf($lang['Sorry_auth_read'], $is_auth['auth_read_type']);
  243.  
  244. message_die(GENERAL_MESSAGE, $message);
  245. }
  246.  
  247. $forum_name = $forum_topic_data['forum_name'];
  248. $topic_title = $forum_topic_data['topic_title'];
  249. $topic_id = intval($forum_topic_data['topic_id']);
  250. $topic_time = $forum_topic_data['topic_time'];
  251.  
  252. if ($post_id)
  253. {
  254. $start = floor(($forum_topic_data['prev_posts'] - 1) / intval($board_config['posts_per_page'])) * intval($board_config['posts_per_page']);
  255. }
  256.  
  257. if( $userdata['session_logged_in'] )
  258. {
  259. $can_watch_topic = TRUE;
  260.  
  261. $sql = "SELECT notify_status
  262. FROM " . TOPICS_WATCH_TABLE . "
  263. WHERE topic_id = $topic_id
  264. AND user_id = " . $userdata['user_id'];
  265. if ( !($result = $db->sql_query($sql)) )
  266. {
  267. message_die(GENERAL_ERROR, "Could not obtain topic watch information", '', __LINE__, __FILE__, $sql);
  268. }
  269.  
  270. if ( $row = $db->sql_fetchrow($result) )
  271. {
  272. if ( isset($HTTP_GET_VARS['unwatch']) )
  273. {
  274. if ( $HTTP_GET_VARS['unwatch'] == 'topic' )
  275. {
  276. $is_watching_topic = 0;
  277.  
  278. $sql_priority = (SQL_LAYER == "mysql") ? "LOW_PRIORITY" : '';
  279. $sql = "DELETE $sql_priority FROM " . TOPICS_WATCH_TABLE . "
  280. WHERE topic_id = $topic_id
  281. AND user_id = " . $userdata['user_id'];
  282. if ( !($result = $db->sql_query($sql)) )
  283. {
  284. message_die(GENERAL_ERROR, "Could not delete topic watch information", '', __LINE__, __FILE__, $sql);
  285. }
  286. }
  287.  
  288. $template->assign_vars(array(
  289. 'META' => '<meta http-equiv="refresh" content="0;url=' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;start=$start") . '">')
  290. );
  291.  
  292. $message = $lang['No_longer_watching'] . '<br /><br />' . sprintf($lang['Click_return_topic'], '<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;start=$start") . '">', '</a>');
  293. message_die(GENERAL_MESSAGE, $message);
  294. }
  295. else
  296. {
  297. $is_watching_topic = TRUE;
  298.  
  299. if ( $row['notify_status'] )
  300. {
  301. $sql_priority = (SQL_LAYER == "mysql") ? "LOW_PRIORITY" : '';
  302. $sql = "UPDATE $sql_priority " . TOPICS_WATCH_TABLE . "
  303. SET notify_status = 0
  304. WHERE topic_id = $topic_id
  305. AND user_id = " . $userdata['user_id'];
  306. if ( !($result = $db->sql_query($sql)) )
  307. {
  308. message_die(GENERAL_ERROR, "Could not update topic watch information", '', __LINE__, __FILE__, $sql);
  309. }
  310. }
  311. }
  312. }
  313. else
  314. {
  315. if ( isset($HTTP_GET_VARS['watch']) )
  316. {
  317. if ( $HTTP_GET_VARS['watch'] == 'topic' )
  318. {
  319. $is_watching_topic = TRUE;
  320.  
  321. $sql_priority = (SQL_LAYER == "mysql") ? "LOW_PRIORITY" : '';
  322. $sql = "INSERT $sql_priority INTO " . TOPICS_WATCH_TABLE . " (user_id, topic_id, notify_status)
  323. VALUES (" . $userdata['user_id'] . ", $topic_id, 0)";
  324. if ( !($result = $db->sql_query($sql)) )
  325. {
  326. message_die(GENERAL_ERROR, "Could not insert topic watch information", '', __LINE__, __FILE__, $sql);
  327. }
  328. }
  329.  
  330. $template->assign_vars(array(
  331. 'META' => '<meta http-equiv="refresh" content="3;url=' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;start=$start") . '">')
  332. );
  333.  
  334. $message = $lang['You_are_watching'] . '<br /><br />' . sprintf($lang['Click_return_topic'], '<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;start=$start") . '">', '</a>');
  335. message_die(GENERAL_MESSAGE, $message);
  336. }
  337. else
  338. {
  339. $is_watching_topic = 0;
  340. }
  341. }
  342. }
  343. else
  344. {
  345. if ( isset($HTTP_GET_VARS['unwatch']) )
  346. {
  347. if ( $HTTP_GET_VARS['unwatch'] == 'topic' )
  348. {
  349. redirect(append_sid("login.$phpEx?redirect=viewtopic.$phpEx&" . POST_TOPIC_URL . "=$topic_id&unwatch=topic", true));
  350. }
  351. }
  352. else
  353. {
  354. $can_watch_topic = 0;
  355. $is_watching_topic = 0;
  356. }
  357. }
  358.  
  359. $previous_days = array(0, 1, 7, 14, 30, 90, 180, 364);
  360. $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']);
  361.  
  362. if( !empty($HTTP_POST_VARS['postdays']) || !empty($HTTP_GET_VARS['postdays']) )
  363. {
  364. $post_days = ( !empty($HTTP_POST_VARS['postdays']) ) ? intval($HTTP_POST_VARS['postdays']) : intval($HTTP_GET_VARS['postdays']);
  365. $min_post_time = time() - (intval($post_days) * 86400);
  366.  
  367. $sql = "SELECT COUNT(p.post_id) AS num_posts
  368. FROM " . TOPICS_TABLE . " t, " . POSTS_TABLE . " p
  369. WHERE t.topic_id = $topic_id
  370. AND p.topic_id = t.topic_id
  371. AND p.post_time >= $min_post_time";
  372. if ( !($result = $db->sql_query($sql)) )
  373. {
  374. message_die(GENERAL_ERROR, "Could not obtain limited topics count information", '', __LINE__, __FILE__, $sql);
  375. }
  376.  
  377. $total_replies = ( $row = $db->sql_fetchrow($result) ) ? intval($row['num_posts']) : 0;
  378.  
  379. $limit_posts_time = "AND p.post_time >= $min_post_time ";
  380.  
  381. if ( !empty($HTTP_POST_VARS['postdays']))
  382. {
  383. $start = 0;
  384. }
  385. }
  386. else
  387. {
  388. $total_replies = intval($forum_topic_data['topic_replies']) + 1;
  389.  
  390. $limit_posts_time = '';
  391. $post_days = 0;
  392. }
  393.  
  394. $select_post_days = '<select name="postdays">';
  395. for($i = 0; $i < count($previous_days); $i++)
  396. {
  397. $selected = ($post_days == $previous_days[$i]) ? ' selected="selected"' : '';
  398. $select_post_days .= '<option value="' . $previous_days[$i] . '"' . $selected . '>' . $previous_days_text[$i] . '</option>';
  399. }
  400. $select_post_days .= '</select>';
  401.  
  402. if ( !empty($HTTP_POST_VARS['postorder']) || !empty($HTTP_GET_VARS['postorder']) )
  403. {
  404. $post_order = (!empty($HTTP_POST_VARS['postorder'])) ? htmlspecialchars($HTTP_POST_VARS['postorder']) : htmlspecialchars($HTTP_GET_VARS['postorder']);
  405. $post_time_order = ($post_order == "asc") ? "ASC" : "DESC";
  406. }
  407. else
  408. {
  409. $post_order = 'asc';
  410. $post_time_order = 'ASC';
  411. }
  412.  
  413. $select_post_order = '<select name="postorder">';
  414. if ( $post_time_order == 'ASC' )
  415. {
  416. $select_post_order .= '<option value="asc" selected="selected">' . $lang['Oldest_First'] . '</option><option value="desc">' . $lang['Newest_First'] . '</option>';
  417. }
  418. else
  419. {
  420. $select_post_order .= '<option value="asc">' . $lang['Oldest_First'] . '</option><option value="desc" selected="selected">' . $lang['Newest_First'] . '</option>';
  421. }
  422. $select_post_order .= '</select>';
  423.  
  424. $sql = "SELECT u.username, u.user_id, u.user_level, u.user_posts, u.user_post_leng, u.user_nic_color, u.user_allowsmile, u.user_allow_viewonline, u.user_session_time, p.*, pt.post_text, pt.post_subject, pt.bbcode_uid, u.user_reputation, u.user_reputation_plus, u.user_warnings,u.user_avatar_type, u.user_allowavatar, u.user_avatar, user_rank
  425.  
  426. FROM " . POSTS_TABLE . " p, " . USERS_TABLE . " u, " . POSTS_TEXT_TABLE . " pt
  427. WHERE p.topic_id = $topic_id
  428. $limit_posts_time
  429. AND pt.post_id = p.post_id
  430. AND u.user_id = p.poster_id
  431. ORDER BY p.post_time $post_time_order
  432. LIMIT $start, ".$board_config['posts_per_page'];
  433. if ( !($result = $db->sql_query($sql)) )
  434. {
  435. message_die(GENERAL_ERROR, "Could not obtain post/user information.", '', __LINE__, __FILE__, $sql);
  436. }
  437.  
  438. $postrow = array();
  439. if ($row = $db->sql_fetchrow($result))
  440. {
  441. $post_ids = $row['post_id'];
  442. do
  443. {
  444. $postrow[] = $row;
  445. $post_ids .= ',' . $row['post_id'];
  446. }
  447. while ($row = $db->sql_fetchrow($result));
  448. $db->sql_freeresult($result);
  449.  
  450. if ($board_config['warnings_enabled'] || $board_config['reputation_enabled'])
  451. {
  452. include($phpbb_root_path . 'includes/functions_reputation.' . $phpEx);
  453.  
  454. $is_auth = reputation_auth($is_auth, $userdata);
  455.  
  456. if ($board_config['warnings_enabled'])
  457. {
  458. $result = db_query('SELECT ban_userid FROM {BANLIST_TABLE}');
  459. while ($row = $db->sql_fetchrow($result))
  460. {
  461. $banned[$row['ban_userid']] = true;
  462. }
  463.  
  464. $result = db_query('SELECT r.*, rt.*, u.username FROM {REPUTATION_TABLE} r, {REPUTATION_TEXT_TABLE} rt, {USERS_TABLE} u
  465. WHERE r.post_id IN (%s)
  466. AND r.modification IN ({REPUTATION_WARNING},{REPUTATION_BAN},{REPUTATION_WARNING_EXPIRED},{REPUTATION_BAN_EXPIRED})
  467. AND r.id = rt.id
  468. AND r.voter_id = u.user_id', $post_ids);
  469. while ($row = $db->sql_fetchrow($result))
  470. {
  471. $post_warnings[$row['post_id']] = $row;
  472. }
  473. }
  474. }
  475.  
  476. $total_posts = count($postrow);
  477. }
  478. else
  479. {
  480. include($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
  481. sync('topic', $topic_id);
  482.  
  483. message_die(GENERAL_MESSAGE, $lang['No_posts_topic']);
  484. }
  485.  
  486. $resync = FALSE;
  487. if ($forum_topic_data['topic_replies'] + 1 < $start + count($postrow))
  488. {
  489. $resync = TRUE;
  490. }
  491. elseif ($start + $board_config['posts_per_page'] > $forum_topic_data['topic_replies'])
  492. {
  493. $row_id = intval($forum_topic_data['topic_replies']) % intval($board_config['posts_per_page']);
  494. if ($postrow[$row_id]['post_id'] != $forum_topic_data['topic_last_post_id'] || $start + count($postrow) < $forum_topic_data['topic_replies'])
  495. {
  496. $resync = TRUE;
  497. }
  498. }
  499. elseif (count($postrow) < $board_config['posts_per_page'])
  500. {
  501. $resync = TRUE;
  502. }
  503.  
  504. if ($resync)
  505. {
  506. include($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
  507. sync('topic', $topic_id);
  508.  
  509. $result = $db->sql_query('SELECT COUNT(post_id) AS total FROM ' . POSTS_TABLE . ' WHERE topic_id = ' . $topic_id);
  510. $row = $db->sql_fetchrow($result);
  511. $total_replies = $row['total'];
  512. }
  513.  
  514. $orig_word = array();
  515. $replacement_word = array();
  516. obtain_word_list($orig_word, $replacement_word);
  517.  
  518. if ( count($orig_word) )
  519. {
  520. $topic_title = str_replace($orig_word, $replacement_word, $topic_title);
  521. }
  522.  
  523. $highlight_match = $highlight = '';
  524. if (isset($HTTP_GET_VARS['highlight']))
  525. {
  526. $words = explode(' ', trim(htmlspecialchars($HTTP_GET_VARS['highlight'])));
  527.  
  528. for($i = 0; $i < sizeof($words); $i++)
  529. {
  530. if (trim($words[$i]) != '')
  531. {
  532. $highlight_match .= (($highlight_match != '') ? '|' : '') . str_replace('*', '\w*', preg_quote($words[$i], '#'));
  533. }
  534. }
  535. unset($words);
  536.  
  537. $highlight = urlencode($HTTP_GET_VARS['highlight']);
  538. $highlight_match = phpbb_rtrim($highlight_match, "\\");
  539. }
  540.  
  541. $reply_topic_url = append_sid("posting.$phpEx?mode=reply&amp;" . POST_TOPIC_URL . "=$topic_id");
  542. $view_forum_url = append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id");
  543.  
  544. $reply_alt = ( $forum_topic_data['forum_status'] == FORUM_LOCKED || $forum_topic_data['topic_status'] == TOPIC_LOCKED ) ? $lang['Topic_locked'] : $lang['Reply_to_topic'];
  545. $post_alt = ( $forum_topic_data['forum_status'] == FORUM_LOCKED ) ? $lang['Forum_locked'] : $lang['Post_new_topic'];
  546.  
  547. if ( $userdata['session_logged_in'] )
  548. {
  549. $tracking_topics = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) : array();
  550. $tracking_forums = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) : array();
  551.  
  552. if ( !empty($tracking_topics[$topic_id]) && !empty($tracking_forums[$forum_id]) )
  553. {
  554. $topic_last_read = ( $tracking_topics[$topic_id] > $tracking_forums[$forum_id] ) ? $tracking_topics[$topic_id] : $tracking_forums[$forum_id];
  555. }
  556. else if ( !empty($tracking_topics[$topic_id]) || !empty($tracking_forums[$forum_id]) )
  557. {
  558. $topic_last_read = ( !empty($tracking_topics[$topic_id]) ) ? $tracking_topics[$topic_id] : $tracking_forums[$forum_id];
  559. }
  560. else
  561. {
  562. $topic_last_read = $userdata['user_lastvisit'];
  563. }
  564.  
  565. if ( count($tracking_topics) >= 150 && empty($tracking_topics[$topic_id]) )
  566. {
  567. asort($tracking_topics);
  568. unset($tracking_topics[key($tracking_topics)]);
  569. }
  570.  
  571. $tracking_topics[$topic_id] = time();
  572.  
  573. setcookie($board_config['cookie_name'] . '_t', serialize($tracking_topics), 0, $board_config['cookie_path'], $board_config['cookie_domain'], $board_config['cookie_secure']);
  574. }
  575.  
  576. $hidden_form_fields = '<input type="hidden" name="mode" value="reply" />';
  577. $hidden_form_fields .= '<input type="hidden" name="sid" value="' . $userdata['session_id'] . '" />';
  578. $hidden_form_fields .= '<input type="hidden" name="' . POST_TOPIC_URL . '" value="' . $topic_id . '" />';
  579.  
  580. $page_title = $topic_title;
  581. include($phpbb_root_path . 'includes/page_header.'.$phpEx);
  582.  
  583. $template->set_filenames(array(
  584. 'body' => 'viewtopic_body.tpl',
  585. 'posttopic' => 'viewtopic_post.tpl',
  586. 'posttopic_out' => 'viewtopic_post_out.tpl')
  587. );
  588.  
  589. $topic_mod = '';
  590.  
  591. if ( $is_auth['auth_mod'] )
  592. {
  593. $topic_mod .= ( $forum_topic_data['topic_status'] == TOPIC_UNLOCKED ) ? "<br/><a href=\"modcp.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;mode=lock&amp;sid=" . $userdata['session_id'] . '">Закр</a>|' : "<br/><a href=\"modcp.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;mode=unlock&amp;sid=" . $userdata['session_id'] . '">Откр</a>|';
  594.  
  595. $topic_mod .= "<a href=\"modcp.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;mode=delete&amp;sid=" . $userdata['session_id'] . '">Удал</a>|';
  596.  
  597. $topic_mod .= "<a href=\"modcp.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;mode=move&amp;sid=" . $userdata['session_id'] . '">Перен</a>|';
  598. $topic_mod .= "<a href=\"modcp.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;mode=split&amp;sid=" . $userdata['session_id'] . '">Разд</a>';
  599.  
  600. }
  601. if ( !$is_auth['auth_mod'] && ($forum_topic_data['topic_poster'] == $userdata['user_id'] && $userdata['user_id'] != ANONYMOUS) && $forum_topic_data['topic_status'] == TOPIC_UNLOCKED )
  602. {
  603. $topic_mod .= "<br/><a href=\"modcp.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;mode=lock&amp;sid=" . $userdata['session_id'] . '" class="buttom">Закрыть тему</a> ';
  604.  
  605. }
  606.  
  607. $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);
  608.  
  609. $template->assign_vars(array(
  610. 'L_DOWNLOAD_TOPIC' => $lang['Download_topic'],
  611. 'DOWNLOAD_TOPIC' => append_sid("viewtopic.$phpEx?download=-1&amp;".POST_TOPIC_URL."=".$topic_id),
  612. 'FORUM_ID' => $forum_id,
  613. 'FORUM_NAME' => $forum_name,
  614. 'TOPIC_ID' => $topic_id,
  615. 'TOPIC_TITLE' => $topic_title,
  616. 'PAGINATION' => $pagination,
  617. 'PAGE_NUMBER' => sprintf($lang['Page_of'], ( floor( $start / intval($board_config['posts_per_page']) ) + 1 ), ceil( $total_replies / intval($board_config['posts_per_page']) )),
  618.  
  619. 'L_POST_REPLY_TOPIC' => $reply_alt,
  620. 'L_SUBMIT' => $lang['Submit'],
  621.  
  622. 'S_TOPIC_LINK' => POST_TOPIC_URL,
  623. 'S_SELECT_POST_DAYS' => $select_post_days,
  624. 'S_SELECT_POST_ORDER' => $select_post_order,
  625. 'S_POST_DAYS_ACTION' => append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . '=' . $topic_id . "&amp;start=$start"),
  626. 'S_AUTH_LIST' => $s_auth_can,
  627. 'S_TOPIC_ADMIN' => $topic_mod,
  628. 'S_POST_ACTION' => append_sid("posting.$phpEx"),
  629. 'S_HIDDEN_FORM_FIELDS' => $hidden_form_fields,
  630.  
  631. '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"),
  632. 'U_VIEW_FORUM' => $view_forum_url,
  633. 'U_POST_REPLY_TOPIC' => $reply_topic_url)
  634. );
  635.  
  636. if ( $is_auth['auth_reply'] )
  637. {
  638. if ( ($userdata['session_logged_in'] ) || !$userdata['session_logged_in'] )
  639. {
  640. if ( !$userdata['session_logged_in'] )
  641. {
  642. $template->assign_block_vars('switch_username_select', array());
  643. }
  644. $template->assign_var_from_handle('POSTTOPIC', 'posttopic');
  645. }
  646. }
  647. else {$template->assign_var_from_handle('posttopic_out', 'posttopic_out');}
  648.  
  649. if ( !empty($forum_topic_data['topic_vote']) )
  650. {
  651. $s_hidden_fields = '';
  652.  
  653. $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
  654. FROM " . VOTE_DESC_TABLE . " vd, " . VOTE_RESULTS_TABLE . " vr
  655. WHERE vd.topic_id = $topic_id
  656. AND vr.vote_id = vd.vote_id
  657. ORDER BY vr.vote_option_id ASC";
  658. if ( !($result = $db->sql_query($sql)) )
  659. {
  660. message_die(GENERAL_ERROR, "Could not obtain vote data for this topic", '', __LINE__, __FILE__, $sql);
  661. }
  662.  
  663. if ( $vote_info = $db->sql_fetchrowset($result) )
  664. {
  665. $db->sql_freeresult($result);
  666. $vote_options = count($vote_info);
  667.  
  668. $vote_id = $vote_info[0]['vote_id'];
  669. $vote_title = $vote_info[0]['vote_text'];
  670.  
  671. $sql = "SELECT vote_id
  672. FROM " . VOTE_USERS_TABLE . "
  673. WHERE vote_id = $vote_id
  674. AND vote_user_id = " . intval($userdata['user_id']);
  675. if ( !($result = $db->sql_query($sql)) )
  676. {
  677. message_die(GENERAL_ERROR, "Could not obtain user vote data for this topic", '', __LINE__, __FILE__, $sql);
  678. }
  679.  
  680. $user_voted = ( $row = $db->sql_fetchrow($result) ) ? TRUE : 0;
  681. $db->sql_freeresult($result);
  682.  
  683. if ( isset($HTTP_GET_VARS['vote']) || isset($HTTP_POST_VARS['vote']) )
  684. {
  685. $view_result = ( ( ( isset($HTTP_GET_VARS['vote']) ) ? $HTTP_GET_VARS['vote'] : $HTTP_POST_VARS['vote'] ) == 'viewresult' ) ? TRUE : 0;
  686. }
  687. else
  688. {
  689. $view_result = 0;
  690. }
  691.  
  692. $poll_expired = ( $vote_info[0]['vote_length'] ) ? ( ( $vote_info[0]['vote_start'] + $vote_info[0]['vote_length'] < time() ) ? TRUE : 0 ) : 0;
  693.  
  694. if ( $user_voted || $view_result || $poll_expired || !$is_auth['auth_vote'] || $forum_topic_data['topic_status'] == TOPIC_LOCKED )
  695. {
  696. $template->set_filenames(array(
  697. 'pollbox' => 'viewtopic_poll_result.tpl')
  698. );
  699.  
  700. $vote_results_sum = 0;
  701.  
  702. for($i = 0; $i < $vote_options; $i++)
  703. {
  704. $vote_results_sum += $vote_info[$i]['vote_result'];
  705. }
  706.  
  707. $vote_graphic = 0;
  708. $vote_graphic_max = count($images['voting_graphic']);
  709.  
  710. for($i = 0; $i < $vote_options; $i++)
  711. {
  712. $vote_percent = ( $vote_results_sum > 0 ) ? $vote_info[$i]['vote_result'] / $vote_results_sum : 0;
  713. $vote_graphic_length = round($vote_percent * $board_config['vote_graphic_length']);
  714.  
  715. $vote_graphic_img = $images['voting_graphic'][$vote_graphic];
  716. $vote_graphic = ($vote_graphic < $vote_graphic_max - 1) ? $vote_graphic + 1 : 0;
  717.  
  718. if ( count($orig_word) )
  719. {
  720. $vote_info[$i]['vote_option_text'] = str_replace($orig_word, $replacement_word, $vote_info[$i]['vote_option_text']);
  721. }
  722.  
  723. $template->assign_block_vars("poll_option", array(
  724. 'POLL_OPTION_CAPTION' => $vote_info[$i]['vote_option_text'],
  725. 'POLL_OPTION_RESULT' => $vote_info[$i]['vote_result'],
  726. 'POLL_OPTION_PERCENT' => sprintf("%.1d%%", ($vote_percent * 100)),
  727.  
  728. 'POLL_OPTION_IMG' => $vote_graphic_img,
  729. 'POLL_OPTION_IMG_WIDTH' => $vote_graphic_length)
  730. );
  731. }
  732.  
  733. $template->assign_vars(array(
  734. 'L_TOTAL_VOTES' => $lang['Total_votes'],
  735. 'TOTAL_VOTES' => $vote_results_sum)
  736. );
  737.  
  738. }
  739. else
  740. {
  741. $template->set_filenames(array(
  742. 'pollbox' => 'viewtopic_poll_ballot.tpl')
  743. );
  744.  
  745. for($i = 0; $i < $vote_options; $i++)
  746. {
  747. if ( count($orig_word) )
  748. {
  749. $vote_info[$i]['vote_option_text'] = str_replace($orig_word, $replacement_word, $vote_info[$i]['vote_option_text']);
  750. }
  751.  
  752. $template->assign_block_vars("poll_option", array(
  753. 'POLL_OPTION_ID' => $vote_info[$i]['vote_option_id'],
  754. 'POLL_OPTION_CAPTION' => $vote_info[$i]['vote_option_text'])
  755. );
  756. }
  757.  
  758. $template->assign_vars(array(
  759. 'L_SUBMIT_VOTE' => $lang['Submit_vote'],
  760. 'L_VIEW_RESULTS' => $lang['View_results'],
  761.  
  762. 'U_VIEW_RESULTS' => append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;postdays=$post_days&amp;postorder=$post_order&amp;vote=viewresult"))
  763. );
  764.  
  765. $s_hidden_fields = '<input type="hidden" name="topic_id" value="' . $topic_id . '" /><input type="hidden" name="mode" value="vote" />';
  766. }
  767.  
  768. if ( count($orig_word) )
  769. {
  770. $vote_title = str_replace($orig_word, $replacement_word, $vote_title);
  771. }
  772.  
  773. $s_hidden_fields .= '<input type="hidden" name="sid" value="' . $userdata['session_id'] . '" />';
  774.  
  775. $template->assign_vars(array(
  776. 'POLL_QUESTION' => $vote_title,
  777.  
  778. 'S_HIDDEN_FIELDS' => $s_hidden_fields,
  779. 'S_POLL_ACTION' => append_sid("posting.$phpEx?mode=vote&amp;" . POST_TOPIC_URL . "=$topic_id"))
  780. );
  781.  
  782. $template->assign_var_from_handle('POLL_DISPLAY', 'pollbox');
  783. }
  784. }
  785. init_display_post_attachments($forum_topic_data['topic_attachment']);
  786.  
  787. $sql = "UPDATE " . TOPICS_TABLE . "
  788. SET topic_views = topic_views + 1
  789. WHERE topic_id = $topic_id";
  790. if ( !$db->sql_query($sql) )
  791. {
  792. message_die(GENERAL_ERROR, "Could not update topic views.", '', __LINE__, __FILE__, $sql);
  793. }
  794.  
  795. for($i = 0; $i < $total_posts; $i++)
  796. {
  797. $avatar_img = '';
  798. if ( $postrow[$i]['user_avatar_type'] && $postrow[$i]['user_allowavatar'] )
  799. {
  800. switch( $postrow[$i]['user_avatar_type'] )
  801. {
  802. case USER_AVATAR_UPLOAD:
  803. $avatar_img = ( $board_config['allow_avatar_upload'] ) ? '<div class="img"><img src="' . $board_config['avatar_path'] . '/' . $postrow[$i]['user_avatar'] . '" alt="" border="0" /></div>' : '';
  804. break;
  805. case USER_AVATAR_REMOTE:
  806. $avatar_img = ( $board_config['allow_avatar_remote'] ) ? '<div class="img"><img src="' . $postrow[$i]['user_avatar'] . '" alt="" border="0" /></div>' : '';
  807. break;
  808. case USER_AVATAR_GALLERY:
  809. $avatar_img = ( $board_config['allow_avatar_local'] ) ? '<div class="img"><img src="' . $board_config['avatar_gallery_path'] . '/' . $postrow[$i]['user_avatar'] . '" alt="" border="0" /></div>' : '';
  810. break;
  811. }
  812.  
  813. }
  814. else {
  815. $avatar_img = '<div class="img"><img src="../images/avatars/noavatar.gif" alt="" /></div>'; }
  816. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  817.  
  818.  
  819. $user_rank = '';
  820. $rank_image = '';
  821. if ( $postrow['user_rank'])
  822. {
  823. for($j = 0; $j < count($ranksrow); $j++)
  824. {
  825. if ( $postrow['user_rank'] == $ranksrow[$j]['rank_id'] && $ranksrow[$j]['rank_special'] )
  826. {
  827. $user_rank = ($postrow['user_id'] != ANONYMOUS) ? $ranksrow[$j]['rank_title'] : '';
  828. $rank_image = ( $ranksrow[$j]['rank_image'] && $postrow['user_id'] != ANONYMOUS) ? '<img src="' . $ranksrow[$j]['rank_image'] . '" alt="' . $user_rank . '" title="' . $user_rank . '" border="0" /><br />' : '';
  829. }
  830. }
  831. } else
  832. {
  833. for($j = 0; $j < count($ranksrow); $j++)
  834. {
  835. if ( $postrow['user_posts'] >= $ranksrow[$j]['rank_min'] && !$ranksrow[$j]['rank_special'] )
  836. {
  837. $user_rank = ($postrow['user_id'] != ANONYMOUS) ? $ranksrow[$j]['rank_title'] : '';
  838. $rank_image = ( $ranksrow[$j]['rank_image'] && $postrow['user_id'] != ANONYMOUS) ? '<img src="' . $ranksrow[$j]['rank_image'] . '" alt="' . $user_rank . '" title="' . $user_rank . '" border="0" /><br />' : '';
  839. }
  840. }
  841. }
  842.  
  843. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  844.  
  845. $poster_id = $postrow[$i]['user_id'];
  846. $nomer_posta = $i + $start + 1;
  847.  
  848. if ( $postrow[$i]['user_warnings'] == 0 )
  849. {
  850. if ( !empty($postrow[$i]['user_nic_color']) )
  851. {
  852. $poster = ( $poster_id == ANONYMOUS ) ? ( ($postrow[$i]['post_username'] != '' ) ? $postrow[$i]['post_username'] : $lang['Guest'] ) : '<a href="' . append_sid("pages/profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . '=' . $postrow[$i]['user_id']) . '" style="color: '.$postrow[$i]['user_nic_color'].'">' . $postrow[$i]['username'] . '</a>';
  853. } else {
  854. $poster = ( $poster_id == ANONYMOUS ) ? ( ($postrow[$i]['post_username'] != '' ) ? $postrow[$i]['post_username'] : $lang['Guest'] ) : '<a href="' . append_sid("pages/profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . '=' . $postrow[$i]['user_id']) . '">' . $postrow[$i]['username'] . '</a>';
  855. }
  856. } else {
  857. $poster = ( $poster_id == ANONYMOUS ) ? ( ($postrow[$i]['post_username'] != '' ) ? $postrow[$i]['post_username'] : $lang['Guest'] ) : '<a href="' . append_sid("pages/profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . '=' . $postrow[$i]['user_id']) . '" style="color:#000000">' . $postrow[$i]['username'] . '</a>';
  858. }
  859. $post_date = create_date($board_config['default_dateformat'], $postrow[$i]['post_time'], $board_config['board_timezone']);
  860.  
  861. $poster_posts = ( $postrow[$i]['user_id'] != ANONYMOUS ) ? $lang['skobka1'] . '' . $postrow[$i]['user_posts'] . '' . $lang['skobka2'] : ' ';
  862.  
  863. $temp_url = '';
  864. $user_reputation = $reviews_img = $reviews = $ban_img = $ban = $warn_img = $warn = $ban_img = $ban = $reportpost_img = $reportpost = '';
  865.  
  866. if ( $poster_id != ANONYMOUS )
  867. {
  868. if ($board_config['warnings_enabled'])
  869. {
  870. $personal_auth = reputation_auth($is_auth, $userdata, $postrow[$i], true);
  871.  
  872. if (!isset($post_warnings[$postrow[$i]['post_id']]))
  873. {
  874. if ($personal_auth['auth_warn'])
  875. {
  876. $temp_url = "reputation.$phpEx?mode=warning&amp;" . POST_POST_URL . "=" . $postrow[$i]['post_id'] . "&amp;sid=" . $userdata['session_id'];
  877. $warn = ' <a href="' . $temp_url . '">пред</a>|';
  878. }
  879.  
  880. if ($personal_auth['auth_ban'])
  881. {
  882. $temp_url = "reputation.$phpEx?mode=ban&amp;" . POST_POST_URL . "=" . $postrow[$i]['post_id'] . "&amp;sid=" . $userdata['session_id'];
  883. $ban = '<a href="' . $temp_url . '">бан</a>|';
  884. }
  885. }
  886. }
  887. if( $userdata['user_on_off'] == 1)
  888. {
  889. if ($postrow[$i]['user_session_time'] >= (time()-$board_config['online_time']))
  890. {
  891. if ($postrow[$i]['user_allow_viewonline'])
  892. {
  893. $online_status = '<span' . $online_color . '>' . $lang['Online'] . '</span>';
  894. }
  895. else if ( $is_auth['auth_mod'] || $userdata['user_id'] == $poster_id )
  896. {
  897. $online_status = '<span' . $hidden_color . '>' . $lang['Hidden'] . '</span>';
  898. }
  899. else
  900. {
  901. $online_status = '<span' . $offline_color . '>' . $lang['Offline'] . '</span>';
  902. }
  903. }
  904. else
  905. {
  906. $online_status = '<span' . $offline_color . '>' . $lang['Offline'] . '</span>';
  907. }
  908. } else {
  909. $online_status = '';
  910. }
  911. }
  912.  
  913. $online_status = ( $postrow[$i]['user_id'] != ANONYMOUS ) ? $online_status : '';
  914.  
  915. $temp_url = append_sid("posting.$phpEx?mode=otv&amp;" . POST_POST_URL . "=" . $postrow[$i]['post_id']);
  916. $quote = '[<a href="' . $temp_url . '">Отв</a>|';
  917.  
  918. $temp_url = append_sid("posting.$phpEx?mode=quote&amp;" . POST_POST_URL . "=" . $postrow[$i]['post_id']);
  919. $quot = '<a href="' . $temp_url . '">Цит</a>]';
  920.  
  921. if ( ( $userdata['user_id'] == $poster_id && $is_auth['auth_edit'] ) || $is_auth['auth_mod'] )
  922. {
  923. $temp_url = append_sid("posting.$phpEx?mode=editpost&amp;" . POST_POST_URL . "=" . $postrow[$i]['post_id']);
  924. $edit = '<a href="' . $temp_url . '">изм</a>';
  925. $user_brow=$postrow[$i]['poster_brow'];
  926. $user_ip=decode_ip($postrow[$i]['poster_ip']);
  927. $print_info_ua='<br/><small><font color="#cc00cc">('.$user_brow.', '.$user_ip.')</font></small>';
  928. }
  929. else
  930. {
  931. $edit_img = '';
  932. $edit = '';
  933. $user_brow = '';
  934. $user_ip = '';
  935. $print_info_ua = '';
  936. }
  937.  
  938. if ( $is_auth['auth_mod'] )
  939. {
  940.  
  941. $temp_url = "modcp.$phpEx?mode=ip&amp;" . POST_POST_URL . "=" . $postrow[$i]['post_id'] . "&amp;" . POST_TOPIC_URL . "=" . $topic_id . "&amp;sid=" . $userdata['session_id'];
  942. $ip = '|<a href="' . $temp_url . '">ип</a>';
  943.  
  944. $temp_url = "posting.$phpEx?mode=delete&amp;" . POST_POST_URL . "=" . $postrow[$i]['post_id'] . "&amp;sid=" . $userdata['session_id'];
  945. $delpost = '|<a href="' . $temp_url . '">уд</a>';
  946. }
  947. else
  948. {
  949. $ip = '';
  950.  
  951. if ( $userdata['user_id'] == $poster_id && $is_auth['auth_delete'] && $forum_topic_data['topic_last_post_id'] == $postrow[$i]['post_id'] )
  952. {
  953. $temp_url = "posting.$phpEx?mode=delete&amp;" . POST_POST_URL . "=" . $postrow[$i]['post_id'] . "&amp;sid=" . $userdata['session_id'];
  954. $delpost = '|<a href="' . $temp_url . '">уд</a>';
  955. }
  956. else
  957. {
  958. $delpost = '';
  959. }
  960. if ($board_config['reports_enabled'])
  961. {
  962. if ($userdata['user_id'] != ANONYMOUS)
  963. {
  964. $temp_url = "post_report.$phpEx?mode=report&amp;" . POST_POST_URL . "=" . $postrow[$i]['post_id'] . "&amp;sid=" . $userdata['session_id'];
  965. $reportpost = '<a href="' . $temp_url . '">' . $lang['reputation_report_post'] . '</a>';
  966. }
  967. }
  968. }
  969.  
  970. $post_subject = ( $postrow[$i]['post_subject'] != '' ) ? $postrow[$i]['post_subject'] : '';
  971.  
  972. $message = $postrow[$i]['post_text'];
  973. $bbcode_uid = $postrow[$i]['bbcode_uid'];
  974.  
  975. if ( (!isset($HTTP_GET_VARS[POST_POST_URL]) || (($HTTP_GET_VARS[POST_POST_URL] != $postrow[$i]['post_id']) && isset($HTTP_GET_VARS[POST_POST_URL]))) && ($userdata['user_post_leng'] > 0) && (strlen($message) > ($userdata['user_post_leng']*4)) && $userdata['session_logged_in'] )
  976. {
  977. $message = u2w($message);
  978. $obrez = strpos($message, " ", $userdata['user_post_leng']*2);
  979. $message = substr($message, 0, $obrez);
  980. $message .= '...<a href="' . append_sid("viewtopic.$phpEx?" .POST_POST_URL . "=" . $postrow[$i]['post_id']) . '">--&gt</a>';
  981. $message = w2u($message);
  982. }
  983.  
  984. if ( !$board_config['allow_html'] || !$userdata['user_allowhtml'])
  985. {
  986. if ( $postrow[$i]['enable_html'] )
  987. {
  988. $message = preg_replace('#(<)([\/]?.*?)(>)#is', "&lt;\\2&gt;", $message);
  989. }
  990. }
  991.  
  992. if ($bbcode_uid != '')
  993. {
  994. $message = ($board_config['allow_bbcode']) ? bbencode_second_pass($message, $bbcode_uid) : preg_replace("/\:$bbcode_uid/si", '', $message);
  995. }
  996.  
  997. $message = make_clickable($message);
  998.  
  999. if ( $board_config['allow_smilies'] )
  1000. {
  1001. if ( $postrow[$i]['enable_smilies'] )
  1002. {
  1003. $message = smilies_pass($message);
  1004. }
  1005. }
  1006.  
  1007. if ($highlight_match)
  1008. {
  1009. $message = preg_replace('#(?!<.*)(?<!\w)(' . $highlight_match . ')(?!\w|[^<>]*>)#i', '<b style="color: red">\1</b>', $message);
  1010. }
  1011.  
  1012. if (count($orig_word))
  1013. {
  1014. $post_subject = str_replace($orig_word, $replacement_word, $post_subject);
  1015. $message = str_replace($orig_word, $replacement_word, $message);
  1016. }
  1017.  
  1018. $message = str_replace("\n", "\n<br />\n", $message);
  1019.  
  1020. if ( $postrow[$i]['post_edit_count'] && (($userdata['session_logged_in'] && $userdata['user_posl_red']) || (!$userdata['session_logged_in'] && $board_config['posl_red'])) )
  1021. {
  1022. $l_edit_time_total = ( $postrow[$i]['post_edit_count'] == 1 ) ? $lang['Edited_time_total'] : $lang['Edited_times_total'];
  1023.  
  1024. $l_edited_by = '<br/><font color="#999999">' . sprintf($l_edit_time_total, create_date($board_config['default_dateformat'], $postrow[$i]['post_edit_time'], $board_config['board_timezone']), $postrow[$i]['post_edit_count']) . '</font>';
  1025. }
  1026. else
  1027. {
  1028. $l_edited_by = '';
  1029. }
  1030.  
  1031. if (isset($post_warnings[$postrow[$i]['post_id']]))
  1032. {
  1033. $warning = $post_warnings[$postrow[$i]['post_id']];
  1034. if ($warning['modification'] == REPUTATION_WARNING || $warning['modification'] == REPUTATION_WARNING_EXPIRED)
  1035. {
  1036. $icon = '<b>!</b>';
  1037. }
  1038. else
  1039. {
  1040. $icon = '<b>#</b>';
  1041. }
  1042. } else {
  1043. $icon = '';
  1044. }
  1045.  
  1046. $row_color = '';
  1047. $row_class = ( !($i % 2) ) ? 'row1' : 'row2';
  1048.  
  1049. $template->assign_block_vars('postrow', array(
  1050. 'USER_RANK' => $user_rank,
  1051. 'AVATAR_IMG' => $avatar_img,
  1052. 'ROW_COLOR' => '#' . $row_color,
  1053. 'ROW_CLASS' => $row_class,
  1054. 'POSTER_NAME' => $poster,
  1055. 'POSTER_POSTS' => $poster_posts,
  1056. 'POSTER_ONLINE_STATUS' => $online_status,
  1057. 'POST_DATE' => $post_date,
  1058. 'POST_SUBJECT' => $post_subject,
  1059. 'MESSAGE' => $message,
  1060. 'EDITED_MESSAGE' => $l_edited_by,
  1061. 'POSTER_REPUTATION' => $user_reputation,
  1062. 'ICON' => $icon,
  1063. 'NOMER_POSTA' => $nomer_posta,
  1064.  
  1065. 'REPORTPOST' => $reportpost,
  1066. 'RED' => $ban,
  1067. 'YELLOW' => $warn,
  1068. 'REVIEWS' => $reviews,
  1069. 'INFO_UA' => $print_info_ua,
  1070.  
  1071. 'EDIT' => $edit,
  1072. 'QUOTE' => $quote,
  1073. 'QUOT' => $quot,
  1074. 'IP' => $ip,
  1075. 'DELETE' => $delpost,
  1076.  
  1077. 'L_MINI_POST_ALT' => $mini_post_alt,
  1078.  
  1079. 'U_MINI_POST' => $mini_post_url,
  1080. 'U_POST_ID' => $postrow[$i]['post_id'])
  1081. );
  1082. display_post_attachments($postrow[$i]['post_id'], $postrow[$i]['post_attachment']);
  1083.  
  1084. }
  1085.  
  1086. $template->pparse('body');
  1087.  
  1088. include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
  1089. ?>