PageRenderTime 154ms CodeModel.GetById 5ms RepoModel.GetById 0ms app.codeStats 1ms

/source/include/post/post_newreply.php

https://github.com/kuaileshike/upload
PHP | 770 lines | 695 code | 69 blank | 6 comment | 299 complexity | 0d67a077c7d250750f13590cdf2ea309 MD5 | raw file
  1. <?php
  2. /**
  3. * [Discuz!] (C)2001-2099 Comsenz Inc.
  4. * This is NOT a freeware, use is subject to license terms
  5. *
  6. * $Id: post_newreply.php 30842 2012-06-25 09:23:12Z liulanbo $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. require_once libfile('function/forumlist');
  12. $isfirstpost = 0;
  13. $showthreadsorts = 0;
  14. $quotemessage = '';
  15. if($special == 5) {
  16. $debate = array_merge($thread, daddslashes(C::t('forum_debate')->fetch($_G['tid'])));
  17. $firststand = C::t('forum_debatepost')->get_firststand($_G['tid'], $_G['uid']);
  18. $stand = $firststand ? $firststand : intval($_GET['stand']);
  19. if($debate['endtime'] && $debate['endtime'] < TIMESTAMP) {
  20. showmessage('debate_end');
  21. }
  22. }
  23. if(!$_G['uid'] && !((!$_G['forum']['replyperm'] && $_G['group']['allowreply']) || ($_G['forum']['replyperm'] && forumperm($_G['forum']['replyperm'])))) {
  24. showmessage('replyperm_login_nopermission', NULL, array(), array('login' => 1));
  25. } elseif(empty($_G['forum']['allowreply'])) {
  26. if(!$_G['forum']['replyperm'] && !$_G['group']['allowreply']) {
  27. showmessage('replyperm_none_nopermission', NULL, array(), array('login' => 1));
  28. } elseif($_G['forum']['replyperm'] && !forumperm($_G['forum']['replyperm'])) {
  29. showmessagenoperm('replyperm', $_G['forum']['fid']);
  30. }
  31. } elseif($_G['forum']['allowreply'] == -1) {
  32. showmessage('post_forum_newreply_nopermission', NULL);
  33. }
  34. if(!$_G['uid'] && ($_G['setting']['need_avatar'] || $_G['setting']['need_email'] || $_G['setting']['need_friendnum'])) {
  35. showmessage('replyperm_login_nopermission', NULL, array(), array('login' => 1));
  36. }
  37. if(empty($thread)) {
  38. showmessage('thread_nonexistence');
  39. } elseif($thread['price'] > 0 && $thread['special'] == 0 && !$_G['uid']) {
  40. showmessage('group_nopermission', NULL, array('grouptitle' => $_G['group']['grouptitle']), array('login' => 1));
  41. }
  42. checklowerlimit('reply', 0, 1, $_G['forum']['fid']);
  43. if($_G['setting']['commentnumber'] && !empty($_GET['comment'])) {
  44. if(!submitcheck('commentsubmit', 0, $seccodecheck, $secqaacheck)) {
  45. showmessage('submitcheck_error', NULL);
  46. }
  47. $post = C::t('forum_post')->fetch('tid:'.$_G['tid'], $_GET['pid']);
  48. if(!$post) {
  49. showmessage('post_nonexistence', NULL);
  50. }
  51. if($thread['closed'] && !$_G['forum']['ismoderator'] && !$thread['isgroup']) {
  52. showmessage('post_thread_closed');
  53. } elseif(!$thread['isgroup'] && $post_autoclose = checkautoclose($thread)) {
  54. showmessage($post_autoclose, '', array('autoclose' => $_G['forum']['autoclose']));
  55. } elseif(checkflood()) {
  56. showmessage('post_flood_ctrl', '', array('floodctrl' => $_G['setting']['floodctrl']));
  57. } elseif(checkmaxperhour('pid')) {
  58. showmessage('post_flood_ctrl_posts_per_hour', '', array('posts_per_hour' => $_G['group']['maxpostsperhour']));
  59. }
  60. $commentscore = '';
  61. if(!empty($_GET['commentitem']) && !empty($_G['uid']) && $post['authorid'] != $_G['uid']) {
  62. foreach($_GET['commentitem'] as $itemk => $itemv) {
  63. if($itemv !== '') {
  64. $commentscore .= strip_tags(trim($itemk)).': <i>'.intval($itemv).'</i> ';
  65. }
  66. }
  67. }
  68. $comment = cutstr(($commentscore ? $commentscore.'<br />' : '').censor(trim(dhtmlspecialchars($_GET['message'])), '***'), 200, ' ');
  69. if(!$comment) {
  70. showmessage('post_sm_isnull');
  71. }
  72. C::t('forum_postcomment')->insert(array(
  73. 'tid' => $post['tid'],
  74. 'pid' => $post['pid'],
  75. 'author' => $_G['username'],
  76. 'authorid' => $_G['uid'],
  77. 'dateline' => TIMESTAMP,
  78. 'comment' => $comment,
  79. 'score' => $commentscore ? 1 : 0,
  80. 'useip' => $_G['clientip'],
  81. ));
  82. C::t('forum_post')->update('tid:'.$_G['tid'], $_GET['pid'], array('comment' => 1));
  83. !empty($_G['uid']) && updatepostcredits('+', $_G['uid'], 'reply', $_G['fid']);
  84. if(!empty($_G['uid']) && $_G['uid'] != $post['authorid']) {
  85. notification_add($post['authorid'], 'pcomment', 'comment_add', array(
  86. 'tid' => $_G['tid'],
  87. 'pid' => $_GET['pid'],
  88. 'subject' => $thread['subject'],
  89. 'from_id' => $_G['tid'],
  90. 'from_idtype' => 'pcomment',
  91. 'commentmsg' => cutstr(str_replace(array('[b]', '[/b]', '[/color]'), '', preg_replace("/\[color=([#\w]+?)\]/i", "", $comment)), 200)
  92. ));
  93. }
  94. update_threadpartake($post['tid']);
  95. $pcid = C::t('forum_postcomment')->fetch_standpoint_by_pid($_GET['pid']);
  96. $pcid = $pcid['id'];
  97. if(!empty($_G['uid']) && $_GET['commentitem']) {
  98. $totalcomment = array();
  99. foreach(C::t('forum_postcomment')->fetch_all_by_pid_score($_GET['pid'], 1) as $comment) {
  100. $comment['comment'] = addslashes($comment['comment']);
  101. if(strexists($comment['comment'], '<br />')) {
  102. if(preg_match_all("/([^:]+?):\s<i>(\d+)<\/i>/", $comment['comment'], $a)) {
  103. foreach($a[1] as $k => $itemk) {
  104. $totalcomment[trim($itemk)][] = $a[2][$k];
  105. }
  106. }
  107. }
  108. }
  109. $totalv = '';
  110. foreach($totalcomment as $itemk => $itemv) {
  111. $totalv .= strip_tags(trim($itemk)).': <i>'.(floatval(sprintf('%1.1f', array_sum($itemv) / count($itemv)))).'</i> ';
  112. }
  113. if($pcid) {
  114. C::t('forum_postcomment')->update($pcid, array('comment' => $totalv, 'dateline' => TIMESTAMP + 1));
  115. } else {
  116. C::t('forum_postcomment')->insert(array(
  117. 'tid' => $post['tid'],
  118. 'pid' => $post['pid'],
  119. 'author' => '',
  120. 'authorid' => '-1',
  121. 'dateline' => TIMESTAMP + 1,
  122. 'comment' => $totalv
  123. ));
  124. }
  125. }
  126. C::t('forum_postcache')->delete($post['pid']);
  127. showmessage('comment_add_succeed', "forum.php?mod=viewthread&tid=$post[tid]&pid=$post[pid]&page=$_GET[page]&extra=$extra#pid$post[pid]", array('tid' => $post['tid'], 'pid' => $post['pid']));
  128. }
  129. if($special == 127) {
  130. $postinfo = C::t('forum_post')->fetch_threadpost_by_tid_invisible($_G['tid']);
  131. $sppos = strrpos($postinfo['message'], chr(0).chr(0).chr(0));
  132. $specialextra = substr($postinfo['message'], $sppos + 3);
  133. }
  134. if(getstatus($thread['status'], 3)) {
  135. $rushinfo = C::t('forum_threadrush')->fetch($_G['tid']);
  136. if($rushinfo['creditlimit'] != -996) {
  137. $checkcreditsvalue = $_G['setting']['creditstransextra'][11] ? getuserprofile('extcredits'.$_G['setting']['creditstransextra'][11]) : $_G['member']['credits'];
  138. if($checkcreditsvalue < $rushinfo['creditlimit']) {
  139. $creditlimit_title = $_G['setting']['creditstransextra'][11] ? $_G['setting']['extcredits'][$_G['setting']['creditstransextra'][11]]['title'] : lang('forum/misc', 'credit_total');
  140. showmessage('post_rushreply_creditlimit', '', array('creditlimit_title' => $creditlimit_title, 'creditlimit' => $rushinfo['creditlimit']));
  141. }
  142. }
  143. }
  144. if(!submitcheck('replysubmit', 0, $seccodecheck, $secqaacheck)) {
  145. if($thread['special'] == 2 && ((!isset($_GET['addtrade']) || $thread['authorid'] != $_G['uid']) && !$tradenum = C::t('forum_trade')->fetch_counter_thread_goods($_G['tid']))) {
  146. showmessage('trade_newreply_nopermission', NULL);
  147. }
  148. $language = lang('forum/misc');
  149. $noticeauthor = $noticetrimstr = '';
  150. if(isset($_GET['repquote']) && $_GET['repquote'] = intval($_GET['repquote'])) {
  151. $thaquote = C::t('forum_post')->fetch('tid:'.$_G['tid'], $_GET['repquote']);
  152. if(!($thaquote && ($thaquote['invisible'] == 0 || $thaquote['authorid'] == $_G['uid'] && $thaquote['invisible'] == -2))) {
  153. $thaquote = array();
  154. }
  155. if($thaquote['tid'] != $_G['tid']) {
  156. showmessage('reply_quotepost_error', NULL);
  157. }
  158. if(getstatus($thread['status'], 2) && $thaquote['authorid'] != $_G['uid'] && $_G['uid'] != $thread['authorid'] && $thaquote['first'] != 1 && !$_G['forum']['ismoderator']) {
  159. showmessage('reply_quotepost_error', NULL);
  160. }
  161. if(!($thread['price'] && !$thread['special'] && $thaquote['first'])) {
  162. $quotefid = $thaquote['fid'];
  163. $message = $thaquote['message'];
  164. if($_G['setting']['bannedmessages'] && $thaquote['authorid']) {
  165. $author = getuserbyuid($thaquote['authorid']);
  166. if(!$author['groupid'] || $author['groupid'] == 4 || $author['groupid'] == 5) {
  167. $message = $language['post_banned'];
  168. } elseif($thaquote['status'] & 1) {
  169. $message = $language['post_single_banned'];
  170. }
  171. }
  172. $time = dgmdate($thaquote['dateline']);
  173. $message = messagecutstr($message, 100);
  174. $message = implode("\n", array_slice(explode("\n", $message), 0, 3));
  175. $thaquote['useip'] = substr($thaquote['useip'], 0, strrpos($thaquote['useip'], '.')).'.x';
  176. if($thaquote['author'] && $thaquote['anonymous']) {
  177. $thaquote['author'] = lang('forum/misc', 'anonymoususer');
  178. } elseif(!$thaquote['author']) {
  179. $thaquote['author'] = lang('forum/misc', 'guestuser').' '.$thaquote['useip'];
  180. } else {
  181. $thaquote['author'] = $thaquote['author'];
  182. }
  183. $post_reply_quote = lang('forum/misc', 'post_reply_quote', array('author' => $thaquote['author'], 'time' => $time));
  184. $noticeauthormsg = dhtmlspecialchars($message);
  185. if(!defined('IN_MOBILE')) {
  186. $message = "[quote][size=2][color=#999999]{$post_reply_quote}[/color] [url=forum.php?mod=redirect&goto=findpost&pid=$_GET[repquote]&ptid={$_G['tid']}][img]static/image/common/back.gif[/img][/url][/size]\n{$message}[/quote]";
  187. } else {
  188. $message = "[quote][color=#999999]{$post_reply_quote}[/color]\n[color=#999999]{$message}[/color][/quote]";
  189. }
  190. $quotemessage = discuzcode($message, 0, 0);
  191. $noticeauthor = dhtmlspecialchars(authcode('q|'.$thaquote['authorid'], 'ENCODE'));
  192. $noticetrimstr = dhtmlspecialchars($message);
  193. $message = '';
  194. }
  195. $reppid = $_GET['repquote'];
  196. } elseif(isset($_GET['reppost']) && $_GET['reppost'] = intval($_GET['reppost'])) {
  197. $thapost = C::t('forum_post')->fetch('tid:'.$_G['tid'], $_GET['reppost']);
  198. if(!($thapost && ($thapost['invisible'] == 0 || $thapost['authorid'] == $_G['uid'] && $thapost['invisible'] == -2))) {
  199. $thapost = array();
  200. }
  201. if($thapost['tid'] != $_G['tid']) {
  202. showmessage('targetpost_donotbelongto_thisthread', NULL);
  203. }
  204. $thapost['useip'] = substr($thapost['useip'], 0, strrpos($thapost['useip'], '.')).'.x';
  205. if($thapost['author'] && $thapost['anonymous']) {
  206. $thapost['author'] = '[color=Olive]'.lang('forum/misc', 'anonymoususer').'[/color]';
  207. } elseif(!$thapost['author']) {
  208. $thapost['author'] = '[color=Olive]'.lang('forum/misc', 'guestuser').'[/color] '.$thapost['useip'];
  209. } else {
  210. $thapost['author'] = '[color=Olive]'.$thapost['author'].'[/color]';
  211. }
  212. $quotemessage = discuzcode($message, 0, 0);
  213. $noticeauthormsg = dhtmlspecialchars(messagecutstr($thapost['message'], 100));
  214. $noticeauthor = dhtmlspecialchars(authcode('r|'.$thapost['authorid'], 'ENCODE'));
  215. $noticetrimstr = dhtmlspecialchars($message);
  216. $message = '';
  217. $reppid = $_GET['reppost'];
  218. }
  219. if(isset($_GET['addtrade']) && $thread['special'] == 2 && $_G['group']['allowposttrade'] && $thread['authorid'] == $_G['uid']) {
  220. $expiration_7days = date('Y-m-d', TIMESTAMP + 86400 * 7);
  221. $expiration_14days = date('Y-m-d', TIMESTAMP + 86400 * 14);
  222. $trade['expiration'] = $expiration_month = date('Y-m-d', mktime(0, 0, 0, date('m')+1, date('d'), date('Y')));
  223. $expiration_3months = date('Y-m-d', mktime(0, 0, 0, date('m')+3, date('d'), date('Y')));
  224. $expiration_halfyear = date('Y-m-d', mktime(0, 0, 0, date('m')+6, date('d'), date('Y')));
  225. $expiration_year = date('Y-m-d', mktime(0, 0, 0, date('m'), date('d'), date('Y')+1));
  226. }
  227. if($thread['replies'] <= $_G['ppp']) {
  228. $postlist = array();
  229. if($thread['price'] > 0 && $thread['special'] == 0) {
  230. $postlist = C::t('forum_post')->fetch_all_by_tid('tid:'.$_G['tid'], $_G['tid'], true, 'DESC', 0, 0, 0, 0);
  231. } else {
  232. $postlist = C::t('forum_post')->fetch_all_by_tid('tid:'.$_G['tid'], $_G['tid'], true, 'DESC', 0, 0, null, 0);
  233. }
  234. if($_G['setting']['bannedmessages']) {
  235. $uids = array();
  236. foreach($postlist as $post) {
  237. $uids[] = $post['authorid'];
  238. }
  239. $users = C::t('common_member')->fetch_all($uids);
  240. }
  241. foreach($postlist as $k => $post) {
  242. $post['dateline'] = dgmdate($post['dateline'], 'u');
  243. if($_G['setting']['bannedmessages'] && ($post['authorid'] && (!$post['groupid'] || $post['groupid'] == 4 || $post['groupid'] == 5))) {
  244. $post['message'] = $language['post_banned'];
  245. } elseif($post['status'] & 1) {
  246. $post['message'] = $language['post_single_banned'];
  247. } else {
  248. $post['message'] = preg_replace("/\[hide=?\d*\](.*?)\[\/hide\]/is", "[b]$language[post_hidden][/b]", $post['message']);
  249. $post['message'] = discuzcode($post['message'], $post['smileyoff'], $post['bbcodeoff'], $post['htmlon'] & 1, $_G['forum']['allowsmilies'], $_G['forum']['allowbbcode'], $_G['forum']['allowimgcode'], $_G['forum']['allowhtml'], $_G['forum']['jammer']);
  250. }
  251. if($_G['setting']['bannedmessages']) {
  252. $post['groupid'] = $users[$post['authorid']]['groupid'];
  253. }
  254. $postlist[$k] = $post;
  255. }
  256. }
  257. unset($uids, $users);
  258. if($_G['group']['allowpostattach'] || $_G['group']['allowpostimage']) {
  259. $attachlist = getattach(0);
  260. $attachs = $attachlist['attachs'];
  261. $imgattachs = $attachlist['imgattachs'];
  262. unset($attachlist);
  263. }
  264. getgpc('infloat') ? include template('forum/post_infloat') : include template('forum/post');
  265. } else {
  266. if($thread['closed'] && !$_G['forum']['ismoderator'] && !$thread['isgroup']) {
  267. showmessage('post_thread_closed');
  268. } elseif(!$thread['isgroup'] && $post_autoclose = checkautoclose($thread)) {
  269. showmessage($post_autoclose, '', array('autoclose' => $_G['forum']['autoclose']));
  270. } if(trim($subject) == '' && trim($message) == '' && $thread['special'] != 2) {
  271. showmessage('post_sm_isnull');
  272. } elseif($post_invalid = checkpost($subject, $message, $special == 2 && $_G['group']['allowposttrade'])) {
  273. showmessage($post_invalid, '', array('minpostsize' => $_G['setting']['minpostsize'], 'maxpostsize' => $_G['setting']['maxpostsize']));
  274. } elseif(checkflood()) {
  275. showmessage('post_flood_ctrl', '', array('floodctrl' => $_G['setting']['floodctrl']));
  276. } elseif(checkmaxperhour('pid')) {
  277. showmessage('post_flood_ctrl_posts_per_hour', '', array('posts_per_hour' => $_G['group']['maxpostsperhour']));
  278. }
  279. if(!empty($_GET['trade']) && $thread['special'] == 2 && $_G['group']['allowposttrade']) {
  280. $item_price = floatval($_GET['item_price']);
  281. $item_credit = intval($_GET['item_credit']);
  282. if(!trim($_GET['item_name'])) {
  283. showmessage('trade_please_name');
  284. } elseif($_G['group']['maxtradeprice'] && $item_price > 0 && ($_G['group']['mintradeprice'] > $item_price || $_G['group']['maxtradeprice'] < $item_price)) {
  285. showmessage('trade_price_between', '', array('mintradeprice' => $_G['group']['mintradeprice'], 'maxtradeprice' => $_G['group']['maxtradeprice']));
  286. } elseif($_G['group']['maxtradeprice'] && $item_credit > 0 && ($_G['group']['mintradeprice'] > $item_credit || $_G['group']['maxtradeprice'] < $item_credit)) {
  287. showmessage('trade_credit_between', '', array('mintradeprice' => $_G['group']['mintradeprice'], 'maxtradeprice' => $_G['group']['maxtradeprice']));
  288. } elseif(!$_G['group']['maxtradeprice'] && $item_price > 0 && $_G['group']['mintradeprice'] > $item_price) {
  289. showmessage('trade_price_more_than', '', array('mintradeprice' => $_G['group']['mintradeprice']));
  290. } elseif(!$_G['group']['maxtradeprice'] && $item_credit > 0 && $_G['group']['mintradeprice'] > $item_credit) {
  291. showmessage('trade_credit_more_than', '', array('mintradeprice' => $_G['group']['mintradeprice']));
  292. } elseif($item_price <= 0 && $item_credit <= 0) {
  293. showmessage('trade_pricecredit_need');
  294. } elseif($_GET['item_number'] < 1) {
  295. showmessage('tread_please_number');
  296. }
  297. }
  298. $attentionon = empty($_GET['attention_add']) ? 0 : 1;
  299. $attentionoff = empty($attention_remove) ? 0 : 1;
  300. $heatthreadset = update_threadpartake($_G['tid'], true);
  301. if($_G['group']['allowat']) {
  302. $atlist = $atlist_tmp = $ateduids = array();
  303. preg_match_all("/@([^\r\n]*?)\s/i", $message.' ', $atlist_tmp);
  304. $atlist_tmp = array_slice(array_unique($atlist_tmp[1]), 0, $_G['group']['allowat']);
  305. $atnum = $maxselect = 0;
  306. foreach(C::t('home_notification')->fetch_all_by_authorid_fromid($_G['uid'], $_G['tid'], 'at') as $row) {
  307. $atnum ++;
  308. $ateduids[$row[uid]] = $row['uid'];
  309. }
  310. $maxselect = $_G['group']['allowat'] - $atnum;
  311. if($maxselect > 0 && !empty($atlist_tmp)) {
  312. if(empty($_G['setting']['at_anyone'])) {
  313. foreach(C::t('home_follow')->fetch_all_by_uid_fusername($_G['uid'], $atlist_tmp) as $row) {
  314. if(!in_array($row['followuid'], $ateduids)) {
  315. $atlist[$row[followuid]] = $row['fusername'];
  316. }
  317. if(count($atlist) == $maxselect) {
  318. break;
  319. }
  320. }
  321. if(count($atlist) < $maxselect) {
  322. $query = C::t('home_friend')->fetch_all_by_uid_username($_G['uid'], $atlist_tmp);
  323. foreach($query as $row) {
  324. if(!in_array($row['followuid'], $ateduids)) {
  325. $atlist[$row[fuid]] = $row['fusername'];
  326. }
  327. }
  328. }
  329. } else {
  330. foreach(C::t('common_member')->fetch_all_by_username($atlist_tmp) as $row) {
  331. if(!in_array($row['uid'], $ateduids)) {
  332. $atlist[$row[uid]] = $row['username'];
  333. }
  334. if(count($atlist) == $maxselect) {
  335. break;
  336. }
  337. }
  338. }
  339. }
  340. if($atlist) {
  341. foreach($atlist as $atuid => $atusername) {
  342. $atsearch[] = "/@$atusername /i";
  343. $atreplace[] = "[url=home.php?mod=space&uid=$atuid]@{$atusername}[/url] ";
  344. }
  345. $message = preg_replace($atsearch, $atreplace, $message.' ', 1);
  346. }
  347. }
  348. $bbcodeoff = checkbbcodes($message, !empty($_GET['bbcodeoff']));
  349. $smileyoff = checksmilies($message, !empty($_GET['smileyoff']));
  350. $parseurloff = !empty($_GET['parseurloff']);
  351. $htmlon = $_G['group']['allowhtml'] && !empty($_GET['htmlon']) ? 1 : 0;
  352. $usesig = !empty($_GET['usesig']) && $_G['group']['maxsigsize'] ? 1 : 0;
  353. $isanonymous = $_G['group']['allowanonymous'] && !empty($_GET['isanonymous'])? 1 : 0;
  354. $author = empty($isanonymous) ? $_G['username'] : '';
  355. if($thread['displayorder'] == -4) {
  356. $modnewreplies = 0;
  357. }
  358. $pinvisible = $modnewreplies ? -2 : ($thread['displayorder'] == -4 ? -3 : 0);
  359. $message = preg_replace('/\[attachimg\](\d+)\[\/attachimg\]/is', '[attach]\1[/attach]', $message);
  360. $postcomment = in_array(2, $_G['setting']['allowpostcomment']) && $_G['group']['allowcommentreply'] && !$pinvisible && !empty($_GET['reppid']) && ($nauthorid != $_G['uid'] || $_G['setting']['commentpostself']) ? messagecutstr($message, 200, ' ') : '';
  361. if(!empty($_GET['noticetrimstr'])) {
  362. $message = $_GET['noticetrimstr']."\n\n".$message;
  363. $bbcodeoff = false;
  364. }
  365. $pid = insertpost(array(
  366. 'fid' => $_G['fid'],
  367. 'tid' => $_G['tid'],
  368. 'first' => '0',
  369. 'author' => $_G['username'],
  370. 'authorid' => $_G['uid'],
  371. 'subject' => $subject,
  372. 'dateline' => $_G['timestamp'],
  373. 'message' => $message,
  374. 'useip' => $_G['clientip'],
  375. 'invisible' => $pinvisible,
  376. 'anonymous' => $isanonymous,
  377. 'usesig' => $usesig,
  378. 'htmlon' => $htmlon,
  379. 'bbcodeoff' => $bbcodeoff,
  380. 'smileyoff' => $smileyoff,
  381. 'parseurloff' => $parseurloff,
  382. 'attachment' => '0',
  383. 'status' => (defined('IN_MOBILE') ? 8 : 0),
  384. ));
  385. if($_G['group']['allowat'] && $atlist) {
  386. foreach($atlist as $atuid => $atusername) {
  387. notification_add($atuid, 'at', 'at_message', array('from_id' => $_G['tid'], 'from_idtype' => 'at', 'buyerid' => $_G['uid'], 'buyer' => $_G['username'], 'tid' => $_G['tid'], 'subject' => $thread['subject'], 'pid' => $pid, 'message' => messagecutstr($message, 150)));
  388. }
  389. set_atlist_cookie(array_keys($atlist));
  390. }
  391. $updatethreaddata = $heatthreadset ? $heatthreadset : array();
  392. $postionid = C::t('forum_post')->fetch_maxposition_by_tid($thread['posttableid'], $_G['tid']);
  393. $updatethreaddata[] = DB::field('maxposition', $postionid);
  394. if(getstatus($thread['status'], 3) && $postionid) {
  395. $rushstopfloor = $rushinfo['stopfloor'];
  396. if($rushstopfloor > 0 && $thread['closed'] == 0 && $postionid >= $rushstopfloor) {
  397. $updatethreaddata[] = 'closed=1';
  398. }
  399. }
  400. useractionlog($_G['uid'], 'pid');
  401. $nauthorid = 0;
  402. if(!empty($_GET['noticeauthor']) && !$isanonymous && !$modnewreplies) {
  403. list($ac, $nauthorid) = explode('|', authcode($_GET['noticeauthor'], 'DECODE'));
  404. if($nauthorid != $_G['uid']) {
  405. if($ac == 'q') {
  406. notification_add($nauthorid, 'post', 'reppost_noticeauthor', array(
  407. 'tid' => $thread['tid'],
  408. 'subject' => $thread['subject'],
  409. 'fid' => $_G['fid'],
  410. 'pid' => $pid,
  411. 'from_id' => $pid,
  412. 'from_idtype' => 'quote',
  413. ));
  414. } elseif($ac == 'r') {
  415. notification_add($nauthorid, 'post', 'reppost_noticeauthor', array(
  416. 'tid' => $thread['tid'],
  417. 'subject' => $thread['subject'],
  418. 'fid' => $_G['fid'],
  419. 'pid' => $pid,
  420. 'from_id' => $thread['tid'],
  421. 'from_idtype' => 'post',
  422. ));
  423. }
  424. }
  425. if($postcomment) {
  426. $rpid = intval($_GET['reppid']);
  427. if($rpost = C::t('forum_post')->fetch('tid:'.$thread['tid'], $rpid)) {
  428. if(!$rpost['first']) {
  429. C::t('forum_postcomment')->insert(array(
  430. 'tid' => $thread['tid'],
  431. 'pid' => $rpid,
  432. 'rpid' => $pid,
  433. 'author' => $_G['username'],
  434. 'authorid' => $_G['uid'],
  435. 'dateline' => TIMESTAMP,
  436. 'comment' => $postcomment,
  437. 'score' => 0,
  438. 'useip' => $_G['clientip'],
  439. ));
  440. C::t('forum_post')->update('tid:'.$thread['tid'], $rpid, array('comment' => 1));
  441. C::t('forum_postcache')->delete($rpid);
  442. }
  443. }
  444. unset($postcomment);
  445. }
  446. }
  447. if($thread['authorid'] != $_G['uid'] && getstatus($thread['status'], 6) && empty($_GET['noticeauthor']) && !$isanonymous && !$modnewreplies) {
  448. $thapost = C::t('forum_post')->fetch_threadpost_by_tid_invisible($_G['tid'], 0);
  449. notification_add($thapost['authorid'], 'post', 'reppost_noticeauthor', array(
  450. 'tid' => $thread['tid'],
  451. 'subject' => $thread['subject'],
  452. 'fid' => $_G['fid'],
  453. 'pid' => $pid,
  454. 'from_id' => $thread['tid'],
  455. 'from_idtype' => 'post',
  456. ));
  457. }
  458. $feedid = 0;
  459. if(helper_access::check_module('follow') && !empty($_GET['adddynamic']) && !$isanonymous) {
  460. require_once libfile('function/discuzcode');
  461. require_once libfile('function/followcode');
  462. $feedcontent = C::t('forum_threadpreview')->count_by_tid($thread['tid']);
  463. $firstpost = C::t('forum_post')->fetch_threadpost_by_tid_invisible($thread['tid']);
  464. if(empty($feedcontent)) {
  465. $feedcontent = array(
  466. 'tid' => $thread['tid'],
  467. 'content' => followcode($firstpost['message'], $thread['tid'], $pid, 1000),
  468. );
  469. C::t('forum_threadpreview')->insert($feedcontent);
  470. C::t('forum_thread')->update_status_by_tid($thread['tid'], '512');
  471. } else {
  472. C::t('forum_threadpreview')->update_relay_by_tid($thread['tid'], 1);
  473. }
  474. $notemsg = cutstr($message, 140);
  475. $followfeed = array(
  476. 'uid' => $_G['uid'],
  477. 'username' => $_G['username'],
  478. 'tid' => $thread['tid'],
  479. 'note' => followcode($notemsg, $thread['tid'], $pid, 0, false),
  480. 'dateline' => TIMESTAMP
  481. );
  482. $feedid = C::t('home_follow_feed')->insert($followfeed, true);
  483. C::t('common_member_count')->increase($_G['uid'], array('feeds'=>1));
  484. }
  485. if($thread['replycredit'] > 0 && !$modnewreplies && $thread['authorid'] != $_G['uid'] && $_G['uid']) {
  486. $replycredit_rule = C::t('forum_replycredit')->fetch($_G['tid']);
  487. if(!empty($replycredit_rule['times'])) {
  488. $have_replycredit = C::t('common_credit_log')->count_by_uid_operation_relatedid($_G['uid'], 'RCA', $_G['tid']);
  489. if($replycredit_rule['membertimes'] - $have_replycredit > 0 && $thread['replycredit'] - $replycredit_rule['extcredits'] >= 0) {
  490. $replycredit_rule['extcreditstype'] = $replycredit_rule['extcreditstype'] ? $replycredit_rule['extcreditstype'] : $_G['setting']['creditstransextra'][10];
  491. if($replycredit_rule['random'] > 0) {
  492. $rand = rand(1, 100);
  493. $rand_replycredit = $rand <= $replycredit_rule['random'] ? true : false ;
  494. } else {
  495. $rand_replycredit = true;
  496. }
  497. if($rand_replycredit) {
  498. updatemembercount($_G['uid'], array($replycredit_rule['extcreditstype'] => $replycredit_rule['extcredits']), 1, 'RCA', $_G[tid]);
  499. C::t('forum_post')->update('tid:'.$_G['tid'], $pid, array('replycredit' => $replycredit_rule['extcredits']));
  500. $updatethreaddata[] = DB::field('replycredit', $thread['replycredit'] - $replycredit_rule['extcredits']);
  501. }
  502. }
  503. }
  504. }
  505. if($special == 5) {
  506. if(!$firststand) {
  507. C::t('forum_debate')->update_debaters($_G['tid'], $stand);
  508. } else {
  509. $stand = $firststand;
  510. }
  511. C::t('forum_debate')->update_replies($_G['tid'], $stand);
  512. C::t('forum_debatepost')->insert(array(
  513. 'tid' => $_G['tid'],
  514. 'pid' => $pid,
  515. 'uid' => $_G['uid'],
  516. 'dateline' => $_G['timestamp'],
  517. 'stand' => $stand,
  518. 'voters' => 0,
  519. 'voterids' => '',
  520. ));
  521. }
  522. ($_G['group']['allowpostattach'] || $_G['group']['allowpostimage']) && ($_GET['attachnew'] || $special == 2 && $_GET['tradeaid']) && updateattach($thread['displayorder'] == -4 || $modnewreplies, $_G['tid'], $pid, $_GET['attachnew']);
  523. $replymessage = 'post_reply_succeed';
  524. if($special == 2 && $_G['group']['allowposttrade'] && $thread['authorid'] == $_G['uid'] && !empty($_GET['trade']) && !empty($_GET['item_name'])) {
  525. require_once libfile('function/trade');
  526. trade_create(array(
  527. 'tid' => $_G['tid'],
  528. 'pid' => $pid,
  529. 'aid' => $_GET['tradeaid'],
  530. 'item_expiration' => $_GET['item_expiration'],
  531. 'thread' => $thread,
  532. 'discuz_uid' => $_G['uid'],
  533. 'author' => $author,
  534. 'seller' => empty($_GET['paymethod']) && $_GET['seller'] ? dhtmlspecialchars(trim($_GET['seller'])) : '',
  535. 'item_name' => $_GET['item_name'],
  536. 'item_price' => $_GET['item_price'],
  537. 'item_number' => $_GET['item_number'],
  538. 'item_quality' => $_GET['item_quality'],
  539. 'item_locus' => $_GET['item_locus'],
  540. 'transport' => $_GET['transport'],
  541. 'postage_mail' => $_GET['postage_mail'],
  542. 'postage_express' => $_GET['postage_express'],
  543. 'postage_ems' => $_GET['postage_ems'],
  544. 'item_type' => $_GET['item_type'],
  545. 'item_costprice' => $_GET['item_costprice'],
  546. 'item_credit' => $_GET['item_credit'],
  547. 'item_costcredit' => $_GET['item_costcredit']
  548. ));
  549. $replymessage = 'trade_add_succeed';
  550. if(!empty($_GET['tradeaid'])) {
  551. convertunusedattach($_GET['tradeaid'], $_G['tid'], $pid);
  552. }
  553. }
  554. if($specialextra) {
  555. @include_once DISCUZ_ROOT.'./source/plugin/'.$_G['setting']['threadplugins'][$specialextra]['module'].'.class.php';
  556. $classname = 'threadplugin_'.$specialextra;
  557. if(class_exists($classname) && method_exists($threadpluginclass = new $classname, 'newreply_submit_end')) {
  558. $threadpluginclass->newreply_submit_end($_G['fid'], $_G['tid']);
  559. }
  560. }
  561. $_G['forum']['threadcaches'] && deletethreadcaches($_G['tid']);
  562. include_once libfile('function/stat');
  563. updatestat($thread['isgroup'] ? 'grouppost' : 'post');
  564. $param = array('fid' => $_G['fid'], 'tid' => $_G['tid'], 'pid' => $pid, 'from' => $_GET['from'], 'sechash' => !empty($_GET['sechash']) ? $_GET['sechash'] : '');
  565. if($feedid) {
  566. $param['feedid'] = $feedid;
  567. }
  568. dsetcookie('clearUserdata', 'forum');
  569. if($modnewreplies) {
  570. updatemoderate('pid', $pid);
  571. unset($param['pid']);
  572. if($updatethreaddata) {
  573. C::t('forum_thread')->update($_G['tid'], $updatethreaddata, false, false, 0, true);
  574. }
  575. C::t('forum_forum')->update_forum_counter($_G['fid'], 0, 0, 1, 1);
  576. $url = empty($_POST['portal_referer']) ? ("forum.php?mod=viewthread&tid={$thread[tid]}") : $_POST['portal_referer'];
  577. manage_addnotify('verifypost');
  578. if(!isset($inspacecpshare)) {
  579. showmessage('post_reply_mod_succeed', $url, $param);
  580. }
  581. } else {
  582. $fieldarr = array(
  583. 'lastposter' => array($author),
  584. 'replies' => 1
  585. );
  586. if($thread['lastpost'] < $_G['timestamp']) {
  587. $fieldarr['lastpost'] = array($_G['timestamp']);
  588. }
  589. $row = C::t('forum_threadaddviews')->fetch($_G['tid']);
  590. if(!empty($row)) {
  591. C::t('forum_threadaddviews')->update($_G['tid'], array('addviews' => 0));
  592. $fieldarr['views'] = $row['addviews'];
  593. }
  594. $updatethreaddata = array_merge($updatethreaddata, C::t('forum_thread')->increase($_G['tid'], $fieldarr, false, 0, true));
  595. if($thread['displayorder'] != -4) {
  596. updatepostcredits('+', $_G['uid'], 'reply', $_G['fid']);
  597. if($_G['forum']['status'] == 3) {
  598. if($_G['forum']['closed'] > 1) {
  599. C::t('forum_thread')->increase($_G['forum']['closed'], $fieldarr, true);
  600. }
  601. C::t('forum_groupuser')->update_counter_for_user($_G['uid'], $_G['fid'], 0, 1);
  602. C::t('forum_forumfield')->update($_G['fid'], array('lastupdate' => TIMESTAMP));
  603. require_once libfile('function/grouplog');
  604. updategroupcreditlog($_G['fid'], $_G['uid']);
  605. }
  606. $lastpost = "$thread[tid]\t$thread[subject]\t$_G[timestamp]\t$author";
  607. C::t('forum_forum')->update($_G['fid'], array('lastpost' => $lastpost));
  608. C::t('forum_forum')->update_forum_counter($_G['fid'], 0, 1, 1);
  609. if($_G['forum']['type'] == 'sub') {
  610. C::t('forum_forum')->update($_G['forum']['fup'], array('lastpost' => $lastpost));
  611. }
  612. }
  613. $feed = array();
  614. if(!isset($_GET['addfeed'])) {
  615. $space = array();
  616. space_merge($space, 'field_home');
  617. $_GET['addfeed'] = $space['privacy']['feed']['newreply'];
  618. }
  619. if(!empty($_GET['addfeed']) && $_G['forum']['allowfeed'] && !$isanonymous) {
  620. if($special == 2 && !empty($_GET['trade'])) {
  621. $feed['icon'] = 'goods';
  622. $feed['title_template'] = 'feed_thread_goods_title';
  623. if($_GET['item_price'] > 0) {
  624. if($_G['setting']['creditstransextra'][5] != -1 && $_GET['item_credit']) {
  625. $feed['body_template'] = 'feed_thread_goods_message_1';
  626. } else {
  627. $feed['body_template'] = 'feed_thread_goods_message_2';
  628. }
  629. } else {
  630. $feed['body_template'] = 'feed_thread_goods_message_3';
  631. }
  632. $feed['body_data'] = array(
  633. 'itemname'=> "<a href=\"forum.php?mod=viewthread&do=tradeinfo&tid=$_G[tid]&pid=$pid\">$_GET[item_name]</a>",
  634. 'itemprice'=> $_GET['item_price'],
  635. 'itemcredit'=> $_GET['item_credit'],
  636. 'creditunit'=> $_G['setting']['extcredits'][$_G['setting']['creditstransextra'][5]]['unit'].$_G['setting']['extcredits'][$_G['setting']['creditstransextra'][5]]['title'],
  637. );
  638. if($_GET['tradeaid']) {
  639. $feed['images'] = array(getforumimg($_GET['tradeaid']));
  640. $feed['image_links'] = array("forum.php?mod=viewthread&do=tradeinfo&tid=$_G[tid]&pid=$pid");
  641. }
  642. } elseif($special == 3 && $thread['authorid'] != $_G['uid']) {
  643. $feed['icon'] = 'reward';
  644. $feed['title_template'] = 'feed_reply_reward_title';
  645. $feed['title_data'] = array(
  646. 'subject' => "<a href=\"forum.php?mod=viewthread&tid=$_G[tid]\">$thread[subject]</a>",
  647. 'author' => "<a href=\"home.php?mod=space&uid=$thread[authorid]\">$thread[author]</a>"
  648. );
  649. } elseif($special == 5 && $thread['authorid'] != $_G['uid']) {
  650. $feed['icon'] = 'debate';
  651. if($stand == 1) {
  652. $feed['title_template'] = 'feed_thread_debatevote_title_1';
  653. } elseif($stand == 2) {
  654. $feed['title_template'] = 'feed_thread_debatevote_title_2';
  655. } else {
  656. $feed['title_template'] = 'feed_thread_debatevote_title_3';
  657. }
  658. $feed['title_data'] = array(
  659. 'subject' => "<a href=\"forum.php?mod=viewthread&tid=$_G[tid]\">$thread[subject]</a>",
  660. 'author' => "<a href=\"home.php?mod=space&uid=$thread[authorid]\">$thread[author]</a>"
  661. );
  662. } elseif($thread['authorid'] != $_G['uid']) {
  663. $post_url = "forum.php?mod=redirect&goto=findpost&pid=$pid&ptid=$_G[tid]";
  664. $feed['icon'] = 'post';
  665. $feed['title_template'] = !empty($thread['author']) ? 'feed_reply_title' : 'feed_reply_title_anonymous';
  666. $feed['title_data'] = array(
  667. 'subject' => "<a href=\"$post_url\">$thread[subject]</a>",
  668. 'author' => "<a href=\"home.php?mod=space&uid=$thread[authorid]\">$thread[author]</a>"
  669. );
  670. if(!empty($_G['forum_attachexist'])) {
  671. $imgattach = C::t('forum_attachment_n')->fetch_max_image('tid:'.$_G['tid'], 'pid', $pid);
  672. $firstaid = $imgattach['aid'];
  673. unset($imgattach);
  674. if($firstaid) {
  675. $feed['images'] = array(getforumimg($firstaid));
  676. $feed['image_links'] = array($post_url);
  677. }
  678. }
  679. }
  680. $feed['title_data']['hash_data'] = "tid{$_G[tid]}";
  681. $feed['id'] = $pid;
  682. $feed['idtype'] = 'pid';
  683. if($feed['icon']) {
  684. postfeed($feed);
  685. }
  686. }
  687. $page = getstatus($thread['status'], 4) ? 1 : @ceil(($thread['special'] ? $thread['replies'] + 1 : $thread['replies'] + 2) / $_G['ppp']);
  688. if($updatethreaddata) {
  689. C::t('forum_thread')->update($_G['tid'], $updatethreaddata, false, false, 0, true);
  690. }
  691. if($special == 2 && !empty($_GET['continueadd'])) {
  692. showmessage('post_reply_succeed', "forum.php?mod=post&action=reply&fid={$_G[forum][fid]}&firstpid=$pid&tid={$thread[tid]}&addtrade=yes", $param, array('header' => true));
  693. } else {
  694. $url = empty($_POST['portal_referer']) ? "forum.php?mod=viewthread&tid={$thread[tid]}&pid=$pid&page=$page&extra=$extra#pid$pid" : $_POST['portal_referer'];
  695. }
  696. if(!isset($inspacecpshare)) {
  697. showmessage($replymessage, $url, $param);
  698. }
  699. }
  700. }
  701. ?>