ManageServer.php 39 KB

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