Chris@76: 'ModifyPostSettings',
Chris@76: 'bbc' => 'ModifyBBCSettings',
Chris@76: 'censor' => 'SetCensor',
Chris@76: 'topics' => 'ModifyTopicSettings',
Chris@76: );
Chris@76:
Chris@76: // Default the sub-action to 'posts'.
Chris@76: $_REQUEST['sa'] = isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]) ? $_REQUEST['sa'] : 'posts';
Chris@76:
Chris@76: $context['page_title'] = $txt['manageposts_title'];
Chris@76:
Chris@76: // Tabs for browsing the different ban functions.
Chris@76: $context[$context['admin_menu_name']]['tab_data'] = array(
Chris@76: 'title' => $txt['manageposts_title'],
Chris@76: 'help' => 'posts_and_topics',
Chris@76: 'description' => $txt['manageposts_description'],
Chris@76: 'tabs' => array(
Chris@76: 'posts' => array(
Chris@76: 'description' => $txt['manageposts_settings_description'],
Chris@76: ),
Chris@76: 'bbc' => array(
Chris@76: 'description' => $txt['manageposts_bbc_settings_description'],
Chris@76: ),
Chris@76: 'censor' => array(
Chris@76: 'description' => $txt['admin_censored_desc'],
Chris@76: ),
Chris@76: 'topics' => array(
Chris@76: 'description' => $txt['manageposts_topic_settings_description'],
Chris@76: ),
Chris@76: ),
Chris@76: );
Chris@76:
Chris@76: // Call the right function for this sub-action.
Chris@76: $subActions[$_REQUEST['sa']]();
Chris@76: }
Chris@76:
Chris@76: // Set the censored words.
Chris@76: function SetCensor()
Chris@76: {
Chris@76: global $txt, $modSettings, $context, $smcFunc;
Chris@76:
Chris@76: if (!empty($_POST['save_censor']))
Chris@76: {
Chris@76: // Make sure censoring is something they can do.
Chris@76: checkSession();
Chris@76:
Chris@76: $censored_vulgar = array();
Chris@76: $censored_proper = array();
Chris@76:
Chris@76: // Rip it apart, then split it into two arrays.
Chris@76: if (isset($_POST['censortext']))
Chris@76: {
Chris@76: $_POST['censortext'] = explode("\n", strtr($_POST['censortext'], array("\r" => '')));
Chris@76:
Chris@76: foreach ($_POST['censortext'] as $c)
Chris@76: list ($censored_vulgar[], $censored_proper[]) = array_pad(explode('=', trim($c)), 2, '');
Chris@76: }
Chris@76: elseif (isset($_POST['censor_vulgar'], $_POST['censor_proper']))
Chris@76: {
Chris@76: if (is_array($_POST['censor_vulgar']))
Chris@76: {
Chris@76: foreach ($_POST['censor_vulgar'] as $i => $value)
Chris@76: {
Chris@76: if (trim(strtr($value, '*', ' ')) == '')
Chris@76: unset($_POST['censor_vulgar'][$i], $_POST['censor_proper'][$i]);
Chris@76: }
Chris@76:
Chris@76: $censored_vulgar = $_POST['censor_vulgar'];
Chris@76: $censored_proper = $_POST['censor_proper'];
Chris@76: }
Chris@76: else
Chris@76: {
Chris@76: $censored_vulgar = explode("\n", strtr($_POST['censor_vulgar'], array("\r" => '')));
Chris@76: $censored_proper = explode("\n", strtr($_POST['censor_proper'], array("\r" => '')));
Chris@76: }
Chris@76: }
Chris@76:
Chris@76: // Set the new arrays and settings in the database.
Chris@76: $updates = array(
Chris@76: 'censor_vulgar' => implode("\n", $censored_vulgar),
Chris@76: 'censor_proper' => implode("\n", $censored_proper),
Chris@76: 'censorWholeWord' => empty($_POST['censorWholeWord']) ? '0' : '1',
Chris@76: 'censorIgnoreCase' => empty($_POST['censorIgnoreCase']) ? '0' : '1',
Chris@76: );
Chris@76:
Chris@76: updateSettings($updates);
Chris@76: }
Chris@76:
Chris@76: if (isset($_POST['censortest']))
Chris@76: {
Chris@76: $censorText = htmlspecialchars($_POST['censortest'], ENT_QUOTES);
Chris@76: $context['censor_test'] = strtr(censorText($censorText), array('"' => '"'));
Chris@76: }
Chris@76:
Chris@76: // Set everything up for the template to do its thang.
Chris@76: $censor_vulgar = explode("\n", $modSettings['censor_vulgar']);
Chris@76: $censor_proper = explode("\n", $modSettings['censor_proper']);
Chris@76:
Chris@76: $context['censored_words'] = array();
Chris@76: for ($i = 0, $n = count($censor_vulgar); $i < $n; $i++)
Chris@76: {
Chris@76: if (empty($censor_vulgar[$i]))
Chris@76: continue;
Chris@76:
Chris@76: // Skip it, it's either spaces or stars only.
Chris@76: if (trim(strtr($censor_vulgar[$i], '*', ' ')) == '')
Chris@76: continue;
Chris@76:
Chris@76: $context['censored_words'][htmlspecialchars(trim($censor_vulgar[$i]))] = isset($censor_proper[$i]) ? htmlspecialchars($censor_proper[$i]) : '';
Chris@76: }
Chris@76:
Chris@76: $context['sub_template'] = 'edit_censored';
Chris@76: $context['page_title'] = $txt['admin_censored_words'];
Chris@76: }
Chris@76:
Chris@76: // Modify all settings related to posts and posting.
Chris@76: function ModifyPostSettings($return_config = false)
Chris@76: {
Chris@76: global $context, $txt, $modSettings, $scripturl, $sourcedir, $smcFunc, $db_prefix;
Chris@76:
Chris@76: // All the settings...
Chris@76: $config_vars = array(
Chris@76: // Simple post options...
Chris@76: array('check', 'removeNestedQuotes'),
Chris@76: array('check', 'enableEmbeddedFlash', 'subtext' => $txt['enableEmbeddedFlash_warning']),
Chris@76: // Note show the warning as read if pspell not installed!
Chris@76: array('check', 'enableSpellChecking', 'subtext' => (function_exists('pspell_new') ? $txt['enableSpellChecking_warning'] : ('' . $txt['enableSpellChecking_warning'] . ''))),
Chris@76: array('check', 'disable_wysiwyg'),
Chris@76: '',
Chris@76: // Posting limits...
Chris@76: array('int', 'max_messageLength', 'subtext' => $txt['max_messageLength_zero'], 'postinput' => $txt['manageposts_characters']),
Chris@76: array('int', 'fixLongWords', 'subtext' => $txt['fixLongWords_zero'] . ($context['utf8'] ? ' ' . $txt['fixLongWords_warning'] . '' : ''), 'postinput' => $txt['manageposts_characters']),
Chris@76: array('int', 'topicSummaryPosts', 'postinput' => $txt['manageposts_posts']),
Chris@76: '',
Chris@76: // Posting time limits...
Chris@76: array('int', 'spamWaitTime', 'postinput' => $txt['manageposts_seconds']),
Chris@76: array('int', 'edit_wait_time', 'postinput' => $txt['manageposts_seconds']),
Chris@76: array('int', 'edit_disable_time', 'subtext' => $txt['edit_disable_time_zero'], 'postinput' => $txt['manageposts_minutes']),
Chris@76: );
Chris@76:
Chris@76: if ($return_config)
Chris@76: return $config_vars;
Chris@76:
Chris@76: // We'll want this for our easy save.
Chris@76: require_once($sourcedir . '/ManageServer.php');
Chris@76:
Chris@76: // Setup the template.
Chris@76: $context['page_title'] = $txt['manageposts_settings'];
Chris@76: $context['sub_template'] = 'show_settings';
Chris@76:
Chris@76: // Are we saving them - are we??
Chris@76: if (isset($_GET['save']))
Chris@76: {
Chris@76: checkSession();
Chris@76:
Chris@76: // If we're changing the message length let's check the column is big enough.
Chris@76: if (!empty($_POST['max_messageLength']) && $_POST['max_messageLength'] != $modSettings['max_messageLength'])
Chris@76: {
Chris@76: db_extend('packages');
Chris@76:
Chris@76: $colData = $smcFunc['db_list_columns']('{db_prefix}messages', true);
Chris@76: foreach ($colData as $column)
Chris@76: if ($column['name'] == 'body')
Chris@76: $body_type = $column['type'];
Chris@76:
Chris@76: $indData = $smcFunc['db_list_indexes']('{db_prefix}messages', true);
Chris@76: foreach ($indData as $index)
Chris@76: foreach ($index['columns'] as $column)
Chris@76: if ($column == 'body' && $index['type'] == 'fulltext')
Chris@76: $fulltext = true;
Chris@76:
Chris@76: if (isset($body_type) && $_POST['max_messageLength'] > 65535 && $body_type == 'text')
Chris@76: {
Chris@76: // !!! Show an error message?!
Chris@76: // MySQL only likes fulltext indexes on text columns... for now?
Chris@76: if (!empty($fulltext))
Chris@76: $_POST['max_messageLength'] = 65535;
Chris@76: else
Chris@76: {
Chris@76: // Make it longer so we can do their limit.
Chris@76: $smcFunc['db_change_column']('{db_prefix}messages', 'body', array('type' => 'mediumtext'));
Chris@76: }
Chris@76: }
Chris@76: elseif (isset($body_type) && $_POST['max_messageLength'] <= 65535 && $body_type != 'text')
Chris@76: {
Chris@76: // Shorten the column so we can have the benefit of fulltext searching again!
Chris@76: $smcFunc['db_change_column']('{db_prefix}messages', 'body', array('type' => 'text'));
Chris@76: }
Chris@76: }
Chris@76:
Chris@76: saveDBSettings($config_vars);
Chris@76: redirectexit('action=admin;area=postsettings;sa=posts');
Chris@76: }
Chris@76:
Chris@76: // Final settings...
Chris@76: $context['post_url'] = $scripturl . '?action=admin;area=postsettings;save;sa=posts';
Chris@76: $context['settings_title'] = $txt['manageposts_settings'];
Chris@76:
Chris@76: // Prepare the settings...
Chris@76: prepareDBSettingContext($config_vars);
Chris@76: }
Chris@76:
Chris@76: // Bulletin Board Code...a lot of Bulletin Board Code.
Chris@76: function ModifyBBCSettings($return_config = false)
Chris@76: {
Chris@76: global $context, $txt, $modSettings, $helptxt, $scripturl, $sourcedir;
Chris@76:
Chris@76: $config_vars = array(
Chris@76: // Main tweaks
Chris@76: array('check', 'enableBBC'),
Chris@76: array('check', 'enablePostHTML'),
Chris@76: array('check', 'autoLinkUrls'),
Chris@76: '',
Chris@76: array('bbc', 'disabledBBC'),
Chris@76: );
Chris@76:
Chris@76: if ($return_config)
Chris@76: return $config_vars;
Chris@76:
Chris@76: // Setup the template.
Chris@76: require_once($sourcedir . '/ManageServer.php');
Chris@76: $context['sub_template'] = 'show_settings';
Chris@76: $context['page_title'] = $txt['manageposts_bbc_settings_title'];
Chris@76:
Chris@76: // Make sure we check the right tags!
Chris@76: $modSettings['bbc_disabled_disabledBBC'] = empty($modSettings['disabledBBC']) ? array() : explode(',', $modSettings['disabledBBC']);
Chris@76:
Chris@76: // Saving?
Chris@76: if (isset($_GET['save']))
Chris@76: {
Chris@76: checkSession();
Chris@76:
Chris@76: // Clean up the tags.
Chris@76: $bbcTags = array();
Chris@76: foreach (parse_bbc(false) as $tag)
Chris@76: $bbcTags[] = $tag['tag'];
Chris@76:
Chris@76: if (!isset($_POST['disabledBBC_enabledTags']))
Chris@76: $_POST['disabledBBC_enabledTags'] = array();
Chris@76: elseif (!is_array($_POST['disabledBBC_enabledTags']))
Chris@76: $_POST['disabledBBC_enabledTags'] = array($_POST['disabledBBC_enabledTags']);
Chris@76: // Work out what is actually disabled!
Chris@76: $_POST['disabledBBC'] = implode(',', array_diff($bbcTags, $_POST['disabledBBC_enabledTags']));
Chris@76:
Chris@76: saveDBSettings($config_vars);
Chris@76: redirectexit('action=admin;area=postsettings;sa=bbc');
Chris@76: }
Chris@76:
Chris@76: $context['post_url'] = $scripturl . '?action=admin;area=postsettings;save;sa=bbc';
Chris@76: $context['settings_title'] = $txt['manageposts_bbc_settings_title'];
Chris@76:
Chris@76: prepareDBSettingContext($config_vars);
Chris@76: }
Chris@76:
Chris@76: // Function for modifying topic settings. Not very exciting.
Chris@76: function ModifyTopicSettings($return_config = false)
Chris@76: {
Chris@76: global $context, $txt, $modSettings, $sourcedir, $scripturl;
Chris@76:
Chris@76: // Here are all the topic settings.
Chris@76: $config_vars = array(
Chris@76: // Some simple bools...
Chris@76: array('check', 'enableStickyTopics'),
Chris@76: array('check', 'enableParticipation'),
Chris@76: '',
Chris@76: // Pagination etc...
Chris@76: array('int', 'oldTopicDays', 'postinput' => $txt['manageposts_days'], 'subtext' => $txt['oldTopicDays_zero']),
Chris@76: array('int', 'defaultMaxTopics', 'postinput' => $txt['manageposts_topics']),
Chris@76: array('int', 'defaultMaxMessages', 'postinput' => $txt['manageposts_posts']),
Chris@76: '',
Chris@76: // Hot topics (etc)...
Chris@76: array('int', 'hotTopicPosts', 'postinput' => $txt['manageposts_posts']),
Chris@76: array('int', 'hotTopicVeryPosts', 'postinput' => $txt['manageposts_posts']),
Chris@76: '',
Chris@76: // All, next/prev...
Chris@76: array('int', 'enableAllMessages', 'postinput' => $txt['manageposts_posts'], 'subtext' => $txt['enableAllMessages_zero']),
Chris@76: array('check', 'disableCustomPerPage'),
Chris@76: array('check', 'enablePreviousNext'),
Chris@76:
Chris@76: );
Chris@76:
Chris@76: if ($return_config)
Chris@76: return $config_vars;
Chris@76:
Chris@76: // Get the settings template ready.
Chris@76: require_once($sourcedir . '/ManageServer.php');
Chris@76:
Chris@76: // Setup the template.
Chris@76: $context['page_title'] = $txt['manageposts_topic_settings'];
Chris@76: $context['sub_template'] = 'show_settings';
Chris@76:
Chris@76: // Are we saving them - are we??
Chris@76: if (isset($_GET['save']))
Chris@76: {
Chris@76: checkSession();
Chris@76:
Chris@76: saveDBSettings($config_vars);
Chris@76: redirectexit('action=admin;area=postsettings;sa=topics');
Chris@76: }
Chris@76:
Chris@76: // Final settings...
Chris@76: $context['post_url'] = $scripturl . '?action=admin;area=postsettings;save;sa=topics';
Chris@76: $context['settings_title'] = $txt['manageposts_topic_settings'];
Chris@76:
Chris@76: // Prepare the settings...
Chris@76: prepareDBSettingContext($config_vars);
Chris@76: }
Chris@76:
Chris@76: ?>