PageRenderTime 39ms CodeModel.GetById 31ms RepoModel.GetById 0ms app.codeStats 1ms

/viewtopic.php

https://github.com/MightyGorgon/icy_phoenix
PHP | 2798 lines | 2348 code | 258 blank | 192 comment | 394 complexity | 009ac20086e3f4db5ca90a7a0f495fa3 MD5 | raw file
Possible License(s): AGPL-1.0
  1. <?php
  2. /**
  3. *
  4. * @package Icy Phoenix
  5. * @version $Id$
  6. * @copyright (c) 2008 Icy Phoenix
  7. * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  8. *
  9. */
  10. /**
  11. *
  12. * @Icy Phoenix is based on phpBB
  13. * @copyright (c) 2008 phpBB Group
  14. *
  15. */
  16. define('IN_TOPIC', true);
  17. // MG Cash MOD For IP - BEGIN
  18. define('IN_CASHMOD', true);
  19. define('CM_VIEWTOPIC', true);
  20. // MG Cash MOD For IP - END
  21. define('CT_SECLEVEL', 'MEDIUM');
  22. $ct_ignoregvar = array('');
  23. // Added to optimize memory for attachments
  24. define('ATTACH_DISPLAY', true);
  25. define('IN_ICYPHOENIX', true);
  26. if (!defined('IP_ROOT_PATH')) define('IP_ROOT_PATH', './');
  27. if (!defined('PHP_EXT')) define('PHP_EXT', substr(strrchr(__FILE__, '.'), 1));
  28. include(IP_ROOT_PATH . 'common.' . PHP_EXT);
  29. include_once(IP_ROOT_PATH . 'includes/bbcode.' . PHP_EXT);
  30. include_once(IP_ROOT_PATH . ATTACH_MOD_PATH . 'includes/functions_delete.' . PHP_EXT);
  31. include_once(IP_ROOT_PATH . 'includes/functions_topics.' . PHP_EXT);
  32. include_once(IP_ROOT_PATH . 'includes/functions_calendar.' . PHP_EXT);
  33. include_once(IP_ROOT_PATH . 'includes/functions_users.' . PHP_EXT);
  34. include_once(IP_ROOT_PATH . 'includes/functions_profile.' . PHP_EXT);
  35. include_once(IP_ROOT_PATH . 'includes/functions_rate.' . PHP_EXT);
  36. // Event Registration - BEGIN
  37. include_once(IP_ROOT_PATH . 'includes/functions_events_reg.' . PHP_EXT);
  38. // Event Registration - END
  39. @include_once(IP_ROOT_PATH . 'includes/class_topics.' . PHP_EXT);
  40. $class_topics = new class_topics();
  41. // Init common vars: forum_id, topic_id, post_id, etc.
  42. $class_topics->var_init(true);
  43. // Start session management
  44. $user->session_begin();
  45. $auth->acl($user->data);
  46. $user->setup();
  47. // End session management
  48. setup_extra_lang(array('lang_rate'));
  49. $start = request_var('start', 0);
  50. $start = ($start < 0) ? 0 : $start;
  51. $page_number = request_var('page_number', 0);
  52. $page_number = ($page_number < 1) ? 0 : $page_number;
  53. $start = (empty($page_number) ? $start : (($page_number * $config['topics_per_page']) - $config['topics_per_page']));
  54. $sort_days_array = array(0, 1, 7, 14, 30, 90, 180, 365);
  55. $sort_days_lang_array = array(0 => $lang['ALL_POSTS'], 1 => $lang['1_DAY'], 7 => $lang['7_DAYS'], 14 => $lang['2_WEEKS'], 30 => $lang['1_MONTH'], 90 => $lang['3_MONTHS'], 180 => $lang['6_MONTHS'], 365 => $lang['1_YEAR']);
  56. $sort_key_array = array('t', 's', 'a');
  57. $sort_key_lang_array = array('t' => $lang['POST_TIME'], 's' => $lang['SUBJECT'], 'a' => $lang['AUTHOR']);
  58. // In Icy Phoenix we still prefer sorting by time instead by ID... it could lead to collateral problems I know...
  59. //$sort_key_sql_array = array('t' => 'p.post_id', 's' => 'p.post_subject', 'a' => 'u.username_clean');
  60. $sort_key_sql_array = array('t' => 'p.post_time', 's' => 'p.post_subject', 'a' => 'u.username_clean');
  61. $sort_dir_array = array('a', 'd');
  62. $sort_dir_lang_array = array('a' => $lang['ASCENDING'], 'd' => $lang['DESCENDING']);
  63. $sort_dir_sql_array = array('a' => 'ASC', 'd' => 'DESC');
  64. $default_sort_days = (!empty($user->data['user_post_show_days'])) ? $user->data['user_post_show_days'] : $sort_days_array[0];
  65. $default_sort_key = (!empty($user->data['user_post_sortby_type'])) ? $user->data['user_post_sortby_type'] : $sort_key_array[0];
  66. $default_sort_dir = (!empty($user->data['user_post_sortby_dir'])) ? $user->data['user_post_sortby_dir'] : $sort_dir_array[0];
  67. $sort_days = request_var('st', $default_sort_days);
  68. $sort_days = check_var_value($sort_days, $sort_days_array);
  69. $sort_key = request_var('sk', $default_sort_key);
  70. $sort_key = check_var_value($sort_key, $sort_key_array);
  71. $sort_key_sql = $sort_key_sql_array[$sort_key];
  72. $sort_dir = strtolower(request_var('sd', $default_sort_dir));
  73. $sort_dir = check_var_value($sort_dir, $sort_dir_array);
  74. $sort_dir_sql = $sort_dir_sql_array[$sort_dir];
  75. // only fetch post higher than a certain post_id. Maybe this should use post_time, as $sort_key_sql_array uses post_time
  76. $after_post_id = request_var('after_post_id', 0);
  77. // make sure we can't fetch negative indices. 0 = disabled
  78. $after_post_id = ($after_post_id < 0) ? 1 : $after_post_id;
  79. // Backward compatibility
  80. if (check_http_var_exists('postorder', true))
  81. {
  82. $sort_dir_array_old = array('asc', 'desc');
  83. $sort_dir = strtolower(request_var('postorder', $sort_dir_array_old[0]));
  84. $sort_dir = check_var_value($sort_dir, $sort_dir_array_old);
  85. $sort_dir = ($sort_dir == 'asc') ? 'a' : 'd';
  86. $sort_dir_sql = $sort_dir_sql_array[$sort_dir];
  87. }
  88. if (check_http_var_exists('postdays', true))
  89. {
  90. $sort_days = request_var('postdays', $default_sort_days);
  91. $sort_days = check_var_value($sort_days, $sort_days_array);
  92. }
  93. $vt_sort_append_array = array();
  94. if ($sort_days != $sort_days_array[0])
  95. {
  96. $vt_sort_append_array['st'] = $sort_days;
  97. }
  98. if ($sort_key != $sort_key_array[0])
  99. {
  100. $vt_sort_append_array['sk'] = $sort_key;
  101. }
  102. if ($sort_dir != $sort_dir_array[0])
  103. {
  104. $vt_sort_append_array['sd'] = $sort_dir;
  105. }
  106. $vt_sort_append = '';
  107. $vt_sort_append_red = '';
  108. if (!empty($vt_sort_append_array))
  109. {
  110. foreach ($vt_sort_append_array as $k => $v)
  111. {
  112. $vt_sort_append = '&amp;' . $k . '=' . $v;
  113. $vt_sort_append_red = '&' . $k . '=' . $v;
  114. }
  115. }
  116. $select_post_array = array('st' => 'sort_days', 'sk' => 'sort_key', 'sd' => 'sort_dir');
  117. $select_post_array_output = array();
  118. foreach ($select_post_array as $s_key => $s_name)
  119. {
  120. $select_post_array_output[$s_key] = '<select name="' . $s_key . '">';
  121. foreach (${$s_name . '_lang_array'} as $k => $v)
  122. {
  123. $selected = (${$s_name} == $k) ? ' selected="selected"' : '';
  124. $select_post_array_output[$s_key] .= '<option value="' . $k . '"' . $selected . '>' . $v . '</option>';
  125. }
  126. $select_post_array_output[$s_key] .= '</select>';
  127. ${'select_' . $s_name} = $select_post_array_output[$s_key];
  128. }
  129. $sid = request_var('sid', '');
  130. // Activity - BEGIN
  131. if (!empty($config['plugins']['activity']['enabled']))
  132. {
  133. include_once(IP_ROOT_PATH . PLUGINS_PATH . $config['plugins']['activity']['dir'] . 'common.' . PHP_EXT);
  134. $q = "SELECT * FROM " . INA_HOF;
  135. $r = $db->sql_query($q);
  136. $hof_data = $db->sql_fetchrowset($r);
  137. $db->sql_freeresult($r);
  138. }
  139. // Activity - END
  140. // Start initial var setup
  141. $kb_mode = false;
  142. $kb_mode_append = '';
  143. $kb_mode_append_red = '';
  144. $kb_mode_var = request_var('kb', '');
  145. if (($kb_mode_var == 'on') && ($user->data['bot_id'] == false))
  146. {
  147. $kb_mode = true;
  148. $kb_mode_append = '&amp;kb=on';
  149. $kb_mode_append_red = '&kb=on';
  150. }
  151. $download = request_get_var('download', '');
  152. if (empty($topic_id) && empty($post_id))
  153. {
  154. if (!defined('STATUS_404')) define('STATUS_404', true);
  155. message_die(GENERAL_MESSAGE, 'NO_TOPIC');
  156. }
  157. // Find topic id if user requested a newer or older topic
  158. $view = request_get_var('view', '');
  159. if (!empty($view) && empty($post_id))
  160. {
  161. if ($view == 'newest')
  162. {
  163. if (isset($_COOKIE[$config['cookie_name'] . '_sid']) || !empty($sid))
  164. {
  165. $session_id = isset($_COOKIE[$config['cookie_name'] . '_sid']) ? $_COOKIE[$config['cookie_name'] . '_sid'] : $sid;
  166. if (!preg_match('/^[A-Za-z0-9]*$/', $session_id))
  167. {
  168. $session_id = '';
  169. }
  170. if ($session_id)
  171. {
  172. $sql = "SELECT p.post_id
  173. FROM " . POSTS_TABLE . " p, " . SESSIONS_TABLE . " s, " . USERS_TABLE . " u
  174. WHERE s.session_id = '" . $db->sql_escape($session_id) . "'
  175. AND u.user_id = s.session_user_id
  176. AND p.topic_id = '" . $topic_id . "'
  177. AND p.post_time >= u.user_lastvisit
  178. ORDER BY p.post_time ASC
  179. LIMIT 1";
  180. $result = $db->sql_query($sql);
  181. /* UPI2DB REPLACE
  182. if (!($row = $db->sql_fetchrow($result)))
  183. {
  184. message_die(GENERAL_MESSAGE, 'No_new_posts_last_visit');
  185. }
  186. */
  187. // UPI2DB - BEGIN
  188. if (!($row = $db->sql_fetchrow($result)))
  189. {
  190. if ($topic_id > 0)
  191. {
  192. redirect(CMS_PAGE_VIEWTOPIC . '?' . $forum_id_append . '&' . $topic_id_append . $kb_mode_append_red);
  193. }
  194. else
  195. {
  196. message_die(GENERAL_MESSAGE, 'No_new_posts_last_visit');
  197. }
  198. }
  199. // UPI2DB - END
  200. $post_id = $row['post_id'];
  201. $post_id_append = (!empty($post_id) ? (POST_POST_URL . '=' . $post_id) : '');
  202. $post_id_append_url = (!empty($post_id) ? ('#p' . $post_id) : '');
  203. $session_id_append = !empty($sid) ? ('sid=' . $session_id . '&') : '';
  204. redirect(append_sid(CMS_PAGE_VIEWTOPIC . '?' . $session_id_append . $kb_mode_append_red . $forum_id_append . '&' . $topic_id_append . '&' . $post_id_append . $post_id_append_url));
  205. }
  206. }
  207. redirect(append_sid(CMS_PAGE_VIEWTOPIC . '?' . $forum_id_append . '&' . $topic_id_append . $kb_mode_append_red, true));
  208. }
  209. elseif (($view == 'next') || ($view == 'previous'))
  210. {
  211. $sql_condition = ($view == 'next') ? '>' : '<';
  212. $sql_ordering = ($view == 'next') ? 'ASC' : 'DESC';
  213. $sql = "SELECT t.topic_id, t.forum_id
  214. FROM " . TOPICS_TABLE . " t, " . TOPICS_TABLE . " t2
  215. WHERE
  216. t2.topic_id = '" . $topic_id . "'
  217. AND t.forum_id = t2.forum_id
  218. AND t.topic_moved_id = 0
  219. AND t.topic_last_post_id $sql_condition t2.topic_last_post_id
  220. ORDER BY t.topic_last_post_id $sql_ordering
  221. LIMIT 1";
  222. $result = $db->sql_query($sql);
  223. if ($row = $db->sql_fetchrow($result))
  224. {
  225. $forum_id = intval($row['forum_id']);
  226. $forum_id_append = (!empty($forum_id) ? (POST_FORUM_URL . '=' . $forum_id) : '');
  227. $topic_id = intval($row['topic_id']);
  228. $topic_id_append = (!empty($topic_id) ? (POST_TOPIC_URL . '=' . $topic_id) : '');
  229. redirect(append_sid(CMS_PAGE_VIEWTOPIC . '?' . $forum_id_append . '&' . $topic_id_append . $kb_mode_append_red));
  230. }
  231. else
  232. {
  233. $message = ($view == 'next') ? 'No_newer_topics' : 'No_older_topics';
  234. message_die(GENERAL_MESSAGE, $message);
  235. }
  236. }
  237. }
  238. // This rather complex gaggle of code handles querying for topics but also allows for direct linking to a post (and the calculation of which page the post is on and the correct display of viewtopic)
  239. $join_sql_table = (!$post_id ? '' : (", " . POSTS_TABLE . " p, " . POSTS_TABLE . " p2 "));
  240. $join_sql = (!$post_id ? ("t.topic_id = " . $topic_id) : ("p.post_id = " . $post_id . " AND t.topic_id = p.topic_id AND p2.topic_id = p.topic_id AND p2.post_id <= " . $post_id));
  241. $count_sql = (!$post_id ? '' : (", COUNT(p2.post_id) AS prev_posts"));
  242. $order_sql = (!$post_id ? '' : ("GROUP BY p.post_id, t.topic_id, t.topic_title, t.topic_status, t.topic_replies, t.topic_time, t.topic_type, t.poll_start, t.topic_last_post_id, f.forum_name, f.forum_status, f.forum_id, f.auth_view, f.auth_read, f.auth_post, f.auth_reply, f.auth_edit, f.auth_delete, f.auth_sticky, f.auth_announce, f.auth_pollcreate, f.auth_vote, f.auth_attachments, f.auth_ban, f.auth_greencard, f.auth_bluecard ORDER BY p.post_id ASC"));
  243. // Let's try to query all fields for topics and forums... it should not require too much resources as we are querying only one row
  244. //$sql = "SELECT t.topic_id, t.topic_title, t.topic_status, t.topic_replies, t.topic_time, t.topic_type, t.poll_start, t.topic_last_post_id, t.topic_label_compiled, t.topic_first_post_id, t.topic_calendar_time, t.topic_calendar_duration, t.topic_reg, t.topic_similar_topics, f.forum_name, f.forum_status, f.forum_id, f.forum_similar_topics, f.forum_topic_views, f.forum_kb_mode, f.auth_view, f.auth_read, f.auth_post, f.auth_reply, f.auth_edit, f.auth_delete, f.auth_sticky, f.auth_announce, f.auth_pollcreate, f.auth_vote, f.auth_attachments, f.auth_ban, f.auth_greencard, f.auth_bluecard" . $count_sql . "
  245. $sql = "SELECT t.*, f.*, u.*" . $count_sql . "
  246. FROM " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f," . USERS_TABLE . " u" . $join_sql_table . "
  247. WHERE $join_sql
  248. AND f.forum_id = t.forum_id AND t.topic_poster = u.user_id
  249. $order_sql";
  250. attach_setup_viewtopic_auth($order_sql, $sql);
  251. $result = $db->sql_query($sql);
  252. if (!($forum_topic_data = $db->sql_fetchrow($result)))
  253. {
  254. if (!defined('STATUS_404')) define('STATUS_404', true);
  255. message_die(GENERAL_MESSAGE, 'NO_TOPIC');
  256. }
  257. $db->sql_freeresult($result);
  258. $forum_id = intval($forum_topic_data['forum_id']);
  259. $forum_id_append = (!empty($forum_id) ? (POST_FORUM_URL . '=' . $forum_id) : '');
  260. $topic_id = intval($forum_topic_data['topic_id']);
  261. $topic_id_append = (!empty($topic_id) ? (POST_TOPIC_URL . '=' . $topic_id) : '');
  262. $forum_name = get_object_lang(POST_FORUM_URL . $forum_id, 'name');
  263. $topic_time = $forum_topic_data['topic_time'];
  264. $topic_first_post_id = intval($forum_topic_data['topic_first_post_id']);
  265. $topic_calendar_time = intval($forum_topic_data['topic_calendar_time']);
  266. $topic_calendar_duration = intval($forum_topic_data['topic_calendar_duration']);
  267. $topic_title_data = $class_topics->generate_topic_title($topic_id, $forum_topic_data, 80);
  268. $topic_title = $topic_title_data['title'];
  269. $topic_title_clean = $topic_title_data['title_clean'];
  270. $topic_title_plain = $topic_title_data['title_plain'];
  271. $topic_title_label = $topic_title_data['title_label'];
  272. $topic_title_short = $topic_title_data['title_short'];
  273. // Topic poster information
  274. $topic_started = create_date_ip($lang['DATE_FORMAT_VF'], $forum_topic_data['topic_time'], $config['board_timezone'], true);
  275. $topic_username = colorize_username($forum_topic_data['user_id'], $forum_topic_data['username'], $forum_topic_data['user_color'], $forum_topic_data['user_active']);
  276. $topic_avatar_img = user_get_avatar($forum_topic_data['user_id'], $forum_topic_data['user_level'], $forum_topic_data['user_avatar'], $forum_topic_data['user_avatar_type'], $forum_topic_data['user_allowavatar']);
  277. $topic_user_from_flag = $forum_topic_data['user_from_flag'] ? '<img src="images/flags/' . $forum_topic_data['user_from_flag'] . '" alt="' . $forum_topic_data['user_from_flag'] . '" title="' . $forum_topic_data['user_from'] . '" />' : '';
  278. switch ($forum_topic_data['user_gender'])
  279. {
  280. case 1:
  281. $topic_user_gender_image = '<img src="' . $images['icon_minigender_male'] . '" alt="' . $lang['Gender']. ': ' . $lang['Male'] . '" title="' . $lang['Gender'] . ': ' . $lang['Male'] . '" />';
  282. break;
  283. case 2:
  284. $topic_user_gender_image = '<img src="' . $images['icon_minigender_female'] . '" alt="' . $lang['Gender']. ': ' . $lang['Female'] . '" title="' . $lang['Gender'] . ': ' . $lang['Female'] . '" />';
  285. break;
  286. default:
  287. $topic_user_gender_image = '';
  288. }
  289. $topic_user_joined = create_date($lang['JOINED_DATE_FORMAT'], $forum_topic_data['user_regdate'], $config['board_timezone']);
  290. $topic_user_posts = $forum_topic_data['user_posts'];
  291. $meta_content = array();
  292. $meta_content = $class_topics->meta_content_init($forum_topic_data, 'topic');
  293. $meta_content['post_id'] = (!empty($post_id) && (intval($post_id) > 0)) ? intval($post_id) : 0;
  294. $this_forum_auth_read = intval($forum_topic_data['auth_read']);
  295. if ($forum_topic_data['forum_kb_mode'])
  296. {
  297. if ($kb_mode_var == 'off')
  298. {
  299. $kb_mode = false;
  300. $kb_mode_append = '&amp;kb=off';
  301. $kb_mode_append_red = '&kb=off';
  302. }
  303. else
  304. {
  305. $kb_mode = true;
  306. $kb_mode_append = '&amp;kb=on';
  307. $kb_mode_append_red = '&kb=on';
  308. }
  309. }
  310. // Set or remove bookmark - BEGIN
  311. $setbm = request_var('setbm', '');
  312. $removebm = request_var('removebm', '');
  313. if ((!empty($setbm) || !empty($removebm)) && !$user->data['is_bot'])
  314. {
  315. $redirect = CMS_PAGE_VIEWTOPIC . '?' . $forum_id_append . '&' . $topic_id_append . $kb_mode_append_red . '&start=' . $start . $vt_sort_append_red . '&highlight=' . urlencode($_GET['highlight']);
  316. if ($user->data['session_logged_in'])
  317. {
  318. if (!empty($setbm))
  319. {
  320. set_bookmark($topic_id);
  321. }
  322. elseif (!empty($removebm))
  323. {
  324. remove_bookmark($topic_id);
  325. }
  326. }
  327. else
  328. {
  329. if (!empty($setbm))
  330. {
  331. $redirect .= '&setbm=true';
  332. }
  333. elseif (!empty($removebm))
  334. {
  335. $redirect .= '&removebm=true';
  336. }
  337. redirect(append_sid(CMS_PAGE_LOGIN . '?redirect=' . $redirect, true));
  338. }
  339. redirect(append_sid($redirect, true));
  340. }
  341. // Set or remove bookmark - END
  342. $cms_page['page_id'] = 'viewtopic';
  343. // Comment out page_nav because viewtopic has its own breadcrumbs...
  344. //$cms_page['page_nav'] = (!empty($cms_config_layouts[$cms_page['page_id']]['page_nav']) ? true : false);
  345. $cms_page['global_blocks'] = (!empty($cms_config_layouts[$cms_page['page_id']]['global_blocks']) ? true : false);
  346. $cms_auth_level = (isset($cms_config_layouts[$cms_page['page_id']]['view']) ? $cms_config_layouts[$cms_page['page_id']]['view'] : AUTH_ALL);
  347. check_page_auth($cms_page['page_id'], $cms_auth_level);
  348. if ($download)
  349. {
  350. @include(IP_ROOT_PATH . 'includes/topic_download.' . PHP_EXT);
  351. exit;
  352. }
  353. //Begin Lo-Fi Mod
  354. if (!empty($lofi))
  355. {
  356. $lang['Reply_with_quote'] = $lang['quote_lofi'] ;
  357. $lang['Edit_delete_post'] = $lang['edit_lofi'];
  358. $lang['View_IP'] = $lang['ip_lofi'];
  359. $lang['Delete_post'] = $lang['del_lofi'];
  360. $lang['Read_profile'] = $lang['profile_lofi'];
  361. $lang['Send_private_message'] = $lang['pm_lofi'];
  362. $lang['Send_email'] = $lang['email_lofi'];
  363. $lang['Visit_website'] = $lang['website_lofi'];
  364. $lang['ICQ'] = $lang['icq_lofi'];
  365. $lang['AIM'] = $lang['aim_lofi'];
  366. $lang['YIM'] = $lang['yim_lofi'];
  367. $lang['MSNM'] = $lang['msnm_lofi'];
  368. }
  369. //End Lo-Fi Mod
  370. // Force Topic Read - BEGIN
  371. $ftr_disabled = $config['ftr_disable'] ? true : false;
  372. if (!$ftr_disabled)
  373. {
  374. @include(IP_ROOT_PATH . 'includes/topic_ftr.' . PHP_EXT);
  375. }
  376. // Force Topic Read - END
  377. $similar_topics_enabled = false;
  378. if ($config['similar_topics'] && $forum_topic_data['forum_similar_topics'])
  379. {
  380. $similar_topics_enabled = true;
  381. }
  382. if ($similar_topics_enabled)
  383. {
  384. $similar_forums_auth = auth(AUTH_ALL, AUTH_LIST_ALL, $user->data);
  385. $similar_is_auth = $similar_forums_auth[$forum_id];
  386. }
  387. // Start auth check
  388. $is_auth = array();
  389. $is_auth = $tree['auth'][POST_FORUM_URL . $forum_id];
  390. if (!$is_auth['auth_read'])
  391. {
  392. if (!$user->data['session_logged_in'])
  393. {
  394. $redirect = $forum_id_append . '&' . $topic_id_append . $kb_mode_append_red;
  395. $redirect .= ($post_id) ? '&' . $post_id_append : '';
  396. $redirect .= ($start) ? '&start=' . $start : '';
  397. redirect(append_sid(CMS_PAGE_LOGIN . '?redirect=' . CMS_PAGE_VIEWTOPIC . '&' . $redirect, true));
  398. }
  399. $message = sprintf($lang['Sorry_auth_read'], $is_auth['auth_read_type']);
  400. message_die(GENERAL_MESSAGE, $message);
  401. }
  402. // End auth check
  403. // Who viewed a topic - BEGIN
  404. if (!$config['disable_topic_view'] && $forum_topic_data['forum_topic_views'])
  405. {
  406. $user_id = $user->data['user_id'];
  407. $sql = 'UPDATE ' . TOPIC_VIEW_TABLE . ' SET topic_id = "' . $topic_id . '", view_time = "' . time() . '", view_count = view_count + 1 WHERE topic_id=' . $topic_id . ' AND user_id = ' . $user_id;
  408. $db->sql_return_on_error(true);
  409. $result = $db->sql_query($sql);
  410. $db->sql_return_on_error(false);
  411. if (!$result || !$db->sql_affectedrows())
  412. {
  413. $sql = 'INSERT IGNORE INTO ' . TOPIC_VIEW_TABLE . ' (topic_id, user_id, view_time, view_count)
  414. VALUES (' . $topic_id . ', "' . $user_id . '", "' . time() . '", "1")';
  415. $db->sql_query($sql);
  416. }
  417. }
  418. // Who viewed a topic - END
  419. if (!empty($post_id))
  420. {
  421. $start = floor(($forum_topic_data['prev_posts'] - 1) / intval($config['posts_per_page'])) * intval($config['posts_per_page']);
  422. }
  423. // Is user watching this thread?
  424. if (!class_exists('class_notifications'))
  425. {
  426. include(IP_ROOT_PATH . 'includes/class_notifications.' . PHP_EXT);
  427. $class_notifications = new class_notifications();
  428. }
  429. $watch = request_var('watch', '');
  430. $unwatch = request_var('unwatch', '');
  431. if($user->data['session_logged_in'] && !$user->data['is_bot'])
  432. {
  433. $can_watch_topic = true;
  434. $sql = "SELECT notify_status
  435. FROM " . TOPICS_WATCH_TABLE . "
  436. WHERE topic_id = " . $topic_id . "
  437. AND user_id = " . $user->data['user_id'] . "
  438. LIMIT 1";
  439. $result = $db->sql_query($sql);
  440. if ($row = $db->sql_fetchrow($result))
  441. {
  442. if (!empty($unwatch))
  443. {
  444. if ($unwatch == 'topic')
  445. {
  446. $is_watching_topic = false;
  447. $class_notifications->delete_topic_watch($user->data['user_id'], $topic_id);
  448. }
  449. $redirect_url = append_sid(CMS_PAGE_VIEWTOPIC . '?' . $forum_id_append . '&amp;' . $topic_id_append . '&amp;start=' . $start . $kb_mode_append);
  450. meta_refresh(3, $redirect_url);
  451. $message = $lang['No_longer_watching'] . '<br /><br />' . sprintf($lang['Click_return_topic'], '<a href="' . append_sid(CMS_PAGE_VIEWTOPIC . '?' . $forum_id_append . '&amp;' . $topic_id_append . '&amp;start=' . $start . $kb_mode_append) . '">', '</a>');
  452. message_die(GENERAL_MESSAGE, $message);
  453. }
  454. else
  455. {
  456. $is_watching_topic = true;
  457. if ($row['notify_status'])
  458. {
  459. $class_notifications->update_topic_watch($user->data['user_id'], $topic_id, $forum_id, 0);
  460. }
  461. }
  462. }
  463. else
  464. {
  465. if (!empty($watch))
  466. {
  467. if ($watch == 'topic')
  468. {
  469. $is_watching_topic = true;
  470. $class_notifications->update_topic_watch($user->data['user_id'], $topic_id, $forum_id, 0);
  471. }
  472. $redirect_url = append_sid(CMS_PAGE_VIEWTOPIC . '?' . $forum_id_append . '&amp;' . $topic_id_append . $kb_mode_append . '&amp;' . 'start=' . $start);
  473. meta_refresh(3, $redirect_url);
  474. $message = $lang['You_are_watching'] . '<br /><br />' . sprintf($lang['Click_return_topic'], '<a href="' . append_sid(CMS_PAGE_VIEWTOPIC . '?' . $forum_id_append . '&amp;' . $topic_id_append . $kb_mode_append . '&amp;' . '&amp;start=' . $start) . '">', '</a>');
  475. message_die(GENERAL_MESSAGE, $message);
  476. }
  477. else
  478. {
  479. $is_watching_topic = false;
  480. }
  481. }
  482. }
  483. else
  484. {
  485. if ($unwatch == 'topic')
  486. {
  487. redirect(append_sid(CMS_PAGE_LOGIN . '?redirect=' . CMS_PAGE_VIEWTOPIC . '?' . $forum_id_append . '&' . $topic_id_append . $kb_mode_append_red . '&unwatch=topic', true));
  488. }
  489. else
  490. {
  491. $can_watch_topic = 0;
  492. $is_watching_topic = false;
  493. }
  494. }
  495. // Generate a 'Show posts in previous x days' select box. If the postdays var is POSTed then get it's value, find the number of topics with dates newer than it (to properly handle pagination) and alter the main query
  496. $limit_sql_insert = '';
  497. if(!empty($sort_days))
  498. {
  499. $start = 0;
  500. $min_post_time = time() - (intval($sort_days) * 86400);
  501. $sql = "SELECT COUNT(p.post_id) AS num_posts
  502. FROM " . TOPICS_TABLE . " t, " . POSTS_TABLE . " p
  503. WHERE t.topic_id = " . $topic_id . "
  504. AND p.topic_id = t.topic_id
  505. AND p.post_time >= " . $min_post_time;
  506. $result = $db->sql_query($sql);
  507. $total_replies = ($row = $db->sql_fetchrow($result)) ? intval($row['num_posts']) : 0;
  508. $limit_posts_time = "AND p.post_time >= " . $min_post_time . " ";
  509. }
  510. elseif ($after_post_id > 0)
  511. {
  512. // TODO make it after_post_time?
  513. $limit_posts_time = "AND p.post_id > " . intval($after_post_id) . " ";
  514. $sort_days = 0;
  515. $total_replies = intval($forum_topic_data['topic_replies']) + 1;
  516. }
  517. else
  518. {
  519. $sort_days = 0;
  520. $total_replies = intval($forum_topic_data['topic_replies']) + 1;
  521. $limit_posts_time = '';
  522. $limit_sql_insert = $start . ', ';
  523. }
  524. $user_ids = array();
  525. $user_ids2 = array();
  526. if($user->data['session_logged_in'])
  527. {
  528. $user_ids[$user->data['user_id']] = $user->data['username'];
  529. }
  530. // Custom Profile Fields MOD
  531. $profile_data = get_fields('WHERE view_in_topic = ' . VIEW_IN_TOPIC . ' AND users_can_view = ' . ALLOW_VIEW);
  532. $profile_data_sql = get_udata_txt($profile_data, 'u.');
  533. // END Custom Profile Fields MOD
  534. // Similar Topics - BEGIN
  535. if ($similar_topics_enabled)
  536. {
  537. $similar_topics = get_similar_topics($similar_forums_auth, $topic_id, $topic_title_plain, $forum_topic_data['topic_similar_topics'], $forum_topic_data['topic_desc']);
  538. $count_similar = sizeof($similar_topics);
  539. // Switch again to false because we will show the box only if we have similar topics!
  540. $similar_topics_enabled = false;
  541. if ($count_similar > 0)
  542. {
  543. $similar_topics_enabled = true;
  544. }
  545. }
  546. // Similar Topics - END
  547. //if ($config['switch_poster_info_topic'] == true)
  548. // Use the above code if you want even guests to be shown the extra info
  549. if ($config['switch_poster_info_topic'] && $user->data['session_logged_in'] && !$user->data['is_bot'])
  550. {
  551. $parse_extra_user_info = true;
  552. // Query Styles
  553. $styles = $cache->obtain_styles(true);
  554. foreach ($styles as $k => $v)
  555. {
  556. $styles_list_id[] = $k;
  557. $styles_list_name[] = $v;
  558. }
  559. }
  560. else
  561. {
  562. $parse_extra_user_info = false;
  563. }
  564. // Activity - BEGIN
  565. if (!empty($config['plugins']['activity']['enabled']) && !$user->data['is_bot'])
  566. {
  567. $activity_sql = ', u.user_trophies, u.ina_char_name';
  568. }
  569. else
  570. {
  571. $activity_sql = '';
  572. }
  573. // Activity - END
  574. // Go ahead and pull all data for this topic
  575. // Self AUTH - BEGIN
  576. $self_sql_tables = (intval($is_auth['auth_read']) == AUTH_SELF) ? ', ' . USERS_TABLE . ' u2' : '';
  577. $self_sql = (intval($is_auth['auth_read']) == AUTH_SELF) ? " AND t.topic_poster = u2.user_id AND (u2.user_id = '" . $user->data['user_id'] . "' OR t.topic_type = '" . POST_GLOBAL_ANNOUNCE . "' OR t.topic_type = '" . POST_ANNOUNCE . "' OR t.topic_type = '" . POST_STICKY . "')" : '';
  578. // Self AUTH - END
  579. $user_sn_im_array = get_user_sn_im_array();
  580. $sn_im_sql = '';
  581. foreach ($user_sn_im_array as $k => $v)
  582. {
  583. $sn_im_sql .= ', u.' . $v['field'];
  584. }
  585. $sql = "SELECT u.username, u.user_id, u.user_active, u.user_mask, u.user_color, u.user_first_name, u.user_last_name, u.user_posts, u.user_from, u.user_from_flag, u.user_website, u.user_email, u.user_regdate, u.user_allow_viewemail, u.user_rank, u.user_rank2, u.user_rank3, u.user_rank4, u.user_rank5, u.user_sig, u.user_avatar, u.user_avatar_type, u.user_allowavatar, u.user_allowsmile, u.user_allow_viewonline, u.user_session_time, u.user_warnings, u.user_level, u.user_birthday, u.user_next_birthday_greeting, u.user_gender, u.user_personal_pics_count, u.user_style, u.user_lang" . $sn_im_sql . $activity_sql . $profile_data_sql . ", u.ct_miserable_user, p.*, t.topic_poster, t.topic_label_compiled
  586. FROM " . POSTS_TABLE . " p, " . USERS_TABLE . " u, " . TOPICS_TABLE . " t" . $self_sql_tables . "
  587. WHERE p.topic_id = $topic_id
  588. AND t.topic_id = p.topic_id
  589. AND u.user_id = p.poster_id
  590. " . $limit_posts_time . "
  591. " . $self_sql . "
  592. ORDER BY " . $sort_key_sql . " " . $sort_dir_sql . "
  593. LIMIT " . $limit_sql_insert . $config['posts_per_page'];
  594. // MG Cash MOD For IP - BEGIN
  595. if (!empty($config['plugins']['cash']['enabled']))
  596. {
  597. $cm_viewtopic->generate_columns($template, $forum_id, $sql);
  598. }
  599. // MG Cash MOD For IP - END
  600. $result = $db->sql_query($sql);
  601. $postrow = array();
  602. if ($row = $db->sql_fetchrow($result))
  603. {
  604. do
  605. {
  606. if($row['user_id'] > 0)
  607. {
  608. $user_ids[$row['user_id']] = $row['username'];
  609. }
  610. $postrow[] = $row;
  611. }
  612. while ($row = $db->sql_fetchrow($result));
  613. $db->sql_freeresult($result);
  614. $total_posts = sizeof($postrow);
  615. }
  616. else
  617. {
  618. if (!class_exists('class_mcp')) include(IP_ROOT_PATH . 'includes/class_mcp.' . PHP_EXT);
  619. if (empty($class_mcp)) $class_mcp = new class_mcp();
  620. $class_mcp->sync('topic', $topic_id);
  621. message_die(GENERAL_MESSAGE, $lang['No_posts_topic']);
  622. }
  623. if (($total_posts == 1) && !empty($config['robots_index_topics_no_replies']))
  624. {
  625. define('ROBOTS_NOINDEX', true);
  626. }
  627. $resync = false;
  628. if (($forum_topic_data['topic_replies'] + 1) < ($start + sizeof($postrow)))
  629. {
  630. $resync = true;
  631. }
  632. elseif (($start + $config['posts_per_page']) > $forum_topic_data['topic_replies'])
  633. {
  634. $row_id = intval($forum_topic_data['topic_replies']) % intval($config['posts_per_page']);
  635. if ($postrow[$row_id]['post_id'] != $forum_topic_data['topic_last_post_id'] || $start + sizeof($postrow) < $forum_topic_data['topic_replies'])
  636. {
  637. $resync = true;
  638. }
  639. }
  640. elseif (sizeof($postrow) < $config['posts_per_page'])
  641. {
  642. $resync = true;
  643. }
  644. if ($resync)
  645. {
  646. if (!class_exists('class_mcp')) include(IP_ROOT_PATH . 'includes/class_mcp.' . PHP_EXT);
  647. if (empty($class_mcp)) $class_mcp = new class_mcp();
  648. $class_mcp->sync('topic', $topic_id);
  649. $sql = 'SELECT COUNT(post_id) AS total FROM ' . POSTS_TABLE . ' WHERE topic_id = ' . $topic_id;
  650. $result = $db->sql_query($sql);
  651. $row = $db->sql_fetchrow($result);
  652. $total_replies = $row['total'];
  653. }
  654. // Mighty Gorgon - Multiple Ranks - BEGIN
  655. $ranks_array = $cache->obtain_ranks(false);
  656. // Mighty Gorgon - Multiple Ranks - END
  657. // Was a highlight request part of the URI?
  658. $highlight_match = '';
  659. $highlight = '';
  660. $highlight_words = request_var('highlight', '');
  661. $highlight_words = htmlspecialchars_decode($highlight_words, ENT_COMPAT);
  662. if (!empty($highlight_words))
  663. {
  664. $highlight_words = addslashes(preg_replace('#[][\\/%():><{}`]#', ' ', $highlight_words));
  665. // Split words and phrases
  666. $words = explode(' ', trim(htmlspecialchars($highlight_words)));
  667. for($i = 0; $i < sizeof($words); $i++)
  668. {
  669. if (trim($words[$i]) != '')
  670. {
  671. $highlight_match .= (($highlight_match != '') ? '|' : '') . str_replace('*', '\w*', preg_quote($words[$i], '#'));
  672. }
  673. }
  674. unset($words);
  675. $highlight = urlencode($highlight_words);
  676. $highlight_match = rtrim($highlight_match, "\\");
  677. }
  678. // Post, reply and other URL generation for templating vars
  679. $new_topic_url = append_sid('posting.' . PHP_EXT . '?mode=newtopic&amp;' . $forum_id_append);
  680. $reply_topic_url = append_sid('posting.' . PHP_EXT . '?mode=reply&amp;' . $forum_id_append . '&amp;' . $topic_id_append);
  681. $view_forum_url = append_sid(CMS_PAGE_VIEWFORUM . '?' . POST_FORUM_URL . '=' . $forum_id . $kb_mode_append);
  682. $view_prev_topic_url = append_sid(CMS_PAGE_VIEWTOPIC . '?' . $forum_id_append . '&amp;' . $topic_id_append . $kb_mode_append . '&amp;view=previous');
  683. $view_next_topic_url = append_sid(CMS_PAGE_VIEWTOPIC . '?' . $forum_id_append . '&amp;' . $topic_id_append . $kb_mode_append . '&amp;view=next');
  684. // Mozilla navigation bar
  685. //SEO TOOLKIT BEGIN
  686. $nav_links['prev'] = array(
  687. 'url' => $view_prev_topic_url,
  688. 'title' => $lang['View_previous_topic']
  689. );
  690. $nav_links['next'] = array(
  691. 'url' => $view_next_topic_url,
  692. 'title' => $lang['View_next_topic']
  693. );
  694. $nav_links['up'] = array(
  695. 'url' => $view_forum_url,
  696. 'title' => $forum_name
  697. );
  698. //SEO TOOLKIT END
  699. $is_this_locked = (($forum_topic_data['forum_status'] == FORUM_LOCKED) || ($forum_topic_data['topic_status'] == TOPIC_LOCKED)) ? true : false;
  700. $reply_img = $is_this_locked ? $images['reply_locked'] : $images['reply_new'];
  701. $reply_alt = $is_this_locked ? $lang['Topic_locked'] : $lang['Reply_to_topic'];
  702. $post_img = ($forum_topic_data['forum_status'] == FORUM_LOCKED) ? $images['post_locked'] : $images['post_new'];
  703. $post_alt = ($forum_topic_data['forum_status'] == FORUM_LOCKED) ? $lang['Forum_locked'] : $lang['Post_new_topic'];
  704. if(!$user->data['session_logged_in'] || !$is_auth['auth_reply'] || ($is_this_locked && !$is_auth['auth_mod']) || $user->data['is_bot'])
  705. {
  706. $can_reply = false;
  707. }
  708. else
  709. {
  710. $can_reply = true;
  711. $template->assign_var('S_CAN_REPLY', true);
  712. }
  713. // Set a cookie for this topic
  714. if ($user->data['session_logged_in'] && !$user->data['is_bot'])
  715. {
  716. $tracking_forums = (isset($_COOKIE[$config['cookie_name'] . '_f'])) ? unserialize($_COOKIE[$config['cookie_name'] . '_f']) : array();
  717. $tracking_topics = (isset($_COOKIE[$config['cookie_name'] . '_t'])) ? unserialize($_COOKIE[$config['cookie_name'] . '_t']) : array();
  718. if (!empty($tracking_topics[$topic_id]) && !empty($tracking_forums[$forum_id]))
  719. {
  720. $topic_last_read = ($tracking_topics[$topic_id] > $tracking_forums[$forum_id]) ? $tracking_topics[$topic_id] : $tracking_forums[$forum_id];
  721. }
  722. elseif (!empty($tracking_topics[$topic_id]) || !empty($tracking_forums[$forum_id]))
  723. {
  724. $topic_last_read = (!empty($tracking_topics[$topic_id])) ? $tracking_topics[$topic_id] : $tracking_forums[$forum_id];
  725. }
  726. else
  727. {
  728. $topic_last_read = $user->data['user_lastvisit'];
  729. }
  730. if ((sizeof($tracking_topics) >= 150) && empty($tracking_topics[$topic_id]))
  731. {
  732. asort($tracking_topics);
  733. unset($tracking_topics[key($tracking_topics)]);
  734. }
  735. $tracking_topics[$topic_id] = time();
  736. $user->set_cookie('t', serialize($tracking_topics), $user->cookie_expire);
  737. }
  738. // UPI2DB - BEGIN
  739. if($user->data['upi2db_access'])
  740. {
  741. $unread_new_posts = 0;
  742. $unread_edit_posts = 0;
  743. for($i = 0; $i < $total_posts; $i++)
  744. {
  745. if (sizeof($user->data['upi2db_unread'][$topic_id]['new_posts']) && in_array($postrow[$i]['post_id'], $user->data['upi2db_unread'][$topic_id]['new_posts']))
  746. {
  747. ++$unread_new_posts;
  748. }
  749. if (sizeof($user->data['upi2db_unread'][$topic_id]['edit_posts']) && in_array($postrow[$i]['post_id'], $user->data['upi2db_unread'][$topic_id]['edit_posts']))
  750. {
  751. ++$unread_edit_posts;
  752. }
  753. }
  754. }
  755. // UPI2DB - END
  756. $template_to_parse = ($kb_mode) ? 'viewtopic_kb_body.tpl' : 'viewtopic_body.tpl';
  757. // Needed for attachments... do not remove!
  758. $template->set_filenames(array('body' => $template_to_parse));
  759. make_jumpbox(CMS_PAGE_VIEWFORUM, $forum_id);
  760. // Output page header
  761. if ($config['display_viewonline'])
  762. {
  763. define('SHOW_ONLINE', true);
  764. }
  765. //$meta_content['page_title'] = $meta_content['forum_name'] . ' :: ' . $topic_title_plain;
  766. //$meta_content['page_title'] = str_replace(array('"'), array('\"'), htmlspecialchars_decode($topic_title_plain));
  767. $meta_content['page_title'] = $topic_title_plain;
  768. $meta_content['page_title_clean'] = $topic_title_plain;
  769. $template->assign_var('S_VIEW_TOPIC', true);
  770. if ($config['show_icons'] == true)
  771. {
  772. $template->assign_var('S_SHOW_ICONS', true);
  773. }
  774. else
  775. {
  776. $template->assign_var('S_SHOW_LINKS', true);
  777. }
  778. if ($similar_topics_enabled)
  779. {
  780. include(IP_ROOT_PATH . 'includes/similar_topics.' . PHP_EXT);
  781. }
  782. // User authorization levels output
  783. // Self AUTH - BEGIN
  784. $lang['Rules_reply_can'] = ((intval($is_auth['auth_reply']) == AUTH_SELF) ? $lang['Rules_reply_can_own'] : $lang['Rules_reply_can']);
  785. // Self AUTH - END
  786. $s_auth_can = ($is_auth['auth_post'] ? $lang['Rules_post_can'] : $lang['Rules_post_cannot']) . '<br />';
  787. $s_auth_can .= ($is_auth['auth_reply'] ? $lang['Rules_reply_can'] : $lang['Rules_reply_cannot']) . '<br />';
  788. $s_auth_can .= ($is_auth['auth_edit'] ? $lang['Rules_edit_can'] : $lang['Rules_edit_cannot']) . '<br />';
  789. $s_auth_can .= ($is_auth['auth_delete'] ? $lang['Rules_delete_can'] : $lang['Rules_delete_cannot']) . '<br />';
  790. $s_auth_can .= ($is_auth['auth_vote'] ? $lang['Rules_vote_can'] : $lang['Rules_vote_cannot']) . '<br />';
  791. if (intval($config['disable_attachments_mod']) == 0)
  792. {
  793. $s_auth_can .= ($is_auth['auth_attachments'] ? $lang['Rules_attach_can'] : $lang['Rules_attach_cannot']) . '<br />';
  794. $s_auth_can .= ($is_auth['auth_download'] ? $lang['Rules_download_can'] : $lang['Rules_download_cannot']) . '<br />';
  795. }
  796. $s_auth_can .= ($is_auth['auth_cal'] ? $lang['Rules_calendar_can'] : $lang['Rules_calendar_cannot']) . '<br />';
  797. $s_auth_can .= ($is_auth['auth_ban'] ? $lang['Rules_ban_can'] . '<br />' : '');
  798. $s_auth_can .= ($is_auth['auth_greencard'] ? $lang['Rules_greencard_can'] . '<br />' : '');
  799. $s_auth_can .= ($is_auth['auth_bluecard'] ? $lang['Rules_bluecard_can'] . '<br />' : '');
  800. //attach_build_auth_levels($is_auth, $s_auth_can);
  801. $topic_mod = '';
  802. $topic_mod_switch = false;
  803. if ($is_auth['auth_mod'])
  804. {
  805. $topic_mod_switch = true;
  806. $s_auth_can .= sprintf($lang['Rules_moderate'], '<a href="modcp.' . PHP_EXT . '?' . $forum_id_append . '&amp;sid=' . $user->data['session_id'] . '">', '</a>');
  807. // Full string to append as a reference for FORUM TOPIC POST (FTP)
  808. $full_ftp_append = (($forum_id_append == '') ? '' : ($forum_id_append . '&amp;')) . (($topic_id_append == '') ? '' : ($topic_id_append . '&amp;')) . (($post_id_append == '') ? '' : ($post_id_append . '&amp;'));
  809. if ($lofi)
  810. {
  811. if ($config['bin_forum'] != false)
  812. {
  813. $topic_mod .= '<a href="bin.' . PHP_EXT . '?' . $full_ftp_append . 'sid=' . $user->data['session_id'] . '" title="' . $lang['Move_bin'] . '">' . $lang['Move_bin'] . '</a>&nbsp;&bull;&nbsp;';
  814. }
  815. $topic_mod .= '<a href="modcp.' . PHP_EXT . '?' . $full_ftp_append . 'mode=delete&amp;sid=' . $user->data['session_id'] . '" title="' . $lang['Delete_topic'] . '">' . $lang['Delete_topic'] . '</a>&nbsp;&bull;&nbsp;';
  816. $topic_mod .= '<a href="modcp.' . PHP_EXT . '?' . $full_ftp_append . 'mode=move&amp;sid=' . $user->data['session_id'] . '" title="' . $lang['Move_topic'] . '">' . $lang['Move_topic'] . '</a>&nbsp;<br />';
  817. $topic_mod .= (($forum_topic_data['topic_status'] == TOPIC_UNLOCKED) ? '<a href="modcp.' . PHP_EXT . '?' . $full_ftp_append . 'mode=lock&amp;sid=' . $user->data['session_id'] . '" title="' . $lang['Lock_topic'] . '">' . $lang['Lock_topic'] . '</a>' : '<a href="modcp.' . PHP_EXT . '?' . $full_ftp_append . 'mode=unlock&amp;sid=' . $user->data['session_id'] . '" title="' . $lang['Unlock_topic'] . '">' . $lang['Unlock_topic'] . '</a>') . '&nbsp;&bull;&nbsp;';
  818. $topic_mod .= '<a href="modcp.' . PHP_EXT . '?' . $full_ftp_append . 'mode=split&amp;sid=' . $user->data['session_id'] . '" title="' . $lang['Split_topic'] . '">' . $lang['Split_topic'] . '</a>&nbsp;&bull;&nbsp;';
  819. $topic_mod .= '<a href="modcp.' . PHP_EXT . '?' . $full_ftp_append . 'mode=merge&amp;sid=' . $user->data['session_id'] . '" title="' . $lang['Merge_topic'] . '">' . $lang['Merge_topic'] . '</a>&nbsp;<br />';
  820. }
  821. else
  822. {
  823. if ($config['bin_forum'] != false)
  824. {
  825. $topic_mod .= '<span class="img-btn"><a href="bin.' . PHP_EXT . '?' . $full_ftp_append . 'sid=' . $user->data['session_id'] . '"><img src="' . $images['topic_mod_bin'] . '" alt="' . $lang['Move_bin'] . '" title="' . $lang['Move_bin'] . '" /></a></span>&nbsp;';
  826. }
  827. $topic_mod .= '<span class="img-btn"><a href="modcp.' . PHP_EXT . '?' . $full_ftp_append . 'mode=delete&amp;sid=' . $user->data['session_id'] . '" ><img src="' . $images['topic_mod_delete'] . '" alt="' . $lang['Delete_topic'] . '" title="' . $lang['Delete_topic'] . '" /></a></span>&nbsp;';
  828. $topic_mod .= '<span class="img-btn"><a href="modcp.' . PHP_EXT . '?' . $full_ftp_append . 'mode=move&amp;sid=' . $user->data['session_id'] . '"><img src="' . $images['topic_mod_move'] . '" alt="' . $lang['Move_topic'] . '" title="' . $lang['Move_topic'] . '" /></a></span>&nbsp;';
  829. $topic_mod .= ($forum_topic_data['topic_status'] == TOPIC_UNLOCKED) ? '<span class="img-btn"><a href="modcp.' . PHP_EXT . '?' . $full_ftp_append . 'mode=lock&amp;sid=' . $user->data['session_id'] . '"><img src="' . $images['topic_mod_lock'] . '" alt="' . $lang['Lock_topic'] . '" title="' . $lang['Lock_topic'] . '" /></a></span>&nbsp;' : '<span class="img-btn"><a href="modcp.' . PHP_EXT . '?' . $full_ftp_append . 'mode=unlock&amp;sid=' . $user->data['session_id'] . '"><img src="' . $images['topic_mod_unlock'] . '" alt="' . $lang['Unlock_topic'] . '" title="' . $lang['Unlock_topic'] . '" /></a></span>&nbsp;';
  830. $topic_mod .= '<span class="img-btn"><a href="modcp.' . PHP_EXT . '?' . $full_ftp_append . 'mode=split&amp;sid=' . $user->data['session_id'] . '"><img src="' . $images['topic_mod_split'] . '" alt="' . $lang['Split_topic'] . '" title="' . $lang['Split_topic'] . '" /></a></span>&nbsp;';
  831. $topic_mod .= '<span class="img-btn"><a href="modcp.' . PHP_EXT . '?' . $full_ftp_append . 'mode=merge&amp;sid=' . $user->data['session_id'] . '"><img src="' . $images['topic_mod_merge'] . '" alt="' . $lang['Merge_topic'] . '" title="' . $lang['Merge_topic'] . '" /></a></span>&nbsp;<br /><br />';
  832. $global_button = ($is_auth['auth_globalannounce']) ? '<span class="img-btn"><a href="modcp.' . PHP_EXT . '?' . $full_ftp_append . 'mode=super_announce&amp;sid=' . $user->data['session_id'] . '"><img src="' . $images['gannounce_post'] . '" alt="' . $lang['Mod_CP_global'] . '" title="' . $lang['Mod_CP_global2'] . '" /></a></span>&nbsp;' : '';
  833. $announce_button = ($is_auth['auth_announce']) ? '<span class="img-btn"><a href="modcp.' . PHP_EXT . '?' . $full_ftp_append . 'mode=announce&amp;sid=' . $user->data['session_id'] . '"><img src="' . $images['announce_post'] . '" alt="' . $lang['Mod_CP_announce'] . '" title="' . $lang['Mod_CP_announce2'] . '" /></a></span>&nbsp;' : '';
  834. $sticky_button = ($is_auth['auth_sticky']) ? '<span class="img-btn"><a href="modcp.' . PHP_EXT . '?' . $full_ftp_append . 'mode=sticky&amp;sid=' . $user->data['session_id'] . '"><img src="' . $images['sticky_post'] . '" alt="' . $lang['Mod_CP_sticky'] . '" title="' . $lang['Mod_CP_sticky2'] . '" /></a></span>&nbsp;' : '';
  835. $normal_button = '<span class="img-btn"><a href="modcp.' . PHP_EXT . '?' . $full_ftp_append . 'mode=normalize&amp;sid=' . $user->data['session_id'] . '"><img src="' . $images['normal_post'] . '" alt="' . $lang['Mod_CP_normal'] . '" title="' . $lang['Mod_CP_normal2'] . '" /></a></span>&nbsp;';
  836. $s_tmod_topic_global = false;
  837. $s_tmod_topic_announce = false;
  838. $s_tmod_topic_sticky = false;
  839. $s_tmod_topic_normal = false;
  840. switch($forum_topic_data['topic_type'])
  841. {
  842. case POST_NORMAL:
  843. $s_tmod_topic_normal = true;
  844. $topic_mod .= $global_button . $announce_button . $sticky_button;
  845. break;
  846. case POST_STICKY:
  847. $s_tmod_topic_sticky = true;
  848. $topic_mod .= $global_button . $announce_button . $normal_button;
  849. break;
  850. case POST_ANNOUNCE:
  851. $s_tmod_topic_announce = true;
  852. $topic_mod .= $global_button . $sticky_button . $normal_button;
  853. break;
  854. case POST_GLOBAL_ANNOUNCE:
  855. $s_tmod_topic_global = true;
  856. $topic_mod .= $announce_button . $sticky_button . $normal_button;
  857. break;
  858. }
  859. }
  860. }
  861. // Topics Labels - BEGIN
  862. //if (!(($user->data['user_level'] == 0) && ($user->data['user_id'] != $row['topic_poster'])))
  863. if ($is_auth['auth_edit'] || ($user->data['user_id'] == $row['topic_poster']))
  864. {
  865. $topics_labels_select = $class_topics->gen_topics_labels_select();
  866. $topic_labels_block = '<form action="modcp.' . PHP_EXT . '?sid=' . $user->data['session_id'] . '" method="post"><br /><br />';
  867. $topic_labels_block .= $topics_labels_select;
  868. $topic_labels_block .= '<input type="submit" name="label_edit" class="liteoption" value="' . $lang['TOPIC_LABEL'] . '"/>';
  869. $topic_labels_block .= '<input type="hidden" name="' . POST_FORUM_URL . '" value="' . $forum_id . '"/>';
  870. $topic_labels_block .= '<input type="hidden" name="' . POST_TOPIC_URL . '" value="' . $topic_id . '"/>';
  871. $topic_labels_block .= '</form>';
  872. $topic_mod .= $topic_labels_block;
  873. }
  874. // Topics Labels - END
  875. $s_kb_mode_url = append_sid(CMS_PAGE_VIEWTOPIC . '?' . $forum_id_append . '&amp;' . $topic_id_append . '&amp;kb=' . (!empty($kb_mode) ? 'off' : 'on') . '&amp;start=' . $start);
  876. $s_kb_mode_l = (!empty($kb_mode) ? $lang['KB_MODE_OFF'] : $lang['KB_MODE_ON']);
  877. $s_kb_mode = '<a href="' . $s_kb_mode_url . '">' . $s_kb_mode_l . '</a>';
  878. $s_kb_mode_img_tmp = (!empty($kb_mode) ? $images['topic_kb_off'] : $images['topic_kb_on']);
  879. $s_kb_mode_img = (!empty($s_kb_mode_img_tmp)) ? '<a href="' . $s_kb_mode_url . '"><img src="' . $s_kb_mode_img_tmp . '" alt="' . $s_kb_mode_l . '" title="' . $s_kb_mode_l . '" /></a>' : '';
  880. // Topic watch information
  881. $s_watching_topic = '';
  882. if ($can_watch_topic)
  883. {
  884. $s_watching_topic_url = append_sid(CMS_PAGE_VIEWTOPIC . '?' . $forum_id_append . '&amp;' . $topic_id_append . $kb_mode_append . '&amp;' . (!empty($is_watching_topic) ? 'unwatch' : 'watch') . '=topic&amp;start=' . $start);
  885. $s_watching_topic_l = (!empty($is_watching_topic) ? $lang['Stop_watching_topic'] : $lang['Start_watching_topic']);
  886. $s_watching_topic = '<a href="' . $s_watching_topic_url . '">' . $s_watching_topic_l . '</a>';
  887. $s_watching_topic_img_tmp = (!empty($is_watching_topic) ? $images['topic_un_watch'] : $images['topic_watch']);
  888. $s_watching_topic_img = (!empty($s_watching_topic_img_tmp)) ? '<a href="' . $s_watching_topic_url . '"><img src="' . $s_watching_topic_img_tmp . '" alt="' . $s_watching_topic_l . '" title="' . $s_watching_topic_l . '" /></a>' : '';
  889. }
  890. // Bookmark information
  891. if ($user->data['session_logged_in'] && !$user->data['is_bot'])
  892. {
  893. $template->assign_block_vars('bookmark_state', array());
  894. // Send vars to template
  895. if (is_bookmark_set($topic_id))
  896. {
  897. $bookmark_img = $images['bookmark_remove'];
  898. $bm_action = '&amp;removebm=true';
  899. $set_rem_bookmark = $lang['Remove_Bookmark'];
  900. }
  901. else
  902. {
  903. $bookmark_img = $images['bookmark_add'];
  904. $bm_action = '&amp;setbm=true';
  905. $set_rem_bookmark = $lang['Set_Bookmark'];
  906. }
  907. $template->assign_vars(array(
  908. 'L_BOOKMARK_ACTION' => $set_rem_bookmark,
  909. 'IMG_BOOKMARK' => $bookmark_img,
  910. 'U_BOOKMARK_ACTION' => append_sid(CMS_PAGE_VIEWTOPIC . '?' . $forum_id_append . '&amp;' . $topic_id_append . $kb_mode_append . '&amp;start=' . $start . $vt_sort_append . '&amp;highlight=' . urlencode($_GET['highlight']) . $bm_action)
  911. )
  912. );
  913. }
  914. // UPI2DB - BEGIN
  915. if($user->data['upi2db_access'])
  916. {
  917. //$mark_always_read = mark_always_read($forum_topic_data['topic_type'], $topic_id, $forum_id, 'viewforum', 'txt', $user->data['upi2db_unread']);
  918. $s_mark_ar = mark_always_read_vt_ip($forum_topic_data['topic_type'], $topic_id, $forum_id, 'txt', $user->data['upi2db_unread']);
  919. $s_mark_ar_img = mark_always_read_vt_ip($forum_topic_data['topic_type'], $topic_id, $forum_id, 'img', $user->data['upi2db_unread']);
  920. }
  921. else
  922. {
  923. $mark_always_read = '';
  924. $s_mark_ar = '';
  925. $s_mark_ar_img = '';
  926. }
  927. // UPI2DB - END
  928. if ($total_replies > (10 * $config['posts_per_page']))
  929. {
  930. $template->assign_var('S_EXTENDED_PAGINATION', true);
  931. }
  932. // If we've got a hightlight set pass it on to pagination,
  933. // I get annoyed when I lose my highlight after the first page.
  934. $pagination = ($highlight != '') ? generate_pagination(CMS_PAGE_VIEWTOPIC . '?' . $forum_id_append . '&amp;' . $topic_id_append . $kb_mode_append . $vt_sort_append . '&amp;highlight=' . $highlight, $total_replies, $config['posts_per_page'], $start) : generate_pagination(CMS_PAGE_VIEWTOPIC . '?' . $forum_id_append . '&amp;' . $topic_id_append . $kb_mode_append . $vt_sort_append, $total_replies, $config['posts_per_page'], $start);
  935. $current_page = get_page($total_replies, $config['posts_per_page'], $start);
  936. $watch_topic_url = 'topic_view_users.' . PHP_EXT . '?' . $forum_id_append . '&amp;' . $topic_id_append;
  937. $rules_bbcode = '';
  938. if ($forum_topic_data['forum_rules_in_viewtopic'])
  939. {
  940. //BBcode Parsing for Olympus rules Start
  941. $rules_bbcode = $forum_topic_data['forum_rules'];
  942. $bbcode->allow_html = true;
  943. $bbcode->allow_bbcode = true;
  944. $bbcode->allow_smilies = true;
  945. $rules_bbcode = $bbcode->parse($rules_bbcode);
  946. //BBcode Parsing for Olympus rules Start
  947. $template->assign_vars(array(
  948. 'S_FORUM_RULES' => true,
  949. 'S_FORUM_RULES_TITLE' => ($forum_topic_data['forum_rules_display_title']) ? true : false
  950. )
  951. );
  952. }
  953. $topic_viewed_link = '';
  954. if (empty($config['disable_topic_view']) && ($forum_topic_data['forum_topic_views'] == 1) && ($user->data['user_level'] == ADMIN))
  955. {
  956. $topic_viewed_link = append_sid('topic_view_users.' . PHP_EXT . '?' . $forum_id_append . '&amp;' . $topic_id_append);
  957. }
  958. if ($config['show_social_bookmarks'])
  959. {
  960. $template->assign_block_vars('social_bookmarks', array());
  961. }
  962. if ($config['display_tags_box'])
  963. {
  964. @include_once(IP_ROOT_PATH . 'includes/class_topics_tags.' . PHP_EXT);
  965. $class_topics_tags = new class_topics_tags();
  966. $topic_tags_links = $class_topics_tags->build_tags_list(array($topic_id));
  967. $template->assign_vars(array(
  968. 'S_TOPIC_TAGS' => true,
  969. 'TOPIC_TAGS' => $topic_tags_links,
  970. )
  971. );
  972. }
  973. if ($config['enable_featured_image'])
  974. {
  975. $template->assign_var('S_FEATURED_IMAGE', true);
  976. }
  977. $topic_title_enc = urlencode(ip_utf8_decode($topic_title_plain));
  978. $topic_title_enc_utf8 = urlencode($topic_title_plain);
  979. // URL Rewrite - BEGIN
  980. // Rewrite Social Bookmars URLs if any of URL Rewrite rules has been enabled
  981. // Forum ID and KB Mode removed from topic_url_enc to avoid compatibility problems with redirects in tell a friend
  982. if (($config['url_rw'] == true) || ($config['url_rw_guests'] == true))
  983. {
  984. $topic_url = create_server_url() . make_url_friendly($topic_title_plain) . '-vt' . $topic_id . '.html' . ($kb_mode ? ('?' . $kb_mode_append) : '');
  985. }
  986. else
  987. {
  988. $topic_url = create_server_url() . ip_build_url(CMS_PAGE_VIEWTOPIC, array($forum_id_append, $topic_id_append), false) . $kb_mode_append_red;
  989. }
  990. $topic_url_ltt = htmlspecialchars($topic_url);
  991. $topic_url_enc = urlencode(ip_utf8_decode($topic_url));
  992. $topic_url_enc_utf8 = urlencode($topic_url);
  993. // URL Rewrite - END
  994. $current_page = (floor($start / intval($config['posts_per_page'])) + 1);
  995. $max_page = ceil($total_replies / intval($config['posts_per_page']));
  996. $ajax_post_data = array(
  997. 'S_TOPIC_URL_AFTER' => append_sid(CMS_PAGE_VIEWTOPIC . '?' . $forum_id_append . '&' . $topic_id_append . '&after_post_id='),
  998. 'L_WARN_NEW_POST' => $lang['Warn_new_post'],
  999. 'REFRESH_INTERVAL' => $config['auto_refresh_topic_interval'],
  1000. );
  1001. $template->assign_vars(array(
  1002. 'FORUM_ID' => $forum_id,
  1003. 'FORUM_ID_FULL' => POST_FORUM_URL . $forum_id,
  1004. 'FORUM_NAME' => $forum_name,
  1005. 'FORUM_RULES' => $rules_bbcode,
  1006. 'TOPIC_ID' => $topic_id,
  1007. 'TOPIC_ID_FULL' => POST_TOPIC_URL . $topic_id,
  1008. 'TOPIC_TITLE' => $topic_title,
  1009. 'TOPIC_TITLE_PLAIN' => $topic_title_plain,
  1010. 'TOPIC_TITLE_SHORT' => $topic_title_short,
  1011. 'TOPIC_TITLE_QR' => str_replace(array('"'), array('\"'), htmlspecialchars_decode($topic_title_plain)),
  1012. 'TOPIC_POSTED_TIME' => $topic_started,
  1013. 'TOPIC_AUTHOR_NAME' => $topic_username,
  1014. 'TOPIC_AUTHOR_AVATAR' => $topic_avatar_img,
  1015. 'TOPIC_AUTHOR_FROM' => $topic_user_from_flag,
  1016. 'TOPIC_AUTHOR_GENDER' => $topic_user_gender_image,
  1017. 'TOPIC_AUTHOR_JOINED' => $topic_user_joined,
  1018. 'TOPIC_AUTHOR_POSTS' => $topic_user_posts,
  1019. 'TOPIC_VIEWS' => $forum_topic_data['topic_views'],
  1020. 'TOPIC_REPLIES' => $forum_topic_data['topic_replies'],
  1021. 'PAGINATION' => $pagination,
  1022. 'CURRENT_PAGE_NUMBER' => $current_page,
  1023. 'MAX_PAGE_NUMBER' => $max_page,
  1024. 'IS_LAST_PAGE' => ($current_page == $max_page) ? 1 : 0,
  1025. 'PAGE_NUMBER' => sprintf($lang['Page_of'], $current_page, $max_page),
  1026. 'AJAX_POST_DATA' => json_encode($ajax_post_data),
  1027. 'POST_IMG' => $post_img,
  1028. 'REPLY_IMG' => $reply_img,
  1029. 'IS_LOCKED' => $is_this_locked,
  1030. 'TOPIC_TITLE_ENC' => $topic_title_enc,
  1031. 'TOPIC_TITLE_ENC_UTF8' => $topic_title_enc_utf8,
  1032. 'TOPIC_URL_ENC' => $topic_url_enc,
  1033. 'TOPIC_URL_ENC_UTF8' => $topic_url_enc_utf8,
  1034. 'TOPIC_URL_LTT' => $topic_url_ltt,
  1035. 'L_DOWNLOAD_POST' => $lang['Download_post'],
  1036. 'L_DOWNLOAD_TOPIC' => $lang['Download_topic'],
  1037. 'DOWNLOAD_TOPIC' => append_sid(CMS_PAGE_VIEWTOPIC . '?download=-1&amp;' . $forum_id_append . '&amp;' . $topic_id_append),
  1038. 'U_TELL' => append_sid('tellafriend.' . PHP_EXT . '?topic_title=' . $topic_title_enc . '&amp;topic_id=' . $topic_id),
  1039. 'L_PRINT' => $lang['Print_View'],
  1040. 'U_PRINT' => append_sid('printview.' . PHP_EXT . '?' . $forum_id_append . '&amp;' . $topic_id_append . '&amp;start=' . $start),
  1041. 'L_SHARE_TOPIC' => $lang['ShareThisTopic'],
  1042. 'L_REPLY_NEWS' => $lang['News_Reply'],
  1043. 'L_PRINT_NEWS' => $lang['News_Print'],
  1044. 'L_EMAIL_NEWS' => $lang['News_Email'],
  1045. 'MINIPOST_IMG' => $images['icon_minipost'],
  1046. 'IMG_FLOPPY' => $images['floppy2'],
  1047. 'IMG_REPLY' => $images['news_reply'],
  1048. 'IMG_RECENT_TOPICS' => $images['recent_topics'],
  1049. 'IMG_PRINT' => $images['printer_topic'],
  1050. 'IMG_VIEWED' => $images['topic_viewed'],
  1051. 'IMG_EMAIL' => $images['email_topic'],
  1052. 'IMG_LEFT' => $images['icon_previous'],
  1053. 'IMG_RIGHT' => $images['icon_next'],
  1054. 'IMG_ARU' => $images['arrow_rounded_up'],
  1055. 'IMG_ARR' => $images['arrow_rounded_right'],
  1056. 'IMG_ARD' => $images['arrow_rounded_down'],
  1057. 'IMG_ARL' => $images['arrow_rounded_left'],
  1058. 'L_AUTHOR' => $lang['Author'],
  1059. 'L_MESSAGE' => $lang['Message'],
  1060. 'L_ARTICLE' => $lang['Article'],
  1061. 'L_COMMENTS' => $lang['Comments'],
  1062. 'L_POSTED' => $lang['Posted'],
  1063. 'L_REPLIES' => $lang['Replies'],
  1064. 'L_VIEWS' => $lang['Views'],
  1065. 'L_POST_SUBJECT' => $lang['Post_subject'],
  1066. 'L_VIEW_NEXT_TOPIC' => $lang['View_next_topic'],
  1067. 'L_VIEW_PREVIOUS_TOPIC' => $lang['View_previous_topic'],
  1068. 'L_GO_TO_PAGE_NUMBER' => $lang['Go_To_Page_Number'],
  1069. 'L_POST_NEW_TOPIC' => $post_alt,
  1070. 'L_POST_REPLY_TOPIC' => $reply_alt,
  1071. 'L_POST_QUOTE' => $lang['Reply_with_quote'],
  1072. 'L_POST_EDIT' => $lang['Edit_delete_post'],
  1073. 'L_POST_DELETE' => $lang['Delete_post'],
  1074. 'L_TOPIC_VIEWED' => $lang['Topic_view_users'],
  1075. 'L_USER_IP' => $lang['View_IP'],
  1076. 'L_QUICK_REPLY' => $lang['Quick_Reply'],
  1077. 'L_QUICK_QUOTE' => $lang['QuickQuote'],
  1078. 'L_OFFTOPIC' => $lang['OffTopic'],
  1079. 'L_BACK_TO_TOP' => $lang['Back_to_top'],
  1080. 'L_DISPLAY_POSTS' => $lang['Display_posts'],
  1081. 'L_LOCK_TOPIC' => $lang['Lock_topic'],
  1082. 'L_UNLOCK_TOPIC' => $lang['Unlock_topic'],
  1083. 'L_MOVE_TOPIC' => $lang['Move_topic'],
  1084. 'L_SPLIT_TOPIC' => $lang['Split_topic'],
  1085. 'L_DELETE_TOPIC' => $lang['Delete_topic'],
  1086. 'L_GOTO_PAGE' => $lang['Goto_page'],
  1087. 'L_FORUM_RULES' => (empty($forum_topic_data['forum_rules_custom_title'])) ? $lang['Forum_Rules'] : $forum_topic_data['forum_rules_custom_title'],
  1088. 'L_PERMISSIONS_LIST' => $lang['Permissions_List'],
  1089. 'L_TELL' => $lang['TELL_FRIEND'],
  1090. 'L_TOPIC_RATING' => $lang['TopicUseful'],
  1091. 'L_USER_ALBUM' => $lang['Show_Personal_Gallery'],
  1092. 'L_USER_WWW' => $lang['Website'],
  1093. 'L_USER_EMAIL' => $lang['Send_Email'],
  1094. 'L_USER_PROFILE' => $lang['Profile'],
  1095. 'L_PM' => $lang['Private_Message'],
  1096. 'L_SMILEYS' => $lang['Emoticons'],
  1097. 'L_SMILEYS_MORE' => $lang['More_emoticons'],
  1098. 'U_SMILEYS_MORE' => append_sid('posting.' . PHP_EXT . '?mode=smilies'),
  1099. 'IMG_QUICK_QUOTE' => $images['icon_quick_quote'],
  1100. 'IMG_OFFTOPIC' => $images['icon_offtopic'],
  1101. 'S_TMOD_BUTTONS' => !empty($topic_mod_switch) ? true : false,
  1102. 'S_TMOD_BIN' => !empty($config['bin_forum']) ? true : false,
  1103. 'S_TMOD_TOPIC_LABELS_BLOCK' => $topic_labels_block,
  1104. 'S_TMOD_TOPIC_UNLOCKED' => ($forum_topic_data['topic_status'] == TOPIC_UNLOCKED) ? true : false,
  1105. 'S_TMOD_TOPIC_GLOBAL' => !empty($s_tmod_topic_global) ? true : false,
  1106. 'S_TMOD_TOPIC_GLOBAL_AUTH' => $is_auth['auth_globalannounce'] ? true : false,
  1107. 'S_TMOD_TOPIC_ANNOUNCE' => !empty($s_tmod_topic_announce) ? true : false,
  1108. 'S_TMOD_TOPIC_ANNOUNCE_AUTH' => $is_auth['auth_announce'] ? true : false,
  1109. 'S_TMOD_TOPIC_STICKY' => !empty($s_tmod_topic_sticky) ? true : false,
  1110. 'S_TMOD_TOPIC_STICKY_AUTH' => $is_auth['auth_sticky'] ? true : false,
  1111. 'S_TMOD_TOPIC_NORMAL' => !empty($s_tmod_topic_normal) ? true : false,
  1112. 'L_TMOD_BIN' => $lang['Move_bin'],
  1113. 'L_TMOD_DELETE' => $lang['Delete_topic'],
  1114. 'L_TMOD_MOVE' => $lang['Move_topic'],
  1115. 'L_TMOD_LOCK' => $lang['Lock_topic'],
  1116. 'L_TMOD_UNLOCK' => $lang['Unlock_topic'],
  1117. 'L_TMOD_SPLIT' => $lang['Split_topic'],
  1118. 'L_TMOD_MERGE' => $lang['Merge_topic'],
  1119. 'L_TMOD_T_GLOBAL' => $lang['Mod_CP_global'],
  1120. 'L_TMOD_T_GLOBAL_T' => $lang['Mod_CP_global2'],
  1121. 'L_TMOD_T_ANNOUNCE' => $lang['Mod_CP_announce'],
  1122. 'L_TMOD_T_ANNOUNCE_T' => $lang['Mod_CP_announce2'],
  1123. 'L_TMOD_T_STICKY' => $lang['Mod_CP_sticky'],
  1124. 'L_TMOD_T_STICKY_T' => $lang['Mod_CP_sticky2'],
  1125. 'L_TMOD_T_NORMAL_T' => $lang['Mod_CP_normal2'],
  1126. 'U_TMOD_BIN' => 'bin.' . PHP_EXT . '?' . $full_ftp_append . 'sid=' . $user->data['session_id'],
  1127. 'U_TMOD_DELETE' => 'modcp.' . PHP_EXT . '?' . $full_ftp_append . 'mode=delete&amp;sid=' . $user->data['session_id'],
  1128. 'U_TMOD_MOVE' => 'modcp.' . PHP_EXT . '?' . $full_ftp_append . 'mode=move&amp;sid=' . $user->data['session_id'],
  1129. 'U_TMOD_LOCK' => 'modcp.' . PHP_EXT . '?' . $full_ftp_append . 'mode=lock&amp;sid=' . $user->data['session_id'],
  1130. 'U_TMOD_UNLOCK' => 'modcp.' . PHP_EXT . '?' . $full_ftp_append . 'mode=unlock&amp;sid=' . $user->data['session_id'],
  1131. 'U_TMOD_SPLIT' => 'modcp.' . PHP_EXT . '?' . $full_ftp_append . 'mode=split&amp;sid=' . $user->data['session_id'],
  1132. 'U_TMOD_MERGE' => 'modcp.' . PHP_EXT . '?' . $full_ftp_append . 'mode=merge&amp;sid=' . $user->data['session_id'],
  1133. 'U_TMOD_T_GLOBAL' => 'modcp.' . PHP_EXT . '?' . $full_ftp_append . 'mode=super_announce&amp;sid=' . $user->data['session_id'],
  1134. 'U_TMOD_T_ANNOUNCE' => 'modcp.' . PHP_EXT . '?' . $full_ftp_append . 'mode=announce&amp;sid=' . $user->data['session_id'],
  1135. 'U_TMOD_T_STICKY' => 'modcp.' . PHP_EXT . '?' . $full_ftp_append . 'mode=sticky&amp;sid=' . $user->data['session_id'],
  1136. 'U_TMOD_T_NORMAL' => 'modcp.' . PHP_EXT . '?' . $full_ftp_append . 'mode=normalize&amp;sid=' . $user->data['session_id'],
  1137. 'IMG_TMOD_BIN' => $images['topic_mod_bin'],
  1138. 'IMG_TMOD_DELETE' => $images['topic_mod_delete'],
  1139. 'IMG_TMOD_MOVE' => $images['topic_mod_move'],
  1140. 'IMG_TMOD_LOCK' => $images['topic_mod_lock'],
  1141. 'IMG_TMOD_UNLOCK' => $images['topic_mod_unlock'],
  1142. 'IMG_TMOD_SPLIT' => $images['topic_mod_split'],
  1143. 'IMG_TMOD_MERGE' => $images['topic_mod_merge'],
  1144. 'IMG_TMOD_T_GLOBAL' => $images['gannounce_post'],
  1145. 'IMG_TMOD_T_ANNOUNCE' => $images['announce_post'],
  1146. 'IMG_TMOD_T_STICKY' => $images['sticky_post'],
  1147. 'IMG_TMOD_T_NORMAL' => $images['normal_post'],
  1148. 'S_TOPIC_LINK' => POST_TOPIC_URL,
  1149. 'S_SELECT_SORT_DAYS' => $select_sort_days,
  1150. 'S_SELECT_SORT_KEY' => $select_sort_key,
  1151. 'S_SELECT_SORT_DIR' => $select_sort_dir,
  1152. 'S_POST_DAYS_ACTION' => append_sid(CMS_PAGE_VIEWTOPIC . '?' . $forum_id_append . '&amp;' . $topic_id_append . $kb_mode_append . '&amp;start=' . $start),
  1153. 'S_AUTH_LIST' => $s_auth_can,
  1154. 'S_TOPIC_ADMIN' => $topic_mod,
  1155. 'IS_KB_MODE' => ($kb_mode == true) ? true : false,
  1156. 'S_KB_MODE' => !empty($s_kb_mode) ? $s_kb_mode : '',
  1157. 'S_KB_MODE_IMG' => !empty($s_kb_mode_img) ? $s_kb_mode_img : '',
  1158. 'S_WATCH_TOPIC' => !empty($s_watching_topic) ? $s_watching_topic : '',
  1159. 'S_WATCH_TOPIC_IMG' => !empty($s_watching_topic_img) ? $s_watching_topic_img : '',
  1160. 'U_VIEW_TOPIC' => append_sid(CMS_PAGE_VIEWTOPIC . '?' . $forum_id_append . '&amp;' . $topic_id_append . $kb_mode_append . (!empty($start) ? ('&amp;start=' . $start) : '') . $vt_sort_append . (!empty($highlight) ? ('&amp;highlight=' . $highlight) : '') . (($kb_mode == true) ? '&amp;kb=on' : '')),
  1161. 'U_VIEW_TOPIC_BASE' => append_sid(CMS_PAGE_VIEWTOPIC . '?' . $forum_id_append . '&amp;' . $topic_id_append . $kb_mode_append),
  1162. // UPI2DB - BEGIN
  1163. 'U_MARK_ALWAYS_READ' => $mark_always_read,
  1164. 'S_MARK_AR' => $s_mark_ar,
  1165. 'S_MARK_AR_IMG' => $s_mark_ar_img,
  1166. // UPI2DB - END
  1167. 'U_TOPIC_VIEWED' => $topic_viewed_link,
  1168. 'U_VIEW_FORUM' => $view_forum_url,
  1169. 'U_VIEW_OLDER_TOPIC' => $view_prev_topic_url,
  1170. 'U_VIEW_NEWER_TOPIC' => $view_next_topic_url,
  1171. 'U_POST_NEW_TOPIC' => $new_topic_url,
  1172. 'U_POST_REPLY_TOPIC' => $reply_topic_url
  1173. )
  1174. );
  1175. // Does this topic contain a poll?
  1176. if (!empty($forum_topic_data['poll_start']))
  1177. {
  1178. $class_topics->poll_display($forum_topic_data, false);
  1179. }
  1180. // Event Registration - BEGIN
  1181. include(IP_ROOT_PATH . 'includes/viewtopic_events_reg.' . PHP_EXT);
  1182. // Event Registration - END
  1183. init_display_post_attachments($forum_topic_data['topic_attachment']);
  1184. if ($config['enable_quick_quote'])
  1185. {
  1186. $template->assign_block_vars('switch_quick_quote', array());
  1187. }
  1188. $sig_cache = array();
  1189. $delnote = isset($_GET['delnote']) ? explode('.', $_GET['delnote']) : array();
  1190. $this_year = create_date('Y', time(), $config['board_timezone']);
  1191. $this_date = create_date('md', time(), $config['board_timezone']);
  1192. // Mighty Gorgon - POSTS LIKES - BEGIN
  1193. $posts_like_enabled = false;
  1194. if (empty($config['disable_likes_posts']) && $forum_topic_data['forum_likes'] && !$user->data['is_bot'])
  1195. {
  1196. $posts_like_enabled = true;
  1197. $posts_list = array();
  1198. for($i = 0; $i < $total_posts; $i++)
  1199. {
  1200. $posts_list[] = $postrow[$i]['post_id'];
  1201. }
  1202. $topic_posts_likes = $class_topics->topic_posts_likes_get(array('topic_id' => $topic_id), $posts_list);
  1203. }
  1204. // Mighty Gorgon - POSTS LIKES - END
  1205. // Mighty Gorgon - Feedback - BEGIN
  1206. $feedback_disabled = true;
  1207. if (!empty($config['plugins']['feedback']['enabled']) && !empty($config['plugins']['feedback']['dir']))
  1208. {
  1209. $plugin_name = 'feedback';
  1210. include(IP_ROOT_PATH . PLUGINS_PATH . $config['plugins']['feedback']['dir'] . 'common.' . PHP_EXT);
  1211. $feedback_allowed_forums = explode(',', PLUGINS_FEEDBACK_FORUMS);
  1212. $feedback_disabled = false;
  1213. if (!in_array($forum_id, $feedback_allowed_forums))
  1214. {
  1215. $feedback_disabled = true;
  1216. }
  1217. }
  1218. // Mighty Gorgon - Feedback - END
  1219. // Keep first post on every page - BEGIN
  1220. if (!empty($forum_topic_data['forum_recurring_first_post']) && ($start > 0))
  1221. {
  1222. // Select the first post of the topic if we're on page >1 along with the user infos
  1223. $sql = "SELECT fp.*, fpu.*
  1224. FROM " . POSTS_TABLE . " fp
  1225. LEFT JOIN " . USERS_TABLE . " fpu
  1226. ON fpu.user_id = fp.poster_id
  1227. WHERE fp.post_id = " . $forum_topic_data['topic_first_post_id'];
  1228. $result = $db->sql_query($sql);
  1229. $first_post_data = $db->sql_fetchrow($result); // it's fine if this fails, we'll just show no first post
  1230. $db->sql_freeresult($result);
  1231. // Add the first post of the topic as the first post of this page... but first mark it special
  1232. $first_post_data['topic_first_post'] = true;
  1233. array_unshift($postrow, $first_post_data);
  1234. $total_posts++;
  1235. }
  1236. // Keep first post on every page - END
  1237. // Okay, let's do the loop, yeah come on baby let's do the loop and it goes like this ...
  1238. $ip_display_auth = ip_display_auth($user->data, true);
  1239. for($i = 0; $i < $total_posts; $i++)
  1240. {
  1241. $this_poster_mask = false;
  1242. if (($user->data['user_level'] != ADMIN) && !empty($postrow[$i]['user_mask']) && empty($postrow[$i]['user_active']))
  1243. {
  1244. $this_poster_mask = true;
  1245. user_profile_mask($postrow[$i]);
  1246. }
  1247. $poster_id = $postrow[$i]['user_id'];
  1248. $post_id = $postrow[$i]['post_id'];
  1249. $user_pic_count = $postrow[$i]['user_personal_pics_count'];
  1250. $poster = ($poster_id == ANONYMOUS) ? $lang['Guest'] : colorize_username($postrow[$i]['user_id'], $postrow[$i]['username'], $postrow[$i]['user_color'], $postrow[$i]['user_active']);
  1251. $poster_qq = ($poster_id == ANONYMOUS) ? $lang['Guest'] : $postrow[$i]['username'];
  1252. $poster_full_name = (!empty($postrow[$i]['user_first_name']) ? ($postrow[$i]['user_first_name'] . (!empty($postrow[$i]['user_last_name']) ? (' ' . $postrow[$i]['user_last_name']) : '')) : '');
  1253. // BIRTHDAY - BEGIN
  1254. $poster_age = '';
  1255. if ($config['birthday_viewtopic'])
  1256. {
  1257. if ($postrow[$i]['user_birthday'] != 999999)
  1258. {
  1259. $poster_birthdate = realdate('md', $postrow[$i]['user_birthday']);
  1260. $poster_age = $this_year - realdate('Y', $postrow[$i]['user_birthday']);
  1261. if ($this_date < $poster_birthdate)
  1262. {
  1263. $poster_age--;
  1264. }
  1265. $poster_age = $lang['Age'] . ': ' . $poster_age . '<br />';
  1266. }
  1267. else
  1268. {
  1269. $poster_age = '';
  1270. $poster_birthdate = '';
  1271. }
  1272. $birtdhay_cake = ($this_date == $poster_birthdate) ? '<img src="images/birthday_cake.png" alt="Happy Birthday" title="Happy Birthday" />' : '';
  1273. }
  1274. // BIRTHDAY - END
  1275. $post_date = create_date_ip($config['default_dateformat'], $postrow[$i]['post_time'], $config['board_timezone']);
  1276. $poster_posts = ($postrow[$i]['user_id'] != ANONYMOUS) ? $lang['Posts'] . ': ' . $postrow[$i]['user_posts'] : '';
  1277. $poster_flag_country = ($postrow[$i]['user_from_flag'] == 'blank.gif') ? '' : ucwords(str_replace(array('.gif', '.png', '_'), array('', '', ' '), $postrow[$i]['user_from_flag']));
  1278. $poster_from_flag = (!empty($postrow[$i]['user_from_flag']) && ($postrow[$i]['user_id'] != ANONYMOUS)) ? '<img src="images/flags/' . $postrow[$i]['user_from_flag'] . '" alt="' . $postrow[$i]['user_from_flag'] . '" title="' . $postrow[$i]['user_from'] . (!empty($poster_flag_country) ? (' (' . $poster_flag_country . ')') : '') . '" />' : '';
  1279. $poster_from = (!empty($postrow[$i]['user_from']) && ($postrow[$i]['user_id'] != ANONYMOUS)) ? $lang['Location'] . ': ' . $postrow[$i]['user_from'] : '';
  1280. $poster_from_full = ((!empty($poster_from_flag) || !empty($postrow[$i]['user_from'])) && ($postrow[$i]['user_id'] != ANONYMOUS)) ? $lang['Location'] . ':' . (!empty($poster_from_flag) ? (' ' . $poster_from_flag) : '') . (!empty($postrow[$i]['user_from']) ? (' ' . $postrow[$i]['user_from']) : '') : '';
  1281. $poster_joined = ($postrow[$i]['user_id'] != ANONYMOUS) ? $lang['Joined'] . ': ' . create_date($lang['JOINED_DATE_FORMAT'], $postrow[$i]['user_regdate'], $config['board_timezone']) : '';
  1282. $poster_avatar = user_get_avatar($poster_id, $postrow[$i]['user_level'], $postrow[$i]['user_avatar'], $postrow[$i]['user_avatar_type'], $postrow[$i]['user_allowavatar']);
  1283. // Define the little post icon
  1284. // UPI2DB - BEGIN
  1285. if(!$user->data['upi2db_access'])
  1286. {
  1287. // UPI2DB - END
  1288. if ($user->data['session_logged_in'] && ($postrow[$i]['post_time'] > $user->data['user_lastvisit']) && ($postrow[$i]['post_time'] > $topic_last_read) && !$user->data['is_bot'])
  1289. {
  1290. $mini_post_img = $images['icon_minipost_new'];
  1291. $mini_post_alt = $lang['New_post'];
  1292. }
  1293. else
  1294. {
  1295. $mini_post_img = $images['icon_minipost'];
  1296. $mini_post_alt = $lang['Post'];
  1297. }
  1298. // UPI2DB - BEGIN
  1299. }
  1300. else
  1301. {
  1302. viewtopic_calc_unread($user->data['upi2db_unread'], $topic_id, $postrow[$i]['post_id'], $forum_id, $mini_post_img, $mini_post_alt, $unread_color, $read_posts);
  1303. }
  1304. // UPI2DB - END
  1305. if (($config['url_rw'] == '1') || (($config['url_rw_guests'] == '1') && ($user->data['user_id'] == ANONYMOUS)))
  1306. {
  1307. $mini_post_url = str_replace ('--', '-', make_url_friendly($postrow[$i]['post_subject']) . '-vp' . $postrow[$i]['post_id'] . '.html#p' . $postrow[$i]['post_id']);
  1308. }
  1309. else
  1310. {
  1311. // Mighty Gorgon: this is the full URL in case we would like to use it instead of the short form permalink... maybe for SEO purpose it is better using the short form
  1312. //$mini_post_url = append_sid(CMS_PAGE_VIEWTOPIC . '?' . $forum_id_append . '&amp;' . $topic_id_append . $kb_mode_append . '&amp;' . POST_POST_URL . '=' . $postrow[$i]['post_id']) . '#p' . $postrow[$i]['post_id'];
  1313. $mini_post_url = append_sid(CMS_PAGE_VIEWTOPIC . '?' . POST_POST_URL . '=' . $postrow[$i]['post_id']) . '#p' . $postrow[$i]['post_id'];
  1314. }
  1315. // Mighty Gorgon - Multiple Ranks - BEGIN
  1316. $user_ranks = generate_ranks($postrow[$i], $ranks_array);
  1317. if (($user_ranks['rank_01_html'] == '') && ($user_ranks['rank_01_img_html'] == '') && ($user_ranks['rank_02_html'] == '') && ($user_ranks['rank_02_img_html'] == '') && ($user_ranks['rank_03_html'] == '') && ($user_ranks['rank_03_img_html'] == '') && ($user_ranks['rank_04_html'] == '') && ($user_ranks['rank_04_img_html'] == '') && ($user_ranks['rank_05_html'] == '') && ($user_ranks['rank_05_img_html'] == ''))
  1318. {
  1319. $user_ranks['rank_01_html'] = '&nbsp;';
  1320. }
  1321. // Mighty Gorgon - Multiple Ranks - END
  1322. // Handle anon users posting with usernames
  1323. if (($poster_id == ANONYMOUS) && ($postrow[$i]['post_username'] != ''))
  1324. {
  1325. $poster = $postrow[$i]['post_username'];
  1326. $poster_qq = $postrow[$i]['post_username'];
  1327. $user_ranks['rank_01_html'] = $lang['Guest'] . '<br />';
  1328. }
  1329. if ($poster_id != ANONYMOUS)
  1330. {
  1331. $profile_url = append_sid(CMS_PAGE_PROFILE . '?mode=viewprofile&amp;' . POST_USERS_URL . '=' . $poster_id);
  1332. $profile_img = '<a href="' . $profile_url . '"><img src="' . $images['icon_profile'] . '" alt="' . htmlspecialchars($postrow[$i]['username']) . ' - ' . $lang['Read_profile'] . '" title="' . htmlspecialchars($postrow[$i]['username']) . '" /></a>';
  1333. $profile = '<a href="' . $profile_url . '">' . $lang['Profile'] . '</a>';
  1334. $pm_url = append_sid(CMS_PAGE_PRIVMSG . '?mode=post&amp;' . POST_USERS_URL . '=' . $poster_id);
  1335. $pm_img = '<a href="' . $pm_url . '"><img src="' . $images['icon_pm'] . '" alt="' . $lang['Send_private_message'] . '" title="' . $lang['Send_private_message'] . '" /></a>';
  1336. $pm = '<a href="' . $pm_url . '">' . $lang['PM'] . '</a>';
  1337. $email_url = '';
  1338. $email_switch = false;
  1339. if (empty($user->data['user_id']) || ($user->data['user_id'] == ANONYMOUS))
  1340. {
  1341. if (!empty($postrow[$i]['user_allow_viewemail']))
  1342. {
  1343. $email_switch = true;
  1344. $email_img = '<img src="' . $images['icon_email'] . '" alt="' . $lang['Hidden_email'] . '" title="' . $lang['Hidden_email'] . '" />';
  1345. }
  1346. else
  1347. {
  1348. $email_img = '&nbsp;';
  1349. }
  1350. $email = '&nbsp;';
  1351. }
  1352. elseif (!empty($postrow[$i]['user_allow_viewemail']) || $is_auth['auth_mod'])
  1353. {
  1354. $email_switch = true;
  1355. $email_url = ($config['board_email_form']) ? append_sid(CMS_PAGE_PROFILE . '?mode=email&amp;' . POST_USERS_URL .'=' . $poster_id) : 'mailto:' . $postrow[$i]['user_email'];
  1356. $email_img = '<a href="' . $email_url . '"><img src="' . $images['icon_email'] . '" alt="' . $lang['Send_email'] . '" title="' . $lang['Send_email'] . '" /></a>';
  1357. $email = '<a href="' . $email_url . '">' . $lang['Email'] . '</a>';
  1358. }
  1359. else
  1360. {
  1361. $email_img = '';
  1362. $email = '';
  1363. }
  1364. $www_img = ($postrow[$i]['user_website']) ? '<a href="' . $postrow[$i]['user_website'] . '" target="_blank" rel="nofollow"><img src="' . $images['icon_www'] . '" alt="' . $lang['Visit_website'] . '" title="' . $lang['Visit_website'] . '" /></a>' : '';
  1365. $www = ($postrow[$i]['user_website']) ? '<a href="' . $postrow[$i]['user_website'] . '" target="_blank" rel="nofollow">' . $lang['Website'] . '</a>' : '';
  1366. $www_url = ($postrow[$i]['user_website']) ? $postrow[$i]['user_website'] : '';
  1367. $user_sn_im_array = get_user_sn_im_array();
  1368. $im_links_array = array();
  1369. foreach ($user_sn_im_array as $k => $v)
  1370. {
  1371. $im_links_array[$k] = $v['alt_name'];
  1372. }
  1373. $im_links_array['chat'] = 'id';
  1374. $social_im_icon_type = !empty($images['common_social_images_vt']) ? 'icon' : 'icon_tpl_vt';
  1375. $all_ims = array();
  1376. foreach ($im_links_array as $im_k => $im_v)
  1377. {
  1378. $all_ims[$im_k] = array(
  1379. 'plain' => '',
  1380. 'img' => '',
  1381. 'url' => ''
  1382. );
  1383. if (!empty($postrow[$i]['user_' . $im_v]))
  1384. {
  1385. $all_ims[$im_k] = array(
  1386. 'plain' => build_im_link($im_k, $postrow[$i], false, false, false, false, false),
  1387. 'img' => build_im_link($im_k, $postrow[$i], $social_im_icon_type, true, false, false, false),
  1388. 'url' => build_im_link($im_k, $postrow[$i], false, false, true, false, false)
  1389. );
  1390. }
  1391. }
  1392. $aim_img = $all_ims['aim']['img'];
  1393. $aim = $all_ims['aim']['plain'];
  1394. $aim_url = $all_ims['aim']['url'];
  1395. $icq_status_img = (!empty($postrow[$i]['user_icq'])) ? '<a href="http://wwp.icq.com/' . $postrow[$i]['user_icq'] . '#pager" rel="nofollow"><img src="http://web.icq.com/whitepages/online?icq=' . $postrow[$i]['user_icq'] . '&amp;img=5" width="18" height="18" /></a>' : '';
  1396. $icq_img = $all_ims['icq']['img'];
  1397. $icq = $all_ims['icq']['plain'];
  1398. $icq_url = $all_ims['icq']['url'];
  1399. $msn_img = $all_ims['msn']['img'];
  1400. $msn = $all_ims['msn']['plain'];
  1401. $msn_url = $all_ims['msn']['url'];
  1402. $skype_img = $all_ims['skype']['img'];
  1403. $skype = $all_ims['skype']['plain'];
  1404. $skype_url = $all_ims['skype']['url'];
  1405. $yahoo_img = $all_ims['yahoo']['img'];
  1406. $yahoo = $all_ims['yahoo']['plain'];
  1407. $yahoo_url = $all_ims['yahoo']['url'];
  1408. // Gender - BEGIN
  1409. $gender_male_switch = false;
  1410. $gender_female_switch = false;
  1411. $gender_default_switch = false;
  1412. switch ($postrow[$i]['user_gender'])
  1413. {
  1414. case 1:
  1415. $gender_male_switch = true;
  1416. $gender_image = '<img src="' . $images['icon_minigender_male'] . '" alt="' . $lang['Gender']. ': ' . $lang['Male'] . '" title="' . $lang['Gender'] . ': ' . $lang['Male'] . '" />';
  1417. break;
  1418. case 2:
  1419. $gender_female_switch = true;
  1420. $gender_image = '<img src="' . $images['icon_minigender_female'] . '" alt="' . $lang['Gender']. ': ' . $lang['Female'] . '" title="' . $lang['Gender'] . ': ' . $lang['Female'] . '" />';
  1421. break;
  1422. default:
  1423. $gender_default_switch = true;
  1424. $gender_image = '';
  1425. }
  1426. // Gender - END
  1427. // ONLINE / OFFLINE - BEGIN
  1428. $offline_status_switch = true;
  1429. $online_status_switch = false;
  1430. $hidden_status_switch = false;
  1431. $online_status_url = append_sid(CMS_PAGE_VIEWONLINE);
  1432. // Start as offline...
  1433. $online_status_img = '<img src="' . $images['icon_im_status_offline'] . '" alt="' . $lang['Offline'] . '" title="' . $lang['Offline'] . '" />';
  1434. $online_status_lang = $lang['Offline'];
  1435. $online_status_class = 'offline';
  1436. if ($postrow[$i]['user_session_time'] >= (time() - $config['online_time']))
  1437. {
  1438. if (!empty($postrow[$i]['user_allow_viewonline']))
  1439. {
  1440. $online_status_switch = true;
  1441. $online_status_img = '<a href="' . $online_status_url . '"><img src="' . $images['icon_im_status_online'] . '" alt="' . $lang['Online'] . '" title="' . $lang['Online'] . '" /></a>';
  1442. $online_status_lang = $lang['Online'];
  1443. $online_status_class = 'online';
  1444. }
  1445. elseif (isset($postrow[$i]['user_allow_viewonline']) && empty($postrow[$i]['user_allow_viewonline']) && (($user->data['user_level'] == ADMIN) || ($user->data['user_id'] == $poster_id)))
  1446. {
  1447. $hidden_status_switch = true;
  1448. $online_status_img = '<a href="' . $online_status_url . '"><img src="' . $images['icon_im_status_hidden'] . '" alt="' . $lang['Hidden'] . '" title="' . $lang['Hidden'] . '" /></a>';
  1449. $online_status_lang = $lang['Hidden'];
  1450. $online_status_class = 'hidden';
  1451. }
  1452. }
  1453. // ONLINE / OFFLINE - END
  1454. }
  1455. else
  1456. {
  1457. $gender_image = '';
  1458. $poster_from_flag = '';
  1459. $profile_url = '';
  1460. $profile_img = '';
  1461. $profile = '';
  1462. $pm_url = '';
  1463. $pm_img = '';
  1464. $pm = '';
  1465. $email_url = '';
  1466. $email_img = '';
  1467. $email = '';
  1468. $www_url = '';
  1469. $www_img = '';
  1470. $www = '';
  1471. $aim_url = '';
  1472. $aim_img = '';
  1473. $aim = '';
  1474. $icq_url = '';
  1475. $icq_status_img = '';
  1476. $icq_img = '';
  1477. $icq = '';
  1478. $msn_url = '';
  1479. $msn_img = '';
  1480. $msn = '';
  1481. $skype_url = '';
  1482. $skype_img = '';
  1483. $skype = '';
  1484. $yahoo_url = '';
  1485. $yahoo_img = '';
  1486. $yahoo = '';
  1487. $online_status_url = '';
  1488. $online_status_img = '';
  1489. }
  1490. $quote_url = append_sid('posting.' . PHP_EXT . '?mode=quote&amp;' . $forum_id_append . '&amp;' . $topic_id_append . '&amp;' . POST_POST_URL . '=' . $postrow[$i]['post_id']);
  1491. $quote_img = '<a href="' . $quote_url . '"><img src="' . $images['icon_quote'] . '" alt="' . $lang['Reply_with_quote'] . '" title="' . $lang['Reply_with_quote'] . '" /></a>';
  1492. $quote = '<a href="' . $quote_url . '">' . $lang['Reply_with_quote'] . '</a>';
  1493. $search_url = append_sid(CMS_PAGE_SEARCH . '?search_author=' . urlencode($postrow[$i]['username']) . '&amp;showresults=posts');
  1494. $search_img = '<a href="' . $search_url . '"><img src="' . $images['icon_search'] . '" alt="' . sprintf($lang['Search_user_posts'], $postrow[$i]['username']) . '" title="' . sprintf($lang['Search_user_posts'], $postrow[$i]['username']) . '" /></a>';
  1495. $search = '<a href="' . $search_url . '">' . sprintf($lang['Search_user_posts'], $postrow[$i]['username']) . '</a>';
  1496. $edit_url = '';
  1497. $edit_img = '';
  1498. $edit = '';
  1499. $edit_switch = false;
  1500. if ((($user->data['user_id'] == $poster_id) && $is_auth['auth_edit'] && !$postrow[$i]['post_locked']) || $is_auth['auth_mod'] || ($user->data['user_level'] == ADMIN))
  1501. {
  1502. if (($config['allow_mods_edit_admin_posts'] == false) && ($postrow[$i]['user_level'] == ADMIN) && ($user->data['user_level'] != ADMIN))
  1503. {
  1504. $edit_img = '';
  1505. $edit = '';
  1506. }
  1507. else
  1508. {
  1509. $edit_switch = true;
  1510. $edit_url = append_sid('posting.' . PHP_EXT . '?mode=editpost&amp;' . $forum_id_append . '&amp;' . $topic_id_append . '&amp;' . POST_POST_URL . '=' . $postrow[$i]['post_id']);
  1511. $edit_img = '<a href="' . $edit_url . '"><img src="' . $images['icon_edit'] . '" alt="' . $lang['Edit_delete_post'] . '" title="' . $lang['Edit_delete_post'] . '" /></a>';
  1512. $edit = '<a href="' . $edit_url . '">' . $lang['Edit_delete_post'] . '</a>';
  1513. }
  1514. }
  1515. $delpost_url = '';
  1516. $delpost_img = '';
  1517. $delpost = '';
  1518. $delpost_switch = false;
  1519. $ip_url = '';
  1520. $ip_img = '';
  1521. $ip_img_icon = '';
  1522. $ip = '';
  1523. if (($user->data['user_level'] == ADMIN) || $is_auth['auth_mod'])
  1524. {
  1525. if (!empty($ip_display_auth))
  1526. {
  1527. $ip_url = 'modcp.' . PHP_EXT . '?mode=ip&amp;' . $forum_id_append . '&amp;' . $topic_id_append . '&amp;' . POST_POST_URL . '=' . $postrow[$i]['post_id'] . '&amp;sid=' . $user->data['session_id'];
  1528. // Start Advanced IP Tools Pack MOD
  1529. $ip_img = '<a href="' . $ip_url . '"><img src="' . $images['icon_ip'] . '" alt="' . $lang['View_IP'] . ' (' . htmlspecialchars($postrow[$i]['poster_ip']) . ')" title="' . $lang['View_IP'] . ' (' . htmlspecialchars($postrow[$i]['poster_ip']) . ')" /></a>';
  1530. $ip_img_icon = '<a href="' . $ip_url . '"><img src="' . $images['vt_post_ip'] . '" alt="' . $lang['View_IP'] . ' (' . htmlspecialchars($postrow[$i]['poster_ip']) . ')" title="' . $lang['View_IP'] . ' (' . htmlspecialchars($postrow[$i]['poster_ip']) . ')" /></a>';
  1531. // End Advanced IP Tools Pack MOD
  1532. $ip = '<a href="' . $ip_url . '">' . $lang['View_IP'] . '</a>';
  1533. }
  1534. if (($config['allow_mods_edit_admin_posts'] == false) && ($postrow[$i]['user_level'] == ADMIN) && ($user->data['user_level'] != ADMIN))
  1535. {
  1536. $delpost_url = '';
  1537. $delpost_img = '';
  1538. $delpost = '';
  1539. }
  1540. else
  1541. {
  1542. $delpost_switch = true;
  1543. $delpost_url = 'posting.' . PHP_EXT . '?mode=delete&amp;' . $forum_id_append . '&amp;' . $topic_id_append . '&amp;' . POST_POST_URL . '=' . $postrow[$i]['post_id'] . '&amp;sid=' . $user->data['session_id'];
  1544. $delpost_img = '<a href="' . $delpost_url . '"><img src="' . $images['icon_delpost'] . '" alt="' . $lang['Delete_post'] . '" title="' . $lang['Delete_post'] . '" /></a>';
  1545. $delpost = '<a href="' . $delpost_url . '">' . $lang['Delete_post'] . '</a>';
  1546. }
  1547. }
  1548. else
  1549. {
  1550. if (($config['allow_mods_edit_admin_posts'] == false) && ($postrow[$i]['user_level'] == ADMIN) && ($user->data['user_level'] != ADMIN))
  1551. {
  1552. $delpost_url = '';
  1553. $delpost_img = '';
  1554. $delpost = '';
  1555. }
  1556. elseif (($user->data['user_id'] == $poster_id) && $is_auth['auth_delete'] && ($forum_topic_data['topic_last_post_id'] == $postrow[$i]['post_id']))
  1557. {
  1558. $delpost_switch = true;
  1559. $delpost_url = 'posting.' . PHP_EXT . '?mode=delete&amp;' . $forum_id_append . '&amp;' . $topic_id_append . '&amp;' . POST_POST_URL . '=' . $postrow[$i]['post_id'] . '&amp;sid=' . $user->data['session_id'];
  1560. $delpost_img = '<a href="' . $delpost_url . '"><img src="' . $images['icon_delpost'] . '" alt="' . $lang['Delete_post'] . '" title="' . $lang['Delete_post'] . '" /></a>';
  1561. $delpost = '<a href="' . $delpost_url . '">' . $lang['Delete_post'] . '</a>';
  1562. }
  1563. }
  1564. $s_card_switch_g = false;
  1565. $s_card_switch_y = false;
  1566. $s_card_switch_r = false;
  1567. $s_card_switch_b = false;
  1568. $s_card_switch_p = false;
  1569. $s_card_switch_y_assigned = false;
  1570. $s_card_switch_r_assigned = false;
  1571. $s_card_y_counter = 0;
  1572. $b_card_img = '';
  1573. if ($is_auth['auth_bluecard'])
  1574. {
  1575. $s_card_switch_b = true;
  1576. $blue_card_img = '<img src="'. $images['icon_b_card'] . '" alt="'. $lang['Give_b_card'] . '" title="'.$lang['Give_b_card'].'" />';
  1577. $blue_card_action = 'return confirm(\'' . $lang['Blue_card_warning'] . '\')';
  1578. $temp_url = 'card.' . PHP_EXT . '?mode=report&amp;post_id=' . $postrow[$i]['post_id'] . '&amp;user_id=' . $user->data['user_id'] . '&amp;sid=' . $user->data['session_id'];
  1579. $b_card_img = '<a href="' . $temp_url . '" title="' . $lang['Give_b_card'] . '" onclick="' . $blue_card_action . '">' . $blue_card_img . '</a>';
  1580. if ($is_auth['auth_mod'] && $postrow[$i]['post_bluecard'])
  1581. {
  1582. $s_card_switch_p = true;
  1583. $blue_card_img = '<img src="' . $images['icon_p_card'] . '" alt="' . sprintf($lang['Clear_b_card'], $postrow[$i]['post_bluecard']) . '" />';
  1584. $blue_card_action = 'return confirm(\'' . $lang['Clear_blue_card_warning'] . '\')';
  1585. $temp_url = 'card.' . PHP_EXT . '?mode=report_reset&amp;post_id=' . $postrow[$i]['post_id'] . '&amp;user_id=' . $user->data['user_id'] . '&amp;sid=' . $user->data['session_id'];
  1586. $b_card_img = '<a href="' . $temp_url . '" onclick="' . $blue_card_action . '" title="' . $lang['Give_b_card'] . '">' . $blue_card_img . '</a>';
  1587. }
  1588. }
  1589. $card_img = '';
  1590. $g_card_img = '';
  1591. $y_card_img = '';
  1592. $r_card_img = '';
  1593. if(($poster_id != ANONYMOUS) && ($postrow[$i]['user_level'] != ADMIN))
  1594. {
  1595. $current_user = str_replace("'", "\'", $postrow[$i]['username']);
  1596. $user_warnings = $postrow[$i]['user_warnings'];
  1597. $is_banned = false;
  1598. $card_img = '';
  1599. if ($user_warnings == 0)
  1600. {
  1601. $card_img = '';
  1602. }
  1603. else
  1604. {
  1605. $is_banned = (isset($ranks_array['bannedrow'][$poster_id])) ? true : false;
  1606. if (($user_warnings >= $config['max_user_bancard']) || $is_banned)
  1607. {
  1608. $s_card_switch_r_assigned = true;
  1609. $card_img = '<img src="' . $images['icon_r_cards'] . '" alt="' . $lang['Banned'] . '" title="' . $lang['Banned'] . '" />';
  1610. }
  1611. else
  1612. {
  1613. $s_card_switch_y_assigned = true;
  1614. for ($n = 0; $n < $user_warnings; $n++)
  1615. {
  1616. $s_card_y_counter++;
  1617. $card_img .= '<img src="' . $images['icon_y_cards'] . '" alt="' . sprintf($lang['Warnings'], $user_warnings) . '" title="' . sprintf($lang['Warnings'], $user_warnings) . '" />&nbsp;';
  1618. }
  1619. }
  1620. }
  1621. $g_card_img = '';
  1622. if ($is_auth['auth_greencard'] && ($s_card_switch_y_assigned || $s_card_switch_r_assigned))
  1623. {
  1624. $s_card_switch_g = true;
  1625. $grn_card_img = '<img src="'. $images['icon_g_card'] . '" alt="' . $lang['Give_G_card'] . '" />';
  1626. $grn_card_action = 'return confirm(\'' . sprintf($lang['Green_card_warning'], $current_user) . '\')';
  1627. $temp_url = 'card.' . PHP_EXT . '?mode=unban&amp;post_id=' . $postrow[$i]['post_id'] . '&amp;user_id=' . $user->data['user_id'] . '&amp;sid=' . $user->data['session_id'];
  1628. $g_card_img = '<a href="' . $temp_url . '" title="' . $lang['Give_G_card'] . '" onclick="' . $grn_card_action . '">' . $grn_card_img . '</a>';
  1629. }
  1630. $y_card_img = '';
  1631. $r_card_img = '';
  1632. if (($user_warnings < $config['max_user_bancard']) && $is_auth['auth_ban'])
  1633. {
  1634. $s_card_switch_y = true;
  1635. $s_card_switch_r = true;
  1636. $yel_card_img = '<img src="' . $images['icon_y_card'] . '" alt="' . sprintf($lang['Give_Y_card'], $user_warnings + 1) . '" />';
  1637. $yel_card_action = 'return confirm(\'' . sprintf($lang['Yellow_card_warning'], $current_user) . '\')';
  1638. $temp_url = 'card.' . PHP_EXT . '?mode=warn&amp;post_id=' . $postrow[$i]['post_id'] . '&amp;user_id=' . $user->data['user_id'] . '&amp;sid=' . $user->data['session_id'];
  1639. $y_card_img = '<a href="' . $temp_url . '" title="' .sprintf($lang['Give_Y_card'], $user_warnings + 1). '" onclick="' . $yel_card_action . '">' . $yel_card_img . '</a>';
  1640. $red_card_img = '<img src="'. $images['icon_r_card'] . '" alt="'. $lang['Give_R_card'] . '" />';
  1641. $red_card_action = 'return confirm(\'' . sprintf($lang['Red_card_warning'], $current_user) . '\')';
  1642. $temp_url = 'card.' . PHP_EXT . '?mode=ban&amp;post_id=' . $postrow[$i]['post_id'] . '&amp;user_id=' . $user->data['user_id'] . '&amp;sid=' . $user->data['session_id'];
  1643. $r_card_img = '<a href="' . $temp_url . '" title="' . $lang['Give_R_card'] . '" onclick="' . $red_card_action . '">' . $red_card_img . '</a>';
  1644. }
  1645. else
  1646. {
  1647. }
  1648. }
  1649. // parse hidden fields if cards visible
  1650. $card_hidden = ($g_card_img || $r_card_img || $y_card_img || $b_card_img) ? '<input type="hidden" name="post_id" value="' . $postrow[$i]['post_id']. '" />' : '';
  1651. // End Changes for Yellow Card Mod
  1652. if ($parse_extra_user_info == true)
  1653. {
  1654. if(array_search($postrow[$i]['user_style'], $styles_list_id))
  1655. {
  1656. $poster_style = $lang['Change_Style'] . ': ' . $styles_list_name[array_search($postrow[$i]['user_style'], $styles_list_id)] . '<br />';
  1657. }
  1658. else
  1659. {
  1660. $poster_style = '';
  1661. }
  1662. if (!$postrow[$i]['user_lang'] == '')
  1663. {
  1664. $poster_lang = $lang['Change_Lang'] . ': ' . ucfirst(strtolower($postrow[$i]['user_lang'])) . '&nbsp;<img src="language/lang_' . $postrow[$i]['user_lang'] . '/flag.png" alt="" title="" /><br />';
  1665. }
  1666. else
  1667. {
  1668. $poster_lang = '';
  1669. }
  1670. }
  1671. else
  1672. {
  1673. $poster_style = '';
  1674. $poster_lang = '';
  1675. }
  1676. $post_subject = ($postrow[$i]['post_subject'] != '') ? $postrow[$i]['post_subject'] : '';
  1677. // Mighty Gorgon - Quick Quote - BEGIN
  1678. if ($config['enable_quick_quote'])
  1679. {
  1680. $look_up_array = array(
  1681. '\"',
  1682. '"',
  1683. "<",
  1684. ">",
  1685. "\n",
  1686. chr(13),
  1687. );
  1688. $replacement_array = array(
  1689. '&q_mg;',
  1690. '\"',
  1691. "&lt_mg;",
  1692. "&gt_mg;",
  1693. "\\n",
  1694. "",
  1695. );
  1696. $plain_message = $postrow[$i]['post_text'];
  1697. $plain_message = strtr($plain_message, array_flip(get_html_translation_table(HTML_ENTITIES)));
  1698. //Hide MOD
  1699. if(preg_match('/\[hide/i', $plain_message))
  1700. {
  1701. $search = array("/\[hide\](.*?)\[\/hide\]/");
  1702. $replace = array('[hide]' . $lang['xs_bbc_hide_quote_message'] . '[/hide]');
  1703. $plain_message = preg_replace($search, $replace, $plain_message);
  1704. }
  1705. //Hide MOD
  1706. $plain_message = censor_text($plain_message);
  1707. $plain_message = str_replace($look_up_array, $replacement_array, $plain_message);
  1708. }
  1709. // Mighty Gorgon - Quick Quote - END
  1710. // Mighty Gorgon - New BBCode Functions - BEGIN
  1711. // Please, do not change anything here, if you're not confident with what you're doing!!!
  1712. $message = $postrow[$i]['post_text'];
  1713. $message_compiled = (empty($postrow[$i]['post_text_compiled']) || !empty($user->data['session_logged_in']) || !empty($config['posts_precompiled'])) ? false : $postrow[$i]['post_text_compiled'];
  1714. // CrackerTracker v5.x
  1715. $poster_miserable = ($postrow[$i]['ct_miserable_user'] == 1) ? true : false;
  1716. $is_miserable = ($poster_miserable && ($postrow[$i]['user_id'] == $user->data['user_id'])) ? true : false;
  1717. if ($poster_miserable && !$is_miserable)
  1718. {
  1719. // Maybe we should hide the miserable user tag for guests? ==> if ($user->data['session_logged_in'])
  1720. if (($user->data['user_level'] != ADMIN) && ($user->data['user_level'] != MOD))
  1721. {
  1722. // Normal users and guests...
  1723. // If you want to hide the post text, just decomment the line below!
  1724. $message = '';
  1725. }
  1726. $message .= "\n\n" . $lang['ctracker_mu_success_bbc'];
  1727. }
  1728. if ($poster_miserable)
  1729. {
  1730. $message_compiled = false;
  1731. }
  1732. // CrackerTracker v5.x
  1733. $user_sig = ($postrow[$i]['enable_sig'] && (trim($postrow[$i]['user_sig']) != '') && $config['allow_sig']) ? $postrow[$i]['user_sig'] : '';
  1734. // Replace Naughty Words - BEGIN
  1735. $post_subject = censor_text($post_subject);
  1736. $user_sig = censor_text($user_sig);
  1737. $message = censor_text($message);
  1738. // Replace Naughty Words - END
  1739. // BBCode Parsing
  1740. if($user_sig && empty($sig_cache[$postrow[$i]['user_id']]))
  1741. {
  1742. $bbcode->allow_bbcode = $config['allow_bbcode'] && $user->data['user_allowbbcode'];
  1743. //$bbcode->allow_smilies = true;
  1744. //$bbcode->allow_html = true;
  1745. $bbcode->allow_smilies = $config['allow_smilies'] && empty($lofi);
  1746. $bbcode->allow_html = $config['allow_html'] && $user->data['user_allowhtml'];
  1747. $bbcode->is_sig = true;
  1748. $bbcode->allow_hs = false;
  1749. $user_sig = $bbcode->parse($user_sig);
  1750. $bbcode->is_sig = false;
  1751. $bbcode->allow_hs = true;
  1752. $sig_cache[$postrow[$i]['user_id']] = $user_sig;
  1753. }
  1754. elseif($user_sig)
  1755. {
  1756. $user_sig = $sig_cache[$postrow[$i]['user_id']];
  1757. }
  1758. // Replace new lines (we use this rather than nl2br because till recently it wasn't XHTML compliant)
  1759. if ($user_sig != '')
  1760. {
  1761. $user_sig = '<br />' . $config['sig_line'] . '<br />' . $user_sig;
  1762. }
  1763. $bbcode->allow_html = (($config['allow_html'] && $user->data['user_allowhtml']) || $config['allow_html_only_for_admins']) && $postrow[$i]['enable_html'];
  1764. $bbcode->allow_bbcode = $config['allow_bbcode'] && $user->data['user_allowbbcode'] && $postrow[$i]['enable_bbcode'];
  1765. $bbcode->allow_smilies = $config['allow_smilies'] && empty($lofi) && $postrow[$i]['enable_smilies'];
  1766. if(preg_match('/\[code/i', $message))
  1767. {
  1768. $bbcode->allow_html = false;
  1769. }
  1770. if (strpos($message, '[imgba') !== false)
  1771. {
  1772. $config['jquery_ui'] = true;
  1773. $config['jquery_ui_ba'] = true;
  1774. }
  1775. if ($message_compiled === false)
  1776. {
  1777. $bbcode->code_post_id = $postrow[$i]['post_id'];
  1778. $message = $bbcode->parse($message);
  1779. $bbcode->code_post_id = 0;
  1780. if ($bbcode->allow_bbcode == false)
  1781. {
  1782. $message = str_replace("\n", "<br />", preg_replace("/\r\n/", "\n", $message));
  1783. }
  1784. if (empty($user->data['session_logged_in']) && empty($config['posts_precompiled']) && empty($lofi))
  1785. {
  1786. // update database
  1787. $sql = "UPDATE " . POSTS_TABLE . " SET post_text_compiled = '" . $db->sql_escape($message) . "' WHERE post_id='" . $postrow[$i]['post_id'] . "'";
  1788. $db->sql_query($sql);
  1789. }
  1790. }
  1791. else
  1792. {
  1793. $message = $message_compiled;
  1794. }
  1795. // Mighty Gorgon - New BBCode Functions - END
  1796. //Acronyms, AutoLinks - BEGIN
  1797. if ($postrow[$i]['enable_autolinks_acronyms'])
  1798. {
  1799. $message = $bbcode->acronym_pass($message);
  1800. $message = $bbcode->autolink_text($message, $forum_id);
  1801. }
  1802. //Acronyms, AutoLinks - END
  1803. // Highlight active words (primarily for search)
  1804. if ($highlight_match)
  1805. {
  1806. // This has been back-ported from 3.0 CVS
  1807. $message = preg_replace('#(?!<.*)(?<!\w)(' . $highlight_match . ')(?!\w|[^<>]*>)#i', '<span class="highlight-w"><b>\1</b></span>', $message);
  1808. }
  1809. // BEGIN CMX News Mod
  1810. // Strip out the <!--break--> delimiter.
  1811. if ($postrow[$i]['post_id'] == $topic_first_post_id)
  1812. {
  1813. $delim = htmlspecialchars('<!--break-->');
  1814. $pos = strpos($message, $delim);
  1815. if(($pos !== false) && ($pos < strlen($message)))
  1816. {
  1817. $message = substr_replace($message, html_entity_decode($delim), $pos, strlen($delim));
  1818. }
  1819. }
  1820. // END CMX News Mod
  1821. // Mighty Gorgon - ???
  1822. // $message = str_replace("\n", "\n<br />\n", $message);
  1823. // Mighty Gorgon - ???
  1824. // Editing information
  1825. $notes_list = array();
  1826. $notes_mod_display = false;
  1827. $notes_s_count = 0;
  1828. $notes_m_count = 0;
  1829. if (!empty($config['edit_notes']))
  1830. {
  1831. $notes_mod_display = (($user->data['user_level'] == ADMIN) || $is_auth['auth_mod']) ? true : false;
  1832. $notes_list_tmp = strlen($postrow[$i]['edit_notes']) ? unserialize($postrow[$i]['edit_notes']) : array();
  1833. foreach ($notes_list_tmp as $k => $v)
  1834. {
  1835. if ($notes_mod_display || empty($v['reserved']))
  1836. {
  1837. $notes_list[] = $v;
  1838. if (empty($v['reserved']))
  1839. {
  1840. $notes_s_count++;
  1841. }
  1842. else
  1843. {
  1844. $notes_m_count++;
  1845. }
  1846. }
  1847. }
  1848. if($notes_mod_display && (sizeof($delnote) == 2) && ($delnote[0] == $postrow[$i]['post_id']))
  1849. {
  1850. $new_list = array();
  1851. $num = intval($delnote[1]);
  1852. for($n = 0; $n < sizeof($notes_list); $n++)
  1853. {
  1854. if($n !== $num)
  1855. {
  1856. $new_list[] = $notes_list[$n];
  1857. }
  1858. }
  1859. $notes_list = $new_list;
  1860. $postrow[$i]['edit_notes'] = sizeof($notes_list) ? serialize($notes_list) : '';
  1861. $sql = "UPDATE " . POSTS_TABLE . " SET edit_notes = '" . $db->sql_escape($postrow[$i]['edit_notes']) . "' WHERE post_id = '" . $postrow[$i]['post_id'] . "'";
  1862. $db->sql_query($sql);
  1863. }
  1864. }
  1865. $show_edit_by = (($config['always_show_edit_by'] || !$notes_list) ? true : false);
  1866. if ($postrow[$i]['post_edit_count'] && $show_edit_by)
  1867. {
  1868. $l_edit_time_total = ($postrow[$i]['post_edit_count'] == 1) ? $lang['Edited_time_total'] : $lang['Edited_times_total'];
  1869. $l_edit_id = (intval($postrow[$i]['post_edit_id']) > 1) ? colorize_username($postrow[$i]['post_edit_id']) : $poster;
  1870. $l_edited_by = sprintf($l_edit_time_total, $l_edit_id, create_date_ip($config['default_dateformat'], $postrow[$i]['post_edit_time'], $config['board_timezone']), $postrow[$i]['post_edit_count']);
  1871. }
  1872. else
  1873. {
  1874. $l_edited_by = '';
  1875. }
  1876. // Convert and clean special chars!
  1877. $post_subject = htmlspecialchars_clean($post_subject);
  1878. // SMILEYS IN TITLE - BEGIN
  1879. if (($config['smilies_topic_title'] == true) && !$lofi)
  1880. {
  1881. $bbcode->allow_smilies = ($config['allow_smilies'] && $postrow[$i]['enable_smilies'] ? true : false);
  1882. $post_subject = $bbcode->parse_only_smilies($post_subject);
  1883. }
  1884. // SMILEYS IN TITLE - END
  1885. if (!empty($topic_calendar_time) && ($postrow[$i]['post_id'] == $topic_first_post_id))
  1886. {
  1887. $post_subject .= get_calendar_title($topic_calendar_time, $topic_calendar_duration);
  1888. }
  1889. // UPI2DB - BEGIN
  1890. if($user->data['upi2db_access'])
  1891. {
  1892. $post_edit_max = ($postrow[$i]['post_time'] >= $postrow[$i]['post_edit_time']) ? $postrow[$i]['post_time'] : $postrow[$i]['post_edit_time'];
  1893. $post_time_max = (empty($config['upi2db_edit_as_new'])) ? $postrow[$i]['post_time'] : $post_edit_max;
  1894. $post_id = $postrow[$i]['post_id'];
  1895. $mark_topic_unread_array = mark_post_viewtopic_array($post_time_max, $user->data['upi2db_unread'], $topic_id, $forum_id, $post_id, $except_time, $forum_topic_data['topic_type']);
  1896. }
  1897. // UPI2DB - END
  1898. $post_id = $postrow[$i]['post_id'];
  1899. $poster_number = ($postrow[$i]['poster_id'] == ANONYMOUS) ? '' : $lang['User_Number'] . ': ' . $postrow[$i]['poster_id'];
  1900. $post_edit_link = append_sid('edit_post_details.' . PHP_EXT . '?' . $forum_id_append . '&amp;' . $topic_id_append . '&amp;' . POST_POST_URL . '=' . $postrow[$i]['post_id']);
  1901. $post_edit_string_short = ($user->data['user_level'] == ADMIN) ? ('<a href="#" onclick="post_time_edit(\'' . $post_edit_link . '\'); return false;" style="text-decoration: none;" title="' . $lang['Edit_post_time_xs'] . '">' . $post_date . '</a>') : '';
  1902. $post_edit_string = ($user->data['user_level'] == ADMIN) ? ('<a href="#" onclick="post_time_edit(\'' . $post_edit_link . '\'); return false;" style="text-decoration: none;" title="' . $lang['Edit_post_time_xs'] . '">' . $lang['Edit_post_time_xs'] . '</a>') : '';
  1903. // Keep first post on every page - BEGIN
  1904. $single_post_number = empty($postrow[$i]['topic_first_post']) ? $i + 1 + $start : 1;
  1905. if (!empty($postrow[0]['topic_first_post']))
  1906. {
  1907. // if there was a first post, we skip it (by not adding + 1)
  1908. $single_post_number = ($i == 0) ? 1 : $i + $start;
  1909. }
  1910. else
  1911. {
  1912. // the "topic first post" isn't on
  1913. $single_post_number = $i + 1 + $start;
  1914. }
  1915. // Keep first post on every page - END
  1916. $single_post = ($user->data['is_bot'] ? ('#' . $single_post_number) : ('<a href="#_Single_Post_View" class="single-post-number" onclick="open_postreview(\'show_post.' . PHP_EXT . '?' . POST_POST_URL . '=' . intval($post_id) . '\'); return false;" style="text-decoration: none;">#' . $single_post_number . '</a>'));
  1917. $single_post_share = '<a href="#" onclick="popup(\'share.' . PHP_EXT . '?' . POST_POST_URL . '=' . intval($post_id) . '\', 840, 420, \'_post_share\'); return false;" style="text-decoration: none;">' . $lang['SHARE'] . '</a>';
  1918. $single_post_like_list = ($user->data['session_logged_in'] ? ('<a href="#" onclick="popup(\'topic_view_users.' . PHP_EXT . '?like=1&amp;' . POST_POST_URL . '=' . intval($post_id) . '\', 840, 420, \'_post_like\'); return false;" style="text-decoration: none;" title="' . $lang['LIKE_RECAP'] . '">' . '{USERS_LIKE}' . '</a>') : '{USERS_LIKE}');
  1919. // Mighty Gorgon - POSTS LIKES - BEGIN
  1920. $post_like_text = '';
  1921. $post_like_text_js = '';
  1922. if ($posts_like_enabled)
  1923. {
  1924. $users_like = sizeof($topic_posts_likes['posts'][$post_id]);
  1925. $reader_likes = false;
  1926. $post_like_text_single = false;
  1927. if (($user->data['user_id'] != ANONYMOUS) && !empty($topic_posts_likes['users'][$user->data['user_id']]) && in_array($post_id, $topic_posts_likes['users'][$user->data['user_id']]))
  1928. {
  1929. $reader_likes = true;
  1930. $users_like--;
  1931. }
  1932. if (!empty($users_like))
  1933. {
  1934. $post_like_text_single = ($users_like == 1) ? true : false;
  1935. }
  1936. if ($reader_likes)
  1937. {
  1938. if (empty($users_like))
  1939. {
  1940. $single_post_like_list = '';
  1941. $post_like_text = $lang['LIKE_COUNTER_YOU'];
  1942. $post_like_text_js = '';
  1943. }
  1944. elseif ($post_like_text_single)
  1945. {
  1946. $single_post_like_list = str_replace('{USERS_LIKE}', 1, $single_post_like_list);
  1947. $post_like_text = sprintf($lang['LIKE_COUNTER_YOU_OTHERS_SINGLE'], $single_post_like_list);
  1948. $post_like_text_js = sprintf($lang['LIKE_COUNTER_OTHERS_SINGLE'], $single_post_like_list);
  1949. }
  1950. else
  1951. {
  1952. $single_post_like_list = str_replace('{USERS_LIKE}', $users_like, $single_post_like_list);
  1953. $post_like_text = sprintf($lang['LIKE_COUNTER_YOU_OTHERS'], $single_post_like_list);
  1954. $post_like_text_js = sprintf($lang['LIKE_COUNTER_OTHERS'], $single_post_like_list);
  1955. }
  1956. }
  1957. else
  1958. {
  1959. if (empty($users_like))
  1960. {
  1961. $single_post_like_list = '';
  1962. $post_like_text = '';
  1963. $post_like_text_js = $lang['LIKE_COUNTER_YOU'];
  1964. }
  1965. elseif ($post_like_text_single)
  1966. {
  1967. $single_post_like_list = str_replace('{USERS_LIKE}', 1, $single_post_like_list);
  1968. $post_like_text = sprintf($lang['LIKE_COUNTER_OTHERS_SINGLE'], $single_post_like_list);
  1969. $post_like_text_js = sprintf($lang['LIKE_COUNTER_YOU_OTHERS_SINGLE'], $single_post_like_list);
  1970. }
  1971. else
  1972. {
  1973. $single_post_like_list = str_replace('{USERS_LIKE}', $users_like, $single_post_like_list);
  1974. $post_like_text = sprintf($lang['LIKE_COUNTER_OTHERS'], $single_post_like_list);
  1975. $post_like_text_js = sprintf($lang['LIKE_COUNTER_YOU_OTHERS'], $single_post_like_list);
  1976. }
  1977. }
  1978. }
  1979. // Mighty Gorgon - POSTS LIKES - END
  1980. // Mighty Gorgon - Feedback - BEGIN
  1981. $feedback_received = '';
  1982. $feedback_add = '';
  1983. if (!empty($config['plugins']['feedback']['enabled']) && !$feedback_disabled)
  1984. {
  1985. $feedback_details = get_user_feedback_received($postrow[$i]['user_id']);
  1986. if ($feedback_details['feedback_count'] > 0)
  1987. {
  1988. $feedback_average = (($feedback_details['feedback_count'] > 0) ? (round($feedback_details['feedback_sum'] / $feedback_details['feedback_count'], 1)) : 0);
  1989. $feedback_average_img = IP_ROOT_PATH . 'images/feedback/' . build_feedback_rating_image($feedback_average);
  1990. $feedback_received = (($feedback_details['feedback_count'] > 0) ? ($lang['FEEDBACK_RECEIVED'] . ': [ <a href="' . append_sid(PLUGINS_FEEDBACK_FILE . '?' . POST_USERS_URL . '=' . $postrow[$i]['user_id']) . '">' . $feedback_details['feedback_count'] . '</a> ]<br /><img src="' . $feedback_average_img . '" alt="' . $feedback_average . '" title="' . $feedback_average . '" /><br />') : '');
  1991. }
  1992. if (can_user_give_feedback_topic($user->data['user_id'], $topic_id) && can_user_give_feedback_global($user->data['user_id'], $topic_id) && ($user->data['user_id'] != $postrow[$i]['user_id']))
  1993. {
  1994. $feedback_add = '&nbsp;&nbsp;<a href="' . append_sid(PLUGINS_FEEDBACK_FILE . '?mode=input&amp;' . POST_TOPIC_URL . '=' . $topic_id . '&amp;' . POST_USERS_URL . '=' . $postrow[$i]['user_id']) . '">' . $lang['FEEDBACK_ADD'] . '</a><br />';
  1995. }
  1996. }
  1997. // Mighty Gorgon - Feedback - END
  1998. // Antispam Measures - BEGIN
  1999. $is_spam_measure_enabled = (($user->data['user_level'] != ADMIN) && (intval($config['spam_posts_number']) > 0) && ($postrow[$i]['user_posts'] < (int) $config['spam_posts_number'])) ? true : false;
  2000. if ($is_spam_measure_enabled)
  2001. {
  2002. $message = !empty($config['spam_disable_url']) ? str_replace(array('http://', 'https://', 'ftp://', 'www.'), array('h**p://', 'h**ps://', 'f*p://', '***.'), $bbcode->strip_only($message, array('a', 'img'))) : $message;
  2003. $user_sig = !empty($config['spam_hide_signature']) ? '' : $user_sig;
  2004. $email_url = '';
  2005. $email_img = '';
  2006. $email = '';
  2007. $www_url = '';
  2008. $www_img = '';
  2009. $www = '';
  2010. $aim_url = '';
  2011. $aim_img = '';
  2012. $aim = '';
  2013. $icq_url = '';
  2014. $icq_status_img = '';
  2015. $icq_img = '';
  2016. $icq = '';
  2017. $msn_url = '';
  2018. $msn_img = '';
  2019. $msn = '';
  2020. $skype_url = '';
  2021. $skype_img = '';
  2022. $skype = '';
  2023. $yahoo_url = '';
  2024. $yahoo_img = '';
  2025. $yahoo = '';
  2026. }
  2027. // Antispam Measures - END
  2028. // Again this will be handled by the templating code at some point
  2029. $row_class = (!($i % 2)) ? $theme['td_class1'] : $theme['td_class2'];
  2030. // ALL SOCIAL ICONS - BEGIN
  2031. $sn_im_tpl_array = array();
  2032. if (!empty($all_ims))
  2033. {
  2034. foreach ($all_ims as $k => $v)
  2035. {
  2036. $sn_im_tpl_array['IMG_SOCIAL_' . strtoupper($k)] = $v['img'];
  2037. }
  2038. }
  2039. // ALL SOCIAL ICONS - END
  2040. $vt_tpl_vars = array(
  2041. // Mighty Gorgon - Feedback - BEGIN
  2042. 'FEEDBACK' => $feedback_received . $feedback_add,
  2043. // Mighty Gorgon - Feedback - END
  2044. 'ROW_CLASS' => $row_class,
  2045. 'POSTER_ID' => ($poster_id != ANONYMOUS) ? $poster_id : false,
  2046. 'POSTER_NAME' => $poster,
  2047. 'POSTER_FULL_NAME' => $poster_full_name,
  2048. 'POSTER_NAME_QQ' => $poster_qq,
  2049. 'POSTER_NAME_QR' => str_replace(array(' ', '?', '&'), array('%20', '%3F', '%26'), $poster_qq),
  2050. //'POSTER_NAME_QR' => htmlspecialchars($poster_qq),
  2051. 'POSTER_AGE' => $poster_age,
  2052. 'HAPPY_BIRTHDAY' => $birtdhay_cake,
  2053. 'USER_RANK_01' => $user_ranks['rank_01_html'],
  2054. 'USER_RANK_01_IMG' => $user_ranks['rank_01_img_html'],
  2055. 'USER_RANK_02' => $user_ranks['rank_02_html'],
  2056. 'USER_RANK_02_IMG' => $user_ranks['rank_02_img_html'],
  2057. 'USER_RANK_03' => $user_ranks['rank_03_html'],
  2058. 'USER_RANK_03_IMG' => $user_ranks['rank_03_img_html'],
  2059. 'USER_RANK_04' => $user_ranks['rank_04_html'],
  2060. 'USER_RANK_04_IMG' => $user_ranks['rank_04_img_html'],
  2061. 'USER_RANK_05' => $user_ranks['rank_05_html'],
  2062. 'USER_RANK_05_IMG' => $user_ranks['rank_05_img_html'],
  2063. 'POSTER_GENDER' => $gender_image,
  2064. 'POSTER_JOINED' => $poster_joined,
  2065. 'POSTER_POSTS' => $poster_posts,
  2066. 'POSTER_FROM' => $poster_from,
  2067. 'POSTER_FROM_FULL' => $poster_from_full,
  2068. 'POSTER_FROM_FLAG' => $poster_from_flag,
  2069. 'POSTER_AVATAR' => $poster_avatar,
  2070. 'POST_DATE' => $post_date,
  2071. 'POST_EDIT_STRING' => $post_edit_string,
  2072. 'POST_EDIT_STRING_SHORT' => $post_edit_string_short,
  2073. //'POST_EDIT_LINK' => $post_edit_link,
  2074. 'POST_SUBJECT' => $post_subject,
  2075. 'MESSAGE' => $message,
  2076. 'PLAIN_MESSAGE' => $plain_message,
  2077. 'SIGNATURE' => $user_sig,
  2078. 'EDITED_MESSAGE' => $l_edited_by,
  2079. 'POSTER_STYLE' => $poster_style,
  2080. 'POSTER_LANG' => $poster_lang,
  2081. // Activity - BEGIN
  2082. 'POSTER_TROPHY' => (!empty($config['plugins']['activity']['enabled']) ? Amod_Build_Topics($hof_data, $postrow[$i]['user_id'], $postrow[$i]['user_trophies'], $postrow[$i]['username'], $postrow[$i]['ina_char_name']) : ''),
  2083. // Activity - END
  2084. 'MINI_POST_IMG' => $mini_post_img,
  2085. 'PROFILE_IMG' => $profile_img,
  2086. 'PROFILE' => $profile,
  2087. 'SEARCH_IMG' => $search_img,
  2088. 'SEARCH' => $search,
  2089. 'PM_IMG' => $pm_img,
  2090. 'PM' => $pm,
  2091. 'EMAIL_IMG' => (!$user->data['session_logged_in'] || $user->data['is_bot']) ? '' : $email_img,
  2092. 'EMAIL' => $email,
  2093. 'WWW_IMG' => $www_img,
  2094. 'WWW' => $www,
  2095. 'AIM_IMG' => $aim_img,
  2096. 'AIM' => $aim,
  2097. 'ICQ_STATUS_IMG' => $icq_status_img,
  2098. 'ICQ_IMG' => $icq_img,
  2099. 'ICQ' => $icq,
  2100. 'MSN_IMG' => $msn_img,
  2101. 'MSN' => $msn,
  2102. 'SKYPE_IMG' => $skype_img,
  2103. 'SKYPE' => $skype,
  2104. 'YIM_IMG' => $yahoo_img,
  2105. 'YIM' => $yahoo,
  2106. 'POSTER_ONLINE_STATUS_IMG' => $online_status_img,
  2107. 'S_THIS_POSTER_MASK' => !empty($this_poster_mask) ? true : false,
  2108. 'S_OWN_POST' => ($user->data['user_id'] == $poster_id) ? true : false,
  2109. 'S_POST_EDIT' => $edit_switch,
  2110. 'S_POST_DELETE' => $delpost_switch,
  2111. 'S_USER_ALLOW_VIEWEMAIL' => $email_switch,
  2112. 'S_USER_WEBSITE' => $postrow[$i]['user_website'],
  2113. 'L_S_POST_EDIT' => $lang['Edit_delete_post'],
  2114. 'L_S_POST_DELETE' => $lang['Delete_post'],
  2115. 'L_POST_QUOTE' => $lang['Reply_with_quote'],
  2116. 'L_VIEW_PROFILE' => $lang['Profile'],
  2117. 'L_SEND_PRIVMSG' => $lang['Send_private_message'],
  2118. 'L_SEND_EMAIL' => $lang['Send_email'],
  2119. 'L_USER_WEBSITE' => $lang['Visit_website'],
  2120. 'U_POST_EDIT' => append_sid('posting.' . PHP_EXT . '?mode=editpost&amp;' . $forum_id_append . '&amp;' . $topic_id_append . '&amp;' . POST_POST_URL . '=' . $postrow[$i]['post_id']),
  2121. 'U_POST_DELETE' => append_sid('posting.' . PHP_EXT . '?mode=delete&amp;' . $forum_id_append . '&amp;' . $topic_id_append . '&amp;' . POST_POST_URL . '=' . $postrow[$i]['post_id']),
  2122. 'U_POST_QUOTE' => append_sid('posting.' . PHP_EXT . '?mode=quote&amp;' . $forum_id_append . '&amp;' . $topic_id_append . '&amp;' . POST_POST_URL . '=' . $postrow[$i]['post_id']),
  2123. 'U_VIEW_PROFILE' => append_sid(CMS_PAGE_PROFILE . '?mode=viewprofile&amp;' . POST_USERS_URL . '=' . $poster_id),
  2124. 'U_SEND_PRIVMSG' => append_sid(CMS_PAGE_PRIVMSG . '?mode=post&amp;' . POST_USERS_URL . '=' . $poster_id),
  2125. 'U_SEND_EMAIL' => ($config['board_email_form']) ? append_sid(CMS_PAGE_PROFILE . '?mode=email&amp;' . POST_USERS_URL .'=' . $poster_id) : 'mailto:' . $postrow[$i]['user_email'],
  2126. 'U_USER_WEBSITE' => ($postrow[$i]['user_website']) ? $postrow[$i]['user_website'] : '',
  2127. 'IMG_POST_EDIT' => $images['icon_edit'],
  2128. 'IMG_POST_DELETE' => $images['icon_delpost'],
  2129. 'IMG_POST_QUOTE' => $images['icon_quote'],
  2130. 'IMG_VIEW_PROFILE' => $images['icon_profile'],
  2131. 'IMG_SEND_PRIVMSG' => $images['icon_pm'],
  2132. 'IMG_SEND_EMAIL' => $images['icon_email'],
  2133. 'IMG_USER_WEBSITE' => $images['icon_www'],
  2134. 'S_USER_OFFLINE' => $offline_status_switch,
  2135. 'S_USER_ONLINE' => $online_status_switch,
  2136. 'S_USER_HIDDEN' => $hidden_status_switch,
  2137. 'L_USER_OFFLINE' => $lang['Offline'],
  2138. 'L_USER_ONLINE' => $lang['Online'],
  2139. 'L_USER_HIDDEN' => $lang['Hidden'],
  2140. 'U_USER_ONLINE_STATUS' => $online_status_url,
  2141. 'IMG_USER_OFFLINE' => $images['icon_im_status_offline'],
  2142. 'IMG_USER_ONLINE' => $images['icon_im_status_online'],
  2143. 'IMG_USER_HIDDEN' => $images['icon_im_status_hidden'],
  2144. // Gender - BEGIN
  2145. 'S_GENDER_MALE' => $gender_male_switch,
  2146. 'S_GENDER_FEMALE' => $gender_female_switch,
  2147. 'L_GENDER_MALE' => $lang['Male'],
  2148. 'L_GENDER_FEMALE' => $lang['Female'],
  2149. 'IMG_GENDER_MALE' => $images['icon_minigender_male'],
  2150. 'IMG_GENDER_FEMALE' => $images['icon_minigender_female'],
  2151. // Gender - END
  2152. 'EDIT_IMG' => $edit_img,
  2153. 'EDIT' => $edit,
  2154. 'DELETE_IMG' => $delpost_img,
  2155. 'DELETE' => $delpost,
  2156. 'QUOTE_IMG' => $quote_img,
  2157. 'QUOTE' => $quote,
  2158. 'DOWNLOAD_IMG' => $images['icon_download2'],
  2159. 'DOWNLOAD_IMG_ICON' => $images['vt_post_download'],
  2160. 'IP_IMG' => $ip_img,
  2161. 'IP_IMG_ICON' => $ip_img_icon,
  2162. 'IP' => $ip,
  2163. 'U_PROFILE' => $profile_url,
  2164. 'U_PM' => $pm_url,
  2165. 'U_EMAIL' => $email_url,
  2166. 'U_WWW' => $www_url,
  2167. 'U_AIM' => $aim_url,
  2168. 'U_ICQ' => $icq_url,
  2169. 'U_MSN' => $msn_url,
  2170. 'U_SKYPE' => $skype_url,
  2171. 'U_YIM' => $yahoo_url,
  2172. 'L_POSTER_ONLINE_STATUS' => $online_status_lang,
  2173. 'POSTER_ONLINE_STATUS_CLASS' => $online_status_class,
  2174. 'U_POSTER_ONLINE_STATUS' => $online_status_url,
  2175. 'U_IP' => $ip_url,
  2176. 'U_QUOTE' => $quote_url,
  2177. 'U_EDIT' => $edit_url,
  2178. 'U_DELETE' => $delpost_url,
  2179. 'L_MINI_POST_ALT' => $mini_post_alt,
  2180. 'NOTES_MOD_DISPLAY' => $notes_mod_display,
  2181. 'NOTES_S_COUNT' => (int) $notes_s_count,
  2182. 'NOTES_M_COUNT' => (int) $notes_m_count,
  2183. 'NOTES_DATA' => $postrow[$i]['edit_notes'],
  2184. 'DOWNLOAD_POST' => append_sid(CMS_PAGE_VIEWTOPIC . '?download=' . $postrow[$i]['post_id'] . '&amp;' . $forum_id_append . '&amp;' . $topic_id_append . $kb_mode_append),
  2185. 'SINGLE_POST_NUMBER' => $single_post_number,
  2186. 'SINGLE_POST' => $single_post,
  2187. 'SINGLE_POST_SHARE' => $single_post_share,
  2188. 'READER_LIKES' => $reader_likes,
  2189. 'POST_LIKE_TEXT' => $post_like_text,
  2190. 'POST_LIKE_TEXT_JS' => str_replace(array('/'), array('\/'), addslashes($post_like_text)),
  2191. 'POST_LIKE_TEXT_JS_NEW' => str_replace(array('/'), array('\/'), addslashes($post_like_text_js)),
  2192. 'POSTER_NO' => $poster_number,
  2193. //'POSTER_NO' => $postrow[$i]['poster_id'],
  2194. 'USER_WARNINGS' => !empty($user_warnings) ? $user_warnings : '',
  2195. 'U_MINI_POST' => $mini_post_url,
  2196. // UPI2DB - BEGIN
  2197. 'UNREAD_COLOR' => !empty($unread_color) ? $unread_color : '',
  2198. 'UPI2DB_MARK_UNREAD' => !empty($mark_topic_unread_array['mark_unread']) ? true : false,
  2199. 'UPI2DB_CANT_MARK' => !empty($mark_topic_unread_array['cant_mark']) ? true : false,
  2200. 'UPI2DB_MARK_POST' => !empty($mark_topic_unread_array['mark_post']) ? true : false,
  2201. 'UPI2DB_UNMARK_POST' => !empty($mark_topic_unread_array['unmark_post']) ? true : false,
  2202. 'L_UPI2DB_MARK_UNREAD' => $lang['upi2db_mark_post_unread'],
  2203. 'L_UPI2DB_CANT_MARK' => $lang['upi2db_post_cant_mark'],
  2204. 'L_UPI2DB_MARK_POST' => $lang['upi2db_mark_post'],
  2205. 'L_UPI2DB_UNMARK_POST' => $lang['upi2db_unmark_post'],
  2206. 'UPI2DB_MARK_UNREAD_IMG' => $images['unread_img'],
  2207. 'UPI2DB_CANT_MARK_IMG' => $images['mark_img'],
  2208. 'UPI2DB_MARK_POST_IMG' => $images['mark_img'],
  2209. 'UPI2DB_UNMARK_POST_IMG' => $images['unmark_img'],
  2210. 'UPI2DB_MARK_UNREAD_URL' => append_sid(CMS_PAGE_VIEWFORUM . '?' . POST_TOPIC_URL . '=' . $topic_id . '&amp;' . POST_FORUM_URL . '=' . $forum_id . '&amp;' . POST_POST_URL . '=' . $post_id . '&amp;tt=' . $topic_type . '&amp;do=mark_unread'),
  2211. 'UPI2DB_CANT_MARK_URL' => '',
  2212. 'UPI2DB_MARK_POST_URL' => append_sid(CMS_PAGE_VIEWFORUM . '?' . POST_TOPIC_URL . '=' . $topic_id . '&amp;' . POST_FORUM_URL . '=' . $forum_id . '&amp;' . POST_POST_URL . '=' . $post_id . '&amp;tt=' . $topic_type . '&amp;do=mark_post'),
  2213. 'UPI2DB_UNMARK_POST_URL' => append_sid(CMS_PAGE_VIEWFORUM . '?' . POST_TOPIC_URL . '=' . $topic_id . '&amp;' . POST_FORUM_URL . '=' . $forum_id . '&amp;' . POST_POST_URL . '=' . $post_id . '&amp;tt=' . $topic_type . '&amp;do=unmark_post'),
  2214. // UPI2DB - END
  2215. // Cards - BEGIN
  2216. 'S_CARD' => append_sid('card.' . PHP_EXT),
  2217. 'CARD_IMG' => $card_img,
  2218. 'CARD_HIDDEN_FIELDS' => $card_hidden,
  2219. 'CARD_EXTRA_SPACE' => ($r_card_img || $y_card_img || $g_card_img || $b_card_img) ? ' ' : '',
  2220. // Backward compatibility - BEGIN
  2221. 'U_G_CARD' => $g_card_img,
  2222. 'U_Y_CARD' => $y_card_img,
  2223. 'U_R_CARD' => $r_card_img,
  2224. 'U_B_CARD' => $b_card_img,
  2225. // Backward compatibility - BEGIN
  2226. 'S_CARD_SWITCH' => ($s_card_switch_g || $s_card_switch_y || $s_card_switch_r || $s_card_switch_b || $s_card_switch_p) ? true : false,
  2227. 'S_CARD_SWITCH_G' => $s_card_switch_g ? true : false,
  2228. 'S_CARD_SWITCH_Y' => $s_card_switch_y ? true : false,
  2229. 'S_CARD_SWITCH_R' => $s_card_switch_r ? true : false,
  2230. 'S_CARD_SWITCH_B' => $s_card_switch_b ? true : false,
  2231. 'S_CARD_SWITCH_P' => $s_card_switch_p ? true : false,
  2232. 'S_CARD_SWITCH_Y_A' => $s_card_switch_y_assigned ? true : false,
  2233. 'S_CARD_SWITCH_R_A' => $s_card_switch_r_assigned ? true : false,
  2234. 'S_CARD_SWITCH_Y_R_A' => ($s_card_switch_y_assigned || $s_card_switch_r_assigned) ? true : false,
  2235. 'L_CARD_G' => $lang['Give_G_card'],
  2236. 'L_CARD_G_JS' => str_replace("'", "\'", sprintf($lang['Green_card_warning'], $current_user)),
  2237. 'L_CARD_Y' => sprintf($lang['Give_Y_card'], $user_warnings + 1),
  2238. 'L_CARD_Y_JS' => str_replace("'", "\'", sprintf($lang['Yellow_card_warning'], $current_user)),
  2239. 'L_CARD_R' => $lang['Give_R_card'],
  2240. 'L_CARD_R_JS' => str_replace("'", "\'", sprintf($lang['Red_card_warning'], $current_user)),
  2241. 'L_CARD_B' => $lang['Give_b_card'],
  2242. 'L_CARD_B_JS' => str_replace("'", "\'", $lang['Blue_card_warning']),
  2243. 'L_CARD_P' => sprintf($lang['Clear_b_card'], $postrow[$i]['post_bluecard']),
  2244. 'L_CARD_P_JS' => str_replace("'", "\'", $lang['Clear_blue_card_warning']),
  2245. 'L_CARD_Y_A' => sprintf($lang['Warnings'], $user_warnings),
  2246. 'L_CARD_R_A' => $lang['Banned'],
  2247. 'U_CARD_G' => 'card.' . PHP_EXT . '?mode=unban&amp;post_id=' . $postrow[$i]['post_id'] . '&amp;user_id=' . $user->data['user_id'] . '&amp;sid=' . $user->data['session_id'],
  2248. 'U_CARD_Y' => 'card.' . PHP_EXT . '?mode=warn&amp;post_id=' . $postrow[$i]['post_id'] . '&amp;user_id=' . $user->data['user_id'] . '&amp;sid=' . $user->data['session_id'],
  2249. 'U_CARD_R' => 'card.' . PHP_EXT . '?mode=ban&amp;post_id=' . $postrow[$i]['post_id'] . '&amp;user_id=' . $user->data['user_id'] . '&amp;sid=' . $user->data['session_id'],
  2250. 'U_CARD_B' => 'card.' . PHP_EXT . '?mode=report&amp;post_id=' . $postrow[$i]['post_id'] . '&amp;user_id=' . $user->data['user_id'] . '&amp;sid=' . $user->data['session_id'],
  2251. 'U_CARD_P' => 'card.' . PHP_EXT . '?mode=' . (($postrow[$i]['post_bluecard']) ? 'report_reset' : 'report') . '&amp;post_id=' . $postrow[$i]['post_id'] . '&amp;user_id=' . $user->data['user_id'] . '&amp;sid=' . $user->data['session_id'],
  2252. 'IMG_CARD_G' => $images['icon_g_card'],
  2253. 'IMG_CARD_Y' => $images['icon_y_card'],
  2254. 'IMG_CARD_R' => $images['icon_r_card'],
  2255. 'IMG_CARD_B' => $images['icon_b_card'],
  2256. 'IMG_CARD_P' => $images['icon_p_card'],
  2257. 'IMG_CARD_Y_A' => $images['icon_y_cards'],
  2258. 'IMG_CARD_R_A' => $images['icon_r_cards'],
  2259. // Card - END
  2260. 'S_FIRST_POST' => ($postrow[$i]['post_id'] == $topic_first_post_id) ? true : false,
  2261. 'U_TOPIC_ID' => $topic_id,
  2262. 'U_POST_ID' => $postrow[$i]['post_id']
  2263. );
  2264. // New Postrow TPL... to be able to assign dynamically some fields!
  2265. $template->assign_block_vars('postrow', array_merge($sn_im_tpl_array, $vt_tpl_vars));
  2266. // MG Cash MOD For IP - BEGIN
  2267. if (!empty($config['plugins']['cash']['enabled']))
  2268. {
  2269. $cm_viewtopic->post_vars($postrow[$i], $user->data, $forum_id);
  2270. }
  2271. // MG Cash MOD For IP - END
  2272. if (!empty($config['plugins']['album']['enabled']))
  2273. {
  2274. // --- Smart Album Button BEGIN ----------------
  2275. $album_url = '';
  2276. $album_switch = false;
  2277. if ($postrow[$i]['user_personal_pics_count'] > 0)
  2278. {
  2279. $album_switch = true;
  2280. $album_url = ($postrow[$i]['user_personal_pics_count']) ? append_sid('album.' . PHP_EXT . '?user_id=' . $postrow[$i]['user_id']) : '';
  2281. $album_img = ($postrow[$i]['user_personal_pics_count']) ? '<a href="' . $album_url . '"><img src="' . $images['icon_album'] . '" alt="' . $lang['Show_Personal_Gallery'] . '" title="' . $lang['Show_Personal_Gallery'] . '" /></a>' : '';
  2282. $album = ($postrow[$i]['user_personal_pics_count']) ? '<a href="' . $album_url . '">' . $lang['Show_Personal_Gallery'] . '</a>' : '';
  2283. }
  2284. else
  2285. {
  2286. $album_img = '';
  2287. $album = '';
  2288. }
  2289. // --- Smart Album Button END ----------------
  2290. if (!$is_spam_measure_enabled && ($poster_id != ANONYMOUS))
  2291. {
  2292. $template->assign_vars(array(
  2293. 'ALBUM_IMG' => $album_img,
  2294. 'ALBUM' => $album,
  2295. 'S_USER_ALBUM' => $album_switch,
  2296. 'L_S_USER_ALBUM' => $lang['Show_Personal_Gallery'],
  2297. 'U_USER_ALBUM' => ($postrow[$i]['user_personal_pics_count']) ? append_sid('album.' . PHP_EXT . '?user_id=' . $postrow[$i]['user_id']) : '',
  2298. 'IMG_USER_ALBUM' => $images['icon_album'],
  2299. 'U_ALBUM' => $album_url,
  2300. )
  2301. );
  2302. }
  2303. }
  2304. // Custom Profile Fields MOD - BEGIN
  2305. if (($poster_id != ANONYMOUS) && ($profile_data_sql != ''))
  2306. {
  2307. $language = $config['default_lang'];
  2308. if (!file_exists(IP_ROOT_PATH . 'language/lang_' . $language . '/lang_profile_fields.' . PHP_EXT))
  2309. {
  2310. $language = 'english';
  2311. }
  2312. include(IP_ROOT_PATH . 'language/lang_' . $language . '/lang_profile_fields.' . PHP_EXT);
  2313. $cp_data = array();
  2314. $cp_data = get_topic_udata($postrow[$i], $profile_data);
  2315. if ($cp_data['aboves'])
  2316. {
  2317. foreach($cp_data['aboves'] as $above_val)
  2318. {
  2319. $template->assign_block_vars('postrow.above_sig', array('ABOVE_VAL' => $above_val));
  2320. }
  2321. }
  2322. if ($cp_data['belows'])
  2323. {
  2324. foreach($cp_data['belows'] as $below_val)
  2325. {
  2326. $template->assign_block_vars('postrow.below_sig', array('BELOW_VAL' => $below_val));
  2327. }
  2328. }
  2329. if ($cp_data['author'])
  2330. {
  2331. foreach($cp_data['author'] as $author_val)
  2332. {
  2333. $template->assign_block_vars('postrow.author_profile', array('AUTHOR_VAL' => $author_val));
  2334. }
  2335. }
  2336. }
  2337. // Custom Profile Fields MOD - END
  2338. if ($config['switch_poster_info_topic'])
  2339. {
  2340. $template->assign_block_vars('postrow.switch_poster_info', array());
  2341. }
  2342. if ($user->data['user_showavatars'])
  2343. {
  2344. $template->assign_block_vars('postrow.switch_showavatars', array());
  2345. }
  2346. if ($user->data['user_showsignatures'])
  2347. {
  2348. $template->assign_block_vars('postrow.switch_showsignatures', array());
  2349. }
  2350. display_post_attachments($postrow[$i]['post_id'], $postrow[$i]['post_attachment']);
  2351. //if ((!$forum_topic_data['forum_status'] == FORUM_LOCKED) && (!$forum_topic_data['topic_status'] == TOPIC_LOCKED) && ($is_auth['auth_reply']) && ($user->data['session_logged_in']))
  2352. if ((!$forum_topic_data['forum_status'] == FORUM_LOCKED) && (!$forum_topic_data['topic_status'] == TOPIC_LOCKED) && ($is_auth['auth_reply']) && $config['enable_quick_quote'] && !$user->data['is_bot'])
  2353. {
  2354. $template->assign_block_vars('postrow.switch_quick_quote', array());
  2355. }
  2356. if ($i == 0)
  2357. {
  2358. $viewtopic_banner_text = get_ad('vtx');
  2359. if (!empty($viewtopic_banner_text))
  2360. {
  2361. $template->assign_vars(array(
  2362. 'VIEWTOPIC_BANNER_CODE' => $viewtopic_banner_text,
  2363. )
  2364. );
  2365. // Decomment this if you want sponsors to be shown everywhere
  2366. $template->assign_block_vars('postrow.switch_viewtopic_banner', array());
  2367. // Use this if you want to block sponsors not readable by guests
  2368. /*
  2369. if ($this_forum_auth_read > 0)
  2370. {
  2371. $template->assign_block_vars('postrow.switch_viewtopic_banner', array());
  2372. }
  2373. */
  2374. }
  2375. $template->assign_block_vars('postrow.switch_first_post', array());
  2376. }
  2377. if (!empty($config['edit_notes']))
  2378. {
  2379. $template->assign_vars(array(
  2380. 'S_EDIT_NOTES' => true,
  2381. )
  2382. );
  2383. for($n = 0; $n < sizeof($notes_list); $n++)
  2384. {
  2385. if(!isset($user_ids[$notes_list[$n]['poster']]))
  2386. {
  2387. $user_ids[$notes_list[$n]['poster']] = 'n/a';
  2388. $user_ids2[] = $notes_list[$n]['poster'];
  2389. }
  2390. }
  2391. // add notes
  2392. unset($item);
  2393. if(!empty($template->_tpldata['postrow.'][$i]['NOTES_DATA']))
  2394. {
  2395. $item = &$template->_tpldata['postrow.'][$i];
  2396. $item['notes.'] = array();
  2397. $list = unserialize($item['NOTES_DATA']);
  2398. for($j = 0; $j < sizeof($list); $j++)
  2399. {
  2400. $notes_tpl_var_name = $list[$j]['reserved'] ? 'notes_mod.' : 'notes.';
  2401. if (($notes_tpl_var_name == 'notes.') || (($notes_tpl_var_name == 'notes_mod.') && $notes_mod_display))
  2402. {
  2403. $item[$notes_tpl_var_name][] = array(
  2404. 'L_EDITED_BY' => $lang['Edited_by'],
  2405. 'POSTER_NAME' => colorize_username($list[$j]['poster']),
  2406. 'POSTER_PROFILE' => append_sid(CMS_PAGE_PROFILE . '?mode=viewprofile&amp;' . POST_USERS_URL . '=' . $list[$j]['poster']),
  2407. 'TEXT' => htmlspecialchars($list[$j]['text']),
  2408. 'TIME' => create_date_ip($config['default_dateformat'], $list[$j]['time'], $config['board_timezone']),
  2409. 'L_DELETE_NOTE' => $lang['Delete_note'],
  2410. 'U_DELETE' => $is_auth['auth_mod'] ? ($template->vars['U_VIEW_TOPIC'] . '&amp;delnote=' . $item['U_POST_ID'] . '.' . $j) : '',
  2411. );
  2412. }
  2413. }
  2414. unset($item);
  2415. }
  2416. }
  2417. // Cards counter... this has to be here!
  2418. for ($n = 0; $n < $s_card_y_counter; $n++)
  2419. {
  2420. $template->assign_block_vars('postrow.cards_y', array('Y_CARD' => true));
  2421. }
  2422. }
  2423. $topic_useful_box = false;
  2424. if (!$user->data['is_bot'])
  2425. {
  2426. $rating_auth_data = rate_auth($user->data['user_id'], $forum_id, $topic_id);
  2427. $rating_box = ((($rating_auth_data == RATE_AUTH_NONE) || ($rating_auth_data == RATE_AUTH_DENY)) ? false : true);
  2428. $sb_box = $config['show_social_bookmarks'] ? true : false;
  2429. $ltt_box = $config['link_this_topic'] ? true : false;
  2430. $topic_useful_box = (($rating_box || $sb_box || $ltt_box) ? true : false);
  2431. }
  2432. if ($topic_useful_box)
  2433. {
  2434. $template->assign_block_vars('switch_topic_useful', array());
  2435. if ($sb_box)
  2436. {
  2437. $template->assign_block_vars('switch_topic_useful.social_bookmarks', array());
  2438. }
  2439. if ($rating_box)
  2440. {
  2441. ratings_view_topic();
  2442. }
  2443. if ($ltt_box)
  2444. {
  2445. $template->assign_block_vars('switch_topic_useful.link_this_topic', array());
  2446. }
  2447. }
  2448. if ($posts_like_enabled)
  2449. {
  2450. $config['ajax_features'] = true;
  2451. $template->assign_vars(array(
  2452. 'S_POSTS_LIKES' => true,
  2453. )
  2454. );
  2455. }
  2456. // Don't update the topic view counter if viewer is poster or a BOT
  2457. if (($postrow[0]['user_id'] != $user->data['user_id']) && !$user->data['is_bot'])
  2458. {
  2459. // Update the topic view counter
  2460. $sql = "UPDATE " . TOPICS_TABLE . "
  2461. SET topic_views = topic_views + 1
  2462. WHERE topic_id = " . $topic_id;
  2463. $db->sql_query($sql);
  2464. }
  2465. // UPI2DB - BEGIN
  2466. if($user->data['upi2db_access'])
  2467. {
  2468. delete_read_posts($read_posts);
  2469. }
  2470. // UPI2DB - END
  2471. $viewtopic_banner_top = get_ad('vtt');
  2472. $viewtopic_banner_bottom = get_ad('vtb');
  2473. $template->assign_vars(array(
  2474. 'VIEWTOPIC_BANNER_TOP' => $viewtopic_banner_top,
  2475. 'VIEWTOPIC_BANNER_BOTTOM' => $viewtopic_banner_bottom,
  2476. )
  2477. );
  2478. if($can_reply)
  2479. {
  2480. if (!function_exists('generate_smilies_row'))
  2481. {
  2482. include_once(IP_ROOT_PATH . 'includes/functions_bbcode.' . PHP_EXT);
  2483. }
  2484. generate_smilies_row();
  2485. }
  2486. // Force to false page_nav because viewtopic has its own breadcrumbs...
  2487. $cms_page['page_nav'] = false;
  2488. full_page_generation($template_to_parse, $meta_content['page_title'], $meta_content['description'], $meta_content['keywords']);
  2489. ?>