Просмотр исходного кода

! added phpinfo() output to the admin panel (manage server)

Spuds 13 лет назад
Родитель
Сommit
64ce5e6be5

+ 1 - 0
Sources/Admin.php

@@ -150,6 +150,7 @@ function AdminMain()
 						'cookie' => array($txt['cookies_sessions_settings']),
 						'cache' => array($txt['caching_settings']),
 						'loads' => array($txt['load_balancing_settings']),
+						'phpinfo' => array($txt['phpinfo_settings']),
 					),
 				),
 				'current_theme' => array(

+ 49 - 1
Sources/ManageServer.php

@@ -103,6 +103,7 @@ function ModifySettings()
 		'cookie' => 'ModifyCookieSettings',
 		'cache' => 'ModifyCacheSettings',
 		'loads' => 'ModifyLoadBalancingSettings',
+		'phpinfo' => 'ShowPHPinfoSettings',
 	);
 
 	call_integration_hook('integrate_server_settings', array(&$subActions));
@@ -361,7 +362,7 @@ function ModifyCacheSettings($return_config = false)
 		$detected = 'APC';
 	elseif (function_exists('output_cache_put'))
 		$detected = 'Zend';
-	elseif (function_exists('memcache_set'))
+	elseif (function_exists('memcache_set') || function_exists('memcached_set'))
 		$detected = 'Memcached';
 	elseif (function_exists('xcache_set'))
 		$detected = 'XCache';
@@ -842,4 +843,51 @@ function saveDBSettings(&$config_vars)
 	}
 }
 
+/**
+ * Allows us to see the servers php settings
+ * - loads the settings into an array for display in a template
+ * - drops cookie values just in case
+ *
+ */
+function ShowPHPinfoSettings()
+{
+	global $context;
+	
+	$info_lines = array();
+	$category = 'General';
+
+	// get the data
+	ob_start();
+	phpinfo();
+
+	// We only want it for its body, pigs that we are
+	$info_lines = preg_replace('~^.*<body>(.*)</body>.*$~', '$1', ob_get_contents());
+	$info_lines = explode("\n", strip_tags($info_lines, "<tr><td><h2>"));
+	ob_end_clean();
+
+	// put all of it into an array
+	foreach ($info_lines as $line)
+	{
+		// lets not load/show these.
+		if (strpos($line, '_COOKIE') !== false || strpos($line, 'Cookie') !== false)
+			continue;
+
+		// new category?
+		if (strpos($line, '<h2>') !== false)
+			$category = preg_match('~<h2>(.*)</h2>~', $line, $title) ? $category = $title[1] : $category;
+
+		// load it as setting => value or the old setting local master
+		if (preg_match('~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~', $line, $val))
+			$pinfo[$category][$val[1]] = $val[2];
+		elseif (preg_match('~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~', $line, $val))
+			$pinfo[$category][$val[1]] = array('local' => $val[2], 'master' => $val[3]);
+	}
+	
+	// load it in to context and display it
+	$context['pinfo'] = $pinfo;
+	$context['page_title'] = $txt['admin_server_settings'];
+	$context['sub_template'] = 'php_info';
+	return;
+}
+
 ?>

+ 56 - 1
Themes/default/Admin.template.php

@@ -388,7 +388,7 @@ function template_view_versions()
 						<th scope="col" width="25%">
 							<strong>', $txt['dvc_your'], '</strong>
 						</th>
-						<th class="last_th" scope="col"" width="25%">
+						<th class="last_th" scope="col" width="25%">
 							<strong>', $txt['dvc_current'], '</strong>
 						</th>
 					</tr>
@@ -1541,4 +1541,59 @@ function template_repair_boards()
 	}
 }
 
+function template_php_info()
+{
+	global $context;
+
+	// for each php info area
+	foreach ($context['pinfo'] as $area => $php_area)
+	{
+		echo '
+	<table id="', str_replace(' ', '_', $area), '" width="100%" class="table_grid">
+		<thead>
+		<tr class="catbg" align="center">
+			<th class="first_th" scope="col" width="33%"></th>
+			<th scope="col" width="33%"><strong>', $area, '</strong></th>
+			<th class="last_th" scope="col" width="33%"></th>
+		</tr>
+		</thead>
+		<tbody>';
+
+		// and for each setting in that area
+		$alternate = true;
+		foreach ($php_area as $key => $setting)
+		{
+			// a local / master setting (3 col)
+			if (is_array($setting))
+			{
+				echo '
+		<tr>
+			<td align="left" width="33%" class="windowbg', $alternate ? '2' : '', '">', $key, '</td>';
+
+				foreach ($setting as $key_lm => $value)
+				{
+					echo '
+			<td align="left" width="33%" class="windowbg', $alternate ? '2' : '', '">', $key_lm, '/', $value, '</td>';
+				}
+				echo '
+		</tr>';
+			}
+			// just a single setting (2 col)
+			else
+			{
+				echo '
+		<tr>
+			<td align="left" width="33%" class="windowbg', $alternate ? '2' : '', '">', $key,  '</td>
+			<td align="left" class="windowbg', $alternate ? '2' : '', '" colspan="2">', $setting, '</td>
+		</tr>';
+			}
+		$alternate = !$alternate;
+		}
+		echo '
+		</tbody>
+	</table>
+	<br class="clear" />';
+	}
+}
+
 ?>

+ 1 - 0
Themes/default/languages/Admin.english.php

@@ -525,6 +525,7 @@ $txt['database_paths_settings'] = 'Database and Paths';
 $txt['cookies_sessions_settings'] = 'Cookies and Sessions';
 $txt['caching_settings'] = 'Caching';
 $txt['load_balancing_settings'] = 'Load Balancing';
+$txt['phpinfo_settings'] = 'PHP Info';
 
 $txt['language_configuration'] = 'Languages';
 $txt['language_description'] = 'This section allows you to edit languages installed on your forum, download new ones from the Simple Machines website. You may also edit language-related settings here.';