ManageServer.php 38 KB

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