pun_trim($_POST['form']['board_title']), 'board_desc' => pun_trim($_POST['form']['board_desc']), 'base_url' => pun_trim($_POST['form']['base_url']), 'default_timezone' => floatval($_POST['form']['default_timezone']), 'default_dst' => $_POST['form']['default_dst'] != '1' ? '0' : '1', 'default_lang' => pun_trim($_POST['form']['default_lang']), 'default_style' => pun_trim($_POST['form']['default_style']), 'time_format' => pun_trim($_POST['form']['time_format']), 'date_format' => pun_trim($_POST['form']['date_format']), 'timeout_visit' => (intval($_POST['form']['timeout_visit']) > 0) ? intval($_POST['form']['timeout_visit']) : 1, 'timeout_online' => (intval($_POST['form']['timeout_online']) > 0) ? intval($_POST['form']['timeout_online']) : 1, 'redirect_delay' => (intval($_POST['form']['redirect_delay']) >= 0) ? intval($_POST['form']['redirect_delay']) : 0, 'show_version' => $_POST['form']['show_version'] != '1' ? '0' : '1', 'show_user_info' => $_POST['form']['show_user_info'] != '1' ? '0' : '1', 'show_post_count' => $_POST['form']['show_post_count'] != '1' ? '0' : '1', 'smilies' => $_POST['form']['smilies'] != '1' ? '0' : '1', 'smilies_sig' => $_POST['form']['smilies_sig'] != '1' ? '0' : '1', 'make_links' => $_POST['form']['make_links'] != '1' ? '0' : '1', 'topic_review' => (intval($_POST['form']['topic_review']) >= 0) ? intval($_POST['form']['topic_review']) : 0, 'disp_topics_default' => intval($_POST['form']['disp_topics_default']), 'disp_posts_default' => intval($_POST['form']['disp_posts_default']), 'indent_num_spaces' => (intval($_POST['form']['indent_num_spaces']) >= 0) ? intval($_POST['form']['indent_num_spaces']) : 0, 'quote_depth' => (intval($_POST['form']['quote_depth']) > 0) ? intval($_POST['form']['quote_depth']) : 1, 'quickpost' => $_POST['form']['quickpost'] != '1' ? '0' : '1', 'users_online' => $_POST['form']['users_online'] != '1' ? '0' : '1', 'censoring' => $_POST['form']['censoring'] != '1' ? '0' : '1', 'signatures' => $_POST['form']['signatures'] != '1' ? '0' : '1', 'show_dot' => $_POST['form']['show_dot'] != '1' ? '0' : '1', 'topic_views' => $_POST['form']['topic_views'] != '1' ? '0' : '1', 'quickjump' => $_POST['form']['quickjump'] != '1' ? '0' : '1', 'gzip' => $_POST['form']['gzip'] != '1' ? '0' : '1', 'search_all_forums' => $_POST['form']['search_all_forums'] != '1' ? '0' : '1', 'additional_navlinks' => pun_trim($_POST['form']['additional_navlinks']), 'feed_type' => intval($_POST['form']['feed_type']), 'feed_ttl' => intval($_POST['form']['feed_ttl']), 'report_method' => intval($_POST['form']['report_method']), 'mailing_list' => pun_trim($_POST['form']['mailing_list']), 'avatars' => $_POST['form']['avatars'] != '1' ? '0' : '1', 'avatars_dir' => pun_trim($_POST['form']['avatars_dir']), 'avatars_width' => (intval($_POST['form']['avatars_width']) > 0) ? intval($_POST['form']['avatars_width']) : 1, 'avatars_height' => (intval($_POST['form']['avatars_height']) > 0) ? intval($_POST['form']['avatars_height']) : 1, 'avatars_size' => (intval($_POST['form']['avatars_size']) > 0) ? intval($_POST['form']['avatars_size']) : 1, 'admin_email' => strtolower(pun_trim($_POST['form']['admin_email'])), 'webmaster_email' => strtolower(pun_trim($_POST['form']['webmaster_email'])), 'forum_subscriptions' => $_POST['form']['forum_subscriptions'] != '1' ? '0' : '1', 'topic_subscriptions' => $_POST['form']['topic_subscriptions'] != '1' ? '0' : '1', 'smtp_host' => pun_trim($_POST['form']['smtp_host']), 'smtp_user' => pun_trim($_POST['form']['smtp_user']), 'smtp_ssl' => $_POST['form']['smtp_ssl'] != '1' ? '0' : '1', 'regs_allow' => $_POST['form']['regs_allow'] != '1' ? '0' : '1', 'regs_verify' => $_POST['form']['regs_verify'] != '1' ? '0' : '1', 'regs_report' => $_POST['form']['regs_report'] != '1' ? '0' : '1', 'rules' => $_POST['form']['rules'] != '1' ? '0' : '1', 'rules_message' => pun_trim($_POST['form']['rules_message']), 'default_email_setting' => intval($_POST['form']['default_email_setting']), 'announcement' => $_POST['form']['announcement'] != '1' ? '0' : '1', 'announcement_message' => pun_trim($_POST['form']['announcement_message']), 'maintenance' => $_POST['form']['maintenance'] != '1' ? '0' : '1', 'maintenance_message' => pun_trim($_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'], false, '404 Not Found'); $styles = forum_list_styles(); if (!in_array($form['default_style'], $styles)) message($lang_common['Bad request'], false, '404 Not Found'); if ($form['time_format'] == '') $form['time_format'] = 'H:i:s'; if ($form['date_format'] == '') $form['date_format'] = 'Y-m-d'; require PUN_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'] = pun_trim(pun_linebreaks($form['additional_navlinks'])); // Change or enter a SMTP password if (isset($_POST['form']['smtp_change_pass'])) { $smtp_pass1 = isset($_POST['form']['smtp_pass1']) ? pun_trim($_POST['form']['smtp_pass1']) : ''; $smtp_pass2 = isset($_POST['form']['smtp_pass2']) ? pun_trim($_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'] = pun_linebreaks($form['announcement_message']); else { $form['announcement_message'] = $lang_admin_options['Enter announcement here']; $form['announcement'] = '0'; } if ($form['rules_message'] != '') $form['rules_message'] = pun_linebreaks($form['rules_message']); else { $form['rules_message'] = $lang_admin_options['Enter rules here']; $form['rules'] = '0'; } if ($form['maintenance_message'] != '') $form['maintenance_message'] = pun_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; else if ($form['disp_topics_default'] > 75) $form['disp_topics_default'] = 75; if ($form['disp_posts_default'] < 3) $form['disp_posts_default'] = 3; else if ($form['disp_posts_default'] > 75) $form['disp_posts_default'] = 75; if ($form['feed_type'] < 0 || $form['feed_type'] > 2) message($lang_common['Bad request'], false, '404 Not Found'); if ($form['feed_ttl'] < 0) message($lang_common['Bad request'], false, '404 Not Found'); if ($form['report_method'] < 0 || $form['report_method'] > 2) message($lang_common['Bad request'], false, '404 Not Found'); if ($form['default_email_setting'] < 0 || $form['default_email_setting'] > 2) message($lang_common['Bad request'], false, '404 Not Found'); 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, $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 if (!defined('FORUM_CACHE_FUNCTIONS_LOADED')) require PUN_ROOT.'include/cache.php'; generate_config_cache(); clear_feed_cache(); redirect('admin_options.php', $lang_admin_options['Options updated redirect']); } $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['Options']); define('PUN_ACTIVE_PAGE', 'admin'); require PUN_ROOT.'header.php'; generate_admin_menu('options'); ?>