-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodcp.php
executable file
·181 lines (148 loc) · 5.85 KB
/
modcp.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: modcp.php 21068 2009-11-10 04:48:56Z monkey $
*/
define('NOROBOT', TRUE);
define('IN_MODCP', true);
define('CURSCRIPT', 'modcp');
$action = !empty($_REQUEST['action']) ? (!empty($_GET['action']) ? $_GET['action'] : '') : (!empty($_POST['action']) ? $_POST['action'] : '');
require_once './include/common.inc.php';
require_once './admin/cpanel.share.php';
$discuz_action = 210;
$action = empty($action) && $fid ? 'threads' : $action;
$cpscript = basename($PHP_SELF);
$modsession = new AdminSession($discuz_uid, $groupid, $adminid, $onlineip);
if($modsession->cpaccess == 1) {
if($action == 'login' && $cppwd && submitcheck('submit')) {
require_once DISCUZ_ROOT.'./uc_client/client.php';
$ucresult = uc_user_login($discuz_uid, $cppwd, 1);
if($ucresult[0] > 0) {
$modsession->errorcount = '-1';
$url_forward = $modsession->get('url_forward');
$modsession->clear(true);
$url_forward && dheader("Location: $cpscript?$url_forward");
$action = 'home';
} else{
$modsession->errorcount ++;
$modsession->update();
}
} else {
$action = 'login';
}
}
if($action == 'logout') {
$modsession->destroy();
showmessage('modcp_logout_succeed', $indexname);
}
$modforums = $modsession->get('modforums');
if($modforums === null) {
$modforums = array('fids' => '', 'list' => array(), 'recyclebins' => array());
$comma = '';
if($adminid == 3) {
$query = $db->query("SELECT m.fid, f.name, f.recyclebin
FROM {$tablepre}moderators m
LEFT JOIN {$tablepre}forums f ON f.fid=m.fid
WHERE m.uid='$discuz_uid' AND f.status='1' AND f.type<>'group'");
while($tforum = $db->fetch_array($query)) {
$modforums['fids'] .= $comma.$tforum['fid']; $comma = ',';
$modforums['recyclebins'][$tforum['fid']] = $tforum['recyclebin'];
$modforums['list'][$tforum['fid']] = strip_tags($tforum['name']);
}
} else {
$sql = !empty($accessmasks) ?
"SELECT f.fid, f.name, f.threads, f.recyclebin, ff.viewperm, a.allowview FROM {$tablepre}forums f
LEFT JOIN {$tablepre}forumfields ff ON ff.fid=f.fid
LEFT JOIN {$tablepre}access a ON a.uid='$discuz_uid' AND a.fid=f.fid
WHERE f.status='1' AND ff.redirect=''"
: "SELECT f.fid, f.name, f.threads, f.recyclebin, ff.viewperm, ff.redirect FROM {$tablepre}forums f
LEFT JOIN {$tablepre}forumfields ff USING(fid)
WHERE f.status='1' AND f.type<>'group' AND ff.redirect=''";
$query = $db->query($sql);
while ($tforum = $db->fetch_array($query)) {
if($tforum['allowview'] == 1 || ($tforum['allowview'] == 0 && ((!$tforum['viewperm'] && $readaccess) || ($tforum['viewperm'] && forumperm($tforum['viewperm']))))) {
$modforums['fids'] .= $comma.$tforum['fid']; $comma = ',';
$modforums['recyclebins'][$tforum['fid']] = $tforum['recyclebin'];
$modforums['list'][$tforum['fid']] = strip_tags($tforum['name']);
}
}
}
$modsession->set('modforums', $modforums, true);
}
if($fid && $forum['ismoderator']) {
dsetcookie('modcpfid', $fid);
$forcefid = "&fid=$fid";
} elseif(!empty($modforums) && count($modforums['list']) == 1) {
$forcefid = "&fid=$modforums[fids]";
} else {
$forcefid = '';
}
$script = $modtpl = '';
switch ($action) {
case 'announcements':
$allowpostannounce && $script = 'announcements';
break;
case 'members':
$op == 'edit' && $allowedituser && $script = 'members';
$op == 'ban' && $allowbanuser && $script = 'members';
$op == 'ipban' && $allowbanip && $script = 'members';
break;
case 'report':
$allowviewreport && $script = 'report';
break;
case 'moderate':
($op == 'threads' || $op == 'replies') && $allowmodpost && $script = 'moderate';
$op == 'members' && $allowmoduser && $script = 'moderate';
break;
case 'forums':
$op == 'editforum' && $alloweditforum && $script = 'forums';
$op == 'recommend' && $allowrecommendthread && $script = 'forums';
break;
case 'forumaccess':
$allowedituser && $script = 'forumaccess';
break;
case 'logs':
$allowviewlog && $script = 'logs';
break;
case 'login':
$script = $modsession->cpaccess == 1 ? 'login' : 'home';
break;
case 'threads':
$script = 'threads';
break;
case 'recyclebins':
$script = 'recyclebins';
break;
case 'plugin':
$script = 'plugin';
break;
default:
$action = $script = 'home';
$modtpl = 'modcp_home';
}
$script = empty($script) ? 'noperm' : $script;
$modtpl = empty($modtpl) ? (!empty($script) ? 'modcp_'.$script : '') : $modtpl;
$op = isset($op) ? trim($op) : '';
if($script != 'logs') {
$extra = implodearray(array('GET' => $_GET, 'POST' => $_POST), array('cppwd', 'formhash', 'submit', 'addsubmit'));
$modcplog = array($timestamp, $discuz_user, $adminid, $onlineip, $action, $op, $fid, $extra);
writelog('modcp', implode("\t", clearlogstring($modcplog)));
}
require DISCUZ_ROOT.'./modcp/'.$script.'.inc.php';
$reportnum = $modpostnum = $modthreadnum = $modforumnum = 0;
$modforumnum = count($modforums['list']);
if($modforumnum) {
$reportnum = $db->result_first("SELECT COUNT(*) FROM {$tablepre}reportlog WHERE fid IN($modforums[fids]) AND status='1'");
$modnum = ($allowmodpost ? ($db->result_first("SELECT COUNT(*) FROM {$tablepre}posts WHERE invisible='-2' AND first='0' and fid IN($modforums[fids])") +
$db->result_first("SELECT COUNT(*) FROM {$tablepre}threads WHERE fid IN($modforums[fids]) AND displayorder='-2'")) : 0) +
($allowmoduser ? $db->result_first("SELECT COUNT(*) FROM {$tablepre}validating WHERE status='0'") : 0);
}
switch($adminid) {
case 1: $access = '1,2,3,4,5,6,7'; break;
case 2: $access = '2,3,6,7'; break;
default: $access = '1,3,5,7'; break;
}
$notenum = $db->result_first("SELECT COUNT(*) FROM {$tablepre}adminnotes WHERE access IN ($access)");
include template('modcp');
?>