From 3b06ee0d381dc1be5f40ca98ad4278046d869d21 Mon Sep 17 00:00:00 2001 From: Andreas Baumann Date: Sun, 17 Nov 2019 20:57:39 +0100 Subject: checked in initial customized verison for Archlinux32 --- profile.php | 1882 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 1882 insertions(+) create mode 100644 profile.php (limited to 'profile.php') diff --git a/profile.php b/profile.php new file mode 100644 index 0000000..8b0eb86 --- /dev/null +++ b/profile.php @@ -0,0 +1,1882 @@ +query('SELECT * FROM '.$db->prefix.'users WHERE id='.$id) or error('Unable to fetch new password', __FILE__, __LINE__, $db->error()); + $cur_user = $db->fetch_assoc($result); + + if ($key == '' || $key != $cur_user['activate_key']) + message($lang_profile['Pass key bad'].' '.pun_htmlspecialchars($pun_config['o_admin_email']).'.'); + else + { + $db->query('UPDATE '.$db->prefix.'users SET password=\''.$db->escape($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()); + + message($lang_profile['Pass updated'], true); + } + } + + // Make sure we are allowed to change this user's password + if ($pun_user['id'] != $id) + { + if (!$pun_user['is_admmod']) // A regular user trying to change another user's password? + message($lang_common['No permission'], false, '403 Forbidden'); + else if ($pun_user['g_moderator'] == '1') // A moderator trying to change a user's password? + { + $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()); + if (!$db->num_rows($result)) + message($lang_common['Bad request'], false, '404 Not Found'); + + list($group_id, $is_moderator) = $db->fetch_row($result); + + if ($pun_user['g_mod_edit_users'] == '0' || $pun_user['g_mod_change_passwords'] == '0' || $group_id == PUN_ADMIN || $is_moderator == '1') + message($lang_common['No permission'], false, '403 Forbidden'); + } + } + + if (isset($_POST['form_sent'])) + { + // Make sure they got here from the site + confirm_referrer('profile.php'); + + $old_password = isset($_POST['req_old_password']) ? pun_trim($_POST['req_old_password']) : ''; + $new_password1 = pun_trim($_POST['req_new_password1']); + $new_password2 = pun_trim($_POST['req_new_password2']); + + if ($new_password1 != $new_password2) + message($lang_prof_reg['Pass not match']); + if (pun_strlen($new_password1) < 9) + message($lang_prof_reg['Pass too short']); + + $result = $db->query('SELECT * FROM '.$db->prefix.'users WHERE id='.$id) or error('Unable to fetch password', __FILE__, __LINE__, $db->error()); + $cur_user = $db->fetch_assoc($result); + + $authorized = false; + + if (!empty($cur_user['password'])) + { + $old_password_hash = pun_hash($old_password); + + if ($cur_user['password'] == $old_password_hash || $pun_user['is_admmod']) + $authorized = true; + } + + if (!$authorized) + message($lang_profile['Wrong pass']); + + $new_password_hash = pun_hash($new_password1); + + $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()); + + if ($pun_user['id'] == $id) + pun_setcookie($pun_user['id'], $new_password_hash, time() + $pun_config['o_timeout_visit']); + + redirect('profile.php?section=essentials&id='.$id, $lang_profile['Pass updated redirect']); + } + + $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_common['Profile'], $lang_profile['Change pass']); + $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']); + $focus_element = array('change_pass', ((!$pun_user['is_admmod']) ? 'req_old_password' : 'req_new_password1')); + define('PUN_ACTIVE_PAGE', 'profile'); + require PUN_ROOT.'header.php'; + +?> +
+

+
+
+
+ +
+ +
+ + + +

+
+
+
+

