portalcp_comment.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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: portalcp_comment.php 33715 2013-08-07 01:59:25Z andyzheng $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. $cid = intval($_GET['cid']);
  12. $comment = array();
  13. if($cid && $_GET['op'] != 'requote') {
  14. $comment = C::t('portal_comment')->fetch($cid);
  15. }
  16. if($_GET['op'] == 'requote') {
  17. $aid = $_GET['aid'];
  18. $article = C::t('portal_article_title')->fetch($aid);
  19. if($article['idtype'] == 'tid') {
  20. $comment = C::t('forum_post')->fetch('tid:'.$article['id'], $cid);
  21. $comment['uid'] = $comment['authorid'];
  22. $comment['username'] = $comment['author'];
  23. } elseif($article['idtype'] == 'blogid') {
  24. $comment = C::t('home_comment')->fetch($cid);
  25. $comment['uid'] = $comment['authorid'];
  26. $comment['username'] = $comment['author'];
  27. } else {
  28. $comment = C::t('portal_comment')->fetch($cid);
  29. }
  30. unset($aid, $article);
  31. if(!empty($comment['message'])) {
  32. include_once libfile('class/bbcode');
  33. $bbcode = & bbcode::instance();
  34. $comment['message'] = $bbcode->html2bbcode($comment['message']);
  35. $comment['message'] = preg_replace("/\[quote\].*?\[\/quote\]/is", '', $comment['message']);
  36. $comment['message'] = getstr($comment['message'], 150, 0, 0, 2, -1);
  37. }
  38. } elseif($_GET['op'] == 'edit') {
  39. if(empty($comment)) {
  40. showmessage('comment_edit_noexist');
  41. }
  42. if((!$_G['group']['allowmanagearticle'] && $_G['uid'] != $comment['uid'] && $_G['adminid'] != 1 && $_GET['modarticlecommentkey'] != modauthkey($comment['cid'])) || $_G['groupid'] == '7') {
  43. showmessage('group_nopermission', NULL, array('grouptitle' => $_G['group']['grouptitle']), array('login' => 1));
  44. }
  45. if(submitcheck('editsubmit')) {
  46. $message = getstr($_POST['message'], 0, 0, 0, 2);
  47. if(strlen($message) < 2) showmessage('content_is_too_short');
  48. $message = censor($message);
  49. if(censormod($message)) {
  50. $comment_status = 1;
  51. } else {
  52. $comment_status = 0;
  53. }
  54. C::t('portal_comment')->update($comment['cid'], array('message' => $message, 'status' => $comment_status, 'postip' => $_G['clientip'], 'port' => $_G['remoteport']));
  55. showmessage('do_success', dreferer());
  56. }
  57. include_once libfile('class/bbcode');
  58. $bbcode = & bbcode::instance();
  59. $comment['message'] = $bbcode->html2bbcode($comment['message']);
  60. } elseif($_GET['op'] == 'delete') {
  61. if(empty($comment)) {
  62. showmessage('comment_delete_noexist');
  63. }
  64. if(!$_G['group']['allowmanagearticle'] && $_G['uid'] != $comment['uid']) {
  65. showmessage('group_nopermission', NULL, array('grouptitle' => $_G['group']['grouptitle']), array('login' => 1));
  66. }
  67. if(submitcheck('deletesubmit')) {
  68. C::t('portal_comment')->delete($cid);
  69. $idtype = in_array($comment['idtype'], array('aid' ,'topicid')) ? $comment['idtype'] : 'aid';
  70. $tablename = $idtype == 'aid' ? 'portal_article_count' : 'portal_topic';
  71. C::t($tablename)->increase($comment[id], array('commentnum' => -1));
  72. showmessage('do_success', dreferer());
  73. }
  74. }
  75. list($seccodecheck, $secqaacheck) = seccheck('publish');
  76. if(submitcheck('commentsubmit', 0, $seccodecheck, $secqaacheck)) {
  77. if(!checkperm('allowcommentarticle')) {
  78. showmessage('group_nopermission', NULL, array('grouptitle' => $_G['group']['grouptitle']), array('login' => 1));
  79. }
  80. $id = 0;
  81. $idtype = '';
  82. if(!empty($_POST['aid'])) {
  83. $id = intval($_POST['aid']);
  84. $idtype = 'aid';
  85. } elseif(!empty($_POST['topicid'])) {
  86. $id = intval($_POST['topicid']);
  87. $idtype = 'topicid';
  88. }
  89. $message = $_POST['message'];
  90. require_once libfile('function/spacecp');
  91. cknewuser();
  92. $waittime = interval_check('post');
  93. if($waittime > 0) {
  94. showmessage('operating_too_fast', '', array('waittime' => $waittime), array('return' => true));
  95. }
  96. $retmessage = addportalarticlecomment($id, $message, $idtype);
  97. if($retmessage == 'do_success') {
  98. showmessage('do_success', $_POST['referer'] ? $_POST['referer'] : "portal.php?mod=comment&id=$id&idtype=$idtype");
  99. } else {
  100. showmessage($retmessage, dreferer("portal.php?mod=comment&id=$id&idtype=$idtype"));
  101. }
  102. }
  103. include_once template("portal/portalcp_comment");
  104. ?>