sub_sendreply.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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: sub_sendreply.php 35073 2014-11-04 09:14:30Z anezhou $
  7. */
  8. if (!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. global $pid, $thread, $_G;
  12. $newmessage = preg_replace('/<\/*.*?>|&nbsp;|\r\n|\[attachimg\].*?\[\/attachimg\]|\[quote\].*?\[\/quote\]|\[\/*.*?\]/ms', '', $GLOBALS['message']);
  13. $newmessage = messagecutstr($newmessage, 100);
  14. $key = C::t('#mobile#mobile_wsq_threadlist')->fetch($_G['tid']);
  15. $posts = dunserialize($key['svalue']);
  16. if (trim($newmessage) != '' && !getstatus($thread['status'], 2)) {
  17. if (!$posts) {
  18. $posts = array();
  19. }
  20. if (count($posts) > 2) {
  21. array_shift($posts);
  22. }
  23. $post = array(
  24. 'pid' => $pid,
  25. 'author' => empty($_GET['isanonymous']) ? $_G['username'] : $_G['setting']['anonymoustext'],
  26. 'authorid' => empty($_GET['isanonymous']) ? $_G['uid'] : 0,
  27. 'message' => $newmessage,
  28. );
  29. array_push($posts, $post);
  30. }
  31. if (count($posts) < 3 && ($thread['replies'] >= count($posts)) && !getstatus($thread['status'], 2)) {
  32. $posts = array();
  33. foreach (C::t('forum_post')->fetch_all_by_tid($thread['posttableid'], $thread['tid'], true, 'DESC', 0, 10, 0, 0) as $p) {
  34. $p['message'] = preg_replace('/<\/*.*?>|&nbsp;|\r\n|\[attachimg\].*?\[\/attachimg\]|\[quote\].*?\[\/quote\]|\[\/*.*?\]/ms', '', $p['message']);
  35. $p['message'] = trim(messagecutstr($p['message'], 100));
  36. if($p['anonymous']) {
  37. $p['author'] = $_G['setting']['anonymoustext'];
  38. $p['authorid'] = 0;
  39. }
  40. $post = array(
  41. 'pid' => $p['pid'],
  42. 'author' => $p['author'],
  43. 'authorid' => $p['authorid'],
  44. 'message' => $p['message'],
  45. 'avatar' => avatar($p['authorid'], 'small', true),
  46. );
  47. if ($post['message'] != '') {
  48. array_push($posts, $post);
  49. }
  50. if (count($posts) > 2) {
  51. break;
  52. }
  53. }
  54. $posts = array_reverse($posts);
  55. }
  56. $data = array(
  57. 'skey' => $_G['tid'],
  58. 'svalue' => serialize($posts)
  59. );
  60. if($message != 'post_reply_mod_succeed') {
  61. C::t('#mobile#mobile_wsq_threadlist')->insert($_G['tid'], $data, false, true);
  62. }
  63. ?>