+
+
+
+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()); + if (!$db->num_rows($result)) + message($lang_common['Bad request'], false, '404 Not Found'); + + list($group_id, $is_moderator) = $db->fetch_row($result); + + if ($pun_user['g_mod_edit_users'] == '0' || $group_id == PUN_ADMIN || $is_moderator == '1') + message($lang_common['No permission'], false, '403 Forbidden'); + } + } + + if (isset($_GET['key'])) + { + $key = $_GET['key']; + + $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()); + list($new_email, $new_email_key) = $db->fetch_row($result); + + if ($key == '' || $key != $new_email_key) + message($lang_profile['Email key bad'].' '.pun_htmlspecialchars($pun_config['o_admin_email']).'.'); + else + { + $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()); + + message($lang_profile['Email updated'], true); + } + } + else if (isset($_POST['form_sent'])) + { + if (pun_hash($_POST['req_password']) !== $pun_user['password']) + message($lang_profile['Wrong pass']); + + // Make sure they got here from the site + confirm_referrer('profile.php'); + + require PUN_ROOT.'include/email.php'; + + // Validate the email address + $new_email = strtolower(pun_trim($_POST['req_new_email'])); + if (!is_valid_email($new_email)) + message($lang_common['Invalid email']); + + // Check if it's a banned email address + if (is_banned_email($new_email)) + { + if ($pun_config['p_allow_banned_email'] == '0') + message($lang_prof_reg['Banned email']); + else if ($pun_config['o_mailing_list'] != '') + { + // Load the "banned email change" template + $mail_tpl = trim(file_get_contents(PUN_ROOT.'lang/'.$pun_user['language'].'/mail_templates/banned_email_change.tpl')); + + // The first row contains the subject + $first_crlf = strpos($mail_tpl, "\n"); + $mail_subject = trim(substr($mail_tpl, 8, $first_crlf-8)); + $mail_message = trim(substr($mail_tpl, $first_crlf)); + + $mail_message = str_replace('', $pun_user['username'], $mail_message); + $mail_message = str_replace('', $new_email, $mail_message); + $mail_message = str_replace('', get_base_url().'/profile.php?id='.$id, $mail_message); + $mail_message = str_replace('', $pun_config['o_board_title'], $mail_message); + + pun_mail($pun_config['o_mailing_list'], $mail_subject, $mail_message); + } + } + + // Check if someone else already has registered with that email address + $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()); + if ($db->num_rows($result)) + { + if ($pun_config['p_allow_dupe_email'] == '0') + message($lang_prof_reg['Dupe email']); + else if ($pun_config['o_mailing_list'] != '') + { + while ($cur_dupe = $db->fetch_assoc($result)) + $dupe_list[] = $cur_dupe['username']; + + // Load the "dupe email change" template + $mail_tpl = trim(file_get_contents(PUN_ROOT.'lang/'.$pun_user['language'].'/mail_templates/dupe_email_change.tpl')); + + // The first row contains the subject + $first_crlf = strpos($mail_tpl, "\n"); + $mail_subject = trim(substr($mail_tpl, 8, $first_crlf-8)); + $mail_message = trim(substr($mail_tpl, $first_crlf)); + + $mail_message = str_replace('', $pun_user['username'], $mail_message); + $mail_message = str_replace('', implode(', ', $dupe_list), $mail_message); + $mail_message = str_replace('', get_base_url().'/profile.php?id='.$id, $mail_message); + $mail_message = str_replace('', $pun_config['o_board_title'], $mail_message); + + pun_mail($pun_config['o_mailing_list'], $mail_subject, $mail_message); + } + } + + + $new_email_key = random_pass(8); + + $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()); + + // Load the "activate email" template + $mail_tpl = trim(file_get_contents(PUN_ROOT.'lang/'.$pun_user['language'].'/mail_templates/activate_email.tpl')); + + // The first row contains the subject + $first_crlf = strpos($mail_tpl, "\n"); + $mail_subject = trim(substr($mail_tpl, 8, $first_crlf-8)); + $mail_message = trim(substr($mail_tpl, $first_crlf)); + + $mail_message = str_replace('', $pun_user['username'], $mail_message); + $mail_message = str_replace('', get_base_url(), $mail_message); + $mail_message = str_replace('', get_base_url().'/profile.php?action=change_email&id='.$id.'&key='.$new_email_key, $mail_message); + $mail_message = str_replace('', $pun_config['o_board_title'], $mail_message); + + pun_mail($new_email, $mail_subject, $mail_message); + + message($lang_profile['Activate email sent'].' '.pun_htmlspecialchars($pun_config['o_admin_email']).'.', true); + } + + $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_common['Profile'], $lang_profile['Change email']); + $required_fields = array('req_new_email' => $lang_profile['New email'], 'req_password' => $lang_common['Password']); + $focus_element = array('change_email', 'req_new_email'); + define('PUN_ACTIVE_PAGE', 'profile'); + require PUN_ROOT.'header.php'; + +?> +
+

+
+
+
+
+ +
+ + + +

+
+
+
+

+
+
+
+ $pun_config['o_avatars_size']) + message($lang_profile['Too large'].' '.forum_number_format($pun_config['o_avatars_size']).' '.$lang_profile['bytes'].'.'); + + // Move the file to the avatar directory. We do this before checking the width/height to circumvent open_basedir restrictions + if (!@move_uploaded_file($uploaded_file['tmp_name'], PUN_ROOT.$pun_config['o_avatars_dir'].'/'.$id.'.tmp')) + message($lang_profile['Move failed'].' '.pun_htmlspecialchars($pun_config['o_admin_email']).'.'); + + list($width, $height, $type,) = @getimagesize(PUN_ROOT.$pun_config['o_avatars_dir'].'/'.$id.'.tmp'); + + // Determine type + if ($type == IMAGETYPE_GIF) + $extension = '.gif'; + else if ($type == IMAGETYPE_JPEG) + $extension = '.jpg'; + else if ($type == IMAGETYPE_PNG) + $extension = '.png'; + else + { + // Invalid type + @unlink(PUN_ROOT.$pun_config['o_avatars_dir'].'/'.$id.'.tmp'); + message($lang_profile['Bad type']); + } + + // Now check the width/height + if (empty($width) || empty($height) || $width > $pun_config['o_avatars_width'] || $height > $pun_config['o_avatars_height']) + { + @unlink(PUN_ROOT.$pun_config['o_avatars_dir'].'/'.$id.'.tmp'); + message($lang_profile['Too wide or high'].' '.$pun_config['o_avatars_width'].'x'.$pun_config['o_avatars_height'].' '.$lang_profile['pixels'].'.'); + } + + // Delete any old avatars and put the new one in place + delete_avatar($id); + @rename(PUN_ROOT.$pun_config['o_avatars_dir'].'/'.$id.'.tmp', PUN_ROOT.$pun_config['o_avatars_dir'].'/'.$id.$extension); + @chmod(PUN_ROOT.$pun_config['o_avatars_dir'].'/'.$id.$extension, 0644); + } + else + message($lang_profile['Unknown failure']); + + redirect('profile.php?section=personality&id='.$id, $lang_profile['Avatar upload redirect']); + } + + $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_common['Profile'], $lang_profile['Upload avatar']); + $required_fields = array('req_file' => $lang_profile['File']); + $focus_element = array('upload_avatar', 'req_file'); + define('PUN_ACTIVE_PAGE', 'profile'); + require PUN_ROOT.'header.php'; + +?> +
+

