admincp_comment.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  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_comment.php 28774 2012-03-12 10:09:50Z chenmengshu $
  7. */
  8. if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
  9. exit('Access Denied');
  10. }
  11. $detail = $_GET['detail'];
  12. $idtype = $_GET['idtype'];
  13. $id = $_GET['id'];
  14. $author = $_GET['author'];
  15. $authorid = $_GET['authorid'];
  16. $uid = $_GET['uid'];
  17. $message = $_GET['message'];
  18. $ip = $_GET['ip'];
  19. $users = $_GET['users'];
  20. $starttime = $_GET['starttime'];
  21. $endtime = $_GET['endtime'];
  22. $searchsubmit = $_GET['searchsubmit'];
  23. $cids = $_GET['cids'];
  24. $page = max(1, $_GET['page']);
  25. $fromumanage = $_GET['fromumanage'] ? 1 : 0;
  26. cpheader();
  27. if(empty($operation)) {
  28. if(!submitcheck('commentsubmit')) {
  29. if($fromumanage) {
  30. $starttime = !preg_match("/^(0|\d{4}\-\d{1,2}\-\d{1,2})$/", $starttime) ? '' : $starttime;
  31. $endtime = $_G['adminid'] == 3 || !preg_match("/^(0|\d{4}\-\d{1,2}\-\d{1,2})$/", $endtime) ? '' : $endtime;
  32. } else {
  33. $starttime = !preg_match("/^(0|\d{4}\-\d{1,2}\-\d{1,2})$/", $starttime) ? dgmdate(TIMESTAMP - 86400 * 7, 'Y-n-j') : $starttime;
  34. $endtime = $_G['adminid'] == 3 || !preg_match("/^(0|\d{4}\-\d{1,2}\-\d{1,2})$/", $endtime) ? dgmdate(TIMESTAMP, 'Y-n-j') : $endtime;
  35. }
  36. shownav('topic', 'nav_comment');
  37. showsubmenu('nav_comment', array(
  38. array('comment_comment', 'comment', 1),
  39. array('comment_article_comment', 'comment&operation=article', 0),
  40. array('comment_topic_comment', 'comment&operation=topic', 0)
  41. ));
  42. showtips('comment_tips');
  43. echo <<<EOT
  44. <script type="text/javascript" src="static/js/calendar.js"></script>
  45. <script type="text/JavaScript">
  46. function page(number) {
  47. $('commentforum').page.value=number;
  48. $('commentforum').searchsubmit.click();
  49. }
  50. </script>
  51. EOT;
  52. showtagheader('div', 'searchposts', !$searchsubmit);
  53. showformheader("comment", '', 'commentforum');
  54. showhiddenfields(array('page' => $page, 'pp' => $_GET['pp'] ? $_GET['pp'] : $_GET['perpage']));
  55. showtableheader();
  56. showsetting('comment_search_detail', 'detail', $detail, 'radio');
  57. 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>");
  58. showsetting('comment_idtype', array('idtype', array(
  59. array('', $lang['all']),
  60. array('uid', $lang['comment_uid']),
  61. array('blogid', $lang['comment_blogid']),
  62. array('picid', $lang['comment_picid']),
  63. array('sid', $lang['comment_sid']),
  64. )), 'comment_idtype', 'select');
  65. showsetting('comment_search_id', 'id', $id, 'text');
  66. showsetting('comment_search_author', 'author', $author, 'text');
  67. showsetting('comment_search_authorid', 'authorid', $authorid, 'text');
  68. showsetting('comment_search_uid', 'uid', $uid, 'text');
  69. showsetting('comment_search_message', 'message', $message, 'text');
  70. showsetting('comment_search_ip', 'ip', $ip, 'text');
  71. showsetting('comment_search_time', array('starttime', 'endtime'), array($starttime, $endtime), 'daterange');
  72. echo '<input type="hidden" name="fromumanage" value="'.$fromumanage.'">';
  73. showsubmit('searchsubmit');
  74. showtablefooter();
  75. showformfooter();
  76. showtagfooter('div');
  77. } else {
  78. $cids = authcode($cids, 'DECODE');
  79. $cidsadd = $cids ? explode(',', $cids) : $_GET['delete'];
  80. include_once libfile('function/delete');
  81. $deletecount = count(deletecomments($cidsadd));
  82. $cpmsg = cplang('comment_succeed', array('deletecount' => $deletecount));
  83. ?>
  84. <script type="text/JavaScript">alert('<?php echo $cpmsg;?>');parent.$('commentforum').searchsubmit.click();</script>
  85. <?php
  86. }
  87. if(submitcheck('searchsubmit', 1)) {
  88. $comments = $commentcount = '0';
  89. $sql = $error = '';
  90. $authorids = array();
  91. $author = trim($author);
  92. if($id !='') {
  93. $id = explode(',', $id);
  94. }
  95. if($author != '') {
  96. $authorids = C::t('common_member')->fetch_all_uid_by_username(array_map('trim', explode(',', $author)));
  97. if (!$authorids) {
  98. $authorids = array(-1);
  99. }
  100. }
  101. $authorid = trim($authorid, ', ');
  102. if($authorid != '') {
  103. if (!$authorids) {
  104. $authorids = explode(',', $authorid);
  105. } else {
  106. $authorids = array_intersect($authorids, explode(',', $authorid));
  107. }
  108. if (!$authorids) {
  109. $authorids = array(-1);
  110. }
  111. }
  112. if($_G['adminid'] == 1 && $endtime != dgmdate(TIMESTAMP, 'Y-n-j')) {
  113. if($endtime != '') {
  114. $endtime = strtotime($endtime);
  115. }
  116. } else {
  117. $endtime = TIMESTAMP;
  118. }
  119. if(($_G['adminid'] == 2 && $endtime - $starttime > 86400 * 16) || ($_G['adminid'] == 3 && $endtime - $starttime > 86400 * 8)) {
  120. $error = 'comment_mod_range_illegal';
  121. }
  122. $uid = trim($uid, ', ');
  123. if($uid !='') {
  124. $uid = explode(',', $uid);
  125. }
  126. if(!$error) {
  127. if($commentcount = C::t('home_comment')->fetch_all_search(3, $id, $authorids, $uid, $ip, $message, $idtype, $starttime, $endtime)) {
  128. if($detail) {
  129. $_GET['perpage'] = intval($_GET['perpage']) < 1 ? 20 : intval($_GET['perpage']);
  130. $perpage = $_GET['pp'] ? $_GET['pp'] : $_GET['perpage'];
  131. $query = C::t('home_comment')->fetch_all_search(1, $id, $authorids, $uid, $ip, $message, $idtype, $starttime, $endtime, (($page - 1) * $perpage), $perpage);
  132. $comments = '';
  133. foreach ($query as $comment) {
  134. $comment['dateline'] = dgmdate($comment['dateline']);
  135. switch($comment['idtype']) {
  136. case 'picid':
  137. $address = "<a href=\"home.php?mod=space&uid=$comment[uid]&do=album&picid=$comment[id]\" target=\"_blank\">$comment[message]</a>";
  138. break;
  139. case 'uid':
  140. $address = "<a href=\"home.php?mod=space&uid=$comment[uid]&do=wall\" target=\"_blank\">$comment[message]</a>";
  141. break;
  142. case 'sid':
  143. $address = "<a href=\"home.php?mod=space&uid=1&do=share&id=$comment[id]\" target=\"_blank\">$comment[message]</a>";
  144. break;
  145. case 'blogid':
  146. $address = "<a href=\"home.php?mod=space&uid=$comment[uid]&do=blog&id=$comment[id]\" target=\"_blank\">$comment[message]</a>";
  147. break;
  148. }
  149. $comments .= showtablerow('', '', array(
  150. "<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"$comment[cid]\" />",
  151. $address,
  152. "<a href=\"home.php?mod=space&uid=$comment[uid]\" target=\"_blank\">$comment[author]</a>",
  153. $comment['ip'],
  154. $comment['idtype'],
  155. $comment['dateline']
  156. ), TRUE);
  157. }
  158. $multi = multi($commentcount, $perpage, $page, ADMINSCRIPT."?action=comment");
  159. $multi = preg_replace("/href=\"".ADMINSCRIPT."\?action=comment&amp;page=(\d+)\"/", "href=\"javascript:page(\\1)\"", $multi);
  160. $multi = str_replace("window.location='".ADMINSCRIPT."?action=comment&amp;page='+this.value", "page(this.value)", $multi);
  161. } else {
  162. $query = C::t('home_comment')->fetch_all_search(2, $id, $authorids, $uid, $ip, $message, $idtype, $starttime, $endtime);
  163. foreach ($query as $comment) {
  164. $cids .= ','.$comment['cid'];
  165. }
  166. }
  167. } else
  168. $error = 'comment_post_nonexistence';
  169. }
  170. showtagheader('div', 'postlist', $searchsubmit);
  171. showformheader('comment&frame=no', 'target="commentframe"');
  172. showhiddenfields(array('cids' => authcode($cids, 'ENCODE')));
  173. showtableheader(cplang('comment_result').' '.$commentcount.' <a href="###" onclick="$(\'searchposts\').style.display=\'\';$(\'postlist\').style.display=\'none\';$(\'commentforum\').pp.value=\'\';$(\'commentforum\').page.value=\'\';" class="act lightlink normal">'.cplang('research').'</a>', 'fixpadding');
  174. if($error) {
  175. echo "<tr><td class=\"lineheight\" colspan=\"15\">$lang[$error]</td></tr>";
  176. } else {
  177. if($detail) {
  178. showsubtitle(array('', 'message', 'author', 'ip', 'comment_idtype', 'time'));
  179. echo $comments;
  180. }
  181. }
  182. showsubmit('commentsubmit', 'delete', $detail ? 'del' : '', '', $multi);
  183. showtablefooter();
  184. showformfooter();
  185. echo '<iframe name="commentframe" style="display:none"></iframe>';
  186. showtagfooter('div');
  187. }
  188. }
  189. if($operation == 'article' || $operation == 'topic') {
  190. $aid = $_GET['aid'];
  191. $subject = $_GET['subject'];
  192. $idtype = $operation == 'article' ? 'aid' : 'topicid';
  193. $tablename = $idtype == 'aid' ? 'portal_article_title' : 'portal_topic';
  194. if(!submitcheck('articlesubmit')) {
  195. $starttime = !preg_match("/^(0|\d{4}\-\d{1,2}\-\d{1,2})$/", $starttime) ? dgmdate(TIMESTAMP - 86400 * 7, 'Y-n-j') : $starttime;
  196. $endtime = $_G['adminid'] == 3 || !preg_match("/^(0|\d{4}\-\d{1,2}\-\d{1,2})$/", $endtime) ? dgmdate(TIMESTAMP, 'Y-n-j') : $endtime;
  197. shownav('topic', 'nav_comment');
  198. showsubmenu('nav_comment', array(
  199. array('comment_comment', 'comment', 0),
  200. array('comment_article_comment', 'comment&operation=article', $operation == 'article' ? 1 : 0),
  201. array('comment_topic_comment', 'comment&operation=topic', $operation == 'topic' ? 1 : 0)
  202. ));
  203. showtips('comment_'.$operation.'_tips');
  204. echo <<<EOT
  205. <script type="text/javascript" src="static/js/calendar.js"></script>
  206. <script type="text/JavaScript">
  207. function page(number) {
  208. $('articleforum').page.value=number;
  209. $('articleforum').searchsubmit.click();
  210. }
  211. </script>
  212. EOT;
  213. showtagheader('div', 'searchposts', !$searchsubmit);
  214. showformheader("comment&operation=$operation", '', 'articleforum');
  215. showhiddenfields(array('page' => $page, 'pp' => $_GET['pp'] ? $_GET['pp'] : $_GET['perpage']));
  216. showtableheader();
  217. 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>");
  218. showsetting("comment_{$operation}_subject", 'subject', $subject, 'text');
  219. showsetting("comment_{$operation}_id", 'aid', $aid, 'text');
  220. showsetting('comment_search_message', 'message', $message, 'text');
  221. showsetting('comment_search_author', 'author', $author, 'text');
  222. showsetting('comment_search_authorid', 'authorid', $authorid, 'text');
  223. showsetting('comment_search_time', array('starttime', 'endtime'), array($starttime, $endtime), 'daterange');
  224. showsubmit('searchsubmit');
  225. showtablefooter();
  226. showformfooter();
  227. showtagfooter('div');
  228. } else {
  229. $commentnum = array();
  230. foreach(C::t('portal_comment')->fetch_all($_GET['delete']) as $value) {
  231. $commentnum[$value['idtype']][$value['id']] = $value['id'];
  232. }
  233. if($commentnum['aid']) {
  234. C::t('portal_article_count')->increase($commentnum['aid'], array('commentnum' => -1));
  235. } elseif($commentnum['topicid']) {
  236. C::t('portal_topic')->increase($commentnum['topicid'], array('commentnum' => -1));
  237. }
  238. C::t('portal_comment')->delete($_GET['delete']);
  239. $cpmsg = cplang('comment_article_delete');
  240. ?>
  241. <script type="text/JavaScript">alert('<?php echo $cpmsg;?>');parent.$('articleforum').searchsubmit.click();</script>
  242. <?php
  243. }
  244. if(submitcheck('searchsubmit')) {
  245. $comments = $commentcount = '0';
  246. $sql = $error = '';
  247. $author = trim($author);
  248. $queryAId = $aid ? array($aid) : array();
  249. if($subject != '') {
  250. $ids = array();
  251. $query = C::t($tablename)->fetch_all_by_title($idtype, $subject);
  252. foreach($query as $value) {
  253. $ids[] = intval($value[$idtype]);
  254. }
  255. $queryAId = array_merge($queryAId, $ids);
  256. }
  257. $queryAuthorIDs = $authorid ? array($authorid) : array();
  258. if($author != '') {
  259. $authorids = C::t('common_member')->fetch_all_uid_by_username(array_map('trim', explode(',', $author)));
  260. $queryAuthorIDs = array_merge($queryAuthorIDs, $authorids);
  261. }
  262. if($starttime != '0') {
  263. $starttime = strtotime($starttime);
  264. }
  265. $sqlendtime = '';
  266. if($_G['adminid'] == 1 && $endtime != dgmdate(TIMESTAMP, 'Y-n-j')) {
  267. if($endtime != '0') {
  268. $sqlendtime = $endtime = strtotime($endtime);
  269. }
  270. } else {
  271. $endtime = TIMESTAMP;
  272. }
  273. if(($_G['adminid'] == 2 && $endtime - $starttime > 86400 * 16) || ($_G['adminid'] == 3 && $endtime - $starttime > 86400 * 8)) {
  274. $error = 'comment_mod_range_illegal';
  275. }
  276. if(!$error) {
  277. $commentcount = C::t('portal_comment')->count_all_by_search($queryAId, $queryAuthorIDs, $starttime, $sqlendtime, $idtype, $message);
  278. if($commentcount) {
  279. $_GET['perpage'] = intval($_GET['perpage']) < 1 ? 20 : intval($_GET['perpage']);
  280. $perpage = $_GET['pp'] ? $_GET['pp'] : $_GET['perpage'];
  281. $query = C::t('portal_comment')->fetch_all_by_search($queryAId, $queryAuthorIDs, $starttime, $sqlendtime, $idtype, $message, (($page - 1) * $perpage), $perpage);
  282. $comments = '';
  283. $mod = $idtype == 'aid' ? 'view' : 'topic';
  284. foreach($query as $comment) {
  285. $comment['dateline'] = dgmdate($comment['dateline']);
  286. $comments .= showtablerow('', '', array(
  287. "<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"$comment[cid]\" />",
  288. "<a href=\"portal.php?mod=$mod&$idtype=$comment[id]\" target=\"_blank\">$comment[title]</a>",
  289. $comment[message],
  290. "<a href=\"home.php?mod=space&uid=$comment[uid]\" target=\"_blank\">$comment[username]</a>",
  291. $comment['dateline']
  292. ), TRUE);
  293. }
  294. $multi = multi($commentcount, $perpage, $page, ADMINSCRIPT."?action=comment&operation=$operation");
  295. $multi = preg_replace("/href=\"".ADMINSCRIPT."\?action=comment&operation=$operation&amp;page=(\d+)\"/", "href=\"javascript:page(\\1)\"", $multi);
  296. $multi = str_replace("window.location='".ADMINSCRIPT."?action=comment&amp;operation=$operation&amp;page='+this.value", "page(this.value)", $multi);
  297. } else {
  298. $error = 'comment_post_nonexistence';
  299. }
  300. }
  301. showtagheader('div', 'postlist', $searchsubmit);
  302. showformheader('comment&operation='.$operation.'&frame=no', 'target="articleframe"');
  303. showtableheader(cplang('comment_result').' '.$commentcount.' <a href="###" onclick="$(\'searchposts\').style.display=\'\';$(\'postlist\').style.display=\'none\';$(\'articleforum\').pp.value=\'\';$(\'articleforum\').page.value=\'\';" class="act lightlink normal">'.cplang('research').'</a>', 'fixpadding');
  304. if($error) {
  305. echo "<tr><td class=\"lineheight\" colspan=\"15\">$lang[$error]</td></tr>";
  306. } else {
  307. showsubtitle(array('', 'article_title', 'message', 'author', 'time'));
  308. echo $comments;
  309. }
  310. showsubmit('articlesubmit', 'delete', 'del', '', $multi);
  311. showtablefooter();
  312. showformfooter();
  313. echo '<iframe name="articleframe" style="display:none"></iframe>';
  314. showtagfooter('div');
  315. }
  316. }
  317. ?>