ManageServer.php 38 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129
  1. <?php
  2. /**
  3. * Contains all the functionality required to be able to edit the core server
  4. * settings. This includes anything from which an error may result in the forum
  5. * destroying itself in a firey fury.
  6. *
  7. * Adding options to one of the setting screens isn't hard. Call prepareDBSettingsContext;
  8. * The basic format for a checkbox is:
  9. * array('check', 'nameInModSettingsAndSQL'),
  10. * And for a text box:
  11. * array('text', 'nameInModSettingsAndSQL')
  12. * (NOTE: You have to add an entry for this at the bottom!)
  13. *
  14. * In these cases, it will look for $txt['nameInModSettingsAndSQL'] as the description,
  15. * and $helptxt['nameInModSettingsAndSQL'] as the help popup description.
  16. *
  17. * Here's a quick explanation of how to add a new item:
  18. *
  19. * - A text input box. For textual values.
  20. * array('text', 'nameInModSettingsAndSQL', 'OptionalInputBoxWidth'),
  21. * - A text input box. For numerical values.
  22. * array('int', 'nameInModSettingsAndSQL', 'OptionalInputBoxWidth'),
  23. * - A text input box. For floating point values.
  24. * array('float', 'nameInModSettingsAndSQL', 'OptionalInputBoxWidth'),
  25. * - A large text input box. Used for textual values spanning multiple lines.
  26. * array('large_text', 'nameInModSettingsAndSQL', 'OptionalNumberOfRows'),
  27. * - A check box. Either one or zero. (boolean)
  28. * array('check', 'nameInModSettingsAndSQL'),
  29. * - A selection box. Used for the selection of something from a list.
  30. * array('select', 'nameInModSettingsAndSQL', array('valueForSQL' => $txt['displayedValue'])),
  31. * Note that just saying array('first', 'second') will put 0 in the SQL for 'first'.
  32. * - A password input box. Used for passwords, no less!
  33. * array('password', 'nameInModSettingsAndSQL', 'OptionalInputBoxWidth'),
  34. * - A permission - for picking groups who have a permission.
  35. * array('permissions', 'manage_groups'),
  36. * - A BBC selection box.
  37. * array('bbc', 'sig_bbc'),
  38. * - A list of boards to choose from
  39. * array('boards', 'likes_boards'),
  40. * Note that the storage in the database is as 1,2,3,4
  41. *
  42. * For each option:
  43. * - type (see above), variable name, size/possible values.
  44. * OR make type '' for an empty string for a horizontal rule.
  45. * - SET preinput - to put some HTML prior to the input box.
  46. * - SET postinput - to put some HTML following the input box.
  47. * - SET invalid - to mark the data as invalid.
  48. * - PLUS you can override label and help parameters by forcing their keys in the array, for example:
  49. * array('text', 'invalidlabel', 3, 'label' => 'Actual Label')
  50. *
  51. * Simple Machines Forum (SMF)
  52. *
  53. * @package SMF
  54. * @author Simple Machines http://www.simplemachines.org
  55. * @copyright 2013 Simple Machines and individual contributors
  56. * @license http://www.simplemachines.org/about/smf/license.php BSD
  57. *
  58. * @version 2.1 Alpha 1
  59. */
  60. if (!defined('SMF'))
  61. die('No direct access...');
  62. /**
  63. * This is the main dispatcher. Sets up all the available sub-actions, all the tabs and selects
  64. * the appropriate one based on the sub-action.
  65. *
  66. * Requires the admin_forum permission.
  67. * Redirects to the appropriate function based on the sub-action.
  68. *
  69. * @uses edit_settings adminIndex.
  70. */
  71. function ModifySettings()
  72. {
  73. global $context, $txt, $scripturl, $boarddir;
  74. // This is just to keep the database password more secure.
  75. isAllowedTo('admin_forum');
  76. // Load up all the tabs...
  77. $context[$context['admin_menu_name']]['tab_data'] = array(
  78. 'title' => $txt['admin_server_settings'],
  79. 'help' => 'serversettings',
  80. 'description' => $txt['admin_basic_settings'],
  81. );
  82. checkSession('request');
  83. // The settings are in here, I swear!
  84. loadLanguage('ManageSettings');
  85. $context['page_title'] = $txt['admin_server_settings'];
  86. $context['sub_template'] = 'show_settings';
  87. $subActions = array(
  88. 'general' => 'ModifyGeneralSettings',
  89. 'database' => 'ModifyDatabaseSettings',
  90. 'cookie' => 'ModifyCookieSettings',
  91. 'security' => 'ModifyGeneralSecuritySettings',
  92. 'cache' => 'ModifyCacheSettings',
  93. 'loads' => 'ModifyLoadBalancingSettings',
  94. 'phpinfo' => 'ShowPHPinfoSettings',
  95. );
  96. call_integration_hook('integrate_server_settings', array(&$subActions));
  97. // By default we're editing the core settings
  98. $_REQUEST['sa'] = isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]) ? $_REQUEST['sa'] : 'general';
  99. $context['sub_action'] = $_REQUEST['sa'];
  100. // Any messages to speak of?
  101. $context['settings_message'] = (isset($_REQUEST['msg']) && isset($txt[$_REQUEST['msg']])) ? $txt[$_REQUEST['msg']] : '';
  102. // Warn the user if there's any relevant information regarding Settings.php.
  103. if ($_REQUEST['sa'] != 'cache')
  104. {
  105. // Warn the user if the backup of Settings.php failed.
  106. $settings_not_writable = !is_writable($boarddir . '/Settings.php');
  107. $settings_backup_fail = !@is_writable($boarddir . '/Settings_bak.php') || !@copy($boarddir . '/Settings.php', $boarddir . '/Settings_bak.php');
  108. if ($settings_not_writable)
  109. $context['settings_message'] = '<div class="centertext"><strong>' . $txt['settings_not_writable'] . '</strong></div><br />';
  110. elseif ($settings_backup_fail)
  111. $context['settings_message'] = '<div class="centertext"><strong>' . $txt['admin_backup_fail'] . '</strong></div><br />';
  112. $context['settings_not_writable'] = $settings_not_writable;
  113. }
  114. // Call the right function for this sub-action.
  115. $subActions[$_REQUEST['sa']]();
  116. }
  117. /**
  118. * General forum settings - forum name, maintenance mode, etc.
  119. * Practically, this shows an interface for the settings in Settings.php to be changed.
  120. *
  121. * - It uses the rawdata sub template (not theme-able.)
  122. * - Requires the admin_forum permission.
  123. * - Uses the edit_settings administration area.
  124. * - Contains the actual array of settings to show from Settings.php.
  125. * - Accessed from ?action=admin;area=serversettings;sa=general.
  126. *
  127. * @param $return_config
  128. */
  129. function ModifyGeneralSettings($return_config = false)
  130. {
  131. global $scripturl, $context, $txt;
  132. /* If you're writing a mod, it's a bad idea to add things here....
  133. For each option:
  134. variable name, description, type (constant), size/possible values, helptext.
  135. OR an empty string for a horizontal rule.
  136. OR a string for a titled section. */
  137. $config_vars = array(
  138. array('mbname', $txt['admin_title'], 'file', 'text', 30),
  139. '',
  140. array('maintenance', $txt['admin_maintain'], 'file', 'check'),
  141. array('mtitle', $txt['maintenance_subject'], 'file', 'text', 36),
  142. array('mmessage', $txt['maintenance_message'], 'file', 'text', 36),
  143. '',
  144. array('webmaster_email', $txt['admin_webmaster_email'], 'file', 'text', 30),
  145. '',
  146. array('enableCompressedOutput', $txt['enableCompressedOutput'], 'db', 'check', null, 'enableCompressedOutput'),
  147. array('disableTemplateEval', $txt['disableTemplateEval'], 'db', 'check', null, 'disableTemplateEval'),
  148. array('disableHostnameLookup', $txt['disableHostnameLookup'], 'db', 'check', null, 'disableHostnameLookup'),
  149. );
  150. call_integration_hook('integrate_general_settings', array(&$config_vars));
  151. if ($return_config)
  152. return $config_vars;
  153. // Setup the template stuff.
  154. $context['post_url'] = $scripturl . '?action=admin;area=serversettings;sa=general;save';
  155. $context['settings_title'] = $txt['general_settings'];
  156. // Saving settings?
  157. if (isset($_REQUEST['save']))
  158. {
  159. call_integration_hook('integrate_save_general_settings');
  160. saveSettings($config_vars);
  161. redirectexit('action=admin;area=serversettings;sa=general;' . $context['session_var'] . '=' . $context['session_id']. ';msg=' . (!empty($context['settings_message']) ? $context['settings_message'] : 'core_settings_saved'));
  162. }
  163. // Fill the config array.
  164. prepareServerSettingsContext($config_vars);
  165. }
  166. /**
  167. * Basic database and paths settings - database name, host, etc.
  168. *
  169. * - It shows an interface for the settings in Settings.php to be changed.
  170. * - It contains the actual array of settings to show from Settings.php.
  171. * - It uses the rawdata sub template (not theme-able.)
  172. * - Requires the admin_forum permission.
  173. * - Uses the edit_settings administration area.
  174. * - Accessed from ?action=admin;area=serversettings;sa=database.
  175. *
  176. * @param $return_config
  177. */
  178. function ModifyDatabaseSettings($return_config = false)
  179. {
  180. global $scripturl, $context, $settings, $txt, $boarddir;
  181. /* If you're writing a mod, it's a bad idea to add things here....
  182. For each option:
  183. variable name, description, type (constant), size/possible values, helptext.
  184. OR an empty string for a horizontal rule.
  185. OR a string for a titled section. */
  186. $config_vars = array(
  187. array('db_persist', $txt['db_persist'], 'file', 'check', null, 'db_persist'),
  188. array('db_error_send', $txt['db_error_send'], 'file', 'check'),
  189. array('ssi_db_user', $txt['ssi_db_user'], 'file', 'text', null, 'ssi_db_user'),
  190. array('ssi_db_passwd', $txt['ssi_db_passwd'], 'file', 'password'),
  191. '',
  192. array('autoFixDatabase', $txt['autoFixDatabase'], 'db', 'check', false, 'autoFixDatabase'),
  193. array('autoOptMaxOnline', $txt['autoOptMaxOnline'], 'subtext' => $txt['zero_for_no_limit'], 'db', 'int'),
  194. '',
  195. array('cachedir', $txt['cachedir'], 'file', 'text', 36),
  196. );
  197. call_integration_hook('integrate_database_settings', array(&$config_vars));
  198. if ($return_config)
  199. return $config_vars;
  200. // Setup the template stuff.
  201. $context['post_url'] = $scripturl . '?action=admin;area=serversettings;sa=database;save';
  202. $context['settings_title'] = $txt['database_paths_settings'];
  203. $context['save_disabled'] = $context['settings_not_writable'];
  204. // Saving settings?
  205. if (isset($_REQUEST['save']))
  206. {
  207. call_integration_hook('integrate_save_database_settings');
  208. saveSettings($config_vars);
  209. redirectexit('action=admin;area=serversettings;sa=database;' . $context['session_var'] . '=' . $context['session_id'] . ';msg=' . (!empty($context['settings_message']) ? $context['settings_message'] : 'core_settings_saved'));
  210. }
  211. // Fill the config array.
  212. prepareServerSettingsContext($config_vars);
  213. }
  214. /**
  215. * This function handles cookies settings modifications.
  216. *
  217. * @param bool $return_config = false
  218. */
  219. function ModifyCookieSettings($return_config = false)
  220. {
  221. global $context, $scripturl, $txt, $sourcedir, $modSettings, $cookiename, $user_settings, $boardurl;
  222. // Define the variables we want to edit.
  223. $config_vars = array(
  224. // Cookies...
  225. array('cookiename', $txt['cookie_name'], 'file', 'text', 20),
  226. array('cookieTime', $txt['cookieTime'], 'db', 'int', 'postinput' => $txt['minutes']),
  227. array('localCookies', $txt['localCookies'], 'db', 'check', false, 'localCookies'),
  228. array('globalCookies', $txt['globalCookies'], 'db', 'check', false, 'globalCookies'),
  229. array('globalCookiesDomain', $txt['globalCookiesDomain'], 'db', 'text', false, 'globalCookiesDomain'),
  230. array('secureCookies', $txt['secureCookies'], 'db', 'check', false, 'secureCookies', 'disabled' => !isset($_SERVER['HTTPS']) || !(strtolower($_SERVER['HTTPS']) == 'on' || strtolower($_SERVER['HTTPS']) == '1')),
  231. array('httponlyCookies', $txt['httponlyCookies'], 'db', 'check', false, 'httponlyCookies'),
  232. '',
  233. // Sessions
  234. array('databaseSession_enable', $txt['databaseSession_enable'], 'db', 'check', false, 'databaseSession_enable'),
  235. array('databaseSession_loose', $txt['databaseSession_loose'], 'db', 'check', false, 'databaseSession_loose'),
  236. array('databaseSession_lifetime', $txt['databaseSession_lifetime'], 'db', 'int', false, 'databaseSession_lifetime', 'postinput' => $txt['seconds']),
  237. );
  238. addInlineJavascript('
  239. function hideGlobalCookies()
  240. {
  241. var usingLocal = $("#localCookies").prop("checked");
  242. $("#setting_globalCookies").closest("dt").toggle(!usingLocal);
  243. $("#globalCookies").closest("dd").toggle(!usingLocal);
  244. var usingGlobal = !usingLocal && $("#globalCookies").prop("checked");
  245. $("#setting_globalCookiesDomain").closest("dt").toggle(usingGlobal);
  246. $("#globalCookiesDomain").closest("dd").toggle(usingGlobal);
  247. };
  248. hideGlobalCookies();
  249. $("#localCookies, #globalCookies").click(function() {
  250. hideGlobalCookies();
  251. });', true);
  252. call_integration_hook('integrate_cookie_settings', array(&$config_vars));
  253. if ($return_config)
  254. return $config_vars;
  255. $context['post_url'] = $scripturl . '?action=admin;area=serversettings;sa=cookie;save';
  256. $context['settings_title'] = $txt['cookies_sessions_settings'];
  257. // Saving settings?
  258. if (isset($_REQUEST['save']))
  259. {
  260. call_integration_hook('integrate_save_cookie_settings');
  261. // Local and global do not play nicely together.
  262. if (!empty($_POST['localCookies']) && empty($_POST['globalCookies']))
  263. unset ($_POST['globalCookies']);
  264. if (!empty($_POST['globalCookiesDomain']) && strpos($boardurl, $_POST['globalCookiesDomain']) === false)
  265. fatal_lang_error('invalid_cookie_domain', false);
  266. saveSettings($config_vars);
  267. // If the cookie name was changed, reset the cookie.
  268. if ($cookiename != $_POST['cookiename'])
  269. {
  270. $original_session_id = $context['session_id'];
  271. include_once($sourcedir . '/Subs-Auth.php');
  272. // Remove the old cookie.
  273. setLoginCookie(-3600, 0);
  274. // Set the new one.
  275. $cookiename = $_POST['cookiename'];
  276. setLoginCookie(60 * $modSettings['cookieTime'], $user_settings['id_member'], sha1($user_settings['passwd'] . $user_settings['password_salt']));
  277. redirectexit('action=admin;area=serversettings;sa=cookie;' . $context['session_var'] . '=' . $original_session_id, $context['server']['needs_login_fix']);
  278. }
  279. redirectexit('action=admin;area=serversettings;sa=cookie;' . $context['session_var'] . '=' . $context['session_id']. ';msg=' . (!empty($context['settings_message']) ? $context['settings_message'] : 'core_settings_saved'));
  280. }
  281. // Fill the config array.
  282. prepareServerSettingsContext($config_vars);
  283. }
  284. /**
  285. * Settings really associated with general security aspects.
  286. *
  287. * @param $return_config
  288. */
  289. function ModifyGeneralSecuritySettings($return_config = false)
  290. {
  291. global $txt, $scripturl, $context, $settings, $sc, $modSettings;
  292. $config_vars = array(
  293. array('int', 'failed_login_threshold'),
  294. array('int', 'loginHistoryDays'),
  295. '',
  296. array('check', 'securityDisable'),
  297. array('check', 'securityDisable_moderate'),
  298. '',
  299. // Reactive on email, and approve on delete
  300. array('check', 'send_validation_onChange'),
  301. array('check', 'approveAccountDeletion'),
  302. '',
  303. // Password strength.
  304. array('select', 'password_strength', array($txt['setting_password_strength_low'], $txt['setting_password_strength_medium'], $txt['setting_password_strength_high'])),
  305. array('check', 'enable_password_conversion'),
  306. '',
  307. // Reporting of personal messages?
  308. array('check', 'enableReportPM'),
  309. '',
  310. array('select', 'frame_security', array('SAMEORIGIN' => $txt['setting_frame_security_SAMEORIGIN'], 'DENY' => $txt['setting_frame_security_DENY'], 'DISABLE' => $txt['setting_frame_security_DISABLE'])),
  311. );
  312. call_integration_hook('integrate_general_security_settings', array(&$config_vars));
  313. if ($return_config)
  314. return $config_vars;
  315. // Saving?
  316. if (isset($_GET['save']))
  317. {
  318. saveDBSettings($config_vars);
  319. $_SESSION['adm-save'] = true;
  320. call_integration_hook('integrate_save_general_security_settings');
  321. writeLog();
  322. redirectexit('action=admin;area=serversettings;sa=security;' . $context['session_var'] . '=' . $context['session_id']);
  323. }
  324. $context['post_url'] = $scripturl . '?action=admin;area=serversettings;save;sa=security';
  325. $context['settings_title'] = $txt['security_settings'];
  326. prepareDBSettingContext($config_vars);
  327. }
  328. /**
  329. * Simply modifying cache functions
  330. *
  331. * @param bool $return_config = false
  332. */
  333. function ModifyCacheSettings($return_config = false)
  334. {
  335. global $context, $scripturl, $txt, $helptxt, $cache_enable;
  336. // Detect all available optimizers
  337. $detected = array();
  338. if (function_exists('apc_store'))
  339. $detected['apc'] = $txt['apc_cache'];
  340. if (function_exists('output_cache_put') || function_exists('zend_shm_cache_store'))
  341. $detected['zend'] = $txt['zend_cache'];
  342. if (function_exists('memcache_set') || function_exists('memcached_set'))
  343. $detected['memcached'] = $txt['memcached_cache'];
  344. if (function_exists('xcache_set'))
  345. $detected['xcache'] = $txt['xcache_cache'];
  346. if (function_exists('file_put_contents'))
  347. $detected['smf'] = $txt['default_cache'];
  348. // set our values to show what, if anything, we found
  349. if (empty($detected))
  350. {
  351. $txt['cache_settings_message'] = $txt['detected_no_caching'];
  352. $cache_level = array($txt['cache_off']);
  353. $detected['none'] = $txt['cache_off'];
  354. }
  355. else
  356. {
  357. $txt['cache_settings_message'] = sprintf($txt['detected_accelerators'], implode(', ', $detected));
  358. $cache_level = array($txt['cache_off'], $txt['cache_level1'], $txt['cache_level2'], $txt['cache_level3']);
  359. }
  360. // Define the variables we want to edit.
  361. $config_vars = array(
  362. // Only a few settings, but they are important
  363. array('', $txt['cache_settings_message'], '', 'desc'),
  364. array('cache_enable', $txt['cache_enable'], 'file', 'select', $cache_level, 'cache_enable'),
  365. array('cache_accelerator', $txt['cache_accelerator'], 'file', 'select', $detected),
  366. array('cache_memcached', $txt['cache_memcached'], 'file', 'text', $txt['cache_memcached'], 'cache_memcached'),
  367. array('cachedir', $txt['cachedir'], 'file', 'text', 36, 'cache_cachedir'),
  368. );
  369. // some javascript to enable / disable certain settings if the option is not selected
  370. $context['settings_post_javascript'] = '
  371. var cache_type = document.getElementById(\'cache_accelerator\');
  372. createEventListener(cache_type);
  373. cache_type.addEventListener("change", toggleCache);
  374. toggleCache();';
  375. call_integration_hook('integrate_modify_cache_settings', array(&$config_vars));
  376. if ($return_config)
  377. return $config_vars;
  378. // Saving again?
  379. if (isset($_GET['save']))
  380. {
  381. call_integration_hook('integrate_save_cache_settings');
  382. saveSettings($config_vars);
  383. // we need to save the $cache_enable to $modSettings as well
  384. updatesettings(array('cache_enable' => (int) $_POST['cache_enable']));
  385. // exit so we reload our new settings on the page
  386. redirectexit('action=admin;area=serversettings;sa=cache;' . $context['session_var'] . '=' . $context['session_id']);
  387. }
  388. loadLanguage('ManageMaintenance');
  389. createToken('admin-maint');
  390. $context['template_layers'][] = 'clean_cache_button';
  391. $context['post_url'] = $scripturl . '?action=admin;area=serversettings;sa=cache;save';
  392. $context['settings_title'] = $txt['caching_settings'];
  393. $context['settings_message'] = $txt['caching_information'];
  394. // Prepare the template.
  395. createToken('admin-ssc');
  396. prepareServerSettingsContext($config_vars);
  397. }
  398. /**
  399. * Allows to edit load balancing settings.
  400. *
  401. * @param bool $return_config = false
  402. */
  403. function ModifyLoadBalancingSettings($return_config = false)
  404. {
  405. global $txt, $scripturl, $context, $settings, $modSettings;
  406. // Setup a warning message, but disabled by default.
  407. $disabled = true;
  408. $context['settings_message'] = $txt['loadavg_disabled_conf'];
  409. if (stripos(PHP_OS, 'win') === 0)
  410. {
  411. $context['settings_message'] = $txt['loadavg_disabled_windows'];
  412. if (isset($_GET['save']))
  413. $_SESSION['adm-save'] = $txt['loadavg_disabled_windows'];
  414. }
  415. else
  416. {
  417. $modSettings['load_average'] = @file_get_contents('/proc/loadavg');
  418. if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) !== 0)
  419. $modSettings['load_average'] = (float) $matches[1];
  420. elseif (($modSettings['load_average'] = @`uptime`) !== null && preg_match('~load averages?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) !== 0)
  421. $modSettings['load_average'] = (float) $matches[1];
  422. else
  423. unset($modSettings['load_average']);
  424. if (!empty($modSettings['load_average']))
  425. {
  426. $context['settings_message'] = sprintf($txt['loadavg_warning'], $modSettings['load_average']);
  427. $disabled = false;
  428. }
  429. }
  430. // Start with a simple checkbox.
  431. $config_vars = array(
  432. array('check', 'loadavg_enable', 'disabled' => $disabled),
  433. );
  434. // Set the default values for each option.
  435. $default_values = array(
  436. 'loadavg_auto_opt' => '1.0',
  437. 'loadavg_search' => '2.5',
  438. 'loadavg_allunread' => '2.0',
  439. 'loadavg_unreadreplies' => '3.5',
  440. 'loadavg_show_posts' => '2.0',
  441. 'loadavg_userstats' => '10.0',
  442. 'loadavg_bbc' => '30.0',
  443. 'loadavg_forum' => '40.0',
  444. );
  445. // Loop through the settings.
  446. foreach ($default_values as $name => $value)
  447. {
  448. // Use the default value if the setting isn't set yet.
  449. $value = !isset($modSettings[$name]) ? $value : $modSettings[$name];
  450. $config_vars[] = array('text', $name, 'value' => $value, 'disabled' => $disabled);
  451. }
  452. call_integration_hook('integrate_loadavg_settings', array(&$config_vars));
  453. if ($return_config)
  454. return $config_vars;
  455. $context['post_url'] = $scripturl . '?action=admin;area=serversettings;sa=loads;save';
  456. $context['settings_title'] = $txt['load_balancing_settings'];
  457. // Saving?
  458. if (isset($_GET['save']))
  459. {
  460. // Stupidity is not allowed.
  461. foreach ($_POST as $key => $value)
  462. {
  463. if (strpos($key, 'loadavg') === 0 || $key === 'loadavg_enable')
  464. continue;
  465. elseif ($key == 'loadavg_auto_opt' && $value <= 1)
  466. $_POST['loadavg_auto_opt'] = '1.0';
  467. elseif ($key == 'loadavg_forum' && $value < 10)
  468. $_POST['loadavg_forum'] = '10.0';
  469. elseif ($value < 2)
  470. $_POST[$key] = '2.0';
  471. }
  472. call_integration_hook('integrate_save_loadavg_settings');
  473. saveDBSettings($config_vars);
  474. if (!isset($_SESSION['adm-save']))
  475. $_SESSION['adm-save'] = true;
  476. redirectexit('action=admin;area=serversettings;sa=loads;' . $context['session_var'] . '=' . $context['session_id']);
  477. }
  478. createToken('admin-ssc');
  479. createToken('admin-dbsc');
  480. prepareDBSettingContext($config_vars);
  481. }
  482. /**
  483. * Helper function, it sets up the context for the manage server settings.
  484. * - The basic usage of the six numbered key fields are
  485. * - array (0 ,1, 2, 3, 4, 5
  486. * 0 variable name - the name of the saved variable
  487. * 1 label - the text to show on the settings page
  488. * 2 saveto - file or db, where to save the variable name - value pair
  489. * 3 type - type of data to save, int, float, text, check
  490. * 4 size - false or field size
  491. * 5 help - '' or helptxt variable name
  492. * )
  493. *
  494. * the following named keys are also permitted
  495. * 'disabled' => 'postinput' => 'preinput' =>
  496. *
  497. * @param array $config_vars
  498. */
  499. function prepareServerSettingsContext(&$config_vars)
  500. {
  501. global $context, $modSettings, $smcFunc;
  502. if (isset($_SESSION['adm-save']))
  503. {
  504. if ($_SESSION['adm-save'] === true)
  505. $context['saved_successful'] = true;
  506. else
  507. $context['saved_failed'] = $_SESSION['adm-save'];
  508. unset($_SESSION['adm-save']);
  509. }
  510. $context['config_vars'] = array();
  511. foreach ($config_vars as $identifier => $config_var)
  512. {
  513. if (!is_array($config_var) || !isset($config_var[1]))
  514. $context['config_vars'][] = $config_var;
  515. else
  516. {
  517. $varname = $config_var[0];
  518. global $$varname;
  519. // Set the subtext in case it's part of the label.
  520. // @todo Temporary. Preventing divs inside label tags.
  521. $divPos = strpos($config_var[1], '<div');
  522. $subtext = '';
  523. if ($divPos !== false)
  524. {
  525. $subtext = preg_replace('~</?div[^>]*>~', '', substr($config_var[1], $divPos));
  526. $config_var[1] = substr($config_var[1], 0, $divPos);
  527. }
  528. $context['config_vars'][$config_var[0]] = array(
  529. 'label' => $config_var[1],
  530. 'help' => isset($config_var[5]) ? $config_var[5] : '',
  531. 'type' => $config_var[3],
  532. 'size' => empty($config_var[4]) ? 0 : $config_var[4],
  533. 'data' => isset($config_var[4]) && is_array($config_var[4]) && $config_var[3] != 'select' ? $config_var[4] : array(),
  534. 'name' => $config_var[0],
  535. 'value' => $config_var[2] == 'file' ? $smcFunc['htmlspecialchars']($$varname) : (isset($modSettings[$config_var[0]]) ? $smcFunc['htmlspecialchars']($modSettings[$config_var[0]]) : (in_array($config_var[3], array('int', 'float')) ? 0 : '')),
  536. 'disabled' => !empty($context['settings_not_writable']) || !empty($config_var['disabled']),
  537. 'invalid' => false,
  538. 'subtext' => !empty($config_var['subtext']) ? $config_var['subtext'] : $subtext,
  539. 'javascript' => '',
  540. 'preinput' => !empty($config_var['preinput']) ? $config_var['preinput'] : '',
  541. 'postinput' => !empty($config_var['postinput']) ? $config_var['postinput'] : '',
  542. );
  543. // If this is a select box handle any data.
  544. if (!empty($config_var[4]) && is_array($config_var[4]))
  545. {
  546. // If it's associative
  547. $config_values = array_values($config_var[4]);
  548. if (isset($config_values[0]) && is_array($config_values[0]))
  549. $context['config_vars'][$config_var[0]]['data'] = $config_var[4];
  550. else
  551. {
  552. foreach ($config_var[4] as $key => $item)
  553. $context['config_vars'][$config_var[0]]['data'][] = array($key, $item);
  554. }
  555. }
  556. }
  557. }
  558. // Two tokens because saving these settings requires both saveSettings and saveDBSettings
  559. createToken('admin-ssc');
  560. createToken('admin-dbsc');
  561. }
  562. /**
  563. * Helper function, it sets up the context for database settings.
  564. * @todo see rev. 10406 from 2.1-requests
  565. *
  566. * @param array $config_vars
  567. */
  568. function prepareDBSettingContext(&$config_vars)
  569. {
  570. global $txt, $helptxt, $context, $modSettings, $sourcedir, $smcFunc;
  571. loadLanguage('Help');
  572. if (isset($_SESSION['adm-save']))
  573. {
  574. if ($_SESSION['adm-save'] === true)
  575. $context['saved_successful'] = true;
  576. else
  577. $context['saved_failed'] = $_SESSION['adm-save'];
  578. unset($_SESSION['adm-save']);
  579. }
  580. $context['config_vars'] = array();
  581. $inlinePermissions = array();
  582. $bbcChoice = array();
  583. $board_list = false;
  584. foreach ($config_vars as $config_var)
  585. {
  586. // HR?
  587. if (!is_array($config_var))
  588. $context['config_vars'][] = $config_var;
  589. else
  590. {
  591. // If it has no name it doesn't have any purpose!
  592. if (empty($config_var[1]))
  593. continue;
  594. // Special case for inline permissions
  595. if ($config_var[0] == 'permissions' && allowedTo('manage_permissions'))
  596. $inlinePermissions[] = $config_var[1];
  597. elseif ($config_var[0] == 'permissions')
  598. continue;
  599. if ($config_var[0] == 'boards')
  600. $board_list = true;
  601. // Are we showing the BBC selection box?
  602. if ($config_var[0] == 'bbc')
  603. $bbcChoice[] = $config_var[1];
  604. // We need to do some parsing of the value before we pass it in.
  605. if (isset($modSettings[$config_var[1]]))
  606. {
  607. switch ($config_var[0])
  608. {
  609. case 'select':
  610. $value = $modSettings[$config_var[1]];
  611. break;
  612. case 'boards':
  613. $value = explode(',', $modSettings[$config_var[1]]);
  614. break;
  615. default:
  616. $value = $smcFunc['htmlspecialchars']($modSettings[$config_var[1]]);
  617. }
  618. }
  619. else
  620. {
  621. // Darn, it's empty. What type is expected?
  622. switch ($config_var[0])
  623. {
  624. case 'int':
  625. case 'float':
  626. $value = 0;
  627. break;
  628. case 'select':
  629. $value = !empty($config_var['multiple']) ? serialize(array()) : '';
  630. break;
  631. case 'boards':
  632. $value = array();
  633. break;
  634. default:
  635. $value = '';
  636. }
  637. }
  638. $context['config_vars'][$config_var[1]] = array(
  639. 'label' => isset($config_var['text_label']) ? $config_var['text_label'] : (isset($txt[$config_var[1]]) ? $txt[$config_var[1]] : (isset($config_var[3]) && !is_array($config_var[3]) ? $config_var[3] : '')),
  640. 'help' => isset($helptxt[$config_var[1]]) ? $config_var[1] : '',
  641. 'type' => $config_var[0],
  642. 'size' => !empty($config_var[2]) && !is_array($config_var[2]) ? $config_var[2] : (in_array($config_var[0], array('int', 'float')) ? 6 : 0),
  643. 'data' => array(),
  644. 'name' => $config_var[1],
  645. 'value' => $value,
  646. 'disabled' => false,
  647. 'invalid' => !empty($config_var['invalid']),
  648. 'javascript' => '',
  649. 'var_message' => !empty($config_var['message']) && isset($txt[$config_var['message']]) ? $txt[$config_var['message']] : '',
  650. 'preinput' => isset($config_var['preinput']) ? $config_var['preinput'] : '',
  651. 'postinput' => isset($config_var['postinput']) ? $config_var['postinput'] : '',
  652. );
  653. // If this is a select box handle any data.
  654. if (!empty($config_var[2]) && is_array($config_var[2]))
  655. {
  656. // If we allow multiple selections, we need to adjust a few things.
  657. if ($config_var[0] == 'select' && !empty($config_var['multiple']))
  658. {
  659. $context['config_vars'][$config_var[1]]['name'] .= '[]';
  660. $context['config_vars'][$config_var[1]]['value'] = unserialize($context['config_vars'][$config_var[1]]['value']);
  661. }
  662. // If it's associative
  663. if (isset($config_var[2][0]) && is_array($config_var[2][0]))
  664. $context['config_vars'][$config_var[1]]['data'] = $config_var[2];
  665. else
  666. {
  667. foreach ($config_var[2] as $key => $item)
  668. $context['config_vars'][$config_var[1]]['data'][] = array($key, $item);
  669. }
  670. }
  671. // Finally allow overrides - and some final cleanups.
  672. foreach ($config_var as $k => $v)
  673. {
  674. if (!is_numeric($k))
  675. {
  676. if (substr($k, 0, 2) == 'on')
  677. $context['config_vars'][$config_var[1]]['javascript'] .= ' ' . $k . '="' . $v . '"';
  678. else
  679. $context['config_vars'][$config_var[1]][$k] = $v;
  680. }
  681. // See if there are any other labels that might fit?
  682. if (isset($txt['setting_' . $config_var[1]]))
  683. $context['config_vars'][$config_var[1]]['label'] = $txt['setting_' . $config_var[1]];
  684. elseif (isset($txt['groups_' . $config_var[1]]))
  685. $context['config_vars'][$config_var[1]]['label'] = $txt['groups_' . $config_var[1]];
  686. }
  687. // Set the subtext in case it's part of the label.
  688. // @todo Temporary. Preventing divs inside label tags.
  689. $divPos = strpos($context['config_vars'][$config_var[1]]['label'], '<div');
  690. if ($divPos !== false)
  691. {
  692. $context['config_vars'][$config_var[1]]['subtext'] = preg_replace('~</?div[^>]*>~', '', substr($context['config_vars'][$config_var[1]]['label'], $divPos));
  693. $context['config_vars'][$config_var[1]]['label'] = substr($context['config_vars'][$config_var[1]]['label'], 0, $divPos);
  694. }
  695. }
  696. }
  697. // If we have inline permissions we need to prep them.
  698. if (!empty($inlinePermissions) && allowedTo('manage_permissions'))
  699. {
  700. require_once($sourcedir . '/ManagePermissions.php');
  701. init_inline_permissions($inlinePermissions, isset($context['permissions_excluded']) ? $context['permissions_excluded'] : array());
  702. }
  703. if ($board_list)
  704. {
  705. require_once($sourcedir . '/Subs-MessageIndex.php');
  706. $context['board_list'] = getBoardList();
  707. }
  708. // What about any BBC selection boxes?
  709. if (!empty($bbcChoice))
  710. {
  711. // What are the options, eh?
  712. $temp = parse_bbc(false);
  713. $bbcTags = array();
  714. foreach ($temp as $tag)
  715. $bbcTags[] = $tag['tag'];
  716. $bbcTags = array_unique($bbcTags);
  717. $totalTags = count($bbcTags);
  718. // The number of columns we want to show the BBC tags in.
  719. $numColumns = isset($context['num_bbc_columns']) ? $context['num_bbc_columns'] : 3;
  720. // Start working out the context stuff.
  721. $context['bbc_columns'] = array();
  722. $tagsPerColumn = ceil($totalTags / $numColumns);
  723. $col = 0; $i = 0;
  724. foreach ($bbcTags as $tag)
  725. {
  726. if ($i % $tagsPerColumn == 0 && $i != 0)
  727. $col++;
  728. $context['bbc_columns'][$col][] = array(
  729. 'tag' => $tag,
  730. // @todo 'tag_' . ?
  731. 'show_help' => isset($helptxt[$tag]),
  732. );
  733. $i++;
  734. }
  735. // Now put whatever BBC options we may have into context too!
  736. $context['bbc_sections'] = array();
  737. foreach ($bbcChoice as $bbc)
  738. {
  739. $context['bbc_sections'][$bbc] = array(
  740. 'title' => isset($txt['bbc_title_' . $bbc]) ? $txt['bbc_title_' . $bbc] : $txt['bbcTagsToUse_select'],
  741. 'disabled' => empty($modSettings['bbc_disabled_' . $bbc]) ? array() : $modSettings['bbc_disabled_' . $bbc],
  742. 'all_selected' => empty($modSettings['bbc_disabled_' . $bbc]),
  743. );
  744. }
  745. }
  746. call_integration_hook('integrate_prepare_db_settings', array(&$config_vars));
  747. createToken('admin-dbsc');
  748. }
  749. /**
  750. * Helper function. Saves settings by putting them in Settings.php or saving them in the settings table.
  751. *
  752. * - Saves those settings set from ?action=admin;area=serversettings.
  753. * - Requires the admin_forum permission.
  754. * - Contains arrays of the types of data to save into Settings.php.
  755. *
  756. * @param $config_vars
  757. */
  758. function saveSettings(&$config_vars)
  759. {
  760. global $boarddir, $sc, $cookiename, $modSettings, $user_settings;
  761. global $sourcedir, $context, $cachedir;
  762. validateToken('admin-ssc');
  763. // Fix the darn stupid cookiename! (more may not be allowed, but these for sure!)
  764. if (isset($_POST['cookiename']))
  765. $_POST['cookiename'] = preg_replace('~[,;\s\.$]+~' . ($context['utf8'] ? 'u' : ''), '', $_POST['cookiename']);
  766. // Fix the forum's URL if necessary.
  767. if (isset($_POST['boardurl']))
  768. {
  769. if (substr($_POST['boardurl'], -10) == '/index.php')
  770. $_POST['boardurl'] = substr($_POST['boardurl'], 0, -10);
  771. elseif (substr($_POST['boardurl'], -1) == '/')
  772. $_POST['boardurl'] = substr($_POST['boardurl'], 0, -1);
  773. if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://')
  774. $_POST['boardurl'] = 'http://' . $_POST['boardurl'];
  775. }
  776. // Any passwords?
  777. $config_passwords = array(
  778. 'db_passwd',
  779. 'ssi_db_passwd',
  780. );
  781. // All the strings to write.
  782. $config_strs = array(
  783. 'mtitle', 'mmessage',
  784. 'language', 'mbname', 'boardurl',
  785. 'cookiename',
  786. 'webmaster_email',
  787. 'db_name', 'db_user', 'db_server', 'db_prefix', 'ssi_db_user',
  788. 'boarddir', 'sourcedir',
  789. 'cachedir', 'cache_accelerator', 'cache_memcached',
  790. );
  791. // All the numeric variables.
  792. $config_ints = array(
  793. 'cache_enable',
  794. );
  795. // All the checkboxes.
  796. $config_bools = array(
  797. 'db_persist', 'db_error_send',
  798. 'maintenance',
  799. );
  800. // Now sort everything into a big array, and figure out arrays and etc.
  801. $new_settings = array();
  802. foreach ($config_passwords as $config_var)
  803. {
  804. if (isset($_POST[$config_var][1]) && $_POST[$config_var][0] == $_POST[$config_var][1])
  805. $new_settings[$config_var] = '\'' . addcslashes($_POST[$config_var][0], '\'\\') . '\'';
  806. }
  807. foreach ($config_strs as $config_var)
  808. {
  809. if (isset($_POST[$config_var]))
  810. $new_settings[$config_var] = '\'' . addcslashes($_POST[$config_var], '\'\\') . '\'';
  811. }
  812. foreach ($config_ints as $config_var)
  813. {
  814. if (isset($_POST[$config_var]))
  815. $new_settings[$config_var] = (int) $_POST[$config_var];
  816. }
  817. foreach ($config_bools as $key)
  818. {
  819. if (!empty($_POST[$key]))
  820. $new_settings[$key] = '1';
  821. else
  822. $new_settings[$key] = '0';
  823. }
  824. // Save the relevant settings in the Settings.php file.
  825. require_once($sourcedir . '/Subs-Admin.php');
  826. updateSettingsFile($new_settings);
  827. // Now loop through the remaining (database-based) settings.
  828. $new_settings = array();
  829. foreach ($config_vars as $config_var)
  830. {
  831. // We just saved the file-based settings, so skip their definitions.
  832. if (!is_array($config_var) || $config_var[2] == 'file')
  833. continue;
  834. // Rewrite the definition a bit.
  835. $new_settings[] = array($config_var[3], $config_var[0]);
  836. }
  837. // Save the new database-based settings, if any.
  838. if (!empty($new_settings))
  839. saveDBSettings($new_settings);
  840. }
  841. /**
  842. * Helper function for saving database settings.
  843. * @todo see rev. 10406 from 2.1-requests
  844. *
  845. * @param array $config_vars
  846. */
  847. function saveDBSettings(&$config_vars)
  848. {
  849. global $sourcedir, $context, $smcFunc;
  850. static $board_list = null;
  851. validateToken('admin-dbsc');
  852. $inlinePermissions = array();
  853. foreach ($config_vars as $var)
  854. {
  855. if (!isset($var[1]) || (!isset($_POST[$var[1]]) && $var[0] != 'check' && $var[0] != 'permissions' && ($var[0] != 'bbc' || !isset($_POST[$var[1] . '_enabledTags']))))
  856. continue;
  857. // Checkboxes!
  858. elseif ($var[0] == 'check')
  859. $setArray[$var[1]] = !empty($_POST[$var[1]]) ? '1' : '0';
  860. // Select boxes!
  861. elseif ($var[0] == 'select' && in_array($_POST[$var[1]], array_keys($var[2])))
  862. $setArray[$var[1]] = $_POST[$var[1]];
  863. elseif ($var[0] == 'select' && !empty($var['multiple']) && array_intersect($_POST[$var[1]], array_keys($var[2])) != array())
  864. {
  865. // For security purposes we validate this line by line.
  866. $options = array();
  867. foreach ($_POST[$var[1]] as $invar)
  868. if (in_array($invar, array_keys($var[2])))
  869. $options[] = $invar;
  870. $setArray[$var[1]] = serialize($options);
  871. }
  872. // List of boards!
  873. elseif ($var[0] == 'boards')
  874. {
  875. // We just need a simple list of valid boards, nothing more.
  876. if ($board_list === null)
  877. {
  878. $board_list = array();
  879. $request = $smcFunc['db_query']('', '
  880. SELECT id_board
  881. FROM {db_prefix}boards');
  882. while ($row = $smcFunc['db_fetch_row']($request))
  883. $board_list[$row[0]] = true;
  884. $smcFunc['db_free_result']($request);
  885. }
  886. $options = array();
  887. foreach ($_POST[$var[1]] as $invar => $dummy)
  888. if (isset($board_list[$invar]))
  889. $options[] = $invar;
  890. $setArray[$var[1]] = implode(',', $options);
  891. }
  892. // Integers!
  893. elseif ($var[0] == 'int')
  894. $setArray[$var[1]] = (int) $_POST[$var[1]];
  895. // Floating point!
  896. elseif ($var[0] == 'float')
  897. $setArray[$var[1]] = (float) $_POST[$var[1]];
  898. // Text!
  899. elseif ($var[0] == 'text' || $var[0] == 'large_text')
  900. $setArray[$var[1]] = $_POST[$var[1]];
  901. // Passwords!
  902. elseif ($var[0] == 'password')
  903. {
  904. if (isset($_POST[$var[1]][1]) && $_POST[$var[1]][0] == $_POST[$var[1]][1])
  905. $setArray[$var[1]] = $_POST[$var[1]][0];
  906. }
  907. // BBC.
  908. elseif ($var[0] == 'bbc')
  909. {
  910. $bbcTags = array();
  911. foreach (parse_bbc(false) as $tag)
  912. $bbcTags[] = $tag['tag'];
  913. if (!isset($_POST[$var[1] . '_enabledTags']))
  914. $_POST[$var[1] . '_enabledTags'] = array();
  915. elseif (!is_array($_POST[$var[1] . '_enabledTags']))
  916. $_POST[$var[1] . '_enabledTags'] = array($_POST[$var[1] . '_enabledTags']);
  917. $setArray[$var[1]] = implode(',', array_diff($bbcTags, $_POST[$var[1] . '_enabledTags']));
  918. }
  919. // Permissions?
  920. elseif ($var[0] == 'permissions')
  921. $inlinePermissions[] = $var[1];
  922. }
  923. if (!empty($setArray))
  924. updateSettings($setArray);
  925. // If we have inline permissions we need to save them.
  926. if (!empty($inlinePermissions) && allowedTo('manage_permissions'))
  927. {
  928. require_once($sourcedir . '/ManagePermissions.php');
  929. save_inline_permissions($inlinePermissions);
  930. }
  931. }
  932. /**
  933. * Allows us to see the servers php settings
  934. *
  935. * - loads the settings into an array for display in a template
  936. * - drops cookie values just in case
  937. */
  938. function ShowPHPinfoSettings()
  939. {
  940. global $context, $txt;
  941. $info_lines = array();
  942. $category = $txt['phpinfo_settings'];
  943. // get the data
  944. ob_start();
  945. phpinfo();
  946. // We only want it for its body, pigs that we are
  947. $info_lines = preg_replace('~^.*<body>(.*)</body>.*$~', '$1', ob_get_contents());
  948. $info_lines = explode("\n", strip_tags($info_lines, "<tr><td><h2>"));
  949. ob_end_clean();
  950. // remove things that could be considered sensitive
  951. $remove = '_COOKIE|Cookie|_GET|_REQUEST|REQUEST_URI|QUERY_STRING|REQUEST_URL|HTTP_REFERER';
  952. // put all of it into an array
  953. foreach ($info_lines as $line)
  954. {
  955. if (preg_match('~(' . $remove . ')~', $line))
  956. continue;
  957. // new category?
  958. if (strpos($line, '<h2>') !== false)
  959. $category = preg_match('~<h2>(.*)</h2>~', $line, $title) ? $category = $title[1] : $category;
  960. // load it as setting => value or the old setting local master
  961. if (preg_match('~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~', $line, $val))
  962. $pinfo[$category][$val[1]] = $val[2];
  963. elseif (preg_match('~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~', $line, $val))
  964. $pinfo[$category][$val[1]] = array($txt['phpinfo_localsettings'] => $val[2], $txt['phpinfo_defaultsettings'] => $val[3]);
  965. }
  966. // load it in to context and display it
  967. $context['pinfo'] = $pinfo;
  968. $context['page_title'] = $txt['admin_server_settings'];
  969. $context['sub_template'] = 'php_info';
  970. return;
  971. }
  972. ?>