+
+
+
+
+ +
+ + + +

+
+
+
+

+
+
+
+ PUN_ADMIN) + message($lang_common['No permission'], false, '403 Forbidden'); + + confirm_referrer('profile.php'); + + $new_group_id = intval($_POST['group_id']); + + $result = $db->query('SELECT group_id FROM '.$db->prefix.'users WHERE id='.$id) or error('Unable to fetch user group', __FILE__, __LINE__, $db->error()); + $old_group_id = $db->result($result); + + $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()); + + // Regenerate the users info cache + if (!defined('FORUM_CACHE_FUNCTIONS_LOADED')) + require PUN_ROOT.'include/cache.php'; + + generate_users_info_cache(); + + if ($old_group_id == PUN_ADMIN || $new_group_id == PUN_ADMIN) + generate_admins_cache(); + + $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()); + $new_group_mod = $db->result($result); + + // If the user was a moderator or an administrator, we remove him/her from the moderator list in all forums as well + if ($new_group_id != PUN_ADMIN && $new_group_mod != '1') + { + $result = $db->query('SELECT id, moderators FROM '.$db->prefix.'forums') or error('Unable to fetch forum list', __FILE__, __LINE__, $db->error()); + + while ($cur_forum = $db->fetch_assoc($result)) + { + $cur_moderators = ($cur_forum['moderators'] != '') ? unserialize($cur_forum['moderators']) : array(); + + if (in_array($id, $cur_moderators)) + { + $username = array_search($id, $cur_moderators); + unset($cur_moderators[$username]); + $cur_moderators = (!empty($cur_moderators)) ? '\''.$db->escape(serialize($cur_moderators)).'\'' : 'NULL'; + + $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()); + } + } + } + + redirect('profile.php?section=admin&id='.$id, $lang_profile['Group membership redirect']); +} + + +else if (isset($_POST['update_forums'])) +{ + if ($pun_user['g_id'] > PUN_ADMIN) + message($lang_common['No permission'], false, '403 Forbidden'); + + confirm_referrer('profile.php'); + + // Get the username of the user we are processing + $result = $db->query('SELECT username FROM '.$db->prefix.'users WHERE id='.$id) or error('Unable to fetch user info', __FILE__, __LINE__, $db->error()); + $username = $db->result($result); + + $moderator_in = (isset($_POST['moderator_in'])) ? array_keys($_POST['moderator_in']) : array(); + + // Loop through all forums + $result = $db->query('SELECT id, moderators FROM '.$db->prefix.'forums') or error('Unable to fetch forum list', __FILE__, __LINE__, $db->error()); + + while ($cur_forum = $db->fetch_assoc($result)) + { + $cur_moderators = ($cur_forum['moderators'] != '') ? unserialize($cur_forum['moderators']) : array(); + // If the user should have moderator access (and he/she doesn't already have it) + if (in_array($cur_forum['id'], $moderator_in) && !in_array($id, $cur_moderators)) + { + $cur_moderators[$username] = $id; + uksort($cur_moderators, 'utf8_strcasecmp'); + + $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()); + } + // If the user shouldn't have moderator access (and he/she already has it) + else if (!in_array($cur_forum['id'], $moderator_in) && in_array($id, $cur_moderators)) + { + unset($cur_moderators[$username]); + $cur_moderators = (!empty($cur_moderators)) ? '\''.$db->escape(serialize($cur_moderators)).'\'' : 'NULL'; + + $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()); + } + } + + redirect('profile.php?section=admin&id='.$id, $lang_profile['Update forums redirect']); +} + + +else if (isset($_POST['ban'])) +{ + if ($pun_user['g_id'] != PUN_ADMIN && ($pun_user['g_moderator'] != '1' || $pun_user['g_mod_ban_users'] == '0')) + message($lang_common['No permission'], false, '403 Forbidden'); + + // Get the username of the user we are banning + $result = $db->query('SELECT username FROM '.$db->prefix.'users WHERE id='.$id) or error('Unable to fetch username', __FILE__, __LINE__, $db->error()); + $username = $db->result($result); + + // Check whether user is already banned + $result = $db->query('SELECT id FROM '.$db->prefix.'bans WHERE username = \''.$db->escape($username).'\' ORDER BY expire IS NULL DESC, expire DESC LIMIT 1') or error('Unable to fetch ban ID', __FILE__, __LINE__, $db->error()); + if ($db->num_rows($result)) + { + $ban_id = $db->result($result); + redirect('admin_bans.php?edit_ban='.$ban_id.'&exists', $lang_profile['Ban redirect']); + } + else + redirect('admin_bans.php?add_ban='.$id, $lang_profile['Ban redirect']); +} + + +else if ($action == 'promote') +{ + if ($pun_user['g_id'] != PUN_ADMIN && ($pun_user['g_moderator'] != '1' || $pun_user['g_mod_promote_users'] == '0')) + message($lang_common['No permission'], false, '403 Forbidden'); + + confirm_referrer('viewtopic.php'); + + check_csrf($_GET['csrf_token']); + + $pid = isset($_GET['pid']) ? intval($_GET['pid']) : 0; + + $sql = 'SELECT g.g_promote_next_group FROM '.$db->prefix.'groups AS g INNER JOIN '.$db->prefix.'users AS u ON u.group_id=g.g_id WHERE u.id='.$id.' AND g.g_promote_next_group>0'; + $result = $db->query($sql) or error('Unable to fetch promotion information', __FILE__, __LINE__, $db->error()); + + if (!$db->num_rows($result)) + message($lang_common['Bad request'], false, '404 Not Found'); + + $next_group_id = $db->result($result); + $db->query('UPDATE '.$db->prefix.'users SET group_id='.$next_group_id.' WHERE id='.$id) or error('Unable to promote user', __FILE__, __LINE__, $db->error()); + + redirect('viewtopic.php?pid='.$pid.'#p'.$pid, $lang_profile['User promote redirect']); +} + + +else if (isset($_POST['delete_user']) || isset($_POST['delete_user_comply'])) +{ + if ($pun_user['g_id'] > PUN_ADMIN) + message($lang_common['No permission'], false, '403 Forbidden'); + + confirm_referrer('profile.php'); + + // Get the username and group of the user we are deleting + $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()); + list($group_id, $username) = $db->fetch_row($result); + + if ($group_id == PUN_ADMIN) + message($lang_profile['No delete admin message']); + + if (isset($_POST['delete_user_comply'])) + { + // If the user is a moderator or an administrator, we remove him/her from the moderator list in all forums as well + $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()); + $group_mod = $db->result($result); + + if ($group_id == PUN_ADMIN || $group_mod == '1') + { + $result = $db->query('SELECT id, moderators FROM '.$db->prefix.'forums') or error('Unable to fetch forum list', __FILE__, __LINE__, $db->error()); + + while ($cur_forum = $db->fetch_assoc($result)) + { + $cur_moderators = ($cur_forum['moderators'] != '') ? unserialize($cur_forum['moderators']) : array(); + + if (in_array($id, $cur_moderators)) + { + unset($cur_moderators[$username]); + $cur_moderators = (!empty($cur_moderators)) ? '\''.$db->escape(serialize($cur_moderators)).'\'' : 'NULL'; + + $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()); + } + } + } + + // Delete any subscriptions + $db->query('DELETE FROM '.$db->prefix.'topic_subscriptions WHERE user_id='.$id) or error('Unable to delete topic subscriptions', __FILE__, __LINE__, $db->error()); + $db->query('DELETE FROM '.$db->prefix.'forum_subscriptions WHERE user_id='.$id) or error('Unable to delete forum subscriptions', __FILE__, __LINE__, $db->error()); + + // Remove him/her from the online list (if they happen to be logged in) + $db->query('DELETE FROM '.$db->prefix.'online WHERE user_id='.$id) or error('Unable to remove user from online list', __FILE__, __LINE__, $db->error()); + + // Should we delete all posts made by this user? + if (isset($_POST['delete_posts'])) + { + require PUN_ROOT.'include/search_idx.php'; + @set_time_limit(0); + + // Find all posts made by this user + $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()); + if ($db->num_rows($result)) + { + while ($cur_post = $db->fetch_assoc($result)) + { + // Determine whether this post is the "topic post" or not + $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()); + + if ($db->result($result2) == $cur_post['id']) + delete_topic($cur_post['topic_id']); + else + delete_post($cur_post['id'], $cur_post['topic_id']); + + update_forum($cur_post['forum_id']); + } + } + } + else + // Set all his/her posts to guest + $db->query('UPDATE '.$db->prefix.'posts SET poster_id=1 WHERE poster_id='.$id) or error('Unable to update posts', __FILE__, __LINE__, $db->error()); + + // Delete the user + $db->query('DELETE FROM '.$db->prefix.'users WHERE id='.$id) or error('Unable to delete user', __FILE__, __LINE__, $db->error()); + + // Delete user avatar + delete_avatar($id); + + // Regenerate the users info cache + if (!defined('FORUM_CACHE_FUNCTIONS_LOADED')) + require PUN_ROOT.'include/cache.php'; + + generate_users_info_cache(); + + if ($group_id == PUN_ADMIN) + generate_admins_cache(); + + redirect('index.php', $lang_profile['User delete redirect']); + } + + $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_common['Profile'], $lang_profile['Confirm delete user']); + define('PUN_ACTIVE_PAGE', 'profile'); + require PUN_ROOT.'header.php'; + +?> +
+

