ManageServer.php 38 KB

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