Advertisement
Guest User

My profile.php

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