admincp_collection.php 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  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_collection.php 32581 2013-02-22 04:03:45Z chenmengshu $
  7. */
  8. if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
  9. exit('Access Denied');
  10. }
  11. cpheader();
  12. $operation = in_array($operation, array('admin', 'comment', 'recommend')) ? $operation : 'admin';
  13. $current = array($operation => 1);
  14. $fromumanage = $_GET['fromumanage'] ? 1 : 0;
  15. shownav('global', 'collection');
  16. showsubmenu('collection', array(
  17. array('collection_admin', 'collection&operation=admin', $current['admin']),
  18. array('collection_comment', 'collection&operation=comment', $current['comment']),
  19. array('collection_recommend', 'collection&operation=recommend', $current['recommend'])
  20. ));
  21. echo '<script src="static/js/calendar.js"></script>';
  22. if($operation == 'comment') {
  23. $tagarray = array();
  24. if(submitcheck('submit') && !empty($_GET['cidarray']) && is_array($_GET['cidarray']) && count($_GET['cidarray']) && !empty($_GET['operate_type'])) {
  25. $class_tag = new tag();
  26. $cidarray = array();
  27. $operate_type = $_GET['operate_type'];
  28. $cidarray = $_GET['cidarray'];
  29. if($operate_type == 'delete') {
  30. require_once libfile('function/delete');
  31. $cidlist = C::t('forum_collectioncomment')->fetch_all($cidarray);
  32. C::t('forum_collectioncomment')->delete_by_cid_ctid($cidarray);
  33. foreach($cidlist as $uniquecid) {
  34. $decreasnum[$uniquecid['ctid']]++;
  35. }
  36. foreach($cidlist as $uniquecid) {
  37. C::t('forum_collection')->update_by_ctid($uniquecid['ctid'], 0, 0, -$decreasnum[$uniquecid['ctid']]);
  38. }
  39. }
  40. cpmsg('collection_admin_updated', 'action=collection&operation=comment&searchsubmit=yes&perpage='.$_GET['perpage'].'&page='.$_GET['page'], 'succeed');
  41. }
  42. if(!submitcheck('searchsubmit', 1)) {
  43. showformheader('collection&operation=comment');
  44. showtableheader();
  45. showsetting('collection_ctid', 'comment_ctid', $comment_ctid, 'text');
  46. showsetting('collection_comment_message', 'comment_message', $comment_message, 'text');
  47. showsetting('collection_comment_cid', 'comment_cid', $comment_cid, 'text');
  48. showsetting('collection_comment_username', 'comment_username', $comment_username, 'text');
  49. showsetting('collection_comment_uid', 'comment_uid', $comment_uid, 'text');
  50. showsetting('collection_comment_rate', 'comment_rate', $comment_rate, 'text');
  51. showsetting('collection_comment_useip', 'comment_useip', $comment_useip, 'text');
  52. if(!$fromumanage) {
  53. empty($_GET['starttime']) && $_GET['starttime'] = date('Y-m-d', time() - 86400 * 30);
  54. }
  55. echo '<input type="hidden" name="fromumanage" value="'.$fromumanage.'">';
  56. showsetting('threads_search_time', array('starttime', 'endtime'), array($_GET['starttime'], $_GET['endtime']), 'daterange');
  57. showsetting('feed_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. showsubmit('searchsubmit');
  59. showtablefooter();
  60. showformfooter();
  61. showtagfooter('div');
  62. } else {
  63. $comment_message = trim($_GET['comment_message']);
  64. $comment_cid = dintval($_GET['comment_cid']);
  65. $comment_ctid = dintval($_GET['comment_ctid']);
  66. $comment_uid = dintval($_GET['comment_uid']);
  67. $comment_username = trim($_GET['comment_username']);
  68. $comment_useip = trim($_GET['comment_useip']);
  69. $comment_rate = dintval($_GET['comment_rate']);
  70. $starttime = $_GET['starttime'] ? strtotime($_GET['starttime']) : '';
  71. $endtime = $_GET['endtime'] ? strtotime($_GET['endtime']) : '';
  72. $ppp = $_GET['perpage'];
  73. $startlimit = ($page - 1) * $ppp;
  74. $multipage = '';
  75. $totalcount = C::t('forum_collectioncomment')->fetch_all_for_search($comment_cid, $comment_ctid, $comment_username, $comment_uid, $comment_useip, $comment_rate, $comment_message, $starttime, $endtime, -1);
  76. $multipage = multi($totalcount, $ppp, $page, ADMINSCRIPT."?action=collection&operation=comment&searchsubmit=yes&comment_message=$comment_message&comment_cid=$comment_cid&comment_username=$comment_username&comment_uid=$comment_uid&comment_ctid=$comment_ctid&comment_useip=$comment_useip&comment_rate=$comment_rate&starttime=$starttime&endtime=$endtime&perpage=$ppp");
  77. $collectioncomment = C::t('forum_collectioncomment')->fetch_all_for_search($comment_cid, $comment_ctid, $comment_username, $comment_uid, $comment_useip, $comment_rate, $comment_message, $starttime, $endtime, $startlimit, $ppp);
  78. showformheader('collection&operation=comment');
  79. showtableheader(cplang('collection_comment_result').' '.$totalcount.' <a href="###" onclick="location.href=\''.ADMINSCRIPT.'?action=collection&operation=comment\';" class="act lightlink normal">'.cplang('research').'</a>', 'nobottom');
  80. showhiddenfields(array('page' => $_GET['page'], 'tagname' => $tagname, 'status' => $status, 'perpage' => $ppp));
  81. showsubtitle(array('', 'collection_comment_message', 'collection_comment_cid', 'collection_name', 'collection_comment_username', 'collection_comment_useip', 'collection_comment_ratenum', 'collection_date'));
  82. foreach($collectioncomment as $uniquecomment) {
  83. $ctidarray[$uniquecomment['ctid']] = 1;
  84. }
  85. $ctidarray = array_keys($ctidarray);
  86. $collectiondata = C::t('forum_collection')->fetch_all($ctidarray);
  87. foreach($collectioncomment as $uniquecomment) {
  88. if($uniquecomment['rate'] == 0) $uniquecomment['rate'] = '-';
  89. showtablerow('', array('class="td25"', 'width=400', ''), array(
  90. "<input class=\"checkbox\" type=\"checkbox\" name=\"cidarray[]\" value=\"$uniquecomment[cid]\" />",
  91. $uniquecomment['message'],
  92. $uniquecomment['cid'],
  93. "<a href='forum.php?mod=collection&action=view&ctid={$uniquecomment['ctid']}' target='_blank'>{$collectiondata[$uniquecomment['ctid']]['name']}</a>",
  94. "<a href='home.php?mod=space&uid={$uniquecomment['uid']}' target='_blank'>{$uniquecomment['username']}</a>",
  95. $uniquecomment['useip'],
  96. $uniquecomment['rate'],
  97. dgmdate($uniquecomment['dateline']),
  98. ));
  99. }
  100. showtablerow('', array('class="td25" colspan="3"'), array('<input name="chkall" id="chkall" type="checkbox" class="checkbox" onclick="checkAll(\'prefix\', this.form, \'cidarray\', \'chkall\')" /><label for="chkall">'.cplang('select_all').'</label>'));
  101. showtablerow('', array('class="td25"', 'colspan="2"'), array(
  102. cplang('operation'),
  103. '<input class="radio" type="radio" name="operate_type" value="delete"> '.cplang('delete').' '
  104. ));
  105. showsubmit('submit', 'submit', '', '', $multipage);
  106. showtablefooter();
  107. showformfooter();
  108. }
  109. } elseif($operation == 'admin') {
  110. $tagarray = array();
  111. if(submitcheck('submit') && !empty($_GET['ctidarray']) && is_array($_GET['ctidarray']) && count($_GET['ctidarray']) && !empty($_GET['operate_type'])) {
  112. $class_tag = new tag();
  113. $ctidarray = array();
  114. $operate_type = $_GET['operate_type'];
  115. $ctidarray = $_GET['ctidarray'];
  116. if($operate_type == 'delete') {
  117. require_once libfile('function/delete');
  118. foreach($ctidarray as $ctid) {
  119. deletecollection($ctid);
  120. }
  121. }
  122. cpmsg('collection_admin_updated', 'action=collection&operation=admin&searchsubmit=yes&perpage='.$_GET['perpage'].'&page='.$_GET['page'], 'succeed');
  123. }
  124. if(!submitcheck('searchsubmit', 1)) {
  125. showformheader('collection&operation=admin');
  126. showtableheader();
  127. showsetting('collection_name', 'collection_name', $collection_name, 'text');
  128. showsetting('collection_ctid', 'collection_ctid', $collection_ctid, 'text');
  129. showsetting('collection_username', 'collection_username', $collection_username, 'text');
  130. showsetting('collection_uid', 'collection_uid', $collection_uid, 'text');
  131. showsetting('feed_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>");
  132. showsubmit('searchsubmit');
  133. showtablefooter();
  134. showformfooter();
  135. showtagfooter('div');
  136. } else {
  137. $collection_name = trim($_GET['collection_name']);
  138. $collection_ctid = dintval($_GET['collection_ctid']);
  139. $collection_username = trim($_GET['collection_username']);
  140. $collection_uid = dintval($_GET['collection_uid']);
  141. $ppp = $_GET['perpage'];
  142. $startlimit = ($page - 1) * $ppp;
  143. $multipage = '';
  144. $totalcount = C::t('forum_collection')->fetch_all_for_search($collection_name, $collection_ctid, $collection_username, $collection_uid, -1);
  145. $multipage = multi($totalcount, $ppp, $page, ADMINSCRIPT."?action=collection&operation=admin&searchsubmit=yes&collection_name=$collection_name&collection_ctid=$collection_ctid&collection_username=$collection_username&collection_uid=$collection_uid&perpage=$ppp&status=$status");
  146. $collection = C::t('forum_collection')->fetch_all_for_search($collection_name, $collection_ctid, $collection_username, $collection_uid, $startlimit, $ppp);
  147. showformheader('collection&operation=admin');
  148. showtableheader(cplang('collection_result').' '.$totalcount.' <a href="###" onclick="location.href=\''.ADMINSCRIPT.'?action=collection&operation=admin\';" class="act lightlink normal">'.cplang('research').'</a>', 'nobottom');
  149. showhiddenfields(array('page' => $_GET['page'], 'collection_name' => $collection_name, 'collection_ctid' => $collection_ctid, 'perpage' => $ppp));
  150. showsubtitle(array('', 'collection_name', 'collection_username', 'collection_date', 'collection_recommend'));
  151. foreach($collection as $uniquecollection) {
  152. showtablerow('', array('class="td25"', 'width=400', ''), array(
  153. "<input class=\"checkbox\" type=\"checkbox\" name=\"ctidarray[]\" value=\"$uniquecollection[ctid]\" />",
  154. "<a href='forum.php?mod=collection&action=view&ctid={$uniquecollection['ctid']}' target='_blank'>{$uniquecollection['name']}</a>",
  155. "<a href='home.php?mod=space&uid={$uniquecollection['uid']}' target='_blank'>{$uniquecollection['username']}</a>",
  156. dgmdate($uniquecollection['dateline']),
  157. "<a href='".ADMINSCRIPT."?action=collection&operation=recommend&recommentctid={$uniquecollection['ctid']}'>".cplang('collection_recommend')."</a>",
  158. ));
  159. }
  160. showtablerow('', array('class="td25" colspan="3"'), array('<input name="chkall" id="chkall" type="checkbox" class="checkbox" onclick="checkAll(\'prefix\', this.form, \'ctidarray\', \'chkall\')" /><label for="chkall">'.cplang('select_all').'</label>'));
  161. showtablerow('', array('class="td25"', 'colspan="2"'), array(
  162. cplang('operation'),
  163. '<input class="radio" type="radio" name="operate_type" value="delete"> '.cplang('delete').' '
  164. ));
  165. showsubmit('submit', 'submit', '', '', $multipage);
  166. showtablefooter();
  167. showformfooter();
  168. }
  169. } elseif($operation == 'recommend') {
  170. if(is_numeric($_GET['recommentctid'])) {
  171. $collectiondata = C::t('forum_collection')->fetch($_GET['recommentctid']);
  172. if($collectiondata['ctid']) {
  173. $collectionrecommend = $_G['setting']['collectionrecommend'] ? dunserialize($_G['setting']['collectionrecommend']) : array();
  174. $collectionrecommend['ctids'][$collectiondata['ctid']] = 0;
  175. $collectionrecommend['ctids'] = removeNonExistsCollection($collectionrecommend['ctids']);
  176. $collectionrecommend['adminrecommend'] = count($collectionrecommend['ctids']);
  177. asort($collectionrecommend['ctids']);
  178. $data = array('collectionrecommendnum' => $collectionrecommend['autorecommend']+$collectionrecommend['adminrecommend'], 'collectionrecommend' => $collectionrecommend);
  179. C::t('common_setting')->update_batch($data);
  180. updatecache('setting');
  181. savecache('collection_index', array());
  182. }
  183. cpmsg('collection_admin_updated', 'action=collection&operation=recommend', 'succeed');
  184. }
  185. if(!submitcheck('submit', 1)) {
  186. $ctidarray = array();
  187. $collectionrecommend = dunserialize($_G['setting']['collectionrecommend']);
  188. showformheader('collection&operation=recommend');
  189. showtableheader(cplang('collection_recommend_settings'), 'nobottom');
  190. showsetting('collection_recommend_index_autonumber', 'settingnew[autorecommend]', $collectionrecommend['autorecommend'] ? $collectionrecommend['autorecommend'] : 0, 'text');
  191. showtableheader(cplang('collection_recommend_existed'), 'nobottom');
  192. showhiddenfields(array('page' => $_GET['page'], 'tagname' => $tagname, 'status' => $status, 'perpage' => $ppp));
  193. showsubtitle(array('', 'collection_name', 'collection_username', 'collection_threadnum', 'collection_commentnum', 'collection_date', 'display_order'));
  194. if($collectionrecommend['ctids']) {
  195. $collectiondata = C::t('forum_collection')->fetch_all(array_keys($collectionrecommend['ctids']));
  196. foreach($collectiondata as $collection) {
  197. showtablerow('', array('class="td25"', 'width=400', ''), array(
  198. "<input class=\"checkbox\" type=\"checkbox\" name=\"ctidarray[]\" value=\"$collection[ctid]\" />",
  199. "<a href='forum.php?mod=collection&action=view&ctid={$collection['ctid']}' target='_blank'>{$collection['name']}</a>",
  200. "<a href='home.php?mod=space&uid={$collection['uid']}' target='_blank'>{$collection['username']}</a>",
  201. $collection['threadnum'],
  202. $collection['commentnum'],
  203. dgmdate($collection['dateline']),
  204. "<input class=\"txt\" type=\"text\" name=\"ctidorder[{$collection[ctid]}]\" value=\"{$collectionrecommend['ctids'][$collection[ctid]]}\" />",
  205. ));
  206. }
  207. } else {
  208. showtablerow('', array('class="td25" colspan="7" align="center"', ''), array(
  209. cplang('collection_recommend_tips'),
  210. ));
  211. }
  212. showtablerow('', array('class="td25" colspan="7"'), array('<input name="chkall" id="chkall" type="checkbox" class="checkbox" onclick="checkAll(\'prefix\', this.form, \'ctidarray\', \'chkall\')" /><label for="chkall"> '.cplang('select_all').'</label>'));
  213. showtablerow('', array('class="td25"', 'colspan="2"'), array(
  214. cplang('operation'),
  215. '<input class="checkbox" type="checkbox" name="operate_type" id="operate_type" value="delete"><label for="operate_type"> '.cplang('delete').'</label> '
  216. ));
  217. showsubmit('submit', 'submit', '', '');
  218. showtablefooter();
  219. showformfooter();
  220. } else {
  221. $collectionrecommend = $_G['setting']['collectionrecommend'] ? dunserialize($_G['setting']['collectionrecommend']) : array();
  222. foreach($collectionrecommend['ctids'] as $rCtid=>&$rCollection) {
  223. if($_GET['operate_type'] == 'delete' && in_array($rCtid, $_GET['ctidarray'])) {
  224. unset($collectionrecommend['ctids'][$rCtid]);
  225. continue;
  226. }
  227. $rCollection = $_GET['ctidorder'][$rCtid];
  228. }
  229. $collectionrecommend['ctids'] = removeNonExistsCollection($collectionrecommend['ctids']);
  230. $collectionrecommend['autorecommend'] = intval($_GET['settingnew']['autorecommend']);
  231. $collectionrecommend['adminrecommend'] = count($collectionrecommend['ctids']);
  232. asort($collectionrecommend['ctids']);
  233. $data = array('collectionrecommendnum' => $collectionrecommend['autorecommend']+$collectionrecommend['adminrecommend'], 'collectionrecommend' => $collectionrecommend);
  234. C::t('common_setting')->update_batch($data);
  235. updatecache('setting');
  236. savecache('collection_index', array());
  237. cpmsg('collection_admin_updated', 'action=collection&operation=recommend', 'succeed');
  238. }
  239. }
  240. function removeNonExistsCollection($collectionrecommend) {
  241. $tmpcollection = C::t('forum_collection')->fetch_all(array_keys($collectionrecommend));
  242. foreach($collectionrecommend as $ctid=>$setcollection) {
  243. if(!$tmpcollection[$ctid]) {
  244. unset($collectionrecommend[$ctid]);
  245. }
  246. }
  247. return $collectionrecommend;
  248. }
  249. ?>