+
+
+
+
+ +
+

'.pun_htmlspecialchars($username).'.' ?>

+
+ +
+

+
+
+
+

+
+
+
+query('SELECT u.username, u.group_id, 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()); + if (!$db->num_rows($result)) + message($lang_common['Bad request'], false, '404 Not Found'); + + list($old_username, $group_id, $is_moderator) = $db->fetch_row($result); + + if ($pun_user['id'] != $id && // If we aren't the user (i.e. editing your own profile) + (!$pun_user['is_admmod'] || // and we are not an admin or mod + ($pun_user['g_id'] != PUN_ADMIN && // or we aren't an admin and ... + ($pun_user['g_mod_edit_users'] == '0' || // mods aren't allowed to edit users + $group_id == PUN_ADMIN || // or the user is an admin + $is_moderator)))) // or the user is another mod + message($lang_common['No permission'], false, '403 Forbidden'); + + // Make sure they got here from the site + confirm_referrer('profile.php'); + + $username_updated = false; + + // Validate input depending on section + switch ($section) + { + case 'essentials': + { + $form = array( + 'timezone' => floatval($_POST['form']['timezone']), + 'dst' => isset($_POST['form']['dst']) ? '1' : '0', + 'time_format' => intval($_POST['form']['time_format']), + 'date_format' => intval($_POST['form']['date_format']), + ); + + // Make sure we got a valid language string + if (isset($_POST['form']['language'])) + { + $languages = forum_list_langs(); + $form['language'] = pun_trim($_POST['form']['language']); + if (!in_array($form['language'], $languages)) + message($lang_common['Bad request'], false, '404 Not Found'); + } + else + $form['language'] = $pun_config['o_default_lang']; + + if ($pun_user['is_admmod']) + { + $form['admin_note'] = pun_trim($_POST['admin_note']); + + // Are we allowed to change usernames? + if ($pun_user['g_id'] == PUN_ADMIN || ($pun_user['g_moderator'] == '1' && $pun_user['g_mod_rename_users'] == '1')) + { + $form['username'] = pun_trim($_POST['req_username']); + + if ($form['username'] != $old_username) + { + // Check username + require PUN_ROOT.'lang/'.$pun_user['language'].'/register.php'; + + $errors = array(); + check_username($form['username'], $id); + if (!empty($errors)) + message($errors[0]); + + $username_updated = true; + } + } + + // We only allow administrators to update the post count + if ($pun_user['g_id'] == PUN_ADMIN) + $form['num_posts'] = intval($_POST['num_posts']); + } + + if ($pun_config['o_regs_verify'] == '0' || $pun_user['is_admmod']) + { + require PUN_ROOT.'include/email.php'; + + // Validate the email address + $form['email'] = strtolower(pun_trim($_POST['req_email'])); + if (!is_valid_email($form['email'])) + message($lang_common['Invalid email']); + } + + break; + } + + case 'personal': + { + $form = array( + 'realname' => isset($_POST['form']['realname']) ? pun_trim($_POST['form']['realname']) : '', + 'url' => isset($_POST['form']['url']) ? pun_trim($_POST['form']['url']) : '', + 'location' => isset($_POST['form']['location']) ? pun_trim($_POST['form']['location']) : '', + ); + + // Add http:// if the URL doesn't contain it already (while allowing https://, too) + if ($pun_user['g_post_links'] == '1') + { + if ($form['url'] != '') + { + $url = url_valid($form['url']); + + if ($url === false) + message($lang_profile['Invalid website URL']); + + $form['url'] = $url['url']; + } + } + else + { + if (!empty($form['url'])) + message($lang_profile['Website not allowed']); + + $form['url'] = ''; + } + + if ($pun_user['g_id'] == PUN_ADMIN) + $form['title'] = pun_trim($_POST['title']); + else if ($pun_user['g_set_title'] == '1') + { + $form['title'] = pun_trim($_POST['title']); + + if ($form['title'] != '') + { + // A list of words that the title may not contain + // If the language is English, there will be some duplicates, but it's not the end of the world + $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'])); + + if (in_array(utf8_strtolower($form['title']), $forbidden)) + message($lang_profile['Forbidden title']); + } + } + + break; + } + + case 'messaging': + { + $form = array( + 'jabber' => pun_trim($_POST['form']['jabber']), + 'icq' => pun_trim($_POST['form']['icq']), + 'msn' => pun_trim($_POST['form']['msn']), + 'aim' => pun_trim($_POST['form']['aim']), + 'yahoo' => pun_trim($_POST['form']['yahoo']), + ); + + // If the ICQ UIN contains anything other than digits it's invalid + if (preg_match('%[^0-9]%', $form['icq'])) + message($lang_prof_reg['Bad ICQ']); + + break; + } + + case 'personality': + { + $form = array(); + + // Clean up signature from POST + if ($pun_config['o_signatures'] == '1') + { + $form['signature'] = pun_linebreaks(pun_trim($_POST['signature'])); + + // Validate signature + if (pun_strlen($form['signature']) > $pun_config['p_sig_length']) + message(sprintf($lang_prof_reg['Sig too long'], $pun_config['p_sig_length'], pun_strlen($form['signature']) - $pun_config['p_sig_length'])); + else if (substr_count($form['signature'], "\n") > ($pun_config['p_sig_lines']-1)) + message(sprintf($lang_prof_reg['Sig too many lines'], $pun_config['p_sig_lines'])); + else if ($form['signature'] && $pun_config['p_sig_all_caps'] == '0' && is_all_uppercase($form['signature']) && !$pun_user['is_admmod']) + $form['signature'] = utf8_ucwords(utf8_strtolower($form['signature'])); + + // Validate BBCode syntax + if ($pun_config['p_sig_bbcode'] == '1') + { + require PUN_ROOT.'include/parser.php'; + + $errors = array(); + + $form['signature'] = preparse_bbcode($form['signature'], $errors, true); + + if(count($errors) > 0) + message('
  • '.implode('
  • ', $errors).'
'); + } + } + + break; + } + + case 'display': + { + $form = array( + 'disp_topics' => pun_trim($_POST['form']['disp_topics']), + 'disp_posts' => pun_trim($_POST['form']['disp_posts']), + ); + + if ($form['disp_topics'] != '') + { + $form['disp_topics'] = intval($form['disp_topics']); + if ($form['disp_topics'] < 3) + $form['disp_topics'] = 3; + else if ($form['disp_topics'] > 75) + $form['disp_topics'] = 75; + } + + if ($form['disp_posts'] != '') + { + $form['disp_posts'] = intval($form['disp_posts']); + if ($form['disp_posts'] < 3) + $form['disp_posts'] = 3; + else if ($form['disp_posts'] > 75) + $form['disp_posts'] = 75; + } + + if ($pun_config['o_smilies'] == '1' || $pun_config['o_smilies_sig'] == '1') + $form['show_smilies'] = isset($_POST['form']['show_smilies']) ? '1' : '0'; + + if ($pun_config['p_message_bbcode'] == '1' && $pun_config['p_message_img_tag'] == '1') + $form['show_img'] = isset($_POST['form']['show_img']) ? '1' : '0'; + + if ($pun_config['o_signatures'] == '1' && $pun_config['p_sig_bbcode'] == '1' && $pun_config['p_sig_img_tag'] == '1') + $form['show_img_sig'] = isset($_POST['form']['show_img_sig']) ? '1' : '0'; + + if ($pun_config['o_avatars'] == '1') + $form['show_avatars'] = isset($_POST['form']['show_avatars']) ? '1' : '0'; + + if ($pun_config['o_signatures'] == '1') + $form['show_sig'] = isset($_POST['form']['show_sig']) ? '1' : '0'; + + // Make sure we got a valid style string + if (isset($_POST['form']['style'])) + { + $styles = forum_list_styles(); + $form['style'] = pun_trim($_POST['form']['style']); + if (!in_array($form['style'], $styles)) + message($lang_common['Bad request'], false, '404 Not Found'); + } + + break; + } + + case 'privacy': + { + $form = array( + 'email_setting' => intval($_POST['form']['email_setting']), + 'notify_with_post' => isset($_POST['form']['notify_with_post']) ? '1' : '0', + 'auto_notify' => isset($_POST['form']['auto_notify']) ? '1' : '0', + ); + + if ($form['email_setting'] < 0 || $form['email_setting'] > 2) + $form['email_setting'] = $pun_config['o_default_email_setting']; + + break; + } + + default: + message($lang_common['Bad request'], false, '404 Not Found'); + } + + + // Single quotes around non-empty values and NULL for empty values + $temp = array(); + foreach ($form as $key => $input) + { + $value = ($input !== '') ? '\''.$db->escape($input).'\'' : 'NULL'; + + $temp[] = $key.'='.$value; + } + + if (empty($temp)) + message($lang_common['Bad request'], false, '404 Not Found'); + + + $db->query('UPDATE '.$db->prefix.'users SET '.implode(',', $temp).' WHERE id='.$id) or error('Unable to update profile', __FILE__, __LINE__, $db->error()); + + // If we changed the username we have to update some stuff + if ($username_updated) + { + $db->query('UPDATE '.$db->prefix.'bans SET username=\''.$db->escape($form['username']).'\' WHERE username=\''.$db->escape($old_username).'\'') or error('Unable to update bans', __FILE__, __LINE__, $db->error()); + // If any bans were updated, we will need to know because the cache will need to be regenerated. + if ($db->affected_rows() > 0) + $bans_updated = true; + $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()); + $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()); + $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()); + $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()); + $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()); + $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()); + + // If the user is a moderator or an administrator we have to update the moderator lists + $result = $db->query('SELECT group_id FROM '.$db->prefix.'users WHERE id='.$id) or error('Unable to fetch user info', __FILE__, __LINE__, $db->error()); + $group_id = $db->result($result); + + $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()); + $group_mod = $db->result($result); + + if ($group_id == PUN_ADMIN || $group_mod == '1') + { + $result = $db->query('SELECT id, moderators FROM '.$db->prefix.'forums') or error('Unable to fetch forum list', __FILE__, __LINE__, $db->error()); + + while ($cur_forum = $db->fetch_assoc($result)) + { + $cur_moderators = ($cur_forum['moderators'] != '') ? unserialize($cur_forum['moderators']) : array(); + + if (in_array($id, $cur_moderators)) + { + unset($cur_moderators[$old_username]); + $cur_moderators[$form['username']] = $id; + uksort($cur_moderators, 'utf8_strcasecmp'); + + $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()); + } + } + } + + // Regenerate the users info cache + if (!defined('FORUM_CACHE_FUNCTIONS_LOADED')) + require PUN_ROOT.'include/cache.php'; + + generate_users_info_cache(); + + // Check if the bans table was updated and regenerate the bans cache when needed + if (isset($bans_updated)) + generate_bans_cache(); + } + + redirect('profile.php?section='.$section.'&id='.$id, $lang_profile['Profile redirect']); +} + +flux_hook('profile_after_form_handling'); + + +$result = $db->query('SELECT u.username, u.email, u.title, u.realname, u.url, u.jabber, u.icq, u.msn, u.aim, u.yahoo, u.location, u.signature, u.disp_topics, u.disp_posts, u.email_setting, u.notify_with_post, u.auto_notify, u.show_smilies, u.show_img, u.show_img_sig, u.show_avatars, u.show_sig, u.timezone, u.dst, u.language, u.style, u.num_posts, u.last_post, u.registered, u.registration_ip, u.admin_note, u.date_format, u.time_format, u.last_visit, 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()); +if (!$db->num_rows($result)) + message($lang_common['Bad request'], false, '404 Not Found'); + +$user = $db->fetch_assoc($result); + +$last_post = format_time($user['last_post']); + +if ($user['signature'] != '') +{ + require PUN_ROOT.'include/parser.php'; + $parsed_signature = parse_signature($user['signature']); +} + + +// View or edit? +if ($pun_user['id'] != $id && // If we aren't the user (i.e. editing your own profile) + (!$pun_user['is_admmod'] || // and we are not an admin or mod + ($pun_user['g_id'] != PUN_ADMIN && // or we aren't an admin and ... + ($pun_user['g_mod_edit_users'] == '0' || // mods aren't allowed to edit users + $user['g_id'] == PUN_ADMIN || // or the user is an admin + $user['g_moderator'] == '1')))) // or the user is another mod +{ + $user_personal = array(); + + $user_personal[] = '
'.$lang_common['Username'].'
'; + $user_personal[] = '
'.pun_htmlspecialchars($user['username']).'
'; + + $user_title_field = get_title($user); + $user_personal[] = '
'.$lang_common['Title'].'
'; + $user_personal[] = '
'.(($pun_config['o_censoring'] == '1') ? censor_words($user_title_field) : $user_title_field).'
'; + + if ($user['realname'] != '') + { + $user_personal[] = '
'.$lang_profile['Realname'].'
'; + $user_personal[] = '
'.pun_htmlspecialchars(($pun_config['o_censoring'] == '1') ? censor_words($user['realname']) : $user['realname']).'
'; + } + + if ($user['location'] != '') + { + $user_personal[] = '
'.$lang_profile['Location'].'
'; + $user_personal[] = '
'.pun_htmlspecialchars(($pun_config['o_censoring'] == '1') ? censor_words($user['location']) : $user['location']).'
'; + } + + if ($user['url'] != '') + { + $user['url'] = pun_htmlspecialchars(($pun_config['o_censoring'] == '1') ? censor_words($user['url']) : $user['url']); + $user_personal[] = '
'.$lang_profile['Website'].'
'; + $user_personal[] = '
'.$user['url'].'
'; + } + + if ($user['email_setting'] == '0' && !$pun_user['is_guest'] && $pun_user['g_send_email'] == '1') + $email_field = ''.pun_htmlspecialchars($user['email']).''; + else if ($user['email_setting'] == '1' && !$pun_user['is_guest'] && $pun_user['g_send_email'] == '1') + $email_field = ''.$lang_common['Send email'].''; + else + $email_field = ''; + if ($email_field != '') + { + $user_personal[] = '
'.$lang_common['Email'].'
'; + $user_personal[] = '
'; + } + + $user_messaging = array(); + + if ($user['jabber'] != '') + { + $user_messaging[] = '
'.$lang_profile['Jabber'].'
'; + $user_messaging[] = '
'.pun_htmlspecialchars(($pun_config['o_censoring'] == '1') ? censor_words($user['jabber']) : $user['jabber']).'
'; + } + + if ($user['icq'] != '') + { + $user_messaging[] = '
'.$lang_profile['ICQ'].'
'; + $user_messaging[] = '
'.$user['icq'].'
'; + } + + if ($user['msn'] != '') + { + $user_messaging[] = '
'.$lang_profile['MSN'].'
'; + $user_messaging[] = '
'.pun_htmlspecialchars(($pun_config['o_censoring'] == '1') ? censor_words($user['msn']) : $user['msn']).'
'; + } + + if ($user['aim'] != '') + { + $user_messaging[] = '
'.$lang_profile['AOL IM'].'
'; + $user_messaging[] = '
'.pun_htmlspecialchars(($pun_config['o_censoring'] == '1') ? censor_words($user['aim']) : $user['aim']).'
'; + } + + if ($user['yahoo'] != '') + { + $user_messaging[] = '
'.$lang_profile['Yahoo'].'
'; + $user_messaging[] = '
'.pun_htmlspecialchars(($pun_config['o_censoring'] == '1') ? censor_words($user['yahoo']) : $user['yahoo']).'
'; + } + + $user_personality = array(); + + if ($pun_config['o_avatars'] == '1') + { + $avatar_field = generate_avatar_markup($id); + if ($avatar_field != '') + { + $user_personality[] = '
'.$lang_profile['Avatar'].'
'; + $user_personality[] = '
'.$avatar_field.'
'; + } + } + + if ($pun_config['o_signatures'] == '1') + { + if (isset($parsed_signature)) + { + $user_personality[] = '
'.$lang_profile['Signature'].'
'; + $user_personality[] = '
'.$parsed_signature.'
'; + } + } + + $user_activity = array(); + + $posts_field = ''; + if ($pun_config['o_show_post_count'] == '1' || $pun_user['is_admmod']) + $posts_field = forum_number_format($user['num_posts']); + if ($pun_user['g_search'] == '1') + { + $quick_searches = array(); + if ($user['num_posts'] > 0) + { + $quick_searches[] = ''.$lang_profile['Show topics'].''; + $quick_searches[] = ''.$lang_profile['Show posts'].''; + } + if ($pun_user['is_admmod'] && $pun_config['o_topic_subscriptions'] == '1') + $quick_searches[] = ''.$lang_profile['Show subscriptions'].''; + + if (!empty($quick_searches)) + $posts_field .= (($posts_field != '') ? ' - ' : '').implode(' - ', $quick_searches); + } + if ($posts_field != '') + { + $user_activity[] = '
'.$lang_common['Posts'].'
'; + $user_activity[] = '
'.$posts_field.'
'; + } + + if ($user['num_posts'] > 0) + { + $user_activity[] = '
'.$lang_common['Last post'].'
'; + $user_activity[] = '
'.$last_post.'
'; + } + + $user_activity[] = '
'.$lang_common['Registered'].'
'; + $user_activity[] = '
'.format_time($user['registered'], true).'
'; + + $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), sprintf($lang_profile['Users profile'], pun_htmlspecialchars($user['username']))); + define('PUN_ALLOW_INDEX', 1); + define('PUN_ACTIVE_PAGE', 'index'); + require PUN_ROOT.'header.php'; + +?> +
+

+
+
+
+
+ +
+
+ +
+
+
+
+
+
+
+ +
+
+ +
+
+
+
+
+
+
+ +
+
+ +
+
+
+
+
+
+
+ +
+
+ +
+
+
+
+
+
+
+
+ +'.$lang_common['Username'].' '.$lang_common['Required'].'

'."\n"; + else + $username_field = '

'.sprintf($lang_profile['Username info'], pun_htmlspecialchars($user['username'])).'

'."\n"; + + $email_field = '

'."\n"; + } + else + { + $username_field = '

'.$lang_common['Username'].': '.pun_htmlspecialchars($user['username']).'

'."\n"; + + if ($pun_config['o_regs_verify'] == '1') + $email_field = '

'.sprintf($lang_profile['Email info'], pun_htmlspecialchars($user['email']).' - '.$lang_profile['Change email'].'').'

'."\n"; + else + $email_field = ''."\n"; + } + + $posts_field = ''; + $posts_actions = array(); + + if ($pun_user['g_id'] == PUN_ADMIN) + $posts_field .= ''; + else if ($pun_config['o_show_post_count'] == '1' || $pun_user['is_admmod']) + $posts_actions[] = sprintf($lang_profile['Posts info'], forum_number_format($user['num_posts'])); + + if ($pun_user['g_search'] == '1' || $pun_user['g_id'] == PUN_ADMIN) + { + $posts_actions[] = ''.$lang_profile['Show topics'].''; + $posts_actions[] = ''.$lang_profile['Show posts'].''; + + if ($pun_config['o_topic_subscriptions'] == '1') + $posts_actions[] = ''.$lang_profile['Show subscriptions'].''; + } + + $posts_field .= (!empty($posts_actions) ? '

'.implode(' - ', $posts_actions).'

' : '')."\n"; + + + $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_common['Profile'], $lang_profile['Section essentials']); + $required_fields = array('req_username' => $lang_common['Username'], 'req_email' => $lang_common['Email']); + define('PUN_ACTIVE_PAGE', 'profile'); + require PUN_ROOT.'header.php'; + + generate_profile_menu('essentials'); + +?> +
+

+
+
+
+
+ +
+ + +

+
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+

+ +
+ +
+ + + + 1) + { + +?> + + +
+
+
+
+
+ +
+

'.pun_htmlspecialchars($user['registration_ip']).')' : '')) ?>

