admincp_postcomment.php 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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: admincp_postcomment.php 25832 2011-11-24 01:11:51Z monkey $
  7. */
  8. if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
  9. exit('Access Denied');
  10. }
  11. $detail = !empty($_GET['authorid']) ? true : $_GET['detail'];
  12. $author = $_GET['author'];
  13. $authorid = $_GET['authorid'];
  14. $uid = $_GET['uid'];
  15. $message = $_GET['message'];
  16. $ip = $_GET['ip'];
  17. $users = $_GET['users'];
  18. $starttime = $_GET['starttime'];
  19. $endtime = $_GET['endtime'];
  20. $searchtid = $_GET['searchtid'];
  21. $searchpid = $_GET['searchpid'];
  22. $searchsubmit = $_GET['searchsubmit'];
  23. $cids = $_GET['cids'];
  24. $page = max(1, $_GET['page']);
  25. cpheader();
  26. $aid = $_GET['aid'];
  27. $subject = $_GET['subject'];
  28. if(!submitcheck('postcommentsubmit')) {
  29. if(empty($_GET['search'])) {
  30. $newlist = 1;
  31. $detail = 1;
  32. $starttime = dgmdate(TIMESTAMP - 86400 * 7, 'Y-n-j');
  33. }
  34. $starttime = !preg_match("/^(0|\d{4}\-\d{1,2}\-\d{1,2})$/", $starttime) ? dgmdate(TIMESTAMP - 86400 * 7, 'Y-n-j') : $starttime;
  35. $endtime = $_G['adminid'] == 3 || !preg_match("/^(0|\d{4}\-\d{1,2}\-\d{1,2})$/", $endtime) ? dgmdate(TIMESTAMP, 'Y-n-j') : $endtime;
  36. shownav('topic', 'nav_postcomment');
  37. showsubmenu('nav_postcomment', array(
  38. array('newlist', 'postcomment', !empty($newlist)),
  39. array('search', 'postcomment&search=true', empty($newlist)),
  40. ));
  41. empty($newlist) && showsubmenusteps('', array(
  42. array('postcomment_search', !$searchsubmit),
  43. array('nav_postcomment', $searchsubmit)
  44. ));
  45. if(empty($newlist)) {
  46. $search_tips = 1;
  47. showtips('postcomment_tips');
  48. }
  49. echo <<<EOT
  50. <script type="text/javascript" src="static/js/calendar.js"></script>
  51. <script type="text/JavaScript">
  52. function page(number) {
  53. $('postcommentforum').page.value=number;
  54. $('postcommentforum').searchsubmit.click();
  55. }
  56. </script>
  57. EOT;
  58. showtagheader('div', 'searchposts', !$searchsubmit && empty($newlist));
  59. showformheader("postcomment".(!empty($_GET['search']) ? '&search=true' : ''), '', 'postcommentforum');
  60. showhiddenfields(array('page' => $page, 'pp' => $_GET['pp'] ? $_GET['pp'] : $_GET['perpage']));
  61. showtableheader();
  62. showsetting('postcomment_search_detail', 'detail', $detail, 'radio');
  63. showsetting('comment_search_perpage', '', $_GET['perpage'], "<select name='perpage'><option value='20'>$lang[perpage_20]</option><option value='50'>$lang[perpage_50]</option><option value='100'>$lang[perpage_100]</option></select>");
  64. showsetting('postcomment_content', 'message', $message, 'text');
  65. showsetting('postcomment_search_tid', 'searchtid', $searchtid, 'text');
  66. showsetting('postcomment_search_pid', 'searchpid', $searchpid, 'text');
  67. showsetting('postcomment_search_author', 'author', $author, 'text');
  68. showsetting('postcomment_search_authorid', 'authorid', $authorid, 'text');
  69. showsetting('comment_search_ip', 'ip', $ip, 'text');
  70. showsetting('postcomment_search_time', array('starttime', 'endtime'), array($starttime, $endtime), 'daterange');
  71. showsubmit('searchsubmit');
  72. showtablefooter();
  73. showformfooter();
  74. showtagfooter('div');
  75. } else {
  76. $cids = authcode($cids, 'DECODE');
  77. $cidsadd = $cids ? explode(',', $cids) : $_GET['delete'];
  78. $pids = array();
  79. foreach(C::t('forum_postcomment')->fetch_all($cidsadd) as $postcomment) {
  80. $pids[$postcomment['pid']] = $postcomment['pid'];
  81. }
  82. C::t('forum_postcache')->delete($pids);
  83. $cidsadd && C::t('forum_postcomment')->delete($cidsadd);
  84. $cpmsg = cplang('postcomment_delete');
  85. ?>
  86. <script type="text/JavaScript">alert('<?php echo $cpmsg;?>');parent.$('postcommentforum').searchsubmit.click();</script>
  87. <?php
  88. }
  89. if(submitcheck('searchsubmit') || $newlist) {
  90. $comments = $commentcount = '0';
  91. $sql = $error = '';
  92. $author = trim($author);
  93. if($author != '') {
  94. $authorids = C::t('common_member')->fetch_all_uid_by_username(array_map('trim', explode(',', $author)));
  95. $authorid = ($authorid ? $authorid.',' : '').implode(',',$authorids);
  96. }
  97. $authorid = trim($authorid,', ');
  98. if($starttime != '0') {
  99. $starttime = strtotime($starttime);
  100. }
  101. if($_G['adminid'] == 1 && $endtime != dgmdate(TIMESTAMP, 'Y-n-j')) {
  102. if($endtime != '0') {
  103. $endtime = strtotime($endtime);
  104. }
  105. } else {
  106. $endtime = TIMESTAMP;
  107. }
  108. if(($_G['adminid'] == 2 && $endtime - $starttime > 86400 * 16) || ($_G['adminid'] == 3 && $endtime - $starttime > 86400 * 8)) {
  109. $error = 'comment_mod_range_illegal';
  110. }
  111. if(!$error) {
  112. if($detail) {
  113. $commentcount = C::t('forum_postcomment')->count_by_search($searchtid, $searchpid, ($authorid ? explode(',', str_replace(' ', '', $authorid)) : null), $starttime, $endtime, $ip, $message);
  114. if($commentcount) {
  115. $_GET['perpage'] = intval($_GET['perpage']) < 1 ? 20 : intval($_GET['perpage']);
  116. $perpage = $_GET['pp'] ? $_GET['pp'] : $_GET['perpage'];
  117. $comments = '';
  118. foreach(C::t('forum_postcomment')->fetch_all_by_search($searchtid, $searchpid, ($authorid ? explode(',', str_replace(' ', '', $authorid)) : null), $starttime, $endtime, $ip, $message, (($page - 1) * $perpage), $perpage) as $comment) {
  119. $comment['dateline'] = dgmdate($comment['dateline']);
  120. $comments .= showtablerow('', '', array(
  121. "<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"$comment[id]\" />",
  122. str_replace(array('[b]', '[/b]', '[/color]'), array('<b>', '</b>', '</font>'), preg_replace("/\[color=([#\w]+?)\]/i", "<font color=\"\\1\">", $comment['comment'])),
  123. ($comment['author'] ? "<a href=\"home.php?mod=space&uid=$comment[authorid]\" target=\"_blank\">".$comment['author']."</a>" : cplang('postcomment_guest')),
  124. $comment['dateline'],
  125. $comment['useip'],
  126. "<a href=\"forum.php?mod=redirect&goto=findpost&ptid=$comment[tid]&pid=$comment[pid]\" target=\"_blank\">".cplang('postcomment_pid')."</a>"
  127. ), TRUE);
  128. }
  129. $multi = multi($commentcount, $perpage, $page, ADMINSCRIPT."?action=postcomment");
  130. $multi = preg_replace("/href=\"".ADMINSCRIPT."\?action=postcomment&amp;page=(\d+)\"/", "href=\"javascript:page(\\1)\"", $multi);
  131. $multi = str_replace("window.location='".ADMINSCRIPT."?action=postcomment&amp;page='+this.value", "page(this.value)", $multi);
  132. } else {
  133. $error = 'postcomment_nonexistence';
  134. }
  135. } else {
  136. $commentcount = 0;
  137. foreach(C::t('forum_postcomment')->fetch_all_by_search($searchtid, $searchpid, ($authorid ? explode(',', str_replace(' ', '', $authorid)) : null), $starttime, $endtime, $ip, $message) as $row) {
  138. $cids .= ','.$row['id'];
  139. $commentcount++;
  140. }
  141. $multi = '';
  142. }
  143. }
  144. showtagheader('div', 'postlist', $searchsubmit || $newlist);
  145. showformheader('postcomment&frame=no', 'target="postcommentframe"');
  146. showhiddenfields(array('cids' => authcode($cids, 'ENCODE')));
  147. if(!$search_tips) {
  148. showtableheader(cplang('postcomment_new_result').' '.$commentcount, 'fixpadding');
  149. } else {
  150. showtableheader(cplang('postcomment_result').' '.$commentcount.(empty($newlist) ? ' <a href="###" onclick="$(\'searchposts\').style.display=\'\';$(\'postlist\').style.display=\'none\';$(\'postcommentforum\').pp.value=\'\';$(\'postcommentforum\').page.value=\'\';" class="act lightlink normal">'.cplang('research').'</a>' : ''), 'fixpadding');
  151. }
  152. if($error) {
  153. echo "<tr><td class=\"lineheight\" colspan=\"15\">$lang[$error]</td></tr>";
  154. } elseif($detail) {
  155. showsubtitle(array('', 'postcomment_content', 'author', 'time', 'ip' ,''));
  156. echo $comments;
  157. }
  158. showsubmit('postcommentsubmit', 'delete', $detail ? 'del' : '', '', $multi);
  159. showtablefooter();
  160. showformfooter();
  161. echo '<iframe name="postcommentframe" style="display:none"></iframe>';
  162. showtagfooter('div');
  163. }
  164. ?>