PageRenderTime 60ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 1ms

/other/punbb-modified-forum/profile.php

https://bitbucket.org/Balancer/projects-balancer
PHP | 1629 lines | 1334 code | 212 blank | 83 comment | 419 complexity | 91b60f5e856ba7ef09b55eee0e6e9696 MD5 | raw file
Possible License(s): AGPL-1.0

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. //if(1 || !empty($_POST['form'])) { echo "<xmp>"; print_r($_POST); print_r($_GET); print_r($_FILES); echo "</xmp>"; exit(); }
  3. /***********************************************************************
  4. Copyright (C) 2002-2005 Rickard Andersson (rickard@punbb.org)
  5. This file is part of PunBB.
  6. PunBB is free software; you can redistribute it and/or modify it
  7. under the terms of the GNU General Public License as published
  8. by the Free Software Foundation; either version 2 of the License,
  9. or (at your option) any later version.
  10. PunBB is distributed in the hope that it will be useful, but
  11. WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with this program; if not, write to the Free Software
  16. Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  17. MA 02111-1307 USA
  18. ************************************************************************/
  19. define('PUN_ROOT', dirname(__FILE__).'/');
  20. require PUN_ROOT.'include/common.php';
  21. if($_SERVER['HTTP_HOST'] != 'www.balancer.ru' || !preg_match('!^/forum/punbb/!', $_SERVER['REQUEST_URI']))
  22. {
  23. include_once('inc/navigation.php');
  24. go("http://www.balancer.ru/forum/punbb/profile.php" . (empty($_SERVER['QUERY_STRING']) ? "" : "?".$_SERVER['QUERY_STRING']), true);
  25. exit("Redirected");
  26. }
  27. $action = isset($_GET['action']) ? $_GET['action'] : null;
  28. $section = isset($_GET['section']) ? $_GET['section'] : null;
  29. $id = isset($_GET['id']) ? intval($_GET['id']) : 0;
  30. if ($id < 2)
  31. message($lang_common['Bad request']);
  32. if ($pun_user['g_read_board'] == '0' && ($action != 'change_pass' || !isset($_GET['key'])))
  33. message($lang_common['No view']);
  34. // Load the profile.php/register.php language file
  35. require PUN_ROOT.'lang/'.$pun_user['language'].'/prof_reg.php';
  36. // Load the profile.php language file
  37. require PUN_ROOT.'lang/'.$pun_user['language'].'/profile.php';
  38. if ($action == 'change_pass')
  39. {
  40. if (isset($_GET['key']))
  41. {
  42. // If the user is already logged in we shouldn't be here :)
  43. if (!$pun_user['is_guest'])
  44. {
  45. header('Location: index.php');
  46. exit;
  47. }
  48. $key = $_GET['key'];
  49. $user = bors_find_first('airbase_user', array('activate_key' => $key));
  50. if(!$key || !$user)
  51. message($lang_profile['Pass key bad'].' <a href="mailto:'.$pun_config['o_admin_email'].'">'.$pun_config['o_admin_email'].'</a>.');
  52. $user->set_password_hash_new($user->activate_string());
  53. message($lang_profile['Pass updated'], true);
  54. }
  55. // Make sure we are allowed to change this users password
  56. if ($pun_user['id'] != $id)
  57. {
  58. if ($pun_user['g_id'] > PUN_MOD) // A regular user trying to change another users password?
  59. message($lang_common['No permission']);
  60. else if ($pun_user['g_id'] == PUN_MOD) // A moderator trying to change a users password?
  61. {
  62. $result = $db->query('SELECT group_id FROM '.$db->prefix.'users WHERE id='.$id) or error('Unable to fetch user info', __FILE__, __LINE__, $db->error());
  63. if (!$db->num_rows($result))
  64. message($lang_common['Bad request']);
  65. if ($pun_config['p_mod_edit_users'] == '0' || $pun_config['p_mod_change_passwords'] == '0' || $db->result($result) < PUN_GUEST)
  66. message($lang_common['No permission']);
  67. }
  68. }
  69. if (isset($_POST['form_sent']))
  70. {
  71. $old_password = isset($_POST['req_old_password']) ? trim($_POST['req_old_password']) : '';
  72. $new_password1 = trim($_POST['req_new_password1']);
  73. $new_password2 = trim($_POST['req_new_password2']);
  74. $user = bors_load('airbase_user', $id);
  75. if(!$user)
  76. message(ec('Не могу найти пользователя с ID=').$id);
  77. $is_admin = $pun_user['g_id'] == PUN_ADMIN;
  78. if(!$is_admin && !$user->check_password($old_password, false))
  79. {
  80. // debug_hidden_log('_pass_ch_err', "old=$old_password, new={$_POST['req_new_password1']}");
  81. message($lang_profile['Wrong pass'].' [1]');
  82. }
  83. // else
  84. // debug_hidden_log('_pass_ch_ok', "old=$old_password, new={$_POST['req_new_password1']}");
  85. if($new_password1 != $new_password2)
  86. message($lang_prof_reg['Pass not match']);
  87. if(strlen($new_password1) < 4)
  88. message($lang_prof_reg['Pass too short']);
  89. $user->change_password($new_password1);
  90. $user->cookie_hash_update($save_pass ? -1 : 0);
  91. redirect('profile.php?section=essentials&amp;id='.$id, $lang_profile['Pass updated redirect']);
  92. }
  93. $page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / '.$lang_common['Profile'];
  94. $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']);
  95. $focus_element = array('change_pass', (($pun_user['g_id'] > PUN_MOD) ? 'req_old_password' : 'req_new_password1'));
  96. require PUN_ROOT.'header.php';
  97. ?>
  98. <div class="blockform">
  99. <h2><span><?php echo $lang_profile['Change pass'] ?></span></h2>
  100. <div class="box">
  101. <form id="change_pass" method="post" action="profile.php?action=change_pass&amp;id=<?php echo $id;/*"*/?>" onsubmit="return process_form(this)">
  102. <div class="inform">
  103. <input type="hidden" name="form_sent" value="1" />
  104. <fieldset>
  105. <legend><?php echo $lang_profile['Change pass legend'] ?></legend>
  106. <div class="infldset">
  107. <?php if ($pun_user['g_id'] > PUN_MOD): ?> <label><strong><?php echo $lang_profile['Old pass'] ?></strong><br />
  108. <input type="password" name="req_old_password" size="16" maxlength="16" /><br /></label>
  109. <?php endif; ?> <label class="conl"><strong><?php echo $lang_profile['New pass'] ?></strong><br />
  110. <input type="password" name="req_new_password1" size="16" maxlength="16" /><br /></label>
  111. <label class="conl"><strong><?php echo $lang_profile['Confirm new pass'] ?></strong><br />
  112. <input type="password" name="req_new_password2" size="16" maxlength="16" /><br /></label>
  113. <div class="clearb"></div>
  114. </div>
  115. </fieldset>
  116. </div>
  117. <p><input type="submit" name="update" value="<?php echo $lang_common['Submit'] ?>" /><a href="javascript:history.go(-1)"><?php echo $lang_common['Go back'];/*"*/?></a></p>
  118. </form>
  119. </div>
  120. </div>
  121. <?php
  122. require PUN_ROOT.'footer.php';
  123. }
  124. else if ($action == 'change_email')
  125. {
  126. // Make sure we are allowed to change this users e-mail
  127. if ($pun_user['id'] != $id)
  128. {
  129. if ($pun_user['g_id'] > PUN_MOD) // A regular user trying to change another users e-mail?
  130. message($lang_common['No permission']);
  131. else if ($pun_user['g_id'] == PUN_MOD) // A moderator trying to change a users e-mail?
  132. {
  133. $result = $db->query('SELECT group_id FROM '.$db->prefix.'users WHERE id='.$id) or error('Unable to fetch user info', __FILE__, __LINE__, $db->error());
  134. if (!$db->num_rows($result))
  135. message($lang_common['Bad request']);
  136. if ($pun_config['p_mod_edit_users'] == '0' || $db->result($result) < PUN_GUEST)
  137. message($lang_common['No permission']);
  138. }
  139. }
  140. if (isset($_GET['key']))
  141. {
  142. $key = $_GET['key'];
  143. $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());
  144. list($new_email, $new_email_key) = $db->fetch_row($result);
  145. if ($key != $new_email_key)
  146. message($lang_profile['E-mail key bad'].' <a href="mailto:'.$pun_config['o_admin_email'].'">'.$pun_config['o_admin_email'].'</a>.');
  147. else
  148. {
  149. $db->query('UPDATE '.$db->prefix.'users SET email=activate_string, activate_string=NULL, activate_key=NULL WHERE id='.$id) or error('Unable to update e-mail address', __FILE__, __LINE__, $db->error());
  150. message($lang_profile['E-mail updated'], true);
  151. }
  152. }
  153. else if (isset($_POST['form_sent']))
  154. {
  155. if (pun_hash($_POST['req_password'], $pun_user['username']) !== $pun_user['password'])
  156. message($lang_profile['Wrong pass'].'[2]');
  157. require PUN_ROOT.'include/email.php';
  158. // Validate the email-address
  159. $new_email = strtolower(trim($_POST['req_new_email']));
  160. if (!is_valid_email($new_email))
  161. message($lang_common['Invalid e-mail']);
  162. // Check it it's a banned e-mail address
  163. if (is_banned_email($new_email))
  164. {
  165. if ($pun_config['p_allow_banned_email'] == '0')
  166. message($lang_prof_reg['Banned e-mail']);
  167. else if ($pun_config['o_mailing_list'] != '')
  168. {
  169. $mail_subject = 'Alert - Banned e-mail detected';
  170. $mail_message = 'User \''.$pun_user['username'].'\' changed to banned e-mail address: '.$new_email."\n\n".'User profile: '.$pun_config['o_base_url'].'/profile.php?id='.$id."\n\n".'-- '."\n".'Forum Mailer'."\n".'(Do not reply to this message)';
  171. pun_mail($pun_config['o_mailing_list'], $mail_subject, $mail_message);
  172. }
  173. }
  174. // Check if someone else already has registered with that e-mail address
  175. $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());
  176. if ($db->num_rows($result))
  177. {
  178. if ($pun_config['p_allow_dupe_email'] == '0')
  179. message($lang_prof_reg['Dupe e-mail']);
  180. else if ($pun_config['o_mailing_list'] != '')
  181. {
  182. while ($cur_dupe = $db->fetch_assoc($result))
  183. $dupe_list[] = $cur_dupe['username'];
  184. $mail_subject = 'Alert - Duplicate e-mail detected';
  185. $mail_message = 'User \''.$pun_user['username'].'\' changed to an e-mail address that also belongs to: '.implode(', ', $dupe_list)."\n\n".'User profile: '.$pun_config['o_base_url'].'/profile.php?id='.$id."\n\n".'-- '."\n".'Forum Mailer'."\n".'(Do not reply to this message)';
  186. pun_mail($pun_config['o_mailing_list'], $mail_subject, $mail_message);
  187. }
  188. }
  189. $new_email_key = random_pass(8);
  190. $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());
  191. // Load the "activate e-mail" template
  192. $mail_tpl = trim(file_get_contents(PUN_ROOT.'lang/'.$pun_user['language'].'/mail_templates/activate_email.tpl'));
  193. // The first row contains the subject
  194. $first_crlf = strpos($mail_tpl, "\n");
  195. $mail_subject = trim(substr($mail_tpl, 8, $first_crlf-8));
  196. $mail_message = trim(substr($mail_tpl, $first_crlf));
  197. $mail_message = str_replace('<username>', $pun_user['username'], $mail_message);
  198. $mail_message = str_replace('<base_url>', $pun_config['o_base_url'], $mail_message);
  199. $mail_message = str_replace('<activation_url>', $pun_config['o_base_url'].'/profile.php?action=change_email&id='.$id.'&key='.$new_email_key, $mail_message);
  200. $mail_message = str_replace('<board_mailer>', $pun_config['o_board_title'].' '.$lang_common['Mailer'], $mail_message);
  201. pun_mail($new_email, $mail_subject, $mail_message);
  202. message($lang_profile['Activate e-mail sent'].' <a href="mailto:'.$pun_config['o_admin_email'].'">'.$pun_config['o_admin_email'].'</a>.', true);
  203. }
  204. $page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / '.$lang_common['Profile'];
  205. $required_fields = array('req_new_email' => $lang_profile['New e-mail'], 'req_password' => $lang_common['Password']);
  206. $focus_element = array('change_email', 'req_new_email');
  207. require PUN_ROOT.'header.php';
  208. ?>
  209. <div class="blockform">
  210. <h2><span><?php echo $lang_profile['Change e-mail'] ?></span></h2>
  211. <div class="box">
  212. <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)">
  213. <div class="inform">
  214. <fieldset>
  215. <legend><?php echo $lang_profile['E-mail legend'] ?></legend>
  216. <div class="infldset">
  217. <input type="hidden" name="form_sent" value="1" />
  218. <label><strong><?php echo $lang_profile['New e-mail'] ?></strong><br /><input type="text" name="req_new_email" size="50" maxlength="50" /><br /></label>
  219. <label><strong><?php echo $lang_common['Password'] ?></strong><br /><input type="password" name="req_password" size="16" maxlength="16" /><br /></label>
  220. <p><?php echo $lang_profile['E-mail instructions'] ?></p>
  221. </div>
  222. </fieldset>
  223. </div>
  224. <p><input type="submit" name="new_email" value="<?php echo $lang_common['Submit']; /*"*/ ?>" /><a href="javascript:history.go(-1)"><?php echo $lang_common['Go back'] ?></a></p>
  225. </form>
  226. </div>
  227. </div>
  228. <?php
  229. require PUN_ROOT.'footer.php';
  230. }
  231. else if ($action == 'upload_avatar' || $action == 'upload_avatar2')
  232. {
  233. if ($pun_config['o_avatars'] == '0')
  234. message($lang_profile['Avatars disabled']);
  235. if ($pun_user['id'] != $id && $pun_user['g_id'] > PUN_MOD)
  236. message($lang_common['No permission']);
  237. if (isset($_POST['form_sent']))
  238. {
  239. if (!isset($_FILES['req_file']))
  240. message($lang_profile['No file']);
  241. $uploaded_file = $_FILES['req_file'];
  242. // Make sure the upload went smooth
  243. if (isset($uploaded_file['error']))
  244. {
  245. switch ($uploaded_file['error'])
  246. {
  247. case 1: // UPLOAD_ERR_INI_SIZE
  248. case 2: // UPLOAD_ERR_FORM_SIZE
  249. message($lang_profile['Too large ini']);
  250. break;
  251. case 3: // UPLOAD_ERR_PARTIAL
  252. message($lang_profile['Partial upload']);
  253. break;
  254. case 4: // UPLOAD_ERR_NO_FILE
  255. message($lang_profile['No file']);
  256. break;
  257. case 6: // UPLOAD_ERR_NO_TMP_DIR
  258. message($lang_profile['No tmp directory']);
  259. break;
  260. default:
  261. // No error occured, but was something actually uploaded?
  262. if ($uploaded_file['size'] == 0)
  263. message($lang_profile['No file']);
  264. break;
  265. }
  266. }
  267. if (is_uploaded_file($uploaded_file['tmp_name']))
  268. {
  269. $allowed_types = array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/png', 'image/x-png');
  270. if (!in_array($uploaded_file['type'], $allowed_types))
  271. message($lang_profile['Bad type']);
  272. // Make sure the file isn't too big
  273. if ($uploaded_file['size'] > $pun_config['o_avatars_size'])
  274. message($lang_profile['Too large'].' '.$pun_config['o_avatars_size'].' '.$lang_profile['bytes'].'.');
  275. // Determine type
  276. $extensions = null;
  277. if ($uploaded_file['type'] == 'image/gif')
  278. $extensions = array('.gif', '.jpg', '.png');
  279. else if ($uploaded_file['type'] == 'image/jpeg' || $uploaded_file['type'] == 'image/pjpeg')
  280. $extensions = array('.jpg', '.gif', '.png');
  281. else
  282. $extensions = array('.png', '.gif', '.jpg');
  283. // Move the file to the avatar directory. We do this before checking the width/height to circumvent open_basedir restrictions.
  284. if (!@move_uploaded_file($uploaded_file['tmp_name'], $pun_config['o_avatars_dir'].'/'.$id.'.tmp'))
  285. message($lang_profile['Move failed'].' <a href="mailto:'.$pun_config['o_admin_email'].'">'.$pun_config['o_admin_email'].'</a>.');
  286. // Now check the width/height
  287. list($width, $height, $type,) = getimagesize($pun_config['o_avatars_dir'].'/'.$id.'.tmp');
  288. if (empty($width) || empty($height) || $width > $pun_config['o_avatars_width'] || $height > $pun_config['o_avatars_height'])
  289. {
  290. @unlink($pun_config['o_avatars_dir'].'/'.$id.'.tmp');
  291. message($lang_profile['Too wide or high'].' '.$pun_config['o_avatars_width'].'x'.$pun_config['o_avatars_height'].' '.$lang_profile['pixels'].'.');
  292. }
  293. else if ($type == 1 && $uploaded_file['type'] != 'image/gif') // Prevent dodgy uploads
  294. {
  295. @unlink($pun_config['o_avatars_dir'].'/'.$id.'.tmp');
  296. message($lang_profile['Bad type']);
  297. }
  298. // Delete any old avatars and put the new one in place
  299. @unlink($pun_config['o_avatars_dir'].'/'.$id.$extensions[0]);
  300. @unlink($pun_config['o_avatars_dir'].'/'.$id.$extensions[1]);
  301. @unlink($pun_config['o_avatars_dir'].'/'.$id.$extensions[2]);
  302. @rename($pun_config['o_avatars_dir'].'/'.$id.'.tmp', $pun_config['o_avatars_dir'].'/'.$id.$extensions[0]);
  303. @chmod($pun_config['o_avatars_dir'].'/'.$id.$extensions[0], 0666);
  304. }
  305. else
  306. message($lang_profile['Unknown failure']);
  307. $avatars_dir = '/var/www/balancer.ru/htdocs/forum/punbb/img/avatars';
  308. $user_avatar = "";
  309. if($img_size = @getimagesize("$avatars_dir/$id.gif"))
  310. $user_avatar = "$id.gif";
  311. elseif($img_size = @getimagesize("$avatars_dir/$id.png"))
  312. $user_avatar = "$id.png";
  313. elseif($img_size = @getimagesize("$avatars_dir/$id.jpg"))
  314. $user_avatar = "$id.jpg";
  315. bors()->changed_save(); // Сохраняем всё. А то, вдруг, там где-то старые параметры аватара.
  316. // Enable use_avatar (seems sane since the user just uploaded an avatar)
  317. $db->query("UPDATE {$db->prefix}users SET use_avatar='".addslashes($user_avatar)."', avatar_width={$img_size[0]}, avatar_height={$img_size[0]} WHERE id=$id")
  318. or error('Unable to update avatar state', __FILE__, __LINE__, $db->error());
  319. redirect('profile.php?section=personality&amp;id='.$id, $lang_profile['Avatar upload redirect']);
  320. }
  321. $page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / '.$lang_common['Profile'];
  322. $required_fields = array('req_file' => $lang_profile['File']);
  323. $focus_element = array('upload_avatar', 'req_file');
  324. require PUN_ROOT.'header.php';
  325. ?>
  326. <div class="blockform">
  327. <h2><span><?php echo $lang_profile['Upload avatar'] ?></span></h2>
  328. <div class="box">
  329. <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)">
  330. <div class="inform">
  331. <fieldset>
  332. <legend><?php echo $lang_profile['Upload avatar legend'] ?></legend>
  333. <div class="infldset">
  334. <input type="hidden" name="form_sent" value="1" />
  335. <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $pun_config['o_avatars_size'];/*"*/ ?>" />
  336. <label><strong><?php echo $lang_profile['File'] ?></strong><br /><input name="req_file" type="file" size="40" /><br /></label>
  337. <p><?php echo $lang_profile['Avatar desc'].' '.$pun_config['o_avatars_width'].' x '.$pun_config['o_avatars_height'].' '.$lang_profile['pixels'].' '.$lang_common['and'].' '.$pun_config['o_avatars_size'].' '.$lang_profile['bytes'].' ('.ceil($pun_config['o_avatars_size'] / 1024) ?> KB).</p>
  338. </div>
  339. </fieldset>
  340. </div>
  341. <p><input type="submit" name="upload" value="<?php echo $lang_profile['Upload'];/*"*/ ?>" /><a href="javascript:history.go(-1)"><?php echo $lang_common['Go back'] ?></a></p>
  342. </form>
  343. </div>
  344. </div>
  345. <?php
  346. require PUN_ROOT.'footer.php';
  347. }
  348. else if ($action == 'delete_avatar')
  349. {
  350. if ($pun_user['id'] != $id && $pun_user['g_id'] > PUN_MOD)
  351. message($lang_common['No permission']);
  352. confirm_referrer('profile.php');
  353. @unlink($pun_config['o_avatars_dir'].'/'.$id.'.jpg');
  354. @unlink($pun_config['o_avatars_dir'].'/'.$id.'.png');
  355. @unlink($pun_config['o_avatars_dir'].'/'.$id.'.gif');
  356. // Disable use_avatar
  357. $db->query("UPDATE {$db->prefix}users SET use_avatar='' WHERE id=$id")
  358. or error('Unable to update avatar state', __FILE__, __LINE__, $db->error());
  359. redirect('profile.php?section=personality&amp;id='.$id, $lang_profile['Avatar deleted redirect']);
  360. }
  361. else if (isset($_POST['update_group_membership']))
  362. {
  363. if ($pun_user['g_id'] > PUN_ADMIN)
  364. message($lang_common['No permission']);
  365. confirm_referrer('profile.php');
  366. $new_group_id = intval($_POST['group_id']);
  367. $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());
  368. // If the user was a moderator or an administrator, we remove him/her from the moderator list in all forums as well
  369. if ($new_group_id > PUN_MOD)
  370. {
  371. $result = $db->query('SELECT id, moderators FROM '.$db->prefix.'forums') or error('Unable to fetch forum list', __FILE__, __LINE__, $db->error());
  372. while ($cur_forum = $db->fetch_assoc($result))
  373. {
  374. $cur_moderators = ($cur_forum['moderators'] != '') ? unserialize($cur_forum['moderators']) : array();
  375. if (in_array($id, $cur_moderators))
  376. {
  377. $username = array_search($id, $cur_moderators);
  378. unset($cur_moderators[$username]);
  379. $cur_moderators = (!empty($cur_moderators)) ? '\''.$db->escape(serialize($cur_moderators)).'\'' : 'NULL';
  380. $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());
  381. }
  382. }
  383. }
  384. redirect('profile.php?section=admin&amp;id='.$id, $lang_profile['Group membership redirect']);
  385. }
  386. else if (isset($_POST['update_forums']))
  387. {
  388. if ($pun_user['g_id'] > PUN_ADMIN)
  389. message($lang_common['No permission']);
  390. confirm_referrer('profile.php');
  391. // Get the username of the user we are processing
  392. $result = $db->query('SELECT username FROM '.$db->prefix.'users WHERE id='.$id) or error('Unable to fetch user info', __FILE__, __LINE__, $db->error());
  393. $username = $db->result($result);
  394. $moderator_in = (isset($_POST['moderator_in'])) ? array_keys($_POST['moderator_in']) : array();
  395. // Loop through all forums
  396. $result = $db->query('SELECT id, moderators FROM '.$db->prefix.'forums') or error('Unable to fetch forum list', __FILE__, __LINE__, $db->error());
  397. while ($cur_forum = $db->fetch_assoc($result))
  398. {
  399. $cur_moderators = ($cur_forum['moderators'] != '') ? unserialize($cur_forum['moderators']) : array();
  400. // If the user should have moderator access (and he/she doesn't already have it)
  401. if (in_array($cur_forum['id'], $moderator_in) && !in_array($id, $cur_moderators))
  402. {
  403. $cur_moderators[$username] = $id;
  404. ksort($cur_moderators);
  405. $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());
  406. }
  407. // If the user shouldn't have moderator access (and he/she already has it)
  408. else if (!in_array($cur_forum['id'], $moderator_in) && in_array($id, $cur_moderators))
  409. {
  410. unset($cur_moderators[$username]);
  411. $cur_moderators = (!empty($cur_moderators)) ? '\''.$db->escape(serialize($cur_moderators)).'\'' : 'NULL';
  412. $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());
  413. }
  414. }
  415. redirect('profile.php?section=admin&amp;id='.$id, $lang_profile['Update forums redirect']);
  416. }
  417. else if (isset($_POST['ban']))
  418. {
  419. if ($pun_user['g_id'] > PUN_MOD || ($pun_user['g_id'] == PUN_MOD && $pun_config['p_mod_ban_users'] == '0'))
  420. message($lang_common['No permission']);
  421. redirect('admin_bans.php?add_ban='.$id, $lang_profile['Ban redirect']);
  422. }
  423. else if (isset($_POST['delete_user']) || isset($_POST['delete_user_comply']))
  424. {
  425. if ($pun_user['g_id'] > PUN_ADMIN)
  426. message($lang_common['No permission']);
  427. confirm_referrer('profile.php');
  428. // Get the username and group of the user we are deleting
  429. $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());
  430. list($group_id, $username) = $db->fetch_row($result);
  431. if ($group_id == PUN_ADMIN)
  432. message('Administrators cannot be deleted. In order to delete this user, you must first move him/her to a different user group.');
  433. if (isset($_POST['delete_user_comply']))
  434. {
  435. // If the user is a moderator or an administrator, we remove him/her from the moderator list in all forums as well
  436. if ($group_id < PUN_GUEST)
  437. {
  438. $result = $db->query('SELECT id, moderators FROM '.$db->prefix.'forums') or error('Unable to fetch forum list', __FILE__, __LINE__, $db->error());
  439. while ($cur_forum = $db->fetch_assoc($result))
  440. {
  441. $cur_moderators = ($cur_forum['moderators'] != '') ? unserialize($cur_forum['moderators']) : array();
  442. if (in_array($id, $cur_moderators))
  443. {
  444. unset($cur_moderators[$username]);
  445. $cur_moderators = (!empty($cur_moderators)) ? '\''.$db->escape(serialize($cur_moderators)).'\'' : 'NULL';
  446. $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());
  447. }
  448. }
  449. }
  450. // Delete any subscriptions
  451. $db->query('DELETE FROM '.$db->prefix.'subscriptions WHERE user_id='.$id) or error('Unable to delete subscriptions', __FILE__, __LINE__, $db->error());
  452. // Remove him/her from the online list (if they happen to be logged in)
  453. $db->query('DELETE FROM '.$db->prefix.'online WHERE user_id='.$id) or error('Unable to remove user from online list', __FILE__, __LINE__, $db->error());
  454. // Should we delete all posts made by this user?
  455. if (isset($_POST['delete_posts']))
  456. {
  457. require PUN_ROOT.'include/search_idx.php';
  458. @set_time_limit(0);
  459. // Find all posts made by this user
  460. $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());
  461. if ($db->num_rows($result))
  462. {
  463. while ($cur_post = $db->fetch_assoc($result))
  464. {
  465. // Determine whether this post is the "topic post" or not
  466. $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());
  467. if ($db->result($result2) == $cur_post['id'])
  468. delete_topic($cur_post['topic_id']);
  469. else
  470. delete_post($cur_post['id'], $cur_post['topic_id']);
  471. update_forum($cur_post['forum_id']);
  472. }
  473. }
  474. }
  475. else
  476. // Set all his/her posts to guest
  477. $db->query('UPDATE '.$db->prefix.'posts SET poster_id=1 WHERE poster_id='.$id) or error('Unable to update posts', __FILE__, __LINE__, $db->error());
  478. // Delete the user
  479. $db->query('DELETE FROM '.$db->prefix.'users WHERE id='.$id) or error('Unable to delete user', __FILE__, __LINE__, $db->error());
  480. redirect('index.php', $lang_profile['User delete redirect']);
  481. }
  482. $page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / '.$lang_common['Profile'];
  483. require PUN_ROOT.'header.php';
  484. ?>
  485. <div class="blockform">
  486. <h2><span><?php echo $lang_profile['Confirm delete user'] ?></span></h2>
  487. <div class="box">
  488. <form id="confirm_del_user" method="post" action="profile.php?id=<?php echo $id /*"*/?>">
  489. <div class="inform">
  490. <fieldset>
  491. <legend><?php echo $lang_profile['Confirm delete legend'] ?></legend>
  492. <div class="infldset">
  493. <p><?php echo $lang_profile['Confirmation info'].' '.pun_htmlspecialchars($username).'.' ?></p>
  494. <div class="rbox">
  495. <label><input type="checkbox" name="delete_posts" value="1" checked="checked" /><?php echo $lang_profile['Delete posts'] ?><br /></label>
  496. </div>
  497. <p class="warntext"><strong><?php echo $lang_profile['Delete warning'] ?></strong></p>
  498. </div>
  499. </fieldset>
  500. </div>
  501. <p><input type="submit" name="delete_user_comply" value="<?php echo $lang_profile['Delete'] /*"*/?>" /><a href="javascript:history.go(-1)"><?php echo $lang_common['Go back'] ?></a></p>
  502. </form>
  503. </div>
  504. </div>
  505. <?php
  506. require PUN_ROOT.'footer.php';
  507. }
  508. else if (isset($_POST['form_sent']))
  509. {
  510. // Fetch the user group of the user we are editing
  511. $result = $db->query('SELECT group_id FROM '.$db->prefix.'users WHERE id='.$id) or error('Unable to fetch user info', __FILE__, __LINE__, $db->error());
  512. if (!$db->num_rows($result))
  513. message($lang_common['Bad request']);
  514. $group_id = $db->result($result);
  515. if ($pun_user['id'] != $id &&
  516. ($pun_user['g_id'] > PUN_MOD ||
  517. ($pun_user['g_id'] == PUN_MOD && $pun_config['p_mod_edit_users'] == '0') ||
  518. ($pun_user['g_id'] == PUN_MOD && $group_id < PUN_GUEST)))
  519. message($lang_common['No permission']);
  520. if ($pun_user['g_id'] < PUN_GUEST)
  521. confirm_referrer('profile.php');
  522. // Extract allowed elements from $_POST['form']
  523. function extract_elements($allowed_elements)
  524. {
  525. $form = array();
  526. while (list($key, $value) = @each($_POST['form']))
  527. {
  528. if (in_array($key, $allowed_elements))
  529. $form[$key] = $value;
  530. }
  531. return $form;
  532. }
  533. $username_updated = false;
  534. // Validate input depending on section
  535. switch ($section)
  536. {
  537. case 'essentials':
  538. {
  539. $form = extract_elements(array('timezone', 'language'));
  540. if ($pun_user['g_id'] < PUN_GUEST)
  541. {
  542. $form['admin_note'] = trim($_POST['admin_note']);
  543. // Are we allowed to change usernames?
  544. if ($pun_user['g_id'] == PUN_ADMIN || ($pun_user['g_id'] == PUN_MOD && $pun_config['p_mod_rename_users'] == '1'))
  545. {
  546. $form['username'] = trim($_POST['req_username']);
  547. $old_username = trim($_POST['old_username']);
  548. if (strlen($form['username']) < 2)
  549. message($lang_prof_reg['Username too short']);
  550. else if (pun_strlen($form['username']) > 25) // This usually doesn't happen since the form element only accepts 25 characters
  551. message($lang_prof_reg['Username too long']." (".strlen($form['username']).")");
  552. else if (!strcasecmp($form['username'], 'Guest') || !strcasecmp($form['username'], $lang_common['Guest']))
  553. message($lang_prof_reg['Username guest']);
  554. else if (preg_match('/[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/', $form['username']))
  555. message($lang_prof_reg['Username IP']);
  556. else if (preg_match('#\[b\]|\[/b\]|\[u\]|\[/u\]|\[i\]|\[/i\]|\[color|\[/color\]|\[quote\]|\[quote=|\[/quote\]|\[code\]|\[/code\]|\[img\]|\[/img\]|\[url|\[/url\]|\[email|\[/email\]#i', $form['username']))
  557. message($lang_prof_reg['Username BBCode']);
  558. // Check that the username is not already registered
  559. $result = $db->query('SELECT 1 FROM '.$db->prefix.'users WHERE username=\''.$db->escape($form['username']).'\' AND id!='.$id) or error('Unable to fetch user info', __FILE__, __LINE__, $db->error());
  560. if ($db->num_rows($result))
  561. message($lang_profile['Dupe username']);
  562. if ($form['username'] != $old_username)
  563. $username_updated = true;
  564. }
  565. // We only allow administrators to update the post count
  566. if ($pun_user['g_id'] == PUN_ADMIN)
  567. $form['num_posts'] = intval($_POST['num_posts']);
  568. }
  569. if ($pun_config['o_regs_verify'] == '0' || $pun_user['g_id'] < PUN_GUEST)
  570. {
  571. require PUN_ROOT.'include/email.php';
  572. // Validate the email-address
  573. $form['email'] = strtolower(trim($_POST['req_email']));
  574. if (!is_valid_email($form['email']))
  575. message($lang_common['Invalid e-mail']);
  576. }
  577. // Make sure we got a valid language string
  578. if (isset($form['language']))
  579. {
  580. $form['language'] = preg_replace('#[\.\\\/]#', '', $form['language']);
  581. if (!file_exists(PUN_ROOT.'lang/'.$form['language'].'/common.php'))
  582. message($lang_common['Bad request']);
  583. }
  584. break;
  585. }
  586. case 'personal':
  587. {
  588. $form = extract_elements(array('realname', 'user_nick', 'url', 'location'));
  589. if ($pun_user['g_id'] == PUN_ADMIN)
  590. $form['title'] = trim($_POST['title']);
  591. else if ($pun_user['g_set_title'] == '1')
  592. {
  593. $form['title'] = trim($_POST['title']);
  594. if ($form['title'] != '')
  595. {
  596. // A list of words that the title may not contain
  597. // If the language is English, there will be some duplicates, but it's not the end of the world
  598. $forbidden = array('Member', 'Moderator', 'Administrator', 'Banned', 'Guest', $lang_common['Member'], $lang_common['Moderator'], $lang_common['Administrator'], $lang_common['Banned'], $lang_common['Guest']);
  599. if (in_array($form['title'], $forbidden))
  600. message($lang_profile['Forbidden title']);
  601. }
  602. }
  603. // Add http:// if the URL doesn't contain it already
  604. if ($form['url'] != '' && !stristr($form['url'], 'http://'))
  605. $form['url'] = 'http://'.$form['url'];
  606. break;
  607. }
  608. case 'messaging':
  609. {
  610. $form = extract_elements(array('jabber', 'icq', 'msn', 'aim', 'yahoo'));
  611. // If the ICQ UIN contains anything other than digits it's invalid
  612. if ($form['icq'] != '' && preg_match('/[^0-9]/', $form['icq']))
  613. message($lang_prof_reg['Bad ICQ']);
  614. break;
  615. }
  616. case 'personality':
  617. {
  618. $form = extract_elements(array('use_avatar'));
  619. // Clean up signature from POST
  620. $form['signature'] = pun_linebreaks(trim($_POST['signature']));
  621. // Validate signature
  622. if (pun_strlen($form['signature']) > $pun_config['p_sig_length'])
  623. message($lang_prof_reg['Sig too long'].' '.$pun_config['p_sig_length'].' '.$lang_prof_reg['characters'].'.');
  624. else if (substr_count($form['signature'], "\n") > ($pun_config['p_sig_lines']-1))
  625. message($lang_prof_reg['Sig too many lines'].' '.$pun_config['p_sig_lines'].' '.$lang_prof_reg['lines'].'.');
  626. else if ($form['signature'] && $pun_config['p_sig_all_caps'] == '0' && strtoupper($form['signature']) == $form['signature'] && $pun_user['g_id'] > PUN_MOD)
  627. $form['signature'] = ucwords(strtolower($form['signature']));
  628. // Validate BBCode syntax
  629. if ($pun_config['p_sig_bbcode'] == '1' && strpos($form['signature'], '[') !== false && strpos($form['signature'], ']') !== false)
  630. {
  631. require PUN_ROOT.'include/parser.php';
  632. $form['signature'] = preparse_bbcode($form['signature'], $foo, true);
  633. }
  634. if (!isset($form['use_avatar']) || !$form['use_avatar']) $form['use_avatar'] = '';
  635. break;
  636. }
  637. case 'display':
  638. {
  639. $form = extract_elements(array('disp_topics', 'disp_posts', 'show_smilies', 'show_img', 'show_img_sig', 'show_avatars', 'show_sig', 'style'));
  640. if ($form['disp_topics'] != '' && intval($form['disp_topics']) < 3) $form['disp_topics'] = 3;
  641. if ($form['disp_topics'] != '' && intval($form['disp_topics']) > 75) $form['disp_topics'] = 75;
  642. if ($form['disp_posts'] != '' && intval($form['disp_posts']) < 3) $form['disp_posts'] = 3;
  643. if ($form['disp_posts'] != '' && intval($form['disp_posts']) > 75) $form['disp_posts'] = 75;
  644. if (!isset($form['show_smilies']) || $form['show_smilies'] != '1') $form['show_smilies'] = '0';
  645. if (!isset($form['show_img']) || $form['show_img'] != '1') $form['show_img'] = '0';
  646. if (!isset($form['show_img_sig']) || $form['show_img_sig'] != '1') $form['show_img_sig'] = '0';
  647. if (!isset($form['show_avatars']) || $form['show_avatars'] != '1') $form['show_avatars'] = '0';
  648. if (!isset($form['show_sig']) || $form['show_sig'] != '1') $form['show_sig'] = '0';
  649. break;
  650. }
  651. case 'privacy':
  652. {
  653. $form = extract_elements(array('email_setting', 'save_pass', 'notify_with_post'));
  654. $form['email_setting'] = intval($form['email_setting']);
  655. if ($form['email_setting'] < 0 && $form['email_setting'] > 2) $form['email_setting'] = 1;
  656. if (!isset($form['save_pass']) || $form['save_pass'] != '1') $form['save_pass'] = '0';
  657. if (!isset($form['notify_with_post']) || $form['notify_with_post'] != '1') $form['notify_with_post'] = '0';
  658. // If the save_pass setting has changed, we need to set a new cookie with the appropriate expire date
  659. if ($pun_user['id'] == $id && $form['save_pass'] != $pun_user['save_pass'])
  660. {
  661. $me = new User($id);
  662. $me->cookie_hash_update();
  663. }
  664. break;
  665. }
  666. default:
  667. message($lang_common['Bad request']);
  668. }
  669. // set_loglevel(10,0);
  670. $user = object_load('forum_user', $id, array('no_load_cache' => true));
  671. $user->set_signature($form['signature'], true);
  672. $user->set_signature_html(NULL, true);
  673. $user->set_use_avatar($form['use_avatar'], true);
  674. foreach(array(
  675. 'url' => 'www',
  676. 'title' => 'user_title',
  677. 'username' => 'title',
  678. ) as $from => $to)
  679. {
  680. if(isset($form[$from]))
  681. $form[$to] = $form[$from];
  682. unset($form[$from]);
  683. }
  684. foreach($form as $key => $val)
  685. $user->set($key, $val, true);
  686. $user->store();
  687. // print_d($form);
  688. // bors_exit();
  689. // $db->query('UPDATE '.$db->prefix.'users SET '.implode(',', $temp).' WHERE id='.$id) or error('Unable to update profile', __FILE__, __LINE__, $db->error());
  690. // If we changed the username we have to update some stuff
  691. if ($username_updated)
  692. {
  693. $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());
  694. $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());
  695. $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());
  696. $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());
  697. $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());
  698. // If the user is a moderator or an administrator we have to update the moderator lists
  699. $result = $db->query('SELECT group_id FROM '.$db->prefix.'users WHERE id='.$id) or error('Unable to fetch user info', __FILE__, __LINE__, $db->error());
  700. $group_id = $db->result($result);
  701. if ($group_id < PUN_GUEST)
  702. {
  703. $result = $db->query('SELECT id, moderators FROM '.$db->prefix.'forums') or error('Unable to fetch forum list', __FILE__, __LINE__, $db->error());
  704. while ($cur_forum = $db->fetch_assoc($result))
  705. {
  706. $cur_moderators = ($cur_forum['moderators'] != '') ? unserialize($cur_forum['moderators']) : array();
  707. if (in_array($id, $cur_moderators))
  708. {
  709. unset($cur_moderators[$old_username]);
  710. $cur_moderators[$form['username']] = $id;
  711. ksort($cur_moderators);
  712. $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());
  713. }
  714. }
  715. }
  716. }
  717. redirect('profile.php?section='.$section.'&amp;id='.$id, $lang_profile['Profile redirect']);
  718. }
  719. $result = $db->query('SELECT u.username, u.email, u.title, u.realname, u.user_nick, u.url, u.jabber, u.icq, u.msn, u.aim, u.yahoo, u.location, u.use_avatar, u.avatar_height, u.avatar_width, u.signature, u.disp_topics, u.disp_posts, u.email_setting, u.save_pass, u.notify_with_post, u.show_smilies, u.show_img, u.show_img_sig, u.show_avatars, u.show_sig, u.timezone, u.language, u.style, u.num_posts, u.last_post, u.last_visit, u.registered, u.registration_ip, u.admin_note, g.g_id, g.g_user_title FROM '.$db->prefix.'users AS u LEFT JOIN '.$db->prefix.'groups AS g ON g.g_id=u.group_id WHERE u.id='.$id) or error('Unable to fetch user info', __FILE__, __LINE__, $db->error());
  720. if (!$db->num_rows($result))
  721. message($lang_common['Bad request']);
  722. $user = $db->fetch_assoc($result);
  723. $last_post = format_time($user['last_post']);
  724. $last_visit = format_time($user['last_visit']);
  725. if ($user['signature'] != '')
  726. {
  727. require PUN_ROOT.'include/parser.php';
  728. $parsed_signature = parse_signature($user['signature']);
  729. }
  730. // View or edit?
  731. if ($pun_user['id'] != $id &&
  732. ($pun_user['g_id'] > PUN_MOD ||
  733. ($pun_user['g_id'] == PUN_MOD && $pun_config['p_mod_edit_users'] == '0') ||
  734. ($pun_user['g_id'] == PUN_MOD && $user['g_id'] < PUN_GUEST)))
  735. {
  736. if ($user['email_setting'] == '0' && !$pun_user['is_guest'])
  737. $email_field = '<a href="mailto:'.$user['email'].'">'.$user['email'].'</a>';
  738. else if ($user['email_setting'] == '1' && !$pun_user['is_guest'])
  739. $email_field = "<a href=\"{$pun_config['root_uri']}/misc.php?email=$id\">".$lang_common['Send e-mail'].'</a>';
  740. else
  741. $email_field = $lang_profile['Private'];
  742. $user_title_field = get_title($user);
  743. if ($user['url'] != '')
  744. {
  745. $user['url'] = pun_htmlspecialchars($user['url']);
  746. if ($pun_config['o_censoring'] == '1')
  747. $user['url'] = censor_words($user['url']);
  748. $url = '<a href="'.$user['url'].'">'.$user['url'].'</a>';
  749. }
  750. else
  751. $url = $lang_profile['Unknown'];
  752. if ($pun_config['o_avatars'] == '1')
  753. {
  754. if ($user['use_avatar'])
  755. $avatar_field = "<img src=\"{$pun_config['root_uri']}/{$pun_config['o_avatars_dir']}/{$user['use_avatar']}\" width=\"{$user['avatar_width']}\" height=\"{$user['avatar_height']}\" alt=\"\" />";
  756. else
  757. $avatar_field = $lang_profile['No avatar'];
  758. }
  759. $posts_field = '';
  760. if ($pun_config['o_show_post_count'] == '1' || $pun_user['g_id'] < PUN_GUEST)
  761. $posts_field = $user['num_posts'];
  762. if ($pun_user['g_search'] == '1')
  763. $posts_field .= (($posts_field != '') ? ' - ' : '')."<a href=\"{$pun_config['root_uri']}/search.php?action=show_user&amp;user_id=$id\">".$lang_profile['Show posts'].'</a>';
  764. $page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / '.$lang_common['Profile'];
  765. define('PUN_ALLOW_INDEX', 1);
  766. require PUN_ROOT.'header.php';
  767. ?>
  768. <div id="viewprofile" class="block">
  769. <h2><span><?php echo $lang_common['Profile'] ?></span></h2>
  770. <div class="box">
  771. <div class="fakeform">
  772. <div class="inform">
  773. <fieldset>
  774. <legend><?php echo $lang_profile['Section personal'] ?></legend>
  775. <div class="infldset">
  776. <dl>
  777. <dt>Новый профиль:</dt>
  778. <dd><a href="http://www.balancer.ru/user/<?php echo $id?>/">http://www.balancer.ru/user/<?php echo $id?>/</a></dd>
  779. <dt><?php echo $lang_common['Username'] ?>: </dt>
  780. <dd><?php echo pun_htmlspecialchars($user['username']) ?></dd>
  781. <dt><?php echo $lang_common['Title'] ?>: </dt>
  782. <dd><?php echo ($pun_config['o_censoring'] == '1') ? censor_words($user_title_field) : $user_title_field; ?></dd>
  783. <dt><?php echo $lang_profile['Realname'] ?>: </dt>
  784. <dd><?php echo ($user['realname'] !='') ? pun_htmlspecialchars(($pun_config['o_censoring'] == '1') ? censor_words($user['realname']) : $user['realname']) : $lang_profile['Unknown']; ?></dd>
  785. <dt><?php echo 'Ник (отображаемое имя)' ?>: </dt>
  786. <dd><?php echo ($user['user_nick'] !='') ? pun_htmlspecialchars(($pun_config['o_censoring'] == '1') ? censor_words($user['user_nick']) : $user['user_nick']) : $lang_profile['Unknown']; ?></dd>
  787. <dt><?php echo $lang_profile['Location'] ?>: </dt>
  788. <dd><?php echo ($user['location'] !='') ? pun_htmlspecialchars(($pun_config['o_censoring'] == '1') ? censor_words($user['location']) : $user['location']) : $lang_profile['Unknown']; ?></dd>
  789. <dt><?php echo $lang_profile['Website'] ?>: </dt>
  790. <dd><?php echo $url ?>&nbsp;</dd>
  791. <dt><?php echo $lang_common['E-mail'] ?>: </dt>
  792. <dd><?php echo $email_field ?></dd>
  793. </dl>
  794. <div class="clearer"></div>
  795. </div>
  796. </fieldset>
  797. </div>
  798. <div class="inform">
  799. <fieldset>
  800. <legend><?php echo $lang_profile['Section messaging'] ?></legend>
  801. <div class="infldset">
  802. <dl>
  803. <dt><?php echo $lang_profile['Jabber'] ?>: </dt>
  804. <dd><?php echo ($user['jabber'] !='') ? pun_htmlspecialchars($user['jabber']) : $lang_profile['Unknown']; ?></dd>
  805. <dt><?php echo $lang_profile['ICQ'] ?>: </dt>
  806. <dd><?php echo ($user['icq'] !='') ? $user['icq'] : $lang_profile['Unknown']; ?></dd>
  807. <dt><?php echo $lang_profile['MSN'] ?>: </dt>
  808. <dd><?php echo ($user['msn'] !='') ? pun_htmlspecialchars(($pun_config['o_censoring'] == '1') ? censor_words($user['msn']) : $user['msn']) : $lang_profile['Unknown']; ?></dd>
  809. <dt><?php echo $lang_profile['AOL IM'] ?>: </dt>
  810. <dd><?php echo ($user['aim'] !='') ? pun_htmlspecialchars(($pun_config['o_censoring'] == '1') ? censor_words($user['aim']) : $user['aim']) : $lang_profile['Unknown']; ?></dd>
  811. <dt><?php echo $lang_profile['Yahoo'] ?>: </dt>
  812. <dd><?php echo ($user['yahoo'] !='') ? pun_htmlspecialchars(($pun_config['o_censoring'] == '1') ? censor_words($user['yahoo']) : $user['yahoo']) : $lang_profile['Unknown']; ?></dd>
  813. </dl>
  814. <div class="clearer"></div>
  815. </div>
  816. </fieldset>
  817. </div>
  818. <div class="inform">
  819. <fieldset>
  820. <legend><?php echo $lang_profile['Section personality'] ?></legend>
  821. <div class="infldset">
  822. <dl>
  823. <?php if ($pun_config['o_avatars'] == '1'): ?> <dt><?php echo $lang_profile['Avatar'] ?>: </dt>
  824. <dd><?php echo $avatar_field ?></dd>
  825. <?php endif; ?> <dt><?php echo $lang_profile['Signature'] ?>: </dt>
  826. <dd><div><?php echo isset($parsed_signature) ? $parsed_signature : $lang_profile['No sig']; ?></div></dd>
  827. </dl>
  828. <div class="clearer"></div>
  829. </div>
  830. </fieldset>
  831. </div>
  832. <div class="inform">
  833. <fieldset>
  834. <legend><?php echo $lang_profile['User activity'] ?></legend>
  835. <div class="infldset">
  836. <dl>
  837. <?php if ($posts_field != ''): ?> <dt><?php echo $lang_common['Posts'] ?>: </dt>
  838. <dd><?php echo $posts_field ?></dd>
  839. <?php endif; ?> <dt><?php echo $lang_common['Last post'] ?>: </dt>
  840. <dd><?php echo $last_post ?></dd>
  841. <dt><?php echo $lang_common['Registered'] ?>: </dt>
  842. <dd><?php echo format_time($user['registered'], true) ?></dd>
  843. </dl>
  844. <div class="clearer"></div>
  845. </div>
  846. </fieldset>
  847. </div>
  848. </div>
  849. </div>
  850. </div>
  851. <?php
  852. require PUN_ROOT.'footer.php';
  853. }
  854. else
  855. {
  856. if (!$section || $section == 'essentials')
  857. {
  858. if ($pun_user['g_id'] < PUN_GUEST)
  859. {
  860. if ($pun_user['g_id'] == PUN_ADMIN || $pun_config['p_mod_rename_users'] == '1')
  861. $username_field = '<input type="hidden" name="old_username" value="'.pun_htmlspecialchars($user['username']).'" /><label><strong>'.$lang_common['Username'].'</strong><br /><input type="text" name="req_username" value="'.pun_htmlspecialchars($user['username']).'" size="25" maxlength="25" /><br /></label>'."\n";
  862. else
  863. $username_field = '<p>'.$lang_common['Username'].': '.pun_htmlspecialchars($user['username']).'</p>'."\n";
  864. $email_field = '<label><strong>'.$lang_common['E-mail'].'</strong><br /><input type="text" name="req_email" value="'.$user['email'].'" size="40" maxlength="50" /><br /></label><p><a href="misc.php?email='.$id.'">'.$lang_common['Send e-mail'].'</a></p>'."\n";
  865. }
  866. else
  867. {
  868. $username_field = '<p>'.$lang_common['Username'].': '.pun_htmlspecialchars($user['username']).'</p>'."\n";
  869. if ($pun_config['o_regs_verify'] == '1')
  870. $email_field = '<p>'.$lang_common['E-mail'].': '.$user['email']."&nbsp;-&nbsp;<a href=\"{$pun_config['root_uri']}/profile.php?action=change_email&amp;id=$id\">".$lang_profile['Change e-mail'].'</a></p>'."\n";
  871. else
  872. $email_field = '<label><strong>'.$lang_common['E-mail'].'</strong><br /><input type="text" name="req_email" value="'.$user['email'].'" size="40" maxlength="50" /><br /></label>'."\n";
  873. }
  874. if ($pun_user['g_id'] == PUN_ADMIN)
  875. $posts_field = '<label>'.$lang_common['Posts'].'<br /><input type="text" name="num_posts" value="'.$user['num_posts'].'" size="8" maxlength="8" /><br /></label><p><a href="search.php?action=show_user&amp;user_id='.$id.'">'.$lang_profile['Show posts'].'</a></p>'."\n";
  876. else if ($pun_config['o_show_post_count'] == '1' || $pun_user['g_id'] < PUN_GUEST)
  877. $posts_field = "<p>{$lang_common['Posts']}: {$user['num_posts']} - <a href=\"{$pun_config['root_uri']}/search.php?action=show_user&amp;user_id=$id\">{$lang_profile['Show posts']}</a></p>\n";
  878. else
  879. $posts_field = "<p><a href=\"{$pun_config['root_uri']}/search.php?action=show_user&amp;user_id=$id\">{$lang_profile['Show posts']}</a></p>\n";
  880. $page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / '.$lang_common['Profile'];
  881. $required_fields = array('req_username' => $lang_common['Username'], 'req_email' => $lang_common['E-mail']);
  882. require PUN_ROOT.'header.php';
  883. generate_profile_menu('essentials');
  884. ?>
  885. <div class="blockform">
  886. <h2><span><?php echo pun_htmlspecialchars($user['username']).' - '.$lang_profile['Section essentials'] ?></span></h2>
  887. <div class="box">
  888. <form id="profile1" method="post" action="profile.php?section=essentials&amp;id=<?php echo $id;/*"*/?>" onsubmit="return process_form(this)">
  889. <div class="inform">
  890. <fieldset>
  891. <legend><?php echo $lang_profile['Username and pass legend'] ?></legend>
  892. <div class="infldset">
  893. <input type="hidden" name="form_sent" value="1" />
  894. <?php echo $username_field ?>
  895. <?php if ($pun_user['id'] == $id || $pun_user['g_id'] == PUN_ADMIN || ($user['g_id'] > PUN_MOD && $pun_config['p_mod_change_passwords'] == '1')): ?><p><a href="<?php echo $pun_config['root_uri'];?>/profile.php?action=change_pass&amp;id=<?php echo $id ?>"><?php echo $lang_profile['Change pass'];/*"*/?></a></p>
  896. <?php endif; ?> </div>
  897. </fieldset>
  898. </div>
  899. <div class="inform">
  900. <fieldset>
  901. <legend><?php echo $lang_prof_reg['E-mail legend'] ?></legend>
  902. <div class="infldset">
  903. <?php echo $email_field ?>
  904. </div>
  905. </fieldset>
  906. </div>
  907. <div class="inform">
  908. <fieldset>
  909. <legend><?php echo $lang_prof_reg['Localisation legend'] ?></legend>
  910. <div class="infldset">
  911. <label><?php echo $lang_prof_reg['Timezone'] ?>: <?php echo $lang_prof_reg['Timezone info'] ?>
  912. <br /><select name="form[timezone]">
  913. <option value="-12"<?php if ($user['timezone'] == -12) echo ' selected="selected"' ?>>-12</option>
  914. <option value="-11"<?php if ($user['timezone'] == -11) echo ' selected="selected"' ?>>-11</option>
  915. <option value="-10"<?php if ($user['timezone'] == -10) echo ' selected="selected"' ?>>-10</option>
  916. <option value="-9.5"<?php if ($user['timezone'] == -9.5) echo ' selected="selected"' ?>>-09.5</option>
  917. <option value="-9"<?php if ($user['timezone'] == -9) echo ' selected="selected"' ?>>-09</option>
  918. <option value="-8.5"<?php if ($user['timezone'] == -8.5) echo ' selected="selected"' ?>>-08.5</option>
  919. <option value="-8"<?php if ($user['timezone'] == -8) echo ' selected="selected"' ?>>-08 PST</option>
  920. <option value="-7"<?php if ($user['timezone'] == -7) echo ' selected="selected"' ?>>-07 MST</option>
  921. <option value="-6"<?php if ($user['timezone'] == -6) echo ' selected="selected"' ?>>-06 CST</option>
  922. <option value="-5"<?php if ($user['timezone'] == -5) echo ' selected="selected"' ?>>-0

Large files files are truncated, but you can click here to view the full file