/sources/admin/ManageSettings.php
PHP | 2770 lines | 2082 code | 325 blank | 363 comment | 301 complexity | 92f855fda189f2efc4a92c5b20bc0728 MD5 | raw file
Possible License(s): BSD-3-Clause, LGPL-3.0
Large files files are truncated, but you can click here to view the full file
- <?php
- /**
- * @name ElkArte Forum
- * @copyright ElkArte Forum contributors
- * @license BSD http://opensource.org/licenses/BSD-3-Clause
- *
- * This software is a derived product, based on:
- *
- * Simple Machines Forum (SMF)
- * copyright: 2011 Simple Machines (http://www.simplemachines.org)
- * license: BSD, See included LICENSE.TXT for terms and conditions.
- *
- * @version 1.0 Alpha
- *
- * This file is here to make it easier for installed mods to have
- * settings and options.
- *
- */
- if (!defined('ELKARTE'))
- die('No access...');
- /**
- * This just avoids some repetition.
- *
- * @param array $subActions = array()
- * @param string $defaultAction = ''
- */
- function loadGeneralSettingParameters($subActions = array(), $defaultAction = '')
- {
- global $context, $txt;
- // You need to be an admin to edit settings!
- isAllowedTo('admin_forum');
- loadLanguage('Help');
- loadLanguage('ManageSettings');
- // Will need the utility functions from here.
- require_once(ADMINDIR . '/ManageServer.php');
- $context['sub_template'] = 'show_settings';
- // By default do the basic settings.
- $_REQUEST['sa'] = isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]) ? $_REQUEST['sa'] : (!empty($defaultAction) ? $defaultAction : array_pop($temp = array_keys($subActions)));
- $context['sub_action'] = $_REQUEST['sa'];
- }
- /**
- * This function passes control through to the relevant tab.
- */
- function ModifyFeatureSettings()
- {
- global $context, $txt, $scripturl, $modSettings, $settings;
- $context['page_title'] = $txt['modSettings_title'];
- $subActions = array(
- 'basic' => 'ModifyBasicSettings',
- 'layout' => 'ModifyLayoutSettings',
- 'karma' => 'ModifyKarmaSettings',
- 'sig' => 'ModifySignatureSettings',
- 'profile' => 'ShowCustomProfiles',
- 'profileedit' => 'EditCustomProfiles',
- );
- call_integration_hook('integrate_modify_features', array($subActions));
- // If Advanced Profile Fields are disabled don't show the setting page
- if (!in_array('cp', $context['admin_features']))
- unset($subActions['profile']);
- // Same for Karma
- if (!in_array('k', $context['admin_features']))
- unset($subActions['karma']);
- loadGeneralSettingParameters($subActions, 'basic');
- // Load up all the tabs...
- $context[$context['admin_menu_name']]['tab_data'] = array(
- 'title' => $txt['modSettings_title'],
- 'help' => 'featuresettings',
- 'description' => sprintf($txt['modSettings_desc'], $settings['theme_id'], $context['session_id'], $context['session_var']),
- 'tabs' => array(
- 'basic' => array(
- ),
- 'layout' => array(
- ),
- 'karma' => array(
- ),
- 'sig' => array(
- 'description' => $txt['signature_settings_desc'],
- ),
- 'profile' => array(
- 'description' => $txt['custom_profile_desc'],
- ),
- ),
- );
- // Call the right function for this sub-acton.
- $subActions[$_REQUEST['sa']]();
- }
- /**
- * This function passes control through to the relevant security tab.
- */
- function ModifySecuritySettings()
- {
- global $context, $txt, $scripturl, $modSettings, $settings;
- $context['page_title'] = $txt['admin_security_moderation'];
- $subActions = array(
- 'general' => 'ModifyGeneralSecuritySettings',
- 'spam' => 'ModifySpamSettings',
- 'badbehavior' => 'ModifyBadBehaviorSettings',
- 'moderation' => 'ModifyModerationSettings',
- );
- call_integration_hook('integrate_modify_security', array($subActions));
- // If Warning System is disabled don't show the setting page
- if (!in_array('w', $context['admin_features']))
- unset($subActions['moderation']);
- loadGeneralSettingParameters($subActions, 'general');
- // Load up all the tabs...
- $context[$context['admin_menu_name']]['tab_data'] = array(
- 'title' => $txt['admin_security_moderation'],
- 'help' => 'securitysettings',
- 'description' => $txt['security_settings_desc'],
- 'tabs' => array(
- 'general' => array(
- ),
- 'spam' => array(
- 'description' => $txt['antispam_Settings_desc'] ,
- ),
- 'badbehavior' => array(
- 'description' => $txt['badbehavior_desc'] ,
- ),
- 'moderation' => array(
- ),
- ),
- );
- // Call the right function for this sub-acton.
- $subActions[$_REQUEST['sa']]();
- }
- /**
- * This my friend, is for all the mod authors out there.
- */
- function ModifyModSettings()
- {
- global $context, $txt, $scripturl, $modSettings, $settings;
- $context['page_title'] = $txt['admin_modifications'];
- $subActions = array(
- 'general' => 'ModifyGeneralModSettings',
- 'hooks' => 'list_integration_hooks',
- // Mod authors, once again, if you have a whole section to add do it AFTER this line, and keep a comma at the end.
- );
- // Make it easier for mods to add new areas.
- call_integration_hook('integrate_modify_modifications', array(&$subActions));
- loadGeneralSettingParameters($subActions, 'general');
- // Load up all the tabs...
- $context[$context['admin_menu_name']]['tab_data'] = array(
- 'title' => $txt['admin_modifications'],
- 'help' => 'modsettings',
- 'description' => $txt['modification_settings_desc'],
- 'tabs' => array(
- 'general' => array(
- ),
- 'hooks' => array(
- ),
- ),
- );
- // Call the right function for this sub-acton.
- $subActions[$_REQUEST['sa']]();
- }
- /**
- * This is an overall control panel enabling/disabling lots of the forums key features.
- *
- * @param $return_config
- */
- function ModifyCoreFeatures($return_config = false)
- {
- global $txt, $scripturl, $context, $settings, $sc, $modSettings;
- /* This is an array of all the features that can be enabled/disabled - each option can have the following:
- title - Text title of this item (If standard string does not exist).
- desc - Description of this feature (If standard string does not exist).
- settings - Array of settings to change (For each name => value) on enable - reverse is done for disable. If > 1 will not change value if set.
- setting_callback- Function that returns an array of settings to save - takes one parameter which is value for this feature.
- save_callback - Function called on save, takes state as parameter.
- */
- $core_features = array(
- // cd = calendar.
- 'cd' => array(
- 'url' => 'action=admin;area=managecalendar',
- 'settings' => array(
- 'cal_enabled' => 1,
- ),
- ),
- // cp = custom profile fields.
- 'cp' => array(
- 'url' => 'action=admin;area=featuresettings;sa=profile',
- 'save_callback' => create_function('$value', '
- global $smcFunc;
- if (!$value)
- {
- $smcFunc[\'db_query\'](\'\', \'
- UPDATE {db_prefix}custom_fields
- SET active = 0\');
- }
- '),
- 'setting_callback' => create_function('$value', '
- if (!$value)
- return array(
- \'disabled_profile_fields\' => \'\',
- \'registration_fields\' => \'\',
- \'displayFields\' => \'\',
- );
- else
- return array();
- '),
- ),
- // dr = drafts
- 'dr' => array(
- 'url' => 'action=admin;area=managedrafts',
- 'settings' => array(
- 'drafts_enabled' => 1,
- 'drafts_post_enabled' => 2,
- 'drafts_pm_enabled' => 2,
- 'drafts_autosave_enabled' => 2,
- 'drafts_show_saved_enabled' => 2,
- ),
- 'setting_callback' => create_function('$value', '
- global $smcFunc;
- // Set the correct disabled value for the scheduled task.
- $smcFunc[\'db_query\'](\'\', \'
- UPDATE {db_prefix}scheduled_tasks
- SET disabled = {int:disabled}
- WHERE task = {string:task}\',
- array(
- \'disabled\' => $value ? 0 : 1,
- \'task\' => \'remove_old_drafts\',
- )
- );
- '),
- ),
- // ih = Integration Hooks Handling.
- 'ih' => array(
- 'url' => 'action=admin;area=modsettings;sa=hooks',
- 'settings' => array(
- 'handlinghooks_enabled' => 1,
- ),
- ),
- // k = karma.
- 'k' => array(
- 'url' => 'action=admin;area=featuresettings;sa=karma',
- 'settings' => array(
- 'karmaMode' => 2,
- ),
- ),
- // ml = moderation log.
- 'ml' => array(
- 'url' => 'action=admin;area=logs;sa=modlog',
- 'settings' => array(
- 'modlog_enabled' => 1,
- ),
- ),
- // pm = post moderation.
- 'pm' => array(
- 'url' => 'action=admin;area=permissions;sa=postmod',
- 'setting_callback' => create_function('$value', '
- // Cant use warning post moderation if disabled!
- if (!$value)
- {
- require_once(CONTROLLERDIR . \'/PostModeration.controller.php\');
- approveAllData();
- return array(\'warning_moderate\' => 0);
- }
- else
- return array();
- '),
- ),
- // ps = Paid Subscriptions.
- 'ps' => array(
- 'url' => 'action=admin;area=paidsubscribe',
- 'settings' => array(
- 'paid_enabled' => 1,
- ),
- 'setting_callback' => create_function('$value', '
- global $smcFunc;
- // Set the correct disabled value for scheduled task.
- $smcFunc[\'db_query\'](\'\', \'
- UPDATE {db_prefix}scheduled_tasks
- SET disabled = {int:disabled}
- WHERE task = {string:task}\',
- array(
- \'disabled\' => $value ? 0 : 1,
- \'task\' => \'paid_subscriptions\',
- )
- );
- // Should we calculate next trigger?
- if ($value)
- {
- require_once(SOURCEDIR . \'/ScheduledTasks.php\');
- CalculateNextTrigger(\'paid_subscriptions\');
- }
- '),
- ),
- // rg = report generator.
- 'rg' => array(
- 'url' => 'action=admin;area=reports',
- ),
- // w = warning.
- 'w' => array(
- 'url' => 'action=admin;area=securitysettings;sa=moderation',
- 'setting_callback' => create_function('$value', '
- global $modSettings;
- list ($modSettings[\'warning_enable\'], $modSettings[\'user_limit\'], $modSettings[\'warning_decrement\']) = explode(\',\', $modSettings[\'warning_settings\']);
- $warning_settings = ($value ? 1 : 0) . \',\' . $modSettings[\'user_limit\'] . \',\' . $modSettings[\'warning_decrement\'];
- if (!$value)
- {
- $returnSettings = array(
- \'warning_watch\' => 0,
- \'warning_moderate\' => 0,
- \'warning_mute\' => 0,
- );
- }
- elseif (empty($modSettings[\'warning_enable\']) && $value)
- {
- $returnSettings = array(
- \'warning_watch\' => 10,
- \'warning_moderate\' => 35,
- \'warning_mute\' => 60,
- );
- }
- else
- $returnSettings = array();
- $returnSettings[\'warning_settings\'] = $warning_settings;
- return $returnSettings;
- '),
- ),
- // Search engines
- 'sp' => array(
- 'url' => 'action=admin;area=sengines',
- 'settings' => array(
- 'spider_mode' => 1,
- ),
- 'setting_callback' => create_function('$value', '
- // Turn off the spider group if disabling.
- if (!$value)
- return array(\'spider_group\' => 0, \'show_spider_online\' => 0);
- '),
- 'on_save' => create_function('', '
- global $modSettings;
- require_once(SUBSDIR . \'/SearchEngines.subs.php\');
- '),
- ),
- );
- // Anyone who would like to add a core feature?
- call_integration_hook('integrate_core_features', array(&$core_features));
- // Are we getting info for the help section.
- if ($return_config)
- {
- $return_data = array();
- foreach ($core_features as $id => $data)
- $return_data[] = array('switch', isset($data['title']) ? $data['title'] : $txt['core_settings_item_' . $id]);
- return $return_data;
- }
- loadGeneralSettingParameters();
- // Are we saving?
- if (isset($_POST['save']))
- {
- checkSession();
- if (isset($_GET['xml']))
- {
- $tokenValidation = validateToken('admin-core', 'post', false);
- if (empty($tokenValidation))
- return 'token_verify_fail';
- }
- else
- validateToken('admin-core');
- $setting_changes = array('admin_features' => array());
- // Cycle each feature and change things as required!
- foreach ($core_features as $id => $feature)
- {
- // Enabled?
- if (!empty($_POST['feature_' . $id]))
- $setting_changes['admin_features'][] = $id;
- // Setting values to change?
- if (isset($feature['settings']))
- {
- foreach ($feature['settings'] as $key => $value)
- {
- if (empty($_POST['feature_' . $id]) || (!empty($_POST['feature_' . $id]) && ($value < 2 || empty($modSettings[$key]))))
- $setting_changes[$key] = !empty($_POST['feature_' . $id]) ? $value : !$value;
- }
- }
- // Is there a call back for settings?
- if (isset($feature['setting_callback']))
- {
- $returned_settings = $feature['setting_callback'](!empty($_POST['feature_' . $id]));
- if (!empty($returned_settings))
- $setting_changes = array_merge($setting_changes, $returned_settings);
- }
- // Standard save callback?
- if (isset($feature['on_save']))
- $feature['on_save']();
- }
- // Make sure this one setting is a string!
- $setting_changes['admin_features'] = implode(',', $setting_changes['admin_features']);
- // Make any setting changes!
- updateSettings($setting_changes);
- // This is needed to let menus appear if cache > 2
- if ($modSettings['cache_enable'] > 2)
- clean_cache('data');
- // Any post save things?
- foreach ($core_features as $id => $feature)
- {
- // Standard save callback?
- if (isset($feature['save_callback']))
- $feature['save_callback'](!empty($_POST['feature_' . $id]));
- }
- if (!isset($_REQUEST['xml']))
- redirectexit('action=admin;area=corefeatures;' . $context['session_var'] . '=' . $context['session_id']);
- }
- // Put them in context.
- $context['features'] = array();
- foreach ($core_features as $id => $feature)
- $context['features'][$id] = array(
- 'title' => isset($feature['title']) ? $feature['title'] : $txt['core_settings_item_' . $id],
- 'desc' => isset($feature['desc']) ? $feature['desc'] : $txt['core_settings_item_' . $id . '_desc'],
- 'enabled' => in_array($id, $context['admin_features']),
- 'state' => in_array($id, $context['admin_features']) ? 'on' : 'off',
- 'url' => !empty($feature['url']) ? $scripturl . '?' . $feature['url'] . ';' . $context['session_var'] . '=' . $context['session_id'] : '',
- 'image' => (file_exists($settings['theme_dir'] . '/images/admin/feature_' . $id . '.png') ? $settings['images_url'] : $settings['default_images_url']) . '/admin/feature_' . $id . '.png',
- );
- // Are they a new user?
- $context['is_new_install'] = !isset($modSettings['admin_features']);
- $context['force_disable_tabs'] = $context['is_new_install'];
- // Don't show them this twice!
- if ($context['is_new_install'])
- updateSettings(array('admin_features' => ''));
- // sub_template is already generic_xml and the token is created somewhere else
- if (isset($_REQUEST['xml']))
- return;
- $context['sub_template'] = 'core_features';
- $context['page_title'] = $txt['core_settings_title'];
- $context[$context['admin_menu_name']]['tab_data'] = array(
- 'title' => $txt['core_settings_title'],
- 'help' => '',
- 'description' => $txt['core_settings_desc'],
- );
- // We love our tokens.
- createToken('admin-core');
- }
- /**
- * Config array for chaning the basic forum settings
- * Accessed from ?action=admin;area=featuresettings;sa=basic;
- *
- * @param $return_config
- */
- function ModifyBasicSettings($return_config = false)
- {
- global $txt, $scripturl, $context, $settings, $sc, $modSettings;
- $config_vars = array(
- // Big Options... polls, sticky, bbc....
- array('select', 'pollMode', array($txt['disable_polls'], $txt['enable_polls'], $txt['polls_as_topics'])),
- '',
- // Basic stuff, titles, flash, permissions...
- array('check', 'allow_guestAccess'),
- array('check', 'enable_buddylist'),
- array('check', 'enable_disregard'),
- array('check', 'allow_editDisplayName'),
- array('check', 'allow_hideOnline'),
- array('check', 'titlesEnable'),
- array('text', 'default_personal_text', 'subtext' => $txt['default_personal_text_note']),
- '',
- // Javascript and CSS options
- array('select', 'jquery_source', array('auto' => $txt['jquery_auto'], 'local' => $txt['jquery_local'], 'cdn' => $txt['jquery_cdn'])),
- array('check', 'minify_css_js'),
- '',
- // SEO stuff
- array('check', 'queryless_urls', 'subtext' => '<strong>' . $txt['queryless_urls_note'] . '</strong>'),
- array('text', 'meta_keywords', 'subtext' => $txt['meta_keywords_note'], 'size' => 50),
- '',
- // Number formatting, timezones.
- array('text', 'time_format'),
- array('float', 'time_offset', 'subtext' => $txt['setting_time_offset_note'], 6, 'postinput' => $txt['hours']),
- 'default_timezone' => array('select', 'default_timezone', array()),
- '',
- // Who's online?
- array('check', 'who_enabled'),
- array('int', 'lastActive', 6, 'postinput' => $txt['minutes']),
- '',
- // Statistics.
- array('check', 'trackStats'),
- array('check', 'hitStats'),
- '',
- // Option-ish things... miscellaneous sorta.
- array('check', 'allow_disableAnnounce'),
- array('check', 'disallow_sendBody'),
- array('select', 'enable_contactform', array('disabled' => $txt['contact_form_disabled'], 'registration' => $txt['contact_form_registration'], 'menu' => $txt['contact_form_menu'])),
- );
- // Get all the time zones.
- if (function_exists('timezone_identifiers_list') && function_exists('date_default_timezone_set'))
- {
- $all_zones = timezone_identifiers_list();
- // Make sure we set the value to the same as the printed value.
- foreach ($all_zones as $zone)
- $config_vars['default_timezone'][2][$zone] = $zone;
- }
- else
- unset($config_vars['default_timezone']);
- call_integration_hook('integrate_modify_basic_settings', array($config_vars));
- if ($return_config)
- return $config_vars;
- // Saving?
- if (isset($_GET['save']))
- {
- checkSession();
- // Prevent absurd boundaries here - make it a day tops.
- if (isset($_POST['lastActive']))
- $_POST['lastActive'] = min((int) $_POST['lastActive'], 1440);
- call_integration_hook('integrate_save_basic_settings');
- saveDBSettings($config_vars);
- writeLog();
- redirectexit('action=admin;area=featuresettings;sa=basic');
- }
- $context['post_url'] = $scripturl . '?action=admin;area=featuresettings;save;sa=basic';
- $context['settings_title'] = $txt['mods_cat_features'];
- prepareDBSettingContext($config_vars);
- }
- /**
- * Settings really associated with general security aspects.
- *
- * @param $return_config
- */
- function ModifyGeneralSecuritySettings($return_config = false)
- {
- global $txt, $scripturl, $context, $settings, $sc, $modSettings;
- $config_vars = array(
- array('check', 'guest_hideContacts'),
- array('check', 'make_email_viewable'),
- '',
- array('int', 'failed_login_threshold'),
- array('int', 'loginHistoryDays'),
- '',
- array('check', 'enableErrorLogging'),
- array('check', 'enableErrorQueryLogging'),
- '',
- array('check', 'securityDisable'),
- array('check', 'securityDisable_moderate'),
- '',
- // Reactive on email, and approve on delete
- array('check', 'send_validation_onChange'),
- array('check', 'approveAccountDeletion'),
- '',
- // Password strength.
- array('select', 'password_strength', array($txt['setting_password_strength_low'], $txt['setting_password_strength_medium'], $txt['setting_password_strength_high'])),
- array('check', 'enable_password_conversion'),
- '',
- // Reporting of personal messages?
- array('check', 'enableReportPM'),
- );
- call_integration_hook('integrate_general_security_settings', array($config_vars));
- if ($return_config)
- return $config_vars;
- // Saving?
- if (isset($_GET['save']))
- {
- checkSession();
- saveDBSettings($config_vars);
- call_integration_hook('integrate_save_general_security_settings');
- writeLog();
- redirectexit('action=admin;area=securitysettings;sa=general');
- }
- $context['post_url'] = $scripturl . '?action=admin;area=securitysettings;save;sa=general';
- $context['settings_title'] = $txt['mods_cat_security_general'];
- prepareDBSettingContext($config_vars);
- }
- /**
- * Allows modifying the global layout settings in the forum
- * Accessed through ?action=admin;area=featuresettings;sa=layout;
- *
- * @param $return_config
- */
- function ModifyLayoutSettings($return_config = false)
- {
- global $txt, $scripturl, $context, $settings, $sc;
- $config_vars = array(
- // Pagination stuff.
- array('check', 'compactTopicPagesEnable'),
- array('int', 'compactTopicPagesContiguous', null, $txt['contiguous_page_display'] . '<div class="smalltext">' . str_replace(' ', ' ', '"3" ' . $txt['to_display'] . ': <strong>1 ... 4 [5] 6 ... 9</strong>') . '<br />' . str_replace(' ', ' ', '"5" ' . $txt['to_display'] . ': <strong>1 ... 3 4 [5] 6 7 ... 9</strong>') . '</div>'),
- array('int', 'defaultMaxMembers'),
- '',
- // Stuff that just is everywhere - today, search, online, etc.
- array('select', 'todayMod', array($txt['today_disabled'], $txt['today_only'], $txt['yesterday_today'])),
- array('check', 'topbottomEnable'),
- array('check', 'onlineEnable'),
- array('check', 'enableVBStyleLogin'),
- '',
- // Automagic image resizing.
- array('int', 'max_image_width', 'subtext' => $txt['zero_for_no_limit']),
- array('int', 'max_image_height', 'subtext' => $txt['zero_for_no_limit']),
- '',
- // This is like debugging sorta.
- array('check', 'timeLoadPageEnable'),
- );
- call_integration_hook('integrate_layout_settings', array($config_vars));
- if ($return_config)
- return $config_vars;
- // Saving?
- if (isset($_GET['save']))
- {
- checkSession();
- call_integration_hook('integrate_save_layout_settings');
- saveDBSettings($config_vars);
- writeLog();
- redirectexit('action=admin;area=featuresettings;sa=layout');
- }
- $context['post_url'] = $scripturl . '?action=admin;area=featuresettings;save;sa=layout';
- $context['settings_title'] = $txt['mods_cat_layout'];
- prepareDBSettingContext($config_vars);
- }
- /**
- * Config array for chaning the karma settings
- * Accessed from ?action=admin;area=featuresettings;sa=karma;
- *
- * @param $return_config
- */
- function ModifyKarmaSettings($return_config = false)
- {
- global $txt, $scripturl, $context, $settings, $sc;
- $config_vars = array(
- // Karma - On or off?
- array('select', 'karmaMode', explode('|', $txt['karma_options'])),
- '',
- // Who can do it.... and who is restricted by time limits?
- array('int', 'karmaMinPosts', 6, 'postinput' => strtolower($txt['posts'])),
- array('float', 'karmaWaitTime', 6, 'postinput' => $txt['hours']),
- array('check', 'karmaTimeRestrictAdmins'),
- '',
- // What does it look like? [smite]?
- array('text', 'karmaLabel'),
- array('text', 'karmaApplaudLabel'),
- array('text', 'karmaSmiteLabel'),
- );
- call_integration_hook('integrate_karma_settings', array($config_vars));
- if ($return_config)
- return $config_vars;
- // Saving?
- if (isset($_GET['save']))
- {
- checkSession();
- call_integration_hook('integrate_save_karma_settings');
- saveDBSettings($config_vars);
- redirectexit('action=admin;area=featuresettings;sa=karma');
- }
- $context['post_url'] = $scripturl . '?action=admin;area=featuresettings;save;sa=karma';
- $context['settings_title'] = $txt['karma'];
- prepareDBSettingContext($config_vars);
- }
- /**
- * Moderation type settings - although there are fewer than we have you believe ;)
- *
- * @param bool $return_config = false
- */
- function ModifyModerationSettings($return_config = false)
- {
- global $txt, $scripturl, $context, $settings, $sc, $modSettings;
- $config_vars = array(
- // Warning system?
- array('int', 'warning_watch', 'subtext' => $txt['setting_warning_watch_note'], 'help' => 'warning_enable'),
- 'moderate' => array('int', 'warning_moderate', 'subtext' => $txt['setting_warning_moderate_note']),
- array('int', 'warning_mute', 'subtext' => $txt['setting_warning_mute_note']),
- 'rem1' => array('int', 'user_limit', 'subtext' => $txt['setting_user_limit_note']),
- 'rem2' => array('int', 'warning_decrement', 'subtext' => $txt['setting_warning_decrement_note']),
- array('select', 'warning_show', 'subtext' => $txt['setting_warning_show_note'], array($txt['setting_warning_show_mods'], $txt['setting_warning_show_user'], $txt['setting_warning_show_all'])),
- );
- call_integration_hook('integrate_moderation_settings', array($config_vars));
- if ($return_config)
- return $config_vars;
- // Cannot use moderation if post moderation is not enabled.
- if (!$modSettings['postmod_active'])
- unset($config_vars['moderate']);
- // Saving?
- if (isset($_GET['save']))
- {
- checkSession();
- // Make sure these don't have an effect.
- if (substr($modSettings['warning_settings'], 0, 1) != 1)
- {
- $_POST['warning_watch'] = 0;
- $_POST['warning_moderate'] = 0;
- $_POST['warning_mute'] = 0;
- }
- else
- {
- $_POST['warning_watch'] = min($_POST['warning_watch'], 100);
- $_POST['warning_moderate'] = $modSettings['postmod_active'] ? min($_POST['warning_moderate'], 100) : 0;
- $_POST['warning_mute'] = min($_POST['warning_mute'], 100);
- }
- // Fix the warning setting array!
- $_POST['warning_settings'] = '1,' . min(100, (int) $_POST['user_limit']) . ',' . min(100, (int) $_POST['warning_decrement']);
- $save_vars = $config_vars;
- $save_vars[] = array('text', 'warning_settings');
- unset($save_vars['rem1'], $save_vars['rem2']);
- call_integration_hook('integrate_save_karma_settings', array($save_vars));
- saveDBSettings($save_vars);
- redirectexit('action=admin;area=securitysettings;sa=moderation');
- }
- // We actually store lots of these together - for efficiency.
- list ($modSettings['warning_enable'], $modSettings['user_limit'], $modSettings['warning_decrement']) = explode(',', $modSettings['warning_settings']);
- $context['post_url'] = $scripturl . '?action=admin;area=securitysettings;save;sa=moderation';
- $context['settings_title'] = $txt['moderation_settings'];
- prepareDBSettingContext($config_vars);
- }
- /**
- * Let's try keep the spam to a minimum ah Thantos?
- * @param bool $return_config = false
- */
- function ModifySpamSettings($return_config = false)
- {
- global $txt, $scripturl, $context, $settings, $sc, $modSettings, $smcFunc;
- // Generate a sample registration image.
- $context['use_graphic_library'] = in_array('gd', get_loaded_extensions());
- $context['verification_image_href'] = $scripturl . '?action=verificationcode;rand=' . md5(mt_rand());
- // Build up our options array
- $config_vars = array(
- array('title', 'antispam_Settings'),
- array('check', 'reg_verification'),
- array('check', 'search_enable_captcha'),
- // This, my friend, is a cheat :p
- 'guest_verify' => array('check', 'guests_require_captcha', 'postinput' => $txt['setting_guests_require_captcha_desc']),
- array('int', 'posts_require_captcha', 'postinput' => $txt['posts_require_captcha_desc'], 'onchange' => 'if (this.value > 0){ document.getElementById(\'guests_require_captcha\').checked = true; document.getElementById(\'guests_require_captcha\').disabled = true;} else {document.getElementById(\'guests_require_captcha\').disabled = false;}'),
- array('check', 'guests_report_require_captcha'),
- // PM Settings
- array('title', 'antispam_PM'),
- 'pm1' => array('int', 'max_pm_recipients', 'postinput' => $txt['max_pm_recipients_note']),
- 'pm2' => array('int', 'pm_posts_verification', 'postinput' => $txt['pm_posts_verification_note']),
- 'pm3' => array('int', 'pm_posts_per_hour', 'postinput' => $txt['pm_posts_per_hour_note']),
- // Visual verification.
- array('title', 'configure_verification_means'),
- array('desc', 'configure_verification_means_desc'),
- 'vv' => array('select', 'visual_verification_type', array($txt['setting_image_verification_off'], $txt['setting_image_verification_vsimple'], $txt['setting_image_verification_simple'], $txt['setting_image_verification_medium'], $txt['setting_image_verification_high'], $txt['setting_image_verification_extreme']), 'subtext'=> $txt['setting_visual_verification_type_desc'], 'onchange' => $context['use_graphic_library'] ? 'refreshImages();' : ''),
- // Clever Thomas, who is looking sheepy now? Not I, the mighty sword swinger did say.
- array('title', 'setup_verification_questions'),
- array('desc', 'setup_verification_questions_desc'),
- array('int', 'qa_verification_number', 'postinput' => $txt['setting_qa_verification_number_desc']),
- array('callback', 'question_answer_list'),
- );
- call_integration_hook('integrate_spam_settings', array($config_vars));
- if ($return_config)
- return $config_vars;
- // Load any question and answers!
- $context['question_answers'] = array();
- $request = $smcFunc['db_query']('', '
- SELECT id_comment, body AS question, recipient_name AS answer
- FROM {db_prefix}log_comments
- WHERE comment_type = {string:ver_test}',
- array(
- 'ver_test' => 'ver_test',
- )
- );
- while ($row = $smcFunc['db_fetch_assoc']($request))
- {
- $context['question_answers'][$row['id_comment']] = array(
- 'id' => $row['id_comment'],
- 'question' => $row['question'],
- 'answer' => $row['answer'],
- );
- }
- $smcFunc['db_free_result']($request);
- // Saving?
- if (isset($_GET['save']))
- {
- checkSession();
- // Fix PM settings.
- $_POST['pm_spam_settings'] = (int) $_POST['max_pm_recipients'] . ',' . (int) $_POST['pm_posts_verification'] . ',' . (int) $_POST['pm_posts_per_hour'];
- // Hack in guest requiring verification!
- if (empty($_POST['posts_require_captcha']) && !empty($_POST['guests_require_captcha']))
- $_POST['posts_require_captcha'] = -1;
- $save_vars = $config_vars;
- unset($save_vars['pm1'], $save_vars['pm2'], $save_vars['pm3'], $save_vars['guest_verify']);
- $save_vars[] = array('text', 'pm_spam_settings');
- // Handle verification questions.
- $questionInserts = array();
- $count_questions = 0;
- foreach ($_POST['question'] as $id => $question)
- {
- $question = trim($smcFunc['htmlspecialchars']($question, ENT_COMPAT));
- $answer = trim($smcFunc['strtolower']($smcFunc['htmlspecialchars']($_POST['answer'][$id], ENT_COMPAT)));
- // Already existed?
- if (isset($context['question_answers'][$id]))
- {
- $count_questions++;
- // Changed?
- if ($context['question_answers'][$id]['question'] != $question || $context['question_answers'][$id]['answer'] != $answer)
- {
- if ($question == '' || $answer == '')
- {
- $smcFunc['db_query']('', '
- DELETE FROM {db_prefix}log_comments
- WHERE comment_type = {string:ver_test}
- AND id_comment = {int:id}',
- array(
- 'id' => $id,
- 'ver_test' => 'ver_test',
- )
- );
- $count_questions--;
- }
- else
- $request = $smcFunc['db_query']('', '
- UPDATE {db_prefix}log_comments
- SET body = {string:question}, recipient_name = {string:answer}
- WHERE comment_type = {string:ver_test}
- AND id_comment = {int:id}',
- array(
- 'id' => $id,
- 'ver_test' => 'ver_test',
- 'question' => $question,
- 'answer' => $answer,
- )
- );
- }
- }
- // It's so shiney and new!
- elseif ($question != '' && $answer != '')
- {
- $questionInserts[] = array(
- 'comment_type' => 'ver_test',
- 'body' => $question,
- 'recipient_name' => $answer,
- );
- }
- }
- // Any questions to insert?
- if (!empty($questionInserts))
- {
- $smcFunc['db_insert']('',
- '{db_prefix}log_comments',
- array('comment_type' => 'string', 'body' => 'string-65535', 'recipient_name' => 'string-80'),
- $questionInserts,
- array('id_comment')
- );
- $count_questions++;
- }
- if (empty($count_questions) || $_POST['qa_verification_number'] > $count_questions)
- $_POST['qa_verification_number'] = $count_questions;
- call_integration_hook('integrate_save_spam_settings', array($save_vars));
- // Now save.
- saveDBSettings($save_vars);
- cache_put_data('verificationQuestionIds', null, 300);
- redirectexit('action=admin;area=securitysettings;sa=spam');
- }
- $character_range = array_merge(range('A', 'H'), array('K', 'M', 'N', 'P', 'R'), range('T', 'Y'));
- $_SESSION['visual_verification_code'] = '';
- for ($i = 0; $i < 6; $i++)
- $_SESSION['visual_verification_code'] .= $character_range[array_rand($character_range)];
- // Some javascript for CAPTCHA.
- $context['settings_post_javascript'] = '';
- if ($context['use_graphic_library'])
- $context['settings_post_javascript'] .= '
- function refreshImages()
- {
- var imageType = document.getElementById(\'visual_verification_type\').value;
- document.getElementById(\'verification_image\').src = \'' . $context['verification_image_href'] . ';type=\' + imageType;
- }';
- // Show the image itself, or text saying we can't.
- if ($context['use_graphic_library'])
- $config_vars['vv']['postinput'] = '<br /><img src="' . $context['verification_image_href'] . ';type=' . (empty($modSettings['visual_verification_type']) ? 0 : $modSettings['visual_verification_type']) . '" alt="' . $txt['setting_image_verification_sample'] . '" id="verification_image" /><br />';
- else
- $config_vars['vv']['postinput'] = '<br /><span class="smalltext">' . $txt['setting_image_verification_nogd'] . '</span>';
- // Hack for PM spam settings.
- list ($modSettings['max_pm_recipients'], $modSettings['pm_posts_verification'], $modSettings['pm_posts_per_hour']) = explode(',', $modSettings['pm_spam_settings']);
- // Hack for guests requiring verification.
- $modSettings['guests_require_captcha'] = !empty($modSettings['posts_require_captcha']);
- $modSettings['posts_require_captcha'] = !isset($modSettings['posts_require_captcha']) || $modSettings['posts_require_captcha'] == -1 ? 0 : $modSettings['posts_require_captcha'];
- // Some minor javascript for the guest post setting.
- if ($modSettings['posts_require_captcha'])
- $context['settings_post_javascript'] .= '
- document.getElementById(\'guests_require_captcha\').disabled = true;';
- $context['post_url'] = $scripturl . '?action=admin;area=securitysettings;save;sa=spam';
- $context['settings_title'] = $txt['antispam_Settings'];
- prepareDBSettingContext($config_vars);
- }
- /**
- * Change the way bad behavior ... well behaves
- *
- * @param $return_config
- */
- function ModifyBadBehaviorSettings($return_config = false)
- {
- global $txt, $scripturl, $context, $modSettings, $boardurl;
- // Our callback templates are here
- loadTemplate('BadBehavior');
- // See if they supplied a valid looking http:BL API Key
- $context['invalid_badbehavior_httpbl_key'] = (!empty($modSettings['badbehavior_httpbl_key']) && (strlen($modSettings['badbehavior_httpbl_key']) !== 12 || !ctype_lower($modSettings['badbehavior_httpbl_key'])));
- // Any errors to display?
- if ($context['invalid_badbehavior_httpbl_key'])
- {
- $context['settings_message'][] = $txt['setting_badbehavior_httpbl_key_invalid'];
- $context['error_type'] = 'notice';
- }
- // Have we blocked anything in the last 7 days?
- if (!empty($modSettings['badbehavior_enabled']))
- $context['settings_message'][] = bb2_insert_stats(true) . '<a href="' . $boardurl . '/index.php?action=admin;area=logs;sa=badbehaviorlog" /> [' . $txt['badbehavior_details'] . ']</a>';
- // Current whitelist data
- $whitelist = array('badbehavior_ip_wl', 'badbehavior_useragent_wl', 'badbehavior_url_wl');
- foreach ($whitelist as $list)
- {
- $context[$list] = array();
- $context[$list . '_desc'] = array();
- if (!empty($modSettings[$list]))
- $context[$list] = unserialize($modSettings[$list]);
- if (!empty($modSettings[$list . '_desc']))
- $context[$list . '_desc'] = unserialize($modSettings[$list . '_desc']);
- }
- // Build up our options array
- $config_vars = array(
- array('title', 'badbehavior_title'),
- array('desc', 'badbehavior_desc'),
- array('check', 'badbehavior_enabled', 'postinput' => $txt['badbehavior_enabled_desc']),
- array('check', 'badbehavior_logging', 'postinput' => $txt['badbehavior_default_on']),
- array('check', 'badbehavior_verbose', 'postinput' => $txt['badbehavior_default_off']),
- array('check', 'badbehavior_strict', 'postinput' => $txt['badbehavior_default_off']),
- array('check', 'badbehavior_offsite_forms', 'postinput' => $txt['badbehavior_default_off']),
- array('check', 'badbehavior_eucookie', 'postinput' => $txt['badbehavior_default_off']),
- array('check', 'badbehavior_display_stats', 'postinput' => $txt['badbehavior_default_off']),
- '',
- array('check', 'badbehavior_reverse_proxy', 'postinput' => $txt['badbehavior_default_off']),
- array('text', 'badbehavior_reverse_proxy_header', 30, 'postinput' => $txt['badbehavior_reverse_proxy_header_desc']),
- array('text', 'badbehavior_reverse_proxy_addresses', 30),
- '',
- array('text', 'badbehavior_httpbl_key', 12, 'invalid' => $context['invalid_badbehavior_httpbl_key']),
- array('int', 'badbehavior_httpbl_threat', 'postinput' => $txt['badbehavior_httpbl_threat_desc']),
- array('int', 'badbehavior_httpbl_maxage', 'postinput' => $txt['badbehavior_httpbl_maxage_desc']),
- array('title', 'badbehavior_whitelist_title'),
- array('desc', 'badbehavior_wl_desc'),
- array('int', 'badbehavior_postcount_wl', 'postinput' => $txt['badbehavior_postcount_wl_desc']),
- array('callback', 'badbehavior_add_ip'),
- array('callback', 'badbehavior_add_url'),
- array('callback', 'badbehavior_add_useragent'),
- );
- if ($return_config)
- return $config_vars;
- // Saving?
- if (isset($_GET['save']))
- {
- checkSession();
- // Make sure Bad Behavior defaults are set if nothing was specified
- $_POST['badbehavior_httpbl_threat'] = empty($_POST['badbehavior_httpbl_threat']) ? 25 : $_POST['badbehavior_httpbl_threat'];
- $_POST['badbehavior_httpbl_maxage'] = empty($_POST['badbehavior_httpbl_maxage']) ? 30 : $_POST['badbehavior_httpbl_maxage'];
- $_POST['badbehavior_reverse_proxy_header'] = empty($_POST['badbehavior_reverse_proxy_header']) ? 'X-Forwarded-For' : $_POST['badbehavior_reverse_proxy_header'];
- // Build up the whitelist options
- foreach ($whitelist as $list)
- {
- $this_list = array();
- $this_desc = array();
- if (isset($_POST[$list]))
- {
- // clear blanks from the data field, only grab the comments that don't have blank data value
- $this_list = array_map('trim', array_filter($_POST[$list]));
- $this_desc = array_intersect_key($_POST[$list . '_desc'], $this_list);
- }
- updateSettings(array($list => serialize($this_list), $list . '_desc' => serialize($this_desc)));
- }
- saveDBSettings($config_vars);
- redirectexit('action=admin;area=securitysettings;sa=badbehavior');
- }
- $context['post_url'] = $scripturl . '?action=admin;area=securitysettings;save;sa=badbehavior';
- // javascript vars for the "add more xyz" buttons in the callback forms
- addInlineJavascript('
- var sUrlParent = \'add_more_url_placeholder\';
- var oUrlOptionsdt = {name: \'badbehavior_url_wl_desc[]\', class: \'input_text\'};
- var oUrlOptionsdd = {name: \'badbehavior_url_wl[]\', class: \'input_text\'};
- var sUseragentParent = \'add_more_useragent_placeholder\';
- var oUseragentOptionsdt = {name: \'badbehavior_useragent_wl_desc[]\', class: \'input_text\'};
- var oUseragentOptionsdd = {name: \'badbehavior_useragent_wl[]\', class: \'input_text\'};
- var sIpParent = \'add_more_ip_placeholder\';
- var oIpOptionsdt = {name: \'badbehavior_ip_wl_desc[]\', class: \'input_text\'};
- var oIpOptionsdd = {name: \'badbehavior_ip_wl[]\', class: \'input_text\'};'
- );
- prepareDBSettingContext($config_vars);
- }
- /**
- * You'll never guess what this function does...
- *
- * @param $return_config
- */
- function ModifySignatureSettings($return_config = false)
- {
- global $context, $txt, $modSettings, $sig_start, $smcFunc, $helptxt, $scripturl;
- $config_vars = array(
- // Are signatures even enabled?
- array('check', 'signature_enable'),
- '',
- // Tweaking settings!
- array('int', 'signature_max_length', 'subtext' => $txt['zero_for_no_limit']),
- array('int', 'signature_max_lines', 'subtext' => $txt['zero_for_no_limit']),
- array('int', 'signature_max_font_size', 'subtext' => $txt['zero_for_no_limit']),
- array('check', 'signature_allow_smileys', 'onclick' => 'document.getElementById(\'signature_max_smileys\').disabled = !this.checked;'),
- array('int', 'signature_max_smileys', 'subtext' => $txt['zero_for_no_limit']),
- '',
- // Image settings.
- array('int', 'signature_max_images', 'subtext' => $txt['signature_max_images_note']),
- array('int', 'signature_max_image_width', 'subtext' => $txt['zero_for_no_limit']),
- array('int', 'signature_max_image_height', 'subtext' => $txt['zero_for_no_limit']),
- '',
- array('bbc', 'signature_bbc'),
- );
- call_integration_hook('integrate_signature_settings', array($config_vars));
- if ($return_config)
- return $config_vars;
- // Setup the template.
- $context['page_title'] = $txt['signature_settings'];
- $context['sub_template'] = 'show_settings';
- // Disable the max smileys option if we don't allow smileys at all!
- $context['settings_post_javascript'] = 'document.getElementById(\'signature_max_smileys\').disabled = !document.getElementById(\'signature_allow_smileys\').checked;';
- // Load all the signature settings.
- list ($sig_limits, $sig_bbc) = explode(':', $modSettings['signature_settings']);
- $sig_limits = explode(',', $sig_limits);
- $disabledTags = !empty($sig_bbc) ? explode(',', $sig_bbc) : array();
- // Applying to ALL signatures?!!
- if (isset($_GET['apply']))
- {
- // Security!
- checkSession('get');
- $sig_start = time();
- // This is horrid - but I suppose some people will want the option to do it.
- $_GET['step'] = isset($_GET['step']) ? (int) $_GET['step'] : 0;
- $done = false;
- $request = $smcFunc['db_query']('', '
- SELECT MAX(id_member)
- FROM {db_prefix}members',
- array(
- )
- );
- list ($context['max_member']) = $smcFunc['db_fetch_row']($request);
- $smcFunc['db_free_result']($request);
- while (!$done)
- {
- $changes = array();
- $request = $smcFunc['db_query']('', '
- SELECT id_member, signature
- FROM {db_prefix}members
- WHERE id_member BETWEEN ' . $_GET['step'] . ' AND ' . $_GET['step'] . ' + 49
- AND id_group != {int:admin_group}
- AND FIND_IN_SET({int:admin_group}, additional_groups) = 0',
- array(
- 'admin_group' => 1,
- )
- );
- while ($row = $smcFunc['db_fetch_assoc']($request))
- {
- // Apply all the rules we can realistically do.
- $sig = strtr($row['signature'], array('<br />' => "\n"));
- // Max characters...
- if (!empty($sig_limits[1]))
- $sig = $smcFunc['substr']($sig, 0, $sig_limits[1]);
- // Max lines...
- if (!empty($sig_limits[2]))
- {
- $count = 0;
- for ($i = 0; $i < strlen($sig); $i++)
- {
- if ($sig[$i] == "\n")
- {
- $count++;
- if ($count >= $sig_limits[2])
- $sig = substr($sig, 0, $i) . strtr(substr($sig, $i), array("\n" => ' '));
- }
- }
- }
- if (!empty($sig_limits[7]) && preg_match_all('~\[size=([\d\.]+)?(px|pt|em|x-large|larger)~i', $sig, $matches) !== false && isset($matches[2]))
- {
- foreach ($matches[1] as $ind => $size)
- {
- $limit_broke = 0;
- // Attempt to allow all sizes of abuse, so to speak.
- if ($matches[2][$ind] == 'px' && $size > $sig_limits[7])
- $limit_broke = $sig_limits[7] . 'px';
- elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75))
- $limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt';
- elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16))
- $limit_broke = ((float) $sig_limits[7] / 16) . 'em';
- elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18)
- $limit_broke = 'large';
- if ($limit_broke)
- $sig = str_replace($matches[0][$ind], '[size=' . $sig_limits[7] . 'px', $sig);
- }
- }
- // Stupid images - this is stupidly, stupidly challenging.
- if ((!empty($sig_limits[3]) || !empty($sig_limits[5]) || !empty($sig_limits[6])))
- {
- $replaces = array();
- $img_count = 0;
- // Get all BBC tags...
- preg_match_all('~\[img(\s+width=([\d]+))?(\s+height=([\d]+))?(\s+width=([\d]+))?\s*\](?:<br />)*([^<">]+?)(?:<br />)*\[/img\]~i', $sig, $matches);
- // ... and all HTML ones.
- preg_match_all('~<img\s+src=(?:")?((?:http://|ftp://|https://|ftps://).+?)(?:")?(?:\s+alt=(?:")?(.*?)(?:")?)?(?:\s?/)?>~i', $sig, $matches2, PREG_PATTERN_ORDER);
- // And stick the HTML in the BBC.
- if (!empty($matches2))
- {
- foreach ($matches2[0] as $ind => $dummy)
- {
- $matches[0][] = $matches2[0][$ind];
- $matches[1][] = '';
- $matches[2][] = '';
- $matches[3][] = '';
- $matches[4][] = '';
- $matches[5][] = '';
- $matches[6][] = '';
- $matches[7][] = $matches2[1][$ind];
- }
- }
- // Try to find all the images!
- if (!empty($matches))
- {
- $image_count_holder = array();
- foreach ($matches[0] as $key => $image)
- {
- $width = -1; $height = -1;
- $img_count++;
- // Too many images?
- if (!empty($sig_limits[3]) && $img_count > $sig_limits[3])
- {
- // If we've already had this before we only want to remove the excess.
- if (isset($image_count_holder[$image]))
- {
- $img_offset = -1;
- $rep_img_count = 0;
- while ($img_offset !== false)
- {
- $img_offset = strpos($sig, $image, $img_offset + 1);
- $rep_img_count++;
- if ($rep_img_count > $image_count_holder[$image])
- {
- // Only replace the excess.
- $sig = substr($sig, 0, $img_offset) . str_replace($image, '', substr($sig, $img_offset));
- // Stop looping.
- $img_offset = false;
- }
- }
- }
- else
- $replaces[$image] = '';
- continue;
- }
- // Does it have predefined restraints? Width first.
- if ($matches[6][$key])
- $matches[2][$key] = $matches[6][$key];
- if ($matches[2][$key] && $sig_limits[5] && $matches[2][$key] > $sig_limits[5])
- {
- $width = $sig_limits[5];
- $matches[4][$key] = $matches[4][$key] * ($width / $matches[2][$key]);
- }
- elseif ($matches[2][$key])
- $width = $matches[2][$key];
- // ... and height.
- if ($matches[4][$key] && $sig_limits[6] && $matches[4][$key] > $sig_limits[6])
- {
- $height = $sig_limits[6];
- if ($width != -1)
- $width = $width * ($height / $matches[4][$key]);
- }
- elseif ($matches[4][$key])
- $height = $matches[4][$key];
- // If the dimensions are still not fixed - we need to check the actual image.
- if (($width == -1 && $sig_limits[5]) || ($height == -1 && $sig_limits[6]))
- {
- // We'll mess up with images, who knows.
- require_once(SUBSDIR . '/Attachments.subs.php');
- $sizes = url_image_size($matches[7][$key]);
- if (is_array($sizes))
- {
- // Too wide?
- if ($sizes[0] > $sig_limits[5] && $sig_limits[5])
- {
- $width = $sig_limits[5];
- $sizes[1] = $sizes[1] * ($width / $sizes[0]);
- }
- // Too high?
- if ($sizes[1] > $sig_limits[6] && $sig_limits[6])
- {
- $height = $sig_limits[6];
- if ($width == -1)
- $width = $sizes[0];
- $width = $width * ($height / $sizes[1]);
- }
- elseif ($width != -1)
- $height = $sizes[1];
- }
- }
- // Did we come up with some changes? If so remake the string.
- if ($width != -1 || $height != -1)
- {
- $replaces[$image] = '[img' . ($width != -1 ? ' width=' . round($width) : '') . ($height != -1 ? ' height=' . round($height) : '') . ']' . $matches[7][$key] . '[/img]';
- }
- // Record that we got one.
- $image_count_holder[$image] = isset($image_count_holder[$image]) ? $image_count_holder[$image] + 1 : 1;
- }
- if (!empty($replaces))
- $sig = str_replace(array_keys($replaces), array_values($replaces), $sig);
- }
- }
- // Try to fix disabled tags.
- if (!empty($disabledTags))
- {
- $sig = preg_replace('~\[(?:' . implode('|', $disabledTags) . ').+?\]~i', '', $sig);
- $sig = preg_replace('~\[/(?:' . implode('|', $disabledTags) . ')\]~i', '', $sig);
- }
- $sig = strtr($sig, array("\n" => '<br />'));
- call_integration_hook('integrate_apply_signature_settings', array($sig, $sig_limits, $disabledTags));
- if ($sig != $row['signature'])
- $changes[$row['id_member']] = $sig;
- }
- if ($smcFunc['db_num_rows']($request) == 0)
- $done = true;
- $smcFunc['db_free_result']($request);
- // Do we need to delete what we have?
- if (!empty($changes))
- {
- foreach ($changes as $id => $sig)
- $smcFunc['db_query']('', '
- UPDATE {db_prefix}members
- SET signature = {string:signature}
- WHERE id_member = {int:id_member}',
- array(
- 'id_member' => $id,
- 'signature' => $sig,
- )
- );
- }
- $_GET['step'] += 50;
- if (!$done)
- pauseSignatureApplySettings();
- }
- $settings_applied = true;
- }
- $context['signature_settings'] = array(
- 'enable' => isset($sig_limits[0]) ? $sig_limits[0] : 0,
- 'max_length' => isset($sig_limits[1]) ? $sig_limits[1] : 0,
- 'max_lines' => isset($sig_limits[2]) ? $sig_limits[2] : 0,
- 'max_images' => isset($sig_limits[3]) ? $sig_limits[3] : 0,
- 'allow_smileys' => isset($sig_limits[4]) && $sig_limits[4] == -1 ? 0 : 1,
- 'max_smileys' => isset($sig_limits[4]) && $sig_limits[4] != -1 ? $sig_limits[4] : 0,
- 'max_image_width' => isset($sig_limits[5]) ? $sig_limits[5] : 0,
- 'max_image_height' => isset($sig_limits[6]) ? $sig_limits[6] : 0,
- 'max_font_size' => isset($sig_limits[7]) ? $sig_limits[7] : 0,
- );
- // Temporarily make each setting a modSetting!
- foreach ($context['signature_settings'] as $key => $value)
- $modSettings['signature_' . $key] = $value;
- // Make sure we check the right tags!
- $modSettings['bbc_disabled_signature_bbc'] = $disabledTags;
- // Saving?
- if (isset($_GET['save']))
- {
- checkSession();
- // Clean up the tag stuff!
- $bbcTags = array();
- foreach (parse_bbc(false) as $tag)
- $bbcTags[] = $tag['tag'];
- if (!isset($_POST['signature_bbc_enabledTags']))
- $_POST['signature_bbc_enabledTags'] = array();
- elseif (!is_array($_POST['signature_bbc_enabledTags']))
- $_POST['signature_bbc_enabledTags'] = array($_POST['signature_bbc_enabledTags']);
- $sig_limits = array();
- foreach ($context['signature_settings'] as $key => $value)
- {
- if ($key == 'allow_smileys')
- continue;
- elseif ($key == 'max_smileys' && empty($_POST['signature_allow_smileys']))
- $sig_limits[] = -1;
- else
- $sig_limits[] = !empty($_POST['signature_' . $key]) ? max(1, (int) $_POST['signature_' . $key]) : 0;
- }
- call_integration_hook('integrate_save_signature_settings', array($sig_limits, $bbcTags));
- $_POST['signature_settings'] = implode(',', $sig_limits) . ':' . implode(',', array_diff($bbcTags, $_POST['signature_bbc_enabledTags']));
- // Even though we have practically no settings l…
Large files files are truncated, but you can click here to view the full file