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

/posting.php

http://github.com/MightyGorgon/icy_phoenix
PHP | 2564 lines | 2071 code | 260 blank | 233 comment | 672 complexity | 68a1ad9e1d79eb77c6463c3fac58861f 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_POSTING', true);
  17. // MG Cash MOD For IP - BEGIN
  18. define('IN_CASHMOD', true);
  19. define('CM_POSTING', true);
  20. // MG Cash MOD For IP - END
  21. // Added to optimize memory for attachments
  22. define('ATTACH_DISPLAY', true);
  23. define('ATTACH_POSTING', true);
  24. define('CT_SECLEVEL', 'MEDIUM');
  25. $ct_ignorepvar = array('helpbox');
  26. define('IN_ICYPHOENIX', true);
  27. if (!defined('IP_ROOT_PATH')) define('IP_ROOT_PATH', './');
  28. if (!defined('PHP_EXT')) define('PHP_EXT', substr(strrchr(__FILE__, '.'), 1));
  29. include(IP_ROOT_PATH . 'common.' . PHP_EXT);
  30. include_once(IP_ROOT_PATH . 'includes/bbcode.' . PHP_EXT);
  31. include_once(IP_ROOT_PATH . 'includes/functions_post.' . PHP_EXT);
  32. include_once(IP_ROOT_PATH . 'includes/functions_topics.' . PHP_EXT);
  33. include_once(IP_ROOT_PATH . 'includes/functions_calendar.' . PHP_EXT);
  34. // Event Registration - BEGIN
  35. include_once(IP_ROOT_PATH . 'includes/functions_events_reg.' . PHP_EXT);
  36. // Event Registration - END
  37. @include_once(IP_ROOT_PATH . 'includes/class_topics.' . PHP_EXT);
  38. $class_topics = new class_topics();
  39. $use_jquery_tags = (!empty($config['use_jquery_tags']) && empty($user->data['mobile_style'])) ? true : false;
  40. //$use_jquery_tags = false;
  41. $config['jquery_ui'] = true;
  42. if (!empty($use_jquery_tags))
  43. {
  44. $config['jquery_tags'] = true;
  45. }
  46. // Init common vars: forum_id, topic_id, post_id, etc.
  47. $class_topics->var_init(true);
  48. // Check and set various parameters
  49. $sid = request_var('sid', '');
  50. $mode = request_var('mode', '');
  51. $submit = request_var('post', '');
  52. $news_category = request_var('news_category', '');
  53. $preview = request_var('preview', '');
  54. $draft = request_var('draft', '');
  55. $draft_mode = request_var('draft_mode', '');
  56. $delete = request_var('delete', '');
  57. $poll_delete = request_var('poll_delete', '');
  58. $poll_add = request_var('add_poll_option', '');
  59. $poll_edit = request_var('edit_poll_option', '');
  60. // UPI2DB - BEGIN
  61. $mark_edit = request_var('mark_edit', '');
  62. // UPI2DB - END
  63. $start = request_var('start', 0);
  64. $start = ($start < 0) ? 0 : $start;
  65. $confirm = isset($_POST['confirm']) ? true : false;
  66. $draft_confirm = !empty($_POST['draft_confirm']) ? true : false;
  67. $draft = (!empty($draft) || $draft_confirm) ? true : false;
  68. $lock_subject = request_var('lock_subject', 0);
  69. $draft_subject = '';
  70. $draft_message = '';
  71. if ($config['allow_drafts'] && ($draft_mode == 'draft_load') && ($draft_id > 0))
  72. {
  73. $sql = "SELECT d.*
  74. FROM " . DRAFTS_TABLE . " d
  75. WHERE d.draft_id = " . $draft_id . "
  76. LIMIT 1";
  77. $result = $db->sql_query($sql);
  78. if ($draft_row = $db->sql_fetchrow($result))
  79. {
  80. $db->sql_freeresult($result);
  81. if ($draft_row['forum_id'] > 0)
  82. {
  83. $forum_id = $draft_row['forum_id'];
  84. if ($draft_row['topic_id'] > 0)
  85. {
  86. $topic_id = $draft_row['topic_id'];
  87. }
  88. else
  89. {
  90. $topic_id = '';
  91. }
  92. $draft_subject = $draft_row['draft_subject'];
  93. $draft_message = htmlspecialchars_decode($draft_row['draft_message'], ENT_COMPAT);
  94. $preview = true;
  95. }
  96. else
  97. {
  98. $draft_subject = $draft_row['draft_subject'];
  99. $draft_message = $draft_row['draft_message'];
  100. $preview = true;
  101. }
  102. }
  103. }
  104. $forum_id_append = (!empty($forum_id) ? (POST_FORUM_URL . '=' . $forum_id) : '');
  105. $topic_id_append = (!empty($topic_id) ? (POST_TOPIC_URL . '=' . $topic_id) : '');
  106. $post_id_append = (!empty($post_id) ? (POST_POST_URL . '=' . $post_id) : '');
  107. // . (!empty($forum_id_append) ? ($forum_id_append . '&amp;') : '') . (!empty($topic_id_append) ? ($topic_id_append . '&amp;') : '') . $post_id_append
  108. $s_hidden_fields = '';
  109. $hidden_form_fields = '';
  110. $refresh = !empty($preview) || $poll_add || $poll_edit || $poll_delete || ($draft && !$draft_confirm);
  111. // Set topic type
  112. //echo $topic_type;
  113. //$topic_type = (in_array($topic_type, array(0, 1, 2, 3, 4))) ? $topic_type : POST_NORMAL;
  114. $topic_show_portal = (!empty($_POST['topic_show_portal'])) ? true : false;
  115. $topic_type = request_var('topictype', POST_NORMAL);
  116. if (!$topic_type)
  117. {
  118. $topic_type = POST_NORMAL;
  119. }
  120. // Maybe better do not replace these $_POST with request_var, or we may have further problems later
  121. $year = request_post_var('topic_calendar_year', 0);
  122. $month = request_post_var('topic_calendar_month', 0);
  123. $day = request_post_var('topic_calendar_day', 0);
  124. $hour = request_post_var('topic_calendar_hour', 0);
  125. $min = request_post_var('topic_calendar_min', 0);
  126. $d_day = request_post_var('topic_calendar_duration_day', 0);
  127. $d_hour = request_post_var('topic_calendar_duration_hour', 0);
  128. $d_min = request_post_var('topic_calendar_duration_min', 0);
  129. // this array will hold the plugin-specific variables
  130. $extra_vars = array();
  131. /**
  132. * @event posting.post_vars.
  133. * @description Allows to read POST data to be used later.
  134. * @since 3.0
  135. * @var int topic_type The topic type.
  136. * @var array extra_vars The extra variables that'll be carried throughout this file.
  137. */
  138. $vars = array(
  139. 'topic_type',
  140. 'extra_vars',
  141. );
  142. extract($class_plugins->trigger('posting.post_vars', compact($vars)));
  143. if (empty($year) || empty($month) || empty($day))
  144. {
  145. $year = '';
  146. $month = '';
  147. $day = '';
  148. $hour = '';
  149. $min = '';
  150. $d_day = '';
  151. $d_hour = '';
  152. $d_min = '';
  153. }
  154. if (empty($hour) && empty($min))
  155. {
  156. $hour = '';
  157. $min = '';
  158. $d_hour = '';
  159. $d_min = '';
  160. }
  161. // start event
  162. $topic_calendar_time = 0;
  163. if (!empty($year))
  164. {
  165. $topic_calendar_time = gmmktime(intval($hour), intval($min), 0, intval($month), intval($day), intval($year));
  166. }
  167. // duration
  168. $topic_calendar_duration = 0;
  169. $d_dur = $d_day . $d_hour . $d_min;
  170. if (!empty($topic_calendar_time) && !empty($d_dur))
  171. {
  172. $topic_calendar_duration = intval($d_day) * 86400 + intval($d_hour) * 3600 + intval($d_min) * 60;
  173. if ($topic_calendar_duration < 0)
  174. {
  175. $topic_calendar_duration = 0;
  176. }
  177. }
  178. // If the mode is set to topic review then output that review...
  179. if ($mode == 'topicreview')
  180. {
  181. require(IP_ROOT_PATH . 'includes/topic_review.' . PHP_EXT);
  182. topic_review($forum_id, $topic_id, false);
  183. exit;
  184. }
  185. elseif ($mode == 'smilies')
  186. {
  187. generate_smilies('window');
  188. exit;
  189. }
  190. // Start session management
  191. $user->session_begin();
  192. $auth->acl($user->data);
  193. $user->setup();
  194. // End session management
  195. // DNSBL CHECK - BEGIN
  196. if (!empty($config['check_dnsbl_posting']) && in_array($mode, array('newtopic', 'reply', 'editpost')) && !empty($submit))
  197. {
  198. if (($dnsbl = $user->check_dnsbl('post')) !== false)
  199. {
  200. $error[] = sprintf($lang['IP_BLACKLISTED'], $user->ip, $dnsbl[1], $dnsbl[1]);
  201. }
  202. if (!empty($error))
  203. {
  204. $message = implode('<br />', $error);
  205. message_die(GENERAL_MESSAGE, $message);
  206. }
  207. }
  208. // DNSBL CHECK - END
  209. // Was cancel pressed? If so then redirect to the appropriate page, no point in continuing with any further checks
  210. if (isset($_POST['cancel']))
  211. {
  212. if ($postreport)
  213. {
  214. $redirect = CMS_PAGE_VIEWTOPIC . '?' . (!empty($forum_id_append) ? ($forum_id_append . '&') : '') . (!empty($topic_id_append) ? ($topic_id_append . '&') : '') . POST_POST_URL . '=' . $postreport;
  215. $post_append = '';
  216. }
  217. elseif ($post_id)
  218. {
  219. $redirect = CMS_PAGE_VIEWTOPIC . '?' . (!empty($forum_id_append) ? ($forum_id_append . '&') : '') . (!empty($topic_id_append) ? ($topic_id_append . '&') : '') . $post_id_append;
  220. $post_append = '#p' . $post_id;
  221. }
  222. elseif ($topic_id)
  223. {
  224. $redirect = CMS_PAGE_VIEWTOPIC . '?' . (!empty($forum_id_append) ? ($forum_id_append . '&') : '') . $topic_id_append;
  225. $post_append = '';
  226. }
  227. elseif ($forum_id)
  228. {
  229. $redirect = CMS_PAGE_VIEWFORUM . '?' . $forum_id_append;
  230. $post_append = '';
  231. }
  232. else
  233. {
  234. $redirect = CMS_PAGE_FORUM;
  235. $post_append = '';
  236. }
  237. redirect(append_sid($redirect, true) . $post_append);
  238. }
  239. // What auth type do we need to check?
  240. $is_auth = array();
  241. $is_auth_type = '';
  242. $is_auth_type_cal = '';
  243. $read_only_write_auth_required = false;
  244. switch($mode)
  245. {
  246. case 'newtopic':
  247. // TODO: these also need to be checked if ($mode == 'editpost' && $post_data['first_post'])
  248. $read_only_write_auth_required = true;
  249. if ($topic_type == POST_GLOBAL_ANNOUNCE)
  250. {
  251. $is_auth_type = 'auth_globalannounce';
  252. }
  253. elseif ($topic_type == POST_ANNOUNCE)
  254. {
  255. $is_auth_type = 'auth_announce';
  256. }
  257. elseif ($topic_type == POST_STICKY)
  258. {
  259. $is_auth_type = 'auth_sticky';
  260. }
  261. else
  262. {
  263. $is_auth_type = 'auth_post';
  264. }
  265. if (!empty($topic_calendar_time))
  266. {
  267. $is_auth_type_cal = 'auth_cal';
  268. }
  269. break;
  270. case 'reply':
  271. case 'quote':
  272. $read_only_write_auth_required = true;
  273. $is_auth_type = 'auth_reply';
  274. break;
  275. case 'editpost':
  276. $read_only_write_auth_required = true;
  277. $is_auth_type = 'auth_edit';
  278. break;
  279. case 'delete':
  280. case 'poll_delete':
  281. $read_only_write_auth_required = true;
  282. $is_auth_type = 'auth_delete';
  283. break;
  284. case 'vote':
  285. $is_auth_type = 'auth_vote';
  286. break;
  287. // Event Registration - BEGIN
  288. case 'register':
  289. $is_auth_type = 'auth_vote';
  290. break;
  291. // Event Registration - END
  292. case 'topicreview':
  293. $is_auth_type = 'auth_read';
  294. break;
  295. default:
  296. message_die(GENERAL_MESSAGE, $lang['No_post_mode']);
  297. break;
  298. }
  299. //if ($read_only_write_auth_required && $config['read_only_forum'])
  300. if ($read_only_write_auth_required && $config['read_only_forum'] && ($user->data['user_level'] != ADMIN))
  301. {
  302. message_die(GENERAL_MESSAGE, $lang['READ_ONLY_FORUM']);
  303. }
  304. //
  305. // Here we do various lookups to find topic_id, forum_id, post_id etc.
  306. // Doing it here prevents spoofing (eg. faking forum_id, topic_id or post_id
  307. //
  308. $error_msg = '';
  309. $post_data = array();
  310. switch ($mode)
  311. {
  312. case 'newtopic':
  313. if (empty($forum_id))
  314. {
  315. if (!defined('STATUS_404')) define('STATUS_404', true);
  316. message_die(GENERAL_MESSAGE, 'NO_FORUM');
  317. }
  318. $sql = "SELECT f.*
  319. FROM " . FORUMS_TABLE . " f
  320. WHERE f.forum_id = " . $forum_id . "
  321. LIMIT 1";
  322. break;
  323. case 'reply':
  324. case 'vote':
  325. // Event Registration - BEGIN
  326. case 'register':
  327. // Event Registration - END
  328. if (empty($topic_id))
  329. {
  330. message_die(GENERAL_MESSAGE, $lang['No_topic_id']);
  331. }
  332. $sql = "SELECT f.*, t.*
  333. FROM " . FORUMS_TABLE . " f, " . TOPICS_TABLE . " t
  334. WHERE t.topic_id = " . $topic_id . "
  335. AND f.forum_id = t.forum_id
  336. LIMIT 1";
  337. break;
  338. case 'quote':
  339. case 'editpost':
  340. case 'delete':
  341. case 'poll_delete':
  342. if (empty($post_id))
  343. {
  344. message_die(GENERAL_MESSAGE, $lang['No_post_id']);
  345. }
  346. // MG Cash MOD For IP - BEGIN
  347. if (!empty($config['plugins']['cash']['enabled']))
  348. {
  349. $temp = $submit;
  350. $submit = !(!$submit || (isset($config['cash_disable']) && !$config['cash_disable'] && (($mode == 'editpost') || ($mode == 'delete'))));
  351. }
  352. // MG Cash MOD For IP - END
  353. $query = array(
  354. 'SELECT' => array('f.*', 't.*', 'p.*'),
  355. 'FROM' => array(
  356. POSTS_TABLE => 'p',
  357. TOPICS_TABLE => 't',
  358. FORUMS_TABLE => 'f',
  359. ),
  360. 'WHERE' => array(
  361. 'p.post_id = ' . $post_id,
  362. 't.topic_id = p.topic_id',
  363. 'f.forum_id = p.forum_id',
  364. ),
  365. 'LIMIT' => 1,
  366. );
  367. if (!$submit)
  368. {
  369. $query['SELECT'] = array_merge($query['SELECT'], array('u.username', 'u.user_id', 'u.user_sig', 'u.user_level', 'u.user_active', 'u.user_color'));
  370. $query['FROM'][USERS_TABLE] = 'u';
  371. $query['WHERE'][] = 'u.user_id = p.poster_id';
  372. }
  373. /**
  374. * @event posting.before_select.
  375. * @description Allows to edit the query to look up the forum / topic / post data.
  376. * @since 3.0
  377. * @var array query The SQL query parts.
  378. */
  379. extract($class_plugins->trigger('posting.before_select', compact('query')));
  380. $sql = $db->sql_build_query('SELECT', $query);
  381. // MG Cash MOD For IP - BEGIN
  382. if (!empty($config['plugins']['cash']['enabled']))
  383. {
  384. $submit = $temp;
  385. unset($temp);
  386. }
  387. // MG Cash MOD For IP - END
  388. break;
  389. default:
  390. message_die(GENERAL_MESSAGE, $lang['No_valid_mode']);
  391. }
  392. $result = $db->sql_query($sql);
  393. $post_info = $db->sql_fetchrow($result);
  394. if ($result && $post_info)
  395. {
  396. $db->sql_freeresult($result);
  397. $forum_id = $post_info['forum_id'];
  398. if (!empty($post_info['topic_calendar_duration']))
  399. {
  400. $post_info['topic_calendar_duration']++;
  401. }
  402. $forum_name = get_object_lang(POST_FORUM_URL . $post_info['forum_id'], 'name');
  403. $is_auth = auth(AUTH_ALL, $forum_id, $user->data, $post_info);
  404. // Topic Lock/Unlock
  405. $lock = (isset($_POST['lock'])) ? true : false;
  406. $unlock = (isset($_POST['unlock'])) ? true : false;
  407. if (($submit || $confirm) && ($lock || $unlock) && $is_auth['auth_mod'] && ($mode != 'newtopic') && (!$refresh))
  408. {
  409. $t_id = (!isset($post_info['topic_id'])) ? $topic_id : $post_info['topic_id'];
  410. if ($lock || $unlock)
  411. {
  412. $sql = "UPDATE " . TOPICS_TABLE . "
  413. SET topic_status = " . ($lock ? TOPIC_LOCKED : TOPIC_UNLOCKED) . "
  414. WHERE topic_id = " . $t_id . "
  415. AND topic_moved_id = 0";
  416. $result = $db->sql_query($sql);
  417. }
  418. }
  419. if (($post_info['forum_status'] == FORUM_LOCKED) && !$is_auth['auth_mod'])
  420. {
  421. message_die(GENERAL_MESSAGE, $lang['Forum_locked']);
  422. }
  423. elseif (($mode != 'newtopic') && ($post_info['topic_status'] == TOPIC_LOCKED) && !$is_auth['auth_mod'])
  424. {
  425. message_die(GENERAL_MESSAGE, $lang['Topic_locked']);
  426. }
  427. // LIMIT POST EDIT TIME - BEGIN
  428. $is_global_limit_edit_enabled = ($post_info['forum_limit_edit_time'] && (intval($config['forum_limit_edit_time_interval']) > 0)) ? true : false;
  429. $is_spam_limit_edit_enabled = ((intval($config['spam_posts_number']) > 0) && ($user->data['user_posts'] < (int) $config['spam_posts_number']) && (intval($config['spam_post_edit_interval']) > 0)) ? true : false;
  430. if (($mode == 'editpost') && ($user->data['user_level'] != ADMIN) && !$is_auth['auth_mod'] && !$submit && ($is_global_limit_edit_enabled || $is_spam_limit_edit_enabled))
  431. {
  432. if (($is_global_limit_edit_enabled && (intval($config['forum_limit_edit_time_interval']) < ((time() - $post_info['post_time']) / 60))) || ($is_spam_limit_edit_enabled && (intval($config['spam_post_edit_interval']) < ((time() - $post_info['post_time']) / 60))))
  433. {
  434. $message = sprintf($lang['LIMIT_EDIT_TIME_WARN'], intval($config['forum_limit_edit_time_interval'])) . '<br /><br />' . sprintf($lang['Click_view_message'], '<a href="' . append_sid(CMS_PAGE_VIEWTOPIC . '?' . POST_POST_URL . '=' . $post_id) . '#' . $post_id . '">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_forum'], '<a href="' . append_sid(CMS_PAGE_VIEWFORUM . '?' . POST_FORUM_URL . '=' . $forum_id) . '">', '</a>');
  435. message_die(GENERAL_MESSAGE, $message);
  436. }
  437. }
  438. // LIMIT POST EDIT TIME - END
  439. if ($mode == 'editpost')
  440. {
  441. if ($is_auth['auth_mod'] || ($user->data['user_level'] == ADMIN))
  442. {
  443. $template->assign_block_vars('switch_lock_post', array());
  444. $template->assign_var('S_POST_LOCKED', $post_info['post_locked'] ? ' checked="checked"' : '');
  445. }
  446. elseif ($post_info['post_locked'])
  447. {
  448. message_die(GENERAL_MESSAGE, 'POST_LOCKED');
  449. }
  450. }
  451. if (($mode == 'editpost') || ($mode == 'delete') || ($mode == 'poll_delete'))
  452. {
  453. $topic_id = $post_info['topic_id'];
  454. $topic_id_append = (!empty($topic_id) ? (POST_TOPIC_URL . '=' . $topic_id) : '');
  455. // MG Cash MOD For IP - BEGIN
  456. if (!empty($config['plugins']['cash']['enabled']))
  457. {
  458. $post_data['post_text'] = (($mode == 'editpost') || ($mode == 'delete')) ? $post_info['post_text'] : '';
  459. }
  460. // MG Cash MOD For IP - END
  461. $post_data['poster_post'] = ($post_info['poster_id'] == $user->data['user_id']) ? true : false;
  462. $post_data['first_post'] = ($post_info['topic_first_post_id'] == $post_id) ? true : false;
  463. $post_data['last_post'] = ($post_info['topic_last_post_id'] == $post_id) ? true : false;
  464. $post_data['last_topic'] = ($post_info['forum_last_post_id'] == $post_id) ? true : false;
  465. $post_data['has_poll'] = (!empty($post_info['poll_start']) ? true : false);
  466. $post_data['poll_start'] = !empty($post_info['poll_start']) ? $post_info['poll_start'] : 0;
  467. // Event Registration - BEGIN
  468. $post_data['has_reg'] = ($post_info['topic_reg']) ? true : false;
  469. // Event Registration - END
  470. $post_data['topic_type'] = $post_info['topic_type'];
  471. $topic_show_portal = ($topic_show_portal || $post_info['topic_show_portal']) ? true : false;
  472. $post_data['topic_show_portal'] = $topic_show_portal;
  473. $post_data['topic_calendar_time'] = $post_info['topic_calendar_time'];
  474. $post_data['topic_calendar_duration'] = $post_info['topic_calendar_duration'];
  475. $post_data['poster_id'] = $post_info['poster_id'];
  476. $post_data['post_images'] = $post_info['post_images'];
  477. /**
  478. * @event posting.post_data.
  479. * @description Sets up the post_data from the post_info.
  480. * @since 3.0
  481. * @var array query The SQL query parts
  482. */
  483. $vars = array(
  484. 'post_data',
  485. 'post_info',
  486. );
  487. extract($class_plugins->trigger('posting.post_data', compact($vars)));
  488. if (($config['allow_mods_edit_admin_posts'] == false) && ($post_info['user_level'] == ADMIN) && ($user->data['user_level'] != ADMIN))
  489. {
  490. message_die(GENERAL_ERROR, $lang['CannotEditAdminsPosts']);
  491. }
  492. if ($post_data['first_post'] && $post_data['has_poll'])
  493. {
  494. $sql = "SELECT *
  495. FROM " . POLL_OPTIONS_TABLE . " o
  496. WHERE o.topic_id = " . $topic_id . "
  497. ORDER BY o.poll_option_id";
  498. $result = $db->sql_query($sql);
  499. $poll_options = array();
  500. $poll_results_sum = 0;
  501. if ($row = $db->sql_fetchrow($result))
  502. {
  503. $poll_title = $post_info['poll_title'];
  504. $poll_start = $post_info['poll_start'];
  505. $poll_length = $post_info['poll_length'] / 86400;
  506. $poll_max_options = $post_info['poll_max_options'];
  507. $poll_change = $post_info['poll_change'];
  508. $poll_data = array(
  509. 'title' => $poll_title,
  510. 'start' => $poll_start,
  511. 'length' => $poll_length,
  512. 'max_options' => $poll_max_options,
  513. 'change' => $poll_change
  514. );
  515. do
  516. {
  517. $poll_options[$row['poll_option_id']] = $row['poll_option_text'];
  518. $poll_results_sum += $row['poll_option_total'];
  519. }
  520. while ($row = $db->sql_fetchrow($result));
  521. }
  522. $db->sql_freeresult($result);
  523. $post_data['edit_poll'] = ((!$poll_results_sum || $is_auth['auth_mod']) && $post_data['first_post']) ? true : 0;
  524. }
  525. else
  526. {
  527. $post_data['edit_poll'] = ($post_data['first_post'] && $is_auth['auth_pollcreate']) ? true : false;
  528. }
  529. // Can this user edit/delete the post/poll?
  530. if (($post_info['poster_id'] != $user->data['user_id']) && !$is_auth['auth_mod'])
  531. {
  532. $message = ($delete || ($mode == 'delete')) ? $lang['Delete_own_posts'] : $lang['Edit_own_posts'];
  533. $message .= '<br /><br />' . sprintf($lang['Click_return_topic'], '<a href="' . append_sid(CMS_PAGE_VIEWTOPIC . '?' . (!empty($forum_id_append) ? ($forum_id_append . '&amp;') : '') . $topic_id_append) . '">', '</a>');
  534. message_die(GENERAL_MESSAGE, $message);
  535. }
  536. elseif (!$post_data['last_post'] && !$is_auth['auth_mod'] && (($mode == 'delete') || $delete))
  537. {
  538. message_die(GENERAL_MESSAGE, $lang['Cannot_delete_replied']);
  539. }
  540. elseif (!$post_data['edit_poll'] && !$is_auth['auth_mod'] && (($mode == 'poll_delete') || $poll_delete))
  541. {
  542. message_die(GENERAL_MESSAGE, $lang['Cannot_delete_poll']);
  543. }
  544. // Event Registration - BEGIN
  545. if ($post_data['first_post'] && $post_data['has_reg'])
  546. {
  547. $sql = "SELECT *
  548. FROM " . REGISTRATION_DESC_TABLE . " rd
  549. WHERE rd.topic_id = $topic_id";
  550. $result = $db->sql_query($sql);
  551. if ($row = $db->sql_fetchrow($result))
  552. {
  553. $reg_active = ($row['reg_active'] == 1) ? 'checked="checked"' : '';
  554. $reg_max_option1 = (!empty($row['reg_max_option1'])) ? $row['reg_max_option1'] : '';
  555. $reg_max_option2 = (!empty($row['reg_max_option2'])) ? $row['reg_max_option2'] : '';
  556. $reg_max_option3 = (!empty($row['reg_max_option3'])) ? $row['reg_max_option3'] : '';
  557. $reg_length = (!empty($row['reg_length'])) ? ($row['reg_length']/86400) : '';
  558. }
  559. $db->sql_freeresult($result);
  560. }
  561. // Event Registration - END
  562. }
  563. else
  564. {
  565. if ($mode == 'quote')
  566. {
  567. $topic_id = $post_info['topic_id'];
  568. $topic_id_append = (!empty($topic_id) ? (POST_TOPIC_URL . '=' . $topic_id) : '');
  569. }
  570. if ($mode == 'newtopic')
  571. {
  572. $post_data['topic_type'] = POST_NORMAL;
  573. }
  574. elseif ($mode == 'reply')
  575. {
  576. $post_data['topic_type'] = $post_info['topic_type'];
  577. }
  578. // MG Cash MOD For IP - BEGIN
  579. if (!empty($config['plugins']['cash']['enabled']))
  580. {
  581. $post_data['topic_poster'] = ($mode == 'reply') ? $post_info['topic_poster'] : 0;
  582. }
  583. // MG Cash MOD For IP - END
  584. $post_data['first_post'] = ($mode == 'newtopic') ? true : 0;
  585. $post_data['last_post'] = false;
  586. $post_data['has_poll'] = false;
  587. $post_data['poll_start'] = 0;
  588. $post_data['edit_poll'] = false;
  589. }
  590. if ($mode == 'poll_delete')
  591. {
  592. $meta = '';
  593. $message = '';
  594. if (!class_exists('class_mcp')) include(IP_ROOT_PATH . 'includes/class_mcp.' . PHP_EXT);
  595. if (empty($class_mcp)) $class_mcp = new class_mcp();
  596. $class_mcp->post_delete($mode, $post_data, $message, $meta, $forum_id, $topic_id, $post_id);
  597. $redirect_url = append_sid(CMS_PAGE_VIEWTOPIC . '?' . POST_TOPIC_URL . '=' . $topic_id);
  598. meta_refresh(3, $redirect_url);
  599. message_die(GENERAL_MESSAGE, $message);
  600. }
  601. // BEGIN cmx_slash_news_mod
  602. // If you want to allow moderators to change news category when editing post you can decomment this...
  603. //if($config['allow_news'] && $post_data['first_post'] && $is_auth['auth_post'] && ($is_auth['auth_news'] || ($is_auth['auth_mod'] && ($mode == 'editpost'))))
  604. if($config['allow_news'] && $post_data['first_post'] && $is_auth['auth_post'] && $is_auth['auth_news'])
  605. {
  606. if($mode == 'editpost')
  607. {
  608. $post_data['news_id'] = $post_info['news_id'];
  609. }
  610. else
  611. {
  612. $post_data['news_id'] = 0;
  613. }
  614. $post_data['disp_news'] = true;
  615. }
  616. else
  617. {
  618. if($config['allow_news'] && $post_data['first_post'] && $is_auth['auth_post'] && !$is_auth['auth_news'] && ($mode == 'editpost'))
  619. {
  620. $post_data['news_id'] = $post_info['news_id'];
  621. }
  622. else
  623. {
  624. $post_data['news_id'] = 0;
  625. }
  626. $post_data['news_id'] = !empty($_POST['news_category']) ? intval($_POST['news_category']) : (!empty($post_data['news_id']) ? intval($post_data['news_id']) : 0);
  627. $hidden_form_fields .= '<input type="hidden" name="news_category" value="' . $post_data['news_id'] . '" />';
  628. $post_data['disp_news'] = false;
  629. }
  630. // END cmx_slash_news_mod
  631. }
  632. else
  633. {
  634. message_die(GENERAL_MESSAGE, $lang['No_such_post']);
  635. }
  636. // The user is not authed, if they're not logged in then redirect them, else show them an error message
  637. if (!$is_auth[$is_auth_type] || (!empty($is_auth_type_cal) && !$is_auth[$is_auth_type_cal]))
  638. {
  639. // Event Registration - BEGIN
  640. $reg_number_clicked = request_var('register', 0);
  641. $reg_user_id = request_var(POST_USERS_URL, 0);
  642. $reg_user_id = ($reg_user_id < 2) ? ANONYMOUS : $reg_user_id;
  643. // Event Registration - END
  644. if ($user->data['session_logged_in'])
  645. {
  646. if (!empty($is_auth_type_cal) && !$is_auth[$is_auth_type_cal])
  647. {
  648. message_die(GENERAL_MESSAGE, sprintf($lang['Sorry_' . $is_auth_type_cal], $is_auth[$is_auth_type_cal . '_type']));
  649. }
  650. message_die(GENERAL_MESSAGE, sprintf($lang['Sorry_' . $is_auth_type], $is_auth[$is_auth_type . '_type']));
  651. }
  652. switch($mode)
  653. {
  654. case 'newtopic':
  655. $redirect = 'mode=newtopic&' . $forum_id_append;
  656. break;
  657. case 'reply':
  658. case 'topicreview':
  659. $redirect = 'mode=reply&' . (!empty($forum_id_append) ? ($forum_id_append . '&') : '') . $topic_id_append;
  660. break;
  661. case 'quote':
  662. case 'editpost':
  663. $redirect = 'mode=quote&' . (!empty($forum_id_append) ? ($forum_id_append . '&') : '') . (!empty($topic_id_append) ? ($topic_id_append . '&') : '') . $post_id_append;
  664. break;
  665. // Event Registration - BEGIN
  666. case 'register':
  667. $redirect = 'mode=register&register=' . $reg_number_clicked . '&' . POST_USERS_URL . '=' . $reg_user_id . '&' . (!empty($forum_id_append) ? ($forum_id_append . '&') : '') . $topic_id_append;
  668. break;
  669. // Event Registration - END
  670. }
  671. $redirect .= ($post_reportid) ? '&post_reportid=' . $post_reportid : '';
  672. redirect(append_sid(CMS_PAGE_LOGIN . '?redirect=posting.' . PHP_EXT . '?' . $redirect, true));
  673. }
  674. // Self AUTH - BEGIN
  675. elseif (intval($is_auth[$is_auth_type]) == AUTH_SELF)
  676. {
  677. //self auth mod
  678. switch($mode)
  679. {
  680. case 'quote':
  681. case 'reply':
  682. $sql = "SELECT t.topic_id
  683. FROM " . TOPICS_TABLE . " t, " . USERS_TABLE. " u
  684. WHERE t.topic_id = " . $topic_id . "
  685. AND t.topic_poster = u.user_id
  686. AND u.user_id = " . $user->data['user_id'];
  687. break;
  688. }
  689. $result = $db->sql_query($sql);
  690. $self_auth = $db->sql_fetchrow($result);
  691. if (empty($self_auth))
  692. {
  693. message_die(GENERAL_MESSAGE, sprintf($lang['Sorry_' . $is_auth_type], $is_auth[$is_auth_type . '_type']));
  694. }
  695. }
  696. // Self AUTH - END
  697. // Set toggles for various options
  698. if (!$config['allow_html'])
  699. {
  700. $html_on = 0;
  701. }
  702. else
  703. {
  704. $html_on = ($submit || $refresh) ? ((!empty($_POST['disable_html'])) ? 0 : 1) : (($user->data['user_id'] == ANONYMOUS) ? $config['allow_html'] : $user->data['user_allowhtml']);
  705. }
  706. $html_on = (!empty($_POST['disable_html']) ? 0 : ((($user->data['user_level'] == ADMIN) && $config['allow_html_only_for_admins']) ? 1 : $html_on));
  707. $acro_auto_on = ($submit || $refresh) ? ((!empty($_POST['disable_acro_auto'])) ? 0 : 1) : 1;
  708. if (!$config['allow_bbcode'])
  709. {
  710. $bbcode_on = 0;
  711. }
  712. else
  713. {
  714. $bbcode_on = ($submit || $refresh) ? ((!empty($_POST['disable_bbcode'])) ? 0 : 1) : (($user->data['user_id'] == ANONYMOUS) ? $config['allow_bbcode'] : $user->data['user_allowbbcode']);
  715. }
  716. if (!$config['allow_smilies'])
  717. {
  718. $smilies_on = 0;
  719. }
  720. else
  721. {
  722. $smilies_on = ($submit || $refresh) ? ((!empty($_POST['disable_smilies'])) ? 0 : 1) : (($user->data['user_id'] == ANONYMOUS) ? $config['allow_smilies'] : $user->data['user_allowsmile']);
  723. }
  724. if($is_auth['auth_news'])
  725. {
  726. $topic_show_portal = ($submit || $refresh) ? (!empty($_POST['topic_show_portal']) ? 1 : 0) : 0;
  727. }
  728. else
  729. {
  730. $topic_show_portal = ($submit || $refresh || ($mode == 'editpost')) ? (!empty($post_data['topic_show_portal']) ? 1 : 0) : 0;
  731. }
  732. if (($submit || $refresh) && $is_auth['auth_read'])
  733. {
  734. $notify_user = (!empty($_POST['notify'])) ? 1 : 0;
  735. }
  736. else
  737. {
  738. if (($mode != 'newtopic') && $user->data['session_logged_in'] && $is_auth['auth_read'])
  739. {
  740. $sql = "SELECT topic_id
  741. FROM " . TOPICS_WATCH_TABLE . "
  742. WHERE topic_id = " . $topic_id . "
  743. AND user_id = " . $user->data['user_id'];
  744. $result = $db->sql_query($sql);
  745. $notify_user = ($db->sql_fetchrow($result)) ? true : $user->data['user_notify'];
  746. $db->sql_freeresult($result);
  747. }
  748. else
  749. {
  750. $notify_user = ($user->data['session_logged_in'] && $is_auth['auth_read']) ? $user->data['user_notify'] : 0;
  751. }
  752. }
  753. $attach_sig = ($submit || $refresh) ? ((!empty($_POST['attach_sig'])) ? 1 : 0) : (($user->data['user_id'] == ANONYMOUS) ? 0 : $user->data['user_attachsig']);
  754. $setbm = ($submit || $refresh) ? ((!empty($_POST['setbm'])) ? 1 : 0) : (($user->data['user_id'] == ANONYMOUS) ? 0 : $user->data['user_setbm']);
  755. execute_posting_attachment_handling();
  756. // What shall we do?
  757. // BEGIN cmx_slash_news_mod
  758. // Get News Categories.
  759. if($user->data['session_logged_in'] && $post_data['disp_news'])
  760. {
  761. if (($mode == 'editpost') && empty($post_id))
  762. {
  763. message_die(GENERAL_MESSAGE, $lang['No_post_id']);
  764. }
  765. $sql = 'SELECT * FROM ' . NEWS_TABLE . ' ORDER BY news_category';
  766. $result = $db->sql_query($sql, 0, 'news_cats_');
  767. $news_sel = array();
  768. $news_cat = array();
  769. while ($row = $db->sql_fetchrow($result))
  770. {
  771. if((($news_category > 0) && ($news_category == $row['news_id'])) || (($post_data['news_id'] > 0) && ($post_data['news_id'] == $row['news_id'])))
  772. {
  773. $news_sel = $row;
  774. }
  775. if($post_data['news_id'] != 0 && $post_data['news_id'] == $row['news_id'])
  776. {
  777. $news_sel = $row;
  778. }
  779. $news_cat[] = $row;
  780. }
  781. if(($post_data['news_id'] == 0) && ($news_category == 0))
  782. {
  783. $boxstring = '<option value="0">' . $lang['Regular_Post'] . '</option>';
  784. }
  785. else
  786. {
  787. $boxstring = '<option value="' . $news_sel['news_id'] . '">' . $news_sel['news_category'] . ' (' . $lang['Current_Selection'] . ')</option>';
  788. $boxstring .= '<option value="0">' . $lang['Regular_Post'] . '</option>';
  789. }
  790. if(sizeof($news_cat) > 0)
  791. {
  792. for($i = 0; $i < sizeof($news_cat); $i++)
  793. {
  794. if($news_cat[$i]['news_id'] != $post_data['news_id'])
  795. {
  796. $boxstring .= '<option value="' . $news_cat[$i]['news_id'] . '">' . $news_cat[$i]['news_category'] . '</option>';
  797. }
  798. }
  799. $template->assign_block_vars('switch_news_cat', array(
  800. 'L_NEWS_CATEGORY' => $lang['Select_News_Category'],
  801. 'S_NAME' => 'news_category',
  802. 'S_CATEGORY_BOX' => $boxstring
  803. )
  804. );
  805. }
  806. }
  807. // END cmx_slash_news_mod
  808. if (($delete || $poll_delete || ($mode == 'delete')) && !$confirm)
  809. {
  810. // Confirm deletion
  811. $s_hidden_fields .= '<input type="hidden" name="' . POST_POST_URL . '" value="' . $post_id . '" />';
  812. $s_hidden_fields .= ($delete || $mode == 'delete') ? '<input type="hidden" name="mode" value="delete" />' : '<input type="hidden" name="mode" value="poll_delete" />';
  813. $s_hidden_fields .= '<input type="hidden" name="sid" value="' . $user->data['session_id'] . '" />';
  814. $l_confirm = ($delete || ($mode == 'delete')) ? $lang['Confirm_delete'] : $lang['Confirm_delete_poll'];
  815. $template->assign_vars(array(
  816. 'MESSAGE_TITLE' => $lang['Information'],
  817. 'MESSAGE_TEXT' => $l_confirm,
  818. 'L_YES' => $lang['Yes'],
  819. 'L_NO' => $lang['No'],
  820. 'S_CONFIRM_ACTION' => append_sid('posting.' . PHP_EXT),
  821. 'S_HIDDEN_FIELDS' => $s_hidden_fields
  822. )
  823. );
  824. full_page_generation('confirm_body.tpl', $lang['Confirm'], '', '');
  825. }
  826. elseif ($mode == 'vote')
  827. {
  828. // Vote in a poll
  829. $voted_id = request_var('vote_id', array('' => 0));
  830. $voted_id = (sizeof($voted_id) > 1) ? array_unique($voted_id) : $voted_id;
  831. // Does this topic contain a poll?
  832. if (!empty($post_info['poll_start']))
  833. {
  834. $sql = "SELECT o.*
  835. FROM " . POLL_OPTIONS_TABLE . " o
  836. WHERE o.topic_id = " . $topic_id . "
  837. ORDER BY o.poll_option_id";
  838. $result = $db->sql_query($sql);
  839. $poll_info = array();
  840. while ($row = $db->sql_fetchrow($result))
  841. {
  842. $poll_info[] = $row;
  843. }
  844. $db->sql_freeresult($result);
  845. $cur_voted_id = array();
  846. if ($user->data['session_logged_in'] && ($user->data['bot_id'] === false))
  847. {
  848. $sql = "SELECT poll_option_id
  849. FROM " . POLL_VOTES_TABLE . "
  850. WHERE topic_id = " . $topic_id . "
  851. AND vote_user_id = " . $user->data['user_id'];
  852. $result = $db->sql_query($sql);
  853. while ($row = $db->sql_fetchrow($result))
  854. {
  855. $cur_voted_id[] = $row['poll_option_id'];
  856. }
  857. $db->sql_freeresult($result);
  858. }
  859. else
  860. {
  861. // Currently disable guests posting...
  862. $message = $lang['POLL_NO_GUESTS'] . '<br /><br />' . sprintf($lang['Click_return_topic'], '<a href="' . $redirect_url . '">', '</a>');
  863. message_die(GENERAL_MESSAGE, $message);
  864. // Cookie based guest tracking... I don't like this but hum ho... it's oft requested. This relies on "nice" users who don't feel the need to delete cookies to mess with results.
  865. if (isset($_COOKIE[$config['cookie_name'] . '_poll_' . $topic_id]))
  866. {
  867. $cur_voted_id = explode(',', $_COOKIE[$config['cookie_name'] . '_poll_' . $topic_id]);
  868. $cur_voted_id = array_map('intval', $cur_voted_id);
  869. }
  870. }
  871. if (!sizeof($voted_id) || (sizeof($voted_id) > $post_info['poll_max_options']) || in_array(VOTE_CONVERTED, $cur_voted_id))
  872. {
  873. if (!sizeof($voted_id))
  874. {
  875. $message = $lang['NO_VOTE_OPTION'];
  876. }
  877. elseif (sizeof($voted_id) > $post_info['poll_max_options'])
  878. {
  879. $message = $lang['TOO_MANY_VOTE_OPTIONS'];
  880. }
  881. elseif (in_array(VOTE_CONVERTED, $cur_voted_id))
  882. {
  883. $message = $lang['VOTE_CONVERTED'];
  884. }
  885. else
  886. {
  887. $message = $lang['FORM_INVALID'];
  888. }
  889. $redirect_url = append_sid(CMS_PAGE_VIEWTOPIC . '?' . (!empty($forum_id_append) ? ($forum_id_append . '&amp;') : '') . $topic_id_append . '&amp;start=' . $start);
  890. meta_refresh(3, $redirect_url);
  891. $message .= '<br /><br />' . sprintf($lang['Click_return_topic'], '<a href="' . $redirect_url . '">', '</a>');
  892. message_die(GENERAL_MESSAGE, $message);
  893. }
  894. foreach ($voted_id as $option)
  895. {
  896. if (in_array($option, $cur_voted_id))
  897. {
  898. continue;
  899. }
  900. $sql = "UPDATE " . POLL_OPTIONS_TABLE . "
  901. SET poll_option_total = poll_option_total + 1
  902. WHERE poll_option_id = " . (int) $option . "
  903. AND topic_id = " . (int) $topic_id;
  904. $db->sql_query($sql);
  905. if ($user->data['session_logged_in'] && ($user->data['bot_id'] === false))
  906. {
  907. $sql_ary = array(
  908. 'topic_id' => (int) $topic_id,
  909. 'poll_option_id' => (int) $option,
  910. 'vote_user_id' => (int) $user->data['user_id'],
  911. 'vote_user_ip' => (string) $user->data['session_ip'],
  912. );
  913. $sql = "INSERT INTO " . POLL_VOTES_TABLE . " " . $db->sql_build_array('INSERT', $sql_ary);
  914. $db->sql_query($sql);
  915. }
  916. }
  917. foreach ($cur_voted_id as $option)
  918. {
  919. if (!in_array($option, $voted_id))
  920. {
  921. $sql = "UPDATE " . POLL_OPTIONS_TABLE . "
  922. SET poll_option_total = poll_option_total - 1
  923. WHERE poll_option_id = " . (int) $option . "
  924. AND topic_id = " . (int) $topic_id;
  925. $db->sql_query($sql);
  926. if ($user->data['session_logged_in'] && ($user->data['bot_id'] === false))
  927. {
  928. $sql = "DELETE FROM " . POLL_VOTES_TABLE . "
  929. WHERE topic_id = " . (int) $topic_id . "
  930. AND poll_option_id = " . (int) $option . "
  931. AND vote_user_id = " . (int) $user->data['user_id'];
  932. $db->sql_query($sql);
  933. }
  934. }
  935. }
  936. if ($user->data['session_logged_in'] && ($user->data['bot_id'] === false))
  937. {
  938. if (function_exists('set_cookie'))
  939. {
  940. set_cookie('poll_' . $topic_id, implode(',', $voted_id), time() + 31536000);
  941. }
  942. }
  943. $sql = "UPDATE " . TOPICS_TABLE . "
  944. SET poll_last_vote = " . time() . "
  945. WHERE topic_id = " . $topic_id;
  946. $db->sql_query($sql);
  947. $redirect_url = append_sid(CMS_PAGE_VIEWTOPIC . '?' . (!empty($forum_id_append) ? ($forum_id_append . '&amp;') : '') . $topic_id_append . '&amp;start=' . $start);
  948. meta_refresh(3, $redirect_url);
  949. $message = $lang['VOTE_SUBMITTED'] . '<br /><br />' . sprintf($lang['Click_return_topic'], '<a href="' . $redirect_url . '">', '</a>');
  950. message_die(GENERAL_MESSAGE, $message);
  951. }
  952. else
  953. {
  954. redirect(append_sid(CMS_PAGE_VIEWTOPIC . '?' . (!empty($forum_id_append) ? ($forum_id_append . '&') : '') . $topic_id_append, true));
  955. }
  956. }
  957. // Event Registration - BEGIN
  958. elseif ($mode == 'register')
  959. {
  960. // Register for an event
  961. $register_value = request_var('register', 0);
  962. $register_value = in_array($register_value, array(REG_OPTION1, REG_OPTION2, REG_OPTION3, REG_UNREGISTER)) ? $register_value : 0;
  963. if (!empty($register_value))
  964. {
  965. $user_id = $user->data['user_id'];
  966. if ($user->data['user_level'] == ADMIN)
  967. {
  968. $target_user_id = request_var(POST_USERS_URL, 0);
  969. $target_user_id = ($target_user_id < 2) ? ANONYMOUS : $target_user_id;
  970. $target_username = request_var('username', '', true);
  971. if (!empty($target_user_id) && ($target_user_id != ANONYMOUS))
  972. {
  973. $target_userdata = get_userdata($target_user_id);
  974. }
  975. else
  976. {
  977. $target_userdata = get_userdata($target_username, true);
  978. }
  979. if (!empty($target_userdata))
  980. {
  981. $user_id = $target_userdata['user_id'];
  982. }
  983. }
  984. $zeit = time();
  985. $sql = "SELECT registration_status FROM " . REGISTRATION_TABLE . "
  986. WHERE topic_id = $topic_id AND registration_user_id = $user_id";
  987. $result = $db->sql_query($sql);
  988. if ($reg_info = $db->sql_fetchrow($result))
  989. {
  990. if ($register_value == REG_UNREGISTER) // cancel registration
  991. {
  992. $sql = "DELETE FROM " . REGISTRATION_TABLE . "
  993. WHERE topic_id = $topic_id
  994. AND registration_user_id = $user_id";
  995. $db->sql_query($sql);
  996. $message = $lang['Reg_Unregister'];
  997. }
  998. else
  999. {
  1000. $old_regstate = $reg_info['registration_status'];
  1001. if (($user->data['user_level'] != ADMIN) && (check_max_registration($topic_id, $register_value) === false))
  1002. {
  1003. $message = $lang['Reg_Max_Registrations'];
  1004. }
  1005. else
  1006. {
  1007. $sql = "UPDATE " . REGISTRATION_TABLE . "
  1008. SET registration_user_ip = '$user_ip', registration_time = $zeit, registration_status = $register_value
  1009. WHERE topic_id = $topic_id
  1010. AND registration_user_id = $user_id";
  1011. $db->sql_query($sql);
  1012. $message = $lang['Reg_Change'];
  1013. }
  1014. }
  1015. }
  1016. else
  1017. {
  1018. if (($user->data['user_level'] != ADMIN) && (check_max_registration($topic_id, $register_value) === false))
  1019. {
  1020. $message = sprintf($lang['Reg_Max_Registrations'], $num_max_reg);
  1021. }
  1022. else
  1023. {
  1024. $sql = "INSERT INTO " . REGISTRATION_TABLE . " (topic_id, registration_user_id, registration_user_ip, registration_time, registration_status)
  1025. VALUES ($topic_id, $user_id, '$user_ip', $zeit, $register_value)";
  1026. $db->sql_query($sql);
  1027. $message = $lang['Reg_Insert'];
  1028. }
  1029. }
  1030. $redirect_url = append_sid(CMS_PAGE_VIEWTOPIC . '?' . (!empty($forum_id_append) ? ($forum_id_append . '&amp;') : '') . $topic_id_append);
  1031. meta_refresh(3, $redirect_url);
  1032. $message .= '<br /><br />' . sprintf($lang['Click_return_topic'], '<a href="' . $redirect_url . '">', '</a>');
  1033. message_die(GENERAL_MESSAGE, $message);
  1034. }
  1035. else
  1036. {
  1037. message_die(GENERAL_ERROR, 'Missing information for registration', '', __LINE__, __FILE__);
  1038. }
  1039. }
  1040. // Event Registration - END
  1041. elseif ($submit || $confirm || ($draft && $draft_confirm))
  1042. {
  1043. // Submit post/vote (newtopic, edit, reply, etc.)
  1044. $return_message = '';
  1045. $return_meta = '';
  1046. // session id check
  1047. if (($sid == '') || ($sid != $user->data['session_id']))
  1048. {
  1049. $error_msg .= (!empty($error_msg)) ? '<br />' . $lang['Session_invalid'] : $lang['Session_invalid'];
  1050. }
  1051. switch ($mode)
  1052. {
  1053. case 'editpost':
  1054. case 'newtopic':
  1055. case 'reply':
  1056. // CrackerTracker v5.x
  1057. if (($config['ctracker_vconfirm_guest'] == 1) && !$user->data['session_logged_in'])
  1058. {
  1059. define('CRACKER_TRACKER_VCONFIRM', true);
  1060. define('POST_CONFIRM_CHECK', true);
  1061. include_once(IP_ROOT_PATH . 'includes/ctracker/engines/ct_visual_confirm.' . PHP_EXT);
  1062. }
  1063. // CrackerTracker v5.x
  1064. $username = htmlspecialchars_decode(request_post_var('username', '', true), ENT_COMPAT);
  1065. $subject = !empty($draft_subject) ? $draft_subject : request_post_var('subject', '', true);
  1066. $topic_desc = request_post_var('topic_desc', '', true);
  1067. $message = !empty($draft_message) ? $draft_message : htmlspecialchars_decode(request_post_var('message', '', true), ENT_COMPAT);
  1068. $notes = htmlspecialchars_decode(request_post_var('notes', '', true), ENT_COMPAT);
  1069. $notes_mod = '';
  1070. if (($user->data['user_level'] == ADMIN) || $is_auth['auth_mod'])
  1071. {
  1072. $notes_mod = htmlspecialchars_decode(request_post_var('notes_mod', '', true), ENT_COMPAT);
  1073. }
  1074. $post_images = request_post_var('post_images', '', true);
  1075. if (!empty($post_images) && (substr($post_images, 0, 4) == 'http'))
  1076. {
  1077. if (!function_exists('get_full_image_info'))
  1078. {
  1079. require(IP_ROOT_PATH . 'includes/class_image.' . PHP_EXT);
  1080. }
  1081. $pic_size = get_full_image_info($post_images);
  1082. if(empty($pic_size))
  1083. {
  1084. $post_images = '';
  1085. }
  1086. }
  1087. else
  1088. {
  1089. $post_images = '';
  1090. }
  1091. $post_data['post_images'] = $post_images;
  1092. $poll_title = (isset($_POST['poll_title']) && $is_auth['auth_pollcreate']) ? request_post_var('poll_title', '', true) : '';
  1093. $poll_options = (isset($_POST['poll_option_text']) && $is_auth['auth_pollcreate']) ? request_post_var('poll_option_text', array(0 => ''), true) : array();
  1094. $poll_start = time();
  1095. $poll_length = (isset($_POST['poll_length']) && $is_auth['auth_pollcreate']) ? request_post_var('poll_length', 0) : 0;
  1096. $poll_length = max(0, $poll_length * 86400);
  1097. $poll_max_options = (isset($_POST['poll_max_options']) && $is_auth['auth_pollcreate']) ? request_post_var('poll_max_options', 1) : 1;
  1098. $poll_max_options = max(1, $poll_max_options);
  1099. $poll_change = (isset($_POST['poll_change']) && $is_auth['auth_pollcreate']) ? 1 : 0;
  1100. $poll_data = array(
  1101. 'title' => $poll_title,
  1102. 'start' => $poll_start,
  1103. 'length' => $poll_length,
  1104. 'max_options' => $poll_max_options,
  1105. 'change' => $poll_change
  1106. );
  1107. $topic_calendar_time = ($topic_calendar_time != $post_data['topic_calendar_time'] && !$is_auth['auth_cal']) ? $post_data['topic_calendar_time'] : $topic_calendar_time;
  1108. if (empty($topic_calendar_time)) $topic_calendar_time = 0;
  1109. $topic_calendar_duration = ($topic_calendar_duration != $post_data['topic_calendar_duration'] && !$is_auth['auth_cal']) ? $post_data['topic_calendar_duration'] : $topic_calendar_duration;
  1110. if (!empty($topic_calendar_duration))
  1111. {
  1112. $topic_calendar_duration--;
  1113. }
  1114. if (empty($topic_calendar_time) || empty($topic_calendar_duration))
  1115. {
  1116. $topic_calendar_duration = 0;
  1117. }
  1118. // Event Registration - BEGIN
  1119. $reg_active = (isset($_POST['start_registration']) && $is_auth['auth_vote'] && $user->data['session_logged_in']) ? $_POST['start_registration'] : '';
  1120. $reg_reset = (isset($_POST['reset_registration']) && $is_auth['auth_vote'] && $user->data['session_logged_in']) ? $_POST['reset_registration'] : '';
  1121. $reg_max_option1 = (!empty($_POST['reg_max_option1']) && $is_auth['auth_vote'] && $user->data['session_logged_in']) ? $_POST['reg_max_option1'] : '';
  1122. $reg_max_option2 = (!empty($_POST['reg_max_option2']) && $is_auth['auth_vote'] && $user->data['session_logged_in']) ? $_POST['reg_max_option2'] : '';
  1123. $reg_max_option3 = (!empty($_POST['reg_max_option3']) && $is_auth['auth_vote'] && $user->data['session_logged_in']) ? $_POST['reg_max_option3'] : '';
  1124. $reg_length = (isset($_POST['reg_length']) && $is_auth['auth_vote'] && $user->data['session_logged_in']) ? $_POST['reg_length'] : '';
  1125. // Event Registration - END
  1126. prepare_post($mode, $post_data, $bbcode_on, $html_on, $smilies_on, $error_msg, $username, $subject, $message, $poll_title, $poll_options, $poll_data, $reg_active, $reg_reset, $reg_max_option1, $reg_max_option2, $reg_max_option3, $reg_length, $topic_desc, $topic_calendar_time, $topic_calendar_duration);
  1127. // MG Drafts - BEGIN
  1128. if (($config['allow_drafts'] == true) && $draft && $draft_confirm && $user->data['session_logged_in'] && (($mode == 'reply') || ($mode == 'newtopic')))
  1129. {
  1130. save_draft($draft_id, $user->data['user_id'], $forum_id, $topic_id, strip_tags($subject), $message);
  1131. //save_draft($draft_id, $user->data['user_id'], $forum_id, $topic_id, $db->sql_escape(strip_tags($subject)), $db->sql_escape($message));
  1132. $output_message = $lang['Drafts_Saved'];
  1133. $output_message .= '<br /><br />' . sprintf($lang['Click_return_drafts'], '<a href="' . append_sid(CMS_PAGE_DRAFTS) . '">', '</a>');
  1134. $output_message .= '<br /><br />' . sprintf($lang['Click_return_forum'], '<a href="' . append_sid(CMS_PAGE_VIEWFORUM . '?' . POST_FORUM_URL . '=' . $forum_id) . '">', '</a>');
  1135. $redirect_url = append_sid(CMS_PAGE_VIEWFORUM . '?' . POST_FORUM_URL . '=' . $forum_id);
  1136. meta_refresh(3, $redirect_url);
  1137. message_die(GENERAL_MESSAGE, $output_message);
  1138. }
  1139. // MG Drafts - END
  1140. if ($error_msg == '')
  1141. {
  1142. if ($mode == 'reply')
  1143. {
  1144. $topic_type = $post_data['topic_type'];
  1145. }
  1146. else
  1147. {
  1148. $topic_type = (($topic_type != $post_data['topic_type']) && !$is_auth['auth_sticky'] && !$is_auth['auth_announce'] && !$is_auth['auth_globalannounce']) ? $post_data['topic_type'] : $topic_type;
  1149. }
  1150. if(($mode == 'editpost') && $config['edit_notes'] && ((strlen($notes) > 2) || (strlen($notes_mod) > 2)))
  1151. {
  1152. $sql = "SELECT edit_notes FROM " . POSTS_TABLE . " WHERE post_id='" . $post_id . "'";
  1153. $result = $db->sql_query($sql);
  1154. $row = $db->sql_fetchrow($result);
  1155. $db->sql_freeresult($result);
  1156. $notes_list = strlen($row['edit_notes']) ? unserialize($row['edit_notes']) : array();
  1157. // Check limit and eventually delete notes
  1158. if(!empty($notes) && (sizeof($notes_list) >= intval($config['edit_notes_n'])))
  1159. {
  1160. $first_edit_note = 0;
  1161. $edit_notes_counter = 0;
  1162. for($i = 0; $i < sizeof($notes_list); $i++)
  1163. {
  1164. if (empty($notes_list[$i]['reserved']))
  1165. {
  1166. $edit_notes_counter++;
  1167. if (empty($first_edit_note))
  1168. {
  1169. $first_edit_note = $i;
  1170. }
  1171. }
  1172. }
  1173. if ($edit_notes_counter > intval($config['edit_notes_n']))
  1174. {
  1175. unset($notes_list[$first_edit_note]);
  1176. }
  1177. }
  1178. if (!empty($notes))
  1179. {
  1180. $notes_list[] = array(
  1181. 'poster' => $user->data['user_id'],
  1182. 'time' => time(),
  1183. //'text' => htmlspecialchars($notes)
  1184. 'text' => $notes,
  1185. 'reserved' => false
  1186. );
  1187. }
  1188. if (!empty($notes_mod))
  1189. {
  1190. $notes_list[] = array(
  1191. 'poster' => $user->data['user_id'],
  1192. 'time' => time(),
  1193. //'text' => htmlspecialchars($notes_mod)
  1194. 'text' => $notes_mod,
  1195. 'reserved' => true
  1196. );
  1197. }
  1198. empty_cache_folders(POSTS_CACHE_FOLDER);
  1199. $sql = "UPDATE " . POSTS_TABLE . " SET edit_notes = '" . $db->sql_escape(serialize($notes_list)) . "' WHERE post_id = '" . $post_id . "'";
  1200. $db->sql_query($sql);
  1201. if (!empty($notes))
  1202. {
  1203. $edit_count_sql = '';
  1204. // We need this, otherwise editing for normal users will be accounted twice... because the same edit will be updated in functions_post.php
  1205. if($user->data['user_level'] == ADMIN)
  1206. {
  1207. $edit_count_sql = ", post_edit_count = (post_edit_count + 1)";
  1208. }
  1209. $edited_sql = "post_edit_time = '" . time() . "'" . $edit_count_sql . ", post_edit_id = '" . $user->data['user_id'] . "'";
  1210. $sql = "UPDATE " . POSTS_TABLE . " SET " . $edited_sql . " WHERE post_id='" . $post_id . "'";
  1211. $db->sql_query($sql);
  1212. }
  1213. }
  1214. if ($lock_subject)
  1215. {
  1216. $url = '[url="' . CMS_PAGE_VIEWTOPIC . '?' . (!empty($forum_id_append) ? ($forum_id_append . '&amp;') : '') . (!empty($topic_id_append) ? ($topic_id_append . '&amp;') : '') . POST_POST_URL . '=' . $lock_subject . '#p' . $lock_subject . '"]';
  1217. $message = sprintf($lang['Link_to_post'], $url, '[/url]') . $message;
  1218. }
  1219. $topic_title_clean = '';
  1220. $topic_tags = '';
  1221. if ($post_data['first_post'])
  1222. {
  1223. $topic_title_clean = request_var('topic_title_clean', $subject, true);
  1224. $topic_title_clean = substr(ip_clean_string($topic_title_clean, $lang['ENCODING']), 0, 254);
  1225. @include_once(IP_ROOT_PATH . 'includes/class_topics_tags.' . PHP_EXT);
  1226. $class_topics_tags = new class_topics_tags();
  1227. if (!empty($use_jquery_tags))
  1228. {
  1229. if(array_key_exists('ttag', $_POST))
  1230. {
  1231. $all_topic_tags = request_var('ttag', array(0 => ''), true);
  1232. $topic_tags = implode(', ', array_filter(array_unique($all_topic_tags)));
  1233. }
  1234. }
  1235. else
  1236. {
  1237. $topic_tags = request_var('topic_tags', '', true);
  1238. }
  1239. if (!empty($topic_tags))
  1240. {
  1241. $topic_tags = trim($topic_tags);
  1242. while(substr($topic_tags, -1) == ',')
  1243. {
  1244. $topic_tags = trim(substr($topic_tags, 0, -1));
  1245. }
  1246. $topic_tags_array = $class_topics_tags->create_tags_array($topic_tags);
  1247. $topic_tags = implode(', ', array_filter(array_unique($topic_tags_array)));
  1248. $topic_tags = substr($topic_tags, 0, 254);
  1249. //die($topic_tags);
  1250. }
  1251. unset($class_topics_tags);
  1252. }
  1253. submit_post($mode, $post_data, $return_message, $return_meta, $forum_id, $topic_id, $post_id, $topic_type, $bbcode_on, $html_on, $acro_auto_on, $smilies_on, $attach_sig, $username, $subject, $topic_title_clean, $topic_tags, $message, $poll_title, $poll_options, $poll_data, $reg_active, $reg_reset, $reg_max_option1, $reg_max_option2, $reg_max_option3, $reg_length, $news_category, $topic_show_portal, $mark_edit, $topic_desc, $topic_calendar_time, $topic_calendar_duration, $extra_vars);
  1254. }
  1255. break;
  1256. case 'delete':
  1257. case 'poll_delete':
  1258. if ($error_msg != '')
  1259. {
  1260. message_die(GENERAL_MESSAGE, $error_msg);
  1261. }
  1262. if (!class_exists('class_mcp')) include(IP_ROOT_PATH . 'includes/class_mcp.' . PHP_EXT);
  1263. if (empty($class_mcp)) $class_mcp = new class_mcp();
  1264. $class_mcp->post_delete($mode, $post_data, $return_message, $return_meta, $forum_id, $topic_id, $post_id);
  1265. break;
  1266. }
  1267. if ($error_msg == '')
  1268. {
  1269. if ($mode != 'editpost')
  1270. {
  1271. $user_id = (($mode == 'reply') || ($mode == 'newtopic')) ? $user->data['user_id'] : $post_data['poster_id'];
  1272. if (!class_exists('class_mcp')) include(IP_ROOT_PATH . 'includes/class_mcp.' . PHP_EXT);
  1273. if (empty($class_mcp)) $class_mcp = new class_mcp();
  1274. $class_mcp->sync_post_stats($mode, $post_data, $forum_id, $topic_id, $post_id, $user_id);
  1275. }
  1276. $attachment_mod['posting']->insert_attachment($post_id);
  1277. if (($error_msg == '') && ($mode != 'poll_delete'))
  1278. {
  1279. // Forum Notification - BEGIN
  1280. if (!class_exists('class_notifications'))
  1281. {
  1282. include(IP_ROOT_PATH . 'includes/class_notifications.' . PHP_EXT);
  1283. $class_notifications = new class_notifications();
  1284. }
  1285. $post_data['subject'] = $subject;
  1286. $post_data['username'] = ($user->data['user_id'] == ANONYMOUS) ? $username : $user->data['username'];
  1287. $post_data['message'] = $message;
  1288. if ($post_data['first_post'])
  1289. {
  1290. // fetch topic title
  1291. $sql = "SELECT topic_title, topic_id
  1292. FROM " . TOPICS_TABLE . "
  1293. WHERE topic_id = " . $topic_id;
  1294. $result = $db->sql_query($sql);
  1295. if ($topic_info = $db->sql_fetchrow($result))
  1296. {
  1297. $class_notifications->send_notifications('newtopic', $post_data, $topic_info['topic_title'], $forum_id, $topic_id, $post_id, $notify_user);
  1298. }
  1299. }
  1300. else
  1301. {
  1302. if ($setbm)
  1303. {
  1304. set_bookmark($topic_id);
  1305. }
  1306. $class_notifications->send_notifications($mode, $post_data, $post_info['topic_title'], $forum_id, $topic_id, $post_id, $notify_user);
  1307. }
  1308. // Forum Notification - END
  1309. }
  1310. if ($lock_subject)
  1311. {
  1312. $url = '<a href="' . append_sid(CMS_PAGE_VIEWTOPIC . '?' . (!empty($forum_id_append) ? ($forum_id_append . '&amp;') : '') . (!empty($topic_id_append) ? ($topic_id_append . '&amp;') : '') . POST_POST_URL . '=' . $lock_subject . '#p' . $lock_subject) . '">';
  1313. $return_message = $lang['Report_stored'] . '<br /><br />' . sprintf($lang['Send_report'], $url, '</a>');
  1314. $return_meta = str_replace($post_id, $lock_subject, $return_meta);
  1315. }
  1316. if (($error_msg == '') && ($lock) && ($mode == 'newtopic'))
  1317. {
  1318. empty_cache_folders(POSTS_CACHE_FOLDER);
  1319. empty_cache_folders(FORUMS_CACHE_FOLDER);
  1320. $sql = "UPDATE " . TOPICS_TABLE . "
  1321. SET topic_status = " . TOPIC_LOCKED . "
  1322. WHERE topic_id = " . $topic_id . "
  1323. AND topic_moved_id = 0";
  1324. $result = $db->sql_query($sql);
  1325. }
  1326. if (($mode == 'newtopic') || ($mode == 'reply'))
  1327. {
  1328. $tracking_forums = (!empty($_COOKIE[$config['cookie_name'] . '_f'])) ? unserialize($_COOKIE[$config['cookie_name'] . '_f']) : array();
  1329. $tracking_topics = (!empty($_COOKIE[$config['cookie_name'] . '_t'])) ? unserialize($_COOKIE[$config['cookie_name'] . '_t']) : array();
  1330. if (((sizeof($tracking_topics) + sizeof($tracking_forums)) >= 150) && empty($tracking_topics[$topic_id]))
  1331. {
  1332. asort($tracking_topics);
  1333. unset($tracking_topics[key($tracking_topics)]);
  1334. }
  1335. $tracking_topics[$topic_id] = time();
  1336. $user->set_cookie('t', serialize($tracking_topics), $user->cookie_expire);
  1337. }
  1338. // MOD: Redirect to Post (normal post) - BEGIN
  1339. if (($mode == 'delete') && $post_data['first_post'] && $post_data['last_post'])
  1340. {
  1341. // URL for redirection after deleting an entire topic
  1342. $redirect = CMS_PAGE_VIEWFORUM . '?' . POST_FORUM_URL . '=' . $forum_id;
  1343. // If the above URL points to a location outside the phpBB directories
  1344. // move the slashes on the next line to the start of the following line:
  1345. //redirect(append_sid($redirect, true), true);
  1346. redirect(append_sid($redirect, true));
  1347. }
  1348. elseif ($mode == 'delete')
  1349. {
  1350. // URL for redirection after deleting a post
  1351. $redirect = CMS_PAGE_VIEWTOPIC . '?' . (!empty($forum_id_append) ? ($forum_id_append . '&') : '') . $topic_id_append;
  1352. if (($config['url_rw'] == '1') || (($config['url_rw_guests'] == '1') && ($user->data['user_id'] == ANONYMOUS)))
  1353. {
  1354. $redirect = str_replace ('--', '-', make_url_friendly($subject) . '-vt' . $topic_id . '.html');
  1355. }
  1356. // If the above URL points to a location outside the phpBB directories
  1357. // move the slashes on the next line to the start of the following line:
  1358. //redirect(append_sid($redirect, true), true);
  1359. redirect(append_sid($redirect, true));
  1360. }
  1361. elseif (($mode == 'reply') || ($mode == 'editpost') || ($mode == 'newtopic'))
  1362. {
  1363. // URL for redirection after posting or editing a post
  1364. $redirect = CMS_PAGE_VIEWTOPIC . '?' . (!empty($forum_id_append) ? ($forum_id_append . '&') : '') . (!empty($topic_id_append) ? ($topic_id_append . '&') : '') . POST_POST_URL . '=' . $post_id;
  1365. $post_append = '#p' . $post_id;
  1366. if (($config['url_rw'] == '1') || (($config['url_rw_guests'] == '1') && ($user->data['user_id'] == ANONYMOUS)))
  1367. {
  1368. $redirect = str_replace ('--', '-', make_url_friendly($subject) . '-vp' . $post_id . '.html');
  1369. }
  1370. // If the above URL points to a location outside the phpBB directories
  1371. // move the slashes on the next line to the start of the following line:
  1372. //redirect(append_sid($redirect, true) . $post_append, true);
  1373. redirect(append_sid($redirect, true) . $post_append);
  1374. }
  1375. // MOD: Redirect to Post (normal post) - END
  1376. $template->assign_vars(array('META' => $return_meta));
  1377. message_die(GENERAL_MESSAGE, $return_message);
  1378. }
  1379. }
  1380. $notes = '';
  1381. if($refresh || isset($_POST['del_poll_option']) || ($error_msg != ''))
  1382. {
  1383. $username = htmlspecialchars_decode(request_post_var('username', '', true), ENT_COMPAT);
  1384. $subject = !empty($draft_subject) ? $draft_subject : request_post_var('subject', '', true);
  1385. $topic_desc = request_post_var('topic_desc', '', true);
  1386. // Mighty Gorgon: still under testing... if we are refreshing the page, it means that we need to keep the original message in the TEXTBOX, so we don't need to escape htmlspecialchars again...
  1387. //$message = !empty($draft_message) ? $draft_message : htmlspecialchars_decode(request_post_var('message', '', true), ENT_COMPAT);
  1388. $message = !empty($draft_message) ? $draft_message : request_post_var('message', '', true);
  1389. $notes = htmlspecialchars_decode(request_post_var('notes', '', true), ENT_COMPAT);
  1390. $notes_mod = '';
  1391. if (($user->data['user_level'] == ADMIN) || $is_auth['auth_mod'])
  1392. {
  1393. $notes_mod = htmlspecialchars_decode(request_post_var('notes_mod', '', true), ENT_COMPAT);
  1394. }
  1395. $topic_title_clean = (empty($_POST['topic_title_clean']) ? $subject : request_post_var('topic_title_clean', '', true));
  1396. $topic_title_clean = substr(ip_clean_string($topic_title_clean, $lang['ENCODING']), 0, 254);
  1397. @include_once(IP_ROOT_PATH . 'includes/class_topics_tags.' . PHP_EXT);
  1398. $class_topics_tags = new class_topics_tags();
  1399. if (!empty($use_jquery_tags))
  1400. {
  1401. if(array_key_exists('ttag', $_POST))
  1402. {
  1403. $all_topic_tags = request_var('ttag', array(0 => ''), true);
  1404. $topic_tags = implode(', ', array_filter(array_unique($all_topic_tags)));
  1405. }
  1406. }
  1407. else
  1408. {
  1409. $topic_tags = request_var('topic_tags', '', true);
  1410. }
  1411. if (!empty($topic_tags))
  1412. {
  1413. $topic_tags = trim($topic_tags);
  1414. while(substr($topic_tags, -1) == ',')
  1415. {
  1416. $topic_tags = trim(substr($topic_tags, 0, -1));
  1417. }
  1418. $topic_tags_array = $class_topics_tags->create_tags_array($topic_tags);
  1419. $topic_tags = implode(', ', array_filter(array_unique($topic_tags_array)));
  1420. $topic_tags = substr($topic_tags, 0, 254);
  1421. //die($topic_tags);
  1422. }
  1423. unset($class_topics_tags);
  1424. $poll_title = (!empty($_POST['poll_title'])) ? request_post_var('poll_title', '', true) : '';
  1425. $poll_start = time();
  1426. $poll_length = (isset($_POST['poll_length'])) ? request_post_var('poll_length', 0) : 0;
  1427. $poll_length = max(0, $poll_length * 86400);
  1428. $poll_max_options = (isset($_POST['poll_max_options'])) ? request_post_var('poll_max_options', 1) : 1;
  1429. $poll_max_options = max(1, $poll_max_options);
  1430. $poll_change = (isset($_POST['poll_change'])) ? 1 : 0;
  1431. $poll_data = array(
  1432. 'title' => $poll_title,
  1433. 'start' => $poll_start,
  1434. 'length' => $poll_length,
  1435. 'max_options' => $poll_max_options,
  1436. 'change' => $poll_change
  1437. );
  1438. $poll_options = request_post_var('poll_option_text', array(0 => ''), true);
  1439. if (!empty($poll_options))
  1440. {
  1441. @reset($poll_options);
  1442. while(list($option_id, $option_text) = @each($poll_options))
  1443. {
  1444. if(isset($_POST['del_poll_option'][$option_id]))
  1445. {
  1446. unset($poll_options[$option_id]);
  1447. }
  1448. elseif (!empty($option_text))
  1449. {
  1450. $poll_options[$option_id] = $option_text;
  1451. }
  1452. }
  1453. }
  1454. if (!empty($poll_add) && !empty($_POST['add_poll_option_text']))
  1455. {
  1456. $poll_options[] = request_post_var('add_poll_option_text', '', true);
  1457. }
  1458. // Event Registration - BEGIN
  1459. $reg_active = (isset($_POST['start_registration']) && $is_auth['auth_vote'] && $user->data['session_logged_in']) ? 'checked="checked"' : '';
  1460. $reg_reset = (isset($_POST['reset_registration']) && $is_auth['auth_vote'] && $user->data['session_logged_in']) ? 'checked="checked"' : '';
  1461. $reg_max_option1 = (!empty($_POST['reg_max_option1']) && $is_auth['auth_vote'] && $user->data['session_logged_in']) ? max(0, $_POST['reg_max_option1']) : '';
  1462. $reg_max_option2 = (!empty($_POST['reg_max_option2']) && $is_auth['auth_vote'] && $user->data['session_logged_in']) ? max(0, $_POST['reg_max_option2']) : '';
  1463. $reg_max_option3 = (!empty($_POST['reg_max_option3']) && $is_auth['auth_vote'] && $user->data['session_logged_in']) ? max(0, $_POST['reg_max_option3']) : '';
  1464. $reg_length = (isset($_POST['reg_length']) && $is_auth['auth_vote'] && $user->data['session_logged_in']) ? max(0, $_POST['reg_length']) : '';
  1465. // Event Registration - END
  1466. if (($mode == 'newtopic') || ($mode == 'reply'))
  1467. {
  1468. $user_sig = (($user->data['user_sig'] != '') && $config['allow_sig']) ? $user->data['user_sig'] : '';
  1469. }
  1470. elseif ($mode == 'editpost')
  1471. {
  1472. $user_sig = (($post_info['user_sig'] != '') && $config['allow_sig']) ? $post_info['user_sig'] : '';
  1473. }
  1474. if(!empty($preview))
  1475. {
  1476. $preview_subject = $subject;
  1477. //$preview_message = prepare_message(unprepare_message($message), $html_on, $bbcode_on, $smilies_on);
  1478. // Mighty Gorgon: this line has been commented out because of some issues it could generate with previews... bbcode should be able to parse everything properly
  1479. //$preview_message = htmlspecialchars($message);
  1480. $preview_message = $message;
  1481. $preview_username = $username;
  1482. // Finalise processing as per viewtopic
  1483. if(!$html_on)
  1484. {
  1485. if(($user_sig != '') || !$user->data['user_allowhtml'])
  1486. {
  1487. $user_sig = preg_replace('#(<)([\/]?.*?)(>)#is', '&lt;\2&gt;', $user_sig);
  1488. }
  1489. }
  1490. $preview_username = censor_text($preview_username);
  1491. $preview_subject = censor_text($preview_subject);
  1492. $preview_message = censor_text($preview_message);
  1493. $user_sig = censor_text($user_sig);
  1494. if(($attach_sig) && ($user_sig != ''))
  1495. {
  1496. $bbcode->allow_html = ($user->data['user_allowhtml'] && $config['allow_html']) ? true : false;
  1497. $bbcode->allow_bbcode = ($user->data['user_allowbbcode'] && $config['allow_bbcode']) ? true : false;
  1498. $bbcode->allow_smilies = ($user->data['user_allowsmile'] && $config['allow_smilies']) ? true : false;
  1499. $bbcode->is_sig = true;
  1500. $user_sig = $bbcode->parse($user_sig);
  1501. $bbcode->is_sig = false;
  1502. $user_sig = str_replace('&amp;', '&', $user_sig);
  1503. }
  1504. $bbcode->allow_html = $html_on;
  1505. $bbcode->allow_bbcode = $bbcode_on;
  1506. $bbcode->allow_smilies = $smilies_on;
  1507. $preview_message = $bbcode->parse($preview_message);
  1508. $preview_message = (($bbcode_on == false) && ($html_on == false)) ? str_replace("\n", '<br />', preg_replace("/\r\n/", "\n", $preview_message)) : $preview_message;
  1509. // Start Autolinks For phpBB Mod
  1510. if($acro_auto_on == true)
  1511. {
  1512. $preview_message = $bbcode->acronym_pass($preview_message);
  1513. $preview_message = $bbcode->autolink_text($preview_message, '999999');
  1514. }
  1515. //$preview_message = kb_word_wrap_pass($preview_message);
  1516. // End Autolinks For phpBB Mod
  1517. if($attach_sig && ($user_sig != ''))
  1518. {
  1519. $user_sig = '<br />' . $config['sig_line'] . '<br />' . $user_sig;
  1520. }
  1521. //$preview_message = str_replace("\n", '<br />', $preview_message);
  1522. $url = '[url="' . CMS_PAGE_VIEWTOPIC . '?' . (!empty($forum_id_append) ? ($forum_id_append . '&') : '') . (!empty($topic_id_append) ? ($topic_id_append . '&') : '') . POST_POST_URL . '=' . $lock_subject . '#p' . $lock_subject . '"]';
  1523. $extra_message_body = sprintf($lang['Link_to_post'], $url, '[/url]') . $message;
  1524. $preview_message = ($lock_subject) ? ($extra_message_body . $preview_message) : $preview_message;
  1525. $template->set_filenames(array('preview' => 'posting_preview.tpl'));
  1526. if (!empty($topic_calendar_time))
  1527. {
  1528. $topic_calendar_duration_preview = $topic_calendar_duration - 1;
  1529. if ($topic_calendar_duration_preview < 0)
  1530. {
  1531. $topic_calendar_duration_preview = 0;
  1532. }
  1533. $preview_subject .= get_calendar_title($topic_calendar_time, $topic_calendar_duration_preview);
  1534. }
  1535. $attachment_mod['posting']->preview_attachments();
  1536. if (($mode == 'newtopic') || (($mode == 'editpost') && $post_data['first_post']))
  1537. {
  1538. $template->assign_var('S_POSTING_TOPIC', true);
  1539. }
  1540. //$preview_subject = strtr($preview_subject, array_flip(get_html_translation_table(HTML_ENTITIES)));
  1541. $template->assign_vars(array(
  1542. 'TOPIC_TITLE' => $preview_subject,
  1543. 'POSTER_NAME' => $preview_username,
  1544. 'POST_DATE' => create_date_ip($config['default_dateformat'], time(), $config['board_timezone']),
  1545. 'USER_SIG' => ($attach_sig) ? $user_sig : '',
  1546. 'PREVIEW_SUBJECT' => $preview_subject,
  1547. 'PREVIEW_MESSAGE' => $preview_message,
  1548. 'L_POST_SUBJECT' => $lang['Post_subject'],
  1549. 'L_PREVIEW' => $lang['Preview'],
  1550. 'L_POSTED' => $lang['Posted'],
  1551. 'L_POST' => $lang['Post']
  1552. )
  1553. );
  1554. $template->assign_var_from_handle('POST_PREVIEW_BOX', 'preview');
  1555. }
  1556. elseif($error_msg != '')
  1557. {
  1558. $template->set_filenames(array('reg_header' => 'error_body.tpl'));
  1559. $template->assign_vars(array(
  1560. 'ERROR_MESSAGE' => $error_msg
  1561. )
  1562. );
  1563. $template->assign_var_from_handle('ERROR_BOX', 'reg_header');
  1564. }
  1565. }
  1566. else
  1567. {
  1568. // User default entry point
  1569. $postreport = request_var('postreport', 0);
  1570. if ($postreport)
  1571. {
  1572. $sql = 'SELECT topic_id FROM ' . POSTS_TABLE . ' WHERE post_id = ' . $postreport;
  1573. $result = $db->sql_query($sql);
  1574. $post_details = $db->sql_fetchrow($result);
  1575. $post_topic_id = $post_details['topic_id'];
  1576. $sql = 'SELECT p.post_subject FROM ' . POSTS_TABLE . ' p WHERE p.topic_id = ' . $post_topic_id . ' ORDER BY p.post_time ASC LIMIT 1';
  1577. $result = $db->sql_query($sql);
  1578. $post_details = $db->sql_fetchrow($result);
  1579. $subject = '(' . $postreport . ')' . $post_details['post_subject'];
  1580. $lock_subject = $postreport;
  1581. }
  1582. else
  1583. {
  1584. $subject = '';
  1585. $lock_subject = '';
  1586. }
  1587. if ($mode == 'newtopic')
  1588. {
  1589. $user_sig = ($user->data['user_sig'] != '') ? $user->data['user_sig'] : '';
  1590. $message = '';
  1591. // Start replacement - Yellow card MOD
  1592. $username = ($user->data['session_logged_in']) ? $user->data['username'] : '';
  1593. $poll_title = '';
  1594. $poll_start = 0;
  1595. $poll_length = 0;
  1596. $poll_max_options = 1;
  1597. $poll_change = 0;
  1598. $poll_data = array(
  1599. 'title' => $poll_title,
  1600. 'start' => $poll_start,
  1601. 'length' => $poll_length,
  1602. 'max_options' => $poll_max_options,
  1603. 'change' => $poll_change
  1604. );
  1605. // End replacement - Yellow card MOD
  1606. }
  1607. elseif ($mode == 'reply')
  1608. {
  1609. $user_sig = ($user->data['user_sig'] != '') ? $user->data['user_sig'] : '';
  1610. $username = ($user->data['session_logged_in']) ? $user->data['username'] : '';
  1611. $subject = $lang['REPLY_PREFIX'] . $post_info['topic_title'];
  1612. $message = '';
  1613. }
  1614. elseif (($mode == 'quote') || ($mode == 'editpost'))
  1615. {
  1616. $subject = ($post_data['first_post']) ? $post_info['topic_title'] : $post_info['post_subject'];
  1617. $message = $post_info['post_text'];
  1618. if ($mode == 'editpost')
  1619. {
  1620. $topic_desc = '';
  1621. $topic_title_clean = '';
  1622. $topic_tags = '';
  1623. if ($post_data['first_post'])
  1624. {
  1625. $topic_desc = $post_info['topic_desc'];
  1626. $topic_title_clean = (empty($post_info['topic_title_clean']) ? $subject : $post_info['topic_title_clean']);
  1627. $topic_title_clean = substr(ip_clean_string($topic_title_clean, $lang['ENCODING']), 0, 254);
  1628. @include_once(IP_ROOT_PATH . 'includes/class_topics_tags.' . PHP_EXT);
  1629. $class_topics_tags = new class_topics_tags();
  1630. $topic_tags = (empty($post_info['topic_tags']) ? '' : $post_info['topic_tags']);
  1631. if (!empty($topic_tags))
  1632. {
  1633. $topic_tags_array = $class_topics_tags->create_tags_array($topic_tags);
  1634. $topic_tags = implode(', ', array_filter(array_unique($topic_tags_array)));
  1635. $topic_tags = substr($topic_tags, 0, 254);
  1636. }
  1637. unset($class_topics_tags);
  1638. }
  1639. $attach_sig = ($post_info['enable_sig'] && $post_info['user_sig'] != '') ? 1 : 0;
  1640. $user_sig = $post_info['user_sig'];
  1641. $topic_show_portal = ($post_info['topic_show_portal']) ? 1 : 0;
  1642. $html_on = ($post_info['enable_html']) ? 1 : 0;
  1643. $bbcode_on = ($post_info['enable_bbcode']) ? 1 : 0;
  1644. $smilies_on = ($post_info['enable_smilies']) ? 1 : 0;
  1645. $acro_auto_on = ($post_info['enable_autolinks_acronyms']) ? 1 : 0;
  1646. }
  1647. else
  1648. {
  1649. $attach_sig = ($user->data['user_attachsig']) ? 1 : 0;
  1650. $user_sig = $user->data['user_sig'];
  1651. }
  1652. $message = str_replace('<', '&lt;', $message);
  1653. $message = str_replace('>', '&gt;', $message);
  1654. $message = str_replace('<br />', "\n", $message);
  1655. if ($mode == 'quote')
  1656. {
  1657. if(preg_match('/\[hide/i', $message))
  1658. {
  1659. $search = array("/\[hide\](.*?)\[\/hide\]/");
  1660. $replace = array('[hide]' . $lang['xs_bbc_hide_quote_message'] . '[/hide]');
  1661. $message = preg_replace($search, $replace, $message);
  1662. }
  1663. $msg_date = create_date_ip($config['default_dateformat'], $postrow['post_time'], $config['board_timezone']);
  1664. // Use trim to get rid of spaces placed there by MS-SQL 2000
  1665. $quote_username = (trim($post_info['post_username']) != '') ? $post_info['post_username'] : $post_info['username'];
  1666. //$message = '[quote="' . $quote_username . '"]' . $message . '[/quote]';
  1667. $message = '[quote user="' . $quote_username . '" post="' . $post_id . '"]' . $message . '[/quote]';
  1668. $subject = censor_text($subject);
  1669. $message = censor_text($message);
  1670. $subject = (((strlen($subject) > 0) && ((substr($subject, 0, strlen($lang['REPLY_PREFIX'])) == $lang['REPLY_PREFIX']) || (substr($subject, 0, strlen($lang['REPLY_PREFIX']))) == $lang['REPLY_PREFIX_OLD'])) ? '' : $lang['REPLY_PREFIX']) . $subject;
  1671. $mode = 'reply';
  1672. }
  1673. else
  1674. {
  1675. $username = ($post_info['user_id'] == ANONYMOUS && !empty($post_info['post_username'])) ? $post_info['post_username'] : '';
  1676. }
  1677. }
  1678. }
  1679. if(($mode == 'editpost') && $config['edit_notes'])
  1680. {
  1681. $template->assign_vars(array(
  1682. 'S_EDIT_NOTES' => true,
  1683. 'L_EDIT_NOTES' => $lang['Edit_notes'],
  1684. 'NOTES' => htmlspecialchars($notes),
  1685. 'NOTES_MOD' => htmlspecialchars($notes_mod),
  1686. )
  1687. );
  1688. }
  1689. // Signature toggle selection
  1690. if($user_sig != '')
  1691. {
  1692. $template->assign_block_vars('switch_signature_checkbox', array());
  1693. }
  1694. // HTML toggle selection
  1695. if ($config['allow_html'] || (($user->data['user_level'] == ADMIN) && $config['allow_html_only_for_admins']))
  1696. {
  1697. $html_status = $lang['HTML_is_ON'];
  1698. $template->assign_block_vars('switch_html_checkbox', array());
  1699. }
  1700. else
  1701. {
  1702. $html_status = $lang['HTML_is_OFF'];
  1703. }
  1704. // BBCode toggle selection
  1705. if ($config['allow_bbcode'])
  1706. {
  1707. $bbcode_status = $lang['BBCode_is_ON'];
  1708. $template->assign_block_vars('switch_bbcode_checkbox', array());
  1709. }
  1710. else
  1711. {
  1712. $bbcode_status = $lang['BBCode_is_OFF'];
  1713. }
  1714. // Smilies toggle selection
  1715. if ($config['allow_smilies'])
  1716. {
  1717. $smilies_status = $lang['Smilies_are_ON'];
  1718. $template->assign_block_vars('switch_smilies_checkbox', array());
  1719. }
  1720. else
  1721. {
  1722. $smilies_status = $lang['Smilies_are_OFF'];
  1723. }
  1724. if(!$user->data['session_logged_in'] || (($mode == 'editpost') && $post_info['poster_id'] == ANONYMOUS))
  1725. {
  1726. $template->assign_block_vars('switch_username_select', array());
  1727. }
  1728. // UPI2DB - BEGIN
  1729. if($user->data['upi2db_access'] && ($mode == 'editpost') && (($user->data['user_level'] == ADMIN) || ($user->data['user_level'] == MOD)))
  1730. {
  1731. $template->assign_block_vars('switch_mark_edit_checkbox', array());
  1732. $mark_edit = ($refresh) ? $mark_edit : true;
  1733. }
  1734. // UPI2DB - END
  1735. // Notify checkbox - only show if user is logged in
  1736. if ($user->data['session_logged_in'] && $is_auth['auth_read'])
  1737. {
  1738. if ($mode != 'editpost' || ($mode == 'editpost' && $post_info['poster_id'] != ANONYMOUS))
  1739. {
  1740. $template->assign_block_vars('switch_notify_checkbox', array());
  1741. }
  1742. }
  1743. // Bookmark checkbox - only show if user is logged in and not editing a post
  1744. if ($user->data['session_logged_in'])
  1745. {
  1746. if ($mode != 'editpost')
  1747. {
  1748. $template->assign_block_vars('switch_bookmark_checkbox', array());
  1749. }
  1750. }
  1751. // Delete selection
  1752. if (($mode == 'editpost') && (($is_auth['auth_delete'] && $post_data['last_post'] && (!$post_data['has_poll'] || $post_data['edit_poll'])) || $is_auth['auth_mod']))
  1753. {
  1754. $template->assign_block_vars('switch_delete_checkbox', array());
  1755. }
  1756. // Lock/Unlock topic selection
  1757. if ((($mode == 'editpost') || ($mode == 'reply') || ($mode == 'quote') || ($mode == 'newtopic')) && ($is_auth['auth_mod']))
  1758. {
  1759. if ($post_info['topic_status'] == TOPIC_LOCKED)
  1760. {
  1761. $template->assign_block_vars('switch_unlock_topic', array());
  1762. $template->assign_vars(array(
  1763. 'L_UNLOCK_TOPIC' => $lang['Unlock_topic'],
  1764. 'S_UNLOCK_CHECKED' => ($unlock) ? 'checked="checked"' : ''
  1765. )
  1766. );
  1767. }
  1768. elseif ($post_info['topic_status'] == TOPIC_UNLOCKED)
  1769. {
  1770. $template->assign_block_vars('switch_lock_topic', array());
  1771. $template->assign_vars(array(
  1772. 'L_LOCK_TOPIC' => $lang['Lock_topic'],
  1773. 'S_LOCK_CHECKED' => ($lock) ? 'checked="checked"' : ''
  1774. )
  1775. );
  1776. }
  1777. }
  1778. // Topic type selection
  1779. $topic_type_toggle = '';
  1780. if ($mode == 'newtopic' || ($mode == 'editpost' && $post_data['first_post']))
  1781. {
  1782. if ($is_auth['auth_sticky'])
  1783. {
  1784. $topic_type_toggle .= '<input type="radio" name="topictype" value="' . POST_STICKY . '"';
  1785. if ($post_data['topic_type'] == POST_STICKY || $topic_type == POST_STICKY)
  1786. {
  1787. $topic_type_toggle .= ' checked="checked"';
  1788. }
  1789. $topic_type_toggle .= ' /> ' . $lang['Post_Sticky'] . '&nbsp;&nbsp;';
  1790. }
  1791. if ($is_auth['auth_announce'])
  1792. {
  1793. $topic_type_toggle .= '<input type="radio" name="topictype" value="' . POST_ANNOUNCE . '"';
  1794. if ($post_data['topic_type'] == POST_ANNOUNCE || $topic_type == POST_ANNOUNCE)
  1795. {
  1796. $topic_type_toggle .= ' checked="checked"';
  1797. }
  1798. $topic_type_toggle .= ' /> ' . $lang['Post_Announcement'] . '&nbsp;&nbsp;';
  1799. }
  1800. if ($is_auth['auth_globalannounce'])
  1801. {
  1802. $topic_type_toggle .= '<input type="radio" name="topictype" value="' . POST_GLOBAL_ANNOUNCE . '"';
  1803. if ($post_data['topic_type'] == POST_GLOBAL_ANNOUNCE || $topic_type == POST_GLOBAL_ANNOUNCE)
  1804. {
  1805. $topic_type_toggle .= ' checked="checked"';
  1806. }
  1807. $topic_type_toggle .= ' /> ' . $lang['Post_global_announcement'] . '&nbsp;&nbsp;';
  1808. }
  1809. if ($topic_type_toggle != '')
  1810. {
  1811. $topic_type_toggle = '<input type="radio" name="topictype" value="' . POST_NORMAL .'"' . (($post_data['topic_type'] == POST_NORMAL || $topic_type == POST_NORMAL) ? ' checked="checked"' : '') . ' /> ' . $lang['Post_Normal'] . '&nbsp;&nbsp;' . $topic_type_toggle;
  1812. /**
  1813. * @event posting.after_topic_type_toggle.
  1814. * @description Allows to change the topic type toggle HTML.
  1815. * @since 3.0
  1816. * @var string topic_type_toggle The fully-built topic type toggle.
  1817. * @var string mode The current mode.
  1818. * @var array post_data The post data.
  1819. */
  1820. $vars = array(
  1821. 'topic_type_toggle',
  1822. 'mode',
  1823. 'post_data'
  1824. );
  1825. extract($class_plugins->trigger('posting.after_topic_type_toggle', compact($vars)));
  1826. $template->assign_block_vars('switch_type_toggle', array());
  1827. }
  1828. }
  1829. // Calendar type selection
  1830. $topic_type_cal = '';
  1831. if (($mode == 'newtopic') || ($mode == 'editpost' && $post_data['first_post']))
  1832. {
  1833. if($is_auth['auth_cal'])
  1834. {
  1835. $template->assign_block_vars('switch_type_cal', array());
  1836. $months = array(
  1837. ' ------------ ',
  1838. $lang['datetime']['January'],
  1839. $lang['datetime']['February'],
  1840. $lang['datetime']['March'],
  1841. $lang['datetime']['April'],
  1842. $lang['datetime']['May'],
  1843. $lang['datetime']['June'],
  1844. $lang['datetime']['July'],
  1845. $lang['datetime']['August'],
  1846. $lang['datetime']['September'],
  1847. $lang['datetime']['October'],
  1848. $lang['datetime']['November'],
  1849. $lang['datetime']['December'],
  1850. );
  1851. // get the date
  1852. $topic_calendar_time = (!isset($_POST['topic_calendar_year']) || (($topic_calendar_time != intval($post_data['topic_calendar_time'])) && !$is_auth['auth_cal'])) ? intval($post_data['topic_calendar_time']) : $topic_calendar_time;
  1853. $topic_calendar_duration = ((!isset($_POST['topic_calendar_duration_day']) && !isset($_POST['topic_calendar_duration_hour']) && !isset($_POST['topic_calendar_duration_min'])) || (($topic_calendar_duration != intval($post_data['topic_calendar_duration'])) && !$is_auth['auth_cal'])) ? intval($post_data['topic_calendar_duration']) : $topic_calendar_duration;
  1854. // get the components of the event date
  1855. $year = '';
  1856. $month = '';
  1857. $day = '';
  1858. $hour = '';
  1859. $min = '';
  1860. if (!empty($topic_calendar_time))
  1861. {
  1862. $year = intval(gmdate('Y', $topic_calendar_time));
  1863. $month = intval(gmdate('m', $topic_calendar_time));
  1864. $day = intval(gmdate('d', $topic_calendar_time));
  1865. $hour = intval(gmdate('H', $topic_calendar_time));
  1866. $min = intval(gmdate('i', $topic_calendar_time));
  1867. }
  1868. // get the components of the duration
  1869. $d_day = '';
  1870. $d_hour = '';
  1871. $d_min = '';
  1872. if (!empty($topic_calendar_time) && !empty($topic_calendar_duration))
  1873. {
  1874. $d_dur = intval($topic_calendar_duration);
  1875. $d_day = intval($d_dur / 86400);
  1876. $d_dur = $d_dur - 86400 * $d_day;
  1877. $d_hour = intval($d_dur / 3600);
  1878. $d_dur = $d_dur - 3600 * $d_hour;
  1879. $d_min = intval($d_dur / 60);
  1880. }
  1881. // raz if no date
  1882. if (empty($year) || empty($month) || empty($day))
  1883. {
  1884. $year = '';
  1885. $month = '';
  1886. $day = '';
  1887. $hour = '';
  1888. $min = '';
  1889. $d_day = '';
  1890. $d_hour = '';
  1891. $d_min = '';
  1892. }
  1893. // day list
  1894. $s_topic_calendar_day = '<select name="topic_calendar_day">';
  1895. for ($i = 0; $i <= 31; $i++)
  1896. {
  1897. $selected = (intval($day) == $i) ? ' selected="selected"' : '';
  1898. $s_topic_calendar_day .= '<option value="' . $i . '"' . $selected . '>' . (($i == 0) ? ' -- ' : str_pad($i, 2, '0', STR_PAD_LEFT)) . '</option>';
  1899. }
  1900. $s_topic_calendar_day .= '</select>';
  1901. // month list
  1902. $s_topic_calendar_month = '<select name="topic_calendar_month">';
  1903. for ($i = 0; $i <= 12; $i++)
  1904. {
  1905. $selected = (intval($month) == $i) ? ' selected="selected"' : '';
  1906. $s_topic_calendar_month .= '<option value="' . $i . '"' . $selected . '>' . $months[$i] . '</option>';
  1907. }
  1908. $s_topic_calendar_month .= '</select>';
  1909. // year list
  1910. $s_topic_calendar_year = '<select name="topic_calendar_year">';
  1911. $selected = empty($year) ? ' selected="selected"' : '';
  1912. $s_topic_calendar_year .= '<option value="0"' . $select . '> ---- </option>';
  1913. $start_year = ((intval($year) > 1971) && (intval($year) <= gmdate('Y'))) ? intval($year) - 1 : gmdate('Y') - 1;
  1914. for ($i = $start_year; $i <= gmdate('Y') + 10; $i++)
  1915. {
  1916. $selected = (intval($year) == $i) ? ' selected="selected"' : '';
  1917. $s_topic_calendar_year .= '<option value="' . $i . '"' . $selected . '>' . $i . '</option>';
  1918. }
  1919. $s_topic_calendar_year .= '</select>';
  1920. // time
  1921. if (empty($hour) && empty($min))
  1922. {
  1923. $hour = '';
  1924. $min = '';
  1925. }
  1926. $topic_calendar_hour = $hour;
  1927. $topic_calendar_min = $min;
  1928. // duration
  1929. if (empty($topic_calendar_hour) && empty($topic_calendar_min))
  1930. {
  1931. $d_hour = '';
  1932. $d_min = '';
  1933. }
  1934. if (empty($d_day) && empty($d_hour) && empty($d_min))
  1935. {
  1936. $d_day = '';
  1937. $d_hour = '';
  1938. $d_min = '';
  1939. }
  1940. $topic_calendar_duration_day = $d_day;
  1941. $topic_calendar_duration_hour = $d_hour;
  1942. $topic_calendar_duration_min = $d_min;
  1943. }
  1944. }
  1945. $hidden_form_fields .= '<input type="hidden" name="mode" value="' . $mode . '" />';
  1946. $hidden_form_fields .= '<input type="hidden" name="sid" value="' . $user->data['session_id'] . '" />';
  1947. $hidden_form_fields .= ($lock_subject) ? '<input type="hidden" name="lock_subject" value="' . $lock_subject . '" />' : '';
  1948. switch($mode)
  1949. {
  1950. case 'newtopic':
  1951. $meta_content['page_title'] = $lang['Post_a_new_topic'];
  1952. $hidden_form_fields .= '<input type="hidden" name="' . POST_FORUM_URL . '" value="' . $forum_id . '" />';
  1953. break;
  1954. case 'reply':
  1955. $meta_content['page_title'] = $lang['Post_a_reply'];
  1956. $hidden_form_fields .= '<input type="hidden" name="' . POST_TOPIC_URL . '" value="' . $topic_id . '" />';
  1957. break;
  1958. case 'editpost':
  1959. $meta_content['page_title'] = $lang['Edit_Post'];
  1960. $hidden_form_fields .= '<input type="hidden" name="' . POST_POST_URL . '" value="' . $post_id . '" />';
  1961. break;
  1962. }
  1963. $meta_content['page_title'] = ($postreport || $lock_subject) ? $lang['Post_a_report'] : $meta_content['page_title'];
  1964. $page_title_alt = $meta_content['page_title'];
  1965. $meta_content['description'] = '';
  1966. $meta_content['keywords'] = '';
  1967. $nav_add_page_title = true;
  1968. // Generate smilies listing for page output
  1969. //generate_smilies('inline');
  1970. // We need to force these vars here since posting doesn't use standard Icy Phoenix page generation.
  1971. $template->assign_vars(array(
  1972. 'S_PRINT_SIZE' => (!empty($config['display_print_size']) ? true : false),
  1973. 'S_JQUERY_UI' => (!empty($config['jquery_ui']) ? true : false),
  1974. 'S_JQUERY_UI_TP' => (!empty($config['jquery_ui_tp']) ? true : false),
  1975. 'S_JQUERY_UI_BA' => (!empty($config['jquery_ui_ba']) ? true : false),
  1976. 'S_JQUERY_UI_STYLE' => (!empty($config['jquery_ui_style']) ? $config['jquery_ui_style'] : 'cupertino'),
  1977. 'S_JQUERY_TAGS' => (!empty($config['jquery_tags']) ? true : false),
  1978. )
  1979. );
  1980. // Include page header
  1981. page_header($meta_content['page_title'], true);
  1982. $template->set_filenames(array(
  1983. 'body' => 'posting_body.tpl',
  1984. 'pollbody' => 'posting_poll_body.tpl',
  1985. // Event Registration - BEGIN
  1986. 'regbody' => 'posting_events_reg_body.tpl',
  1987. // Event Registration - END
  1988. 'reviewbody' => 'posting_topic_review.tpl'
  1989. )
  1990. );
  1991. make_jumpbox(CMS_PAGE_VIEWFORUM);
  1992. $rules_bbcode = '';
  1993. if (!empty($post_info['forum_rules_in_posting']))
  1994. {
  1995. //BBcode Parsing for Olympus rules Start
  1996. $rules_bbcode = $post_info['forum_rules'];
  1997. $bbcode->allow_html = true;
  1998. $bbcode->allow_bbcode = true;
  1999. $bbcode->allow_smilies = true;
  2000. $rules_bbcode = $bbcode->parse($rules_bbcode);
  2001. //BBcode Parsing for Olympus rules Start
  2002. $template->assign_vars(array(
  2003. 'S_FORUM_RULES' => true,
  2004. 'S_FORUM_RULES_TITLE' => ($post_info['forum_rules_display_title']) ? true : false
  2005. )
  2006. );
  2007. }
  2008. $template->assign_vars(array(
  2009. 'FORUM_ID' => $forum_id,
  2010. 'FORUM_NAME' => $forum_name,
  2011. 'FORUM_RULES' => $rules_bbcode,
  2012. 'L_FORUM_RULES' => (empty($post_info['forum_rules_custom_title'])) ? $lang['Forum_Rules'] : $post_info['forum_rules_custom_title'],
  2013. 'L_POST_A' => $page_title_alt,
  2014. 'L_POST_SUBJECT' => $lang['Post_subject'],
  2015. 'U_VIEW_FORUM' => append_sid(CMS_PAGE_VIEWFORUM . '?' . POST_FORUM_URL . '=' . $forum_id)
  2016. )
  2017. );
  2018. // This enables the forum/topic title to be output for posting but not for privmsg (where it makes no sense)
  2019. $template->assign_block_vars('switch_not_privmsg', array());
  2020. // Enable the Topic Description MOD only if this is a new post or if you edit the fist post of a topic
  2021. if (($mode == 'newtopic') || (($mode == 'editpost') && $post_data['first_post']))
  2022. {
  2023. $template->assign_var('S_POSTING_TOPIC', true);
  2024. if($is_auth['auth_news'])
  2025. {
  2026. $template->assign_block_vars('switch_show_portal', array());
  2027. }
  2028. if ($config['show_topic_description'])
  2029. {
  2030. $template->assign_block_vars('topic_description', array());
  2031. }
  2032. if ($config['display_tags_box'] && (($user->data['user_level'] == ADMIN) || ($is_auth['auth_mod'] && $config['allow_moderators_edit_tags'])))
  2033. {
  2034. $template->assign_var('S_TOPIC_TAGS', true);
  2035. }
  2036. if ($config['enable_featured_image'])
  2037. {
  2038. $template->assign_var('S_FEATURED_IMAGE', true);
  2039. }
  2040. }
  2041. // CrackerTracker v5.x
  2042. $confirm_image = '';
  2043. if (($config['ctracker_vconfirm_guest'] == 1) && !$user->data['session_logged_in'])
  2044. {
  2045. define('CRACKER_TRACKER_VCONFIRM', true);
  2046. $template->assign_block_vars('switch_confirm', array());
  2047. include_once(IP_ROOT_PATH . 'includes/ctracker/engines/ct_visual_confirm.' . PHP_EXT);
  2048. }
  2049. // CrackerTracker v5.x
  2050. if (!empty($config['ajax_features']))
  2051. {
  2052. $ajax_blur = ($mode == 'newtopic') ? 'onblur="AJAXSearch(this.value);"' : '';
  2053. $ajax_pm_user_check = 'onkeyup="AJAXCheckPMUsername(this.value);"';
  2054. }
  2055. else
  2056. {
  2057. $ajax_blur = '';
  2058. $ajax_pm_user_check = '';
  2059. }
  2060. // MG Drafts - BEGIN
  2061. if ($config['allow_drafts'] == true)
  2062. {
  2063. $template->assign_block_vars('allow_drafts', array());
  2064. $hidden_form_fields .= '<input type="hidden" name="d" value="' . $draft_id . '" />';
  2065. if (($draft == true) && ($draft_confirm == false))
  2066. {
  2067. $template->assign_block_vars('save_draft_confirm', array());
  2068. }
  2069. }
  2070. // MG Drafts - END
  2071. // MG Featured Image - BEGIN
  2072. $post_featured_image = $post_info['post_images'];
  2073. // MG Featured Image - END
  2074. // Convert and clean special chars!
  2075. $subject = (($mode == 'editpost') ? $subject : htmlspecialchars_clean($subject));
  2076. $topic_desc = !empty($topic_desc) ? htmlspecialchars_clean($topic_desc) : '';
  2077. $topic_title_clean = (empty($topic_title_clean) ? $subject : trim($topic_title_clean));
  2078. $topic_title_clean = substr(ip_clean_string($topic_title_clean, $lang['ENCODING']), 0, 254);
  2079. $topic_tags = (empty($topic_tags) ? '' : trim($topic_tags));
  2080. // Clean Name - BEGIN
  2081. // Just hidden for now... we can restore it in the future...
  2082. $hidden_form_fields .= '<input type="hidden" name="topic_title_clean" value="' . $topic_title_clean . '" />';
  2083. // Clean Name - END
  2084. if (!empty($topic_tags))
  2085. {
  2086. $ttags = explode(', ', $topic_tags);
  2087. foreach ($ttags as $ttag)
  2088. {
  2089. if (!empty($ttag))
  2090. {
  2091. $template->assign_block_vars('ttag', array(
  2092. 'TTAG' => $ttag
  2093. )
  2094. );
  2095. }
  2096. }
  2097. }
  2098. // Output the data to the template
  2099. $template->assign_vars(array(
  2100. 'FORUM_ID' => $forum_id,
  2101. 'USERNAME' => $username,
  2102. 'SUBJECT' => $subject,
  2103. 'TOPIC_DESCRIPTION' => $topic_desc,
  2104. 'TOPIC_TITLE_CLEAN' => $topic_title_clean,
  2105. 'TOPIC_TAGS' => $topic_tags,
  2106. 'POST_FEATURED_IMAGE' => $post_info['post_images'],
  2107. 'S_JQUERY_TOPIC_TAGS' => !empty($use_jquery_tags) ? true : false,
  2108. 'MESSAGE' => $message,
  2109. 'HTML_STATUS' => $html_status,
  2110. 'BBCODE_STATUS' => sprintf($bbcode_status, '<a href="' . append_sid('faq.' . PHP_EXT . '?mode=bbcode') . '" target="_blank">', '</a>'),
  2111. 'SMILIES_STATUS' => $smilies_status,
  2112. 'L_SUBJECT' => $lang['Subject'],
  2113. 'L_TYPE_TOGGLE_TITLE' => $lang['Post_topic_as'],
  2114. 'L_MESSAGE_BODY' => $lang['Message_body'],
  2115. 'L_OPTIONS' => $lang['Options'],
  2116. 'L_PREVIEW' => $lang['Preview'],
  2117. 'L_DRAFTS' => $lang['Drafts'],
  2118. 'L_DRAFT_SAVE' => $lang['Drafts_Save'],
  2119. 'L_DRAFT_CONFIRM' => $lang['Drafts_Save_Question'],
  2120. 'L_SPELLCHECK' => $lang['Spellcheck'],
  2121. 'L_SUBMIT' => $lang['Submit'],
  2122. 'L_CANCEL' => $lang['Cancel'],
  2123. 'L_CONFIRM_DELETE' => $lang['Confirm_delete'],
  2124. 'L_DISABLE_HTML' => $lang['Disable_HTML_post'],
  2125. 'L_DISABLE_ACRO_AUTO' => $lang['Disable_ACRO_AUTO_post'],
  2126. 'L_DISABLE_BBCODE' => $lang['Disable_BBCode_post'],
  2127. 'L_DISABLE_SMILIES' => $lang['Disable_Smilies_post'],
  2128. 'L_ATTACH_SIGNATURE' => $lang['Attach_signature'],
  2129. 'L_SET_BOOKMARK' => $lang['Set_Bookmark'],
  2130. 'L_NOTIFY_ON_REPLY' => $lang['Notify'],
  2131. // UPI2DB - BEGIN
  2132. 'L_MARK_EDIT' => $lang['mark_edit'],
  2133. // UPI2DB - END
  2134. 'L_DELETE_POST' => $lang['Delete_post'],
  2135. 'L_SHOW_PORTAL' => $lang['Show_In_Portal'],
  2136. 'S_TOPIC_SHOW_PORTAL' => ($topic_show_portal) ? 'checked="checked"' : '',
  2137. 'L_POST_HIGHLIGHT' => $lang['PostHighlight'],
  2138. 'L_TOPIC_DESCRIPTION' => $lang['Topic_description'],
  2139. 'U_SMILEY_CREATOR' => append_sid('smiley_creator.' . PHP_EXT . '?mode=text2shield'),
  2140. 'U_VIEWTOPIC' => ($mode == 'reply') ? append_sid(CMS_PAGE_VIEWTOPIC . '?' . (!empty($forum_id_append) ? ($forum_id_append . '&amp;') : '') . $topic_id_append . '&amp;sd=d') : '',
  2141. 'U_REVIEW_TOPIC' => ($mode == 'reply') ? append_sid('posting.' . PHP_EXT . '?mode=topicreview&amp;' . (!empty($forum_id_append) ? ($forum_id_append . '&amp;') : '') . $topic_id_append) : '',
  2142. 'S_IS_PM' => 0,
  2143. // AJAX Features - BEGIN
  2144. 'S_AJAX_BLUR' => $ajax_blur,
  2145. 'S_AJAX_PM_USER_CHECK' => $ajax_pm_user_check,
  2146. 'S_DISPLAY_PREVIEW' => ($preview) ? '' : 'style="display: none;"',
  2147. 'S_EDIT_POST_ID' => ($mode == 'editpost') ? $post_id : 0,
  2148. 'L_SEARCH_RESULTS' => $lang['AJAX_search_results'],
  2149. 'L_SEARCH_RESULT' => $lang['AJAX_search_result'],
  2150. 'L_EMPTY_SUBJECT' => $lang['Empty_subject'],
  2151. 'L_AJAX_NO_RESULTS' => $lang['No_search_match'],
  2152. 'L_MAX_POLL_OPTIONS' => $lang['To_many_poll_options'],
  2153. 'POLL_MAX_OPTIONS' => $config['max_poll_options'],
  2154. // AJAX Features - END
  2155. 'L_CALENDAR_TITLE' => $lang['Calendar_event'],
  2156. 'L_TIME' => $lang['Event_time'],
  2157. 'L_CALENDAR_DURATION' => $lang['Calendar_duration'],
  2158. 'L_DAYS' => $lang['Days'],
  2159. 'L_HOURS' => $lang['Hours'],
  2160. 'L_MINUTES' => $lang['Minutes'],
  2161. 'L_TODAY' => $lang['Today'],
  2162. // We need to remove leading zero or we may have problems with the script!
  2163. 'TODAY_DAY' => gmdate('j'),
  2164. 'TODAY_MONTH' => gmdate('n'),
  2165. 'TODAY_YEAR' => gmdate('Y'),
  2166. 'S_CALENDAR_YEAR' => (!empty($s_topic_calendar_year) ? $s_topic_calendar_year : ''),
  2167. 'S_CALENDAR_MONTH' => (!empty($s_topic_calendar_month) ? $s_topic_calendar_month : ''),
  2168. 'S_CALENDAR_DAY' => (!empty($s_topic_calendar_day) ? $s_topic_calendar_day : ''),
  2169. 'CALENDAR_HOUR' => (!empty($topic_calendar_hour) ? $topic_calendar_hour : ''),
  2170. 'CALENDAR_MIN' => (!empty($topic_calendar_min) ? $topic_calendar_min : ''),
  2171. 'CALENDAR_DURATION_DAY' => (!empty($topic_calendar_duration_day) ? $topic_calendar_duration_day : ''),
  2172. 'CALENDAR_DURATION_HOUR' => (!empty($topic_calendar_duration_hour) ? $topic_calendar_duration_hour : ''),
  2173. 'CALENDAR_DURATION_MIN' => (!empty($topic_calendar_duration_min) ? $topic_calendar_duration_min : ''),
  2174. 'S_HTML_CHECKED' => (!$html_on) ? 'checked="checked"' : '',
  2175. 'S_ACRO_AUTO_CHECKED' => ($acro_auto_on == false) ? ' checked="checked"' : '',
  2176. 'S_BBCODE_CHECKED' => (!$bbcode_on) ? 'checked="checked"' : '',
  2177. 'S_SMILIES_CHECKED' => (!$smilies_on) ? 'checked="checked"' : '',
  2178. 'S_SIGNATURE_CHECKED' => ($attach_sig) ? 'checked="checked"' : '',
  2179. 'S_SETBM_CHECKED' => ($setbm) ? 'checked="checked"' : '',
  2180. // Start replacement - Yellow card admin MOD
  2181. 'S_NOTIFY_CHECKED' => ($is_auth['auth_read']) ? (($notify_user) ? 'checked="checked"' : '') : 'DISABLED',
  2182. 'S_LOCK_SUBJECT' => ($lock_subject) ? ' READONLY ' : '',
  2183. // End replacement - Yellow card admin MOD
  2184. // UPI2DB - BEGIN
  2185. 'S_MARK_EDIT_CHECKED' => ($mark_edit) ? 'checked="checked"' : '',
  2186. // UPI2DB - BEGIN
  2187. // CrackerTracker v5.x
  2188. 'CONFIRM_IMAGE' => $confirm_image,
  2189. 'L_CT_CONFIRM' => $lang['ctracker_vc_guest_post'],
  2190. 'L_CT_CONFIRM_E' => $lang['ctracker_vc_guest_expl'],
  2191. 'S_HIDDEN_FIELDS' => $s_hidden_fields,
  2192. // CrackerTracker v5.x
  2193. 'S_TYPE_TOGGLE' => $topic_type_toggle,
  2194. 'S_TOPIC_ID' => $topic_id,
  2195. 'S_POST_ACTION' => append_sid(CMS_PAGE_POSTING),
  2196. 'S_HIDDEN_FORM_FIELDS' => $hidden_form_fields
  2197. )
  2198. );
  2199. // Poll entry switch/output
  2200. if((($mode == 'newtopic') || (($mode == 'editpost') && $post_data['edit_poll'])) && $is_auth['auth_pollcreate'])
  2201. {
  2202. $template->assign_vars(array(
  2203. 'L_ADD_A_POLL' => $lang['Add_poll'],
  2204. 'L_ADD_POLL_EXPLAIN' => $lang['Add_poll_explain'],
  2205. 'L_POLL_QUESTION' => $lang['Poll_question'],
  2206. 'L_POLL_OPTION' => $lang['Poll_option'],
  2207. 'L_ADD_OPTION' => $lang['Add_option'],
  2208. 'L_UPDATE_OPTION' => $lang['Update'],
  2209. 'L_DELETE_OPTION' => $lang['Delete'],
  2210. 'L_POLL_LENGTH' => $lang['Poll_for'],
  2211. 'L_DAYS' => $lang['Days'],
  2212. 'L_POLL_LENGTH_EXPLAIN' => $lang['Poll_for_explain'],
  2213. 'L_POLL_DELETE' => $lang['Delete_poll'],
  2214. 'POLL_TITLE' => $poll_title,
  2215. 'POLL_START' => $poll_start,
  2216. 'POLL_LENGTH' => $poll_length,
  2217. 'POLL_MAX_OPTIONS_INPUT' => $poll_max_options,
  2218. 'POLL_CHANGE_CHECKBOX' => (!empty($poll_change) ? ' checked="checked"' : ''),
  2219. 'POLL_CHANGE' => $poll_change
  2220. )
  2221. );
  2222. if(($mode == 'editpost') && $post_data['edit_poll'] && $post_data['has_poll'])
  2223. {
  2224. $template->assign_block_vars('switch_poll_delete_toggle', array());
  2225. }
  2226. if(!empty($poll_options))
  2227. {
  2228. @reset($poll_options);
  2229. while(list($option_id, $option_text) = each($poll_options))
  2230. {
  2231. if (!empty($option_text))
  2232. {
  2233. $template->assign_block_vars('poll_option_rows', array(
  2234. 'POLL_OPTION' => $option_text,
  2235. 'S_POLL_OPTION_NUM' => $option_id
  2236. )
  2237. );
  2238. }
  2239. }
  2240. }
  2241. $template->assign_var_from_handle('POLLBOX', 'pollbody');
  2242. }
  2243. // Event Registration - BEGIN
  2244. // Registration entry switch/output
  2245. if((($mode == 'newtopic') || (($mode == 'editpost') && $post_data['first_post'])) && $is_auth['auth_cal'])
  2246. {
  2247. if($preview)
  2248. {
  2249. $reg_active = ($_POST['start_registration'] == 1) ? 'checked="checked"' : '';
  2250. $reg_max_option1 = (!empty($_POST['reg_max_option1'])) ? $_POST['reg_max_option1'] : '';
  2251. $reg_max_option2 = (!empty($_POST['reg_max_option2'])) ? $_POST['reg_max_option2'] : '';
  2252. $reg_max_option3 = (!empty($_POST['reg_max_option3'])) ? $_POST['reg_max_option3'] : '';
  2253. $reg_length = (!empty($_POST['reg_length'])) ? $_POST['reg_length'] : '';
  2254. }
  2255. // secure integer-values
  2256. $reg_max_option1 = (!empty($reg_max_option1)) ? max(0, intval($reg_max_option1)) : '';
  2257. $reg_max_option2 = (!empty($reg_max_option2)) ? max(0, intval($reg_max_option2)) : '';
  2258. $reg_max_option3 = (!empty($reg_max_option3)) ? max(0, intval($reg_max_option3)) : '';
  2259. $reg_length = (isset($reg_length)) ? max(0, intval($reg_length)) : 0;
  2260. $template->assign_vars(array(
  2261. 'REG_ACTIVE' => $reg_active,
  2262. 'L_REG_TITLE' => $lang['Reg_Title'],
  2263. 'L_ADD_REGISTRATION' => $lang['Add_registration'],
  2264. 'L_ADD_REG_EXPLAIN' => $lang['Add_reg_explain'],
  2265. 'L_REG_ACTIVATE' => $lang['reg_activate'],
  2266. 'L_REG_RESET' => $lang['reg_reset'],
  2267. //'L_REG_OPTION1_OPTION' => $lang['Reg_Green_Option'],
  2268. //'L_REG_OPTION2_OPTION' => $lang['Reg_Blue_Option'],
  2269. //'L_REG_OPTION3_OPTION' => $lang['Reg_Red_Option'],
  2270. 'L_REG_OPTION1' => $lang['Reg_Do'],
  2271. 'L_REG_OPTION2' => $lang['Reg_Maybe'],
  2272. 'L_REG_OPTION3' => $lang['Reg_Dont'],
  2273. 'L_REG_MAX_OPTION1' => $reg_max_option1,
  2274. 'L_REG_MAX_OPTION2' => $reg_max_option2,
  2275. 'L_REG_MAX_OPTION3' => $reg_max_option3,
  2276. 'L_REG_MAX_REGISTRATIONS' => $lang['Reg_Value_Max_Registrations'],
  2277. 'REG_LENGTH' => $reg_length,
  2278. 'L_REG_LENGTH' => $lang['Reg_for'],
  2279. 'L_REG_LENGTH_EXPLAIN' => $lang['Reg_for_explain'],
  2280. 'L_REG_DAYS' => $lang['Days']
  2281. )
  2282. );
  2283. $template->assign_var_from_handle('REGBOX', 'regbody');
  2284. }
  2285. // Event Registration - END
  2286. // Topic review
  2287. if($mode == 'reply' && $is_auth['auth_read'])
  2288. {
  2289. require(IP_ROOT_PATH . 'includes/topic_review.' . PHP_EXT);
  2290. topic_review($forum_id, $topic_id, true);
  2291. $template->assign_block_vars('switch_inline_mode', array());
  2292. $template->assign_var_from_handle('TOPIC_REVIEW_BOX', 'reviewbody');
  2293. }
  2294. // BBCBMG - BEGIN
  2295. include(IP_ROOT_PATH . 'includes/bbcb_mg.' . PHP_EXT);
  2296. $template->assign_var_from_handle('BBCB_MG', 'bbcb_mg');
  2297. // BBCBMG - END
  2298. // BBCBMG SMILEYS - BEGIN
  2299. generate_smilies('inline');
  2300. include(IP_ROOT_PATH . 'includes/bbcb_smileys_mg.' . PHP_EXT);
  2301. $template->assign_var_from_handle('BBCB_SMILEYS_MG', 'bbcb_smileys_mg');
  2302. // BBCBMG SMILEYS - END
  2303. page_footer();
  2304. ?>