123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483 |
- <?php
- if (!defined('SMF'))
- die('No direct access...');
- function ManagePostSettings()
- {
- global $context, $txt, $scripturl;
-
- isAllowedTo('admin_forum');
- loadLanguage('Drafts');
- $subActions = array(
- 'posts' => 'ModifyPostSettings',
- 'bbc' => 'ModifyBBCSettings',
- 'censor' => 'SetCensor',
- 'topics' => 'ModifyTopicSettings',
- 'drafts' => 'ModifyDraftSettings',
- );
- call_integration_hook('integrate_manage_posts', array(&$subActions));
-
- $_REQUEST['sa'] = isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]) ? $_REQUEST['sa'] : 'posts';
- $context['page_title'] = $txt['manageposts_title'];
-
- $context[$context['admin_menu_name']]['tab_data'] = array(
- 'title' => $txt['manageposts_title'],
- 'help' => 'posts_and_topics',
- 'description' => $txt['manageposts_description'],
- 'tabs' => array(
- 'posts' => array(
- 'description' => $txt['manageposts_settings_description'],
- ),
- 'bbc' => array(
- 'description' => $txt['manageposts_bbc_settings_description'],
- ),
- 'censor' => array(
- 'description' => $txt['admin_censored_desc'],
- ),
- 'topics' => array(
- 'description' => $txt['manageposts_topic_settings_description'],
- ),
- 'drafts' => array(
- 'description' => $txt['drafts_show_desc'],
- ),
- ),
- );
-
- $subActions[$_REQUEST['sa']]();
- }
- function SetCensor()
- {
- global $txt, $modSettings, $context, $smcFunc, $sourcedir;
- if (!empty($_POST['save_censor']))
- {
-
- checkSession();
- validateToken('admin-censor');
- $censored_vulgar = array();
- $censored_proper = array();
-
- if (isset($_POST['censortext']))
- {
- $_POST['censortext'] = explode("\n", strtr($_POST['censortext'], array("\r" => '')));
- foreach ($_POST['censortext'] as $c)
- list ($censored_vulgar[], $censored_proper[]) = array_pad(explode('=', trim($c)), 2, '');
- }
- elseif (isset($_POST['censor_vulgar'], $_POST['censor_proper']))
- {
- if (is_array($_POST['censor_vulgar']))
- {
- foreach ($_POST['censor_vulgar'] as $i => $value)
- {
- if (trim(strtr($value, '*', ' ')) == '')
- unset($_POST['censor_vulgar'][$i], $_POST['censor_proper'][$i]);
- }
- $censored_vulgar = $_POST['censor_vulgar'];
- $censored_proper = $_POST['censor_proper'];
- }
- else
- {
- $censored_vulgar = explode("\n", strtr($_POST['censor_vulgar'], array("\r" => '')));
- $censored_proper = explode("\n", strtr($_POST['censor_proper'], array("\r" => '')));
- }
- }
-
- $updates = array(
- 'censor_vulgar' => implode("\n", $censored_vulgar),
- 'censor_proper' => implode("\n", $censored_proper),
- 'allow_no_censored' => empty($_POST['allow_no_censored']) ? '0' : '1',
- 'censorWholeWord' => empty($_POST['censorWholeWord']) ? '0' : '1',
- 'censorIgnoreCase' => empty($_POST['censorIgnoreCase']) ? '0' : '1',
- );
- call_integration_hook('integrate_save_censors', array(&$updates));
- $context['saved_successful'] = true;
- updateSettings($updates);
- }
- if (isset($_POST['censortest']))
- {
- require_once($sourcedir . '/Subs-Post.php');
- $censorText = $smcFunc['htmlspecialchars']($_POST['censortest'], ENT_QUOTES);
- preparsecode($censorText);
- $context['censor_test'] = strtr(censorText($censorText), array('"' => '"'));
- }
-
- $censor_vulgar = explode("\n", $modSettings['censor_vulgar']);
- $censor_proper = explode("\n", $modSettings['censor_proper']);
- $context['censored_words'] = array();
- for ($i = 0, $n = count($censor_vulgar); $i < $n; $i++)
- {
- if (empty($censor_vulgar[$i]))
- continue;
-
- if (trim(strtr($censor_vulgar[$i], '*', ' ')) == '')
- continue;
- $context['censored_words'][$smcFunc['htmlspecialchars'](trim($censor_vulgar[$i]))] = isset($censor_proper[$i]) ? $smcFunc['htmlspecialchars']($censor_proper[$i]) : '';
- }
- call_integration_hook('integrate_censors');
-
- loadLanguage('Themes');
- $context['sub_template'] = 'edit_censored';
- $context['page_title'] = $txt['admin_censored_words'];
- createToken('admin-censor');
- }
- function ModifyPostSettings($return_config = false)
- {
- global $context, $txt, $modSettings, $scripturl, $sourcedir, $smcFunc, $db_type;
-
- $can_spell_check = false;
- if (function_exists('pspell_new'))
- $can_spell_check = true;
- elseif (function_exists('enchant_broker_init') && ($txt['lang_charset'] == 'UTF-8' || function_exists('iconv')))
- $can_spell_check = true;
-
- $config_vars = array(
-
- array('check', 'removeNestedQuotes'),
- array('check', 'enableEmbeddedFlash', 'subtext' => $txt['enableEmbeddedFlash_warning']),
-
- array('check', 'enableSpellChecking', 'subtext' => ($can_spell_check ? $txt['enableSpellChecking_warning'] : ('<span class="alert">' . $txt['enableSpellChecking_warning'] . '</span>'))),
- array('check', 'disable_wysiwyg'),
- '',
-
- array('int', 'max_messageLength', 'subtext' => $txt['max_messageLength_zero'], 'postinput' => $txt['manageposts_characters']),
- array('int', 'topicSummaryPosts', 'postinput' => $txt['manageposts_posts']),
- '',
-
- array('int', 'spamWaitTime', 'postinput' => $txt['manageposts_seconds']),
- array('int', 'edit_wait_time', 'postinput' => $txt['manageposts_seconds']),
- array('int', 'edit_disable_time', 'subtext' => $txt['edit_disable_time_zero'], 'postinput' => $txt['manageposts_minutes']),
- '',
-
- array('int', 'max_image_width', 'subtext' => $txt['zero_for_no_limit']),
- array('int', 'max_image_height', 'subtext' => $txt['zero_for_no_limit']),
- '',
-
- array('int', 'preview_characters', 'subtext' => $txt['preview_characters_zero'], 'postinput' => $txt['preview_characters_units']),
- );
- call_integration_hook('integrate_modify_post_settings', array(&$config_vars));
- if ($return_config)
- return $config_vars;
-
- require_once($sourcedir . '/ManageServer.php');
-
- $context['page_title'] = $txt['manageposts_settings'];
- $context['sub_template'] = 'show_settings';
-
- if (isset($_GET['save']))
- {
- checkSession();
-
- if (isset($_POST['max_messageLength']) && $_POST['max_messageLength'] != $modSettings['max_messageLength'] && ($db_type == 'mysql' || $db_type == 'mysqli'))
- {
- db_extend('packages');
- $colData = $smcFunc['db_list_columns']('{db_prefix}messages', true);
- foreach ($colData as $column)
- if ($column['name'] == 'body')
- $body_type = $column['type'];
- if (isset($body_type) && ($_POST['max_messageLength'] > 65535 || $_POST['max_messageLength'] == 0) && $body_type == 'text')
- fatal_lang_error('convert_to_mediumtext', false, array($scripturl . '?action=admin;area=maintain;sa=database'));
- }
-
- if (!empty($_POST['preview_characters']))
- $_POST['preview_characters'] = (int) min(max(0, $_POST['preview_characters']), 512);
- call_integration_hook('integrate_save_post_settings');
- saveDBSettings($config_vars);
- $_SESSION['adm-save'] = true;
- redirectexit('action=admin;area=postsettings;sa=posts');
- }
-
- $context['post_url'] = $scripturl . '?action=admin;area=postsettings;save;sa=posts';
- $context['settings_title'] = $txt['manageposts_settings'];
-
- prepareDBSettingContext($config_vars);
- }
- function ModifyBBCSettings($return_config = false)
- {
- global $context, $txt, $modSettings, $helptxt, $scripturl, $sourcedir;
- $config_vars = array(
-
- array('check', 'enableBBC'),
- array('check', 'enableBBC', 0, 'onchange' => 'toggleBBCDisabled(\'disabledBBC\', !this.checked);'),
- array('check', 'enablePostHTML'),
- array('check', 'autoLinkUrls'),
- '',
- array('bbc', 'disabledBBC'),
- );
- $context['settings_post_javascript'] = '
- toggleBBCDisabled(\'disabledBBC\', ' . (empty($modSettings['enableBBC']) ? 'true' : 'false') . ');';
- call_integration_hook('integrate_modify_bbc_settings', array(&$config_vars));
- if ($return_config)
- return $config_vars;
-
- require_once($sourcedir . '/ManageServer.php');
- $context['sub_template'] = 'show_settings';
- $context['page_title'] = $txt['manageposts_bbc_settings_title'];
-
- $modSettings['bbc_disabled_disabledBBC'] = empty($modSettings['disabledBBC']) ? array() : explode(',', $modSettings['disabledBBC']);
-
- if (isset($_GET['save']))
- {
- checkSession();
-
- $bbcTags = array();
- foreach (parse_bbc(false) as $tag)
- $bbcTags[] = $tag['tag'];
- if (!isset($_POST['disabledBBC_enabledTags']))
- $_POST['disabledBBC_enabledTags'] = array();
- elseif (!is_array($_POST['disabledBBC_enabledTags']))
- $_POST['disabledBBC_enabledTags'] = array($_POST['disabledBBC_enabledTags']);
-
- $_POST['disabledBBC'] = implode(',', array_diff($bbcTags, $_POST['disabledBBC_enabledTags']));
- call_integration_hook('integrate_save_bbc_settings', array($bbcTags));
- saveDBSettings($config_vars);
- $_SESSION['adm-save'] = true;
- redirectexit('action=admin;area=postsettings;sa=bbc');
- }
- $context['post_url'] = $scripturl . '?action=admin;area=postsettings;save;sa=bbc';
- $context['settings_title'] = $txt['manageposts_bbc_settings_title'];
- prepareDBSettingContext($config_vars);
- }
- function ModifyTopicSettings($return_config = false)
- {
- global $context, $txt, $sourcedir, $scripturl;
-
- $config_vars = array(
-
- array('check', 'enableParticipation'),
- '',
-
- array('int', 'oldTopicDays', 'postinput' => $txt['manageposts_days'], 'subtext' => $txt['oldTopicDays_zero']),
- array('int', 'defaultMaxTopics', 'postinput' => $txt['manageposts_topics']),
- array('int', 'defaultMaxMessages', 'postinput' => $txt['manageposts_posts']),
- array('check', 'disable_print_topic'),
- '',
-
- array('int', 'enableAllMessages', 'postinput' => $txt['manageposts_posts'], 'subtext' => $txt['enableAllMessages_zero']),
- array('check', 'disableCustomPerPage'),
- array('check', 'enablePreviousNext'),
- );
- call_integration_hook('integrate_modify_topic_settings', array(&$config_vars));
- if ($return_config)
- return $config_vars;
-
- require_once($sourcedir . '/ManageServer.php');
-
- $context['page_title'] = $txt['manageposts_topic_settings'];
- $context['sub_template'] = 'show_settings';
-
- if (isset($_GET['save']))
- {
- checkSession();
- call_integration_hook('integrate_save_topic_settings');
- saveDBSettings($config_vars);
- $_SESSION['adm-save'] = true;
- redirectexit('action=admin;area=postsettings;sa=topics');
- }
-
- $context['post_url'] = $scripturl . '?action=admin;area=postsettings;save;sa=topics';
- $context['settings_title'] = $txt['manageposts_topic_settings'];
-
- prepareDBSettingContext($config_vars);
- }
- function ModifyDraftSettings($return_config = false)
- {
- global $context, $txt, $sourcedir, $scripturl, $smcFunc;
-
- $config_vars = array(
-
- array('check', 'drafts_post_enabled'),
- array('check', 'drafts_pm_enabled'),
- array('check', 'drafts_show_saved_enabled', 'subtext' => $txt['drafts_show_saved_enabled_subnote']),
- array('int', 'drafts_keep_days', 'postinput' => $txt['days_word'], 'subtext' => $txt['drafts_keep_days_subnote']),
- '',
- array('check', 'drafts_autosave_enabled', 'subtext' => $txt['drafts_autosave_enabled_subnote']),
- array('int', 'drafts_autosave_frequency', 'postinput' => $txt['manageposts_seconds'], 'subtext' => $txt['drafts_autosave_frequency_subnote']),
- );
- if ($return_config)
- return $config_vars;
-
- require_once($sourcedir . '/ManageServer.php');
-
- $context['page_title'] = $txt['managedrafts_settings'];
- $context['sub_template'] = 'show_settings';
-
- if (isset($_GET['save']))
- {
- checkSession();
-
- $_POST['drafts_autosave_frequency'] = !isset($_POST['drafts_autosave_frequency']) || $_POST['drafts_autosave_frequency'] < 30 ? 30 : $_POST['drafts_autosave_frequency'];
-
- $smcFunc['db_query']('', '
- UPDATE {db_prefix}scheduled_tasks
- SET disabled = {int:disabled}
- WHERE task = {string:task}',
- array(
- 'disabled' => !empty($_POST['drafts_keep_days']) ? 0 : 1,
- 'task' => 'remove_old_drafts',
- )
- );
- require_once($sourcedir . '/ScheduledTasks.php');
- CalculateNextTrigger();
-
- saveDBSettings($config_vars);
- $_SESSION['adm-save'] = true;
- redirectexit('action=admin;area=postsettings;sa=drafts');
- }
-
- $context['settings_post_javascript'] = '
- function toggle()
- {
- $("#drafts_autosave_frequency").prop("disabled", !($("#drafts_autosave_enabled").prop("checked")));
- };
- toggle();
- $("#drafts_autosave_enabled").click(function() { toggle(); });
- ';
-
- $context['post_url'] = $scripturl . '?action=admin;area=postsettings;sa=drafts;save';
- $context['settings_title'] = $txt['managedrafts_settings'];
-
- prepareDBSettingContext($config_vars);
- }
- ?>
|