-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmanagemembers.php
319 lines (277 loc) · 11.7 KB
/
managemembers.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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
<?php
/*
Viscacha - A bulletin board solution for easily managing your content
Copyright (C) 2004-2009 The Viscacha Project
Author: Matthias Mohr (et al.)
Publisher: The Viscacha Project, http://www.viscacha.org
Start Date: May 22, 2004
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
error_reporting(E_ALL);
define('SCRIPTNAME', 'managemembers');
define('VISCACHA_CORE', '1');
include ("data/config.inc.php");
include ("classes/function.viscacha_frontend.php");
$my->p = $slog->Permissions();
include_once ("classes/function.profilefields.php");
$breadcrumb->Add($lang->phrase('teamcp'));
echo $tpl->parse("header");
($code = $plugins->load('managemembers_start')) ? eval($code) : null;
if (!$my->vlogin || $my->p['admin'] == 0) {
errorLogin($lang->phrase('not_allowed'));
}
$result = $db->query('SELECT * FROM '.$db->pre.'user WHERE id = '.$_GET['id']);
if ($db->num_rows($result) != 1) {
error($lang->phrase('no_id_given'), 'members.php'.SID2URL_1);
}
$user = $gpc->prepare($db->fetch_assoc($result));
($code = $plugins->load('managemembers_prepare')) ? eval($code) : null;
if ($_GET['action'] == 'delete') {
if ($my->id == $user['id']) {
error($lang->phrase('member_delete_yourself_error'));
}
echo $tpl->parse("menu");
echo $tpl->parse("admin/members/delete");
}
elseif ($_GET['action'] == 'recount') {
$posts = UpdateMemberStats($user['id']);
$diff = $posts - $user['posts'];
ok($lang->phrase('member_recount_ok'), 'profile.php?id='.$user['id'].SID2URL_x);
}
elseif ($_GET['action'] == 'delete2') {
if ($my->id == $user['id']) {
error($lang->phrase('member_delete_yourself_error'));
}
// Step 1: Write Data to File with old Usernames
$olduserdata = file_get_contents('data/deleteduser.php');
$olduserdata .= "\n{$user['id']}\t".$user['name'];
$olduserdata = trim($olduserdata);
file_put_contents('data/deleteduser.php', $olduserdata);
// Step 2: Delete all abos
$db->query("DELETE FROM {$db->pre}abos WHERE mid = '{$user['id']}'");
// Step 4: Delete as mod
$db->query("DELETE FROM {$db->pre}moderators WHERE mid = '{$user['id']}'");
// Step 5: Delete all pms
$db->query("DELETE FROM {$db->pre}pm WHERE pm_to = '{$user['id']}'");
// Step 6: Search all old posts by an user, and update to guests post
$db->query("UPDATE {$db->pre}replies SET name = '{$user['name']}', email = '{$user['mail']}', guest = '1' WHERE name = '{$user['id']}' AND guest = '0'");
// Step 7: Search all old topics by an user, and update to guests post
$db->query("UPDATE {$db->pre}topics SET name = '{$user['name']}' WHERE name = '{$user['id']}'");
$db->query("UPDATE {$db->pre}topics SET last_name = '{$user['name']}' WHERE last_name = '{$user['id']}'");
// Step 8: Set uploads from member to guests-group
$db->query("UPDATE {$db->pre}uploads SET mid = '0' WHERE mid = '{$user['id']}'");
// Step 9: Set post ratings from member to guests-group I
$db->query("UPDATE {$db->pre}postratings SET mid = '0' WHERE mid = '{$user['id']}'");
// Step 10: Set post ratings from member to guests-group II
$db->query("UPDATE {$db->pre}postratings SET aid = '0' WHERE aid = '{$user['id']}'");
// Step 11: Delete pic
removeOldImages('uploads/pics/', $user['id']);
// Step 12: Delete user himself
$db->query("DELETE FROM {$db->pre}user WHERE id = '{$user['id']}'");
// Step 13: Delete user's custom profilefields
$db->query("DELETE FROM {$db->pre}userfields WHERE ufid = '{$user['id']}'");
$cache = $scache->load('memberdata');
$cache = $cache->delete();
($code = $plugins->load('managemembers_delete_end')) ? eval($code) : null;
ok($lang->phrase('member_deleted'),'members.php'.SID2URL_1);
}
elseif ($_GET['action'] == 'edit') {
$lang->group("timezones");
$chars = numbers($config['maxaboutlength']);
BBProfile($bbcode);
($code = $plugins->load('managemembers_edit_start')) ? eval($code) : null;
if (empty($user['template'])) {
$user['template'] = $config['templatedir'];
}
if (empty($user['language'])) {
$user['language'] = $config['langdir'];
}
// Settings
$loaddesign_obj = $scache->load('loaddesign');
$design = $loaddesign_obj->get();
$mydesign = $design[$user['template']]['name'];
$loadlanguage_obj = $scache->load('loadlanguage');
$language = $loadlanguage_obj->get();
$mylanguage = $language[$user['language']]['language'];
// Profile
$bday = explode('-',$user['birthday']);
$year = gmdate('Y');
$maxy = $year-6;
$miny = $year-100;
$result = $db->query("SELECT id, title, name, core FROM {$db->pre}groups ORDER BY admin DESC , guest ASC , core ASC");
if (!isset($user['timezone']) || $user['timezone'] === null) {
$user['timezone'] = $config['timezone'];
}
$random = md5(microtime());
$customfields = admin_customfields($user['id']);
echo $tpl->parse("menu");
($code = $plugins->load('managemembers_edit_prepared')) ? eval($code) : null;
echo $tpl->parse("admin/members/edit");
($code = $plugins->load('managemembers_edit_end')) ? eval($code) : null;
}
elseif ($_GET['action'] == 'edit2') {
$loaddesign_obj = $scache->load('loaddesign');
$cache = $loaddesign_obj->get();
$loadlanguage_obj = $scache->load('loadlanguage');
$cache2 = $loadlanguage_obj->get();
$_POST['hp'] = trim($_POST['hp']);
if (strtolower(substr($_POST['hp'], 0, 4)) == 'www.') {
$_POST['hp'] = "http://{$_POST['hp']}";
}
$random = $gpc->get('random', none);
$name = $gpc->get('name_'.$random, str);
if (empty($name)) {
$_POST['name'] = $user['name'];
}
else {
$_POST['name'] = $name;
}
$_POST['pw'] = $gpc->get('pw_'.$random, str);
$error = array();
if (strxlen($_POST['comment']) > $config['maxaboutlength']) {
$error[] = $lang->phrase('about_too_long');
}
if (check_mail($_POST['email']) == false) {
$error[] = $lang->phrase('illegal_mail');
}
if ($user['mail'] != $_POST['email'] && double_udata('mail', $_POST['email']) == false) {
$error[] = $lang->phrase('email_already_used');
}
if (strxlen($_POST['name']) > $config['maxnamelength']) {
$error[] = $lang->phrase('name_too_long');
}
if (strxlen($_POST['name']) < $config['minnamelength']) {
$error[] = $lang->phrase('name_too_short');
}
if (strlen($_POST['email']) > 200) {
$error[] = $lang->phrase('email_too_long');
}
if (strxlen($_POST['signature']) > $config['maxsiglength']) {
$error[] = $lang->phrase('editprofile_signature_too_long');
}
if (strlen($_POST['hp']) > 255) {
$error[] = $lang->phrase('editprofile_homepage_too_long');
}
if (!check_hp($_POST['hp'])) {
$_POST['hp'] = '';
}
if (strlen($_POST['location']) > 50) {
$error[] = $lang->phrase('editprofile_location_too_long');
}
if ($_POST['gender'] != 'm' && $_POST['gender'] != 'w' && $_POST['gender'] != '') {
$error[] = $lang->phrase('editprofile_gender_incorrect');
}
if ($_POST['birthday'] > 31) {
$error[] = $lang->phrase('editprofile_birthday_incorrect');
}
if ($_POST['birthmonth'] > 12) {
$error[] = $lang->phrase('editprofile_birthmonth_incorrect');
}
if (($_POST['birthyear'] < gmdate('Y')-120 || $_POST['birthyear'] > gmdate('Y')) && $_POST['birthyear'] != 0 ) {
$error[] = $lang->phrase('editprofile_birthyear_incorrect');
}
if (strlen($_POST['fullname']) > 128) {
$error[] = $lang->phrase('editprofile_fullname_incorrect');
}
if (intval($_POST['temp']) < -12 && intval($_POST['temp']) > 12) {
$error[] = $lang->phrase('editprofile_settings_error').$lang->phrase('timezone');
}
if ($_POST['opt_0'] < 0 && $_POST['opt_0'] > 2) {
$error[] = $lang->phrase('editprofile_settings_error').$lang->phrase('editprofile_editor');
}
if ($_POST['opt_1'] != 0 && $_POST['opt_1'] != 1) {
$error[] = $lang->phrase('editprofile_settings_error').$lang->phrase('editprofile_emailpn');
}
if ($_POST['opt_2'] != 0 && $_POST['opt_2'] != 1) {
$error[] = $lang->phrase('editprofile_settings_error').$lang->phrase('editprofile_bad');
}
if ($_POST['opt_3'] < 0 && $_POST['opt_3'] > 2) {
$error[] = $lang->phrase('editprofile_settings_error').$lang->phrase('editprofile_showmail');
}
if (!isset($cache[$_POST['opt_4']])) {
$error[] = $lang->phrase('editprofile_settings_error').$lang->phrase('editprofile_design');
}
if (!isset($cache2[$_POST['opt_5']])) {
$error[] = $lang->phrase('editprofile_settings_error').$lang->phrase('editprofile_language');
}
if (!empty($_POST['pic']) && preg_match('~^'.URL_REGEXP.'$~i', $_POST['pic'])) {
$_POST['pic'] = checkRemotePic($_POST['pic'], $_GET['id'], "managemembers.php?action=edit&id=".$_GET['id']);
switch ($_POST['pic']) {
case REMOTE_INVALID_URL:
$error[] = $lang->phrase('editprofile_pic_error1');
$_POST['pic'] = '';
break;
case REMOTE_CLIENT_ERROR:
$error[] = $lang->phrase('editprofile_pic_error2');
$_POST['pic'] = '';
break;
case REMOTE_FILESIZE_ERROR:
case REMOTE_IMAGE_HEIGHT_ERROR:
case REMOTE_IMAGE_WIDTH_ERROR:
case REMOTE_EXTENSION_ERROR:
$error[] = $lang->phrase('editprofile_pic_error3');
$_POST['pic'] = '';
break;
case REMOTE_IMAGE_ERROR:
$error[] = $lang->phrase('editprofile_pic_error4');
$_POST['pic'] = '';
break;
}
}
elseif (empty($_POST['pic']) || !file_exists($_POST['pic'])) {
$_POST['pic'] = '';
}
($code = $plugins->load('managemembers_edit2_errorhandling')) ? eval($code) : null;
if (count($error) > 0) {
($code = $plugins->load('managemembers_edit2_errordata')) ? eval($code) : null;
error($error);
}
else {
// Now we create the birthday...
if (empty($_POST['birthmonth']) || empty($_POST['birthday'])) {
$_POST['birthmonth'] = 0;
$_POST['birthday'] = 0;
$_POST['birthyear'] = 0;
}
if (empty($_POST['birthyear'])) {
$_POST['birthyear'] = 1000;
}
$_POST['birthmonth'] = leading_zero($_POST['birthmonth']);
$_POST['birthday'] = leading_zero($_POST['birthday']);
$_POST['birthyear'] = leading_zero($_POST['birthyear'], 4);
$bday = $_POST['birthyear'].'-'.$_POST['birthmonth'].'-'.$_POST['birthday'];
if (!empty($_POST['pw']) && strxlen($_POST['pw']) >= $config['minpwlength']) {
$md5 = md5($_POST['pw']);
$update_sql = ", pw = '{$md5}' ";
}
else {
$update_sql = ' ';
}
admin_customsave($user['id']);
($code = $plugins->load('managemembers_edit2_savedata')) ? eval($code) : null;
$db->query("UPDATE {$db->pre}user SET groups = '".saveCommaSeparated($gpc->get('groups', db_esc))."', timezone = '{$_POST['temp']}', opt_textarea = '{$_POST['opt_0']}', opt_pmnotify = '{$_POST['opt_1']}', opt_hidebad = '{$_POST['opt_2']}', opt_hidemail = '{$_POST['opt_3']}', template = '{$_POST['opt_4']}', language = '{$_POST['opt_5']}', pic = '{$_POST['pic']}', about = '{$_POST['comment']}', jabber = '{$_POST['jabber']}', skype = '{$_POST['skype']}', birthday = '{$bday}', gender = '{$_POST['gender']}', hp = '{$_POST['hp']}', signature = '{$_POST['signature']}', location = '{$_POST['location']}', fullname = '{$_POST['fullname']}', mail = '{$_POST['email']}', name = '{$_POST['name']}' {$update_sql} WHERE id = '{$user['id']}'");
$cache = $scache->load('memberdata');
$cache = $cache->delete();
ok($lang->phrase('data_success'), "profile.php?id=".$user['id']);
}
}
else {
($code = $plugins->load('managemembers_end')) ? eval($code) : null;
error($lang->phrase('docs_not_found'), "profile.php?id={$user['id']}");
}
$slog->updatelogged();
$zeitmessung = t2();
echo $tpl->parse("footer");
$phpdoc->Out();
$db->close();
?>