collection_comment.php 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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: collection_comment.php 33715 2013-08-07 01:59:25Z andyzheng $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. if(empty($_G['uid'])) {
  12. showmessage('login_before_enter_home', null, array(), array('showmsg' => true, 'login' => 1));
  13. }
  14. $oplist = array('add', 'del', 'pop', 'recommend');
  15. if(!in_array($op, $oplist)) {
  16. $op = '';
  17. }
  18. if(empty($op) || $op == 'add') {
  19. $_GET['handlekey'] = 'addComment';
  20. if(!$ctid) {
  21. showmessage('undefined_action', NULL);
  22. }
  23. if(!$_G['group']['allowcommentcollection']) {
  24. showmessage('collection_comment_closed');
  25. }
  26. require_once libfile('function/spacecp');
  27. if(!$_G['collection']['ctid']) {
  28. showmessage('collection_permission_deny');
  29. }
  30. $waittime = interval_check('post');
  31. if($waittime > 0) {
  32. showmessage('operating_too_fast', '', array('waittime' => $waittime), array('return' => true));
  33. }
  34. $memberrate = C::t('forum_collectioncomment')->fetch_rate_by_ctid_uid($_G['collection']['ctid'], $_G['uid']);
  35. if(!trim($_GET['message']) && ((!$memberrate && !$_GET['ratescore']) || $memberrate)) {
  36. showmessage('collection_edit_checkentire');
  37. }
  38. if($_G['setting']['maxpostsize'] && strlen($_GET['message']) > $_G['setting']['maxpostsize']) {
  39. showmessage('post_message_toolong', '', array('maxpostsize' => $_G['setting']['maxpostsize']));
  40. }
  41. $newcomment = array(
  42. 'ctid' => $_G['collection']['ctid'],
  43. 'uid' => $_G['uid'],
  44. 'username' => $_G['username'],
  45. 'message' => dhtmlspecialchars(censor($_GET['message'])),
  46. 'dateline' => $_G['timestamp'],
  47. 'useip' => $_G['clientip'],
  48. 'port' => $_G['remoteport']
  49. );
  50. if(!$memberrate) {
  51. $newcomment['rate'] = $_GET['ratescore'];
  52. } else {
  53. $_GET['ratescore'] = 0;
  54. }
  55. C::t('forum_collectioncomment')->insert($newcomment);
  56. C::t('forum_collection')->update_by_ctid($_G['collection']['ctid'], 0, 0, 1, 0, $_GET['ratescore'], $_G['collection']['ratenum']);
  57. if($_G['collection']['uid'] != $_G['uid']) {
  58. notification_add($_G['collection']['uid'], "system", 'collection_becommented', array('from_id'=>$_G['collection']['ctid'], 'from_idtype'=>'collectioncomment', 'ctid'=>$_G['collection']['ctid'], 'collectionname'=>$_G['collection']['name']), 1);
  59. }
  60. C::t('common_member_status')->update($_G['uid'], array('lastpost' => TIMESTAMP), 'UNBUFFERED');
  61. showmessage('collection_comment_succ', $tid ? 'forum.php?mod=viewthread&tid='.$tid : dreferer());
  62. } elseif($op == 'del') {
  63. if(!submitcheck('formhash')) {
  64. showmessage('undefined_action', NULL);
  65. } else {
  66. if(!$_G['collection']['ctid'] || !checkcollectionperm($_G['collection'], $_G['uid']) || count($_GET['delcomment']) == 0) {
  67. showmessage('undefined_action', NULL);
  68. }
  69. $delrows = C::t('forum_collectioncomment')->delete_by_cid_ctid($_GET['delcomment'], $_G['collection']['ctid']);
  70. C::t('forum_collection')->update_by_ctid($_G['collection']['ctid'], 0, 0, -$delrows);
  71. showmessage('collection_comment_remove_succ', 'forum.php?mod=collection&action=view&op=comment&ctid='.$ctid);
  72. }
  73. } elseif($op == 'pop') {
  74. $collectionthread = C::t('forum_collectionthread')->fetch_by_ctid_tid($ctid, $tid);
  75. if(!$collectionthread['ctid']) {
  76. showmessage('collection_permission_deny');
  77. }
  78. $thread = C::t('forum_thread')->fetch($tid);
  79. include template('forum/collection_commentpop');
  80. } elseif($op == 'recommend') {
  81. if(!$_G['collection']['ctid']) {
  82. showmessage('collection_permission_deny');
  83. }
  84. if(!submitcheck('formhash')) {
  85. include template('forum/collection_recommend');
  86. } else {
  87. if(!$_GET['threadurl']) {
  88. showmessage('collection_recommend_url', '', array(), array('alert'=> 'error', 'closetime' => true, 'showdialog' => 1));
  89. }
  90. $touid = &$_G['collection']['uid'];
  91. $coef = 1;
  92. $subject = $message = lang('message', 'collection_recommend_message', array('fromuser' => $_G['username'], 'collectioname' => $_G['collection']['name'], 'url' => $_GET['threadurl']));
  93. if(C::t('home_blacklist')->count_by_uid_buid($touid, $_G['uid'])) {
  94. showmessage('is_blacklist', '', array(), array('return' => true));
  95. }
  96. if(($value = getuserbyuid($touid))) {
  97. require_once libfile('function/friend');
  98. $value['onlyacceptfriendpm'] = $value['onlyacceptfriendpm'] ? $value['onlyacceptfriendpm'] : ($_G['setting']['onlyacceptfriendpm'] ? 1 : 2);
  99. if($_G['group']['allowsendallpm'] || $value['onlyacceptfriendpm'] == 2 || ($value['onlyacceptfriendpm'] == 1 && friend_check($touid))) {
  100. $return = sendpm($touid, $subject, $message, '', 0, 0);
  101. } else {
  102. showmessage('message_can_not_send_onlyfriend', '', array(), array('return' => true));
  103. }
  104. } else {
  105. showmessage('message_bad_touid', '', array(), array('return' => true));
  106. }
  107. if($return > 0) {
  108. include_once libfile('function/stat');
  109. updatestat('sendpm', 0, $coef);
  110. C::t('common_member_status')->update($_G['uid'], array('lastpost' => TIMESTAMP), 'UNBUFFERED');
  111. !($_G['group']['exempt'] & 1) && updatecreditbyaction('sendpm', 0, array(), '', $coef);
  112. showmessage('collection_recommend_succ', '', array(), array('alert'=> 'right', 'closetime' => true, 'showdialog' => 1));
  113. }
  114. }
  115. }
  116. ?>