function reloadSettings() { global $modSettings, $sourcedir, $boardurl, $cachedir; $no_hooks = isset($GLOBALS['g_disable_all_hooks']) && $GLOBALS['g_disable_all_hooks'] === true; CacheAPI::init($GLOBALS['db_cache_api'], md5($boardurl . filemtime($sourcedir . '/Load.php')) . '-SMF-', $GLOBALS['db_cache_memcached'], $cachedir); // Most database systems have not set UTF-8 as their default input charset. smf_db_query(' SET NAMES utf8', array()); // Try to load it from the cache first; it'll never get cached if the setting is off. if (($modSettings = CacheAPI::getCache('modSettings', 600)) == null) { $request = smf_db_query(' SELECT variable, value FROM {db_prefix}settings', array()); $modSettings = array(); if (!$request) { db_fatal_error(); } while ($row = mysql_fetch_row($request)) { $modSettings[$row[0]] = $row[1]; } mysql_free_result($request); // Do a few things to protect against missing settings or settings with invalid values... if (empty($modSettings['defaultMaxTopics']) || $modSettings['defaultMaxTopics'] <= 0 || $modSettings['defaultMaxTopics'] > 999) { $modSettings['defaultMaxTopics'] = 20; } if (empty($modSettings['defaultMaxMessages']) || $modSettings['defaultMaxMessages'] <= 0 || $modSettings['defaultMaxMessages'] > 999) { $modSettings['defaultMaxMessages'] = 15; } if (empty($modSettings['defaultMaxMembers']) || $modSettings['defaultMaxMembers'] <= 0 || $modSettings['defaultMaxMembers'] > 999) { $modSettings['defaultMaxMembers'] = 30; } if (empty($modSettings['max_messageLength'])) { $modSettings['max_messageLength'] = 1024 * 1024; } // hard post length limit, 1M *should* be more than ever needed if (isset($modSettings['admin_features'])) { $_f = explode(',', $modSettings['admin_features']); $modSettings['postmod_active'] = in_array('pm', $_f); $modSettings['astream_active'] = in_array('as', $_f); $modSettings['tags_active'] = in_array('ts', $_f); } else { $modSettings['tags_active'] = $modSettings['postmod_active'] = $modSettings['astream_active'] = false; } $modSettings['hidden_content_no_view_msg'] = @unserialize($modSettings['hidden_content_no_view']); $modSettings['online_today'] = @unserialize($modSettings['log_online_today']); if (!empty($modSettings['cache_enable'])) { CacheAPI::putCache('modSettings', $modSettings, 600); } } if (empty($modSettings['cache_enable'])) { CacheAPI::disable(); } if ($no_hooks) { $modSettings['integration_hooks'] = ''; } HookAPI::setHooks($modSettings['integration_hooks']); // Setting the timezone is a requirement for some functions in PHP >= 5.1. date_default_timezone_set(isset($modSettings['default_timezone']) ? $modSettings['default_timezone'] : 'UTC'); // Check the load averages? if (!empty($modSettings['loadavg_enable'])) { if (($modSettings['load_average'] = CacheAPI::getCache('loadavg', 90)) == null) { $modSettings['load_average'] = @file_get_contents('/proc/loadavg'); if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) != 0) { $modSettings['load_average'] = (double) $matches[1]; } elseif (($modSettings['load_average'] = @`uptime`) != null && preg_match('~load average[s]?: (\\d+\\.\\d+), (\\d+\\.\\d+), (\\d+\\.\\d+)~i', $modSettings['load_average'], $matches) != 0) { $modSettings['load_average'] = (double) $matches[1]; } else { unset($modSettings['load_average']); } if (!empty($modSettings['load_average'])) { CacheAPI::putCache('loadavg', $modSettings['load_average'], 90); } } if (!empty($modSettings['loadavg_forum']) && !empty($modSettings['load_average']) && $modSettings['load_average'] >= $modSettings['loadavg_forum']) { db_fatal_error(true); } } require_once $sourcedir . '/SimpleSEF.php'; URL::init($boardurl); // Call pre load integration functions. HookAPI::callHook('pre_load'); SimpleSEF::convertQueryString(); }