function ModifyLanguageSettings($return_config = false) { global $scripturl, $context, $txt, $boarddir, $settings, $smcFunc; // Warn the user if the backup of Settings.php failed. $settings_not_writable = !is_writable($boarddir . '/Settings.php'); $settings_backup_fail = !@is_writable($boarddir . '/Settings_bak.php') || !@copy($boarddir . '/Settings.php', $boarddir . '/Settings_bak.php'); /* If you're writing a mod, it's a bad idea to add things here.... For each option: variable name, description, type (constant), size/possible values, helptext. OR an empty string for a horizontal rule. OR a string for a titled section. */ $config_vars = array('language' => array('language', $txt['default_language'], 'file', 'select', array(), null, 'disabled' => $settings_not_writable), array('userLanguage', $txt['userLanguage'], 'db', 'check', null, 'userLanguage')); if ($return_config) { return $config_vars; } // Get our languages. No cache and use utf8. getLanguages(false, false); foreach ($context['languages'] as $lang) { $config_vars['language'][4][$lang['filename']] = array($lang['filename'], strtr($lang['name'], array('-utf8' => ' (UTF-8)'))); } // Saving settings? if (isset($_REQUEST['save'])) { checkSession(); saveSettings($config_vars); redirectexit('action=admin;area=languages;sa=settings'); } // Setup the template stuff. $context['post_url'] = $scripturl . '?action=admin;area=languages;sa=settings;save'; $context['settings_title'] = $txt['language_settings']; $context['save_disabled'] = $settings_not_writable; if ($settings_not_writable) { $context['settings_message'] = '<div class="centertext"><strong>' . $txt['settings_not_writable'] . '</strong></div><br />'; } elseif ($settings_backup_fail) { $context['settings_message'] = '<div class="centertext"><strong>' . $txt['admin_backup_fail'] . '</strong></div><br />'; } // Fill the config array. prepareServerSettingsContext($config_vars); }
/** * Simply modifying cache functions * * @param bool $return_config = false */ function ModifyCacheSettings($return_config = false) { global $context, $scripturl, $txt, $helptxt, $cache_enable; // Detect all available optimizers $detected = array(); if (function_exists('eaccelerator_put')) { $detected['eaccelerator'] = $txt['eAccelerator_cache']; } if (function_exists('mmcache_put')) { $detected['mmcache'] = $txt['mmcache_cache']; } if (function_exists('apc_store')) { $detected['apc'] = $txt['apc_cache']; } if (function_exists('output_cache_put') || function_exists('zend_shm_cache_store')) { $detected['zend'] = $txt['zend_cache']; } if (function_exists('memcache_set') || function_exists('memcached_set')) { $detected['memcached'] = $txt['memcached_cache']; } if (function_exists('xcache_set')) { $detected['xcache'] = $txt['xcache_cache']; } // set a message to show what, if anything, we found if (empty($detected)) { $txt['cache_settings_message'] = $txt['detected_no_caching']; } else { $txt['cache_settings_message'] = sprintf($txt['detected_accelerators'], implode(', ', $detected)); } // This is always an option $detected['smf'] = $txt['default_cache']; // Define the variables we want to edit. $config_vars = array(array('', $txt['cache_settings_message'], '', 'desc'), array('cache_enable', $txt['cache_enable'], 'file', 'select', array($txt['cache_off'], $txt['cache_level1'], $txt['cache_level2'], $txt['cache_level3']), 'cache_enable'), array('cache_accelerator', $txt['cache_accelerator'], 'file', 'select', $detected), array('cache_memcached', $txt['cache_memcached'], 'file', 'text', $txt['cache_memcached'], 'cache_memcached'), array('cachedir', $txt['cachedir'], 'file', 'text', 36, 'cache_cachedir')); // some javascript to enable / disable certain settings if the option is not selected $context['settings_post_javascript'] = ' var cache_type = document.getElementById(\'cache_accelerator\'); createEventListener(cache_type); cache_type.addEventListener("change", toggleCache); toggleCache();'; call_integration_hook('integrate_modify_cache_settings', array(&$config_vars)); if ($return_config) { return $config_vars; } // Saving again? if (isset($_GET['save'])) { call_integration_hook('integrate_save_cache_settings'); saveSettings($config_vars); // we need to save the $cache_enable to $modSettings as well updatesettings(array('cache_enable' => (int) $_POST['cache_enable'])); // exit so we reload our new settings on the page redirectexit('action=admin;area=serversettings;sa=cache;' . $context['session_var'] . '=' . $context['session_id']); } // if its off, allow them to clear it as well // @todo why only when its off ? if (empty($cache_enable)) { loadLanguage('ManageMaintenance'); createToken('admin-maint'); $context['template_layers'][] = 'clean_cache_button'; } $context['post_url'] = $scripturl . '?action=admin;area=serversettings;sa=cache;save'; $context['settings_title'] = $txt['caching_settings']; $context['settings_message'] = $txt['caching_information']; // Prepare the template. createToken('admin-ssc'); prepareServerSettingsContext($config_vars); }