Commit | Line | Data |
---|---|---|
c495c100 P |
1 | <?php |
2 | /*********************************************************************** | |
3 | ||
4 | Copyright (C) 2002-2005 Rickard Andersson (rickard@punbb.org) | |
5 | ||
6 | This file is part of PunBB. | |
7 | ||
8 | PunBB is free software; you can redistribute it and/or modify it | |
9 | under the terms of the GNU General Public License as published | |
10 | by the Free Software Foundation; either version 2 of the License, | |
11 | or (at your option) any later version. | |
12 | ||
13 | PunBB is distributed in the hope that it will be useful, but | |
14 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | GNU General Public License for more details. | |
17 | ||
18 | You should have received a copy of the GNU General Public License | |
19 | along with this program; if not, write to the Free Software | |
20 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, | |
21 | MA 02111-1307 USA | |
22 | ||
23 | ************************************************************************/ | |
24 | ||
25 | ||
26 | define('PUN_ROOT', './'); | |
27 | require PUN_ROOT.'include/common.php'; | |
28 | ||
29 | ||
30 | $action = isset($_GET['action']) ? $_GET['action'] : null; | |
31 | $section = isset($_GET['section']) ? $_GET['section'] : null; | |
32 | $id = isset($_GET['id']) ? intval($_GET['id']) : 0; | |
33 | if ($id < 2) | |
34 | message($lang_common['Bad request']); | |
35 | ||
36 | if ($pun_user['g_read_board'] == '0' && ($action != 'change_pass' || !isset($_GET['key']))) | |
37 | message($lang_common['No view']); | |
38 | ||
39 | // Load the profile.php/register.php language file | |
40 | require PUN_ROOT.'lang/'.$pun_user['language'].'/prof_reg.php'; | |
41 | ||
42 | // Load the profile.php language file | |
43 | require PUN_ROOT.'lang/'.$pun_user['language'].'/profile.php'; | |
44 | ||
45 | ||
46 | if ($action == 'change_pass') | |
47 | { | |
48 | if (isset($_GET['key'])) | |
49 | { | |
50 | // If the user is already logged in we shouldn't be here :) | |
51 | if (!$pun_user['is_guest']) | |
52 | { | |
53 | header('Location: index.php'); | |
54 | exit; | |
55 | } | |
56 | ||
57 | $key = $_GET['key']; | |
58 | ||
59 | $result = $db->query('SELECT activate_string, activate_key FROM '.$db->prefix.'users WHERE id='.$id) or error('Unable to fetch new password', __FILE__, __LINE__, $db->error()); | |
60 | list($new_password_hash, $new_password_key) = $db->fetch_row($result); | |
61 | ||
62 | if ($key == '' || $key != $new_password_key) | |
63 | message($lang_profile['Pass key bad'].' <a href="mailto:'.$pun_config['o_admin_email'].'">'.$pun_config['o_admin_email'].'</a>.'); | |
64 | else | |
65 | { | |
66 | $db->query('UPDATE '.$db->prefix.'users SET password=\''.$new_password_hash.'\', activate_string=NULL, activate_key=NULL WHERE id='.$id) or error('Unable to update password', __FILE__, __LINE__, $db->error()); | |
67 | ||
68 | message($lang_profile['Pass updated'], true); | |
69 | } | |
70 | } | |
71 | ||
72 | // Make sure we are allowed to change this users password | |
73 | if ($pun_user['id'] != $id) | |
74 | { | |
75 | if ($pun_user['g_id'] > PUN_MOD) // A regular user trying to change another users password? | |
76 | message($lang_common['No permission']); | |
77 | else if ($pun_user['g_id'] == PUN_MOD) // A moderator trying to change a users password? | |
78 | { | |
79 | $result = $db->query('SELECT group_id FROM '.$db->prefix.'users WHERE id='.$id) or error('Unable to fetch user info', __FILE__, __LINE__, $db->error()); | |
80 | if (!$db->num_rows($result)) | |
81 | message($lang_common['Bad request']); | |
82 | ||
83 | if ($pun_config['p_mod_edit_users'] == '0' || $pun_config['p_mod_change_passwords'] == '0' || $db->result($result) < PUN_GUEST) | |
84 | message($lang_common['No permission']); | |
85 | } | |
86 | } | |
87 | ||
88 | if (isset($_POST['form_sent'])) | |
89 | { | |
90 | if ($pun_user['g_id'] < PUN_GUEST) | |
91 | confirm_referrer('profile.php'); | |
92 | ||
93 | $old_password = isset($_POST['req_old_password']) ? trim($_POST['req_old_password']) : ''; | |
94 | $new_password1 = trim($_POST['req_new_password1']); | |
95 | $new_password2 = trim($_POST['req_new_password2']); | |
96 | ||
97 | if ($new_password1 != $new_password2) | |
98 | message($lang_prof_reg['Pass not match']); | |
99 | if (strlen($new_password1) < 4) | |
100 | message($lang_prof_reg['Pass too short']); | |
101 | ||
102 | $result = $db->query('SELECT password, save_pass FROM '.$db->prefix.'users WHERE id='.$id) or error('Unable to fetch password', __FILE__, __LINE__, $db->error()); | |
103 | list($db_password_hash, $save_pass) = $db->fetch_row($result); | |
104 | ||
105 | $authorized = false; | |
106 | ||
107 | if (!empty($db_password_hash)) | |
108 | { | |
109 | $sha1_in_db = (strlen($db_password_hash) == 40) ? true : false; | |
110 | $sha1_available = (function_exists('sha1') || function_exists('mhash')) ? true : false; | |
111 | ||
112 | $old_password_hash = pun_hash($old_password); // This could result in either an SHA-1 or an MD5 hash | |
113 | ||
114 | if (($sha1_in_db && $sha1_available && $db_password_hash == $old_password_hash) || | |
115 | (!$sha1_in_db && $db_password_hash == md5($old_password)) || | |
116 | $pun_user['g_id'] < PUN_GUEST) | |
117 | $authorized = true; | |
118 | } | |
119 | ||
120 | if (!$authorized) | |
121 | message($lang_profile['Wrong pass']); | |
122 | ||
123 | $new_password_hash = pun_hash($new_password1); | |
124 | ||
125 | $db->query('UPDATE '.$db->prefix.'users SET password=\''.$new_password_hash.'\' WHERE id='.$id) or error('Unable to update password', __FILE__, __LINE__, $db->error()); | |
126 | ||
127 | if ($pun_user['id'] == $id) | |
128 | { | |
129 | $expire = ($save_pass == '1') ? time() + 31536000 : 0; | |
130 | pun_setcookie($pun_user['id'], $new_password_hash, $expire); | |
131 | } | |
132 | ||
133 | redirect('profile.php?section=essentials&id='.$id, $lang_profile['Pass updated redirect']); | |
134 | } | |
135 | ||
136 | $page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / '.$lang_common['Profile']; | |
137 | $required_fields = array('req_old_password' => $lang_profile['Old pass'], 'req_new_password1' => $lang_profile['New pass'], 'req_new_password2' => $lang_profile['Confirm new pass']); | |
138 | $focus_element = array('change_pass', (($pun_user['g_id'] > PUN_MOD) ? 'req_old_password' : 'req_new_password1')); | |
139 | require PUN_ROOT.'header.php'; | |
140 | ||
141 | ?> | |
142 | <div class="blockform"> | |
143 | <h2><span><?php echo $lang_profile['Change pass'] ?></span></h2> | |
144 | <div class="box"> | |
145 | <form id="change_pass" method="post" action="profile.php?action=change_pass&id=<?php echo $id ?>" onsubmit="return process_form(this)"> | |
146 | <div class="inform"> | |
147 | <input type="hidden" name="form_sent" value="1" /> | |
148 | <fieldset> | |
149 | <legend><?php echo $lang_profile['Change pass legend'] ?></legend> | |
150 | <div class="infldset"> | |
151 | <?php if ($pun_user['g_id'] > PUN_MOD): ?> <label><strong><?php echo $lang_profile['Old pass'] ?></strong><br /> | |
152 | <input type="password" name="req_old_password" size="16" maxlength="16" /><br /></label> | |
153 | <?php endif; ?> <label class="conl"><strong><?php echo $lang_profile['New pass'] ?></strong><br /> | |
154 | <input type="password" name="req_new_password1" size="16" maxlength="16" /><br /></label> | |
155 | <label class="conl"><strong><?php echo $lang_profile['Confirm new pass'] ?></strong><br /> | |
156 | <input type="password" name="req_new_password2" size="16" maxlength="16" /><br /></label> | |
157 | <div class="clearb"></div> | |
158 | </div> | |
159 | </fieldset> | |
160 | </div> | |
161 | <p><input type="submit" name="update" value="<?php echo $lang_common['Submit'] ?>" /><a href="javascript:history.go(-1)"><?php echo $lang_common['Go back'] ?></a></p> | |
162 | </form> | |
163 | </div> | |
164 | </div> | |
165 | <?php | |
166 | ||
167 | require PUN_ROOT.'footer.php'; | |
168 | } | |
169 | ||
170 | ||
171 | else if ($action == 'change_email') | |
172 | { | |
173 | // Make sure we are allowed to change this users e-mail | |
174 | if ($pun_user['id'] != $id) | |
175 | { | |
176 | if ($pun_user['g_id'] > PUN_MOD) // A regular user trying to change another users e-mail? | |
177 | message($lang_common['No permission']); | |
178 | else if ($pun_user['g_id'] == PUN_MOD) // A moderator trying to change a users e-mail? | |
179 | { | |
180 | $result = $db->query('SELECT group_id FROM '.$db->prefix.'users WHERE id='.$id) or error('Unable to fetch user info', __FILE__, __LINE__, $db->error()); | |
181 | if (!$db->num_rows($result)) | |
182 | message($lang_common['Bad request']); | |
183 | ||
184 | if ($pun_config['p_mod_edit_users'] == '0' || $db->result($result) < PUN_GUEST) | |
185 | message($lang_common['No permission']); | |
186 | } | |
187 | } | |
188 | ||
189 | if (isset($_GET['key'])) | |
190 | { | |
191 | $key = $_GET['key']; | |
192 | ||
193 | $result = $db->query('SELECT activate_string, activate_key FROM '.$db->prefix.'users WHERE id='.$id) or error('Unable to fetch activation data', __FILE__, __LINE__, $db->error()); | |
194 | list($new_email, $new_email_key) = $db->fetch_row($result); | |
195 | ||
196 | if ($key == '' || $key != $new_email_key) | |
197 | message($lang_profile['E-mail key bad'].' <a href="mailto:'.$pun_config['o_admin_email'].'">'.$pun_config['o_admin_email'].'</a>.'); | |
198 | else | |
199 | { | |
200 | $db->query('UPDATE '.$db->prefix.'users SET email=activate_string, activate_string=NULL, activate_key=NULL WHERE id='.$id) or error('Unable to update e-mail address', __FILE__, __LINE__, $db->error()); | |
201 | ||
202 | message($lang_profile['E-mail updated'], true); | |
203 | } | |
204 | } | |
205 | else if (isset($_POST['form_sent'])) | |
206 | { | |
207 | if (pun_hash($_POST['req_password']) !== $pun_user['password']) | |
208 | message($lang_profile['Wrong pass']); | |
209 | ||
210 | require PUN_ROOT.'include/email.php'; | |
211 | ||
212 | // Validate the email-address | |
213 | $new_email = strtolower(trim($_POST['req_new_email'])); | |
214 | if (!is_valid_email($new_email)) | |
215 | message($lang_common['Invalid e-mail']); | |
216 | ||
217 | // Check it it's a banned e-mail address | |
218 | if (is_banned_email($new_email)) | |
219 | { | |
220 | if ($pun_config['p_allow_banned_email'] == '0') | |
221 | message($lang_prof_reg['Banned e-mail']); | |
222 | else if ($pun_config['o_mailing_list'] != '') | |
223 | { | |
224 | $mail_subject = 'Alerte - Adresse e-mail bannis détectée'; | |
225 | $mail_message = 'L\'utilisateur \''.$pun_user['username'].'\' a changé son e-mail en une adresse interdite : '.$new_email."\n\n".'Profil utilisateur : '.$pun_config['o_base_url'].'/profile.php?id='.$id."\n\n".'-- '."\n".'E-mail automatique'."\n".'(Ne répondez pas à ce message)'; | |
226 | ||
227 | pun_mail($pun_config['o_mailing_list'], $mail_subject, $mail_message); | |
228 | } | |
229 | } | |
230 | ||
231 | // Check if someone else already has registered with that e-mail address | |
232 | $result = $db->query('SELECT id, username FROM '.$db->prefix.'users WHERE email=\''.$db->escape($new_email).'\'') or error('Unable to fetch user info', __FILE__, __LINE__, $db->error()); | |
233 | if ($db->num_rows($result)) | |
234 | { | |
235 | if ($pun_config['p_allow_dupe_email'] == '0') | |
236 | message($lang_prof_reg['Dupe e-mail']); | |
237 | else if ($pun_config['o_mailing_list'] != '') | |
238 | { | |
239 | while ($cur_dupe = $db->fetch_assoc($result)) | |
240 | $dupe_list[] = $cur_dupe['username']; | |
241 | ||
242 | $mail_subject = 'Alerte - Adresse e-mail en doublon détectée'; | |
243 | $mail_message = 'L\'utilisateur \''.$pun_user['username'].'\' a changé son e-mail pour une adresse qui appartient déjà à : '.implode(', ', $dupe_list)."\n\n".'Profil utilisateur : '.$pun_config['o_base_url'].'/profile.php?id='.$id."\n\n".'-- '."\n".'E-mail automatique'."\n".'(Ne répondez pas à ce message)'; | |
244 | ||
245 | pun_mail($pun_config['o_mailing_list'], $mail_subject, $mail_message); | |
246 | } | |
247 | } | |
248 | ||
249 | ||
250 | $new_email_key = random_pass(8); | |
251 | ||
252 | $db->query('UPDATE '.$db->prefix.'users SET activate_string=\''.$db->escape($new_email).'\', activate_key=\''.$new_email_key.'\' WHERE id='.$id) or error('Unable to update activation data', __FILE__, __LINE__, $db->error()); | |
253 | ||
254 | // Load the "activate e-mail" template | |
255 | $mail_tpl = trim(file_get_contents(PUN_ROOT.'lang/'.$pun_user['language'].'/mail_templates/activate_email.tpl')); | |
256 | ||
257 | // The first row contains the subject | |
258 | $first_crlf = strpos($mail_tpl, "\n"); | |
259 | $mail_subject = trim(substr($mail_tpl, 8, $first_crlf-8)); | |
260 | $mail_message = trim(substr($mail_tpl, $first_crlf)); | |
261 | ||
262 | $mail_message = str_replace('<username>', $pun_user['username'], $mail_message); | |
263 | $mail_message = str_replace('<base_url>', $pun_config['o_base_url'], $mail_message); | |
264 | $mail_message = str_replace('<activation_url>', $pun_config['o_base_url'].'/profile.php?action=change_email&id='.$id.'&key='.$new_email_key, $mail_message); | |
265 | $mail_message = str_replace('<board_mailer>', $pun_config['o_board_title'].' '.$lang_common['Mailer'], $mail_message); | |
266 | ||
267 | pun_mail($new_email, $mail_subject, $mail_message); | |
268 | ||
269 | message($lang_profile['Activate e-mail sent'].' <a href="mailto:'.$pun_config['o_admin_email'].'">'.$pun_config['o_admin_email'].'</a>.', true); | |
270 | } | |
271 | ||
272 | $page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / '.$lang_common['Profile']; | |
273 | $required_fields = array('req_new_email' => $lang_profile['New e-mail'], 'req_password' => $lang_common['Password']); | |
274 | $focus_element = array('change_email', 'req_new_email'); | |
275 | require PUN_ROOT.'header.php'; | |
276 | ||
277 | ?> | |
278 | <div class="blockform"> | |
279 | <h2><span><?php echo $lang_profile['Change e-mail'] ?></span></h2> | |
280 | <div class="box"> | |
281 | <form id="change_email" method="post" action="profile.php?action=change_email&id=<?php echo $id ?>" id="change_email" onsubmit="return process_form(this)"> | |
282 | <div class="inform"> | |
283 | <fieldset> | |
284 | <legend><?php echo $lang_profile['E-mail legend'] ?></legend> | |
285 | <div class="infldset"> | |
286 | <input type="hidden" name="form_sent" value="1" /> | |
287 | <label><strong><?php echo $lang_profile['New e-mail'] ?></strong><br /><input type="text" name="req_new_email" size="50" maxlength="50" /><br /></label> | |
288 | <label><strong><?php echo $lang_common['Password'] ?></strong><br /><input type="password" name="req_password" size="16" maxlength="16" /><br /></label> | |
289 | <p><?php echo $lang_profile['E-mail instructions'] ?></p> | |
290 | </div> | |
291 | </fieldset> | |
292 | </div> | |
293 | <p><input type="submit" name="new_email" value="<?php echo $lang_common['Submit'] ?>" /><a href="javascript:history.go(-1)"><?php echo $lang_common['Go back'] ?></a></p> | |
294 | </form> | |
295 | </div> | |
296 | </div> | |
297 | <?php | |
298 | ||
299 | require PUN_ROOT.'footer.php'; | |
300 | } | |
301 | ||
302 | ||
303 | else if ($action == 'upload_avatar' || $action == 'upload_avatar2') | |
304 | { | |
305 | if ($pun_config['o_avatars'] == '0') | |
306 | message($lang_profile['Avatars disabled']); | |
307 | ||
308 | if ($pun_user['id'] != $id && $pun_user['g_id'] > PUN_MOD) | |
309 | message($lang_common['No permission']); | |
310 | ||
311 | if (isset($_POST['form_sent'])) | |
312 | { | |
313 | if (!isset($_FILES['req_file'])) | |
314 | message($lang_profile['No file']); | |
315 | ||
316 | $uploaded_file = $_FILES['req_file']; | |
317 | ||
318 | // Make sure the upload went smooth | |
319 | if (isset($uploaded_file['error'])) | |
320 | { | |
321 | switch ($uploaded_file['error']) | |
322 | { | |
323 | case 1: // UPLOAD_ERR_INI_SIZE | |
324 | case 2: // UPLOAD_ERR_FORM_SIZE | |
325 | message($lang_profile['Too large ini']); | |
326 | break; | |
327 | ||
328 | case 3: // UPLOAD_ERR_PARTIAL | |
329 | message($lang_profile['Partial upload']); | |
330 | break; | |
331 | ||
332 | case 4: // UPLOAD_ERR_NO_FILE | |
333 | message($lang_profile['No file']); | |
334 | break; | |
335 | ||
336 | case 6: // UPLOAD_ERR_NO_TMP_DIR | |
337 | message($lang_profile['No tmp directory']); | |
338 | break; | |
339 | ||
340 | default: | |
341 | // No error occured, but was something actually uploaded? | |
342 | if ($uploaded_file['size'] == 0) | |
343 | message($lang_profile['No file']); | |
344 | break; | |
345 | } | |
346 | } | |
347 | ||
348 | if (is_uploaded_file($uploaded_file['tmp_name'])) | |
349 | { | |
350 | // Preliminary file check, adequate in most cases | |
351 | $allowed_types = array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/png', 'image/x-png'); | |
352 | if (!in_array($uploaded_file['type'], $allowed_types)) | |
353 | message($lang_profile['Bad type']); | |
354 | ||
355 | // Make sure the file isn't too big | |
356 | if ($uploaded_file['size'] > $pun_config['o_avatars_size']) | |
357 | message($lang_profile['Too large'].' '.$pun_config['o_avatars_size'].' '.$lang_profile['bytes'].'.'); | |
358 | ||
359 | // Move the file to the avatar directory. We do this before checking the width/height to circumvent open_basedir restrictions. | |
360 | if (!@move_uploaded_file($uploaded_file['tmp_name'], $pun_config['o_avatars_dir'].'/'.$id.'.tmp')) | |
361 | message($lang_profile['Move failed'].' <a href="mailto:'.$pun_config['o_admin_email'].'">'.$pun_config['o_admin_email'].'</a>.'); | |
362 | ||
363 | list($width, $height, $type,) = getimagesize($pun_config['o_avatars_dir'].'/'.$id.'.tmp'); | |
364 | ||
365 | // Determine type | |
366 | $extensions = null; | |
367 | if ($type == IMAGETYPE_GIF) | |
368 | $extensions = array('.gif', '.jpg', '.png'); | |
369 | else if ($type == IMAGETYPE_JPEG) | |
370 | $extensions = array('.jpg', '.gif', '.png'); | |
371 | else if ($type == IMAGETYPE_PNG) | |
372 | $extensions = array('.png', '.gif', '.jpg'); | |
373 | else | |
374 | { | |
375 | // Invalid type | |
376 | @unlink($pun_config['o_avatars_dir'].'/'.$id.'.tmp'); | |
377 | message($lang_profile['Bad type']); | |
378 | } | |
379 | ||
380 | // Now check the width/height | |
381 | if (empty($width) || empty($height) || $width > $pun_config['o_avatars_width'] || $height > $pun_config['o_avatars_height']) | |
382 | { | |
383 | @unlink($pun_config['o_avatars_dir'].'/'.$id.'.tmp'); | |
384 | message($lang_profile['Too wide or high'].' '.$pun_config['o_avatars_width'].'x'.$pun_config['o_avatars_height'].' '.$lang_profile['pixels'].'.'); | |
385 | } | |
386 | ||
387 | // Delete any old avatars and put the new one in place | |
388 | @unlink($pun_config['o_avatars_dir'].'/'.$id.$extensions[0]); | |
389 | @unlink($pun_config['o_avatars_dir'].'/'.$id.$extensions[1]); | |
390 | @unlink($pun_config['o_avatars_dir'].'/'.$id.$extensions[2]); | |
391 | @rename($pun_config['o_avatars_dir'].'/'.$id.'.tmp', $pun_config['o_avatars_dir'].'/'.$id.$extensions[0]); | |
392 | @chmod($pun_config['o_avatars_dir'].'/'.$id.$extensions[0], 0644); | |
393 | } | |
394 | else | |
395 | message($lang_profile['Unknown failure']); | |
396 | ||
397 | // Enable use_avatar (seems sane since the user just uploaded an avatar) | |
398 | $db->query('UPDATE '.$db->prefix.'users SET use_avatar=1 WHERE id='.$id) or error('Unable to update avatar state', __FILE__, __LINE__, $db->error()); | |
399 | ||
400 | redirect('profile.php?section=personality&id='.$id, $lang_profile['Avatar upload redirect']); | |
401 | } | |
402 | ||
403 | $page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / '.$lang_common['Profile']; | |
404 | $required_fields = array('req_file' => $lang_profile['File']); | |
405 | $focus_element = array('upload_avatar', 'req_file'); | |
406 | require PUN_ROOT.'header.php'; | |
407 | ||
408 | ?> | |
409 | <div class="blockform"> | |
410 | <h2><span><?php echo $lang_profile['Upload avatar'] ?></span></h2> | |
411 | <div class="box"> | |
412 | <form id="upload_avatar" method="post" enctype="multipart/form-data" action="profile.php?action=upload_avatar2&id=<?php echo $id ?>" onsubmit="return process_form(this)"> | |
413 | <div class="inform"> | |
414 | <fieldset> | |
415 | <legend><?php echo $lang_profile['Upload avatar legend'] ?></legend> | |
416 | <div class="infldset"> | |
417 | <input type="hidden" name="form_sent" value="1" /> | |
418 | <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $pun_config['o_avatars_size'] ?>" /> | |
419 | <label><strong><?php echo $lang_profile['File'] ?></strong><br /><input name="req_file" type="file" size="40" /><br /></label> | |
420 | <p><?php echo $lang_profile['Avatar desc'].' '.$pun_config['o_avatars_width'].' x '.$pun_config['o_avatars_height'].' '.$lang_profile['pixels'].' '.$lang_common['and'].' '.$pun_config['o_avatars_size'].' '.$lang_profile['bytes'].' ('.ceil($pun_config['o_avatars_size'] / 1024) ?> KB).</p> | |
421 | </div> | |
422 | </fieldset> | |
423 | </div> | |
424 | <p><input type="submit" name="upload" value="<?php echo $lang_profile['Upload'] ?>" /><a href="javascript:history.go(-1)"><?php echo $lang_common['Go back'] ?></a></p> | |
425 | </form> | |
426 | </div> | |
427 | </div> | |
428 | <?php | |
429 | ||
430 | require PUN_ROOT.'footer.php'; | |
431 | } | |
432 | ||
433 | ||
434 | else if ($action == 'delete_avatar') | |
435 | { | |
436 | if ($pun_user['id'] != $id && $pun_user['g_id'] > PUN_MOD) | |
437 | message($lang_common['No permission']); | |
438 | ||
439 | confirm_referrer('profile.php'); | |
440 | ||
441 | @unlink($pun_config['o_avatars_dir'].'/'.$id.'.jpg'); | |
442 | @unlink($pun_config['o_avatars_dir'].'/'.$id.'.png'); | |
443 | @unlink($pun_config['o_avatars_dir'].'/'.$id.'.gif'); | |
444 | ||
445 | // Disable use_avatar | |
446 | $db->query('UPDATE '.$db->prefix.'users SET use_avatar=0 WHERE id='.$id) or error('Unable to update avatar state', __FILE__, __LINE__, $db->error()); | |
447 | ||
448 | redirect('profile.php?section=personality&id='.$id, $lang_profile['Avatar deleted redirect']); | |
449 | } | |
450 | ||
451 | ||
452 | else if (isset($_POST['update_group_membership'])) | |
453 | { | |
454 | if ($pun_user['g_id'] > PUN_ADMIN) | |
455 | message($lang_common['No permission']); | |
456 | ||
457 | confirm_referrer('profile.php'); | |
458 | ||
459 | $new_group_id = intval($_POST['group_id']); | |
460 | ||
461 | $db->query('UPDATE '.$db->prefix.'users SET group_id='.$new_group_id.' WHERE id='.$id) or error('Unable to change user group', __FILE__, __LINE__, $db->error()); | |
462 | ||
463 | // If the user was a moderator or an administrator, we remove him/her from the moderator list in all forums as well | |
464 | if ($new_group_id > PUN_MOD) | |
465 | { | |
466 | $result = $db->query('SELECT id, moderators FROM '.$db->prefix.'forums') or error('Unable to fetch forum list', __FILE__, __LINE__, $db->error()); | |
467 | ||
468 | while ($cur_forum = $db->fetch_assoc($result)) | |
469 | { | |
470 | $cur_moderators = ($cur_forum['moderators'] != '') ? unserialize($cur_forum['moderators']) : array(); | |
471 | ||
472 | if (in_array($id, $cur_moderators)) | |
473 | { | |
474 | $username = array_search($id, $cur_moderators); | |
475 | unset($cur_moderators[$username]); | |
476 | $cur_moderators = (!empty($cur_moderators)) ? '\''.$db->escape(serialize($cur_moderators)).'\'' : 'NULL'; | |
477 | ||
478 | $db->query('UPDATE '.$db->prefix.'forums SET moderators='.$cur_moderators.' WHERE id='.$cur_forum['id']) or error('Unable to update forum', __FILE__, __LINE__, $db->error()); | |
479 | } | |
480 | } | |
481 | } | |
482 | ||
483 | redirect('profile.php?section=admin&id='.$id, $lang_profile['Group membership redirect']); | |
484 | } | |
485 | ||
486 | ||
487 | else if (isset($_POST['update_forums'])) | |
488 | { | |
489 | if ($pun_user['g_id'] > PUN_ADMIN) | |
490 | message($lang_common['No permission']); | |
491 | ||
492 | confirm_referrer('profile.php'); | |
493 | ||
494 | // Get the username of the user we are processing | |
495 | $result = $db->query('SELECT username FROM '.$db->prefix.'users WHERE id='.$id) or error('Unable to fetch user info', __FILE__, __LINE__, $db->error()); | |
496 | $username = $db->result($result); | |
497 | ||
498 | $moderator_in = (isset($_POST['moderator_in'])) ? array_keys($_POST['moderator_in']) : array(); | |
499 | ||
500 | // Loop through all forums | |
501 | $result = $db->query('SELECT id, moderators FROM '.$db->prefix.'forums') or error('Unable to fetch forum list', __FILE__, __LINE__, $db->error()); | |
502 | ||
503 | while ($cur_forum = $db->fetch_assoc($result)) | |
504 | { | |
505 | $cur_moderators = ($cur_forum['moderators'] != '') ? unserialize($cur_forum['moderators']) : array(); | |
506 | // If the user should have moderator access (and he/she doesn't already have it) | |
507 | if (in_array($cur_forum['id'], $moderator_in) && !in_array($id, $cur_moderators)) | |
508 | { | |
509 | $cur_moderators[$username] = $id; | |
510 | ksort($cur_moderators); | |
511 | ||
512 | $db->query('UPDATE '.$db->prefix.'forums SET moderators=\''.$db->escape(serialize($cur_moderators)).'\' WHERE id='.$cur_forum['id']) or error('Unable to update forum', __FILE__, __LINE__, $db->error()); | |
513 | } | |
514 | // If the user shouldn't have moderator access (and he/she already has it) | |
515 | else if (!in_array($cur_forum['id'], $moderator_in) && in_array($id, $cur_moderators)) | |
516 | { | |
517 | unset($cur_moderators[$username]); | |
518 | $cur_moderators = (!empty($cur_moderators)) ? '\''.$db->escape(serialize($cur_moderators)).'\'' : 'NULL'; | |
519 | ||
520 | $db->query('UPDATE '.$db->prefix.'forums SET moderators='.$cur_moderators.' WHERE id='.$cur_forum['id']) or error('Unable to update forum', __FILE__, __LINE__, $db->error()); | |
521 | } | |
522 | } | |
523 | ||
524 | redirect('profile.php?section=admin&id='.$id, $lang_profile['Update forums redirect']); | |
525 | } | |
526 | ||
527 | ||
528 | else if (isset($_POST['ban'])) | |
529 | { | |
530 | if ($pun_user['g_id'] > PUN_MOD || ($pun_user['g_id'] == PUN_MOD && $pun_config['p_mod_ban_users'] == '0')) | |
531 | message($lang_common['No permission']); | |
532 | ||
533 | redirect('admin_bans.php?add_ban='.$id, $lang_profile['Ban redirect']); | |
534 | } | |
535 | ||
536 | ||
537 | else if (isset($_POST['delete_user']) || isset($_POST['delete_user_comply'])) | |
538 | { | |
539 | if ($pun_user['g_id'] > PUN_ADMIN) | |
540 | message($lang_common['No permission']); | |
541 | ||
542 | confirm_referrer('profile.php'); | |
543 | ||
544 | // Get the username and group of the user we are deleting | |
545 | $result = $db->query('SELECT group_id, username FROM '.$db->prefix.'users WHERE id='.$id) or error('Unable to fetch user info', __FILE__, __LINE__, $db->error()); | |
546 | list($group_id, $username) = $db->fetch_row($result); | |
547 | ||
548 | if ($group_id == PUN_ADMIN) | |
549 | message('Les administrateurs ne peuvent êtres supprimés. Afin de supprimer cet utilisateur vous devez d\'abord le déplacer dans un autre groupe.'); | |
550 | ||
551 | if (isset($_POST['delete_user_comply'])) | |
552 | { | |
553 | // If the user is a moderator or an administrator, we remove him/her from the moderator list in all forums as well | |
554 | if ($group_id < PUN_GUEST) | |
555 | { | |
556 | $result = $db->query('SELECT id, moderators FROM '.$db->prefix.'forums') or error('Unable to fetch forum list', __FILE__, __LINE__, $db->error()); | |
557 | ||
558 | while ($cur_forum = $db->fetch_assoc($result)) | |
559 | { | |
560 | $cur_moderators = ($cur_forum['moderators'] != '') ? unserialize($cur_forum['moderators']) : array(); | |
561 | ||
562 | if (in_array($id, $cur_moderators)) | |
563 | { | |
564 | unset($cur_moderators[$username]); | |
565 | $cur_moderators = (!empty($cur_moderators)) ? '\''.$db->escape(serialize($cur_moderators)).'\'' : 'NULL'; | |
566 | ||
567 | $db->query('UPDATE '.$db->prefix.'forums SET moderators='.$cur_moderators.' WHERE id='.$cur_forum['id']) or error('Unable to update forum', __FILE__, __LINE__, $db->error()); | |
568 | } | |
569 | } | |
570 | } | |
571 | ||
572 | // Delete any subscriptions | |
573 | $db->query('DELETE FROM '.$db->prefix.'subscriptions WHERE user_id='.$id) or error('Unable to delete subscriptions', __FILE__, __LINE__, $db->error()); | |
574 | ||
575 | // Remove him/her from the online list (if they happen to be logged in) | |
576 | $db->query('DELETE FROM '.$db->prefix.'online WHERE user_id='.$id) or error('Unable to remove user from online list', __FILE__, __LINE__, $db->error()); | |
577 | ||
578 | // Should we delete all posts made by this user? | |
579 | if (isset($_POST['delete_posts'])) | |
580 | { | |
581 | require PUN_ROOT.'include/search_idx.php'; | |
582 | @set_time_limit(0); | |
583 | ||
584 | // Find all posts made by this user | |
585 | $result = $db->query('SELECT p.id, p.topic_id, t.forum_id FROM '.$db->prefix.'posts AS p INNER JOIN '.$db->prefix.'topics AS t ON t.id=p.topic_id INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id WHERE p.poster_id='.$id) or error('Unable to fetch posts', __FILE__, __LINE__, $db->error()); | |
586 | if ($db->num_rows($result)) | |
587 | { | |
588 | while ($cur_post = $db->fetch_assoc($result)) | |
589 | { | |
590 | // Determine whether this post is the "topic post" or not | |
591 | $result2 = $db->query('SELECT id FROM '.$db->prefix.'posts WHERE topic_id='.$cur_post['topic_id'].' ORDER BY posted LIMIT 1') or error('Unable to fetch post info', __FILE__, __LINE__, $db->error()); | |
592 | ||
593 | if ($db->result($result2) == $cur_post['id']) | |
594 | delete_topic($cur_post['topic_id']); | |
595 | else | |
596 | delete_post($cur_post['id'], $cur_post['topic_id']); | |
597 | ||
598 | update_forum($cur_post['forum_id']); | |
599 | } | |
600 | } | |
601 | } | |
602 | else | |
603 | // Set all his/her posts to guest | |
604 | $db->query('UPDATE '.$db->prefix.'posts SET poster_id=1 WHERE poster_id='.$id) or error('Unable to update posts', __FILE__, __LINE__, $db->error()); | |
605 | ||
606 | // Delete the user | |
607 | $db->query('DELETE FROM '.$db->prefix.'users WHERE id='.$id) or error('Unable to delete user', __FILE__, __LINE__, $db->error()); | |
608 | ||
609 | // Delete user avatar | |
610 | if (file_exists($pun_config['o_avatars_dir'].'/'.$id.'.gif')) | |
611 | @unlink($pun_config['o_avatars_dir'].'/'.$id.'.gif'); | |
612 | if (file_exists($pun_config['o_avatars_dir'].'/'.$id.'.jpg')) | |
613 | @unlink($pun_config['o_avatars_dir'].'/'.$id.'.jpg'); | |
614 | if (file_exists($pun_config['o_avatars_dir'].'/'.$id.'.png')) | |
615 | @unlink($pun_config['o_avatars_dir'].'/'.$id.'.png'); | |
616 | ||
617 | redirect('index.php', $lang_profile['User delete redirect']); | |
618 | } | |
619 | ||
620 | $page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / '.$lang_common['Profile']; | |
621 | require PUN_ROOT.'header.php'; | |
622 | ||
623 | ?> | |
624 | <div class="blockform"> | |
625 | <h2><span><?php echo $lang_profile['Confirm delete user'] ?></span></h2> | |
626 | <div class="box"> | |
627 | <form id="confirm_del_user" method="post" action="profile.php?id=<?php echo $id ?>"> | |
628 | <div class="inform"> | |
629 | <fieldset> | |
630 | <legend><?php echo $lang_profile['Confirm delete legend'] ?></legend> | |
631 | <div class="infldset"> | |
632 | <p><?php echo $lang_profile['Confirmation info'].' '.pun_htmlspecialchars($username).'.' ?></p> | |
633 | <div class="rbox"> | |
634 | <label><input type="checkbox" name="delete_posts" value="1" checked="checked" /><?php echo $lang_profile['Delete posts'] ?><br /></label> | |
635 | </div> | |
636 | <p class="warntext"><strong><?php echo $lang_profile['Delete warning'] ?></strong></p> | |
637 | </div> | |
638 | </fieldset> | |
639 | </div> | |
640 | <p><input type="submit" name="delete_user_comply" value="<?php echo $lang_profile['Delete'] ?>" /><a href="javascript:history.go(-1)"><?php echo $lang_common['Go back'] ?></a></p> | |
641 | </form> | |
642 | </div> | |
643 | </div> | |
644 | <?php | |
645 | ||
646 | require PUN_ROOT.'footer.php'; | |
647 | } | |
648 | ||
649 | ||
650 | else if (isset($_POST['form_sent'])) | |
651 | { | |
652 | // Fetch the user group of the user we are editing | |
653 | $result = $db->query('SELECT group_id FROM '.$db->prefix.'users WHERE id='.$id) or error('Unable to fetch user info', __FILE__, __LINE__, $db->error()); | |
654 | if (!$db->num_rows($result)) | |
655 | message($lang_common['Bad request']); | |
656 | ||
657 | $group_id = $db->result($result); | |
658 | ||
659 | if ($pun_user['id'] != $id && | |
660 | ($pun_user['g_id'] > PUN_MOD || | |
661 | ($pun_user['g_id'] == PUN_MOD && $pun_config['p_mod_edit_users'] == '0') || | |
662 | ($pun_user['g_id'] == PUN_MOD && $group_id < PUN_GUEST))) | |
663 | message($lang_common['No permission']); | |
664 | ||
665 | if ($pun_user['g_id'] < PUN_GUEST) | |
666 | confirm_referrer('profile.php'); | |
667 | ||
668 | // Extract allowed elements from $_POST['form'] | |
669 | function extract_elements($allowed_elements) | |
670 | { | |
671 | $form = array(); | |
672 | ||
673 | while (list($key, $value) = @each($_POST['form'])) | |
674 | { | |
675 | if (in_array($key, $allowed_elements)) | |
676 | $form[$key] = $value; | |
677 | } | |
678 | ||
679 | return $form; | |
680 | } | |
681 | ||
682 | $username_updated = false; | |
683 | ||
684 | // Validate input depending on section | |
685 | switch ($section) | |
686 | { | |
687 | case 'essentials': | |
688 | { | |
689 | $form = extract_elements(array('timezone', 'language')); | |
690 | ||
691 | if ($pun_user['g_id'] < PUN_GUEST) | |
692 | { | |
693 | $form['admin_note'] = trim($_POST['admin_note']); | |
694 | ||
695 | // Are we allowed to change usernames? | |
696 | if ($pun_user['g_id'] == PUN_ADMIN || ($pun_user['g_id'] == PUN_MOD && $pun_config['p_mod_rename_users'] == '1')) | |
697 | { | |
698 | $form['username'] = trim($_POST['req_username']); | |
699 | $old_username = trim($_POST['old_username']); | |
700 | ||
701 | if (strlen($form['username']) < 2) | |
702 | message($lang_prof_reg['Username too short']); | |
703 | else if (pun_strlen($form['username']) > 25) // This usually doesn't happen since the form element only accepts 25 characters | |
704 | message($lang_common['Bad request']); | |
705 | else if (!strcasecmp($form['username'], 'Guest') || !strcasecmp($form['username'], 'invité') || !strcasecmp($form['username'], $lang_common['Guest'])) | |
706 | message($lang_prof_reg['Username guest']); | |
707 | else if (preg_match('/[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/', $form['username'])) | |
708 | message($lang_prof_reg['Username IP']); | |
709 | else if (preg_match('#\[b\]|\[/b\]|\[u\]|\[/u\]|\[i\]|\[/i\]|\[color|\[/color\]|\[quote\]|\[quote=|\[/quote\]|\[code\]|\[/code\]|\[img\]|\[/img\]|\[url|\[/url\]|\[email|\[/email\]#i', $form['username'])) | |
710 | message($lang_prof_reg['Username BBCode']); | |
711 | ||
712 | // Check that the username is not already registered | |
713 | $result = $db->query('SELECT 1 FROM '.$db->prefix.'users WHERE username=\''.$db->escape($form['username']).'\' AND id!='.$id) or error('Unable to fetch user info', __FILE__, __LINE__, $db->error()); | |
714 | if ($db->num_rows($result)) | |
715 | message($lang_profile['Dupe username']); | |
716 | ||
717 | if ($form['username'] != $old_username) | |
718 | $username_updated = true; | |
719 | } | |
720 | ||
721 | // We only allow administrators to update the post count | |
722 | if ($pun_user['g_id'] == PUN_ADMIN) | |
723 | $form['num_posts'] = intval($_POST['num_posts']); | |
724 | } | |
725 | ||
726 | if ($pun_config['o_regs_verify'] == '0' || $pun_user['g_id'] < PUN_GUEST) | |
727 | { | |
728 | require PUN_ROOT.'include/email.php'; | |
729 | ||
730 | // Validate the email-address | |
731 | $form['email'] = strtolower(trim($_POST['req_email'])); | |
732 | if (!is_valid_email($form['email'])) | |
733 | message($lang_common['Invalid e-mail']); | |
734 | } | |
735 | ||
736 | // Make sure we got a valid language string | |
737 | if (isset($form['language'])) | |
738 | { | |
739 | $form['language'] = preg_replace('#[\.\\\/]#', '', $form['language']); | |
740 | if (!file_exists(PUN_ROOT.'lang/'.$form['language'].'/common.php')) | |
741 | message($lang_common['Bad request']); | |
742 | } | |
743 | ||
744 | break; | |
745 | } | |
746 | ||
747 | case 'personal': | |
748 | { | |
749 | $form = extract_elements(array('realname', 'url', 'location')); | |
750 | ||
751 | if ($pun_user['g_id'] == PUN_ADMIN) | |
752 | $form['title'] = trim($_POST['title']); | |
753 | else if ($pun_user['g_set_title'] == '1') | |
754 | { | |
755 | $form['title'] = trim($_POST['title']); | |
756 | ||
757 | if ($form['title'] != '') | |
758 | { | |
759 | // A list of words that the title may not contain | |
760 | // If the language is English, there will be some duplicates, but it's not the end of the world | |
761 | $forbidden = array('Member', 'Moderator', 'Administrator', 'Banned', 'Guest', $lang_common['Member'], $lang_common['Moderator'], $lang_common['Administrator'], $lang_common['Banned'], $lang_common['Guest']); | |
762 | ||
763 | if (in_array($form['title'], $forbidden)) | |
764 | message($lang_profile['Forbidden title']); | |
765 | } | |
766 | } | |
767 | ||
768 | // Add http:// if the URL doesn't contain it already | |
769 | if ($form['url'] != '' && strpos(strtolower($form['url']), 'http://') !== 0) | |
770 | $form['url'] = 'http://'.$form['url']; | |
771 | ||
772 | break; | |
773 | } | |
774 | ||
775 | case 'messaging': | |
776 | { | |
777 | $form = extract_elements(array('jabber', 'icq', 'msn', 'aim', 'yahoo')); | |
778 | ||
779 | // If the ICQ UIN contains anything other than digits it's invalid | |
780 | if ($form['icq'] != '' && @preg_match('/[^0-9]/', $form['icq'])) | |
781 | message($lang_prof_reg['Bad ICQ']); | |
782 | ||
783 | break; | |
784 | } | |
785 | ||
786 | case 'personality': | |
787 | { | |
788 | $form = extract_elements(array('use_avatar')); | |
789 | ||
790 | // Clean up signature from POST | |
791 | $form['signature'] = pun_linebreaks(trim($_POST['signature'])); | |
792 | ||
793 | // Validate signature | |
794 | if (pun_strlen($form['signature']) > $pun_config['p_sig_length']) | |
795 | message($lang_prof_reg['Sig too long'].' '.$pun_config['p_sig_length'].' '.$lang_prof_reg['characters'].'.'); | |
796 | else if (substr_count($form['signature'], "\n") > ($pun_config['p_sig_lines']-1)) | |
797 | message($lang_prof_reg['Sig too many lines'].' '.$pun_config['p_sig_lines'].' '.$lang_prof_reg['lines'].'.'); | |
798 | else if ($form['signature'] && $pun_config['p_sig_all_caps'] == '0' && strtoupper($form['signature']) == $form['signature'] && $pun_user['g_id'] > PUN_MOD) | |
799 | $form['signature'] = ucwords(strtolower($form['signature'])); | |
800 | ||
801 | // Validate BBCode syntax | |
802 | if ($pun_config['p_sig_bbcode'] == '1' && strpos($form['signature'], '[') !== false && strpos($form['signature'], ']') !== false) | |
803 | { | |
804 | require PUN_ROOT.'include/parser.php'; | |
805 | $form['signature'] = preparse_bbcode($form['signature'], $foo, true); | |
806 | } | |
807 | ||
808 | if (!isset($form['use_avatar']) || $form['use_avatar'] != '1') $form['use_avatar'] = '0'; | |
809 | ||
810 | break; | |
811 | } | |
812 | ||
813 | case 'display': | |
814 | { | |
815 | $form = extract_elements(array('disp_topics', 'disp_posts', 'show_smilies', 'show_img', 'show_img_sig', 'show_avatars', 'show_sig', 'style')); | |
816 | ||
817 | if ($form['disp_topics'] != '' && intval($form['disp_topics']) < 3) $form['disp_topics'] = 3; | |
818 | if ($form['disp_topics'] != '' && intval($form['disp_topics']) > 75) $form['disp_topics'] = 75; | |
819 | if ($form['disp_posts'] != '' && intval($form['disp_posts']) < 3) $form['disp_posts'] = 3; | |
820 | if ($form['disp_posts'] != '' && intval($form['disp_posts']) > 75) $form['disp_posts'] = 75; | |
821 | ||
822 | if (!isset($form['show_smilies']) || $form['show_smilies'] != '1') $form['show_smilies'] = '0'; | |
823 | if (!isset($form['show_img']) || $form['show_img'] != '1') $form['show_img'] = '0'; | |
824 | if (!isset($form['show_img_sig']) || $form['show_img_sig'] != '1') $form['show_img_sig'] = '0'; | |
825 | if (!isset($form['show_avatars']) || $form['show_avatars'] != '1') $form['show_avatars'] = '0'; | |
826 | if (!isset($form['show_sig']) || $form['show_sig'] != '1') $form['show_sig'] = '0'; | |
827 | ||
828 | break; | |
829 | } | |
830 | ||
831 | case 'privacy': | |
832 | { | |
833 | $form = extract_elements(array('email_setting', 'save_pass', 'notify_with_post')); | |
834 | ||
835 | $form['email_setting'] = intval($form['email_setting']); | |
836 | if ($form['email_setting'] < 0 && $form['email_setting'] > 2) $form['email_setting'] = 1; | |
837 | ||
838 | if (!isset($form['save_pass']) || $form['save_pass'] != '1') $form['save_pass'] = '0'; | |
839 | if (!isset($form['notify_with_post']) || $form['notify_with_post'] != '1') $form['notify_with_post'] = '0'; | |
840 | ||
841 | // If the save_pass setting has changed, we need to set a new cookie with the appropriate expire date | |
842 | if ($pun_user['id'] == $id && $form['save_pass'] != $pun_user['save_pass']) | |
843 | { | |
844 | $result = $db->query('SELECT password FROM '.$db->prefix.'users WHERE id='.$id) or error('Unable to fetch user password hash', __FILE__, __LINE__, $db->error()); | |
845 | pun_setcookie($id, $db->result($result), ($form['save_pass'] == '1') ? time() + 31536000 : 0); | |
846 | } | |
847 | ||
848 | break; | |
849 | } | |
850 | ||
851 | default: | |
852 | message($lang_common['Bad request']); | |
853 | } | |
854 | ||
855 | ||
856 | // Singlequotes around non-empty values and NULL for empty values | |
857 | $temp = array(); | |
858 | while (list($key, $input) = @each($form)) | |
859 | { | |
860 | $value = ($input !== '') ? '\''.$db->escape($input).'\'' : 'NULL'; | |
861 | ||
862 | $temp[] = $key.'='.$value; | |
863 | } | |
864 | ||
865 | if (empty($temp)) | |
866 | message($lang_common['Bad request']); | |
867 | ||
868 | ||
869 | $db->query('UPDATE '.$db->prefix.'users SET '.implode(',', $temp).' WHERE id='.$id) or error('Unable to update profile', __FILE__, __LINE__, $db->error()); | |
870 | ||
871 | // If we changed the username we have to update some stuff | |
872 | if ($username_updated) | |
873 | { | |
874 | $db->query('UPDATE '.$db->prefix.'posts SET poster=\''.$db->escape($form['username']).'\' WHERE poster_id='.$id) or error('Unable to update posts', __FILE__, __LINE__, $db->error()); | |
875 | $db->query('UPDATE '.$db->prefix.'topics SET poster=\''.$db->escape($form['username']).'\' WHERE poster=\''.$db->escape($old_username).'\'') or error('Unable to update topics', __FILE__, __LINE__, $db->error()); | |
876 | $db->query('UPDATE '.$db->prefix.'topics SET last_poster=\''.$db->escape($form['username']).'\' WHERE last_poster=\''.$db->escape($old_username).'\'') or error('Unable to update topics', __FILE__, __LINE__, $db->error()); | |
877 | $db->query('UPDATE '.$db->prefix.'forums SET last_poster=\''.$db->escape($form['username']).'\' WHERE last_poster=\''.$db->escape($old_username).'\'') or error('Unable to update forums', __FILE__, __LINE__, $db->error()); | |
878 | $db->query('UPDATE '.$db->prefix.'online SET ident=\''.$db->escape($form['username']).'\' WHERE ident=\''.$db->escape($old_username).'\'') or error('Unable to update online list', __FILE__, __LINE__, $db->error()); | |
879 | ||
880 | // If the user is a moderator or an administrator we have to update the moderator lists | |
881 | $result = $db->query('SELECT group_id FROM '.$db->prefix.'users WHERE id='.$id) or error('Unable to fetch user info', __FILE__, __LINE__, $db->error()); | |
882 | $group_id = $db->result($result); | |
883 | ||
884 | if ($group_id < PUN_GUEST) | |
885 | { | |
886 | $result = $db->query('SELECT id, moderators FROM '.$db->prefix.'forums') or error('Unable to fetch forum list', __FILE__, __LINE__, $db->error()); | |
887 | ||
888 | while ($cur_forum = $db->fetch_assoc($result)) | |
889 | { | |
890 | $cur_moderators = ($cur_forum['moderators'] != '') ? unserialize($cur_forum['moderators']) : array(); | |
891 | ||
892 | if (in_array($id, $cur_moderators)) | |
893 | { | |
894 | unset($cur_moderators[$old_username]); | |
895 | $cur_moderators[$form['username']] = $id; | |
896 | ksort($cur_moderators); | |
897 | ||
898 | $db->query('UPDATE '.$db->prefix.'forums SET moderators=\''.$db->escape(serialize($cur_moderators)).'\' WHERE id='.$cur_forum['id']) or error('Unable to update forum', __FILE__, __LINE__, $db->error()); | |
899 | } | |
900 | } | |
901 | } | |
902 | } | |
903 | ||
904 | redirect('profile.php?section='.$section.'&id='.$id, $lang_profile['Profile redirect']); | |
905 | } | |
906 | ||
907 | ||
908 | $result = $db->query('SELECT u.username, u.email, u.title, u.realname, u.url, u.jabber, u.icq, u.msn, u.aim, u.yahoo, u.location, u.use_avatar, u.signature, u.disp_topics, u.disp_posts, u.email_setting, u.save_pass, u.notify_with_post, u.show_smilies, u.show_img, u.show_img_sig, u.show_avatars, u.show_sig, u.timezone, u.language, u.style, u.num_posts, u.last_post, u.registered, u.registration_ip, u.admin_note, g.g_id, g.g_user_title FROM '.$db->prefix.'users AS u LEFT JOIN '.$db->prefix.'groups AS g ON g.g_id=u.group_id WHERE u.id='.$id) or error('Unable to fetch user info', __FILE__, __LINE__, $db->error()); | |
909 | if (!$db->num_rows($result)) | |
910 | message($lang_common['Bad request']); | |
911 | ||
912 | $user = $db->fetch_assoc($result); | |
913 | ||
914 | $last_post = format_time($user['last_post']); | |
915 | ||
916 | if ($user['signature'] != '') | |
917 | { | |
918 | require PUN_ROOT.'include/parser.php'; | |
919 | $parsed_signature = parse_signature($user['signature']); | |
920 | } | |
921 | ||
922 | ||
923 | // View or edit? | |
924 | if ($pun_user['id'] != $id && | |
925 | ($pun_user['g_id'] > PUN_MOD || | |
926 | ($pun_user['g_id'] == PUN_MOD && $pun_config['p_mod_edit_users'] == '0') || | |
927 | ($pun_user['g_id'] == PUN_MOD && $user['g_id'] < PUN_GUEST))) | |
928 | { | |
929 | if ($user['email_setting'] == '0' && !$pun_user['is_guest']) | |
930 | $email_field = '<a href="mailto:'.$user['email'].'">'.$user['email'].'</a>'; | |
931 | else if ($user['email_setting'] == '1' && !$pun_user['is_guest']) | |
932 | $email_field = '<a href="misc.php?email='.$id.'">'.$lang_common['Send e-mail'].'</a>'; | |
933 | else | |
934 | $email_field = $lang_profile['Private']; | |
935 | ||
936 | $user_title_field = get_title($user); | |
937 | ||
938 | if ($user['url'] != '') | |
939 | { | |
940 | $user['url'] = pun_htmlspecialchars($user['url']); | |
941 | ||
942 | if ($pun_config['o_censoring'] == '1') | |
943 | $user['url'] = censor_words($user['url']); | |
944 | ||
945 | $url = '<a href="'.$user['url'].'">'.$user['url'].'</a>'; | |
946 | } | |
947 | else | |
948 | $url = $lang_profile['Unknown']; | |
949 | ||
950 | if ($pun_config['o_avatars'] == '1') | |
951 | { | |
952 | if ($user['use_avatar'] == '1') | |
953 | { | |
954 | if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$id.'.gif')) | |
955 | $avatar_field = '<img src="'.$pun_config['o_avatars_dir'].'/'.$id.'.gif" '.$img_size[3].' alt="" />'; | |
956 | else if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$id.'.jpg')) | |
957 | $avatar_field = '<img src="'.$pun_config['o_avatars_dir'].'/'.$id.'.jpg" '.$img_size[3].' alt="" />'; | |
958 | else if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$id.'.png')) | |
959 | $avatar_field = '<img src="'.$pun_config['o_avatars_dir'].'/'.$id.'.png" '.$img_size[3].' alt="" />'; | |
960 | else | |
961 | $avatar_field = $lang_profile['No avatar']; | |
962 | } | |
963 | else | |
964 | $avatar_field = $lang_profile['No avatar']; | |
965 | } | |
966 | ||
967 | $posts_field = ''; | |
968 | if ($pun_config['o_show_post_count'] == '1' || $pun_user['g_id'] < PUN_GUEST) | |
969 | $posts_field = $user['num_posts']; | |
970 | if ($pun_user['g_search'] == '1') | |
971 | $posts_field .= (($posts_field != '') ? ' - ' : '').'<a href="search.php?action=show_user&user_id='.$id.'">'.$lang_profile['Show posts'].'</a>'; | |
972 | ||
973 | $page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / '.$lang_common['Profile']; | |
974 | define('PUN_ALLOW_INDEX', 1); | |
975 | require PUN_ROOT.'header.php'; | |
976 | ||
977 | ?> | |
978 | <div id="viewprofile" class="block"> | |
979 | <h2><span><?php echo $lang_common['Profile'] ?></span></h2> | |
980 | <div class="box"> | |
981 | <div class="fakeform"> | |
982 | <div class="inform"> | |
983 | <fieldset> | |
984 | <legend><?php echo $lang_profile['Section personal'] ?></legend> | |
985 | <div class="infldset"> | |
986 | <dl> | |
987 | <dt><?php echo $lang_common['Username'] ?>: </dt> | |
988 | <dd><?php echo pun_htmlspecialchars($user['username']) ?></dd> | |
989 | <dt><?php echo $lang_common['Title'] ?>: </dt> | |
990 | <dd><?php echo ($pun_config['o_censoring'] == '1') ? censor_words($user_title_field) : $user_title_field; ?></dd> | |
991 | <dt><?php echo $lang_profile['Realname'] ?>: </dt> | |
992 | <dd><?php echo ($user['realname'] !='') ? pun_htmlspecialchars(($pun_config['o_censoring'] == '1') ? censor_words($user['realname']) : $user['realname']) : $lang_profile['Unknown']; ?></dd> | |
993 | <dt><?php echo $lang_profile['Location'] ?>: </dt> | |
994 | <dd><?php echo ($user['location'] !='') ? pun_htmlspecialchars(($pun_config['o_censoring'] == '1') ? censor_words($user['location']) : $user['location']) : $lang_profile['Unknown']; ?></dd> | |
995 | <dt><?php echo $lang_profile['Website'] ?>: </dt> | |
996 | <dd><?php echo $url ?> </dd> | |
997 | <dt><?php echo $lang_common['E-mail'] ?>: </dt> | |
998 | <dd><?php echo $email_field ?></dd> | |
999 | </dl> | |
1000 | <div class="clearer"></div> | |
1001 | </div> | |
1002 | </fieldset> | |
1003 | </div> | |
1004 | <div class="inform"> | |
1005 | <fieldset> | |
1006 | <legend><?php echo $lang_profile['Section messaging'] ?></legend> | |
1007 | <div class="infldset"> | |
1008 | <dl> | |
1009 | <dt><?php echo $lang_profile['Jabber'] ?>: </dt> | |
1010 | <dd><?php echo ($user['jabber'] !='') ? pun_htmlspecialchars($user['jabber']) : $lang_profile['Unknown']; ?></dd> | |
1011 | <dt><?php echo $lang_profile['ICQ'] ?>: </dt> | |
1012 | <dd><?php echo ($user['icq'] !='') ? $user['icq'] : $lang_profile['Unknown']; ?></dd> | |
1013 | <dt><?php echo $lang_profile['MSN'] ?>: </dt> | |
1014 | <dd><?php echo ($user['msn'] !='') ? pun_htmlspecialchars(($pun_config['o_censoring'] == '1') ? censor_words($user['msn']) : $user['msn']) : $lang_profile['Unknown']; ?></dd> | |
1015 | <dt><?php echo $lang_profile['AOL IM'] ?>: </dt> | |
1016 | <dd><?php echo ($user['aim'] !='') ? pun_htmlspecialchars(($pun_config['o_censoring'] == '1') ? censor_words($user['aim']) : $user['aim']) : $lang_profile['Unknown']; ?></dd> | |
1017 | <dt><?php echo $lang_profile['Yahoo'] ?>: </dt> | |
1018 | <dd><?php echo ($user['yahoo'] !='') ? pun_htmlspecialchars(($pun_config['o_censoring'] == '1') ? censor_words($user['yahoo']) : $user['yahoo']) : $lang_profile['Unknown']; ?></dd> | |
1019 | </dl> | |
1020 | <div class="clearer"></div> | |
1021 | </div> | |
1022 | </fieldset> | |
1023 | </div> | |
1024 | <div class="inform"> | |
1025 | <fieldset> | |
1026 | <legend><?php echo $lang_profile['Section personality'] ?></legend> | |
1027 | <div class="infldset"> | |
1028 | <dl> | |
1029 | <?php if ($pun_config['o_avatars'] == '1'): ?> <dt><?php echo $lang_profile['Avatar'] ?>: </dt> | |
1030 | <dd><?php echo $avatar_field ?></dd> | |
1031 | <?php endif; ?> <dt><?php echo $lang_profile['Signature'] ?>: </dt> | |
1032 | <dd><div><?php echo isset($parsed_signature) ? $parsed_signature : $lang_profile['No sig']; ?></div></dd> | |
1033 | </dl> | |
1034 | <div class="clearer"></div> | |
1035 | </div> | |
1036 | </fieldset> | |
1037 | </div> | |
1038 | <div class="inform"> | |
1039 | <fieldset> | |
1040 | <legend><?php echo $lang_profile['User activity'] ?></legend> | |
1041 | <div class="infldset"> | |
1042 | <dl> | |
1043 | <?php if ($posts_field != ''): ?> <dt><?php echo $lang_common['Posts'] ?>: </dt> | |
1044 | <dd><?php echo $posts_field ?></dd> | |
1045 | <?php endif; ?> <dt><?php echo $lang_common['Last post'] ?>: </dt> | |
1046 | <dd><?php echo $last_post ?></dd> | |
1047 | <dt><?php echo $lang_common['Registered'] ?>: </dt> | |
1048 | <dd><?php echo format_time($user['registered'], true) ?></dd> | |
1049 | </dl> | |
1050 | <div class="clearer"></div> | |
1051 | </div> | |
1052 | </fieldset> | |
1053 | </div> | |
1054 | </div> | |
1055 | </div> | |
1056 | </div> | |
1057 | ||
1058 | <?php | |
1059 | ||
1060 | require PUN_ROOT.'footer.php'; | |
1061 | } | |
1062 | else | |
1063 | { | |
1064 | if (!$section || $section == 'essentials') | |
1065 | { | |
1066 | if ($pun_user['g_id'] < PUN_GUEST) | |
1067 | { | |
1068 | if ($pun_user['g_id'] == PUN_ADMIN || $pun_config['p_mod_rename_users'] == '1') | |
1069 | $username_field = '<input type="hidden" name="old_username" value="'.pun_htmlspecialchars($user['username']).'" /><label><strong>'.$lang_common['Username'].'</strong><br /><input type="text" name="req_username" value="'.pun_htmlspecialchars($user['username']).'" size="25" maxlength="25" /><br /></label>'."\n"; | |
1070 | else | |
1071 | $username_field = '<p>'.$lang_common['Username'].': '.pun_htmlspecialchars($user['username']).'</p>'."\n"; | |
1072 | ||
1073 | $email_field = '<label><strong>'.$lang_common['E-mail'].'</strong><br /><input type="text" name="req_email" value="'.$user['email'].'" size="40" maxlength="50" /><br /></label><p><a href="misc.php?email='.$id.'">'.$lang_common['Send e-mail'].'</a></p>'."\n"; | |
1074 | } | |
1075 | else | |
1076 | { | |
1077 | $username_field = '<p>'.$lang_common['Username'].': '.pun_htmlspecialchars($user['username']).'</p>'."\n"; | |
1078 | ||
1079 | if ($pun_config['o_regs_verify'] == '1') | |
1080 | $email_field = '<p>'.$lang_common['E-mail'].': '.$user['email'].' - <a href="profile.php?action=change_email&id='.$id.'">'.$lang_profile['Change e-mail'].'</a></p>'."\n"; | |
1081 | else | |
1082 | $email_field = '<label><strong>'.$lang_common['E-mail'].'</strong><br /><input type="text" name="req_email" value="'.$user['email'].'" size="40" maxlength="50" /><br /></label>'."\n"; | |
1083 | } | |
1084 | ||
1085 | if ($pun_user['g_id'] == PUN_ADMIN) | |
1086 | $posts_field = '<label>'.$lang_common['Posts'].'<br /><input type="text" name="num_posts" value="'.$user['num_posts'].'" size="8" maxlength="8" /><br /></label><p><a href="search.php?action=show_user&user_id='.$id.'">'.$lang_profile['Show posts'].'</a></p>'."\n"; | |
1087 | else if ($pun_config['o_show_post_count'] == '1' || $pun_user['g_id'] < PUN_GUEST) | |
1088 | $posts_field = '<p>'.$lang_common['Posts'].': '.$user['num_posts'].' - <a href="search.php?action=show_user&user_id='.$id.'">'.$lang_profile['Show posts'].'</a></p>'."\n"; | |
1089 | else | |
1090 | $posts_field = '<p><a href="search.php?action=show_user&user_id='.$id.'">'.$lang_profile['Show posts'].'</a></p>'."\n"; | |
1091 | ||
1092 | $page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / '.$lang_common['Profile']; | |
1093 | $required_fields = array('req_username' => $lang_common['Username'], 'req_email' => $lang_common['E-mail']); | |
1094 | require PUN_ROOT.'header.php'; | |
1095 | ||
1096 | generate_profile_menu('essentials'); | |
1097 | ||
1098 | ?> | |
1099 | <div class="blockform"> | |
1100 | <h2><span><?php echo pun_htmlspecialchars($user['username']).' - '.$lang_profile['Section essentials'] ?></span></h2> | |
1101 | <div class="box"> | |
1102 | <form id="profile1" method="post" action="profile.php?section=essentials&id=<?php echo $id ?>" onsubmit="return process_form(this)"> | |
1103 | <div class="inform"> | |
1104 | <fieldset> | |
1105 | <legend><?php echo $lang_profile['Username and pass legend'] ?></legend> | |
1106 | <div class="infldset"> | |
1107 | <input type="hidden" name="form_sent" value="1" /> | |
1108 | <?php echo $username_field ?> | |
1109 | <?php if ($pun_user['id'] == $id || $pun_user['g_id'] == PUN_ADMIN || ($user['g_id'] > PUN_MOD && $pun_config['p_mod_change_passwords'] == '1')): ?><p><a href="profile.php?action=change_pass&id=<?php echo $id ?>"><?php echo $lang_profile['Change pass'] ?></a></p> | |
1110 | <?php endif; ?> </div> | |
1111 | </fieldset> | |
1112 | </div> | |
1113 | <div class="inform"> | |
1114 | <fieldset> | |
1115 | <legend><?php echo $lang_prof_reg['E-mail legend'] ?></legend> | |
1116 | <div class="infldset"> | |
1117 | <?php echo $email_field ?> | |
1118 | </div> | |
1119 | </fieldset> | |
1120 | </div> | |
1121 | <div class="inform"> | |
1122 | <fieldset> | |
1123 | <legend><?php echo $lang_prof_reg['Localisation legend'] ?></legend> | |
1124 | <div class="infldset"> | |
1125 | <label><?php echo $lang_prof_reg['Timezone'] ?>: <?php echo $lang_prof_reg['Timezone info'] ?> | |
1126 | <br /><select name="form[timezone]"> | |
1127 | <option value="-12"<?php if ($user['timezone'] == -12) echo ' selected="selected"' ?>>-12</option> | |
1128 | <option value="-11"<?php if ($user['timezone'] == -11) echo ' selected="selected"' ?>>-11</option> | |
1129 | <option value="-10"<?php if ($user['timezone'] == -10) echo ' selected="selected"' ?>>-10</option> | |
1130 | <option value="-9.5"<?php if ($user['timezone'] == -9.5) echo ' selected="selected"' ?>>-09.5</option> | |
1131 | <option value="-9"<?php if ($user['timezone'] == -9) echo ' selected="selected"' ?>>-09</option> | |
1132 | <option value="-8.5"<?php if ($user['timezone'] == -8.5) echo ' selected="selected"' ?>>-08.5</option> | |
1133 | <option value="-8"<?php if ($user['timezone'] == -8) echo ' selected="selected"' ?>>-08 PST</option> | |
1134 | <option value="-7"<?php if ($user['timezone'] == -7) echo ' selected="selected"' ?>>-07 MST</option> | |
1135 | <option value="-6"<?php if ($user['timezone'] == -6) echo ' selected="selected"' ?>>-06 CST</option> | |
1136 | <option value="-5"<?php if ($user['timezone'] == -5) echo ' selected="selected"' ?>>-05 EST</option> | |
1137 | <option value="-4"<?php if ($user['timezone'] == -4) echo ' selected="selected"' ?>>-04 AST</option> | |
1138 | <option value="-3.5"<?php if ($user['timezone'] == -3.5) echo ' selected="selected"' ?>>-03.5</option> | |
1139 | <option value="-3"<?php if ($user['timezone'] == -3) echo ' selected="selected"' ?>>-03 ADT</option> | |
1140 | <option value="-2"<?php if ($user['timezone'] == -2) echo ' selected="selected"' ?>>-02</option> | |
1141 | <option value="-1"<?php if ($user['timezone'] == -1) echo ' selected="selected"' ?>>-01</option> | |
1142 | <option value="0"<?php if ($user['timezone'] == 0) echo ' selected="selected"' ?>>00 GMT</option> | |
1143 | <option value="1"<?php if ($user['timezone'] == 1) echo ' selected="selected"' ?>>+01 CET</option> | |
1144 | <option value="2"<?php if ($user['timezone'] == 2) echo ' selected="selected"' ?>>+02</option> | |
1145 | <option value="3"<?php if ($user['timezone'] == 3) echo ' selected="selected"' ?>>+03</option> | |
1146 | <option value="3.5"<?php if ($user['timezone'] == 3.5) echo ' selected="selected"' ?>>+03.5</option> | |
1147 | <option value="4"<?php if ($user['timezone'] == 4) echo ' selected="selected"' ?>>+04</option> | |
1148 | <option value="4.5"<?php if ($user['timezone'] == 4.5) echo ' selected="selected"' ?>>+04.5</option> | |
1149 | <option value="5"<?php if ($user['timezone'] == 5) echo ' selected="selected"' ?>>+05</option> | |
1150 | <option value="5.5"<?php if ($user['timezone'] == 5.5) echo ' selected="selected"' ?>>+05.5</option> | |
1151 | <option value="6"<?php if ($user['timezone'] == 6) echo ' selected="selected"' ?>>+06</option> | |
1152 | <option value="6.5"<?php if ($user['timezone'] == 6.5) echo ' selected="selected"' ?>>+06.5</option> | |
1153 | <option value="7"<?php if ($user['timezone'] == 7) echo ' selected="selected"' ?>>+07</option> | |
1154 | <option value="8"<?php if ($user['timezone'] == 8) echo ' selected="selected"' ?>>+08</option> | |
1155 | <option value="9"<?php if ($user['timezone'] == 9) echo ' selected="selected"' ?>>+09</option> | |
1156 | <option value="9.5"<?php if ($user['timezone'] == 9.5) echo ' selected="selected"' ?>>+09.5</option> | |
1157 | <option value="10"<?php if ($user['timezone'] == 10) echo ' selected="selected"' ?>>+10</option> | |
1158 | <option value="10.5"<?php if ($user['timezone'] == 10.5) echo ' selected="selected"' ?>>+10.5</option> | |
1159 | <option value="11"<?php if ($user['timezone'] == 11) echo ' selected="selected"' ?>>+11</option> | |
1160 | <option value="11.5"<?php if ($user['timezone'] == 11.5) echo ' selected="selected"' ?>>+11.5</option> | |
1161 | <option value="12"<?php if ($user['timezone'] == 12) echo ' selected="selected"' ?>>+12</option> | |
1162 | <option value="13"<?php if ($user['timezone'] == 13) echo ' selected="selected"' ?>>+13</option> | |
1163 | <option value="14"<?php if ($user['timezone'] == 14) echo ' selected="selected"' ?>>+14</option> | |
1164 | </select> | |
1165 | <br /></label> | |
1166 | <?php | |
1167 | ||
1168 | $languages = array(); | |
1169 | $d = dir(PUN_ROOT.'lang'); | |
1170 | while (($entry = $d->read()) !== false) | |
1171 | { | |
1172 | if ($entry != '.' && $entry != '..' && is_dir(PUN_ROOT.'lang/'.$entry) && file_exists(PUN_ROOT.'lang/'.$entry.'/common.php')) | |
1173 | $languages[] = $entry; | |
1174 | } | |
1175 | $d->close(); | |
1176 | ||
1177 | // Only display the language selection box if there's more than one language available | |
1178 | if (count($languages) > 1) | |
1179 | { | |
1180 | natsort($languages); | |
1181 | ||
1182 | ?> | |
1183 | <label><?php echo $lang_prof_reg['Language'] ?>: <?php echo $lang_prof_reg['Language info'] ?> | |
1184 | <br /><select name="form[language]"> | |
1185 | <?php | |
1186 | ||
1187 | while (list(, $temp) = @each($languages)) | |
1188 | { | |
1189 | if ($user['language'] == $temp) | |
1190 | echo "\t\t\t\t\t\t\t\t".'<option value="'.$temp.'" selected="selected">'.$temp.'</option>'."\n"; | |
1191 | else | |
1192 | echo "\t\t\t\t\t\t\t\t".'<option value="'.$temp.'">'.$temp.'</option>'."\n"; | |
1193 | } | |
1194 | ||
1195 | ?> | |
1196 | </select> | |
1197 | <br /></label> | |
1198 | <?php | |
1199 | ||
1200 | } | |
1201 | ||
1202 | ?> | |
1203 | </div> | |
1204 | </fieldset> | |
1205 | </div> | |
1206 | <div class="inform"> | |
1207 | <fieldset> | |
1208 | <legend><?php echo $lang_profile['User activity'] ?></legend> | |
1209 | <div class="infldset"> | |
1210 | <p><?php echo $lang_common['Registered'] ?>: <?php echo format_time($user['registered'], true); if ($pun_user['g_id'] < PUN_GUEST) echo ' (<a href="moderate.php?get_host='.pun_htmlspecialchars($user['registration_ip']).'">'.pun_htmlspecialchars($user['registration_ip']).'</a>)'; ?></p> | |
1211 | <p><?php echo $lang_common['Last post'] ?>: <?php echo $last_post ?></p> | |
1212 | <?php echo $posts_field ?> | |
1213 | <?php if ($pun_user['g_id'] < PUN_GUEST): ?> <label><?php echo $lang_profile['Admin note'] ?><br /> | |
1214 | <input id="admin_note" type="text" name="admin_note" value="<?php echo pun_htmlspecialchars($user['admin_note']) ?>" size="30" maxlength="30" /><br /></label> | |
1215 | </div> | |
1216 | <?php endif; ?> </fieldset> | |
1217 | </div> | |
1218 | <p><input type="submit" name="update" value="<?php echo $lang_common['Submit'] ?>" /><?php echo $lang_profile['Instructions'] ?></p> | |
1219 | </form> | |
1220 | </div> | |
1221 | </div> | |
1222 | <?php | |
1223 | ||
1224 | } | |
1225 | else if ($section == 'personal') | |
1226 | { | |
1227 | if ($pun_user['g_set_title'] == '1') | |
1228 | $title_field = '<label>'.$lang_common['Title'].' (<em>'.$lang_profile['Leave blank'].'</em>)<br /><input type="text" name="title" value="'.pun_htmlspecialchars($user['title']).'" size="30" maxlength="50" /><br /></label>'."\n"; | |
1229 | ||
1230 | $page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / '.$lang_common['Profile']; | |
1231 | require PUN_ROOT.'header.php'; | |
1232 | ||
1233 | generate_profile_menu('personal'); | |
1234 | ||
1235 | ?> | |
1236 | <div class="blockform"> | |
1237 | <h2><span><?php echo pun_htmlspecialchars($user['username']).' - '.$lang_profile['Section personal'] ?></span></h2> | |
1238 | <div class="box"> | |
1239 | <form id="profile2" method="post" action="profile.php?section=personal&id=<?php echo $id ?>"> | |
1240 | <div class="inform"> | |
1241 | <fieldset> | |
1242 | <legend><?php echo $lang_profile['Personal details legend'] ?></legend> | |
1243 | <div class="infldset"> | |
1244 | <input type="hidden" name="form_sent" value="1" /> | |
1245 | <label><?php echo $lang_profile['Realname'] ?><br /><input type="text" name="form[realname]" value="<?php echo pun_htmlspecialchars($user['realname']) ?>" size="40" maxlength="40" /><br /></label> | |
1246 | <?php if (isset($title_field)): ?> <?php echo $title_field ?> | |
1247 | <?php endif; ?> <label><?php echo $lang_profile['Location'] ?><br /><input type="text" name="form[location]" value="<?php echo pun_htmlspecialchars($user['location']) ?>" size="30" maxlength="30" /><br /></label> | |
1248 | <label><?php echo $lang_profile['Website'] ?><br /><input type="text" name="form[url]" value="<?php echo pun_htmlspecialchars($user['url']) ?>" size="50" maxlength="80" /><br /></label> | |
1249 | </div> | |
1250 | </fieldset> | |
1251 | </div> | |
1252 | <p><input type="submit" name="update" value="<?php echo $lang_common['Submit'] ?>" /><?php echo $lang_profile['Instructions'] ?></p> | |
1253 | </form> | |
1254 | </div> | |
1255 | </div> | |
1256 | <?php | |
1257 | ||
1258 | } | |
1259 | else if ($section == 'messaging') | |
1260 | { | |
1261 | ||
1262 | $page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / '.$lang_common['Profile']; | |
1263 | require PUN_ROOT.'header.php'; | |
1264 | ||
1265 | generate_profile_menu('messaging'); | |
1266 | ||
1267 | ?> | |
1268 | <div class="blockform"> | |
1269 | <h2><span><?php echo pun_htmlspecialchars($user['username']).' - '.$lang_profile['Section messaging'] ?></span></h2> | |
1270 | <div class="box"> | |
1271 | <form id="profile3" method="post" action="profile.php?section=messaging&id=<?php echo $id ?>"> | |
1272 | <div class="inform"> | |
1273 | <fieldset> | |
1274 | <legend><?php echo $lang_profile['Contact details legend'] ?></legend> | |
1275 | <div class="infldset"> | |
1276 | <input type="hidden" name="form_sent" value="1" /> | |
1277 | <label><?php echo $lang_profile['Jabber'] ?><br /><input id="jabber" type="text" name="form[jabber]" value="<?php echo pun_htmlspecialchars($user['jabber']) ?>" size="40" maxlength="75" /><br /></label> | |
1278 | <label><?php echo $lang_profile['ICQ'] ?><br /><input id="icq" type="text" name="form[icq]" value="<?php echo $user['icq'] ?>" size="12" maxlength="12" /><br /></label> | |
1279 | <label><?php echo $lang_profile['MSN'] ?><br /><input id="msn" type="text" name="form[msn]" value="<?php echo pun_htmlspecialchars($user['msn']) ?>" size="40" maxlength="50" /><br /></label> | |
1280 | <label><?php echo $lang_profile['AOL IM'] ?><br /><input id="aim" type="text" name="form[aim]" value="<?php echo pun_htmlspecialchars($user['aim']) ?>" size="20" maxlength="30" /><br /></label> | |
1281 | <label><?php echo $lang_profile['Yahoo'] ?><br /><input id="yahoo" type="text" name="form[yahoo]" value="<?php echo pun_htmlspecialchars($user['yahoo']) ?>" size="20" maxlength="30" /><br /></label> | |
1282 | </div> | |
1283 | </fieldset> | |
1284 | </div> | |
1285 | <p><input type="submit" name="update" value="<?php echo $lang_common['Submit'] ?>" /><?php echo $lang_profile['Instructions'] ?></p> | |
1286 | </form> | |
1287 | </div> | |
1288 | </div> | |
1289 | <?php | |
1290 | ||
1291 | } | |
1292 | else if ($section == 'personality') | |
1293 | { | |
1294 | $avatar_field = '<a href="profile.php?action=upload_avatar&id='.$id.'">'.$lang_profile['Change avatar'].'</a>'; | |
1295 | if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$id.'.gif')) | |
1296 | $avatar_format = 'gif'; | |
1297 | else if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$id.'.jpg')) | |
1298 | $avatar_format = 'jpg'; | |
1299 | else if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$id.'.png')) | |
1300 | $avatar_format = 'png'; | |
1301 | else | |
1302 | $avatar_field = '<a href="profile.php?action=upload_avatar&id='.$id.'">'.$lang_profile['Upload avatar'].'</a>'; | |
1303 | ||
1304 | // Display the delete avatar link? | |
1305 | if ($img_size) | |
1306 | $avatar_field .= ' <a href="profile.php?action=delete_avatar&id='.$id.'">'.$lang_profile['Delete avatar'].'</a>'; | |
1307 | ||
1308 | if ($user['signature'] != '') | |
1309 | $signature_preview = '<p>'.$lang_profile['Sig preview'].'</p>'."\n\t\t\t\t\t".'<div class="postsignature">'."\n\t\t\t\t\t\t".'<hr />'."\n\t\t\t\t\t\t".$parsed_signature."\n\t\t\t\t\t".'</div>'."\n"; | |
1310 | else | |
1311 | $signature_preview = '<p>'.$lang_profile['No sig'].'</p>'."\n"; | |
1312 | ||
1313 | $page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / '.$lang_common['Profile']; | |
1314 | require PUN_ROOT.'header.php'; | |
1315 | ||
1316 | generate_profile_menu('personality'); | |
1317 | ||
1318 | ||
1319 | ?> | |
1320 | <div class="blockform"> | |
1321 | <h2><span><?php echo pun_htmlspecialchars($user['username']).' - '.$lang_profile['Section personality'] ?></span></h2> | |
1322 | <div class="box"> | |
1323 | <form id="profile4" method="post" action="profile.php?section=personality&id=<?php echo $id ?>"> | |
1324 | <div><input type="hidden" name="form_sent" value="1" /></div> | |
1325 | <?php if ($pun_config['o_avatars'] == '1'): ?> <div class="inform"> | |
1326 | <fieldset id="profileavatar"> | |
1327 | <legend><?php echo $lang_profile['Avatar legend'] ?></legend> | |
1328 | <div class="infldset"> | |
1329 | <?php if (isset($avatar_format)): ?> <img src="<?php echo $pun_config['o_avatars_dir'].'/'.$id.'.'.$avatar_format ?>" <?php echo $img_size[3] ?> alt="" /> | |
1330 | <?php endif; ?> <p><?php echo $lang_profile['Avatar info'] ?></p> | |
1331 | <div class="rbox"> | |
1332 | <label><input type="checkbox" name="form[use_avatar]" value="1"<?php if ($user['use_avatar'] == '1') echo ' checked="checked"' ?> /><?php echo $lang_profile['Use avatar'] ?><br /></label> | |
1333 | </div> | |
1334 | <p class="clearb"><?php echo $avatar_field ?></p> | |
1335 | </div> | |
1336 | </fieldset> | |
1337 | </div> | |
1338 | <?php endif; ?> <div class="inform"> | |
1339 | <fieldset> | |
1340 | <legend><?php echo $lang_profile['Signature legend'] ?></legend> | |
1341 | <div class="infldset"> | |
1342 | <p><?php echo $lang_profile['Signature info'] ?></p> | |
1343 | <div class="txtarea"> | |
1344 | <label><?php echo $lang_profile['Sig max length'] ?>: <?php echo $pun_config['p_sig_length'] ?> / <?php echo $lang_profile['Sig max lines'] ?>: <?php echo $pun_config['p_sig_lines'] ?><br /> | |
1345 | <textarea name="signature" rows="4" cols="65"><?php echo pun_htmlspecialchars($user['signature']) ?></textarea><br /></label> | |
1346 | </div> | |
1347 | <ul class="bblinks"> | |
1348 | <li><a href="help.php#bbcode" onclick="window.open(this.href); return false;"><?php echo $lang_common['BBCode'] ?></a>: <?php echo ($pun_config['p_sig_bbcode'] == '1') ? $lang_common['on'] : $lang_common['off']; ?></li> | |
1349 | <li><a href="help.php#img" onclick="window.open(this.href); return false;"><?php echo $lang_common['img tag'] ?></a>: <?php echo ($pun_config['p_sig_img_tag'] == '1') ? $lang_common['on'] : $lang_common['off']; ?></li> | |
1350 | <li><a href="help.php#smilies" onclick="window.open(this.href); return false;"><?php echo $lang_common['Smilies'] ?></a>: <?php echo ($pun_config['o_smilies_sig'] == '1') ? $lang_common['on'] : $lang_common['off']; ?></li> | |
1351 | </ul> | |
1352 | <?php echo $signature_preview ?> | |
1353 | </div> | |
1354 | </fieldset> | |
1355 | </div> | |
1356 | <p><input type="submit" name="update" value="<?php echo $lang_common['Submit'] ?>" /><?php echo $lang_profile['Instructions'] ?></p> | |
1357 | </form> | |
1358 | </div> | |
1359 | </div> | |
1360 | <?php | |
1361 | ||
1362 | } | |
1363 | else if ($section == 'display') | |
1364 | { | |
1365 | $page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / '.$lang_common['Profile']; | |
1366 | require PUN_ROOT.'header.php'; | |
1367 | ||
1368 | generate_profile_menu('display'); | |
1369 | ||
1370 | ?> | |
1371 | <div class="blockform"> | |
1372 | <h2><span><?php echo pun_htmlspecialchars($user['username']).' - '.$lang_profile['Section display'] ?></span></h2> | |
1373 | <div class="box"> | |
1374 | <form id="profile5" method="post" action="profile.php?section=display&id=<?php echo $id ?>"> | |
1375 | <div><input type="hidden" name="form_sent" value="1" /></div> | |
1376 | <?php | |
1377 | ||
1378 | $styles = array(); | |
1379 | $d = dir(PUN_ROOT.'style'); | |
1380 | while (($entry = $d->read()) !== false) | |
1381 | { | |
1382 | if (substr($entry, strlen($entry)-4) == '.css') | |
1383 | $styles[] = substr($entry, 0, strlen($entry)-4); | |
1384 | } | |
1385 | $d->close(); | |
1386 | ||
1387 | // Only display the style selection box if there's more than one style available | |
1388 | if (count($styles) == 1) | |
1389 | echo "\t\t\t".'<div><input type="hidden" name="form[style]" value="'.$styles[0].'" /></div>'."\n"; | |
1390 | else if (count($styles) > 1) | |
1391 | { | |
1392 | natsort($styles); | |
1393 | ||
1394 | ?> | |
1395 | <div class="inform"> | |
1396 | <fieldset> | |
1397 | <legend><?php echo $lang_profile['Style legend'] ?></legend> | |
1398 | <div class="infldset"> | |
1399 | <label><?php echo $lang_profile['Style info'] ?><br /> | |
1400 | ||
1401 | <select name="form[style]"> | |
1402 | <?php | |
1403 | ||
1404 | while (list(, $temp) = @each($styles)) | |
1405 | { | |
1406 | if ($user['style'] == $temp) | |
1407 | echo "\t\t\t\t\t\t\t\t".'<option value="'.$temp.'" selected="selected">'.str_replace('_', ' ', $temp).'</option>'."\n"; | |
1408 | else | |
1409 | echo "\t\t\t\t\t\t\t\t".'<option value="'.$temp.'">'.str_replace('_', ' ', $temp).'</option>'."\n"; | |
1410 | } | |
1411 | ||
1412 | ?> | |
1413 | </select> | |
1414 | <br /></label> | |
1415 | </div> | |
1416 | </fieldset> | |
1417 | </div> | |
1418 | <?php | |
1419 | ||
1420 | } | |
1421 | ||
1422 | ?> | |
1423 | <div class="inform"> | |
1424 | <fieldset> | |
1425 | <legend><?php echo $lang_profile['Post display legend'] ?></legend> | |
1426 | <div class="infldset"> | |
1427 | <p><?php echo $lang_profile['Post display info'] ?></p> | |
1428 | <div class="rbox"> | |
1429 | <label><input type="checkbox" name="form[show_smilies]" value="1"<?php if ($user['show_smilies'] == '1') echo ' checked="checked"' ?> /><?php echo $lang_profile['Show smilies'] ?><br /></label> | |
1430 | <label><input type="checkbox" name="form[show_sig]" value="1"<?php if ($user['show_sig'] == '1') echo ' checked="checked"' ?> /><?php echo $lang_profile['Show sigs'] ?><br /></label> | |
1431 | <?php if ($pun_config['o_avatars'] == '1'): ?> <label><input type="checkbox" name="form[show_avatars]" value="1"<?php if ($user['show_avatars'] == '1') echo ' checked="checked"' ?> /><?php echo $lang_profile['Show avatars'] ?><br /></label> | |
1432 | <?php endif; ?> <label><input type="checkbox" name="form[show_img]" value="1"<?php if ($user['show_img'] == '1') echo ' checked="checked"' ?> /><?php echo $lang_profile['Show images'] ?><br /></label> | |
1433 | <label><input type="checkbox" name="form[show_img_sig]" value="1"<?php if ($user['show_img_sig'] == '1') echo ' checked="checked"' ?> /><?php echo $lang_profile['Show images sigs'] ?><br /></label> | |
1434 | </div> | |
1435 | </div> | |
1436 | </fieldset> | |
1437 | </div> | |
1438 | <div class="inform"> | |
1439 | <fieldset> | |
1440 | <legend><?php echo $lang_profile['Pagination legend'] ?></legend> | |
1441 | <div class="infldset"> | |
1442 | <label class="conl"><?php echo $lang_profile['Topics per page'] ?><br /><input type="text" name="form[disp_topics]" value="<?php echo $user['disp_topics'] ?>" size="6" maxlength="3" /><br /></label> | |
1443 | <label class="conl"><?php echo $lang_profile['Posts per page'] ?><br /><input type="text" name="form[disp_posts]" value="<?php echo $user['disp_posts'] ?>" size="6" maxlength="3" /><br /></label> | |
1444 | <p class="clearb"><?php echo $lang_profile['Paginate info'] ?> <?php echo $lang_profile['Leave blank'] ?></p> | |
1445 | </div> | |
1446 | </fieldset> | |
1447 | </div> | |
1448 | <p><input type="submit" name="update" value="<?php echo $lang_common['Submit'] ?>" /> <?php echo $lang_profile['Instructions'] ?></p> | |
1449 | </form> | |
1450 | </div> | |
1451 | </div> | |
1452 | <?php | |
1453 | ||
1454 | } | |
1455 | else if ($section == 'privacy') | |
1456 | { | |
1457 | $page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / '.$lang_common['Profile']; | |
1458 | require PUN_ROOT.'header.php'; | |
1459 | ||
1460 | generate_profile_menu('privacy'); | |
1461 | ||
1462 | ?> | |
1463 | <div class="blockform"> | |
1464 | <h2><span><?php echo pun_htmlspecialchars($user['username']).' - '.$lang_profile['Section privacy'] ?></span></h2> | |
1465 | <div class="box"> | |
1466 | <form id="profile6" method="post" action="profile.php?section=privacy&id=<?php echo $id ?>"> | |
1467 | <div class="inform"> | |
1468 | <fieldset> | |
1469 | <legend><?php echo $lang_prof_reg['Privacy options legend'] ?></legend> | |
1470 | <div class="infldset"> | |
1471 | <input type="hidden" name="form_sent" value="1" /> | |
1472 | <p><?php echo $lang_prof_reg['E-mail setting info'] ?></p> | |
1473 | <div class="rbox"> | |
1474 | <label><input type="radio" name="form[email_setting]" value="0"<?php if ($user['email_setting'] == '0') echo ' checked="checked"' ?> /><?php echo $lang_prof_reg['E-mail setting 1'] ?><br /></label> | |
1475 | <label><input type="radio" name="form[email_setting]" value="1"<?php if ($user['email_setting'] == '1') echo ' checked="checked"' ?> /><?php echo $lang_prof_reg['E-mail setting 2'] ?><br /></label> | |
1476 | <label><input type="radio" name="form[email_setting]" value="2"<?php if ($user['email_setting'] == '2') echo ' checked="checked"' ?> /><?php echo $lang_prof_reg['E-mail setting 3'] ?><br /></label> | |
1477 | </div> | |
1478 | <p><?php echo $lang_prof_reg['Save user/pass info'] ?></p> | |
1479 | <div class="rbox"> | |
1480 | <label><input type="checkbox" name="form[save_pass]" value="1"<?php if ($user['save_pass'] == '1') echo ' checked="checked"' ?> /><?php echo $lang_prof_reg['Save user/pass'] ?><br /></label> | |
1481 | </div> | |
1482 | <p><?php echo $lang_profile['Notify full info'] ?></p> | |
1483 | <div class="rbox"> | |
1484 | <label><input type="checkbox" name="form[notify_with_post]" value="1"<?php if ($user['notify_with_post'] == '1') echo ' checked="checked"' ?> /><?php echo $lang_profile['Notify full'] ?><br /></label> | |
1485 | </div> | |
1486 | </div> | |
1487 | </fieldset> | |
1488 | </div> | |
1489 | <p><input type="submit" name="update" value="<?php echo $lang_common['Submit'] ?>" /><?php echo $lang_profile['Instructions'] ?></p> | |
1490 | </form> | |
1491 | </div> | |
1492 | </div> | |
1493 | <?php | |
1494 | ||
1495 | } | |
1496 | else if ($section == 'admin') | |
1497 | { | |
1498 | if ($pun_user['g_id'] > PUN_MOD || ($pun_user['g_id'] == PUN_MOD && $pun_config['p_mod_ban_users'] == '0')) | |
1499 | message($lang_common['Bad request']); | |
1500 | ||
1501 | $page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / '.$lang_common['Profile']; | |
1502 | require PUN_ROOT.'header.php'; | |
1503 | ||
1504 | generate_profile_menu('admin'); | |
1505 | ||
1506 | ?> | |
1507 | <div class="blockform"> | |
1508 | <h2><span><?php echo pun_htmlspecialchars($user['username']).' - '.$lang_profile['Section admin'] ?></span></h2> | |
1509 | <div class="box"> | |
1510 | <form id="profile7" method="post" action="profile.php?section=admin&id=<?php echo $id ?>&action=foo"> | |
1511 | <div class="inform"> | |
1512 | <input type="hidden" name="form_sent" value="1" /> | |
1513 | <fieldset> | |
1514 | <?php | |
1515 | ||
1516 | if ($pun_user['g_id'] == PUN_MOD) | |
1517 | { | |
1518 | ||
1519 | ?> | |
1520 | <legend><?php echo $lang_profile['Delete ban legend'] ?></legend> | |
1521 | <div class="infldset"> | |
1522 | <p><input type="submit" name="ban" value="<?php echo $lang_profile['Ban user'] ?>" /></p> | |
1523 | </div> | |
1524 | </fieldset> | |
1525 | </div> | |
1526 | <?php | |
1527 | ||
1528 | } | |
1529 | else | |
1530 | { | |
1531 | if ($pun_user['id'] != $id) | |
1532 | { | |
1533 | ||
1534 | ?> | |
1535 | <legend><?php echo $lang_profile['Group membership legend'] ?></legend> | |
1536 | <div class="infldset"> | |
1537 | <select id="group_id" name="group_id"> | |
1538 | <?php | |
1539 | ||
1540 | $result = $db->query('SELECT g_id, g_title FROM '.$db->prefix.'groups WHERE g_id!='.PUN_GUEST.' ORDER BY g_title') or error('Unable to fetch user group list', __FILE__, __LINE__, $db->error()); | |
1541 | ||
1542 | while ($cur_group = $db->fetch_assoc($result)) | |
1543 | { | |
1544 | if ($cur_group['g_id'] == $user['g_id'] || ($cur_group['g_id'] == $pun_config['o_default_user_group'] && $user['g_id'] == '')) | |
1545 | echo "\t\t\t\t\t\t\t\t".'<option value="'.$cur_group['g_id'].'" selected="selected">'.pun_htmlspecialchars($cur_group['g_title']).'</option>'."\n"; | |
1546 | else | |
1547 | echo "\t\t\t\t\t\t\t\t".'<option value="'.$cur_group['g_id'].'">'.pun_htmlspecialchars($cur_group['g_title']).'</option>'."\n"; | |
1548 | } | |
1549 | ||
1550 | ?> | |
1551 | </select> | |
1552 | <input type="submit" name="update_group_membership" value="<?php echo $lang_profile['Save'] ?>" /> | |
1553 | </div> | |
1554 | </fieldset> | |
1555 | </div> | |
1556 | <div class="inform"> | |
1557 | <fieldset> | |
1558 | <?php | |
1559 | ||
1560 | } | |
1561 | ||
1562 | ?> | |
1563 | <legend><?php echo $lang_profile['Delete ban legend'] ?></legend> | |
1564 | <div class="infldset"> | |
1565 | <input type="submit" name="delete_user" value="<?php echo $lang_profile['Delete user'] ?>" /> <input type="submit" name="ban" value="<?php echo $lang_profile['Ban user'] ?>" /> | |
1566 | </div> | |
1567 | </fieldset> | |
1568 | </div> | |
1569 | <?php | |
1570 | ||
1571 | if ($user['g_id'] == PUN_MOD || $user['g_id'] == PUN_ADMIN) | |
1572 | { | |
1573 | ||
1574 | ?> | |
1575 | <div class="inform"> | |
1576 | <fieldset> | |
1577 | <legend><?php echo $lang_profile['Set mods legend'] ?></legend> | |
1578 | <div class="infldset"> | |
1579 | <p><?php echo $lang_profile['Moderator in info'] ?></p> | |
1580 | <?php | |
1581 | ||
1582 | $result = $db->query('SELECT c.id AS cid, c.cat_name, f.id AS fid, f.forum_name, f.moderators FROM '.$db->prefix.'categories AS c INNER JOIN '.$db->prefix.'forums AS f ON c.id=f.cat_id WHERE f.redirect_url IS NULL ORDER BY c.disp_position, c.id, f.disp_position') or error('Unable to fetch category/forum list', __FILE__, __LINE__, $db->error()); | |
1583 | ||
1584 | $cur_category = 0; | |
1585 | while ($cur_forum = $db->fetch_assoc($result)) | |
1586 | { | |
1587 | if ($cur_forum['cid'] != $cur_category) // A new category since last iteration? | |
1588 | { | |
1589 | if ($cur_category) | |
1590 | echo "\n\t\t\t\t\t\t\t\t".'</div>'; | |
1591 | ||
1592 | if ($cur_category != 0) | |
1593 | echo "\n\t\t\t\t\t\t\t".'</div>'."\n"; | |
1594 | ||
1595 | echo "\t\t\t\t\t\t\t".'<div class="conl">'."\n\t\t\t\t\t\t\t\t".'<p><strong>'.$cur_forum['cat_name'].'</strong></p>'."\n\t\t\t\t\t\t\t\t".'<div class="rbox">'; | |
1596 | $cur_category = $cur_forum['cid']; | |
1597 | } | |
1598 | ||
1599 | $moderators = ($cur_forum['moderators'] != '') ? unserialize($cur_forum['moderators']) : array(); | |
1600 | ||
1601 | echo "\n\t\t\t\t\t\t\t\t\t".'<label><input type="checkbox" name="moderator_in['.$cur_forum['fid'].']" value="1"'.((in_array($id, $moderators)) ? ' checked="checked"' : '').' />'.pun_htmlspecialchars($cur_forum['forum_name']).'<br /></label>'."\n"; | |
1602 | } | |
1603 | ||
1604 | ?> | |
1605 | </div> | |
1606 | </div> | |
1607 | <br class="clearb" /><input type="submit" name="update_forums" value="<?php echo $lang_profile['Update forums'] ?>" /> | |
1608 | </div> | |
1609 | </fieldset> | |
1610 | </div> | |
1611 | <?php | |
1612 | ||
1613 | } | |
1614 | } | |
1615 | ||
1616 | ?> | |
1617 | </form> | |
1618 | </div> | |
1619 | </div> | |
1620 | <?php | |
1621 | ||
1622 | } | |
1623 | ||
1624 | ?> | |
1625 | <div class="clearer"></div> | |
1626 | </div> | |
1627 | <?php | |
1628 | ||
1629 | require PUN_ROOT.'footer.php'; | |
1630 | } |