aboutsummaryrefslogtreecommitdiff
path: root/mod/diagnostics/start.php
diff options
context:
space:
mode:
Diffstat (limited to 'mod/diagnostics/start.php')
-rw-r--r--mod/diagnostics/start.php117
1 files changed, 32 insertions, 85 deletions
diff --git a/mod/diagnostics/start.php b/mod/diagnostics/start.php
index 5f0f80d62..55842800a 100644
--- a/mod/diagnostics/start.php
+++ b/mod/diagnostics/start.php
@@ -5,57 +5,27 @@
* @package ElggDiagnostics
*/
+elgg_register_event_handler('init', 'system', 'diagnostics_init');
+
/**
* Initialise the diagnostics tool
- *
*/
-function diagnostics_init()
-{
- global $CONFIG;
+function diagnostics_init() {
- // Register a page handler, so we can have nice URLs
- register_page_handler('diagnostics','diagnostics_page_handler');
+ // Add admin menu item
+ elgg_register_admin_menu_item('administer', 'diagnostics', 'administer_utilities');
// Register some actions
- elgg_register_action("diagnostics/download", $CONFIG->pluginspath . "diagnostics/actions/download.php");
-}
-
-/**
- * Adding the diagnostics to the admin menu
- *
- */
-function diagnostics_pagesetup()
-{
- if (elgg_get_context() == 'admin' && isadminloggedin()) {
- global $CONFIG;
- add_submenu_item(elgg_echo('diagnostics'), 'pg/diagnostics/');
- }
-}
-
-/**
- * Diagnostics page.
- *
- * @param array $page Array of page elements, forwarded by the page handling mechanism
- */
-function diagnostics_page_handler($page)
-{
- global $CONFIG;
-
- // only interested in one page for now
- include($CONFIG->pluginspath . "diagnostics/index.php");
+ $file = elgg_get_plugins_path() . "diagnostics/actions/download.php";
+ elgg_register_action("diagnostics/download", $file, 'admin');
}
/**
* Generate a basic report.
*
- * @param unknown_type $hook
- * @param unknown_type $entity_type
- * @param unknown_type $returnvalue
- * @param unknown_type $params
+ * @return string
*/
-function diagnostics_basic_hook($hook, $entity_type, $returnvalue, $params)
-{
- global $CONFIG;
+function diagnostics_basic_hook($hook, $entity_type, $returnvalue, $params) {
// Get version information
$version = get_version();
@@ -69,14 +39,11 @@ function diagnostics_basic_hook($hook, $entity_type, $returnvalue, $params)
/**
* Get some information about the plugins installed on the system.
*
- * @param unknown_type $hook
- * @param unknown_type $entity_type
- * @param unknown_type $returnvalue
- * @param unknown_type $params
+ * @return tring
*/
-function diagnostics_plugins_hook($hook, $entity_type, $returnvalue, $params)
-{
- $returnvalue .= elgg_echo('diagnostics:report:plugins', array(print_r(get_installed_plugins(), true)));
+function diagnostics_plugins_hook($hook, $entity_type, $returnvalue, $params) {
+ // @todo this is a really bad idea because of the new plugin system
+ //$returnvalue .= elgg_echo('diagnostics:report:plugins', array(print_r(elgg_get_plugins(), true)));
return $returnvalue;
}
@@ -87,8 +54,7 @@ function diagnostics_plugins_hook($hook, $entity_type, $returnvalue, $params)
* @param starting dir $dir
* @param buffer $buffer
*/
-function diagnostics_md5_dir($dir)
-{
+function diagnostics_md5_dir($dir) {
$extensions_allowed = array('.php', '.js', '.css');
$buffer = "";
@@ -113,16 +79,12 @@ function diagnostics_md5_dir($dir)
/**
* Get some information about the files installed on a system.
*
- * @param unknown_type $hook
- * @param unknown_type $entity_type
- * @param unknown_type $returnvalue
- * @param unknown_type $params
+ * @return string
*/
-function diagnostics_sigs_hook($hook, $entity_type, $returnvalue, $params)
-{
- global $CONFIG;
+function diagnostics_sigs_hook($hook, $entity_type, $returnvalue, $params) {
- $returnvalue .= elgg_echo('diagnostics:report:md5', array(diagnostics_md5_dir($CONFIG->path)));
+ $base_dir = elgg_get_root_path();
+ $returnvalue .= elgg_echo('diagnostics:report:md5', array(diagnostics_md5_dir($base_dir)));
return $returnvalue;
}
@@ -130,32 +92,27 @@ function diagnostics_sigs_hook($hook, $entity_type, $returnvalue, $params)
/**
* Get some information about the php install
*
- * @param unknown_type $hook
- * @param unknown_type $entity_type
- * @param unknown_type $returnvalue
- * @param unknown_type $params
+ * @return string
*/
-function diagnostics_phpinfo_hook($hook, $entity_type, $returnvalue, $params)
-{
- global $CONFIG;
+function diagnostics_phpinfo_hook($hook, $entity_type, $returnvalue, $params) {
ob_start();
phpinfo();
$phpinfo = array('phpinfo' => array());
- if(preg_match_all('#(?:<h2>(?:<a name=".*?">)?(.*?)(?:</a>)?</h2>)|(?:<tr(?: class=".*?")?><t[hd](?: class=".*?")?>(.*?)\s*</t[hd]>(?:<t[hd](?: class=".*?")?>(.*?)\s*</t[hd]>(?:<t[hd](?: class=".*?")?>(.*?)\s*</t[hd]>)?)?</tr>)#s', ob_get_clean(), $matches, PREG_SET_ORDER))
+ if (preg_match_all('#(?:<h2>(?:<a name=".*?">)?(.*?)(?:</a>)?</h2>)|(?:<tr(?: class=".*?")?><t[hd](?: class=".*?")?>(.*?)\s*</t[hd]>(?:<t[hd](?: class=".*?")?>(.*?)\s*</t[hd]>(?:<t[hd](?: class=".*?")?>(.*?)\s*</t[hd]>)?)?</tr>)#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];
+ 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 .= elgg_echo('diagnostics:report:php', array(print_r($phpinfo, true)));
return $returnvalue;
@@ -164,14 +121,9 @@ function diagnostics_phpinfo_hook($hook, $entity_type, $returnvalue, $params)
/**
* Get global variables.
*
- * @param unknown_type $hook
- * @param unknown_type $entity_type
- * @param unknown_type $returnvalue
- * @param unknown_type $params
- * @return unknown
+ * @return string
*/
-function diagnostics_globals_hook($hook, $entity_type, $returnvalue, $params)
-{
+function diagnostics_globals_hook($hook, $entity_type, $returnvalue, $params) {
global $CONFIG;
$output = str_replace($CONFIG->dbpass, '<<DBPASS>>', print_r($GLOBALS, true));
@@ -180,14 +132,9 @@ function diagnostics_globals_hook($hook, $entity_type, $returnvalue, $params)
return $returnvalue;
}
-// Initialise log browser
-elgg_register_event_handler('init','system','diagnostics_init');
-elgg_register_event_handler('pagesetup','system','diagnostics_pagesetup');
-
elgg_register_plugin_hook_handler("diagnostics:report", "system", "diagnostics_basic_hook", 0); // show basics first
elgg_register_plugin_hook_handler("diagnostics:report", "system", "diagnostics_plugins_hook", 2); // Now the plugins
elgg_register_plugin_hook_handler("diagnostics:report", "system", "diagnostics_sigs_hook", 1); // Now the signatures
elgg_register_plugin_hook_handler("diagnostics:report", "system", "diagnostics_globals_hook"); // Global variables
elgg_register_plugin_hook_handler("diagnostics:report", "system", "diagnostics_phpinfo_hook"); // PHP info
-?> \ No newline at end of file