PageRenderTime 39ms CodeModel.GetById 31ms RepoModel.GetById 1ms app.codeStats 0ms

/profile.php

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