ManageServer.php 39 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142
  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. 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, $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, $sc;
  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, $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']) || $modSettings['load_average'] === 0.0)
  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('float', $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. else
  468. $_POST[$key] = (float) $value;
  469. if ($key == 'loadavg_auto_opt' && $value <= 1)
  470. $_POST['loadavg_auto_opt'] = 1.0;
  471. elseif ($key == 'loadavg_forum' && $value < 10)
  472. $_POST['loadavg_forum'] = 10.0;
  473. elseif ($value < 2)
  474. $_POST[$key] = 2.0;
  475. }
  476. call_integration_hook('integrate_save_loadavg_settings');
  477. saveDBSettings($config_vars);
  478. if (!isset($_SESSION['adm-save']))
  479. $_SESSION['adm-save'] = true;
  480. redirectexit('action=admin;area=serversettings;sa=loads;' . $context['session_var'] . '=' . $context['session_id']);
  481. }
  482. createToken('admin-ssc');
  483. createToken('admin-dbsc');
  484. prepareDBSettingContext($config_vars);
  485. }
  486. /**
  487. * Helper function, it sets up the context for the manage server settings.
  488. * - The basic usage of the six numbered key fields are
  489. * - array (0 ,1, 2, 3, 4, 5
  490. * 0 variable name - the name of the saved variable
  491. * 1 label - the text to show on the settings page
  492. * 2 saveto - file or db, where to save the variable name - value pair
  493. * 3 type - type of data to save, int, float, text, check
  494. * 4 size - false or field size
  495. * 5 help - '' or helptxt variable name
  496. * )
  497. *
  498. * the following named keys are also permitted
  499. * 'disabled' => 'postinput' => 'preinput' =>
  500. *
  501. * @param array $config_vars
  502. */
  503. function prepareServerSettingsContext(&$config_vars)
  504. {
  505. global $context, $modSettings, $smcFunc;
  506. if (isset($_SESSION['adm-save']))
  507. {
  508. if ($_SESSION['adm-save'] === true)
  509. $context['saved_successful'] = true;
  510. else
  511. $context['saved_failed'] = $_SESSION['adm-save'];
  512. unset($_SESSION['adm-save']);
  513. }
  514. $context['config_vars'] = array();
  515. foreach ($config_vars as $identifier => $config_var)
  516. {
  517. if (!is_array($config_var) || !isset($config_var[1]))
  518. $context['config_vars'][] = $config_var;
  519. else
  520. {
  521. $varname = $config_var[0];
  522. global $$varname;
  523. // Set the subtext in case it's part of the label.
  524. // @todo Temporary. Preventing divs inside label tags.
  525. $divPos = strpos($config_var[1], '<div');
  526. $subtext = '';
  527. if ($divPos !== false)
  528. {
  529. $subtext = preg_replace('~</?div[^>]*>~', '', substr($config_var[1], $divPos));
  530. $config_var[1] = substr($config_var[1], 0, $divPos);
  531. }
  532. $context['config_vars'][$config_var[0]] = array(
  533. 'label' => $config_var[1],
  534. 'help' => isset($config_var[5]) ? $config_var[5] : '',
  535. 'type' => $config_var[3],
  536. 'size' => empty($config_var[4]) ? 0 : $config_var[4],
  537. 'data' => isset($config_var[4]) && is_array($config_var[4]) && $config_var[3] != 'select' ? $config_var[4] : array(),
  538. 'name' => $config_var[0],
  539. '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 : '')),
  540. 'disabled' => !empty($context['settings_not_writable']) || !empty($config_var['disabled']),
  541. 'invalid' => false,
  542. 'subtext' => !empty($config_var['subtext']) ? $config_var['subtext'] : $subtext,
  543. 'javascript' => '',
  544. 'preinput' => !empty($config_var['preinput']) ? $config_var['preinput'] : '',
  545. 'postinput' => !empty($config_var['postinput']) ? $config_var['postinput'] : '',
  546. );
  547. // If this is a select box handle any data.
  548. if (!empty($config_var[4]) && is_array($config_var[4]))
  549. {
  550. // If it's associative
  551. $config_values = array_values($config_var[4]);
  552. if (isset($config_values[0]) && is_array($config_values[0]))
  553. $context['config_vars'][$config_var[0]]['data'] = $config_var[4];
  554. else
  555. {
  556. foreach ($config_var[4] as $key => $item)
  557. $context['config_vars'][$config_var[0]]['data'][] = array($key, $item);
  558. }
  559. }
  560. }
  561. }
  562. // Two tokens because saving these settings requires both saveSettings and saveDBSettings
  563. createToken('admin-ssc');
  564. createToken('admin-dbsc');
  565. }
  566. /**
  567. * Helper function, it sets up the context for database settings.
  568. * @todo see rev. 10406 from 2.1-requests
  569. *
  570. * @param array $config_vars
  571. */
  572. function prepareDBSettingContext(&$config_vars)
  573. {
  574. global $txt, $helptxt, $context, $modSettings, $sourcedir, $smcFunc;
  575. loadLanguage('Help');
  576. if (isset($_SESSION['adm-save']))
  577. {
  578. if ($_SESSION['adm-save'] === true)
  579. $context['saved_successful'] = true;
  580. else
  581. $context['saved_failed'] = $_SESSION['adm-save'];
  582. unset($_SESSION['adm-save']);
  583. }
  584. $context['config_vars'] = array();
  585. $inlinePermissions = array();
  586. $bbcChoice = array();
  587. $board_list = false;
  588. foreach ($config_vars as $config_var)
  589. {
  590. // HR?
  591. if (!is_array($config_var))
  592. $context['config_vars'][] = $config_var;
  593. else
  594. {
  595. // If it has no name it doesn't have any purpose!
  596. if (empty($config_var[1]))
  597. continue;
  598. // Special case for inline permissions
  599. if ($config_var[0] == 'permissions' && allowedTo('manage_permissions'))
  600. $inlinePermissions[] = $config_var[1];
  601. elseif ($config_var[0] == 'permissions')
  602. continue;
  603. if ($config_var[0] == 'boards')
  604. $board_list = true;
  605. // Are we showing the BBC selection box?
  606. if ($config_var[0] == 'bbc')
  607. $bbcChoice[] = $config_var[1];
  608. // We need to do some parsing of the value before we pass it in.
  609. if (isset($modSettings[$config_var[1]]))
  610. {
  611. switch ($config_var[0])
  612. {
  613. case 'select':
  614. $value = $modSettings[$config_var[1]];
  615. break;
  616. case 'boards':
  617. $value = explode(',', $modSettings[$config_var[1]]);
  618. break;
  619. default:
  620. $value = $smcFunc['htmlspecialchars']($modSettings[$config_var[1]]);
  621. }
  622. }
  623. else
  624. {
  625. // Darn, it's empty. What type is expected?
  626. switch ($config_var[0])
  627. {
  628. case 'int':
  629. case 'float':
  630. $value = 0;
  631. break;
  632. case 'select':
  633. $value = !empty($config_var['multiple']) ? serialize(array()) : '';
  634. break;
  635. case 'boards':
  636. $value = array();
  637. break;
  638. default:
  639. $value = '';
  640. }
  641. }
  642. $context['config_vars'][$config_var[1]] = array(
  643. '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] : '')),
  644. 'help' => isset($helptxt[$config_var[1]]) ? $config_var[1] : '',
  645. 'type' => $config_var[0],
  646. 'size' => !empty($config_var[2]) && !is_array($config_var[2]) ? $config_var[2] : (in_array($config_var[0], array('int', 'float')) ? 6 : 0),
  647. 'data' => array(),
  648. 'name' => $config_var[1],
  649. 'value' => $value,
  650. 'disabled' => false,
  651. 'invalid' => !empty($config_var['invalid']),
  652. 'javascript' => '',
  653. 'var_message' => !empty($config_var['message']) && isset($txt[$config_var['message']]) ? $txt[$config_var['message']] : '',
  654. 'preinput' => isset($config_var['preinput']) ? $config_var['preinput'] : '',
  655. 'postinput' => isset($config_var['postinput']) ? $config_var['postinput'] : '',
  656. );
  657. // If this is a select box handle any data.
  658. if (!empty($config_var[2]) && is_array($config_var[2]))
  659. {
  660. // If we allow multiple selections, we need to adjust a few things.
  661. if ($config_var[0] == 'select' && !empty($config_var['multiple']))
  662. {
  663. $context['config_vars'][$config_var[1]]['name'] .= '[]';
  664. $context['config_vars'][$config_var[1]]['value'] = unserialize($context['config_vars'][$config_var[1]]['value']);
  665. }
  666. // If it's associative
  667. if (isset($config_var[2][0]) && is_array($config_var[2][0]))
  668. $context['config_vars'][$config_var[1]]['data'] = $config_var[2];
  669. else
  670. {
  671. foreach ($config_var[2] as $key => $item)
  672. $context['config_vars'][$config_var[1]]['data'][] = array($key, $item);
  673. }
  674. }
  675. // Finally allow overrides - and some final cleanups.
  676. foreach ($config_var as $k => $v)
  677. {
  678. if (!is_numeric($k))
  679. {
  680. if (substr($k, 0, 2) == 'on')
  681. $context['config_vars'][$config_var[1]]['javascript'] .= ' ' . $k . '="' . $v . '"';
  682. else
  683. $context['config_vars'][$config_var[1]][$k] = $v;
  684. }
  685. // See if there are any other labels that might fit?
  686. if (isset($txt['setting_' . $config_var[1]]))
  687. $context['config_vars'][$config_var[1]]['label'] = $txt['setting_' . $config_var[1]];
  688. elseif (isset($txt['groups_' . $config_var[1]]))
  689. $context['config_vars'][$config_var[1]]['label'] = $txt['groups_' . $config_var[1]];
  690. }
  691. // Set the subtext in case it's part of the label.
  692. // @todo Temporary. Preventing divs inside label tags.
  693. $divPos = strpos($context['config_vars'][$config_var[1]]['label'], '<div');
  694. if ($divPos !== false)
  695. {
  696. $context['config_vars'][$config_var[1]]['subtext'] = preg_replace('~</?div[^>]*>~', '', substr($context['config_vars'][$config_var[1]]['label'], $divPos));
  697. $context['config_vars'][$config_var[1]]['label'] = substr($context['config_vars'][$config_var[1]]['label'], 0, $divPos);
  698. }
  699. }
  700. }
  701. // If we have inline permissions we need to prep them.
  702. if (!empty($inlinePermissions) && allowedTo('manage_permissions'))
  703. {
  704. require_once($sourcedir . '/ManagePermissions.php');
  705. init_inline_permissions($inlinePermissions, isset($context['permissions_excluded']) ? $context['permissions_excluded'] : array());
  706. }
  707. if ($board_list)
  708. {
  709. require_once($sourcedir . '/Subs-MessageIndex.php');
  710. $context['board_list'] = getBoardList();
  711. }
  712. // What about any BBC selection boxes?
  713. if (!empty($bbcChoice))
  714. {
  715. // What are the options, eh?
  716. $temp = parse_bbc(false);
  717. $bbcTags = array();
  718. foreach ($temp as $tag)
  719. $bbcTags[] = $tag['tag'];
  720. $bbcTags = array_unique($bbcTags);
  721. $totalTags = count($bbcTags);
  722. // The number of columns we want to show the BBC tags in.
  723. $numColumns = isset($context['num_bbc_columns']) ? $context['num_bbc_columns'] : 3;
  724. // Start working out the context stuff.
  725. $context['bbc_columns'] = array();
  726. $tagsPerColumn = ceil($totalTags / $numColumns);
  727. $col = 0; $i = 0;
  728. foreach ($bbcTags as $tag)
  729. {
  730. if ($i % $tagsPerColumn == 0 && $i != 0)
  731. $col++;
  732. $context['bbc_columns'][$col][] = array(
  733. 'tag' => $tag,
  734. // @todo 'tag_' . ?
  735. 'show_help' => isset($helptxt[$tag]),
  736. );
  737. $i++;
  738. }
  739. // Now put whatever BBC options we may have into context too!
  740. $context['bbc_sections'] = array();
  741. foreach ($bbcChoice as $bbc)
  742. {
  743. $context['bbc_sections'][$bbc] = array(
  744. 'title' => isset($txt['bbc_title_' . $bbc]) ? $txt['bbc_title_' . $bbc] : $txt['bbcTagsToUse_select'],
  745. 'disabled' => empty($modSettings['bbc_disabled_' . $bbc]) ? array() : $modSettings['bbc_disabled_' . $bbc],
  746. 'all_selected' => empty($modSettings['bbc_disabled_' . $bbc]),
  747. );
  748. }
  749. }
  750. call_integration_hook('integrate_prepare_db_settings', array(&$config_vars));
  751. createToken('admin-dbsc');
  752. }
  753. /**
  754. * Helper function. Saves settings by putting them in Settings.php or saving them in the settings table.
  755. *
  756. * - Saves those settings set from ?action=admin;area=serversettings.
  757. * - Requires the admin_forum permission.
  758. * - Contains arrays of the types of data to save into Settings.php.
  759. *
  760. * @param $config_vars
  761. */
  762. function saveSettings(&$config_vars)
  763. {
  764. global $boarddir, $sc, $cookiename, $user_settings;
  765. global $sourcedir, $context, $cachedir;
  766. validateToken('admin-ssc');
  767. // Fix the darn stupid cookiename! (more may not be allowed, but these for sure!)
  768. if (isset($_POST['cookiename']))
  769. $_POST['cookiename'] = preg_replace('~[,;\s\.$]+~' . ($context['utf8'] ? 'u' : ''), '', $_POST['cookiename']);
  770. // Fix the forum's URL if necessary.
  771. if (isset($_POST['boardurl']))
  772. {
  773. if (substr($_POST['boardurl'], -10) == '/index.php')
  774. $_POST['boardurl'] = substr($_POST['boardurl'], 0, -10);
  775. elseif (substr($_POST['boardurl'], -1) == '/')
  776. $_POST['boardurl'] = substr($_POST['boardurl'], 0, -1);
  777. if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://')
  778. $_POST['boardurl'] = 'http://' . $_POST['boardurl'];
  779. }
  780. // Any passwords?
  781. $config_passwords = array(
  782. 'db_passwd',
  783. 'ssi_db_passwd',
  784. );
  785. // All the strings to write.
  786. $config_strs = array(
  787. 'mtitle', 'mmessage',
  788. 'language', 'mbname', 'boardurl',
  789. 'cookiename',
  790. 'webmaster_email',
  791. 'db_name', 'db_user', 'db_server', 'db_prefix', 'ssi_db_user',
  792. 'boarddir', 'sourcedir',
  793. 'cachedir', 'cache_accelerator', 'cache_memcached',
  794. );
  795. // All the numeric variables.
  796. $config_ints = array(
  797. 'cache_enable',
  798. );
  799. // All the checkboxes
  800. $config_bools = array('db_persist', 'db_error_send', 'maintenance');
  801. // Now sort everything into a big array, and figure out arrays and etc.
  802. $new_settings = array();
  803. // Figure out which config vars we're saving here...
  804. foreach ($config_vars as $var)
  805. {
  806. if (!is_array($var) || $var[2] != 'file')
  807. continue;
  808. $config_var = $var[0];
  809. if (in_array($config_var, $config_passwords))
  810. {
  811. if (isset($_POST[$config_var][1]) && $_POST[$config_var][0] == $_POST[$config_var][1])
  812. $new_settings[$config_var] = '\'' . addcslashes($_POST[$config_var][0], '\'\\') . '\'';
  813. }
  814. elseif (in_array($config_var, $config_strs))
  815. {
  816. $new_settings[$config_var] = '\'' . addcslashes($_POST[$config_var], '\'\\') . '\'';
  817. }
  818. elseif (in_array($config_var, $config_ints))
  819. {
  820. $new_settings[$config_var] = (int) $_POST[$config_var];
  821. }
  822. elseif (in_array($config_var, $config_bools))
  823. {
  824. if (!empty($_POST[$config_var]))
  825. $new_settings[$config_var] = '1';
  826. else
  827. $new_settings[$config_var] = '0';
  828. }
  829. else
  830. {
  831. // This shouldn't happen, but it might...
  832. fatal_error('Unknown config_var \'' . $config_var . '\'');
  833. }
  834. }
  835. // Save the relevant settings in the Settings.php file.
  836. require_once($sourcedir . '/Subs-Admin.php');
  837. updateSettingsFile($new_settings);
  838. // Now loop through the remaining (database-based) settings.
  839. $new_settings = array();
  840. foreach ($config_vars as $config_var)
  841. {
  842. // We just saved the file-based settings, so skip their definitions.
  843. if (!is_array($config_var) || $config_var[2] == 'file')
  844. continue;
  845. // Rewrite the definition a bit.
  846. $new_settings[] = array($config_var[3], $config_var[0]);
  847. }
  848. // Save the new database-based settings, if any.
  849. if (!empty($new_settings))
  850. saveDBSettings($new_settings);
  851. }
  852. /**
  853. * Helper function for saving database settings.
  854. * @todo see rev. 10406 from 2.1-requests
  855. *
  856. * @param array $config_vars
  857. */
  858. function saveDBSettings(&$config_vars)
  859. {
  860. global $sourcedir, $context, $smcFunc;
  861. static $board_list = null;
  862. validateToken('admin-dbsc');
  863. $inlinePermissions = array();
  864. foreach ($config_vars as $var)
  865. {
  866. if (!isset($var[1]) || (!isset($_POST[$var[1]]) && $var[0] != 'check' && $var[0] != 'permissions' && ($var[0] != 'bbc' || !isset($_POST[$var[1] . '_enabledTags']))))
  867. continue;
  868. // Checkboxes!
  869. elseif ($var[0] == 'check')
  870. $setArray[$var[1]] = !empty($_POST[$var[1]]) ? '1' : '0';
  871. // Select boxes!
  872. elseif ($var[0] == 'select' && in_array($_POST[$var[1]], array_keys($var[2])))
  873. $setArray[$var[1]] = $_POST[$var[1]];
  874. elseif ($var[0] == 'select' && !empty($var['multiple']) && array_intersect($_POST[$var[1]], array_keys($var[2])) != array())
  875. {
  876. // For security purposes we validate this line by line.
  877. $options = array();
  878. foreach ($_POST[$var[1]] as $invar)
  879. if (in_array($invar, array_keys($var[2])))
  880. $options[] = $invar;
  881. $setArray[$var[1]] = serialize($options);
  882. }
  883. // List of boards!
  884. elseif ($var[0] == 'boards')
  885. {
  886. // We just need a simple list of valid boards, nothing more.
  887. if ($board_list === null)
  888. {
  889. $board_list = array();
  890. $request = $smcFunc['db_query']('', '
  891. SELECT id_board
  892. FROM {db_prefix}boards');
  893. while ($row = $smcFunc['db_fetch_row']($request))
  894. $board_list[$row[0]] = true;
  895. $smcFunc['db_free_result']($request);
  896. }
  897. $options = array();
  898. foreach ($_POST[$var[1]] as $invar => $dummy)
  899. if (isset($board_list[$invar]))
  900. $options[] = $invar;
  901. $setArray[$var[1]] = implode(',', $options);
  902. }
  903. // Integers!
  904. elseif ($var[0] == 'int')
  905. $setArray[$var[1]] = (int) $_POST[$var[1]];
  906. // Floating point!
  907. elseif ($var[0] == 'float')
  908. $setArray[$var[1]] = (float) $_POST[$var[1]];
  909. // Text!
  910. elseif ($var[0] == 'text' || in_array($var[0], array('color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'time')))
  911. $setArray[$var[1]] = $_POST[$var[1]];
  912. // Passwords!
  913. elseif ($var[0] == 'password')
  914. {
  915. if (isset($_POST[$var[1]][1]) && $_POST[$var[1]][0] == $_POST[$var[1]][1])
  916. $setArray[$var[1]] = $_POST[$var[1]][0];
  917. }
  918. // BBC.
  919. elseif ($var[0] == 'bbc')
  920. {
  921. $bbcTags = array();
  922. foreach (parse_bbc(false) as $tag)
  923. $bbcTags[] = $tag['tag'];
  924. if (!isset($_POST[$var[1] . '_enabledTags']))
  925. $_POST[$var[1] . '_enabledTags'] = array();
  926. elseif (!is_array($_POST[$var[1] . '_enabledTags']))
  927. $_POST[$var[1] . '_enabledTags'] = array($_POST[$var[1] . '_enabledTags']);
  928. $setArray[$var[1]] = implode(',', array_diff($bbcTags, $_POST[$var[1] . '_enabledTags']));
  929. }
  930. // Permissions?
  931. elseif ($var[0] == 'permissions')
  932. $inlinePermissions[] = $var[1];
  933. }
  934. if (!empty($setArray))
  935. updateSettings($setArray);
  936. // If we have inline permissions we need to save them.
  937. if (!empty($inlinePermissions) && allowedTo('manage_permissions'))
  938. {
  939. require_once($sourcedir . '/ManagePermissions.php');
  940. save_inline_permissions($inlinePermissions);
  941. }
  942. }
  943. /**
  944. * Allows us to see the servers php settings
  945. *
  946. * - loads the settings into an array for display in a template
  947. * - drops cookie values just in case
  948. */
  949. function ShowPHPinfoSettings()
  950. {
  951. global $context, $txt;
  952. $info_lines = array();
  953. $category = $txt['phpinfo_settings'];
  954. // get the data
  955. ob_start();
  956. phpinfo();
  957. // We only want it for its body, pigs that we are
  958. $info_lines = preg_replace('~^.*<body>(.*)</body>.*$~', '$1', ob_get_contents());
  959. $info_lines = explode("\n", strip_tags($info_lines, "<tr><td><h2>"));
  960. ob_end_clean();
  961. // remove things that could be considered sensitive
  962. $remove = '_COOKIE|Cookie|_GET|_REQUEST|REQUEST_URI|QUERY_STRING|REQUEST_URL|HTTP_REFERER';
  963. // put all of it into an array
  964. foreach ($info_lines as $line)
  965. {
  966. if (preg_match('~(' . $remove . ')~', $line))
  967. continue;
  968. // new category?
  969. if (strpos($line, '<h2>') !== false)
  970. $category = preg_match('~<h2>(.*)</h2>~', $line, $title) ? $category = $title[1] : $category;
  971. // load it as setting => value or the old setting local master
  972. if (preg_match('~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~', $line, $val))
  973. $pinfo[$category][$val[1]] = $val[2];
  974. elseif (preg_match('~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~', $line, $val))
  975. $pinfo[$category][$val[1]] = array($txt['phpinfo_localsettings'] => $val[2], $txt['phpinfo_defaultsettings'] => $val[3]);
  976. }
  977. // load it in to context and display it
  978. $context['pinfo'] = $pinfo;
  979. $context['page_title'] = $txt['admin_server_settings'];
  980. $context['sub_template'] = 'php_info';
  981. return;
  982. }
  983. ?>