forum_modcp.php 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  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: forum_modcp.php 28867 2012-03-16 02:27:08Z monkey $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. define('IN_MODCP', true);
  12. $cpscript = basename($_G['PHP_SELF']);
  13. if(!empty($_G['forum']) && $_G['forum']['status'] == 3) {
  14. showmessage('group_admin_enter_panel', 'forum.php?mod=group&action=manage&fid='.$_G['fid']);
  15. }
  16. $modsession = new discuz_panel(MODCP_PANEL);
  17. if(getgpc('login_panel') && getgpc('cppwd') && submitcheck('submit')) {
  18. $modsession->dologin($_G[uid], getgpc('cppwd'), true);
  19. }
  20. if(!$modsession->islogin) {
  21. $_GET['action'] = 'login';
  22. }
  23. if($_GET['action'] == 'logout') {
  24. $modsession->dologout();
  25. showmessage('modcp_logout_succeed', 'forum.php');
  26. }
  27. $modforums = $modsession->get('modforums');
  28. $_GET['action'] = empty($_GET['action']) && $_G['fid'] ? 'thread' : $_GET['action'];
  29. $op = getgpc('op');
  30. if($modforums === null) {
  31. $modforums = array('fids' => '', 'list' => array(), 'recyclebins' => array());
  32. $comma = '';
  33. if($_G['adminid'] == 3) {
  34. foreach(C::t('forum_moderator')->fetch_all_by_uid_forum($_G['uid']) as $tforum) {
  35. $modforums['fids'] .= $comma.$tforum['fid']; $comma = ',';
  36. $modforums['recyclebins'][$tforum['fid']] = $tforum['recyclebin'];
  37. $modforums['list'][$tforum['fid']] = strip_tags($tforum['name']);
  38. }
  39. } else {
  40. $query = C::t('forum_forum')->fetch_all_info_by_fids(0, 1, 0, 0, 0, 1, 1);
  41. if(!empty($_G['member']['accessmasks'])) {
  42. $fids = array_keys($query);
  43. $accesslist = C::t('forum_access')->fetch_all_by_fid_uid($fids, $_G['uid']);
  44. foreach($query as $key => $val) {
  45. $query[$key]['allowview'] = $accesslist[$key];
  46. }
  47. }
  48. foreach($query as $tforum) {
  49. $tforum['allowview'] = !isset($tforum['allowview']) ? '' : $tforum['allowview'];
  50. if($tforum['allowview'] == 1 || ($tforum['allowview'] == 0 && ((!$tforum['viewperm'] && $_G['group']['readaccess']) || ($tforum['viewperm'] && forumperm($tforum['viewperm']))))) {
  51. $modforums['fids'] .= $comma.$tforum['fid']; $comma = ',';
  52. $modforums['recyclebins'][$tforum['fid']] = $tforum['recyclebin'];
  53. $modforums['list'][$tforum['fid']] = strip_tags($tforum['name']);
  54. }
  55. }
  56. }
  57. $modsession->set('modforums', $modforums, true);
  58. }
  59. $threadclasslist = array();
  60. if($_G['fid'] && in_array($_G['fid'], explode(',', $modforums['fids']))) {
  61. foreach(C::t('forum_threadclass')->fetch_all_by_fid($_G['fid']) as $tc) {
  62. $threadclasslist[] = $tc;
  63. }
  64. }
  65. if($_G['fid'] && $_G['forum']['ismoderator']) {
  66. dsetcookie('modcpfid', $_G['fid']);
  67. $forcefid = "&amp;fid=$_G[fid]";
  68. } elseif(!empty($modforums) && count($modforums['list']) == 1) {
  69. $forcefid = "&amp;fid=$modforums[fids]";
  70. } else {
  71. $forcefid = '';
  72. }
  73. $script = $modtpl = '';
  74. switch ($_GET['action']) {
  75. case 'announcement':
  76. $_G['group']['allowpostannounce'] && $script = 'announcement';
  77. break;
  78. case 'member':
  79. $op == 'edit' && $_G['group']['allowedituser'] && $script = 'member';
  80. $op == 'ban' && ($_G['group']['allowbanuser'] || $_G['group']['allowbanvisituser']) && $script = 'member';
  81. $op == 'ipban' && $_G['group']['allowbanip'] && $script = 'member';
  82. break;
  83. case 'moderate':
  84. ($op == 'threads' || $op == 'replies') && $_G['group']['allowmodpost'] && $script = 'moderate';
  85. $op == 'members' && $_G['group']['allowmoduser'] && $script = 'moderate';
  86. break;
  87. case 'forum':
  88. $op == 'editforum' && $_G['group']['alloweditforum'] && $script = 'forum';
  89. $op == 'recommend' && $_G['group']['allowrecommendthread'] && $script = 'forum';
  90. break;
  91. case 'forumaccess':
  92. $_G['group']['allowedituser'] && $script = 'forumaccess';
  93. break;
  94. case 'log':
  95. $_G['group']['allowviewlog'] && $script = 'log';
  96. break;
  97. case 'login':
  98. $script = $modsession->islogin ? 'home' : 'login';
  99. break;
  100. case 'thread':
  101. $script = 'thread';
  102. break;
  103. case 'recyclebin':
  104. $script = 'recyclebin';
  105. break;
  106. case 'recyclebinpost':
  107. $script = 'recyclebinpost';
  108. break;
  109. case 'plugin':
  110. $script = 'plugin';
  111. break;
  112. case 'report':
  113. $script = 'report';
  114. break;
  115. default:
  116. $_GET['action'] = $script = 'home';
  117. $modtpl = 'modcp_home';
  118. }
  119. $script = empty($script) ? 'noperm' : $script;
  120. $modtpl = empty($modtpl) ? (!empty($script) ? 'modcp_'.$script : '') : $modtpl;
  121. $modtpl = 'forum/' . $modtpl;
  122. $op = isset($op) ? trim($op) : '';
  123. if($script != 'log') {
  124. include libfile('function/misc');
  125. $extra = implodearray(array('GET' => $_GET, 'POST' => $_POST), array('cppwd', 'formhash', 'submit', 'addsubmit'));
  126. $modcplog = array(TIMESTAMP, $_G['username'], $_G['adminid'], $_G['clientip'], $_GET['action'], $op, $_G['fid'], $extra);
  127. writelog('modcp', implode("\t", clearlogstring($modcplog)));
  128. }
  129. require DISCUZ_ROOT.'./source/include/modcp/modcp_'.$script.'.php';
  130. $reportnum = $modpostnum = $modthreadnum = $modforumnum = 0;
  131. $modforumnum = count($modforums['list']);
  132. $modnum = '';
  133. if($modforumnum) {
  134. if(!empty($_G['setting']['moddetail'])) {
  135. if($_G['group']['allowmodpost']) {
  136. $modnum = C::t('common_moderate')->count_by_idtype_status_fid('tid', 0, explode(',', $modforums['fids']));
  137. $modnum += C::t('common_moderate')->count_by_idtype_status_fid('pid', 0, explode(',', $modforums['fids']));
  138. }
  139. if($_G['group']['allowmoduser']) {
  140. $modnum += C::t('common_member_validate')->count_by_status(0);
  141. }
  142. }
  143. }
  144. switch($_G['adminid']) {
  145. case 1: $access = '1,2,3,4,5,6,7'; break;
  146. case 2: $access = '2,3,6,7'; break;
  147. default: $access = '1,3,5,7'; break;
  148. }
  149. $notenum = C::t('common_adminnote')->count_by_access(explode(',', $access));
  150. include template('forum/modcp');
  151. function getposttableselect() {
  152. global $_G;
  153. loadcache('posttable_info');
  154. if(!empty($_G['cache']['posttable_info']) && is_array($_G['cache']['posttable_info'])) {
  155. $posttableselect = '<select name="posttableid" id="posttableid" class="ps">';
  156. foreach($_G['cache']['posttable_info'] as $posttableid => $data) {
  157. $posttableselect .= '<option value="'.$posttableid.'"'.($_GET['posttableid'] == $posttableid ? ' selected="selected"' : '').'>'.($data['memo'] ? $data['memo'] : 'post_'.$posttableid).'</option>';
  158. }
  159. $posttableselect .= '</select>';
  160. } else {
  161. $posttableselect = '';
  162. }
  163. return $posttableselect;
  164. }
  165. ?>