PUN_ADMIN) message($lang_common['No permission']); if (isset($_POST['form_sent'])) { // Custom referrer check (so we can output a custom error message) if (!preg_match('#^'.preg_quote(str_replace('www.', '', $pun_config['o_base_url']).'/admin_options.php', '#').'#i', str_replace('www.', '', (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '')))) message('Bad HTTP_REFERER. If you have moved these forums from one location to another or switched domains, you need to update the Base URL manually in the database (look for o_base_url in the config table) and then clear the cache by deleting all .php files in the /cache directory.'); $form = array_map('trim', $_POST['form']); if ($form['board_title'] == '') message('You must enter a board title.'); // Clean default_lang $form['default_lang'] = preg_replace('#[\.\\\/]#', '', $form['default_lang']); require PUN_ROOT.'include/email.php'; $form['admin_email'] = strtolower($form['admin_email']); if (!is_valid_email($form['admin_email'])) message('The admin e-mail address you entered is invalid.'); $form['webmaster_email'] = strtolower($form['webmaster_email']); if (!is_valid_email($form['webmaster_email'])) message('The webmaster e-mail address you entered is invalid.'); if ($form['mailing_list'] != '') $form['mailing_list'] = strtolower(preg_replace('/[\s]/', '', $form['mailing_list'])); // 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); // Clean avatars_dir $form['avatars_dir'] = str_replace("\0", '', $form['avatars_dir']); // 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'] = trim(pun_linebreaks($form['additional_navlinks'])); if ($form['announcement_message'] != '') $form['announcement_message'] = pun_linebreaks($form['announcement_message']); else { $form['announcement_message'] = 'Enter your announcement here.'; if ($form['announcement'] == '1') $form['announcement'] = '0'; } if ($form['rules_message'] != '') $form['rules_message'] = pun_linebreaks($form['rules_message']); else { $form['rules_message'] = 'Enter your rules here.'; if ($form['rules'] == '1') $form['rules'] = '0'; } if ($form['maintenance_message'] != '') $form['maintenance_message'] = pun_linebreaks($form['maintenance_message']); else { $form['maintenance_message'] = 'The forums are temporarily down for maintenance. Please try again in a few minutes.\n\n/Administrator'; if ($form['maintenance'] == '1') $form['maintenance'] = '0'; } $form['timeout_visit'] = intval($form['timeout_visit']); $form['timeout_online'] = intval($form['timeout_online']); $form['redirect_delay'] = intval($form['redirect_delay']); $form['topic_review'] = intval($form['topic_review']); $form['disp_topics_default'] = intval($form['disp_topics_default']); $form['disp_posts_default'] = intval($form['disp_posts_default']); $form['indent_num_spaces'] = intval($form['indent_num_spaces']); $form['avatars_width'] = intval($form['avatars_width']); $form['avatars_height'] = intval($form['avatars_height']); $form['avatars_size'] = intval($form['avatars_size']); if ($form['timeout_online'] >= $form['timeout_visit']) message('The value of "Timeout online" must be smaller than the value of "Timeout visit".'); while (list($key, $input) = @each($form)) { // Only update values that have changed if (array_key_exists('o_'.$key, $pun_config) && $pun_config['o_'.$key] != $input) { if ($input != '' || is_int($input)) $value = '\''.$db->escape($input).'\''; else $value = 'NULL'; $db->query('UPDATE '.$db->prefix.'config SET conf_value='.$value.' WHERE conf_name=\'o_'.$db->escape($key).'\'') or error('Unable to update board config', __FILE__, __LINE__, $db->error()); } } // Regenerate the config cache require_once PUN_ROOT.'include/cache.php'; generate_config_cache(); redirect('admin_options.php', 'Options updated. Redirecting …'); } $page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / Admin / Options'; $form_name = 'update_options'; require PUN_ROOT.'header.php'; generate_admin_menu('options'); ?>