function pun_mail($to, $subject, $message, $reply_to_email = '', $reply_to_name = '') { global $feather_config, $lang_common; // Use \r\n for SMTP servers, the system's line ending for local mailers $smtp = $feather_config['o_smtp_host'] != ''; $EOL = $smtp ? "\r\n" : FORUM_EOL; // Default sender/return address $from_name = sprintf($lang_common['Mailer'], $feather_config['o_board_title']); $from_email = $feather_config['o_webmaster_email']; // Do a little spring cleaning $to = feather_trim(preg_replace('%[\\n\\r]+%s', '', $to)); $subject = feather_trim(preg_replace('%[\\n\\r]+%s', '', $subject)); $from_email = feather_trim(preg_replace('%[\\n\\r:]+%s', '', $from_email)); $from_name = feather_trim(preg_replace('%[\\n\\r:]+%s', '', str_replace('"', '', $from_name))); $reply_to_email = feather_trim(preg_replace('%[\\n\\r:]+%s', '', $reply_to_email)); $reply_to_name = feather_trim(preg_replace('%[\\n\\r:]+%s', '', str_replace('"', '', $reply_to_name))); // Set up some headers to take advantage of UTF-8 $from = '"' . encode_mail_text($from_name) . '" <' . $from_email . '>'; $subject = encode_mail_text($subject); $headers = 'From: ' . $from . $EOL . 'Date: ' . gmdate('r') . $EOL . 'MIME-Version: 1.0' . $EOL . 'Content-transfer-encoding: 8bit' . $EOL . 'Content-type: text/plain; charset=utf-8' . $EOL . 'X-Mailer: FeatherBB Mailer'; // If we specified a reply-to email, we deal with it here if (!empty($reply_to_email)) { $reply_to = '"' . encode_mail_text($reply_to_name) . '" <' . $reply_to_email . '>'; $headers .= $EOL . 'Reply-To: ' . $reply_to; } // Make sure all linebreaks are LF in message (and strip out any NULL bytes) $message = str_replace("", '', feather_linebreaks($message)); $message = str_replace("\n", $EOL, $message); $mailer = $smtp ? 'smtp_mail' : 'mail'; $mailer($to, $subject, $message, $headers); }
<?php } ?> <label class="required"><strong><?php echo $lang_common['Message']; ?> <span><?php echo $lang_common['Required']; ?> </span></strong><br /> <script>postEditorToolbar('req_message');</script> <textarea name="req_message" id="req_message" rows="20" cols="95" tabindex="<?php echo $cur_index++; ?> "><?php echo $feather->request->post('req_message') ? feather_linebreaks(feather_trim(feather_escape($feather->request->post('req_message')))) : (isset($quote) ? $quote : ''); ?> </textarea><br /></label> <ul class="bblinks"> <li><span><a href="<?php echo get_link('help/#bbcode'); ?> " onclick="window.open(this.href); return false;"><?php echo $lang_common['BBCode']; ?> </a> <?php echo $feather_config['p_message_bbcode'] == '1' ? $lang_common['on'] : $lang_common['off']; ?> </span></li> <li><span><a href="<?php echo get_link('help/#url');
public function update_options() { global $lang_admin_options, $lang_common; $form = array('board_title' => feather_trim($this->request->post('form_board_title')), 'board_desc' => feather_trim($this->request->post('form_board_desc')), 'base_url' => feather_trim($this->request->post('form_base_url')), 'default_timezone' => floatval($this->request->post('form_default_timezone')), 'default_dst' => $this->request->post('form_default_dst') != '1' ? '0' : '1', 'default_lang' => feather_trim($this->request->post('form_default_lang')), 'default_style' => feather_trim($this->request->post('form_default_style')), 'time_format' => feather_trim($this->request->post('form_time_format')), 'date_format' => feather_trim($this->request->post('form_date_format')), 'timeout_visit' => intval($this->request->post('form_timeout_visit')) > 0 ? intval($this->request->post('form_timeout_visit')) : 1, 'timeout_online' => intval($this->request->post('form_timeout_online')) > 0 ? intval($this->request->post('form_timeout_online')) : 1, 'redirect_delay' => intval($this->request->post('form_redirect_delay')) >= 0 ? intval($this->request->post('form_redirect_delay')) : 0, 'show_version' => $this->request->post('form_show_version') != '1' ? '0' : '1', 'show_user_info' => $this->request->post('form_show_user_info') != '1' ? '0' : '1', 'show_post_count' => $this->request->post('form_show_post_count') != '1' ? '0' : '1', 'smilies' => $this->request->post('form_smilies') != '1' ? '0' : '1', 'smilies_sig' => $this->request->post('form_smilies_sig') != '1' ? '0' : '1', 'make_links' => $this->request->post('form_make_links') != '1' ? '0' : '1', 'topic_review' => intval($this->request->post('form_topic_review')) >= 0 ? intval($this->request->post('form_topic_review')) : 0, 'disp_topics_default' => intval($this->request->post('form_disp_topics_default')), 'disp_posts_default' => intval($this->request->post('form_disp_posts_default')), 'indent_num_spaces' => intval($this->request->post('form_indent_num_spaces')) >= 0 ? intval($this->request->post('form_indent_num_spaces')) : 0, 'quote_depth' => intval($this->request->post('form_quote_depth')) > 0 ? intval($this->request->post('form_quote_depth')) : 1, 'quickpost' => $this->request->post('form_quickpost') != '1' ? '0' : '1', 'users_online' => $this->request->post('form_users_online') != '1' ? '0' : '1', 'censoring' => $this->request->post('form_censoring') != '1' ? '0' : '1', 'signatures' => $this->request->post('form_signatures') != '1' ? '0' : '1', 'show_dot' => $this->request->post('form_show_dot') != '1' ? '0' : '1', 'topic_views' => $this->request->post('form_topic_views') != '1' ? '0' : '1', 'quickjump' => $this->request->post('form_quickjump') != '1' ? '0' : '1', 'gzip' => $this->request->post('form_gzip') != '1' ? '0' : '1', 'search_all_forums' => $this->request->post('form_search_all_forums') != '1' ? '0' : '1', 'additional_navlinks' => feather_trim($this->request->post('form_additional_navlinks')), 'feed_type' => intval($this->request->post('form_feed_type')), 'feed_ttl' => intval($this->request->post('form_feed_ttl')), 'report_method' => intval($this->request->post('form_report_method')), 'mailing_list' => feather_trim($this->request->post('form_mailing_list')), 'avatars' => $this->request->post('form_avatars') != '1' ? '0' : '1', 'avatars_dir' => feather_trim($this->request->post('form_avatars_dir')), 'avatars_width' => intval($this->request->post('form_avatars_width')) > 0 ? intval($this->request->post('form_avatars_width')) : 1, 'avatars_height' => intval($this->request->post('form_avatars_height')) > 0 ? intval($this->request->post('form_avatars_height')) : 1, 'avatars_size' => intval($this->request->post('form_avatars_size')) > 0 ? intval($this->request->post('form_avatars_size')) : 1, 'admin_email' => strtolower(feather_trim($this->request->post('form_admin_email'))), 'webmaster_email' => strtolower(feather_trim($this->request->post('form_webmaster_email'))), 'forum_subscriptions' => $this->request->post('form_forum_subscriptions') != '1' ? '0' : '1', 'topic_subscriptions' => $this->request->post('form_topic_subscriptions') != '1' ? '0' : '1', 'smtp_host' => feather_trim($this->request->post('form_smtp_host')), 'smtp_user' => feather_trim($this->request->post('form_smtp_user')), 'smtp_ssl' => $this->request->post('form_smtp_ssl') != '1' ? '0' : '1', 'regs_allow' => $this->request->post('form_regs_allow') != '1' ? '0' : '1', 'regs_verify' => $this->request->post('form_regs_verify') != '1' ? '0' : '1', 'regs_report' => $this->request->post('form_regs_report') != '1' ? '0' : '1', 'rules' => $this->request->post('form_rules') != '1' ? '0' : '1', 'rules_message' => feather_trim($this->request->post('form_rules_message')), 'default_email_setting' => intval($this->request->post('form_default_email_setting')), 'announcement' => $this->request->post('form_announcement') != '1' ? '0' : '1', 'announcement_message' => feather_trim($this->request->post('form_announcement_message')), 'maintenance' => $this->request->post('form_maintenance') != '1' ? '0' : '1', 'maintenance_message' => feather_trim($this->request->post('form_maintenance_message'))); if ($form['board_title'] == '') { message($lang_admin_options['Must enter title message']); } // Make sure base_url doesn't end with a slash if (substr($form['base_url'], -1) == '/') { $form['base_url'] = substr($form['base_url'], 0, -1); } // Convert IDN to Punycode if needed if (preg_match('/[^\\x00-\\x7F]/', $form['base_url'])) { if (!function_exists('idn_to_ascii')) { message($lang_admin_options['Base URL problem']); } else { $form['base_url'] = idn_to_ascii($form['base_url']); } } $languages = forum_list_langs(); if (!in_array($form['default_lang'], $languages)) { message($lang_common['Bad request'], '404'); } $styles = forum_list_styles(); if (!in_array($form['default_style'], $styles)) { message($lang_common['Bad request'], '404'); } if ($form['time_format'] == '') { $form['time_format'] = 'H:i:s'; } if ($form['date_format'] == '') { $form['date_format'] = 'Y-m-d'; } require FEATHER_ROOT . 'include/email.php'; if (!is_valid_email($form['admin_email'])) { message($lang_admin_options['Invalid e-mail message']); } if (!is_valid_email($form['webmaster_email'])) { message($lang_admin_options['Invalid webmaster e-mail message']); } if ($form['mailing_list'] != '') { $form['mailing_list'] = strtolower(preg_replace('%\\s%S', '', $form['mailing_list'])); } // Make sure avatars_dir doesn't end with a slash if (substr($form['avatars_dir'], -1) == '/') { $form['avatars_dir'] = substr($form['avatars_dir'], 0, -1); } if ($form['additional_navlinks'] != '') { $form['additional_navlinks'] = feather_trim(feather_linebreaks($form['additional_navlinks'])); } // Change or enter a SMTP password if ($this->request->post('form_smtp_change_pass')) { $smtp_pass1 = $this->request->post('form_smtp_pass1') ? feather_trim($this->request->post('form_smtp_pass1')) : ''; $smtp_pass2 = $this->request->post('form_smtp_pass2') ? feather_trim($this->request->post('form_smtp_pass2')) : ''; if ($smtp_pass1 == $smtp_pass2) { $form['smtp_pass'] = $smtp_pass1; } else { message($lang_admin_options['SMTP passwords did not match']); } } if ($form['announcement_message'] != '') { $form['announcement_message'] = feather_linebreaks($form['announcement_message']); } else { $form['announcement_message'] = $lang_admin_options['Enter announcement here']; $form['announcement'] = '0'; } if ($form['rules_message'] != '') { $form['rules_message'] = feather_linebreaks($form['rules_message']); } else { $form['rules_message'] = $lang_admin_options['Enter rules here']; $form['rules'] = '0'; } if ($form['maintenance_message'] != '') { $form['maintenance_message'] = feather_linebreaks($form['maintenance_message']); } else { $form['maintenance_message'] = $lang_admin_options['Default maintenance message']; $form['maintenance'] = '0'; } // Make sure the number of displayed topics and posts is between 3 and 75 if ($form['disp_topics_default'] < 3) { $form['disp_topics_default'] = 3; } elseif ($form['disp_topics_default'] > 75) { $form['disp_topics_default'] = 75; } if ($form['disp_posts_default'] < 3) { $form['disp_posts_default'] = 3; } elseif ($form['disp_posts_default'] > 75) { $form['disp_posts_default'] = 75; } if ($form['feed_type'] < 0 || $form['feed_type'] > 2) { message($lang_common['Bad request'], '404'); } if ($form['feed_ttl'] < 0) { message($lang_common['Bad request'], '404'); } if ($form['report_method'] < 0 || $form['report_method'] > 2) { message($lang_common['Bad request'], '404'); } if ($form['default_email_setting'] < 0 || $form['default_email_setting'] > 2) { message($lang_common['Bad request'], '404'); } if ($form['timeout_online'] >= $form['timeout_visit']) { message($lang_admin_options['Timeout error message']); } foreach ($form as $key => $input) { // Only update values that have changed if (array_key_exists('o_' . $key, $this->config) && $this->config['o_' . $key] != $input) { if ($input != '' || is_int($input)) { DB::for_table('config')->where('conf_name', 'o_' . $key)->update_many('conf_value', $input); } else { DB::for_table('config')->where('conf_name', 'o_' . $key)->update_many_expr('conf_value', 'NULL'); } } } // Regenerate the config cache if (!defined('FORUM_CACHE_FUNCTIONS_LOADED')) { require FEATHER_ROOT . 'include/cache.php'; } generate_config_cache(); clear_feed_cache(); redirect(get_link('admin/options/'), $lang_admin_options['Options updated redirect']); }
public function setup_variables($errors, $is_admmod) { $post = array(); if (!$this->user->is_guest) { $post['username'] = $this->user->username; $post['email'] = $this->user->email; } else { $post['username'] = feather_trim($this->request->post('req_username')); $post['email'] = strtolower(feather_trim($this->config['p_force_guest_email'] == '1' ? $this->request->post('req_email') : $this->request->post('email'))); } if ($this->request->post('req_subject')) { $post['subject'] = feather_trim($this->request->post('req_subject')); } $post['hide_smilies'] = $this->request->post('hide_smilies') ? '1' : '0'; $post['subscribe'] = $this->request->post('subscribe') ? '1' : '0'; $post['stick_topic'] = $this->request->post('stick_topic') && $is_admmod ? '1' : '0'; $post['message'] = feather_linebreaks(feather_trim($this->request->post('req_message'))); // Validate BBCode syntax if ($this->config['p_message_bbcode'] == '1') { require_once FEATHER_ROOT . 'include/parser.php'; $post['message'] = preparse_bbcode($post['message'], $errors); } // Replace four-byte characters (MySQL cannot handle them) $post['message'] = strip_bad_multibyte_chars($post['message']); $post['time'] = time(); return $post; }
public function setup_variables($cur_post, $is_admmod, $can_edit_subject, $errors) { global $pd; $post = array(); $post['hide_smilies'] = $this->request->post('hide_smilies') ? '1' : '0'; $post['stick_topic'] = $this->request->post('stick_topic') ? '1' : '0'; if (!$is_admmod) { $post['stick_topic'] = $cur_post['sticky']; } // Clean up message from POST $post['message'] = feather_linebreaks(feather_trim($this->request->post('req_message'))); // Validate BBCode syntax if ($this->config['p_message_bbcode'] == '1') { require_once FEATHER_ROOT . 'include/parser.php'; $post['message'] = preparse_bbcode($post['message'], $errors); } // Replace four-byte characters (MySQL cannot handle them) $post['message'] = strip_bad_multibyte_chars($post['message']); // Get the subject if ($can_edit_subject) { $post['subject'] = feather_trim($this->request->post('req_subject')); } return $post; }
public function edit_forum($forum_id) { global $lang_common, $lang_admin_common, $lang_admin_forums; if ($this->user->g_id != FEATHER_ADMIN) { message($lang_common['No permission'], '403'); } // Load the admin_options.php language file require FEATHER_ROOT . 'include/common_admin.php'; require FEATHER_ROOT . 'lang/' . $admin_language . '/forums.php'; if ($this->request->isPost()) { if ($this->request->post('save') && $this->request->post('read_forum_old')) { // Forums parameters / TODO : better handling of wrong parameters $forum_data = array('forum_name' => feather_escape($this->request->post('forum_name')), 'forum_desc' => $this->request->post('forum_desc') ? feather_linebreaks(feather_trim($this->request->post('forum_desc'))) : NULL, 'cat_id' => (int) $this->request->post('cat_id'), 'sort_by' => (int) $this->request->post('sort_by'), 'redirect_url' => url_valid($this->request->post('redirect_url')) ? feather_escape($this->request->post('redirect_url')) : NULL); if ($forum_data['forum_name'] == '') { redirect(get_link('admin/forums/edit/' . $forum_id . '/'), $lang_admin_forums['Must enter name message']); } if ($forum_data['cat_id'] < 1) { redirect(get_link('admin/forums/edit/' . $forum_id . '/'), $lang_admin_forums['Must be valid category']); } $this->model->update_forum($forum_id, $forum_data); // Permissions $permissions = $this->model->get_default_group_permissions(false); foreach ($permissions as $perm_group) { $permissions_data = array('group_id' => $perm_group['g_id'], 'forum_id' => $forum_id); if ($perm_group['g_read_board'] == '1' && isset($this->request->post('read_forum_new')[$perm_group['g_id']]) && $this->request->post('read_forum_new')[$perm_group['g_id']] == '1') { $permissions_data['read_forum'] = '1'; } else { $permissions_data['read_forum'] = '0'; } $permissions_data['post_replies'] = isset($this->request->post('post_replies_new')[$perm_group['g_id']]) ? '1' : '0'; $permissions_data['post_topics'] = isset($this->request->post('post_topics_new')[$perm_group['g_id']]) ? '1' : '0'; // Check if the new settings differ from the old if ($permissions_data['read_forum'] != $this->request->post('read_forum_old')[$perm_group['g_id']] || $permissions_data['post_replies'] != $this->request->post('post_replies_old')[$perm_group['g_id']] || $permissions_data['post_topics'] != $this->request->post('post_topics_old')[$perm_group['g_id']]) { // If there is no group permissions override for this forum if ($permissions_data['read_forum'] == '1' && $permissions_data['post_replies'] == $perm_group['g_post_replies'] && $permissions_data['post_topics'] == $perm_group['g_post_topics']) { $this->model->delete_permissions($forum_id, $perm_group['g_id']); } else { // Run an UPDATE and see if it affected a row, if not, INSERT $this->model->update_permissions($permissions_data); } } } // Regenerate the quick jump cache if (!defined('FORUM_CACHE_FUNCTIONS_LOADED')) { require FEATHER_ROOT . 'include/cache.php'; } generate_quickjump_cache(); redirect(get_link('admin/forums/edit/' . $forum_id . '/'), $lang_admin_forums['Forum updated redirect']); } elseif ($this->request->post('revert_perms')) { $this->model->delete_permissions($forum_id); // Regenerate the quick jump cache if (!defined('FORUM_CACHE_FUNCTIONS_LOADED')) { require FEATHER_ROOT . 'include/cache.php'; } generate_quickjump_cache(); redirect(get_link('admin/forums/edit/' . $forum_id . '/'), $lang_admin_forums['Perms reverted redirect']); } } else { define('FEATHER_ADMIN_CONSOLE', 1); $page_title = array(feather_escape($this->config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['Forums']); define('FEATHER_ACTIVE_PAGE', 'admin'); $this->header->setTitle($page_title)->display(); generate_admin_menu('forums'); $this->feather->render('admin/forums/permissions.php', array('lang_admin_forums' => $lang_admin_forums, 'lang_admin_common' => $lang_admin_common, 'feather_config' => $this->config, 'perm_data' => $this->model->get_permissions($forum_id), 'cur_index' => 7, 'cur_forum' => $this->model->get_forum_info($forum_id), 'forum_data' => $this->model->get_forums())); $this->footer->display(); } }
public function update_profile($id, $info, $section) { global $lang_common, $lang_profile, $lang_prof_reg, $pd; $username_updated = false; // Validate input depending on section switch ($section) { case 'essentials': $form = array('timezone' => floatval($this->request->post('form_timezone')), 'dst' => $this->request->post('form_dst') ? '1' : '0', 'time_format' => intval($this->request->post('form_time_format')), 'date_format' => intval($this->request->post('form_date_format'))); // Make sure we got a valid language string if ($this->request->post('form_language')) { $languages = forum_list_langs(); $form['language'] = feather_trim($this->request->post('form_language')); if (!in_array($form['language'], $languages)) { message($lang_common['Bad request'], '404'); } } if ($this->user->is_admmod) { $form['admin_note'] = feather_trim($this->request->post('admin_note')); // Are we allowed to change usernames? if ($this->user->g_id == FEATHER_ADMIN || $this->user->g_moderator == '1' && $this->user->g_mod_rename_users == '1') { $form['username'] = feather_trim($this->request->post('req_username')); if ($form['username'] != $info['old_username']) { // Check username require FEATHER_ROOT . 'lang/' . $this->user->language . '/register.php'; $errors = ''; $errors = check_username($form['username'], $errors, $id); if (!empty($errors)) { message($errors[0]); } $username_updated = true; } } // We only allow administrators to update the post count if ($this->user->g_id == FEATHER_ADMIN) { $form['num_posts'] = intval($this->request->post('num_posts')); } } if ($this->config['o_regs_verify'] == '0' || $this->user->is_admmod) { require FEATHER_ROOT . 'include/email.php'; // Validate the email address $form['email'] = strtolower(feather_trim($this->request->post('req_email'))); if (!is_valid_email($form['email'])) { message($lang_common['Invalid email']); } } break; case 'personal': $form = array('realname' => $this->request->post('form_realname') ? feather_trim($this->request->post('form_realname')) : '', 'url' => $this->request->post('form_url') ? feather_trim($this->request->post('form_url')) : '', 'location' => $this->request->post('form_location') ? feather_trim($this->request->post('form_location')) : ''); // Add http:// if the URL doesn't contain it already (while allowing https://, too) if ($this->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 ($this->user->g_id == FEATHER_ADMIN) { $form['title'] = feather_trim($this->request->post('title')); } elseif ($this->user->g_set_title == '1') { $form['title'] = feather_trim($this->request->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' => feather_trim($this->request->post('form_jabber')), 'icq' => feather_trim($this->request->post('form_icq')), 'msn' => feather_trim($this->request->post('form_msn')), 'aim' => feather_trim($this->request->post('form_aim')), 'yahoo' => feather_trim($this->request->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 ($this->config['o_signatures'] == '1') { $form['signature'] = feather_linebreaks(feather_trim($this->request->post('signature'))); // Validate signature if (feather_strlen($form['signature']) > $this->config['p_sig_length']) { message(sprintf($lang_prof_reg['Sig too long'], $this->config['p_sig_length'], feather_strlen($form['signature']) - $this->config['p_sig_length'])); } elseif (substr_count($form['signature'], "\n") > $this->config['p_sig_lines'] - 1) { message(sprintf($lang_prof_reg['Sig too many lines'], $this->config['p_sig_lines'])); } elseif ($form['signature'] && $this->config['p_sig_all_caps'] == '0' && is_all_uppercase($form['signature']) && !$this->user->is_admmod) { $form['signature'] = utf8_ucwords(utf8_strtolower($form['signature'])); } // Validate BBCode syntax if ($this->config['p_sig_bbcode'] == '1') { require FEATHER_ROOT . 'include/parser.php'; $errors = array(); $form['signature'] = preparse_bbcode($form['signature'], $errors, true); if (count($errors) > 0) { message('<ul><li>' . implode('</li><li>', $errors) . '</li></ul>'); } } } break; case 'display': $form = array('disp_topics' => feather_trim($this->request->post('form_disp_topics')), 'disp_posts' => feather_trim($this->request->post('form_disp_posts')), 'show_smilies' => $this->request->post('form_show_smilies') ? '1' : '0', 'show_img' => $this->request->post('form_show_img') ? '1' : '0', 'show_img_sig' => $this->request->post('form_show_img_sig') ? '1' : '0', 'show_avatars' => $this->request->post('form_show_avatars') ? '1' : '0', 'show_sig' => $this->request->post('form_show_sig') ? '1' : '0'); if ($form['disp_topics'] != '') { $form['disp_topics'] = intval($form['disp_topics']); if ($form['disp_topics'] < 3) { $form['disp_topics'] = 3; } elseif ($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; } elseif ($form['disp_posts'] > 75) { $form['disp_posts'] = 75; } } // Make sure we got a valid style string if ($this->request->post('form_style')) { $styles = forum_list_styles(); $form['style'] = feather_trim($this->request->post('form_style')); if (!in_array($form['style'], $styles)) { message($lang_common['Bad request'], '404'); } } break; case 'privacy': $form = array('email_setting' => intval($this->request->post('form_email_setting')), 'notify_with_post' => $this->request->post('form_notify_with_post') ? '1' : '0', 'auto_notify' => $this->request->post('form_auto_notify') ? '1' : '0'); if ($form['email_setting'] < 0 || $form['email_setting'] > 2) { $form['email_setting'] = $this->config['o_default_email_setting']; } break; default: message($lang_common['Bad request'], '404'); } // Single quotes around non-empty values and nothing for empty values $temp = array(); foreach ($form as $key => $input) { $temp[$key] = $input; } if (empty($temp)) { message($lang_common['Bad request'], '404'); } DB::for_table('users')->where('id', $id)->find_one()->set($temp)->save(); // If we changed the username we have to update some stuff if ($username_updated) { $bans_updated = DB::for_table('bans')->where('username', $info['old_username'])->update_many('username', $form['username']); DB::for_table('posts')->where('poster_id', $id)->update_many('poster', $form['username']); DB::for_table('posts')->where('edited_by', $info['old_username'])->update_many('edited_by', $form['username']); DB::for_table('topics')->where('poster', $info['old_username'])->update_many('poster', $form['username']); DB::for_table('topics')->where('last_poster', $info['old_username'])->update_many('last_poster', $form['username']); DB::for_table('forums')->where('last_poster', $info['old_username'])->update_many('last_poster', $form['username']); DB::for_table('online')->where('ident', $info['old_username'])->update_many('ident', $form['username']); // If the user is a moderator or an administrator we have to update the moderator lists $group_id = DB::for_table('users')->where('id', $id)->find_one_col('group_id'); $group_mod = DB::for_table('groups')->where('g_id', $group_id)->find_one_col('g_moderator'); if ($group_id == FEATHER_ADMIN || $group_mod == '1') { $select_mods = array('id', 'moderators'); $result = DB::for_table('forums')->select_many($select_mods)->find_many(); foreach ($result as $cur_forum) { $cur_moderators = $cur_forum['moderators'] != '' ? unserialize($cur_forum['moderators']) : array(); if (in_array($id, $cur_moderators)) { unset($cur_moderators[$info['old_username']]); $cur_moderators[$form['username']] = $id; uksort($cur_moderators, 'utf8_strcasecmp'); DB::for_table('forums')->where('id', $cur_forum['id'])->find_one()->set('moderators', serialize($cur_moderators))->save(); } } } // Regenerate the users info cache if (!defined('FORUM_CACHE_FUNCTIONS_LOADED')) { require FEATHER_ROOT . 'include/cache.php'; } generate_users_info_cache(); // Check if the bans table was updated and regenerate the bans cache when needed if ($bans_updated) { generate_bans_cache(); } } redirect(get_link('user/' . $id . '/section/' . $section . '/'), $lang_profile['Profile redirect']); }