From a3e6db37cac7097abc4131b96b1ba522a4c0cdcf Mon Sep 17 00:00:00 2001 From: marcus Date: Sat, 16 Aug 2008 10:56:39 +0000 Subject: Globals and PHP info added to diagnostics git-svn-id: https://code.elgg.org/elgg/trunk@1963 36083f99-b078-4883-b0ff-0f9b5a30f544 --- mod/diagnostics/languages/en.php | 10 +++++++-- mod/diagnostics/start.php | 44 ++++++++++++++++++++++++++++++++++++---- 2 files changed, 48 insertions(+), 6 deletions(-) (limited to 'mod/diagnostics') diff --git a/mod/diagnostics/languages/en.php b/mod/diagnostics/languages/en.php index ff3198393..15c8b6750 100644 --- a/mod/diagnostics/languages/en.php +++ b/mod/diagnostics/languages/en.php @@ -28,8 +28,8 @@ Generated %s by %s Elgg Release %s, version %s ------------------------------------------------------------------------', - 'diagnostics:report:session' => ' -Current session: + 'diagnostics:report:php' => ' +PHP info: %s ------------------------------------------------------------------------', 'diagnostics:report:plugins' => ' @@ -42,6 +42,12 @@ Installed files and checksums: %s ------------------------------------------------------------------------', + 'diagnostics:report:globals' => ' +Global variables: + +%s +------------------------------------------------------------------------', + ); add_translation("en",$english); diff --git a/mod/diagnostics/start.php b/mod/diagnostics/start.php index a9e3828e5..38cb6b167 100644 --- a/mod/diagnostics/start.php +++ b/mod/diagnostics/start.php @@ -130,18 +130,53 @@ } /** - * Get some information about the current session + * Get some information about the php install * * @param unknown_type $hook * @param unknown_type $entity_type * @param unknown_type $returnvalue * @param unknown_type $params */ - function diagnostics_session_hook($hook, $entity_type, $returnvalue, $params) + function diagnostics_phpinfo_hook($hook, $entity_type, $returnvalue, $params) { global $CONFIG; - $returnvalue .= sprintf(elgg_echo('diagnostics:report:session'), print_r($_SESSION, true)); + ob_start(); + phpinfo(); + $phpinfo = array('phpinfo' => array()); + + if(preg_match_all('#(?:

(?:)?(.*?)(?:)?

)|(?:(.*?)\s*(?:(.*?)\s*(?:(.*?)\s*)?)?)#s', ob_get_clean(), $matches, PREG_SET_ORDER)) + + foreach($matches as $match) + { + if(strlen($match[1])) + $phpinfo[$match[1]] = array(); + else if(isset($match[3])) + $phpinfo[end(array_keys($phpinfo))][$match[2]] = isset($match[4]) ? array($match[3], $match[4]) : $match[3]; + else + $phpinfo[end(array_keys($phpinfo))][] = $match[2]; + } + + + $returnvalue .= sprintf(elgg_echo('diagnostics:report:php'), print_r($phpinfo, true)); + + return $returnvalue; + } + + /** + * Get global variables. + * + * @param unknown_type $hook + * @param unknown_type $entity_type + * @param unknown_type $returnvalue + * @param unknown_type $params + * @return unknown + */ + function diagnostics_globals_hook($hook, $entity_type, $returnvalue, $params) + { + global $CONFIG; + + $returnvalue .= sprintf(elgg_echo('diagnostics:report:globals'), print_r($GLOBALS, true)); return $returnvalue; } @@ -154,5 +189,6 @@ register_plugin_hook("diagnostics:report", "all", "diagnostics_plugins_hook", 2); // Now the plugins register_plugin_hook("diagnostics:report", "all", "diagnostics_sigs_hook", 1); // Now the signatures - register_plugin_hook("diagnostics:report", "all", "diagnostics_session_hook"); // Session + register_plugin_hook("diagnostics:report", "all", "diagnostics_globals_hook"); // Global variables + register_plugin_hook("diagnostics:report", "all", "diagnostics_phpinfo_hook"); // PHP info ?> \ No newline at end of file -- cgit v1.2.3