PageRenderTime 60ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/viewtopic.php

https://github.com/gencer/fluxbb
PHP | 534 lines | 387 code | 112 blank | 35 comment | 165 complexity | 0afef8cc7e25b48d8b249bdb368eeac5 MD5 | raw file
Possible License(s): GPL-2.0
  1. <?php
  2. /**
  3. * Copyright (C) 2008-2012 FluxBB
  4. * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB
  5. * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
  6. */
  7. define('PUN_ROOT', dirname(__FILE__).'/');
  8. require PUN_ROOT.'include/common.php';
  9. if ($pun_user['g_read_board'] == '0')
  10. message($lang->t('No view'));
  11. $action = isset($_GET['action']) ? $_GET['action'] : null;
  12. $id = isset($_GET['id']) ? intval($_GET['id']) : 0;
  13. $pid = isset($_GET['pid']) ? intval($_GET['pid']) : 0;
  14. if ($id < 1 && $pid < 1)
  15. message($lang->t('Bad request'));
  16. // Load the viewtopic.php language file
  17. $lang->load('topic');
  18. // If a post ID is specified we determine topic ID and page number so we can redirect to the correct message
  19. if ($pid)
  20. {
  21. $query = $db->select(array('topic_id' => 'p.topic_id', 'posted' => 'p.posted'), 'posts AS p');
  22. $query->where = 'id = :pid';
  23. $params = array(':pid' => $pid);
  24. $result = $query->run($params);
  25. if (empty($result))
  26. message($lang->t('Bad request'));
  27. $id = $result[0]['topic_id'];
  28. $posted = $result[0]['posted'];
  29. unset ($result, $query, $params);
  30. // Determine on what page the post is located (depending on $forum_user['disp_posts'])
  31. $query = $db->select(array('num_posts' => '(COUNT(p.id) + 1) AS num_posts'), 'posts AS p');
  32. $query->where = 'p.topic_id = :tid AND p.posted < :posted';
  33. $params = array(':tid' => $id, ':posted' => $posted);
  34. $result = $query->run($params);
  35. $num_posts = $result[0]['num_posts'];
  36. unset ($result, $query, $params);
  37. $_GET['p'] = ceil($num_posts / $pun_user['disp_posts']);
  38. }
  39. // If action=new, we redirect to the first new post (if any)
  40. else if ($action == 'new')
  41. {
  42. if (!$pun_user['is_guest'])
  43. {
  44. // We need to check if this topic has been viewed recently by the user
  45. $tracked_topics = get_tracked_topics();
  46. $last_viewed = isset($tracked_topics['topics'][$id]) ? $tracked_topics['topics'][$id] : $pun_user['last_visit'];
  47. $query = $db->select(array('new_pid' => 'MIN(p.id) AS new_pid'), 'posts AS p');
  48. $query->where = 'p.topic_id = :tid AND p.posted > :last_viewed';
  49. $params = array(':tid' => $id, ':last_viewed' => $last_viewed);
  50. $result = $query->run($params);
  51. unset ($query, $params);
  52. if (!empty($result))
  53. {
  54. $first_new_post_id = $result[0]['new_pid'];
  55. header('Location: viewtopic.php?pid='.$first_new_post_id.'#p'.$first_new_post_id);
  56. exit;
  57. }
  58. }
  59. // If there is no new post, we go to the last post
  60. header('Location: viewtopic.php?id='.$id.'&action=last');
  61. exit;
  62. }
  63. // If action=last, we redirect to the last post
  64. else if ($action == 'last')
  65. {
  66. $query = $db->select(array('last_pid' => 'MAX(p.id) AS last_pid'), 'posts AS p');
  67. $query->where = 'topic_id = :tid';
  68. $params = array(':tid' => $id);
  69. $result = $query->run($params);
  70. unset ($query, $params);
  71. if (!empty($result))
  72. {
  73. $last_post_id = $result[0]['last_pid'];
  74. header('Location: viewtopic.php?pid='.$last_post_id.'#p'.$last_post_id);
  75. exit;
  76. }
  77. }
  78. // Fetch some info about the topic
  79. $query = $db->select(array('subject' => 't.subject', 'closed' => 't.closed', 'num_replies' => 't.num_replies', 'sticky' => 't.sticky', 'first_post_id' => 't.first_post_id', 'forum_id' => 'f.id AS forum_id', 'forum_name' => 'f.forum_name', 'moderators' => 'f.moderators', 'post_replies' => 'fp.post_replies', 'is_subscribed' => '0 AS is_subscribed'), 'topics AS t');
  80. $query->innerJoin('f', 'forums AS f', 'f.id = t.forum_id');
  81. $query->leftJoin('fp', 'forum_perms AS fp', 'fp.forum_id = f.id AND fp.group_id = :group_id');
  82. $query->where = '(fp.read_forum IS NULL OR fp.read_forum = 1) AND t.id = :tid AND t.moved_to IS NULL';
  83. $params = array(':group_id' => $pun_user['g_id'], ':tid' => $id);
  84. // If we aren't a guest then handle subscription checks
  85. if (!$pun_user['is_guest'])
  86. {
  87. $query->fields['is_subscribed'] = 's.user_id AS is_subscribed';
  88. $query->leftJoin('s', 'topic_subscriptions AS s', 't.id = s.topic_id AND s.user_id = :user_id');
  89. $params[':user_id'] = $pun_user['id'];
  90. }
  91. $result = $query->run($params);
  92. if (empty($result))
  93. message($lang->t('Bad request'));
  94. $cur_topic = $result[0];
  95. unset ($query, $params, $result);
  96. // Sort out who the moderators are and if we are currently a moderator (or an admin)
  97. $mods_array = ($cur_topic['moderators'] != '') ? unserialize($cur_topic['moderators']) : array();
  98. $is_admmod = ($pun_user['g_id'] == PUN_ADMIN || ($pun_user['g_moderator'] == '1' && array_key_exists($pun_user['username'], $mods_array))) ? true : false;
  99. // Can we or can we not post replies?
  100. if ($cur_topic['closed'] == '0')
  101. {
  102. if (($cur_topic['post_replies'] == '' && $pun_user['g_post_replies'] == '1') || $cur_topic['post_replies'] == '1' || $is_admmod)
  103. $post_link = "\t\t\t".'<p class="postlink conr"><a href="post.php?tid='.$id.'">'.$lang->t('Post reply').'</a></p>'."\n";
  104. else
  105. $post_link = '';
  106. }
  107. else
  108. {
  109. $post_link = $lang->t('Topic closed');
  110. if ($is_admmod)
  111. $post_link .= ' / <a href="post.php?tid='.$id.'">'.$lang->t('Post reply').'</a>';
  112. $post_link = "\t\t\t".'<p class="postlink conr">'.$post_link.'</p>'."\n";
  113. }
  114. // Add/update this topic in our list of tracked topics
  115. if (!$pun_user['is_guest'])
  116. {
  117. $tracked_topics = get_tracked_topics();
  118. $tracked_topics['topics'][$id] = time();
  119. set_tracked_topics($tracked_topics);
  120. }
  121. // Determine the post offset (based on $_GET['p'])
  122. $num_pages = ceil(($cur_topic['num_replies'] + 1) / $pun_user['disp_posts']);
  123. $p = (!isset($_GET['p']) || $_GET['p'] <= 1 || $_GET['p'] > $num_pages) ? 1 : intval($_GET['p']);
  124. $start_from = $pun_user['disp_posts'] * ($p - 1);
  125. // Generate paging links
  126. $paging_links = '<span class="pages-label">'.$lang->t('Pages').' </span>'.paginate($num_pages, $p, 'viewtopic.php?id='.$id);
  127. if ($pun_config['o_censoring'] == '1')
  128. $cur_topic['subject'] = censor_words($cur_topic['subject']);
  129. $quickpost = false;
  130. if ($pun_config['o_quickpost'] == '1' &&
  131. ($cur_topic['post_replies'] == '1' || ($cur_topic['post_replies'] == '' && $pun_user['g_post_replies'] == '1')) &&
  132. ($cur_topic['closed'] == '0' || $is_admmod))
  133. {
  134. // Load the post.php language file
  135. $lang->load('post');
  136. $required_fields = array('req_message' => $lang->t('Message'));
  137. if ($pun_user['is_guest'])
  138. {
  139. $required_fields['req_username'] = $lang->t('Guest name');
  140. if ($pun_config['p_force_guest_email'] == '1')
  141. $required_fields['req_email'] = $lang->t('Email');
  142. }
  143. $quickpost = true;
  144. }
  145. if (!$pun_user['is_guest'] && $pun_config['o_topic_subscriptions'] == '1')
  146. {
  147. if ($cur_topic['is_subscribed'])
  148. // I apologize for the variable naming here. It's a mix of subscription and action I guess :-)
  149. $subscraction = "\t\t".'<p class="subscribelink clearb"><span>'.$lang->t('Is subscribed').' - </span><a href="misc.php?action=unsubscribe&amp;tid='.$id.'">'.$lang->t('Unsubscribe').'</a></p>'."\n";
  150. else
  151. $subscraction = "\t\t".'<p class="subscribelink clearb"><a href="misc.php?action=subscribe&amp;tid='.$id.'">'.$lang->t('Subscribe').'</a></p>'."\n";
  152. }
  153. else
  154. $subscraction = '';
  155. if ($pun_config['o_feed_type'] == '1')
  156. $page_head = array('feed' => '<link rel="alternate" type="application/rss+xml" href="extern.php?action=feed&amp;tid='.$id.'&amp;type=rss" title="'.$lang->t('RSS topic feed').'" />');
  157. else if ($pun_config['o_feed_type'] == '2')
  158. $page_head = array('feed' => '<link rel="alternate" type="application/atom+xml" href="extern.php?action=feed&amp;tid='.$id.'&amp;type=atom" title="'.$lang->t('Atom topic feed').'" />');
  159. $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), pun_htmlspecialchars($cur_topic['forum_name']), pun_htmlspecialchars($cur_topic['subject']));
  160. define('PUN_ALLOW_INDEX', 1);
  161. define('PUN_ACTIVE_PAGE', 'index');
  162. require PUN_ROOT.'header.php';
  163. ?>
  164. <div class="linkst">
  165. <div class="inbox crumbsplus">
  166. <ul class="crumbs">
  167. <li><a href="index.php"><?php echo $lang->t('Index') ?></a></li>
  168. <li><span>»&#160;</span><a href="viewforum.php?id=<?php echo $cur_topic['forum_id'] ?>"><?php echo pun_htmlspecialchars($cur_topic['forum_name']) ?></a></li>
  169. <li><span>»&#160;</span><a href="viewtopic.php?id=<?php echo $id ?>"><strong><?php echo pun_htmlspecialchars($cur_topic['subject']) ?></strong></a></li>
  170. </ul>
  171. <div class="pagepost">
  172. <p class="pagelink conl"><?php echo $paging_links ?></p>
  173. <?php echo $post_link ?>
  174. </div>
  175. <div class="clearer"></div>
  176. </div>
  177. </div>
  178. <?php
  179. require PUN_ROOT.'include/parser.php';
  180. $post_count = 0; // Keep track of post numbers
  181. // Retrieve a list of post IDs, LIMIT is (really) expensive so we only fetch the IDs here then later fetch the remaining data
  182. $query = $db->select(array('id' => 'p.id'), 'posts AS p');
  183. $query->where = 'p.topic_id = :tid';
  184. $query->order = array('id' => 'p.id ASC');
  185. $query->limit = $pun_user['disp_posts'];
  186. $query->offset = $start_from;
  187. $params = array(':tid' => $id);
  188. $post_ids = $query->run($params);
  189. unset ($query, $params);
  190. // If there are posts in this topic
  191. if (empty($post_ids))
  192. error('The post table and topic table seem to be out of sync!', __FILE__, __LINE__);
  193. // Translate from a 3d array into 2d array: $post_ids[0]['id'] -> $post_ids[0]
  194. foreach ($post_ids as $key => $value)
  195. $post_ids[$key] = $value['id'];
  196. // Retrieve the posts (and their respective poster/online status)
  197. $query = $db->select(array('email' => 'u.email', 'title' => 'u.title', 'url' => 'u.url', 'location' => 'u.location', 'signature' => 'u.signature', 'email_setting' => 'u.email_setting', 'num_posts' => 'u.num_posts', 'registered' => 'u.registered', 'admin_note' => 'u.admin_note', 'pid' => 'p.id', 'username' => 'p.poster AS username', 'poster_id' => 'p.poster_id', 'poster_ip' => 'p.poster_ip', 'poster_email' => 'p.poster_email', 'message' => 'p.message', 'hide_smilies' => 'p.hide_smilies', 'posted' => 'p.posted', 'edited' => 'p.edited', 'edited_by' => 'p.edited_by', 'gid' => 'g.g_id', 'g_user_title' => 'g.g_user_title', 'is_online' => 'o.user_id AS is_online'), 'posts AS p');
  198. $query->innerJoin('u', 'users AS u', 'u.id = p.poster_id');
  199. $query->innerJoin('g', 'groups AS g', 'g.g_id = u.group_id');
  200. $query->leftJoin('o', 'online AS o', 'o.user_id = u.id AND o.user_id != 1 AND o.idle = 0');
  201. $query->where = 'p.id IN :pids';
  202. $query->order = array('pid' => 'p.id ASC');
  203. $params = array(':pids' => $post_ids);
  204. $result = $query->run($params);
  205. foreach ($result as $cur_post)
  206. {
  207. $post_count++;
  208. $user_avatar = '';
  209. $user_info = array();
  210. $user_contacts = array();
  211. $post_actions = array();
  212. $is_online = '';
  213. $signature = '';
  214. // If the poster is a registered user
  215. if ($cur_post['poster_id'] > 1)
  216. {
  217. if ($pun_user['g_view_users'] == '1')
  218. $username = '<a href="profile.php?id='.$cur_post['poster_id'].'">'.pun_htmlspecialchars($cur_post['username']).'</a>';
  219. else
  220. $username = pun_htmlspecialchars($cur_post['username']);
  221. $user_title = get_title($cur_post);
  222. if ($pun_config['o_censoring'] == '1')
  223. $user_title = censor_words($user_title);
  224. // Format the online indicator
  225. $is_online = ($cur_post['is_online'] == $cur_post['poster_id']) ? '<strong>'.$lang->t('Online').'</strong>' : '<span>'.$lang->t('Offline').'</span>';
  226. if ($pun_config['o_avatars'] == '1' && $pun_user['show_avatars'] != '0')
  227. {
  228. if (isset($user_avatar_cache[$cur_post['poster_id']]))
  229. $user_avatar = $user_avatar_cache[$cur_post['poster_id']];
  230. else
  231. $user_avatar = $user_avatar_cache[$cur_post['poster_id']] = generate_avatar_markup($cur_post['poster_id']);
  232. }
  233. // We only show location, register date, post count and the contact links if "Show user info" is enabled
  234. if ($pun_config['o_show_user_info'] == '1')
  235. {
  236. if ($cur_post['location'] != '')
  237. {
  238. if ($pun_config['o_censoring'] == '1')
  239. $cur_post['location'] = censor_words($cur_post['location']);
  240. $user_info[] = '<dd><span>'.$lang->t('From').' '.pun_htmlspecialchars($cur_post['location']).'</span></dd>';
  241. }
  242. $user_info[] = '<dd><span>'.$lang->t('Registered date').' '.format_time($cur_post['registered'], true).'</span></dd>';
  243. if ($pun_config['o_show_post_count'] == '1' || $pun_user['is_admmod'])
  244. $user_info[] = '<dd><span>'.$lang->t('Num posts').' '.forum_number_format($cur_post['num_posts']).'</span></dd>';
  245. // Now let's deal with the contact links (Email and URL)
  246. if ((($cur_post['email_setting'] == '0' && !$pun_user['is_guest']) || $pun_user['is_admmod']) && $pun_user['g_send_email'] == '1')
  247. $user_contacts[] = '<span class="email"><a href="mailto:'.$cur_post['email'].'">'.$lang->t('Email').'</a></span>';
  248. else if ($cur_post['email_setting'] == '1' && !$pun_user['is_guest'] && $pun_user['g_send_email'] == '1')
  249. $user_contacts[] = '<span class="email"><a href="misc.php?email='.$cur_post['poster_id'].'">'.$lang->t('Email').'</a></span>';
  250. if ($cur_post['url'] != '')
  251. {
  252. if ($pun_config['o_censoring'] == '1')
  253. $cur_post['url'] = censor_words($cur_post['url']);
  254. $user_contacts[] = '<span class="website"><a href="'.pun_htmlspecialchars($cur_post['url']).'">'.$lang->t('Website').'</a></span>';
  255. }
  256. }
  257. if ($pun_user['is_admmod'])
  258. {
  259. $user_info[] = '<dd><span><a href="moderate.php?get_host='.$cur_post['id'].'" title="'.$cur_post['poster_ip'].'">'.$lang->t('IP address logged').'</a></span></dd>';
  260. if ($cur_post['admin_note'] != '')
  261. $user_info[] = '<dd><span>'.$lang->t('Note').' <strong>'.pun_htmlspecialchars($cur_post['admin_note']).'</strong></span></dd>';
  262. }
  263. }
  264. // If the poster is a guest (or a user that has been deleted)
  265. else
  266. {
  267. $username = pun_htmlspecialchars($cur_post['username']);
  268. $user_title = get_title($cur_post);
  269. if ($pun_user['is_admmod'])
  270. $user_info[] = '<dd><span><a href="moderate.php?get_host='.$cur_post['id'].'" title="'.$cur_post['poster_ip'].'">'.$lang->t('IP address logged').'</a></span></dd>';
  271. if ($pun_config['o_show_user_info'] == '1' && $cur_post['poster_email'] != '' && !$pun_user['is_guest'] && $pun_user['g_send_email'] == '1')
  272. $user_contacts[] = '<span class="email"><a href="mailto:'.$cur_post['poster_email'].'">'.$lang->t('Email').'</a></span>';
  273. }
  274. // Generation post action array (quote, edit, delete etc.)
  275. if (!$is_admmod)
  276. {
  277. if (!$pun_user['is_guest'])
  278. $post_actions[] = '<li class="postreport"><span><a href="misc.php?report='.$cur_post['id'].'">'.$lang->t('Report').'</a></span></li>';
  279. if ($cur_topic['closed'] == '0')
  280. {
  281. if ($cur_post['poster_id'] == $pun_user['id'])
  282. {
  283. if ((($start_from + $post_count) == 1 && $pun_user['g_delete_topics'] == '1') || (($start_from + $post_count) > 1 && $pun_user['g_delete_posts'] == '1'))
  284. $post_actions[] = '<li class="postdelete"><span><a href="delete.php?id='.$cur_post['id'].'">'.$lang->t('Delete').'</a></span></li>';
  285. if ($pun_user['g_edit_posts'] == '1')
  286. $post_actions[] = '<li class="postedit"><span><a href="edit.php?id='.$cur_post['id'].'">'.$lang->t('Edit').'</a></span></li>';
  287. }
  288. if (($cur_topic['post_replies'] == '' && $pun_user['g_post_replies'] == '1') || $cur_topic['post_replies'] == '1')
  289. $post_actions[] = '<li class="postquote"><span><a href="post.php?tid='.$id.'&amp;qid='.$cur_post['id'].'">'.$lang->t('Quote').'</a></span></li>';
  290. }
  291. }
  292. else
  293. {
  294. $post_actions[] = '<li class="postreport"><span><a href="misc.php?report='.$cur_post['id'].'">'.$lang->t('Report').'</a></span></li>';
  295. $post_actions[] = '<li class="postdelete"><span><a href="delete.php?id='.$cur_post['id'].'">'.$lang->t('Delete').'</a></span></li>';
  296. $post_actions[] = '<li class="postedit"><span><a href="edit.php?id='.$cur_post['id'].'">'.$lang->t('Edit').'</a></span></li>';
  297. $post_actions[] = '<li class="postquote"><span><a href="post.php?tid='.$id.'&amp;qid='.$cur_post['id'].'">'.$lang->t('Quote').'</a></span></li>';
  298. }
  299. // Perform the main parsing of the message (BBCode, smilies, censor words etc)
  300. $cur_post['message'] = parse_message($cur_post['message'], $cur_post['hide_smilies']);
  301. // Do signature parsing/caching
  302. if ($pun_config['o_signatures'] == '1' && $cur_post['signature'] != '' && $pun_user['show_sig'] != '0')
  303. {
  304. if (isset($signature_cache[$cur_post['poster_id']]))
  305. $signature = $signature_cache[$cur_post['poster_id']];
  306. else
  307. {
  308. $signature = parse_signature($cur_post['signature']);
  309. $signature_cache[$cur_post['poster_id']] = $signature;
  310. }
  311. }
  312. ?>
  313. <div id="p<?php echo $cur_post['id'] ?>" class="blockpost<?php echo ($post_count % 2 == 0) ? ' roweven' : ' rowodd' ?><?php if ($cur_post['id'] == $cur_topic['first_post_id']) echo ' firstpost'; ?><?php if ($post_count == 1) echo ' blockpost1'; ?>">
  314. <h2><span><span class="conr">#<?php echo ($start_from + $post_count) ?></span> <a href="viewtopic.php?pid=<?php echo $cur_post['id'].'#p'.$cur_post['id'] ?>"><?php echo format_time($cur_post['posted']) ?></a></span></h2>
  315. <div class="box">
  316. <div class="inbox">
  317. <div class="postbody">
  318. <div class="postleft">
  319. <dl>
  320. <dt><strong><?php echo $username ?></strong></dt>
  321. <dd class="usertitle"><strong><?php echo $user_title ?></strong></dd>
  322. <?php if ($user_avatar != '') echo "\t\t\t\t\t\t".'<dd class="postavatar">'.$user_avatar.'</dd>'."\n"; ?>
  323. <?php if (count($user_info)) echo "\t\t\t\t\t\t".implode("\n\t\t\t\t\t\t", $user_info)."\n"; ?>
  324. <?php if (count($user_contacts)) echo "\t\t\t\t\t\t".'<dd class="usercontacts">'.implode(' ', $user_contacts).'</dd>'."\n"; ?>
  325. </dl>
  326. </div>
  327. <div class="postright">
  328. <h3><?php if ($cur_post['id'] != $cur_topic['first_post_id']) echo $lang->t('Re').' '; ?><?php echo pun_htmlspecialchars($cur_topic['subject']) ?></h3>
  329. <div class="postmsg">
  330. <?php echo $cur_post['message']."\n" ?>
  331. <?php if ($cur_post['edited'] != '') echo "\t\t\t\t\t\t".'<p class="postedit"><em>'.$lang->t('Last edit').' '.pun_htmlspecialchars($cur_post['edited_by']).' ('.format_time($cur_post['edited']).')</em></p>'."\n"; ?>
  332. </div>
  333. <?php if ($signature != '') echo "\t\t\t\t\t".'<div class="postsignature postmsg"><hr />'.$signature.'</div>'."\n"; ?>
  334. </div>
  335. </div>
  336. </div>
  337. <div class="inbox">
  338. <div class="postfoot clearb">
  339. <div class="postfootleft"><?php if ($cur_post['poster_id'] > 1) echo '<p>'.$is_online.'</p>'; ?></div>
  340. <?php if (count($post_actions)) echo "\t\t\t\t".'<div class="postfootright">'."\n\t\t\t\t\t".'<ul>'."\n\t\t\t\t\t\t".implode("\n\t\t\t\t\t\t", $post_actions)."\n\t\t\t\t\t".'</ul>'."\n\t\t\t\t".'</div>'."\n" ?>
  341. </div>
  342. </div>
  343. </div>
  344. </div>
  345. <?php
  346. }
  347. unset ($result, $query, $params);
  348. ?>
  349. <div class="postlinksb">
  350. <div class="inbox crumbsplus">
  351. <div class="pagepost">
  352. <p class="pagelink conl"><?php echo $paging_links ?></p>
  353. <?php echo $post_link ?>
  354. </div>
  355. <ul class="crumbs">
  356. <li><a href="index.php"><?php echo $lang->t('Index') ?></a></li>
  357. <li><span>»&#160;</span><a href="viewforum.php?id=<?php echo $cur_topic['forum_id'] ?>"><?php echo pun_htmlspecialchars($cur_topic['forum_name']) ?></a></li>
  358. <li><span>»&#160;</span><a href="viewtopic.php?id=<?php echo $id ?>"><strong><?php echo pun_htmlspecialchars($cur_topic['subject']) ?></strong></a></li>
  359. </ul>
  360. <?php echo $subscraction ?>
  361. <div class="clearer"></div>
  362. </div>
  363. </div>
  364. <?php
  365. // Display quick post if enabled
  366. if ($quickpost)
  367. {
  368. $cur_index = 1;
  369. ?>
  370. <div id="quickpost" class="blockform">
  371. <h2><span><?php echo $lang->t('Quick post') ?></span></h2>
  372. <div class="box">
  373. <form id="quickpostform" method="post" action="post.php?tid=<?php echo $id ?>" onsubmit="this.submit.disabled=true;if(process_form(this)){return true;}else{this.submit.disabled=false;return false;}">
  374. <div class="inform">
  375. <fieldset>
  376. <legend><?php echo $lang->t('Write message legend') ?></legend>
  377. <div class="infldset txtarea">
  378. <input type="hidden" name="form_sent" value="1" />
  379. <?php if ($pun_config['o_topic_subscriptions'] == '1' && ($pun_user['auto_notify'] == '1' || $cur_topic['is_subscribed'])): ?> <input type="hidden" name="subscribe" value="1" />
  380. <?php endif; ?>
  381. <?php
  382. if ($pun_user['is_guest'])
  383. {
  384. $email_label = ($pun_config['p_force_guest_email'] == '1') ? '<strong>'.$lang->t('Email').' <span>'.$lang->t('Required').'</span></strong>' : $lang->t('Email');
  385. $email_form_name = ($pun_config['p_force_guest_email'] == '1') ? 'req_email' : 'email';
  386. ?>
  387. <label class="conl required"><strong><?php echo $lang->t('Guest name') ?> <span><?php echo $lang->t('Required') ?></span></strong><br /><input type="text" name="req_username" value="<?php if (isset($_POST['req_username'])) echo pun_htmlspecialchars($username); ?>" size="25" maxlength="25" tabindex="<?php echo $cur_index++ ?>" /><br /></label>
  388. <label class="conl<?php echo ($pun_config['p_force_guest_email'] == '1') ? ' required' : '' ?>"><?php echo $email_label ?><br /><input type="text" name="<?php echo $email_form_name ?>" value="<?php if (isset($_POST[$email_form_name])) echo pun_htmlspecialchars($email); ?>" size="50" maxlength="80" tabindex="<?php echo $cur_index++ ?>" /><br /></label>
  389. <div class="clearer"></div>
  390. <?php
  391. echo "\t\t\t\t\t\t".'<label class="required"><strong>'.$lang->t('Message').' <span>'.$lang->t('Required').'</span></strong><br />';
  392. }
  393. else
  394. echo "\t\t\t\t\t\t".'<label>';
  395. ?>
  396. <textarea name="req_message" rows="7" cols="75" tabindex="<?php echo $cur_index++ ?>"></textarea></label>
  397. <ul class="bblinks">
  398. <li><span><a href="help.php#bbcode" onclick="window.open(this.href); return false;"><?php echo $lang->t('BBCode') ?></a> <?php echo ($pun_config['p_message_bbcode'] == '1') ? $lang->t('on') : $lang->t('off'); ?></span></li>
  399. <li><span><a href="help.php#img" onclick="window.open(this.href); return false;"><?php echo $lang->t('img tag') ?></a> <?php echo ($pun_config['p_message_bbcode'] == '1' && $pun_config['p_message_img_tag'] == '1') ? $lang->t('on') : $lang->t('off'); ?></span></li>
  400. <li><span><a href="help.php#smilies" onclick="window.open(this.href); return false;"><?php echo $lang->t('Smilies') ?></a> <?php echo ($pun_config['o_smilies'] == '1') ? $lang->t('on') : $lang->t('off'); ?></span></li>
  401. </ul>
  402. </div>
  403. </fieldset>
  404. </div>
  405. <p class="buttons"><input type="submit" name="submit" tabindex="<?php echo $cur_index++ ?>" value="<?php echo $lang->t('Submit') ?>" accesskey="s" /> <input type="submit" name="preview" value="<?php echo $lang->t('Preview') ?>" tabindex="<?php echo $cur_index++ ?>" accesskey="p" /></p>
  406. </form>
  407. </div>
  408. </div>
  409. <?php
  410. }
  411. // Increment "num_views" for topic
  412. if ($pun_config['o_topic_views'] == '1')
  413. {
  414. $query = $db->update(array('num_views' => 'num_views + 1'), 'topics');
  415. $query->where = 'id = :tid';
  416. $params = array(':tid' => $id);
  417. $query->run($params);
  418. unset ($query, $params);
  419. }
  420. $forum_id = $cur_topic['forum_id'];
  421. $footer_style = 'viewtopic';
  422. require PUN_ROOT.'footer.php';