+

+

+ + +
+
+
+

+
+
+
+'.$lang_common['Title'].' ('.$lang_profile['Leave blank'].')

'."\n"; + + $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_common['Profile'], $lang_profile['Section personal']); + define('PUN_ACTIVE_PAGE', 'profile'); + require PUN_ROOT.'header.php'; + + generate_profile_menu('personal'); + +?> +
+

+
+
+
+
+ +
+ + + + + + +
+
+
+

+
+
+
+ +
+

+
+
+
+
+ +
+ + + + + + +
+
+
+

+
+
+
+'.$lang_profile['Change avatar'].''; + + $user_avatar = generate_avatar_markup($id); + if ($user_avatar) + $avatar_field .= ' '.$lang_profile['Delete avatar'].''; + else + $avatar_field = ''.$lang_profile['Upload avatar'].''; + + if ($user['signature'] != '') + $signature_preview = '

'.$lang_profile['Sig preview'].'

'."\n\t\t\t\t\t\t\t".'
'."\n\t\t\t\t\t\t\t\t".'
'."\n\t\t\t\t\t\t\t\t".$parsed_signature."\n\t\t\t\t\t\t\t".'
'."\n"; + else + $signature_preview = '

'.$lang_profile['No sig'].'

'."\n"; + + $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_common['Profile'], $lang_profile['Section personality']); + define('PUN_ACTIVE_PAGE', 'profile'); + require PUN_ROOT.'header.php'; + + generate_profile_menu('personality'); + + +?> +
+

