Guest User

Untitled

a guest
Jan 14th, 2012
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 101.79 KB | None | 0 0
  1. <?php
  2. /**
  3. *
  4. * @package phpBB3
  5. * @version $Id$
  6. * @copyright (c) 2005 phpBB Group
  7. * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  8. *
  9. */
  10.  
  11.  
  12.  
  13. /**
  14. * @ignore
  15. */
  16. define('IN_PHPBB', true);
  17. $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
  18. $phpEx = substr(strrchr(__FILE__, '.'), 1);
  19. include($phpbb_root_path . 'common.' . $phpEx);
  20. include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
  21. include($phpbb_root_path . 'includes/bbcode.' . $phpEx);
  22.  
  23. include($phpbb_root_path . 'mods/viewtopic.' . $phpEx);
  24.  
  25.  
  26.  
  27. // Start session management
  28. $user->session_begin();
  29. $auth->acl($user->data);
  30.  
  31.  
  32.  
  33. // Initial var setup
  34. $forum_id = request_var('f', 0);
  35. $topic_id = request_var('t', 0);
  36. $post_id = request_var('p', 0);
  37. $voted_id = request_var('vote_id', array('' => 0));
  38.  
  39.  
  40.  
  41. $voted_id = (sizeof($voted_id) > 1) ? array_unique($voted_id) : $voted_id;
  42.  
  43.  
  44.  
  45.  
  46.  
  47. $start = request_var('start', 0);
  48. $view = request_var('view', '');
  49.  
  50.  
  51.  
  52. $default_sort_days = (!empty($user->data['user_post_show_days'])) ? $user->data['user_post_show_days'] : 0;
  53. $default_sort_key = (!empty($user->data['user_post_sortby_type'])) ? $user->data['user_post_sortby_type'] : 't';
  54. $default_sort_dir = (!empty($user->data['user_post_sortby_dir'])) ? $user->data['user_post_sortby_dir'] : 'a';
  55.  
  56.  
  57.  
  58. $sort_days = request_var('st', $default_sort_days);
  59. $sort_key = request_var('sk', $default_sort_key);
  60. $sort_dir = request_var('sd', $default_sort_dir);
  61.  
  62.  
  63.  
  64. $update = request_var('update', false);
  65.  
  66.  
  67.  
  68. $s_can_vote = false;
  69. /**
  70. * @todo normalize?
  71. */
  72. $hilit_words = request_var('hilit', '', true);
  73.  
  74.  
  75.  
  76. // Do we have a topic or post id?
  77. if (!$topic_id && !$post_id)
  78. {
  79. trigger_error('NO_TOPIC');
  80. }
  81.  
  82.  
  83.  
  84. // Find topic id if user requested a newer or older topic
  85. if ($view && !$post_id)
  86. {
  87. if (!$forum_id)
  88. {
  89. $sql = 'SELECT forum_id
  90. FROM ' . TOPICS_TABLE . "
  91. WHERE topic_id = $topic_id";
  92. $result = $db->sql_query($sql);
  93. $forum_id = (int) $db->sql_fetchfield('forum_id');
  94. $db->sql_freeresult($result);
  95.  
  96.  
  97.  
  98. if (!$forum_id)
  99. {
  100. trigger_error('NO_TOPIC');
  101. }
  102. }
  103.  
  104.  
  105.  
  106. if ($view == 'unread')
  107. {
  108. // Get topic tracking info
  109. $topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_id);
  110.  
  111.  
  112.  
  113. $topic_last_read = (isset($topic_tracking_info[$topic_id])) ? $topic_tracking_info[$topic_id] : 0;
  114.  
  115.  
  116.  
  117. $sql = 'SELECT post_id, topic_id, forum_id
  118. FROM ' . POSTS_TABLE . "
  119. WHERE topic_id = $topic_id
  120. " . (($auth->acl_get('m_approve', $forum_id)) ? '' : 'AND post_approved = 1') . "
  121. AND post_time > $topic_last_read
  122. AND forum_id = $forum_id
  123. ORDER BY post_time ASC";
  124. $result = $db->sql_query_limit($sql, 1);
  125. $row = $db->sql_fetchrow($result);
  126. $db->sql_freeresult($result);
  127.  
  128.  
  129.  
  130. if (!$row)
  131. {
  132. $sql = 'SELECT topic_last_post_id as post_id, topic_id, forum_id
  133. FROM ' . TOPICS_TABLE . '
  134. WHERE topic_id = ' . $topic_id;
  135. $result = $db->sql_query($sql);
  136. $row = $db->sql_fetchrow($result);
  137. $db->sql_freeresult($result);
  138. }
  139.  
  140.  
  141.  
  142. if (!$row)
  143. {
  144. // Setup user environment so we can process lang string
  145. $user->setup('viewtopic');
  146.  
  147.  
  148.  
  149. trigger_error('NO_TOPIC');
  150. }
  151.  
  152.  
  153.  
  154. $post_id = $row['post_id'];
  155. $topic_id = $row['topic_id'];
  156. }
  157. else if ($view == 'next' || $view == 'previous')
  158. {
  159. $sql_condition = ($view == 'next') ? '>' : '<';
  160. $sql_ordering = ($view == 'next') ? 'ASC' : 'DESC';
  161.  
  162.  
  163.  
  164. $sql = 'SELECT forum_id, topic_last_post_time
  165. FROM ' . TOPICS_TABLE . '
  166. WHERE topic_id = ' . $topic_id;
  167. $result = $db->sql_query($sql);
  168. $row = $db->sql_fetchrow($result);
  169. $db->sql_freeresult($result);
  170.  
  171.  
  172.  
  173. if (!$row)
  174. {
  175. $user->setup('viewtopic');
  176. // OK, the topic doesn't exist. This error message is not helpful, but technically correct.
  177. trigger_error(($view == 'next') ? 'NO_NEWER_TOPICS' : 'NO_OLDER_TOPICS');
  178. }
  179. else
  180. {
  181. $sql = 'SELECT topic_id, forum_id
  182. FROM ' . TOPICS_TABLE . '
  183. WHERE forum_id = ' . $row['forum_id'] . "
  184. AND topic_moved_id = 0
  185. AND topic_last_post_time $sql_condition {$row['topic_last_post_time']}
  186. " . (($auth->acl_get('m_approve', $row['forum_id'])) ? '' : 'AND topic_approved = 1') . "
  187. ORDER BY topic_last_post_time $sql_ordering";
  188. $result = $db->sql_query_limit($sql, 1);
  189. $row = $db->sql_fetchrow($result);
  190. $db->sql_freeresult($result);
  191.  
  192.  
  193.  
  194. if (!$row)
  195. {
  196. $user->setup('viewtopic');
  197. trigger_error(($view == 'next') ? 'NO_NEWER_TOPICS' : 'NO_OLDER_TOPICS');
  198. }
  199. else
  200. {
  201. $topic_id = $row['topic_id'];
  202.  
  203.  
  204.  
  205. // Check for global announcement correctness?
  206. if (!$row['forum_id'] && !$forum_id)
  207. {
  208. trigger_error('NO_TOPIC');
  209. }
  210. else if ($row['forum_id'])
  211. {
  212. $forum_id = $row['forum_id'];
  213. }
  214. }
  215. }
  216. }
  217.  
  218.  
  219.  
  220. // Check for global announcement correctness?
  221. if ((!isset($row) || !$row['forum_id']) && !$forum_id)
  222. {
  223. trigger_error('NO_TOPIC');
  224. }
  225. else if (isset($row) && $row['forum_id'])
  226. {
  227. $forum_id = $row['forum_id'];
  228. }
  229. }
  230.  
  231.  
  232.  
  233. // This rather complex gaggle of code handles querying for topics but
  234. // also allows for direct linking to a post (and the calculation of which
  235. // page the post is on and the correct display of viewtopic)
  236. $sql_array = array(
  237. 'SELECT' => 't.*, f.*',
  238.  
  239.  
  240.  
  241. 'FROM' => array(FORUMS_TABLE => 'f'),
  242. );
  243.  
  244.  
  245.  
  246. // Firebird handles two columns of the same name a little differently, this
  247. // addresses that by forcing the forum_id to come from the forums table.
  248. if ($db->sql_layer === 'firebird')
  249. {
  250. $sql_array['SELECT'] = 'f.forum_id AS forum_id, ' . $sql_array['SELECT'];
  251. }
  252.  
  253.  
  254.  
  255. // The FROM-Order is quite important here, else t.* columns can not be correctly bound.
  256. if ($post_id)
  257. {
  258. $sql_array['SELECT'] .= ', p.post_approved, p.post_time, p.post_id';
  259. $sql_array['FROM'][POSTS_TABLE] = 'p';
  260. }
  261.  
  262.  
  263.  
  264. // Topics table need to be the last in the chain
  265. $sql_array['FROM'][TOPICS_TABLE] = 't';
  266.  
  267.  
  268.  
  269. if ($user->data['is_registered'])
  270. {
  271. $sql_array['SELECT'] .= ', tw.notify_status';
  272. $sql_array['LEFT_JOIN'] = array();
  273.  
  274.  
  275.  
  276. $sql_array['LEFT_JOIN'][] = array(
  277. 'FROM' => array(TOPICS_WATCH_TABLE => 'tw'),
  278. 'ON' => 'tw.user_id = ' . $user->data['user_id'] . ' AND t.topic_id = tw.topic_id'
  279. );
  280.  
  281.  
  282.  
  283. if ($config['allow_bookmarks'])
  284. {
  285. $sql_array['SELECT'] .= ', bm.topic_id as bookmarked';
  286. $sql_array['LEFT_JOIN'][] = array(
  287. 'FROM' => array(BOOKMARKS_TABLE => 'bm'),
  288. 'ON' => 'bm.user_id = ' . $user->data['user_id'] . ' AND t.topic_id = bm.topic_id'
  289. );
  290. }
  291.  
  292.  
  293.  
  294. if ($config['load_db_lastread'])
  295. {
  296. $sql_array['SELECT'] .= ', tt.mark_time, ft.mark_time as forum_mark_time';
  297.  
  298.  
  299.  
  300. $sql_array['LEFT_JOIN'][] = array(
  301. 'FROM' => array(TOPICS_TRACK_TABLE => 'tt'),
  302. 'ON' => 'tt.user_id = ' . $user->data['user_id'] . ' AND t.topic_id = tt.topic_id'
  303. );
  304.  
  305.  
  306.  
  307. $sql_array['LEFT_JOIN'][] = array(
  308. 'FROM' => array(FORUMS_TRACK_TABLE => 'ft'),
  309. 'ON' => 'ft.user_id = ' . $user->data['user_id'] . ' AND t.forum_id = ft.forum_id'
  310. );
  311. }
  312. }
  313.  
  314.  
  315.  
  316. if (!$post_id)
  317. {
  318. $sql_array['WHERE'] = "t.topic_id = $topic_id";
  319. }
  320. else
  321. {
  322. $sql_array['WHERE'] = "p.post_id = $post_id AND t.topic_id = p.topic_id";
  323. }
  324.  
  325.  
  326.  
  327. $sql_array['WHERE'] .= ' AND (f.forum_id = t.forum_id';
  328.  
  329.  
  330.  
  331. if (!$forum_id)
  332. {
  333. // If it is a global announcement make sure to set the forum id to a postable forum
  334. $sql_array['WHERE'] .= ' OR (t.topic_type = ' . POST_GLOBAL . '
  335. AND f.forum_type = ' . FORUM_POST . ')';
  336. }
  337. else
  338. {
  339. $sql_array['WHERE'] .= ' OR (t.topic_type = ' . POST_GLOBAL . "
  340. AND f.forum_id = $forum_id)";
  341. }
  342.  
  343.  
  344.  
  345. $sql_array['WHERE'] .= ')';
  346.  
  347.  
  348.  
  349. // Join to forum table on topic forum_id unless topic forum_id is zero
  350. // whereupon we join on the forum_id passed as a parameter ... this
  351. // is done so navigation, forum name, etc. remain consistent with where
  352. // user clicked to view a global topic
  353. $sql = $db->sql_build_query('SELECT', $sql_array);
  354. $result = $db->sql_query($sql);
  355. $topic_data = $db->sql_fetchrow($result);
  356. $db->sql_freeresult($result);
  357.  
  358.  
  359.  
  360. // link to unapproved post or incorrect link
  361. if (!$topic_data)
  362. {
  363. // If post_id was submitted, we try at least to display the topic as a last resort...
  364. if ($post_id && $topic_id)
  365. {
  366. redirect(append_sid("{$phpbb_root_path}viewtopic.$phpEx", "t=$topic_id" . (($forum_id) ? "&amp;f=$forum_id" : '')));
  367. }
  368.  
  369.  
  370.  
  371. trigger_error('NO_TOPIC');
  372. }
  373.  
  374.  
  375.  
  376. $forum_id = (int) $topic_data['forum_id'];
  377. // This is for determining where we are (page)
  378. if ($post_id)
  379. {
  380. // are we where we are supposed to be?
  381. if (!$topic_data['post_approved'] && !$auth->acl_get('m_approve', $topic_data['forum_id']))
  382. {
  383. // If post_id was submitted, we try at least to display the topic as a last resort...
  384. if ($topic_id)
  385. {
  386. redirect(append_sid("{$phpbb_root_path}viewtopic.$phpEx", "t=$topic_id" . (($forum_id) ? "&amp;f=$forum_id" : '')));
  387. }
  388.  
  389.  
  390.  
  391. trigger_error('NO_TOPIC');
  392. }
  393. if ($post_id == $topic_data['topic_first_post_id'] || $post_id == $topic_data['topic_last_post_id'])
  394. {
  395. $check_sort = ($post_id == $topic_data['topic_first_post_id']) ? 'd' : 'a';
  396.  
  397.  
  398.  
  399. if ($sort_dir == $check_sort)
  400. {
  401. $topic_data['prev_posts'] = ($auth->acl_get('m_approve', $forum_id)) ? $topic_data['topic_replies_real'] : $topic_data['topic_replies'];
  402. }
  403. else
  404. {
  405. $topic_data['prev_posts'] = 0;
  406. }
  407. }
  408. else
  409. {
  410. $sql = 'SELECT COUNT(p.post_id) AS prev_posts
  411. FROM ' . POSTS_TABLE . " p
  412. WHERE p.topic_id = {$topic_data['topic_id']}
  413. " . ((!$auth->acl_get('m_approve', $forum_id)) ? 'AND p.post_approved = 1' : '');
  414.  
  415. if ($sort_dir == 'd')
  416. {
  417. $sql .= " AND (p.post_time > {$topic_data['post_time']} OR (p.post_time = {$topic_data['post_time']} AND p.post_id >= {$topic_data['post_id']}))";
  418. }
  419. else
  420. {
  421. $sql .= " AND (p.post_time < {$topic_data['post_time']} OR (p.post_time = {$topic_data['post_time']} AND p.post_id <= {$topic_data['post_id']}))";
  422. }
  423.  
  424. $result = $db->sql_query($sql);
  425. $row = $db->sql_fetchrow($result);
  426. $db->sql_freeresult($result);
  427.  
  428.  
  429.  
  430. $topic_data['prev_posts'] = $row['prev_posts'] - 1;
  431. }
  432. }
  433.  
  434.  
  435.  
  436. $topic_id = (int) $topic_data['topic_id'];
  437. //
  438. $topic_replies = ($auth->acl_get('m_approve', $forum_id)) ? $topic_data['topic_replies_real'] : $topic_data['topic_replies'];
  439.  
  440.  
  441.  
  442. // Check sticky/announcement time limit
  443. if (($topic_data['topic_type'] == POST_STICKY || $topic_data['topic_type'] == POST_ANNOUNCE) && $topic_data['topic_time_limit'] && ($topic_data['topic_time'] + $topic_data['topic_time_limit']) < time())
  444. {
  445. $sql = 'UPDATE ' . TOPICS_TABLE . '
  446. SET topic_type = ' . POST_NORMAL . ', topic_time_limit = 0
  447. WHERE topic_id = ' . $topic_id;
  448. $db->sql_query($sql);
  449.  
  450.  
  451.  
  452. $topic_data['topic_type'] = POST_NORMAL;
  453. $topic_data['topic_time_limit'] = 0;
  454. }
  455.  
  456.  
  457.  
  458. // Setup look and feel
  459. $user->setup('viewtopic', $topic_data['forum_style']);
  460.  
  461.  
  462.  
  463. if (!$topic_data['topic_approved'] && !$auth->acl_get('m_approve', $forum_id))
  464. {
  465. trigger_error('NO_TOPIC');
  466. }
  467.  
  468.  
  469.  
  470. // Start auth check
  471. if (!$auth->acl_get('f_read', $forum_id))
  472. {
  473. if ($user->data['user_id'] != ANONYMOUS)
  474. {
  475. trigger_error('SORRY_AUTH_READ');
  476. }
  477.  
  478.  
  479.  
  480. login_box('', $user->lang['LOGIN_VIEWFORUM']);
  481. }
  482.  
  483.  
  484.  
  485. // Forum is passworded ... check whether access has been granted to this
  486. // user this session, if not show login box
  487. if ($topic_data['forum_password'])
  488. {
  489. login_forum_box($topic_data);
  490. }
  491.  
  492.  
  493.  
  494. evaluation_display();
  495.  
  496. // Redirect to login or to the correct post upon emailed notification links
  497. if (isset($_GET['e']))
  498. {
  499. $jump_to = request_var('e', 0);
  500.  
  501. $redirect_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&amp;t=$topic_id");
  502.  
  503. if ($user->data['user_id'] == ANONYMOUS)
  504. {
  505. login_box($redirect_url . "&amp;p=$post_id&amp;e=$jump_to", $user->lang['LOGIN_NOTIFY_TOPIC']);
  506. }
  507.  
  508.  
  509.  
  510. if ($jump_to > 0)
  511. {
  512. // We direct the already logged in user to the correct post...
  513. redirect($redirect_url . ((!$post_id) ? "&amp;p=$jump_to" : "&amp;p=$post_id") . "#p$jump_to");
  514. }
  515. }
  516.  
  517.  
  518.  
  519. // What is start equal to?
  520. if ($post_id)
  521. {
  522. $start = floor(($topic_data['prev_posts']) / $config['posts_per_page']) * $config['posts_per_page'];
  523. }
  524.  
  525.  
  526.  
  527. // Get topic tracking info
  528. if (!isset($topic_tracking_info))
  529. {
  530. $topic_tracking_info = array();
  531.  
  532.  
  533.  
  534. // Get topic tracking info
  535. if ($config['load_db_lastread'] && $user->data['is_registered'])
  536. {
  537. $tmp_topic_data = array($topic_id => $topic_data);
  538. $topic_tracking_info = get_topic_tracking($forum_id, $topic_id, $tmp_topic_data, array($forum_id => $topic_data['forum_mark_time']));
  539. unset($tmp_topic_data);
  540. }
  541. else if ($config['load_anon_lastread'] || $user->data['is_registered'])
  542. {
  543. $topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_id);
  544. }
  545. }
  546.  
  547.  
  548.  
  549. // Post ordering options
  550. $limit_days = array(0 => $user->lang['ALL_POSTS'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']);
  551.  
  552.  
  553.  
  554. $sort_by_text = array('a' => $user->lang['AUTHOR'], 't' => $user->lang['POST_TIME'], 's' => $user->lang['SUBJECT']);
  555. $sort_by_sql = array('a' => array('u.username_clean', 'p.post_id'), 't' => 'p.post_time', 's' => array('p.post_subject', 'p.post_id'));
  556. $join_user_sql = array('a' => true, 't' => false, 's' => false);
  557.  
  558.  
  559.  
  560. $s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = '';
  561.  
  562.  
  563.  
  564. gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param, $default_sort_days, $default_sort_key, $default_sort_dir);
  565.  
  566.  
  567.  
  568. // Obtain correct post count and ordering SQL if user has
  569. // requested anything different
  570. if ($sort_days)
  571. {
  572. $min_post_time = time() - ($sort_days * 86400);
  573.  
  574.  
  575.  
  576. $sql = 'SELECT COUNT(post_id) AS num_posts
  577. FROM ' . POSTS_TABLE . "
  578. WHERE topic_id = $topic_id
  579. AND post_time >= $min_post_time
  580. " . (($auth->acl_get('m_approve', $forum_id)) ? '' : 'AND post_approved = 1');
  581. $result = $db->sql_query($sql);
  582. $total_posts = (int) $db->sql_fetchfield('num_posts');
  583. $db->sql_freeresult($result);
  584.  
  585.  
  586.  
  587. $limit_posts_time = "AND p.post_time >= $min_post_time ";
  588.  
  589.  
  590.  
  591. if (isset($_POST['sort']))
  592. {
  593. $start = 0;
  594. }
  595. }
  596. else
  597. {
  598. $total_posts = $topic_replies + 1;
  599. $limit_posts_time = '';
  600. }
  601.  
  602.  
  603.  
  604. // Was a highlight request part of the URI?
  605. $highlight_match = $highlight = '';
  606. if ($hilit_words)
  607. {
  608. foreach (explode(' ', trim($hilit_words)) as $word)
  609. {
  610. if (trim($word))
  611. {
  612. $word = str_replace('\*', '\w+?', preg_quote($word, '#'));
  613. $word = preg_replace('#(^|\s)\\\\w\*\?(\s|$)#', '$1\w+?$2', $word);
  614. $highlight_match .= (($highlight_match != '') ? '|' : '') . $word;
  615. }
  616. }
  617.  
  618.  
  619.  
  620. $highlight = urlencode($hilit_words);
  621. }
  622.  
  623.  
  624.  
  625. // Make sure $start is set to the last page if it exceeds the amount
  626. if ($start < 0 || $start >= $total_posts)
  627. {
  628. $start = ($start < 0) ? 0 : floor(($total_posts - 1) / $config['posts_per_page']) * $config['posts_per_page'];
  629. }
  630.  
  631.  
  632.  
  633. // General Viewtopic URL for return links
  634.  
  635. $viewtopic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&amp;t=$topic_id&amp;start=$start" . ((strlen($u_sort_param)) ? "&amp;$u_sort_param" : '') . (($highlight_match) ? "&amp;hilit=$highlight" : ''));
  636.  
  637.  
  638.  
  639. // Are we watching this topic?
  640. $s_watching_topic = array(
  641. 'link' => '',
  642. 'title' => '',
  643. 'is_watching' => false,
  644. );
  645.  
  646.  
  647.  
  648. if (($config['email_enable'] || $config['jab_enable']) && $config['allow_topic_notify'])
  649. {
  650. $notify_status = (isset($topic_data['notify_status'])) ? $topic_data['notify_status'] : null;
  651. watch_topic_forum('topic', $s_watching_topic, $user->data['user_id'], $forum_id, $topic_id, $notify_status, $start, $topic_data['topic_title']);
  652.  
  653. // Reset forum notification if forum notify is set
  654. if ($config['allow_forum_notify'] && $auth->acl_get('f_subscribe', $forum_id))
  655. {
  656. $s_watching_forum = $s_watching_topic;
  657. watch_topic_forum('forum', $s_watching_forum, $user->data['user_id'], $forum_id, 0);
  658. }
  659. }
  660.  
  661.  
  662.  
  663. // Bookmarks
  664. if ($config['allow_bookmarks'] && $user->data['is_registered'] && request_var('bookmark', 0))
  665. {
  666. if (check_link_hash(request_var('hash', ''), "topic_$topic_id"))
  667. {
  668. if (!$topic_data['bookmarked'])
  669. {
  670. $sql = 'INSERT INTO ' . BOOKMARKS_TABLE . ' ' . $db->sql_build_array('INSERT', array(
  671. 'user_id' => $user->data['user_id'],
  672. 'topic_id' => $topic_id,
  673. ));
  674. $db->sql_query($sql);
  675. }
  676. else
  677. {
  678. $sql = 'DELETE FROM ' . BOOKMARKS_TABLE . "
  679. WHERE user_id = {$user->data['user_id']}
  680. AND topic_id = $topic_id";
  681. $db->sql_query($sql);
  682. }
  683. $message = (($topic_data['bookmarked']) ? $user->lang['BOOKMARK_REMOVED'] : $user->lang['BOOKMARK_ADDED']) . '<br /><br />' . sprintf($user->lang['RETURN_TOPIC'], '<a href="' . $viewtopic_url . '">', '</a>');
  684. }
  685. else
  686. {
  687. $message = $user->lang['BOOKMARK_ERR'] . '<br /><br />' . sprintf($user->lang['RETURN_TOPIC'], '<a href="' . $viewtopic_url . '">', '</a>');
  688. }
  689. meta_refresh(3, $viewtopic_url);
  690.  
  691.  
  692.  
  693. trigger_error($message);
  694. }
  695.  
  696.  
  697.  
  698. // Grab ranks
  699. $ranks = $cache->obtain_ranks();
  700.  
  701.  
  702.  
  703. // Grab icons
  704. $icons = $cache->obtain_icons();
  705.  
  706.  
  707.  
  708. // Grab extensions
  709. $extensions = array();
  710. if ($topic_data['topic_attachment'])
  711. {
  712. $extensions = $cache->obtain_attach_extensions($forum_id);
  713. }
  714.  
  715.  
  716.  
  717. // Forum rules listing
  718. $s_forum_rules = '';
  719. gen_forum_auth_level('topic', $forum_id, $topic_data['forum_status']);
  720.  
  721.  
  722.  
  723. // Quick mod tools
  724. $allow_change_type = ($auth->acl_get('m_', $forum_id) || ($user->data['is_registered'] && $user->data['user_id'] == $topic_data['topic_poster'])) ? true : false;
  725.  
  726.  
  727.  
  728. $topic_mod = '';
  729. $topic_mod .= ($auth->acl_get('m_lock', $forum_id) || ($auth->acl_get('f_user_lock', $forum_id) && $user->data['is_registered'] && $user->data['user_id'] == $topic_data['topic_poster'] && $topic_data['topic_status'] == ITEM_UNLOCKED)) ? (($topic_data['topic_status'] == ITEM_UNLOCKED) ? '<option value="lock">' . $user->lang['LOCK_TOPIC'] . '</option>' : '<option value="unlock">' . $user->lang['UNLOCK_TOPIC'] . '</option>') : '';
  730. $topic_mod .= ($auth->acl_get('m_delete', $forum_id)) ? '<option value="delete_topic">' . $user->lang['DELETE_TOPIC'] . '</option>' : '';
  731. $topic_mod .= ($auth->acl_get('m_move', $forum_id) && $topic_data['topic_status'] != ITEM_MOVED) ? '<option value="move">' . $user->lang['MOVE_TOPIC'] . '</option>' : '';
  732. $topic_mod .= ($auth->acl_get('m_split', $forum_id)) ? '<option value="split">' . $user->lang['SPLIT_TOPIC'] . '</option>' : '';
  733. $topic_mod .= ($auth->acl_get('m_merge', $forum_id)) ? '<option value="merge">' . $user->lang['MERGE_POSTS'] . '</option>' : '';
  734. $topic_mod .= ($auth->acl_get('m_merge', $forum_id)) ? '<option value="merge_topic">' . $user->lang['MERGE_TOPIC'] . '</option>' : '';
  735. $topic_mod .= ($auth->acl_get('m_move', $forum_id)) ? '<option value="fork">' . $user->lang['FORK_TOPIC'] . '</option>' : '';
  736. $topic_mod .= ($allow_change_type && $auth->acl_gets('f_sticky', 'f_announce', $forum_id) && $topic_data['topic_type'] != POST_NORMAL) ? '<option value="make_normal">' . $user->lang['MAKE_NORMAL'] . '</option>' : '';
  737. $topic_mod .= ($allow_change_type && $auth->acl_get('f_sticky', $forum_id) && $topic_data['topic_type'] != POST_STICKY) ? '<option value="make_sticky">' . $user->lang['MAKE_STICKY'] . '</option>' : '';
  738. $topic_mod .= ($allow_change_type && $auth->acl_get('f_announce', $forum_id) && $topic_data['topic_type'] != POST_ANNOUNCE) ? '<option value="make_announce">' . $user->lang['MAKE_ANNOUNCE'] . '</option>' : '';
  739. $topic_mod .= ($allow_change_type && $auth->acl_get('f_announce', $forum_id) && $topic_data['topic_type'] != POST_GLOBAL) ? '<option value="make_global">' . $user->lang['MAKE_GLOBAL'] . '</option>' : '';
  740. $topic_mod .= ($auth->acl_get('m_', $forum_id)) ? '<option value="topic_logs">' . $user->lang['VIEW_TOPIC_LOGS'] . '</option>' : '';
  741.  
  742.  
  743.  
  744. // If we've got a hightlight set pass it on to pagination.
  745. $pagination = generate_pagination(append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&amp;t=$topic_id" . ((strlen($u_sort_param)) ? "&amp;$u_sort_param" : '') . (($highlight_match) ? "&amp;hilit=$highlight" : '')), $total_posts, $config['posts_per_page'], $start);
  746.  
  747.  
  748.  
  749. // Navigation links
  750. generate_forum_nav($topic_data);
  751.  
  752.  
  753.  
  754. // Forum Rules
  755. generate_forum_rules($topic_data);
  756.  
  757.  
  758.  
  759. // Moderators
  760. $forum_moderators = array();
  761. if ($config['load_moderators'])
  762. {
  763. get_moderators($forum_moderators, $forum_id);
  764. }
  765.  
  766.  
  767.  
  768. // This is only used for print view so ...
  769. $server_path = (!$view) ? $phpbb_root_path : generate_board_url() . '/';
  770.  
  771.  
  772.  
  773. // Replace naughty words in title
  774. $topic_data['topic_title'] = censor_text($topic_data['topic_title']);
  775.  
  776.  
  777.  
  778. //Begin Thank Post MOD
  779.  
  780. $user->add_lang('mods/thanks');
  781.  
  782. //End Thank Post MOD
  783.  
  784. // Send vars to template
  785.  
  786. /**
  787. Prüfe, ob es hierzu Hoster gibt
  788. */
  789. $sql = $db->sql_query('SELECT id, megavideo_url, bitshare_url, filestage_url, divxstage_url, uploadc_url, videobb_url, putlocker_url, movshare_url, videoweed_url, novamov_url, sockshare_url, videozer_url, megavideo_url_comment, bitshare_url_comment, filestage_url_comment, divxstage_url_comment, uploadc_url_comment, videobb_url_comment, putlocker_url_comment, movshare_url_comment, videoweed_url_comment, novamov_url_comment, sockshare_url_comment, videozer_url_comment, megavideo_url_low, divxstage_url_low, uploadc_url_low, putlocker_url_low, movshare_url_low, videoweed_url_low, novamov_url_low, videozer_url_low, videobb_url_low, bitshare_url_low FROM ' . HOSTERBOXES_TABLE . " WHERE topic_id = '" . $topic_data['topic_id'] . "' AND (megavideo_url_comment != '' OR bitshare_url_comment != '' OR filestage_url_comment != '' OR divxstage_url_comment != '' OR uploadc_url_comment != '' OR videobb_url_comment != '' OR putlocker_url_comment != '' OR movshare_url_comment != '' OR videoweed_url_comment != '' OR novamov_url_comment != '' OR sockshare_url_comment != '' OR videozer_url_comment != '')");
  790.  
  791. $show_hosterbox = false;
  792. $show_megavideo = false;
  793. $show_bitshare = false;
  794. $show_filestage = false;
  795. $show_divxstage = false;
  796. $show_uploadc = false;
  797. $show_videobb = false;
  798. $show_putlocker = false;
  799. $show_movshare = false;
  800. $show_videoweed = false;
  801. $show_novamov = false;
  802. $show_sockshare = false;
  803. $show_videozer = false;
  804.  
  805. $megavideo_parts = false;
  806. $bitshare_parts = false;
  807. $filestage_parts = false;
  808. $divxstage_parts = false;
  809. $uploadc_parts = false;
  810. $videobb_parts = false;
  811. $putlocker_parts = false;
  812. $movshare_parts = false;
  813. $videoweed_parts = false;
  814. $novamov_parts = false;
  815. $sockshare_parts = false;
  816. $videozer_parts = false;
  817.  
  818. $megavideo_videos = NULL;
  819. $bitshare_videos = NULL;
  820. $filestage_videos = NULL;
  821. $divxstage_videos = NULL;
  822. $uploadc_videos = NULL;
  823. $videobb_videos = NULL;
  824. $putlocker_videos = NULL;
  825. $movshare_videos = NULL;
  826. $videoweed_videos = NULL;
  827. $novamov_videos = NULL;
  828. $sockshare_videos = NULL;
  829. $videozer_videos = NULL;
  830.  
  831. $megavideo_firstlink = NULL;
  832. $bitshare_firstlink = NULL;
  833. $filestage_firstlink = NULL;
  834. $divxstage_firstlink = NULL;
  835. $uploadc_firstlink = NULL;
  836. $videobb_firstlink = NULL;
  837. $putlocker_firstlink = NULL;
  838. $movshare_firstlink = NULL;
  839. $videoweed_firstlink = NULL;
  840. $novamov_firstlink = NULL;
  841. $sockshare_firstlink = NULL;
  842. $videozer_firstlink = NULL;
  843.  
  844. $video_comments_available = true;
  845. $video_comments_low_available = true;
  846.  
  847. $break = array(
  848. 'mv' => NULL,
  849. 'bs' => NULL,
  850. 'fs' => NULL,
  851. 'vbb' => NULL,
  852. 'sts' => NULL,
  853. 'ds' => NULL,
  854. 'pl' => NULL,
  855. 'ms' => NULL,
  856. 'vw' => NULL,
  857. 'nm' => NULL,
  858. 'ss' => NULL,
  859. 'vz' => NULL
  860. );
  861. if ($_SID)
  862. {
  863. $s_search_hidden_fields['sid'] = $_SID;
  864. }
  865.  
  866. if (!empty($_EXTRA_URL))
  867. {
  868. foreach ($_EXTRA_URL as $url_param)
  869. {
  870. $url_param = explode('=', $url_param, 2);
  871. $s_hidden_fields[$url_param[0]] = $url_param[1];
  872. }
  873. }
  874.  
  875. if (!empty($_EXTRA_URL))
  876. {
  877. foreach ($_EXTRA_URL as $url_param)
  878. {
  879. $url_param = explode('=', $url_param, 2);
  880. $s_hidden_fields[$url_param[0]] = $url_param[1];
  881. }
  882. }
  883.  
  884. if (!empty($_EXTRA_URL))
  885. {
  886. foreach ($_EXTRA_URL as $url_param)
  887. {
  888. $url_param = explode('=', $url_param, 2);
  889. $s_hidden_fields[$url_param[0]] = $url_param[1];
  890. }
  891. }
  892.  
  893. $lastVideo = NULL;
  894.  
  895. $get_video_type = $_GET['videoType'];
  896.  
  897. switch ($get_video_type) {
  898. case '':
  899. $video_mode = '_comment';
  900. $video_mode_boolean = true;
  901. break;
  902. case 'no_comments':
  903. $video_mode = NULL;
  904. $video_mode_boolean = false;
  905. break;
  906. case 'low':
  907. $video_mode = '_low';
  908. $video_mode_boolean = false;
  909. break;
  910. }
  911.  
  912.  
  913. $min1Part = false;
  914. $videoButtons = array();
  915.  
  916. $partButtonsScript = '<script type="text/javascript">
  917. function unpressPartButtons() {';
  918.  
  919. if ($db->sql_num_rows($sql) != 0) {
  920. $show_hosterbox = true;
  921.  
  922. /**
  923. Daten abfragen
  924. */
  925. $row = $db->sql_fetchrow($sql);
  926.  
  927. /**
  928. Wenn es keine Kommentare gibt, den Umschalter ausschalten
  929. */
  930. if (empty($row['megavideo_url']) && empty($row['videobb_url']) && empty($row['putlocker_url']) && empty($row['novamov_url']) && empty($row['divxstage_url'])) {
  931. $video_comments_available = false;
  932. }
  933.  
  934. /**
  935. Wenn es keine LOW Kommentare gibt, den Umschalter ausschalten
  936. */
  937. if (empty($row['megavideo_url_low']) && empty($row['bitshare_url_low']) && empty($row['videoweed_url_low']) && empty($row['videobb_url_low']) && empty($row['divxstage_url_low'])) {
  938. $video_comments_low_available = false;
  939. }
  940.  
  941. $hosters = 0;
  942.  
  943. /**
  944. Links
  945. */
  946. if (!empty($row['megavideo_url' . $video_mode])) {
  947. $megavideo_urls = explode("\n", $row['megavideo_url' . $video_mode] . "\n");
  948.  
  949. $num = 1;
  950.  
  951. $thisVideoButton = NULL;
  952.  
  953. for ($i = 0; $i < count($megavideo_urls); $i++) {
  954.  
  955. if ($num > 2) {
  956. $megavideo_parts = true;
  957. }
  958.  
  959. /**
  960. Link umwandeln
  961. */
  962. $value = trim($megavideo_urls[$i]);
  963.  
  964. if (!empty($value)) {
  965.  
  966. $value = explode('=', $value);
  967. $value = 'http://www.megavideo.com/v/' . $value[1];
  968.  
  969. /**
  970. Den Button hinzufügen
  971. */
  972. if ($num == 1) {
  973. $thisVideoButton .= '<div class="box megavideo" onmouseover="javascript:buttonPress(this.id); unpressPartButtons();" onmouseout="javascript:buttonUnpress(this.id);" id="megavideoButton">
  974.  
  975. <h3 onclick="javascript:showVideo(\'megavideo\', \'' . $value . '\'); unpressPartButtons();">Megavideo</h3>
  976.  
  977. <div class="partVideos">';
  978. }
  979.  
  980. if (count($megavideo_urls) > 2) {
  981. $thisVideoButton .= '<input type="button" id="mv_part_' . $num . '" onfocus="javascript:this.blur();" onmouseover="javascript:buttonPress(this.id);" onmouseout="javascript:buttonUnpress(this.id);" onclick="javascript:showVideo(\'megavideo\', \'' . $value . '\'); unpressPartButtons(); buttonPress(this.id); this.onmouseout=\'\';" value="' . $num . '" />';
  982.  
  983. $min1Part = true;
  984.  
  985. $partButtonsScript .= 'buttonUnpress(\'mv_part_' . $num . '\');';
  986. }
  987.  
  988. if ($num == (count($megavideo_urls) - 1)) {
  989. $thisVideoButton .= '</div></div>';
  990.  
  991. $videoButtons[] = $thisVideoButton;
  992. }
  993.  
  994. /**
  995. Den ersten Link speichern
  996. */
  997. if ($num == 1) {
  998. $megavideo_firstlink = $value;
  999. }
  1000.  
  1001. $num++;
  1002. }
  1003.  
  1004. }
  1005.  
  1006. $hosters++;
  1007. $show_megavideo = true;
  1008. $lastVideo = 'mv';
  1009. }
  1010.  
  1011.  
  1012. /**
  1013. Links
  1014. */
  1015. if (!empty($row['videobb_url' . $video_mode])) {
  1016. $videobb_urls = explode("\n", $row['videobb_url' . $video_mode] . "\n");
  1017.  
  1018. $num = 1;
  1019.  
  1020. $thisVideoButton = NULL;
  1021.  
  1022. for ($i = 0; $i < count($videobb_urls); $i++) {
  1023.  
  1024. if ($num > 2) {
  1025. $videobb_parts = true;
  1026. }
  1027.  
  1028. /**
  1029. Link umwandeln
  1030. */
  1031. $value = trim($videobb_urls[$i]);
  1032.  
  1033. if (!empty($value)) {
  1034.  
  1035. $value = explode('/video/', $value);
  1036. $value = 'http://videobb.com/e/' . $value[1];
  1037.  
  1038. /**
  1039. Den Button hinzufügen
  1040. */
  1041. if ($num == 1) {
  1042. $thisVideoButton .= '<div class="box videobb" onmouseover="javascript:buttonPress(this.id);" onmouseout="javascript:buttonUnpress(this.id);" id="videobbButton" style="margin-right: 10px;">
  1043.  
  1044. <h3 onclick="javascript:showVideo(\'videobb\', \'' . $value . '\'); unpressPartButtons();">Videobb</h3>
  1045.  
  1046. <div class="partVideos">';
  1047. }
  1048.  
  1049. if (count($videobb_urls) > 2) {
  1050. $thisVideoButton .= '<input type="button" id="vbb_part_' . $num . '" onfocus="javascript:this.blur();" onmouseover="javascript:buttonPress(this.id);" onmouseout="javascript:buttonUnpress(this.id);" onclick="javascript:showVideo(\'videobb\', \'' . $value . '\'); unpressPartButtons(); buttonPress(this.id); this.onmouseout=\'\';" value="' . $num . '" />';
  1051.  
  1052. $min1Part = true;
  1053.  
  1054. $partButtonsScript .= 'buttonUnpress(\'vbb_part_' . $num . '\');';
  1055. }
  1056.  
  1057. if ($num == (count($videobb_urls) - 1)) {
  1058. $thisVideoButton .= '</div></div>';
  1059.  
  1060. $videoButtons[] = $thisVideoButton;
  1061. }
  1062.  
  1063. /**
  1064. Den ersten Link speichern
  1065. */
  1066. if ($num == 1) {
  1067. $videobb_firstlink = $value;
  1068. }
  1069.  
  1070. $num++;
  1071. }
  1072.  
  1073. }
  1074.  
  1075.  
  1076. $hosters++;
  1077. $show_videobb = true;
  1078. $lastVideo = 'vbb';
  1079. }
  1080.  
  1081.  
  1082. /**
  1083. Links
  1084. */
  1085. if (!empty($row['putlocker_url' . $video_mode])) {
  1086. $putlocker_urls = explode("\n", $row['putlocker_url' . $video_mode] . "\n");
  1087.  
  1088. $num = 1;
  1089.  
  1090. $thisVideoButton = NULL;
  1091.  
  1092. for ($i = 0; $i < count($putlocker_urls); $i++) {
  1093.  
  1094. if ($num > 2) {
  1095. $putlocker_parts = true;
  1096. }
  1097.  
  1098. /**
  1099. Link umwandeln
  1100. */
  1101. $value = trim($putlocker_urls[$i]);
  1102.  
  1103. if (!empty($value)) {
  1104.  
  1105. $value = explode('/file/', $value);
  1106. $value = 'http://www.putlocker.com/embed/' . $value[1];
  1107.  
  1108. /**
  1109. Den Button hinzufügen
  1110. */
  1111. if ($num == 1) {
  1112. $thisVideoButton .= '<div class="box putlocker" onmouseover="javascript:buttonPress(this.id);" onmouseout="javascript:buttonUnpress(this.id);" id="putlockerButton" style="margin-right: 10px;">
  1113.  
  1114. <h3 onclick="javascript:showVideo(\'putlocker\', \'' . $value . '\'); unpressPartButtons();">Putlocker</h3>
  1115.  
  1116. <div class="partVideos">';
  1117. }
  1118.  
  1119. if (count($putlocker_urls) > 2) {
  1120. $thisVideoButton .= '<input type="button" id="pl_part_' . $num . '" onfocus="javascript:this.blur();" onmouseover="javascript:buttonPress(this.id);" onmouseout="javascript:buttonUnpress(this.id);" onclick="javascript:showVideo(\'putlocker\', \'' . $value . '\'); unpressPartButtons(); buttonPress(this.id); this.onmouseout=\'\';" value="' . $num . '" />';
  1121.  
  1122. $min1Part = true;
  1123.  
  1124. $partButtonsScript .= 'buttonUnpress(\'pl_part_' . $num . '\');';
  1125. }
  1126.  
  1127. if ($num == (count($putlocker_urls) - 1)) {
  1128. $thisVideoButton .= '</div></div>';
  1129.  
  1130. $videoButtons[] = $thisVideoButton;
  1131. }
  1132.  
  1133. /**
  1134. Den ersten Link speichern
  1135. */
  1136. if ($num == 1) {
  1137. $putlocker_firstlink = $value;
  1138. }
  1139.  
  1140. $num++;
  1141. }
  1142.  
  1143. }
  1144.  
  1145. $hosters++;
  1146. $show_putlocker = true;
  1147. $lastVideo = 'pl';
  1148. }
  1149.  
  1150. /**
  1151. Links
  1152. */
  1153. if (!empty($row['movshare_url' . $video_mode])) {
  1154. $movshare_urls = explode("\n", $row['movshare_url' . $video_mode] . "\n");
  1155.  
  1156. $num = 1;
  1157.  
  1158. $thisVideoButton = NULL;
  1159.  
  1160. for ($i = 0; $i < count($movshare_urls); $i++) {
  1161.  
  1162. if ($num > 2) {
  1163. $movshare_parts = true;
  1164. }
  1165.  
  1166. /**
  1167. Link umwandeln
  1168. */
  1169. $value = trim($movshare_urls[$i]);
  1170.  
  1171. if (!empty($value)) {
  1172.  
  1173. $value = explode('/video/', $value);
  1174. $value = 'http://embed.movshare.net/embed.php?v=' . $value[1];
  1175.  
  1176. /**
  1177. Den Button hinzufügen
  1178. */
  1179. if ($num == 1) {
  1180. $thisVideoButton .= '<div class="box movshare" onmouseover="javascript:buttonPress(this.id);" onmouseout="javascript:buttonUnpress(this.id);" id="movshareButton" style="margin-right: 10px;">
  1181.  
  1182. <h3 onclick="javascript:showVideo(\'movshare\', \'' . $value . '\'); unpressPartButtons();">Movshare (Divx)</h3>
  1183.  
  1184. <div class="partVideos">';
  1185. }
  1186.  
  1187. if (count($movshare_urls) > 2) {
  1188. $thisVideoButton .= '<input type="button" id="ms_part_' . $num . '" onfocus="javascript:this.blur();" onmouseover="javascript:buttonPress(this.id);" onmouseout="javascript:buttonUnpress(this.id);" onclick="javascript:showVideo(\'movshare\', \'' . $value . '\'); unpressPartButtons(); buttonPress(this.id); this.onmouseout=\'\';" value="' . $num . '" />';
  1189.  
  1190. $min1Part = true;
  1191.  
  1192. $partButtonsScript .= 'buttonUnpress(\'ms_part_' . $num . '\');';
  1193. }
  1194.  
  1195. if ($num == (count($movshare_urls) - 1)) {
  1196. $thisVideoButton .= '</div></div>';
  1197.  
  1198. $videoButtons[] = $thisVideoButton;
  1199. }
  1200.  
  1201. /**
  1202. Den ersten Link speichern
  1203. */
  1204. if ($num == 1) {
  1205. $movshare_firstlink = $value;
  1206. }
  1207.  
  1208. $num++;
  1209. }
  1210.  
  1211. }
  1212.  
  1213. $hosters++;
  1214. $show_movshare = true;
  1215. $lastVideo = 'ms';
  1216. }
  1217.  
  1218. /**
  1219. Links
  1220. */
  1221. if (!empty($row['divxstage_url' . $video_mode])) {
  1222. $divxstage_urls = explode("\n", $row['divxstage_url' . $video_mode] . "\n");
  1223.  
  1224. $num = 1;
  1225.  
  1226. $thisVideoButton = NULL;
  1227.  
  1228. for ($i = 0; $i < count($divxstage_urls); $i++) {
  1229.  
  1230. if ($num > 2) {
  1231. $divxstage_parts = true;
  1232. }
  1233.  
  1234. /**
  1235. Link umwandeln
  1236. */
  1237. $value = trim($divxstage_urls[$i]);
  1238.  
  1239. if (!empty($value)) {
  1240.  
  1241. $value = explode('/video/', $value);
  1242. $value = 'http://embed.divxstage.eu/embed.php?v=' . $value[1];
  1243.  
  1244. /**
  1245. Den Button hinzufügen
  1246. */
  1247. if ($num == 1) {
  1248. $thisVideoButton .= '<div class="box divxstage" onmouseover="javascript:buttonPress(this.id);" onmouseout="javascript:buttonUnpress(this.id);" id="divxstageButton" style="margin-right: 10px;">
  1249.  
  1250. <h3 onclick="javascript:showVideo(\'divxstage\', \'' . $value . '\'); unpressPartButtons();">Divxstage (Divx)</h3>
  1251.  
  1252. <div class="partVideos">';
  1253. }
  1254.  
  1255. if (count($divxstage_urls) > 2) {
  1256. $thisVideoButton .= '<input type="button" id="ds_part_' . $num . '" onfocus="javascript:this.blur();" onmouseover="javascript:buttonPress(this.id);" onmouseout="javascript:buttonUnpress(this.id);" onclick="javascript:showVideo(\'divxstage\', \'' . $value . '\'); unpressPartButtons(); buttonPress(this.id); this.onmouseout=\'\';" value="' . $num . '" />';
  1257.  
  1258. $min1Part = true;
  1259.  
  1260. $partButtonsScript .= 'buttonUnpress(\'ds_part_' . $num . '\');';
  1261. }
  1262.  
  1263. if ($num == (count($divxstage_urls) - 1)) {
  1264. $thisVideoButton .= '</div></div>';
  1265.  
  1266. $videoButtons[] = $thisVideoButton;
  1267. }
  1268.  
  1269. /**
  1270. Den ersten Link speichern
  1271. */
  1272. if ($num == 1) {
  1273. $divxstage_firstlink = $value;
  1274. }
  1275.  
  1276. $num++;
  1277. }
  1278.  
  1279. }
  1280.  
  1281. $hosters++;
  1282. $show_divxstage = true;
  1283. $lastVideo = 'ds';
  1284. }
  1285.  
  1286.  
  1287. /**
  1288. Links
  1289. */
  1290. if (!empty($row['uploadc_url' . $video_mode])) {
  1291. $uploadc_urls = explode("\n", $row['uploadc_url' . $video_mode] . "\n");
  1292.  
  1293. $num = 1;
  1294.  
  1295. $thisVideoButton = NULL;
  1296.  
  1297. for ($i = 0; $i < count($uploadc_urls); $i++) {
  1298.  
  1299. if ($num > 2) {
  1300. $uploadc_parts = true;
  1301. }
  1302. /**
  1303. Link umwandeln
  1304. */
  1305. $value = trim($uploadc_urls[$i]);
  1306.  
  1307. if (!empty($value)) {
  1308.  
  1309. $value = explode('http://www.uploadc.com/', $value);
  1310. $value = explode('/', $value[1]);
  1311. $value = 'http://www.uploadc.com/embed-' . $value[0] . '.html';
  1312.  
  1313. /**
  1314. Den Button hinzufügen
  1315. */
  1316. if ($num == 1) {
  1317. $thisVideoButton .= '<div class="box uploadc" onmouseover="javascript:buttonPress(this.id);" onmouseout="javascript:buttonUnpress(this.id);" id="uploadcButton" style="margin-right: 10px;">
  1318.  
  1319. <h3 onclick="javascript:showVideo(\'uploadc\', \'' . $value . '\'); unpressPartButtons();">UploadC (Divx)</h3>
  1320.  
  1321. <div class="partVideos">';
  1322. }
  1323.  
  1324. if (count($uploadc_urls) > 2) {
  1325. $thisVideoButton .= '<input type="button" id="sts_part_' . $num . '" onfocus="javascript:this.blur();" onmouseover="javascript:buttonPress(this.id);" onmouseout="javascript:buttonUnpress(this.id);" onclick="javascript:showVideo(\'uploadc\', \'' . $value . '\'); unpressPartButtons(); buttonPress(this.id); this.onmouseout=\'\';" value="' . $num . '" />';
  1326.  
  1327. $min1Part = true;
  1328.  
  1329. $partButtonsScript .= 'buttonUnpress(\'sts_part_' . $num . '\');';
  1330. }
  1331.  
  1332. if ($num == (count($uploadc_urls) - 1)) {
  1333. $thisVideoButton .= '</div></div>';
  1334.  
  1335. $videoButtons[] = $thisVideoButton;
  1336. }
  1337.  
  1338. /**
  1339. Den ersten Link speichern
  1340. */
  1341. if ($num == 1) {
  1342. $uploadc_firstlink = $value;
  1343. }
  1344.  
  1345. $num++;
  1346. }
  1347.  
  1348. }
  1349.  
  1350. $hosters++;
  1351. $show_videobb = true;
  1352. $lastVideo = 'sts';
  1353. }
  1354.  
  1355. /**
  1356. Links
  1357. */
  1358. if (!empty($row['videoweed_url' . $video_mode])) {
  1359. $videoweed_urls = explode("\n", $row['videoweed_url' . $video_mode] . "\n");
  1360.  
  1361. $num = 1;
  1362.  
  1363. $thisVideoButton = NULL;
  1364.  
  1365. for ($i = 0; $i < count($videoweed_urls); $i++) {
  1366.  
  1367. if ($num > 2) {
  1368. $videoweed_parts = true;
  1369. }
  1370.  
  1371. /**
  1372. Link umwandeln
  1373. */
  1374. $value = trim($videoweed_urls[$i]);
  1375.  
  1376. if (!empty($value)) {
  1377.  
  1378. $value = explode('/file/', $value);
  1379. $value = 'http://embed.videoweed.com/embed.php?v=' . $value[1];
  1380.  
  1381. /**
  1382. Den Button hinzufügen
  1383. */
  1384. if ($num == 1) {
  1385. $thisVideoButton .= '<div class="box videoweed" onmouseover="javascript:buttonPress(this.id);" onmouseout="javascript:buttonUnpress(this.id);" id="videoweedButton" style="margin-right: 10px;">
  1386.  
  1387. <h3 onclick="javascript:showVideo(\'videoweed\', \'' . $value . '\'); unpressPartButtons();">Videoweed</h3>
  1388.  
  1389. <div class="partVideos">';
  1390. }
  1391.  
  1392. if (count($videoweed_urls) > 2) {
  1393. $thisVideoButton .= '<input type="button" id="vw_part_' . $num . '" onfocus="javascript:this.blur();" onmouseover="javascript:buttonPress(this.id);" onmouseout="javascript:buttonUnpress(this.id);" onclick="javascript:showVideo(\'videoweed\', \'' . $value . '\'); unpressPartButtons(); buttonPress(this.id); this.onmouseout=\'\';" value="' . $num . '" />';
  1394.  
  1395. $min1Part = true;
  1396.  
  1397. $partButtonsScript .= 'buttonUnpress(\'vw_part_' . $num . '\');';
  1398. }
  1399.  
  1400. if ($num == (count($videoweed_urls) - 1)) {
  1401. $thisVideoButton .= '</div></div>';
  1402.  
  1403. $videoButtons[] = $thisVideoButton;
  1404. }
  1405.  
  1406. /**
  1407. Den ersten Link speichern
  1408. */
  1409. if ($num == 1) {
  1410. $videoweed_firstlink = $value;
  1411. }
  1412.  
  1413. $num++;
  1414. }
  1415.  
  1416. }
  1417.  
  1418. $hosters++;
  1419. $show_videoweed = true;
  1420. $lastVideo = 'vw';
  1421. }
  1422.  
  1423. /**
  1424. Links
  1425. */
  1426. if (!empty($row['novamov_url' . $video_mode])) {
  1427. $novamov_urls = explode("\n", $row['novamov_url' . $video_mode] . "\n");
  1428.  
  1429. $num = 1;
  1430.  
  1431. $thisVideoButton = NULL;
  1432.  
  1433. for ($i = 0; $i < count($novamov_urls); $i++) {
  1434.  
  1435. if ($num > 2) {
  1436. $novamov_parts = true;
  1437. }
  1438.  
  1439. /**
  1440. Link umwandeln
  1441. */
  1442. $value = trim($novamov_urls[$i]);
  1443.  
  1444. if (!empty($value)) {
  1445.  
  1446. $value = explode('/video/', $value);
  1447. $value = 'http://embed.novamov.com/embed.php?width=800&height=430&v=' . $value[1];
  1448.  
  1449. /**
  1450. Den Button hinzufügen
  1451. */
  1452. if ($num == 1) {
  1453. $thisVideoButton .= '<div class="box novamov" onmouseover="javascript:buttonPress(this.id);" onmouseout="javascript:buttonUnpress(this.id);" id="novamovButton" style="margin-right: 10px;">
  1454.  
  1455. <h3 onclick="javascript:showVideo(\'novamov\', \'' . $value . '\'); unpressPartButtons();">Novamov</h3>
  1456.  
  1457. <div class="partVideos">';
  1458. }
  1459.  
  1460. if (count($novamov_urls) > 2) {
  1461. $thisVideoButton .= '<input type="button" id="nm_part_' . $num . '" onfocus="javascript:this.blur();" onmouseover="javascript:buttonPress(this.id);" onmouseout="javascript:buttonUnpress(this.id);" onclick="javascript:showVideo(\'novamov\', \'' . $value . '\'); unpressPartButtons(); buttonPress(this.id); this.onmouseout=\'\';" value="' . $num . '" />';
  1462.  
  1463. $min1Part = true;
  1464.  
  1465. $partButtonsScript .= 'buttonUnpress(\'nm_part_' . $num . '\');';
  1466. }
  1467.  
  1468. if ($num == (count($novamov_urls) - 1)) {
  1469. $thisVideoButton .= '</div></div>';
  1470.  
  1471. $videoButtons[] = $thisVideoButton;
  1472. }
  1473.  
  1474. /**
  1475. Den ersten Link speichern
  1476. */
  1477. if ($num == 1) {
  1478. $novamov_firstlink = $value;
  1479. }
  1480.  
  1481. $num++;
  1482. }
  1483.  
  1484. }
  1485.  
  1486. $hosters++;
  1487. $show_novamov = true;
  1488. $lastVideo = 'nm';
  1489. }
  1490.  
  1491. /**
  1492. Links
  1493. */
  1494. if (!empty($row['videozer_url' . $video_mode])) {
  1495. $videozer_urls = explode("\n", $row['videozer_url' . $video_mode] . "\n");
  1496.  
  1497. $num = 1;
  1498.  
  1499. $thisVideoButton = NULL;
  1500.  
  1501. for ($i = 0; $i < count($videozer_urls); $i++) {
  1502.  
  1503. if ($num > 2) {
  1504. $videozer_parts = true;
  1505. }
  1506.  
  1507. /**
  1508. Link umwandeln
  1509. */
  1510. $value = trim($videozer_urls[$i]);
  1511.  
  1512. if (!empty($value)) {
  1513.  
  1514. $value = explode('/video/', $value);
  1515. $value = 'http://www.videozer.com/embed/' . $value[1];
  1516.  
  1517. /**
  1518. Den Button hinzufügen
  1519. */
  1520. if ($num == 1) {
  1521. $thisVideoButton .= '<div class="box videozer" onmouseover="javascript:buttonPress(this.id);" onmouseout="javascript:buttonUnpress(this.id);" id="videozerButton" style="margin-right: 10px;">
  1522.  
  1523. <h3 onclick="javascript:showVideo(\'videozer\', \'' . $value . '\'); unpressPartButtons();">Videozer</h3>
  1524.  
  1525. <div class="partVideos">';
  1526. }
  1527.  
  1528. if (count($videozer_urls) > 2) {
  1529. $thisVideoButton .= '<input type="button" id="vz_part_' . $num . '" onfocus="javascript:this.blur();" onmouseover="javascript:buttonPress(this.id);" onmouseout="javascript:buttonUnpress(this.id);" onclick="javascript:showVideo(\'videozer\', \'' . $value . '\'); unpressPartButtons(); buttonPress(this.id); this.onmouseout=\'\';" value="' . $num . '" />';
  1530.  
  1531. $min1Part = true;
  1532.  
  1533. $partButtonsScript .= 'buttonUnpress(\'vz_part_' . $num . '\');';
  1534. }
  1535.  
  1536. if ($num == (count($videozer_urls) - 1)) {
  1537. $thisVideoButton .= '</div></div>';
  1538.  
  1539. $videoButtons[] = $thisVideoButton;
  1540. }
  1541.  
  1542. /**
  1543. Den ersten Link speichern
  1544. */
  1545. if ($num == 1) {
  1546. $videozer_firstlink = $value;
  1547. }
  1548.  
  1549. $num++;
  1550. }
  1551.  
  1552. }
  1553.  
  1554. $hosters++;
  1555. $show_videozer = true;
  1556. $lastVideo = 'vz';
  1557. }
  1558.  
  1559. /**
  1560. Links
  1561. */
  1562. if (!empty($row['bitshare_url' . $video_mode])) {
  1563. $bitshare_urls = explode("\n", $row['bitshare_url' . $video_mode] . "\n");
  1564.  
  1565. $num = 1;
  1566.  
  1567. $thisVideoButton = NULL;
  1568.  
  1569. for ($i = 0; $i < count($bitshare_urls); $i++) {
  1570.  
  1571. if ($num > 2) {
  1572. $bitshare_parts = true;
  1573. }
  1574.  
  1575. /**
  1576. Link umwandeln
  1577. */
  1578. $value = trim($bitshare_urls[$i]);
  1579.  
  1580. if (!empty($value)) {
  1581.  
  1582. /**
  1583. Den Button hinzufügen
  1584. */
  1585. if ($num == 1) {
  1586. $thisVideoButton .= '<div class="box bitshare" onmouseover="javascript:buttonPress(this.id);" onmouseout="javascript:buttonUnpress(this.id);" id="bitshareButton" style="margin-right: 10px;">
  1587.  
  1588. <h3 onclick="javascript:showVideo(\'bitshare\', \'' . $value . '\'); unpressPartButtons();">Bitshare</h3>
  1589.  
  1590. <div class="partVideos">';
  1591. }
  1592.  
  1593. if (count($bitshare_urls) > 2) {
  1594. $thisVideoButton .= '<input type="button" id="bs_part_' . $num . '" onfocus="javascript:this.blur();" onmouseover="javascript:buttonPress(this.id);" onmouseout="javascript:buttonUnpress(this.id);" onclick="javascript:showVideo(\'bitshare\', \'' . $value . '\'); unpressPartButtons(); buttonPress(this.id); this.onmouseout=\'\';" value="' . $num . '" />';
  1595.  
  1596. $min1Part = true;
  1597.  
  1598. $partButtonsScript .= 'buttonUnpress(\'bs_part_' . $num . '\');';
  1599. }
  1600.  
  1601. if ($num == (count($bitshare_urls) - 1)) {
  1602. $thisVideoButton .= '</div></div>';
  1603.  
  1604. $videoButtons[] = $thisVideoButton;
  1605. }
  1606.  
  1607. /**
  1608. Den ersten Link speichern
  1609. */
  1610. if ($num == 1) {
  1611. $bitshare_firstlink = $value;
  1612. }
  1613.  
  1614. $num++;
  1615. }
  1616.  
  1617. }
  1618.  
  1619.  
  1620. $hosters++;
  1621. $show_bitshare = true;
  1622. $lastVideo = 'bs';
  1623. }
  1624.  
  1625. }
  1626.  
  1627. $videoButtonsData = NULL;
  1628.  
  1629. for ($i = 0; $i < count($videoButtons); $i++) {
  1630.  
  1631. $videoButtonsData .= $videoButtons[$i];
  1632.  
  1633. if (($i+1) % 5 == 0 && $i != 0 && count($videoButtons) > 5) {
  1634. $videoButtonsData .= '<div style="clear: both;"></div><div style="padding-top: 40px;"></div>';
  1635. }
  1636.  
  1637. }
  1638.  
  1639. if ($min1Part == true) {
  1640. $videoButtonsData .= '<div style="clear: both;"></div><div style="padding-top: 30px;"></div>';
  1641. }
  1642.  
  1643. $partButtonsScript .= '}
  1644. </script>';
  1645.  
  1646. $template->assign_vars(array(
  1647.  
  1648. 'VIDEO_BUTTONS' => $videoButtonsData,
  1649. 'PBJS' => $partButtonsScript,
  1650.  
  1651. 'SHOW_HOSTERBOX' => $show_hosterbox,
  1652. 'SHOW_HOSTERBOX2' => ($hosters > 3) ? true : false,
  1653. 'SHOW_MEGAVIDEO' => $show_megavideo,
  1654. 'SHOW_BITSHARE' => $show_bitshare,
  1655. 'SHOW_FILESTAGE' => $show_filestage,
  1656. 'SHOW_DIVXSTAGE' => $show_divxstage,
  1657. 'SHOW_UPLOADC' => $show_uploadc,
  1658. 'SHOW_VIDEOBB' => $show_videobb,
  1659. 'SHOW_PUTLOCKER' => $show_putlocker,
  1660. 'SHOW_MOVSHARE' => $show_movshare,
  1661. 'SHOW_VIDEOWEED' => $show_videoweed,
  1662. 'SHOW_NOVAMOV' => $show_novamov,
  1663. 'SHOW_SOCKSHARE' => $show_sockshare,
  1664. 'SHOW_VIDEOZER' => $show_videozer,
  1665.  
  1666. 'MEGAVIDEO_VIDEOS' => $megavideo_videos,
  1667. 'BITSHARE_VIDEOS' => $bitshare_videos,
  1668. 'FILESTAGE_VIDEOS' => $filestage_videos,
  1669. 'DIVXSTAGE_VIDEOS' => $divxstage_videos,
  1670. 'UPLOADC_VIDEOS' => $uploadc_videos,
  1671. 'VIDEOBB_VIDEOS' => $videobb_videos,
  1672. 'PUTLOCKER_VIDEOS' => $putlocker_videos,
  1673. 'MOVSHARE_VIDEOS' => $movshare_videos,
  1674. 'VIDEOWEED_VIDEOS' => $videoweed_videos,
  1675. 'NOVAMOV_VIDEOS' => $novamov_videos,
  1676. 'SOCKSHARE_VIDEOS' => $sockshare_videos,
  1677. 'VIDEOZER_VIDEOS' => $videozer_videos,
  1678.  
  1679. 'MEGAVIDEO_PARTS' => $megavideo_parts,
  1680. 'BITSHARE_PARTS' => $bitshare_parts,
  1681. 'FILESTAGE_PARTS' => $filestage_parts,
  1682. 'DIVXSTAGE_PARTS' => $divxstage_parts,
  1683. 'UPLOADC_PARTS' => $uploadc_parts,
  1684. 'VIDEOBB_PARTS' => $videobb_parts,
  1685. 'PUTLOCKER_PARTS' => $putlocker_parts,
  1686. 'MOVSHARE_PARTS' => $movshare_parts,
  1687. 'VIDEOWEED_PARTS' => $videoweed_parts,
  1688. 'NOVAMOV_PARTS' => $novamov_parts,
  1689. 'SOCKSHARE_PARTS' => $sockshare_parts,
  1690. 'VIDEOZER_PARTS' => $videozer_parts,
  1691.  
  1692. 'MEGAVIDEO_FIRSTLINK' => $megavideo_firstlink,
  1693. 'BITSHARE_FIRSTLINK' => $bitshare_firstlink,
  1694. 'FILESTAGE_FIRSTLINK' => $filestage_firstlink,
  1695. 'DIVXSTAGE_FIRSTLINK' => $divxstage_firstlink,
  1696. 'UPLOADC_FIRSTLINK' => $uploadc_firstlink,
  1697. 'VIDEOBB_FIRSTLINK' => $videobb_firstlink,
  1698. 'PUTLOCKER_FIRSTLINK' => $putlocker_firstlink,
  1699. 'MOVSHARE_FIRSTLINK' => $movshare_firstlink,
  1700. 'VIDEOWEED_FIRSTLINK' => $videoweed_firstlink,
  1701. 'NOVAMOV_FIRSTLINK' => $novamov_firstlink,
  1702. 'SOCKSHARE_FIRSTLINK' => $sockshare_firstlink,
  1703. 'VIDEOZER_FIRSTLINK' => $videozer_firstlink,
  1704.  
  1705. 'VIDEO_MODE' => $video_mode_boolean,
  1706. 'VIDEO_COMMENTS_AVAILABLE' => $video_comments_available,
  1707. 'VIDEO_COMMENTS_LOW_AVAILABLE' => $video_comments_low_available,
  1708.  
  1709. // Facebook Like button MOD
  1710. 'U_FB' => urlencode(generate_board_url() . "/viewtopic.$phpEx?f=$forum_id&t=$topic_id"),
  1711. // Facebook Like button MOD
  1712.  
  1713. 'FORUM_ID' => $forum_id,
  1714. 'FORUM_NAME' => $topic_data['forum_name'],
  1715. 'FORUM_DESC' => generate_text_for_display($topic_data['forum_desc'], $topic_data['forum_desc_uid'], $topic_data['forum_desc_bitfield'], $topic_data['forum_desc_options']),
  1716. 'TOPIC_ID' => $topic_id,
  1717. 'TOPIC_TITLE' => $topic_data['topic_title'],
  1718. 'TOPIC_POSTER' => $topic_data['topic_poster'],
  1719.  
  1720.  
  1721.  
  1722. 'TOPIC_AUTHOR_FULL' => get_username_string('full', $topic_data['topic_poster'], $topic_data['topic_first_poster_name'], $topic_data['topic_first_poster_colour']),
  1723. 'TOPIC_AUTHOR_COLOUR' => get_username_string('colour', $topic_data['topic_poster'], $topic_data['topic_first_poster_name'], $topic_data['topic_first_poster_colour']),
  1724. 'TOPIC_AUTHOR' => get_username_string('username', $topic_data['topic_poster'], $topic_data['topic_first_poster_name'], $topic_data['topic_first_poster_colour']),
  1725.  
  1726.  
  1727.  
  1728. 'PAGINATION' => $pagination,
  1729. 'PAGE_NUMBER' => on_page($total_posts, $config['posts_per_page'], $start),
  1730. 'TOTAL_POSTS' => ($total_posts == 1) ? $user->lang['VIEW_TOPIC_POST'] : sprintf($user->lang['VIEW_TOPIC_POSTS'], $total_posts),
  1731.  
  1732. 'U_MCP' => ($auth->acl_get('m_', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", "i=main&amp;mode=topic_view&amp;f=$forum_id&amp;t=$topic_id&amp;start=$start" . ((strlen($u_sort_param)) ? "&amp;$u_sort_param" : ''), true, $user->session_id) : '',
  1733.  
  1734. 'MODERATORS' => (isset($forum_moderators[$forum_id]) && sizeof($forum_moderators[$forum_id])) ? implode(', ', $forum_moderators[$forum_id]) : '',
  1735.  
  1736.  
  1737.  
  1738. 'POST_IMG' => ($topic_data['forum_status'] == ITEM_LOCKED) ? $user->img('button_topic_locked', 'FORUM_LOCKED') : $user->img('button_topic_new', 'POST_NEW_TOPIC'),
  1739. 'QUOTE_IMG' => $user->img('icon_post_quote', 'REPLY_WITH_QUOTE'),
  1740. 'REPLY_IMG' => ($topic_data['forum_status'] == ITEM_LOCKED || $topic_data['topic_status'] == ITEM_LOCKED) ? $user->img('button_topic_locked', 'TOPIC_LOCKED') : $user->img('button_topic_reply', 'REPLY_TO_TOPIC'),
  1741. 'EDIT_IMG' => $user->img('icon_post_edit', 'EDIT_POST'),
  1742. 'DELETE_IMG' => $user->img('icon_post_delete', 'DELETE_POST'),
  1743. 'INFO_IMG' => $user->img('icon_post_info', 'VIEW_INFO'),
  1744. 'PROFILE_IMG' => $user->img('icon_user_profile', 'READ_PROFILE'),
  1745. 'SEARCH_IMG' => $user->img('icon_user_search', 'SEARCH_USER_POSTS'),
  1746. 'PM_IMG' => $user->img('icon_contact_pm', 'SEND_PRIVATE_MESSAGE'),
  1747. 'EMAIL_IMG' => $user->img('icon_contact_email', 'SEND_EMAIL'),
  1748. 'WWW_IMG' => $user->img('icon_contact_www', 'VISIT_WEBSITE'),
  1749. 'ICQ_IMG' => $user->img('icon_contact_icq', 'ICQ'),
  1750. 'AIM_IMG' => $user->img('icon_contact_aim', 'AIM'),
  1751. 'MSN_IMG' => $user->img('icon_contact_msnm', 'MSNM'),
  1752. 'YIM_IMG' => $user->img('icon_contact_yahoo', 'YIM'),
  1753. 'JABBER_IMG' => $user->img('icon_contact_jabber', 'JABBER') ,
  1754. 'REPORT_IMG' => $user->img('icon_post_report', 'REPORT_POST'),
  1755. 'REPORTED_IMG' => $user->img('icon_topic_reported', 'POST_REPORTED'),
  1756. 'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', 'POST_UNAPPROVED'),
  1757. 'WARN_IMG' => $user->img('icon_user_warn', 'WARN_USER'),
  1758.  
  1759.  
  1760.  
  1761. 'S_IS_LOCKED' => ($topic_data['topic_status'] == ITEM_UNLOCKED && $topic_data['forum_status'] == ITEM_UNLOCKED) ? false : true,
  1762. 'S_SELECT_SORT_DIR' => $s_sort_dir,
  1763. 'S_SELECT_SORT_KEY' => $s_sort_key,
  1764. 'S_SELECT_SORT_DAYS' => $s_limit_days,
  1765. 'S_SINGLE_MODERATOR' => (!empty($forum_moderators[$forum_id]) && sizeof($forum_moderators[$forum_id]) > 1) ? false : true,
  1766.  
  1767. 'S_TOPIC_ACTION' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&amp;t=$topic_id&amp;start=$start"),
  1768.  
  1769. 'S_TOPIC_MOD' => ($topic_mod != '') ? '<select name="action" id="quick-mod-select">' . $topic_mod . '</select>' : '',
  1770. 'S_MOD_ACTION' => append_sid("{$phpbb_root_path}mcp.$phpEx", "f=$forum_id&amp;t=$topic_id" . (($start == 0) ? '' : "&amp;start=$start") . "&amp;quickmod=1&amp;redirect=" . urlencode(str_replace('&amp;', '&', $viewtopic_url)), true, $user->session_id),
  1771.  
  1772. 'S_VIEWTOPIC' => true,
  1773. 'S_DISPLAY_SEARCHBOX' => ($auth->acl_get('u_search') && $auth->acl_get('f_search', $forum_id) && $config['load_search']) ? true : false,
  1774.  
  1775. 'S_SEARCHBOX_ACTION' => append_sid("{$phpbb_root_path}search.$phpEx", 't=' . $topic_id),
  1776.  
  1777.  
  1778.  
  1779. 'S_DISPLAY_POST_INFO' => ($topic_data['forum_type'] == FORUM_POST && ($auth->acl_get('f_post', $forum_id) || $user->data['user_id'] == ANONYMOUS)) ? true : false,
  1780. 'S_DISPLAY_REPLY_INFO' => ($topic_data['forum_type'] == FORUM_POST && ($auth->acl_get('f_reply', $forum_id) || $user->data['user_id'] == ANONYMOUS)) ? true : false,
  1781. 'S_ENABLE_FEEDS_TOPIC' => ($config['feed_topic'] && !phpbb_optionget(FORUM_OPTION_FEED_EXCLUDE, $topic_data['forum_options'])) ? true : false,
  1782.  
  1783.  
  1784.  
  1785. 'U_TOPIC' => "{$server_path}viewtopic.$phpEx?f=$forum_id&amp;t=$topic_id",
  1786. 'U_FORUM' => $server_path,
  1787. 'U_VIEW_TOPIC' => $viewtopic_url,
  1788. 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id),
  1789. 'U_VIEW_OLDER_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&amp;t=$topic_id&amp;view=previous"),
  1790. 'U_VIEW_NEWER_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&amp;t=$topic_id&amp;view=next"),
  1791. 'U_PRINT_TOPIC' => ($auth->acl_get('f_print', $forum_id)) ? $viewtopic_url . '&amp;view=print' : '',
  1792. 'U_EMAIL_TOPIC' => ($auth->acl_get('f_email', $forum_id) && $config['email_enable']) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=email&amp;t=$topic_id") : '',
  1793.  
  1794.  
  1795.  
  1796. 'U_WATCH_TOPIC' => $s_watching_topic['link'],
  1797. 'L_WATCH_TOPIC' => $s_watching_topic['title'],
  1798. 'S_WATCHING_TOPIC' => $s_watching_topic['is_watching'],
  1799.  
  1800.  
  1801.  
  1802. 'U_BOOKMARK_TOPIC' => ($user->data['is_registered'] && $config['allow_bookmarks']) ? $viewtopic_url . '&amp;bookmark=1&amp;hash=' . generate_link_hash("topic_$topic_id") : '',
  1803. 'L_BOOKMARK_TOPIC' => ($user->data['is_registered'] && $config['allow_bookmarks'] && $topic_data['bookmarked']) ? $user->lang['BOOKMARK_TOPIC_REMOVE'] : $user->lang['BOOKMARK_TOPIC'],
  1804.  
  1805.  
  1806.  
  1807. 'U_POST_NEW_TOPIC' => ($auth->acl_get('f_post', $forum_id) || $user->data['user_id'] == ANONYMOUS) ? append_sid("{$phpbb_root_path}posting.$phpEx", "mode=post&amp;f=$forum_id") : '',
  1808. 'U_POST_REPLY_TOPIC' => ($auth->acl_get('f_reply', $forum_id) || $user->data['user_id'] == ANONYMOUS) ? append_sid("{$phpbb_root_path}posting.$phpEx", "mode=reply&amp;f=$forum_id&amp;t=$topic_id") : '',
  1809. 'U_BUMP_TOPIC' => (bump_topic_allowed($forum_id, $topic_data['topic_bumped'], $topic_data['topic_last_post_time'], $topic_data['topic_poster'], $topic_data['topic_last_poster_id'])) ? append_sid("{$phpbb_root_path}posting.$phpEx", "mode=bump&amp;f=$forum_id&amp;t=$topic_id&amp;hash=" . generate_link_hash("topic_$topic_id")) : '')
  1810. );
  1811.  
  1812.  
  1813.  
  1814. //phpbb_topic_tagging MOD
  1815. $template->assign_vars(array(
  1816. 'S_ADD_TAG_ACTION' => append_sid("{$phpbb_root_path}phpbb_topic_tagging.$phpEx", 'mode=add_tag'),
  1817. 'TOPIC_TAG_LIST' => get_tag_list($topic_id, 0, 'topic'),
  1818. )
  1819. );
  1820. //end phpbb_topic_tagging MOD
  1821.  
  1822.  
  1823.  
  1824. // Does this topic contain a poll?
  1825. if (!empty($topic_data['poll_start']))
  1826. {
  1827. $sql = 'SELECT o.*, p.bbcode_bitfield, p.bbcode_uid
  1828. FROM ' . POLL_OPTIONS_TABLE . ' o, ' . POSTS_TABLE . " p
  1829. WHERE o.topic_id = $topic_id
  1830. AND p.post_id = {$topic_data['topic_first_post_id']}
  1831. AND p.topic_id = o.topic_id
  1832. ORDER BY o.poll_option_id";
  1833. $result = $db->sql_query($sql);
  1834.  
  1835.  
  1836.  
  1837. $poll_info = array();
  1838. while ($row = $db->sql_fetchrow($result))
  1839. {
  1840. $poll_info[] = $row;
  1841. }
  1842. $db->sql_freeresult($result);
  1843.  
  1844.  
  1845.  
  1846. $cur_voted_id = array();
  1847. if ($user->data['is_registered'])
  1848. {
  1849. $sql = 'SELECT poll_option_id
  1850. FROM ' . POLL_VOTES_TABLE . '
  1851. WHERE topic_id = ' . $topic_id . '
  1852. AND vote_user_id = ' . $user->data['user_id'];
  1853. $result = $db->sql_query($sql);
  1854.  
  1855.  
  1856.  
  1857. while ($row = $db->sql_fetchrow($result))
  1858. {
  1859. $cur_voted_id[] = $row['poll_option_id'];
  1860. }
  1861. $db->sql_freeresult($result);
  1862. }
  1863. else
  1864. {
  1865. // Cookie based guest tracking ... I don't like this but hum ho
  1866. // it's oft requested. This relies on "nice" users who don't feel
  1867. // the need to delete cookies to mess with results.
  1868. if (isset($_COOKIE[$config['cookie_name'] . '_poll_' . $topic_id]))
  1869. {
  1870. $cur_voted_id = explode(',', $_COOKIE[$config['cookie_name'] . '_poll_' . $topic_id]);
  1871. $cur_voted_id = array_map('intval', $cur_voted_id);
  1872. }
  1873. }
  1874.  
  1875.  
  1876.  
  1877. // Can not vote at all if no vote permission
  1878. $s_can_vote = ($auth->acl_get('f_vote', $forum_id) &&
  1879. (($topic_data['poll_length'] != 0 && $topic_data['poll_start'] + $topic_data['poll_length'] > time()) || $topic_data['poll_length'] == 0) &&
  1880. $topic_data['topic_status'] != ITEM_LOCKED &&
  1881. $topic_data['forum_status'] != ITEM_LOCKED &&
  1882. (!sizeof($cur_voted_id) ||
  1883. ($auth->acl_get('f_votechg', $forum_id) && $topic_data['poll_vote_change']))) ? true : false;
  1884. $s_display_results = (!$s_can_vote || ($s_can_vote && sizeof($cur_voted_id)) || $view == 'viewpoll') ? true : false;
  1885.  
  1886.  
  1887.  
  1888. if ($update && $s_can_vote)
  1889. {
  1890.  
  1891.  
  1892.  
  1893. if (!sizeof($voted_id) || sizeof($voted_id) > $topic_data['poll_max_options'] || in_array(VOTE_CONVERTED, $cur_voted_id) || !check_form_key('posting'))
  1894. {
  1895.  
  1896. $redirect_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&amp;t=$topic_id&amp;start=$start");
  1897.  
  1898.  
  1899.  
  1900. meta_refresh(5, $redirect_url);
  1901. if (!sizeof($voted_id))
  1902. {
  1903. $message = 'NO_VOTE_OPTION';
  1904. }
  1905. else if (sizeof($voted_id) > $topic_data['poll_max_options'])
  1906. {
  1907. $message = 'TOO_MANY_VOTE_OPTIONS';
  1908. }
  1909. else if (in_array(VOTE_CONVERTED, $cur_voted_id))
  1910. {
  1911. $message = 'VOTE_CONVERTED';
  1912. }
  1913. else
  1914. {
  1915. $message = 'FORM_INVALID';
  1916. }
  1917.  
  1918.  
  1919.  
  1920. $message = $user->lang[$message] . '<br /><br />' . sprintf($user->lang['RETURN_TOPIC'], '<a href="' . $redirect_url . '">', '</a>');
  1921. trigger_error($message);
  1922. }
  1923.  
  1924.  
  1925.  
  1926. foreach ($voted_id as $option)
  1927. {
  1928. if (in_array($option, $cur_voted_id))
  1929. {
  1930. continue;
  1931. }
  1932.  
  1933.  
  1934.  
  1935. $sql = 'UPDATE ' . POLL_OPTIONS_TABLE . '
  1936. SET poll_option_total = poll_option_total + 1
  1937. WHERE poll_option_id = ' . (int) $option . '
  1938. AND topic_id = ' . (int) $topic_id;
  1939. $db->sql_query($sql);
  1940.  
  1941.  
  1942.  
  1943. if ($user->data['is_registered'])
  1944. {
  1945. $sql_ary = array(
  1946. 'topic_id' => (int) $topic_id,
  1947. 'poll_option_id' => (int) $option,
  1948. 'vote_user_id' => (int) $user->data['user_id'],
  1949. 'vote_user_ip' => (string) $user->ip,
  1950. );
  1951.  
  1952.  
  1953.  
  1954. $sql = 'INSERT INTO ' . POLL_VOTES_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
  1955. $db->sql_query($sql);
  1956. }
  1957. }
  1958.  
  1959.  
  1960.  
  1961. foreach ($cur_voted_id as $option)
  1962. {
  1963. if (!in_array($option, $voted_id))
  1964. {
  1965. $sql = 'UPDATE ' . POLL_OPTIONS_TABLE . '
  1966. SET poll_option_total = poll_option_total - 1
  1967. WHERE poll_option_id = ' . (int) $option . '
  1968. AND topic_id = ' . (int) $topic_id;
  1969. $db->sql_query($sql);
  1970.  
  1971.  
  1972.  
  1973. if ($user->data['is_registered'])
  1974. {
  1975. $sql = 'DELETE FROM ' . POLL_VOTES_TABLE . '
  1976. WHERE topic_id = ' . (int) $topic_id . '
  1977. AND poll_option_id = ' . (int) $option . '
  1978. AND vote_user_id = ' . (int) $user->data['user_id'];
  1979. $db->sql_query($sql);
  1980. }
  1981. }
  1982. }
  1983.  
  1984.  
  1985.  
  1986. if ($user->data['user_id'] == ANONYMOUS && !$user->data['is_bot'])
  1987. {
  1988. $user->set_cookie('poll_' . $topic_id, implode(',', $voted_id), time() + 31536000);
  1989. }
  1990.  
  1991.  
  1992.  
  1993. $sql = 'UPDATE ' . TOPICS_TABLE . '
  1994. SET poll_last_vote = ' . time() . "
  1995. WHERE topic_id = $topic_id";
  1996. //, topic_last_post_time = ' . time() . " -- for bumping topics with new votes, ignore for now
  1997. $db->sql_query($sql);
  1998.  
  1999.  
  2000.  
  2001. $redirect_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&amp;t=$topic_id&amp;start=$start");
  2002.  
  2003.  
  2004.  
  2005. meta_refresh(5, $redirect_url);
  2006. trigger_error($user->lang['VOTE_SUBMITTED'] . '<br /><br />' . sprintf($user->lang['RETURN_TOPIC'], '<a href="' . $redirect_url . '">', '</a>'));
  2007. }
  2008.  
  2009.  
  2010.  
  2011. $poll_total = 0;
  2012. foreach ($poll_info as $poll_option)
  2013. {
  2014. $poll_total += $poll_option['poll_option_total'];
  2015. }
  2016.  
  2017.  
  2018.  
  2019. if ($poll_info[0]['bbcode_bitfield'])
  2020. {
  2021. $poll_bbcode = new bbcode();
  2022. }
  2023. else
  2024. {
  2025. $poll_bbcode = false;
  2026. }
  2027.  
  2028.  
  2029.  
  2030. for ($i = 0, $size = sizeof($poll_info); $i < $size; $i++)
  2031. {
  2032. $poll_info[$i]['poll_option_text'] = censor_text($poll_info[$i]['poll_option_text']);
  2033.  
  2034.  
  2035.  
  2036. if ($poll_bbcode !== false)
  2037. {
  2038. $poll_bbcode->bbcode_second_pass($poll_info[$i]['poll_option_text'], $poll_info[$i]['bbcode_uid'], $poll_option['bbcode_bitfield']);
  2039. }
  2040.  
  2041.  
  2042.  
  2043. $poll_info[$i]['poll_option_text'] = bbcode_nl2br($poll_info[$i]['poll_option_text']);
  2044. $poll_info[$i]['poll_option_text'] = smiley_text($poll_info[$i]['poll_option_text']);
  2045. }
  2046.  
  2047.  
  2048.  
  2049. $topic_data['poll_title'] = censor_text($topic_data['poll_title']);
  2050.  
  2051.  
  2052.  
  2053. if ($poll_bbcode !== false)
  2054. {
  2055. $poll_bbcode->bbcode_second_pass($topic_data['poll_title'], $poll_info[0]['bbcode_uid'], $poll_info[0]['bbcode_bitfield']);
  2056. }
  2057.  
  2058.  
  2059.  
  2060. $topic_data['poll_title'] = bbcode_nl2br($topic_data['poll_title']);
  2061. $topic_data['poll_title'] = smiley_text($topic_data['poll_title']);
  2062.  
  2063.  
  2064.  
  2065. unset($poll_bbcode);
  2066.  
  2067.  
  2068.  
  2069. foreach ($poll_info as $poll_option)
  2070. {
  2071. $option_pct = ($poll_total > 0) ? $poll_option['poll_option_total'] / $poll_total : 0;
  2072. $option_pct_txt = sprintf("%.1d%%", round($option_pct * 100));
  2073.  
  2074.  
  2075.  
  2076. $template->assign_block_vars('poll_option', array(
  2077. 'POLL_OPTION_ID' => $poll_option['poll_option_id'],
  2078. 'POLL_OPTION_CAPTION' => $poll_option['poll_option_text'],
  2079. 'POLL_OPTION_RESULT' => $poll_option['poll_option_total'],
  2080. 'POLL_OPTION_PERCENT' => $option_pct_txt,
  2081. 'POLL_OPTION_PCT' => round($option_pct * 100),
  2082. 'POLL_OPTION_IMG' => $user->img('poll_center', $option_pct_txt, round($option_pct * 250)),
  2083. 'POLL_OPTION_VOTED' => (in_array($poll_option['poll_option_id'], $cur_voted_id)) ? true : false)
  2084. );
  2085. }
  2086.  
  2087.  
  2088.  
  2089. $poll_end = $topic_data['poll_length'] + $topic_data['poll_start'];
  2090.  
  2091.  
  2092.  
  2093. $template->assign_vars(array(
  2094. 'POLL_QUESTION' => $topic_data['poll_title'],
  2095. 'TOTAL_VOTES' => $poll_total,
  2096. 'POLL_LEFT_CAP_IMG' => $user->img('poll_left'),
  2097. 'POLL_RIGHT_CAP_IMG'=> $user->img('poll_right'),
  2098.  
  2099.  
  2100.  
  2101. 'L_MAX_VOTES' => ($topic_data['poll_max_options'] == 1) ? $user->lang['MAX_OPTION_SELECT'] : sprintf($user->lang['MAX_OPTIONS_SELECT'], $topic_data['poll_max_options']),
  2102. 'L_POLL_LENGTH' => ($topic_data['poll_length']) ? sprintf($user->lang[($poll_end > time()) ? 'POLL_RUN_TILL' : 'POLL_ENDED_AT'], $user->format_date($poll_end)) : '',
  2103.  
  2104.  
  2105.  
  2106. 'S_HAS_POLL' => true,
  2107. 'S_CAN_VOTE' => $s_can_vote,
  2108. 'S_DISPLAY_RESULTS' => $s_display_results,
  2109. 'S_IS_MULTI_CHOICE' => ($topic_data['poll_max_options'] > 1) ? true : false,
  2110. 'S_POLL_ACTION' => $viewtopic_url,
  2111.  
  2112. 'U_VIEW_RESULTS' => $viewtopic_url . '&amp;view=viewpoll')
  2113. );
  2114.  
  2115.  
  2116.  
  2117. unset($poll_end, $poll_info, $voted_id);
  2118. }
  2119.  
  2120.  
  2121.  
  2122. // If the user is trying to reach the second half of the topic, fetch it starting from the end
  2123. $store_reverse = false;
  2124. $sql_limit = $config['posts_per_page'];
  2125. $sql_sort_order = $direction = '';
  2126.  
  2127.  
  2128.  
  2129. if ($start > $total_posts / 2)
  2130. {
  2131. $store_reverse = true;
  2132.  
  2133.  
  2134.  
  2135. if ($start + $config['posts_per_page'] > $total_posts)
  2136. {
  2137. $sql_limit = min($config['posts_per_page'], max(1, $total_posts - $start));
  2138. }
  2139.  
  2140.  
  2141.  
  2142. // Select the sort order
  2143. $direction = (($sort_dir == 'd') ? 'ASC' : 'DESC');
  2144. $sql_start = max(0, $total_posts - $sql_limit - $start);
  2145. }
  2146. else
  2147. {
  2148. // Select the sort order
  2149. $direction = (($sort_dir == 'd') ? 'DESC' : 'ASC');
  2150. $sql_start = $start;
  2151. }
  2152.  
  2153.  
  2154.  
  2155. if (is_array($sort_by_sql[$sort_key]))
  2156. {
  2157. $sql_sort_order = implode(' ' . $direction . ', ', $sort_by_sql[$sort_key]) . ' ' . $direction;
  2158. }
  2159. else
  2160. {
  2161. $sql_sort_order = $sort_by_sql[$sort_key] . ' ' . $direction;
  2162. }
  2163.  
  2164.  
  2165.  
  2166. // Container for user details, only process once
  2167. $post_list = $user_cache = $id_cache = $attachments = $attach_list = $rowset = $update_count = $post_edit_list = array();
  2168. $has_attachments = $display_notice = false;
  2169. $bbcode_bitfield = '';
  2170. $i = $i_total = 0;
  2171.  
  2172.  
  2173.  
  2174. // Go ahead and pull all data for this topic
  2175. $sql = 'SELECT p.post_id
  2176. FROM ' . POSTS_TABLE . ' p' . (($join_user_sql[$sort_key]) ? ', ' . USERS_TABLE . ' u': '') . "
  2177. WHERE p.topic_id = $topic_id
  2178. " . ((!$auth->acl_get('m_approve', $forum_id)) ? 'AND p.post_approved = 1' : '') . "
  2179. " . (($join_user_sql[$sort_key]) ? 'AND u.user_id = p.poster_id': '') . "
  2180. $limit_posts_time
  2181. ORDER BY $sql_sort_order";
  2182. $result = $db->sql_query_limit($sql, $sql_limit, $sql_start);
  2183.  
  2184.  
  2185.  
  2186. $i = ($store_reverse) ? $sql_limit - 1 : 0;
  2187. while ($row = $db->sql_fetchrow($result))
  2188. {
  2189. $post_list[$i] = (int) $row['post_id'];
  2190. ($store_reverse) ? $i-- : $i++;
  2191. }
  2192. $db->sql_freeresult($result);
  2193.  
  2194.  
  2195.  
  2196. if (!sizeof($post_list))
  2197. {
  2198. if ($sort_days)
  2199. {
  2200. trigger_error('NO_POSTS_TIME_FRAME');
  2201. }
  2202. else
  2203. {
  2204. trigger_error('NO_TOPIC');
  2205. }
  2206. }
  2207.  
  2208.  
  2209.  
  2210. // Holding maximum post time for marking topic read
  2211. // We need to grab it because we do reverse ordering sometimes
  2212. $max_post_time = 0;
  2213.  
  2214.  
  2215.  
  2216. $sql = $db->sql_build_query('SELECT', array(
  2217. 'SELECT' => 'u.*, z.friend, z.foe, p.*',
  2218.  
  2219.  
  2220.  
  2221. 'FROM' => array(
  2222. USERS_TABLE => 'u',
  2223. POSTS_TABLE => 'p',
  2224. ),
  2225.  
  2226.  
  2227.  
  2228. 'LEFT_JOIN' => array(
  2229. array(
  2230. 'FROM' => array(ZEBRA_TABLE => 'z'),
  2231. 'ON' => 'z.user_id = ' . $user->data['user_id'] . ' AND z.zebra_id = p.poster_id'
  2232. )
  2233. ),
  2234.  
  2235.  
  2236.  
  2237. 'WHERE' => $db->sql_in_set('p.post_id', $post_list) . '
  2238. AND u.user_id = p.poster_id'
  2239. ));
  2240.  
  2241.  
  2242.  
  2243. $result = $db->sql_query($sql);
  2244.  
  2245.  
  2246.  
  2247. $now = phpbb_gmgetdate(time() + $user->timezone + $user->dst);
  2248.  
  2249. // Posts are stored in the $rowset array while $attach_list, $user_cache
  2250. // and the global bbcode_bitfield are built
  2251. while ($row = $db->sql_fetchrow($result))
  2252. {
  2253. // Set max_post_time
  2254. if ($row['post_time'] > $max_post_time)
  2255. {
  2256. $max_post_time = $row['post_time'];
  2257. }
  2258.  
  2259.  
  2260.  
  2261.  
  2262.  
  2263. // Does post have an attachment? If so, add it to the list
  2264. if ($row['post_attachment'] && $config['allow_attachments'])
  2265. {
  2266. $attach_list[] = (int) $row['post_id'];
  2267.  
  2268.  
  2269.  
  2270. if ($row['post_approved'])
  2271. {
  2272. $has_attachments = true;
  2273. }
  2274. }
  2275.  
  2276.  
  2277.  
  2278. $rowset[$row['post_id']] = array(
  2279. 'hide_post' => ($row['foe'] && ($view != 'show' || $post_id != $row['post_id'])) ? true : false,
  2280.  
  2281.  
  2282.  
  2283. 'post_id' => $row['post_id'],
  2284. 'post_time' => $row['post_time'],
  2285. 'user_id' => $row['user_id'],
  2286. 'username' => $row['username'],
  2287. 'user_colour' => $row['user_colour'],
  2288. 'topic_id' => $row['topic_id'],
  2289. 'forum_id' => $row['forum_id'],
  2290. 'post_subject' => $row['post_subject'],
  2291. 'post_edit_count' => $row['post_edit_count'],
  2292. 'post_edit_time' => $row['post_edit_time'],
  2293. 'post_edit_reason' => $row['post_edit_reason'],
  2294. 'post_edit_user' => $row['post_edit_user'],
  2295. 'post_edit_locked' => $row['post_edit_locked'],
  2296.  
  2297.  
  2298.  
  2299. // Make sure the icon actually exists
  2300. 'icon_id' => (isset($icons[$row['icon_id']]['img'], $icons[$row['icon_id']]['height'], $icons[$row['icon_id']]['width'])) ? $row['icon_id'] : 0,
  2301. 'post_attachment' => $row['post_attachment'],
  2302. 'post_approved' => $row['post_approved'],
  2303. 'post_reported' => $row['post_reported'],
  2304. 'post_username' => $row['post_username'],
  2305. 'post_text' => $row['post_text'],
  2306. 'bbcode_uid' => $row['bbcode_uid'],
  2307. 'bbcode_bitfield' => $row['bbcode_bitfield'],
  2308. 'enable_smilies' => $row['enable_smilies'],
  2309. 'enable_sig' => $row['enable_sig'],
  2310. 'friend' => $row['friend'],
  2311. 'foe' => $row['foe'],
  2312. );
  2313.  
  2314.  
  2315.  
  2316. // Define the global bbcode bitfield, will be used to load bbcodes
  2317. $bbcode_bitfield = $bbcode_bitfield | base64_decode($row['bbcode_bitfield']);
  2318.  
  2319.  
  2320.  
  2321. // Is a signature attached? Are we going to display it?
  2322. if ($row['enable_sig'] && $config['allow_sig'] && $user->optionget('viewsigs'))
  2323. {
  2324. $bbcode_bitfield = $bbcode_bitfield | base64_decode($row['user_sig_bbcode_bitfield']);
  2325. }
  2326.  
  2327.  
  2328.  
  2329. // Cache various user specific data ... so we don't have to recompute
  2330. // this each time the same user appears on this page
  2331. if (!isset($user_cache[$poster_id]))
  2332. {
  2333. if ($poster_id == ANONYMOUS)
  2334. {
  2335. $user_cache[$poster_id] = array(
  2336. 'joined' => '',
  2337. 'posts' => '',
  2338. 'from' => '',
  2339.  
  2340.  
  2341.  
  2342. 'sig' => '',
  2343. 'sig_bbcode_uid' => '',
  2344. 'sig_bbcode_bitfield' => '',
  2345.  
  2346.  
  2347.  
  2348. 'online' => false,
  2349. 'avatar' => ($user->optionget('viewavatars')) ? get_user_avatar($row['user_avatar'], $row['user_avatar_type'], $row['user_avatar_width'], $row['user_avatar_height']) : '',
  2350. 'rank_title' => '',
  2351. 'rank_image' => '',
  2352. 'rank_image_src' => '',
  2353. 'sig' => '',
  2354. 'profile' => '',
  2355. 'pm' => '',
  2356. 'email' => '',
  2357. 'www' => '',
  2358. 'icq_status_img' => '',
  2359. 'icq' => '',
  2360. 'aim' => '',
  2361. 'msn' => '',
  2362. 'yim' => '',
  2363. 'jabber' => '',
  2364. 'search' => '',
  2365. 'age' => '',
  2366.  
  2367.  
  2368.  
  2369. 'username' => $row['username'],
  2370. 'user_colour' => $row['user_colour'],
  2371.  
  2372.  
  2373.  
  2374. 'warnings' => 0,
  2375. 'allow_pm' => 0,
  2376. );
  2377.  
  2378.  
  2379.  
  2380. get_user_rank($row['user_rank'], false, $user_cache[$poster_id]['rank_title'], $user_cache[$poster_id]['rank_image'], $user_cache[$poster_id]['rank_image_src']);
  2381. }
  2382. else
  2383. {
  2384. $user_sig = '';
  2385.  
  2386.  
  2387.  
  2388. // We add the signature to every posters entry because enable_sig is post dependant
  2389. if ($row['user_sig'] && $config['allow_sig'] && $user->optionget('viewsigs'))
  2390. {
  2391. $user_sig = $row['user_sig'];
  2392. }
  2393.  
  2394.  
  2395.  
  2396. $id_cache[] = $poster_id;
  2397.  
  2398.  
  2399.  
  2400. $user_cache[$poster_id] = array(
  2401. 'joined' => $user->format_date($row['user_regdate']),
  2402. 'posts' => $row['user_posts'],
  2403.  
  2404. //Begin Thank Post MOD
  2405.  
  2406. 'thanks' => $row['user_thanks'],
  2407.  
  2408. 'thanked' => $row['user_thanked'],
  2409.  
  2410. 'thanks_post' => $row['user_thanks_post'],
  2411.  
  2412. //End Thank Post MOD
  2413.  
  2414. 'warnings' => (isset($row['user_warnings'])) ? $row['user_warnings'] : 0,
  2415. 'from' => (!empty($row['user_from'])) ? $row['user_from'] : '',
  2416.  
  2417.  
  2418.  
  2419. 'sig' => $user_sig,
  2420. 'sig_bbcode_uid' => (!empty($row['user_sig_bbcode_uid'])) ? $row['user_sig_bbcode_uid'] : '',
  2421. 'sig_bbcode_bitfield' => (!empty($row['user_sig_bbcode_bitfield'])) ? $row['user_sig_bbcode_bitfield'] : '',
  2422.  
  2423.  
  2424.  
  2425. 'viewonline' => $row['user_allow_viewonline'],
  2426. 'allow_pm' => $row['user_allow_pm'],
  2427.  
  2428.  
  2429.  
  2430. 'avatar' => ($user->optionget('viewavatars')) ? get_user_avatar($row['user_avatar'], $row['user_avatar_type'], $row['user_avatar_width'], $row['user_avatar_height']) : '',
  2431. 'age' => '',
  2432.  
  2433.  
  2434.  
  2435. 'rank_title' => '',
  2436. 'rank_image' => '',
  2437. 'rank_image_src' => '',
  2438.  
  2439.  
  2440.  
  2441. 'username' => $row['username'],
  2442. 'user_colour' => $row['user_colour'],
  2443.  
  2444.  
  2445.  
  2446. 'online' => false,
  2447. 'profile' => append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=viewprofile&amp;u=$poster_id"),
  2448. 'www' => $row['user_website'],
  2449. 'aim' => ($row['user_aim'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=contact&amp;action=aim&amp;u=$poster_id") : '',
  2450. 'msn' => ($row['user_msnm'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=contact&amp;action=msnm&amp;u=$poster_id") : '',
  2451. 'yim' => ($row['user_yim']) ? 'http://edit.yahoo.com/config/send_webmesg?.target=' . urlencode($row['user_yim']) . '&amp;.src=pg' : '',
  2452. 'jabber' => ($row['user_jabber'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=contact&amp;action=jabber&amp;u=$poster_id") : '',
  2453. 'search' => ($auth->acl_get('u_search')) ? append_sid("{$phpbb_root_path}search.$phpEx", "author_id=$poster_id&amp;sr=posts") : '',
  2454.  
  2455.  
  2456.  
  2457. 'author_full' => get_username_string('full', $poster_id, $row['username'], $row['user_colour']),
  2458. 'author_colour' => get_username_string('colour', $poster_id, $row['username'], $row['user_colour']),
  2459. 'author_username' => get_username_string('username', $poster_id, $row['username'], $row['user_colour']),
  2460. 'author_profile' => get_username_string('profile', $poster_id, $row['username'], $row['user_colour']),
  2461. );
  2462.  
  2463.  
  2464.  
  2465. get_user_rank($row['user_rank'], $row['user_posts'], $user_cache[$poster_id]['rank_title'], $user_cache[$poster_id]['rank_image'], $user_cache[$poster_id]['rank_image_src']);
  2466.  
  2467.  
  2468.  
  2469. if (!empty($row['user_allow_viewemail']) || $auth->acl_get('a_email'))
  2470.  
  2471. {
  2472. $user_cache[$poster_id]['email'] = ($config['board_email_form'] && $config['email_enable']) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=email&amp;u=$poster_id") : (($config['board_hide_emails'] && !$auth->acl_get('a_email')) ? '' : 'mailto:' . $row['user_email']);
  2473. }
  2474. else
  2475. {
  2476. $user_cache[$poster_id]['email'] = '';
  2477. }
  2478.  
  2479.  
  2480.  
  2481. if (!empty($row['user_icq']))
  2482. {
  2483.  
  2484. $user_cache[$poster_id]['icq'] = 'http://www.icq.com/people/webmsg.php?to=' . $row['user_icq'];
  2485.  
  2486. $user_cache[$poster_id]['icq_status_img'] = '<img src="http://web.icq.com/whitepages/online?icq=' . $row['user_icq'] . '&amp;img=5" width="18" height="18" alt="" />';
  2487. }
  2488. else
  2489. {
  2490. $user_cache[$poster_id]['icq_status_img'] = '';
  2491. $user_cache[$poster_id]['icq'] = '';
  2492. }
  2493.  
  2494.  
  2495.  
  2496. if ($config['allow_birthdays'] && !empty($row['user_birthday']))
  2497. {
  2498. list($bday_day, $bday_month, $bday_year) = array_map('intval', explode('-', $row['user_birthday']));
  2499.  
  2500.  
  2501.  
  2502. if ($bday_year)
  2503. {
  2504. $diff = $now['mon'] - $bday_month;
  2505. if ($diff == 0)
  2506. {
  2507. $diff = ($now['mday'] - $bday_day < 0) ? 1 : 0;
  2508. }
  2509. else
  2510. {
  2511. $diff = ($diff < 0) ? 1 : 0;
  2512. }
  2513.  
  2514.  
  2515.  
  2516. $user_cache[$poster_id]['age'] = (int) ($now['year'] - $bday_year - $diff);
  2517. }
  2518. }
  2519. }
  2520. }
  2521. }
  2522. $db->sql_freeresult($result);
  2523.  
  2524.  
  2525.  
  2526. // Load custom profile fields
  2527. if ($config['load_cpf_viewtopic'])
  2528. {
  2529. if (!class_exists('custom_profile'))
  2530. {
  2531. include($phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx);
  2532. }
  2533. $cp = new custom_profile();
  2534.  
  2535.  
  2536.  
  2537. // Grab all profile fields from users in id cache for later use - similar to the poster cache
  2538. $profile_fields_tmp = $cp->generate_profile_fields_template('grab', $id_cache);
  2539.  
  2540.  
  2541.  
  2542. // filter out fields not to be displayed on viewtopic. Yes, it's a hack, but this shouldn't break any MODs.
  2543. $profile_fields_cache = array();
  2544. foreach ($profile_fields_tmp as $profile_user_id => $profile_fields)
  2545. {
  2546. $profile_fields_cache[$profile_user_id] = array();
  2547. foreach ($profile_fields as $used_ident => $profile_field)
  2548. {
  2549. if ($profile_field['data']['field_show_on_vt'])
  2550. {
  2551. $profile_fields_cache[$profile_user_id][$used_ident] = $profile_field;
  2552. }
  2553. }
  2554. }
  2555. unset($profile_fields_tmp);
  2556. }
  2557.  
  2558.  
  2559.  
  2560. // Generate online information for user
  2561. if ($config['load_onlinetrack'] && sizeof($id_cache))
  2562. {
  2563. $sql = 'SELECT session_user_id, MAX(session_time) as online_time, MIN(session_viewonline) AS viewonline
  2564. FROM ' . SESSIONS_TABLE . '
  2565. WHERE ' . $db->sql_in_set('session_user_id', $id_cache) . '
  2566. GROUP BY session_user_id';
  2567. $result = $db->sql_query($sql);
  2568.  
  2569.  
  2570.  
  2571. $update_time = $config['load_online_time'] * 60;
  2572. while ($row = $db->sql_fetchrow($result))
  2573. {
  2574. $user_cache[$row['session_user_id']]['online'] = (time() - $update_time < $row['online_time'] && (($row['viewonline']) || $auth->acl_get('u_viewonline'))) ? true : false;
  2575. }
  2576. $db->sql_freeresult($result);
  2577. }
  2578. unset($id_cache);
  2579.  
  2580.  
  2581.  
  2582. // Pull attachment data
  2583. if (sizeof($attach_list))
  2584. {
  2585. if ($auth->acl_get('u_download') && $auth->acl_get('f_download', $forum_id))
  2586. {
  2587. $sql = 'SELECT *
  2588. FROM ' . ATTACHMENTS_TABLE . '
  2589. WHERE ' . $db->sql_in_set('post_msg_id', $attach_list) . '
  2590. AND in_message = 0
  2591. ORDER BY filetime DESC, post_msg_id ASC';
  2592. $result = $db->sql_query($sql);
  2593.  
  2594.  
  2595.  
  2596. while ($row = $db->sql_fetchrow($result))
  2597. {
  2598. $attachments[$row['post_msg_id']][] = $row;
  2599. }
  2600. $db->sql_freeresult($result);
  2601.  
  2602.  
  2603.  
  2604. // No attachments exist, but post table thinks they do so go ahead and reset post_attach flags
  2605. if (!sizeof($attachments))
  2606. {
  2607. $sql = 'UPDATE ' . POSTS_TABLE . '
  2608. SET post_attachment = 0
  2609. WHERE ' . $db->sql_in_set('post_id', $attach_list);
  2610. $db->sql_query($sql);
  2611.  
  2612.  
  2613.  
  2614. // We need to update the topic indicator too if the complete topic is now without an attachment
  2615. if (sizeof($rowset) != $total_posts)
  2616. {
  2617. // Not all posts are displayed so we query the db to find if there's any attachment for this topic
  2618. $sql = 'SELECT a.post_msg_id as post_id
  2619. FROM ' . ATTACHMENTS_TABLE . ' a, ' . POSTS_TABLE . " p
  2620. WHERE p.topic_id = $topic_id
  2621. AND p.post_approved = 1
  2622. AND p.topic_id = a.topic_id";
  2623. $result = $db->sql_query_limit($sql, 1);
  2624. $row = $db->sql_fetchrow($result);
  2625. $db->sql_freeresult($result);
  2626.  
  2627.  
  2628.  
  2629. if (!$row)
  2630. {
  2631. $sql = 'UPDATE ' . TOPICS_TABLE . "
  2632. SET topic_attachment = 0
  2633. WHERE topic_id = $topic_id";
  2634. $db->sql_query($sql);
  2635. }
  2636. }
  2637. else
  2638. {
  2639. $sql = 'UPDATE ' . TOPICS_TABLE . "
  2640. SET topic_attachment = 0
  2641. WHERE topic_id = $topic_id";
  2642. $db->sql_query($sql);
  2643. }
  2644. }
  2645. else if ($has_attachments && !$topic_data['topic_attachment'])
  2646. {
  2647. // Topic has approved attachments but its flag is wrong
  2648. $sql = 'UPDATE ' . TOPICS_TABLE . "
  2649. SET topic_attachment = 1
  2650. WHERE topic_id = $topic_id";
  2651. $db->sql_query($sql);
  2652.  
  2653.  
  2654.  
  2655. $topic_data['topic_attachment'] = 1;
  2656. }
  2657. }
  2658. else
  2659. {
  2660. $display_notice = true;
  2661. }
  2662. }
  2663.  
  2664.  
  2665.  
  2666. // Instantiate BBCode if need be
  2667. if ($bbcode_bitfield !== '')
  2668. {
  2669. $bbcode = new bbcode(base64_encode($bbcode_bitfield));
  2670. }
  2671.  
  2672.  
  2673.  
  2674. $i_total = sizeof($rowset) - 1;
  2675. $prev_post_id = '';
  2676.  
  2677.  
  2678.  
  2679. $template->assign_vars(array(
  2680. 'S_NUM_POSTS' => sizeof($post_list))
  2681. );
  2682.  
  2683.  
  2684.  
  2685. // Link as Website Title / 4seven / 2009
  2686.  
  2687. function getTitleTag($uwebsite) {
  2688.  
  2689. $uhtml = implode("", file(html_entity_decode($uwebsite)));
  2690.  
  2691. if (preg_match("/<title>(.*)<\/title>/isU", $uhtml, $utitle)){
  2692.  
  2693. $utitletag = trim($utitle[1]);
  2694.  
  2695. return '<a href="' . $uwebsite . '">' . $utitletag . '</a>';}}
  2696.  
  2697. // Link as Website Title / 4seven / 2009
  2698.  
  2699. // Output the posts
  2700. $first_unread = $post_unread = false;
  2701.  
  2702. // Advanced Meta Tags MOD
  2703.  
  2704. $first_post_text = '';
  2705.  
  2706. for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i)
  2707. {
  2708. // A non-existing rowset only happens if there was no user present for the entered poster_id
  2709. // This could be a broken posts table.
  2710. if (!isset($rowset[$post_list[$i]]))
  2711. {
  2712. continue;
  2713. }
  2714.  
  2715.  
  2716.  
  2717. $row =& $rowset[$post_list[$i]];
  2718. $poster_id = $row['user_id'];
  2719.  
  2720.  
  2721.  
  2722. // End signature parsing, only if needed
  2723. if ($user_cache[$poster_id]['sig'] && $row['enable_sig'] && empty($user_cache[$poster_id]['sig_parsed']))
  2724. {
  2725. $user_cache[$poster_id]['sig'] = censor_text($user_cache[$poster_id]['sig']);
  2726.  
  2727.  
  2728.  
  2729. if ($user_cache[$poster_id]['sig_bbcode_bitfield'])
  2730. {
  2731. $bbcode->bbcode_second_pass($user_cache[$poster_id]['sig'], $user_cache[$poster_id]['sig_bbcode_uid'], $user_cache[$poster_id]['sig_bbcode_bitfield']);
  2732. }
  2733.  
  2734.  
  2735.  
  2736. $user_cache[$poster_id]['sig'] = bbcode_nl2br($user_cache[$poster_id]['sig']);
  2737. $user_cache[$poster_id]['sig'] = smiley_text($user_cache[$poster_id]['sig']);
  2738. $user_cache[$poster_id]['sig_parsed'] = true;
  2739. }
  2740.  
  2741.  
  2742.  
  2743. // Parse the message and subject
  2744. $message = censor_text($row['post_text']);
  2745.  
  2746. // Link as Website Title / 4seven / 2009
  2747.  
  2748. if((preg_match("#\[url_title:#", $message)) && preg_match("#\[\/url_title:#", $message)){
  2749.  
  2750. $message = preg_replace("/\[url_title(.*?)\](.*?)\[\/url_title(.*?)\]/eU", 'getTitleTag("\\2")', $message);}
  2751.  
  2752. // Link as Website Title / 4seven / 2009
  2753.  
  2754.  
  2755.  
  2756. // Second parse bbcode here
  2757. if ($row['bbcode_bitfield'])
  2758. {
  2759. $bbcode->bbcode_second_pass($message, $row['bbcode_uid'], $row['bbcode_bitfield']);
  2760. }
  2761.  
  2762. // Advanced Meta Tags MOD
  2763.  
  2764. if ($i == 0)
  2765.  
  2766. {
  2767.  
  2768. $first_post_text = $message;
  2769.  
  2770. }
  2771.  
  2772.  
  2773.  
  2774. $message = bbcode_nl2br($message);
  2775. $message = smiley_text($message);
  2776.  
  2777.  
  2778.  
  2779. if (!empty($attachments[$row['post_id']]))
  2780. {
  2781. parse_attachments($forum_id, $message, $attachments[$row['post_id']], $update_count);
  2782. }
  2783.  
  2784.  
  2785.  
  2786. // Replace naughty words such as farty pants
  2787. $row['post_subject'] = censor_text($row['post_subject']);
  2788.  
  2789.  
  2790.  
  2791. // Highlight active words (primarily for search)
  2792. if ($highlight_match)
  2793. {
  2794. $message = preg_replace('#(?!<.*)(?<!\w)(' . $highlight_match . ')(?!\w|[^<>]*(?:</s(?:cript|tyle))?>)#is', '<span class="posthilit">\1</span>', $message);
  2795. $row['post_subject'] = preg_replace('#(?!<.*)(?<!\w)(' . $highlight_match . ')(?!\w|[^<>]*(?:</s(?:cript|tyle))?>)#is', '<span class="posthilit">\1</span>', $row['post_subject']);
  2796. }
  2797.  
  2798.  
  2799.  
  2800. // Editing information
  2801. if (($row['post_edit_count'] && $config['display_last_edited']) || $row['post_edit_reason'])
  2802. {
  2803. // Get usernames for all following posts if not already stored
  2804. if (!sizeof($post_edit_list) && ($row['post_edit_reason'] || ($row['post_edit_user'] && !isset($user_cache[$row['post_edit_user']]))))
  2805. {
  2806. // Remove all post_ids already parsed (we do not have to check them)
  2807. $post_storage_list = (!$store_reverse) ? array_slice($post_list, $i) : array_slice(array_reverse($post_list), $i);
  2808.  
  2809.  
  2810.  
  2811. $sql = 'SELECT DISTINCT u.user_id, u.username, u.user_colour
  2812. FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u
  2813. WHERE ' . $db->sql_in_set('p.post_id', $post_storage_list) . '
  2814. AND p.post_edit_count <> 0
  2815. AND p.post_edit_user <> 0
  2816. AND p.post_edit_user = u.user_id';
  2817. $result2 = $db->sql_query($sql);
  2818. while ($user_edit_row = $db->sql_fetchrow($result2))
  2819. {
  2820. $post_edit_list[$user_edit_row['user_id']] = $user_edit_row;
  2821. }
  2822. $db->sql_freeresult($result2);
  2823.  
  2824.  
  2825.  
  2826. unset($post_storage_list);
  2827. }
  2828.  
  2829.  
  2830.  
  2831. $l_edit_time_total = ($row['post_edit_count'] == 1) ? $user->lang['EDITED_TIME_TOTAL'] : $user->lang['EDITED_TIMES_TOTAL'];
  2832.  
  2833.  
  2834.  
  2835. if ($row['post_edit_reason'])
  2836. {
  2837. // User having edited the post also being the post author?
  2838. if (!$row['post_edit_user'] || $row['post_edit_user'] == $poster_id)
  2839. {
  2840. $display_username = get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username']);
  2841. }
  2842. else
  2843. {
  2844. $display_username = get_username_string('full', $row['post_edit_user'], $post_edit_list[$row['post_edit_user']]['username'], $post_edit_list[$row['post_edit_user']]['user_colour']);
  2845. }
  2846.  
  2847.  
  2848.  
  2849. $l_edited_by = sprintf($l_edit_time_total, $display_username, $user->format_date($row['post_edit_time'], false, true), $row['post_edit_count']);
  2850. }
  2851. else
  2852. {
  2853. if ($row['post_edit_user'] && !isset($user_cache[$row['post_edit_user']]))
  2854. {
  2855. $user_cache[$row['post_edit_user']] = $post_edit_list[$row['post_edit_user']];
  2856. }
  2857.  
  2858.  
  2859.  
  2860. // User having edited the post also being the post author?
  2861. if (!$row['post_edit_user'] || $row['post_edit_user'] == $poster_id)
  2862. {
  2863. $display_username = get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username']);
  2864. }
  2865. else
  2866. {
  2867. $display_username = get_username_string('full', $row['post_edit_user'], $user_cache[$row['post_edit_user']]['username'], $user_cache[$row['post_edit_user']]['user_colour']);
  2868. }
  2869.  
  2870.  
  2871.  
  2872. $l_edited_by = sprintf($l_edit_time_total, $display_username, $user->format_date($row['post_edit_time'], false, true), $row['post_edit_count']);
  2873. }
  2874. }
  2875. else
  2876. {
  2877. $l_edited_by = '';
  2878. }
  2879.  
  2880.  
  2881.  
  2882. // Bump information
  2883. if ($topic_data['topic_bumped'] && $row['post_id'] == $topic_data['topic_last_post_id'] && isset($user_cache[$topic_data['topic_bumper']]) )
  2884. {
  2885. // It is safe to grab the username from the user cache array, we are at the last
  2886. // post and only the topic poster and last poster are allowed to bump.
  2887. // Admins and mods are bound to the above rules too...
  2888. $l_bumped_by = sprintf($user->lang['BUMPED_BY'], $user_cache[$topic_data['topic_bumper']]['username'], $user->format_date($topic_data['topic_last_post_time'], false, true));
  2889. }
  2890. else
  2891. {
  2892. $l_bumped_by = '';
  2893. }
  2894.  
  2895.  
  2896.  
  2897. $cp_row = array();
  2898.  
  2899.  
  2900.  
  2901. //
  2902. if ($config['load_cpf_viewtopic'])
  2903. {
  2904. $cp_row = (isset($profile_fields_cache[$poster_id])) ? $cp->generate_profile_fields_template('show', false, $profile_fields_cache[$poster_id]) : array();
  2905. }
  2906.  
  2907.  
  2908.  
  2909. $post_unread = (isset($topic_tracking_info[$topic_id]) && $row['post_time'] > $topic_tracking_info[$topic_id]) ? true : false;
  2910.  
  2911.  
  2912.  
  2913. $s_first_unread = false;
  2914. if (!$first_unread && $post_unread)
  2915. {
  2916. $s_first_unread = $first_unread = true;
  2917. }
  2918.  
  2919.  
  2920.  
  2921. $edit_allowed = ($user->data['is_registered'] && ($auth->acl_get('m_edit', $forum_id) || (
  2922. $user->data['user_id'] == $poster_id &&
  2923. $auth->acl_get('f_edit', $forum_id) &&
  2924. !$row['post_edit_locked'] &&
  2925. ($row['post_time'] > time() - ($config['edit_time'] * 60) || !$config['edit_time'])
  2926. )));
  2927.  
  2928.  
  2929.  
  2930. $delete_allowed = ($user->data['is_registered'] && ($auth->acl_get('m_delete', $forum_id) || (
  2931. $user->data['user_id'] == $poster_id &&
  2932. $auth->acl_get('f_delete', $forum_id) &&
  2933. $topic_data['topic_last_post_id'] == $row['post_id'] &&
  2934. ($row['post_time'] > time() - ($config['delete_time'] * 60) || !$config['delete_time']) &&
  2935. // we do not want to allow removal of the last post if a moderator locked it!
  2936. !$row['post_edit_locked']
  2937. )));
  2938.  
  2939.  
  2940.  
  2941. //
  2942. $postrow = array(
  2943.  
  2944. 'S_FIRST_POST_TRUE' => ($topic_data['topic_first_post_id'] == $row['post_id']) ? true : false,
  2945.  
  2946. 'POST_AUTHOR_FULL' => ($poster_id != ANONYMOUS) ? $user_cache[$poster_id]['author_full'] : get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username']),
  2947. 'POST_AUTHOR_COLOUR' => ($poster_id != ANONYMOUS) ? $user_cache[$poster_id]['author_colour'] : get_username_string('colour', $poster_id, $row['username'], $row['user_colour'], $row['post_username']),
  2948. 'POST_AUTHOR' => ($poster_id != ANONYMOUS) ? $user_cache[$poster_id]['author_username'] : get_username_string('username', $poster_id, $row['username'], $row['user_colour'], $row['post_username']),
  2949. 'U_POST_AUTHOR' => ($poster_id != ANONYMOUS) ? $user_cache[$poster_id]['author_profile'] : get_username_string('profile', $poster_id, $row['username'], $row['user_colour'], $row['post_username']),
  2950.  
  2951. //Begin Thank Post MOD
  2952.  
  2953. 'THANKS_FROM' => sprintf($user->lang['THANKS_FROM'], get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username'])),
  2954.  
  2955. //End Thank Post MOD
  2956.  
  2957.  
  2958.  
  2959. 'RANK_TITLE' => $user_cache[$poster_id]['rank_title'],
  2960. 'RANK_IMG' => $user_cache[$poster_id]['rank_image'],
  2961. 'RANK_IMG_SRC' => $user_cache[$poster_id]['rank_image_src'],
  2962. 'POSTER_JOINED' => $user_cache[$poster_id]['joined'],
  2963. 'POSTER_POSTS' => $user_cache[$poster_id]['posts'],
  2964.  
  2965. //Begin Thank Post MOD
  2966.  
  2967. 'POSTER_THANKS' => $user_cache[$poster_id]['thanks'],
  2968.  
  2969. 'POSTER_THANKED' => ($user_cache[$poster_id]['thanked'] <= 1) ? $user_cache[$poster_id]['thanked'] . $user->lang['THANKS_TIME'] : $user_cache[$poster_id]['thanked'] . $user->lang['THANKS_TIMES'],
  2970.  
  2971. 'POSTER_THANKS_POST' => ($user_cache[$poster_id]['thanks_post'] <= 1) ? $user_cache[$poster_id]['thanks_post'] . $user->lang['THANKS_POST'] : $user_cache[$poster_id]['thanks_post'] . $user->lang['THANKS_POSTS'],
  2972.  
  2973. //End Thank Post MOD
  2974.  
  2975. 'POSTER_FROM' => $user_cache[$poster_id]['from'],
  2976. 'POSTER_AVATAR' => $user_cache[$poster_id]['avatar'],
  2977. 'POSTER_WARNINGS' => $user_cache[$poster_id]['warnings'],
  2978. 'POSTER_AGE' => $user_cache[$poster_id]['age'],
  2979.  
  2980.  
  2981.  
  2982. 'POST_DATE' => $user->format_date($row['post_time'], false, ($view == 'print') ? true : false),
  2983. 'POST_SUBJECT' => $row['post_subject'],
  2984. 'MESSAGE' => $message,
  2985.  
  2986. 'SIGNATURE' => ($row['enable_sig']) ? ($config['reimg_ignore_sig_img'] ? str_replace(reimg_properties(), '', $user_cache[$poster_id]['sig']) : $user_cache[$poster_id]['sig']) : '',
  2987.  
  2988. 'EDITED_MESSAGE' => $l_edited_by,
  2989. 'EDIT_REASON' => $row['post_edit_reason'],
  2990. 'BUMPED_MESSAGE' => $l_bumped_by,
  2991.  
  2992.  
  2993.  
  2994. 'MINI_POST_IMG' => ($post_unread) ? $user->img('icon_post_target_unread', 'NEW_POST') : $user->img('icon_post_target', 'POST'),
  2995.  
  2996. 'POST_ICON_IMG' => ($topic_data['enable_icons'] && !empty($row['icon_id'])) ? $icons[$row['icon_id']]['img'] : '',
  2997. 'POST_ICON_IMG_WIDTH' => ($topic_data['enable_icons'] && !empty($row['icon_id'])) ? $icons[$row['icon_id']]['width'] : '',
  2998. 'POST_ICON_IMG_HEIGHT' => ($topic_data['enable_icons'] && !empty($row['icon_id'])) ? $icons[$row['icon_id']]['height'] : '',
  2999. 'ICQ_STATUS_IMG' => $user_cache[$poster_id]['icq_status_img'],
  3000. 'ONLINE_IMG' => ($poster_id == ANONYMOUS || !$config['load_onlinetrack']) ? '' : (($user_cache[$poster_id]['online']) ? $user->img('icon_user_online', 'ONLINE') : $user->img('icon_user_offline', 'OFFLINE')),
  3001. 'S_ONLINE' => ($poster_id == ANONYMOUS || !$config['load_onlinetrack']) ? false : (($user_cache[$poster_id]['online']) ? true : false),
  3002.  
  3003.  
  3004.  
  3005. 'U_EDIT' => ($edit_allowed) ? append_sid("{$phpbb_root_path}posting.$phpEx", "mode=edit&amp;f=$forum_id&amp;p={$row['post_id']}") : '',
  3006. 'U_QUOTE' => ($auth->acl_get('f_reply', $forum_id)) ? append_sid("{$phpbb_root_path}posting.$phpEx", "mode=quote&amp;f=$forum_id&amp;p={$row['post_id']}") : '',
  3007. 'U_INFO' => ($auth->acl_get('m_info', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", "i=main&amp;mode=post_details&amp;f=$forum_id&amp;p=" . $row['post_id'], true, $user->session_id) : '',
  3008. 'U_DELETE' => ($delete_allowed) ? append_sid("{$phpbb_root_path}posting.$phpEx", "mode=delete&amp;f=$forum_id&amp;p={$row['post_id']}") : '',
  3009.  
  3010.  
  3011.  
  3012. 'U_PROFILE' => $user_cache[$poster_id]['profile'],
  3013. 'U_SEARCH' => $user_cache[$poster_id]['search'],
  3014. 'U_PM' => ($poster_id != ANONYMOUS && $config['allow_privmsg'] && $auth->acl_get('u_sendpm') && ($user_cache[$poster_id]['allow_pm'] || $auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_'))) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&amp;mode=compose&amp;action=quotepost&amp;p=' . $row['post_id']) : '',
  3015. 'U_EMAIL' => $user_cache[$poster_id]['email'],
  3016. 'U_WWW' => $user_cache[$poster_id]['www'],
  3017. 'U_ICQ' => $user_cache[$poster_id]['icq'],
  3018. 'U_AIM' => $user_cache[$poster_id]['aim'],
  3019. 'U_MSN' => $user_cache[$poster_id]['msn'],
  3020. 'U_YIM' => $user_cache[$poster_id]['yim'],
  3021. 'U_JABBER' => $user_cache[$poster_id]['jabber'],
  3022. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  3023. // Replace "YOUR_FORUM_TWITTER_ID" for your forum twitter id, or remove the "(from @YOUR_TWITTER_ID)" from the line if your board doesn't have a twitter id //
  3024. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  3025.  
  3026. // Mod_Share_On by JesusADS
  3027. 'U_FACEBOOK' => 'http://www.facebook.com/share.php?u=' . generate_board_url() . '/viewtopic.php?t='. $topic_data['topic_id'],
  3028. 'U_TWITTER' => 'http://twitter.com/home?status=' . $topic_data['topic_title'] . ' '. generate_board_url() . '/viewtopic.php?t=' . $topic_data['topic_id'],
  3029. 'U_DIGG' => 'http://digg.com/submit?phase=2&url=' . generate_board_url() . '/viewtopic.php?t='. $topic_data['topic_id'] . '&title=' . $topic_data['topic_title'],
  3030. 'U_MYSPACE' => 'http://www.myspace.com/Modules/PostTo/Pages/?u=' . generate_board_url() . '/viewtopic.php?t='. $topic_data['topic_id'] . '&t=' . $topic_data['topic_title'],
  3031. 'U_DELICIOUS' => 'http://delicious.com/post?url=' . generate_board_url() . '/viewtopic.php?t='. $topic_data['topic_id'] . '&title=' . $topic_data['topic_title'],
  3032. 'U_TECHNORATI' => 'http://technorati.com/faves?add=' . generate_board_url() . '/viewtopic.php?t='. $topic_data['topic_id'],
  3033. // Mod_Share_On
  3034.  
  3035.  
  3036.  
  3037. 'U_REPORT' => ($auth->acl_get('f_report', $forum_id)) ? append_sid("{$phpbb_root_path}report.$phpEx", 'f=' . $forum_id . '&amp;p=' . $row['post_id']) : '',
  3038. 'U_MCP_REPORT' => ($auth->acl_get('m_report', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&amp;mode=report_details&amp;f=' . $forum_id . '&amp;p=' . $row['post_id'], true, $user->session_id) : '',
  3039. 'U_MCP_APPROVE' => ($auth->acl_get('m_approve', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&amp;mode=approve_details&amp;f=' . $forum_id . '&amp;p=' . $row['post_id'], true, $user->session_id) : '',
  3040. 'U_MINI_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'p=' . $row['post_id']) . (($topic_data['topic_type'] == POST_GLOBAL) ? '&amp;f=' . $forum_id : '') . '#p' . $row['post_id'],
  3041. 'U_NEXT_POST_ID' => ($i < $i_total && isset($rowset[$post_list[$i + 1]])) ? $rowset[$post_list[$i + 1]]['post_id'] : '',
  3042. 'U_PREV_POST_ID' => $prev_post_id,
  3043. 'U_NOTES' => ($auth->acl_getf_global('m_')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&amp;mode=user_notes&amp;u=' . $poster_id, true, $user->session_id) : '',
  3044. 'U_WARN' => ($auth->acl_get('m_warn') && $poster_id != $user->data['user_id'] && $poster_id != ANONYMOUS) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=warn&amp;mode=warn_post&amp;f=' . $forum_id . '&amp;p=' . $row['post_id'], true, $user->session_id) : '',
  3045.  
  3046.  
  3047.  
  3048. 'POST_ID' => $row['post_id'],
  3049. 'POSTER_ID' => $poster_id,
  3050.  
  3051.  
  3052.  
  3053. 'S_HAS_ATTACHMENTS' => (!empty($attachments[$row['post_id']])) ? true : false,
  3054. 'S_POST_UNAPPROVED' => ($row['post_approved']) ? false : true,
  3055. 'S_POST_REPORTED' => ($row['post_reported'] && $auth->acl_get('m_report', $forum_id)) ? true : false,
  3056. 'S_DISPLAY_NOTICE' => $display_notice && $row['post_attachment'],
  3057. 'S_FRIEND' => ($row['friend']) ? true : false,
  3058. 'S_UNREAD_POST' => $post_unread,
  3059. 'S_FIRST_UNREAD' => $s_first_unread,
  3060. 'S_CUSTOM_FIELDS' => (isset($cp_row['row']) && sizeof($cp_row['row'])) ? true : false,
  3061. 'S_TOPIC_POSTER' => ($topic_data['topic_poster'] == $poster_id) ? true : false,
  3062.  
  3063.  
  3064. // Mod_Share_On by JesusADS
  3065. 'S_SO_STATUS' => $config['so_status'],
  3066. 'S_SO_FACEBOOK' => $config['so_facebook'],
  3067. 'S_SO_TWITTER' => $config['so_twitter'],
  3068. 'S_SO_ORKUT' => $config['so_orkut'],
  3069. 'S_SO_DIGG' => $config['so_digg'],
  3070. 'S_SO_MYSPACE' => $config['so_myspace'],
  3071. 'S_SO_DELICIOUS' => $config['so_delicious'],
  3072. 'S_SO_TECHNORATI' => $config['so_technorati'],
  3073. 'S_SHARE_ON_FIRST_POST' => ($row['post_id'] == $topic_data['topic_first_post_id']) ? true : false,
  3074. // Mod_Share_On
  3075. 'S_IGNORE_POST' => ($row['hide_post']) ? true : false,
  3076. 'L_IGNORE_POST' => ($row['hide_post']) ? sprintf($user->lang['POST_BY_FOE'], get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username']), '<a href="' . $viewtopic_url . "&amp;p={$row['post_id']}&amp;view=show#p{$row['post_id']}" . '">', '</a>') : '',
  3077. );
  3078.  
  3079.  
  3080.  
  3081. //Begin Thank Post MOD
  3082.  
  3083. $sql = 'SELECT thanks_from
  3084.  
  3085. FROM ' . THANKS_TABLE . '
  3086.  
  3087. WHERE post_id = ' . $row['post_id'] .'
  3088.  
  3089. AND thanks_from = ' . $user->data['user_id'];
  3090.  
  3091. $result = $db->sql_query($sql);
  3092.  
  3093. $give_thanks = $db->sql_fetchfield('thanks_from');
  3094.  
  3095. $db->sql_freeresult($result);
  3096.  
  3097.  
  3098.  
  3099. $sql_array = array(
  3100.  
  3101. 'SELECT' => 'u.username, u.user_colour, t.*',
  3102.  
  3103.  
  3104.  
  3105. 'FROM' => array(
  3106.  
  3107. USERS_TABLE => 'u',
  3108.  
  3109. THANKS_TABLE => 't'
  3110.  
  3111. ),
  3112.  
  3113.  
  3114.  
  3115. 'WHERE' => 't.post_id =' . $row['post_id'] . '
  3116.  
  3117. AND u.user_id = t.thanks_from',
  3118.  
  3119.  
  3120.  
  3121. 'ORDER_BY' => 'u.username_clean'
  3122.  
  3123. );
  3124.  
  3125.  
  3126.  
  3127. $sql = $db->sql_build_query('SELECT', $sql_array);
  3128.  
  3129. $result = $db->sql_query($sql);
  3130.  
  3131.  
  3132.  
  3133. $thanks_list = '';
  3134.  
  3135. while ($row2 = $db->sql_fetchrow($result))
  3136.  
  3137. {
  3138.  
  3139. $thanks_user = get_username_string('full', $row2['thanks_from'], $row2['username'], $row2['user_colour'], $row2['username']);
  3140.  
  3141. $thanks_list = $thanks_list . ", " . $thanks_user;
  3142.  
  3143. }
  3144.  
  3145.  
  3146.  
  3147. $thanks_list = ltrim($thanks_list, ", ");
  3148.  
  3149. $postrow = array_merge($postrow, array(
  3150.  
  3151. 'THANKS_LIST' => $thanks_list,
  3152.  
  3153. 'U_THANKS' => (!$give_thanks) ? append_sid("{$phpbb_root_path}thanks.$phpEx", 'p=' . $row['post_id'] . '&amp;mode=thanks') : append_sid("{$phpbb_root_path}thanks.$phpEx", 'p=' . $row['post_id'] . '&amp;mode=remove'),
  3154.  
  3155. 'S_GIVE_THANKS' => $give_thanks,
  3156.  
  3157. 'S_FIRST_POST' => true,
  3158.  
  3159. 'S_IS_OWN_POST' => ($poster_id == $user->data['user_id']) ? true : false
  3160.  
  3161. ));
  3162.  
  3163. $db->sql_freeresult($result);
  3164.  
  3165.  
  3166.  
  3167. $template->assign_vars(array(
  3168.  
  3169. 'THANKS_ENABLE' => ($topic_data['enable_thanks']) ? true : false));
  3170.  
  3171. //End Thank Post MOD
  3172.  
  3173. if (isset($cp_row['row']) && sizeof($cp_row['row']))
  3174. {
  3175. $postrow = array_merge($postrow, $cp_row['row']);
  3176. }
  3177. $postrow['S_POST_NUM'] = $start + ($i+1);
  3178.  
  3179.  
  3180.  
  3181. // Dump vars into template
  3182. $template->assign_block_vars('postrow', $postrow);
  3183.  
  3184.  
  3185.  
  3186. if (!empty($cp_row['blockrow']))
  3187. {
  3188. foreach ($cp_row['blockrow'] as $field_data)
  3189. {
  3190. $template->assign_block_vars('postrow.custom_fields', $field_data);
  3191. }
  3192. }
  3193.  
  3194.  
  3195.  
  3196. // Display not already displayed Attachments for this post, we already parsed them. ;)
  3197. if (!empty($attachments[$row['post_id']]))
  3198. {
  3199. foreach ($attachments[$row['post_id']] as $attachment)
  3200. {
  3201. $template->assign_block_vars('postrow.attachment', array(
  3202. 'DISPLAY_ATTACHMENT' => $attachment)
  3203. );
  3204. }
  3205. }
  3206.  
  3207.  
  3208.  
  3209. $prev_post_id = $row['post_id'];
  3210.  
  3211.  
  3212.  
  3213. unset($rowset[$post_list[$i]]);
  3214. unset($attachments[$row['post_id']]);
  3215. }
  3216. unset($rowset, $user_cache);
  3217.  
  3218.  
  3219.  
  3220. // Update topic view and if necessary attachment view counters ... but only for humans and if this is the first 'page view'
  3221. if (isset($user->data['session_page']) && !$user->data['is_bot'] && (strpos($user->data['session_page'], '&t=' . $topic_id) === false || isset($user->data['session_created'])))
  3222. {
  3223. $sql = 'UPDATE ' . TOPICS_TABLE . '
  3224. SET topic_views = topic_views + 1, topic_last_view_time = ' . time() . "
  3225. WHERE topic_id = $topic_id";
  3226. $db->sql_query($sql);
  3227.  
  3228.  
  3229.  
  3230. // Update the attachment download counts
  3231. if (sizeof($update_count))
  3232. {
  3233. $sql = 'UPDATE ' . ATTACHMENTS_TABLE . '
  3234. SET download_count = download_count + 1
  3235. WHERE ' . $db->sql_in_set('attach_id', array_unique($update_count));
  3236. $db->sql_query($sql);
  3237. }
  3238. }
  3239.  
  3240.  
  3241.  
  3242. // Get last post time for all global announcements
  3243. // to keep proper forums tracking
  3244. if ($topic_data['topic_type'] == POST_GLOBAL)
  3245. {
  3246. $sql = 'SELECT topic_last_post_time as forum_last_post_time
  3247. FROM ' . TOPICS_TABLE . '
  3248. WHERE forum_id = 0
  3249. ORDER BY topic_last_post_time DESC';
  3250. $result = $db->sql_query_limit($sql, 1);
  3251. $topic_data['forum_last_post_time'] = (int) $db->sql_fetchfield('forum_last_post_time');
  3252. $db->sql_freeresult($result);
  3253.  
  3254.  
  3255.  
  3256. $sql = 'SELECT mark_time as forum_mark_time
  3257. FROM ' . FORUMS_TRACK_TABLE . '
  3258. WHERE forum_id = 0
  3259. AND user_id = ' . $user->data['user_id'];
  3260. $result = $db->sql_query($sql);
  3261. $topic_data['forum_mark_time'] = (int) $db->sql_fetchfield('forum_mark_time');
  3262. $db->sql_freeresult($result);
  3263. }
  3264.  
  3265.  
  3266.  
  3267. // Only mark topic if it's currently unread. Also make sure we do not set topic tracking back if earlier pages are viewed.
  3268. if (isset($topic_tracking_info[$topic_id]) && $topic_data['topic_last_post_time'] > $topic_tracking_info[$topic_id] && $max_post_time > $topic_tracking_info[$topic_id])
  3269. {
  3270. markread('topic', (($topic_data['topic_type'] == POST_GLOBAL) ? 0 : $forum_id), $topic_id, $max_post_time);
  3271.  
  3272.  
  3273.  
  3274. // Update forum info
  3275. $all_marked_read = update_forum_tracking_info((($topic_data['topic_type'] == POST_GLOBAL) ? 0 : $forum_id), $topic_data['forum_last_post_time'], (isset($topic_data['forum_mark_time'])) ? $topic_data['forum_mark_time'] : false, false);
  3276. }
  3277. else
  3278. {
  3279. $all_marked_read = true;
  3280. }
  3281.  
  3282.  
  3283.  
  3284. // If there are absolutely no more unread posts in this forum and unread posts shown, we can savely show the #unread link
  3285. if ($all_marked_read)
  3286. {
  3287. if ($post_unread)
  3288. {
  3289. $template->assign_vars(array(
  3290. 'U_VIEW_UNREAD_POST' => '#unread',
  3291. ));
  3292. }
  3293. else if (isset($topic_tracking_info[$topic_id]) && $topic_data['topic_last_post_time'] > $topic_tracking_info[$topic_id])
  3294. {
  3295. $template->assign_vars(array(
  3296. 'U_VIEW_UNREAD_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&amp;t=$topic_id&amp;view=unread") . '#unread',
  3297. ));
  3298. }
  3299. }
  3300. else if (!$all_marked_read)
  3301. {
  3302. $last_page = ((floor($start / $config['posts_per_page']) + 1) == max(ceil($total_posts / $config['posts_per_page']), 1)) ? true : false;
  3303.  
  3304.  
  3305.  
  3306. // What can happen is that we are at the last displayed page. If so, we also display the #unread link based in $post_unread
  3307. if ($last_page && $post_unread)
  3308. {
  3309. $template->assign_vars(array(
  3310. 'U_VIEW_UNREAD_POST' => '#unread',
  3311. ));
  3312. }
  3313. else if (!$last_page)
  3314. {
  3315. $template->assign_vars(array(
  3316. 'U_VIEW_UNREAD_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&amp;t=$topic_id&amp;view=unread") . '#unread',
  3317. ));
  3318. }
  3319. }
  3320.  
  3321.  
  3322.  
  3323. // let's set up quick_reply
  3324. $s_quick_reply = false;
  3325. if ($user->data['is_registered'] && $config['allow_quick_reply'] && ($topic_data['forum_flags'] & FORUM_FLAG_QUICK_REPLY) && $auth->acl_get('f_reply', $forum_id))
  3326. {
  3327. // Quick reply enabled forum
  3328. $s_quick_reply = (($topic_data['forum_status'] == ITEM_UNLOCKED && $topic_data['topic_status'] == ITEM_UNLOCKED) || $auth->acl_get('m_edit', $forum_id)) ? true : false;
  3329. }
  3330.  
  3331.  
  3332.  
  3333. if ($s_can_vote || $s_quick_reply)
  3334. {
  3335. add_form_key('posting');
  3336.  
  3337.  
  3338.  
  3339. if ($s_quick_reply)
  3340. {
  3341. $s_attach_sig = $config['allow_sig'] && $user->optionget('attachsig') && $auth->acl_get('f_sigs', $forum_id) && $auth->acl_get('u_sig');
  3342. $s_smilies = $config['allow_smilies'] && $user->optionget('smilies') && $auth->acl_get('f_smilies', $forum_id);
  3343. $s_bbcode = $config['allow_bbcode'] && $user->optionget('bbcode') && $auth->acl_get('f_bbcode', $forum_id);
  3344. $s_notify = $config['allow_topic_notify'] && ($user->data['user_notify'] || $s_watching_topic['is_watching']);
  3345.  
  3346.  
  3347.  
  3348. $qr_hidden_fields = array(
  3349. 'topic_cur_post_id' => (int) $topic_data['topic_last_post_id'],
  3350. 'lastclick' => (int) time(),
  3351. 'topic_id' => (int) $topic_data['topic_id'],
  3352. 'forum_id' => (int) $forum_id,
  3353. );
  3354.  
  3355.  
  3356.  
  3357. // Originally we use checkboxes and check with isset(), so we only provide them if they would be checked
  3358. (!$s_bbcode) ? $qr_hidden_fields['disable_bbcode'] = 1 : true;
  3359. (!$s_smilies) ? $qr_hidden_fields['disable_smilies'] = 1 : true;
  3360. (!$config['allow_post_links']) ? $qr_hidden_fields['disable_magic_url'] = 1 : true;
  3361. ($s_attach_sig) ? $qr_hidden_fields['attach_sig'] = 1 : true;
  3362. ($s_notify) ? $qr_hidden_fields['notify'] = 1 : true;
  3363. ($topic_data['topic_status'] == ITEM_LOCKED) ? $qr_hidden_fields['lock_topic'] = 1 : true;
  3364.  
  3365.  
  3366.  
  3367. $template->assign_vars(array(
  3368. 'S_QUICK_REPLY' => true,
  3369. 'U_QR_ACTION' => append_sid("{$phpbb_root_path}posting.$phpEx", "mode=reply&amp;f=$forum_id&amp;t=$topic_id"),
  3370. 'QR_HIDDEN_FIELDS' => build_hidden_fields($qr_hidden_fields),
  3371. 'SUBJECT' => 'Re: ' . censor_text($topic_data['topic_title']),
  3372. ));
  3373. }
  3374. }
  3375. // now I have the urge to wash my hands :(
  3376.  
  3377.  
  3378.  
  3379.  
  3380.  
  3381. // We overwrite $_REQUEST['f'] if there is no forum specified
  3382. // to be able to display the correct online list.
  3383. // One downside is that the user currently viewing this topic/post is not taken into account.
  3384. if (empty($_REQUEST['f']))
  3385. {
  3386. $_REQUEST['f'] = $forum_id;
  3387. }
  3388.  
  3389.  
  3390.  
  3391. // We need to do the same with the topic_id. See #53025.
  3392. if (empty($_REQUEST['t']) && !empty($topic_id))
  3393. {
  3394. $_REQUEST['t'] = $topic_id;
  3395. }
  3396.  
  3397.  
  3398.  
  3399. // Output the page
  3400.  
  3401. page_header($user->lang['VIEW_TOPIC'] . ' - ' . $topic_data['topic_title'], true, $forum_id, 'forum', $first_post_text);
  3402. // BEGIN Precise Similar Topics
  3403. if ($config['similar_topics'] && $auth->acl_get('u_similar_topics'))
  3404. {
  3405. include($phpbb_root_path . 'includes/functions_similar_topics.' . $phpEx);
  3406. similar_topics($topic_data, $forum_id);
  3407. }
  3408. // END Precise Similar Topics
  3409.  
  3410. // true, post_text added by Advanced Meta Tags MOD
  3411.  
  3412.  
  3413.  
  3414. $template->set_filenames(array(
  3415. 'body' => ($view == 'print') ? 'viewtopic_print.html' : 'viewtopic_body.html')
  3416. );
  3417. make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx"), $forum_id);
  3418.  
  3419.  
  3420.  
  3421. page_footer();
  3422.  
  3423.  
  3424.  
  3425. ?>
Add Comment
Please, Sign In to add comment