+
+
+
+
+
+ +
+
+

+

+
+
+
+
+
+ +
+

+
+ +
+ + +
+
+
+

+
+
+
+ +
+

+
+
+
+
'."\n"; + else if (count($styles) > 1) + { + +?> +
+
+ +
+ +
+
+
+ + +
+
+ +
+

+
+ + + + + + +
+
+
+
+ +
+
+ +
+ + +

+
+
+
+

+ +
+ + +
+

+
+
+
+
+ +
+ +

+
+ + + +
+
+
+
+
+
+ +
+
+ + + +
+
+
+
+

+
+
+
+ +
+

+
+
+
+ +
+ + +
+

+
+
+
+ + +
+ + +
+ +
+
+
+ + +
+ +
+
+
+ +
+
+ +
+

+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()); + + $cur_category = 0; + while ($cur_forum = $db->fetch_assoc($result)) + { + if ($cur_forum['cid'] != $cur_category) // A new category since last iteration? + { + if ($cur_category) + echo "\n\t\t\t\t\t\t\t\t".'
'; + + if ($cur_category != 0) + echo "\n\t\t\t\t\t\t\t".'
'."\n"; + + echo "\t\t\t\t\t\t\t".'
'."\n\t\t\t\t\t\t\t\t".'

'.pun_htmlspecialchars($cur_forum['cat_name']).'

'."\n\t\t\t\t\t\t\t\t".'
'; + $cur_category = $cur_forum['cid']; + } + + $moderators = ($cur_forum['moderators'] != '') ? unserialize($cur_forum['moderators']) : array(); + + echo "\n\t\t\t\t\t\t\t\t\t".''."\n"; + } + +?> +
+
+
+
+ + + + + + + + +
+ +