diff options
Diffstat (limited to 'mod/diagnostics')
| -rw-r--r-- | mod/diagnostics/actions/download.php | 31 | ||||
| -rw-r--r-- | mod/diagnostics/languages/en.php | 65 | ||||
| -rw-r--r-- | mod/diagnostics/manifest.xml | 24 | ||||
| -rw-r--r-- | mod/diagnostics/start.php | 63 | ||||
| -rw-r--r-- | mod/diagnostics/views/default/admin/administer_utilities/diagnostics.php | 17 | ||||
| -rw-r--r-- | mod/diagnostics/views/default/admin/utilities/diagnostics.php | 35 | ||||
| -rw-r--r-- | mod/diagnostics/views/default/diagnostics/forms/download.php | 9 |
7 files changed, 87 insertions, 157 deletions
diff --git a/mod/diagnostics/actions/download.php b/mod/diagnostics/actions/download.php index 3c096eb0a..97775c92e 100644 --- a/mod/diagnostics/actions/download.php +++ b/mod/diagnostics/actions/download.php @@ -1,21 +1,18 @@ <?php - /** - * Elgg diagnostics - * - * @package ElggDiagnostics - */ +/** + * Elgg diagnostics + * + * @package ElggDiagnostics + */ - admin_gatekeeper(); +$output = elgg_echo('diagnostics:header', array(date('r'), elgg_get_logged_in_user_entity()->name)); +$output = elgg_trigger_plugin_hook('diagnostics:report', 'system', null, $output); - $output = elgg_echo('diagnostics:header', array(date('r'), get_loggedin_user()->name)); - $output = elgg_trigger_plugin_hook('diagnostics:report', 'system', null, $output); +header("Cache-Control: public"); +header("Content-Description: File Transfer"); +header('Content-disposition: attachment; filename=elggdiagnostic.txt'); +header("Content-Type: text/plain"); +header('Content-Length: ' . strlen($output)); - header("Cache-Control: public"); - header("Content-Description: File Transfer"); - header('Content-disposition: attachment; filename=elggdiagnostic.txt'); - header("Content-Type: text/plain"); - header('Content-Length: '. strlen($output)); - - echo $output; - exit; -?>
\ No newline at end of file +echo $output; +exit; diff --git a/mod/diagnostics/languages/en.php b/mod/diagnostics/languages/en.php index 476c4fb5c..54859941d 100644 --- a/mod/diagnostics/languages/en.php +++ b/mod/diagnostics/languages/en.php @@ -1,70 +1,45 @@ <?php - /** - * Elgg diagnostics language pack. - * - * @package ElggDiagnostics - */ - - $english = array( - - 'diagnostics' => 'System diagnostics', - 'diagnostics:report' => 'Diagnostics Report', - 'diagnostics:unittester' => 'Unit Tests', - - 'diagnostics:description' => 'The following diagnostic report is useful for diagnosing any problems with Elgg, and should be attached to any bug reports you file.', - 'diagnostics:unittester:description' => 'The following are diagnostic tests which are registered by plugins and may be performed in order to debug parts of the Elgg framework.', - - 'diagnostics:unittester:description' => 'Unit tests check Elgg Core for broken or buggy APIs.', - 'diagnostics:unittester:debug' => 'The site must be in debug mode to run unit tests.', - 'diagnostics:unittester:warning' => 'WARNING: These tests can leave behind debugging objects in your database.<br />DO NOT USE ON A PRODUCTION SITE!', - - 'diagnostics:test:executetest' => 'Execute test', - 'diagnostics:test:executeall' => 'Execute All', - 'diagnostics:unittester:notests' => 'Sorry, there are no unit test modules currently installed.', - 'diagnostics:unittester:testnotfound' => 'Sorry, the report could not be generated because that test was not found', - - 'diagnostics:unittester:testresult:nottestclass' => 'FAIL - Result not a test class', - 'diagnostics:unittester:testresult:fail' => 'FAIL', - 'diagnostics:unittester:testresult:success' => 'SUCCESS', - - 'diagnostics:unittest:example' => 'Example unit test, only available in debug mode.', - - 'diagnostics:unittester:report' => 'Test report for %s', - - 'diagnostics:download' => 'Download .txt', - - - 'diagnostics:header' => '======================================================================== +/** + * Elgg diagnostics language pack. + * + * @package ElggDiagnostics + */ + +$english = array( + 'admin:administer_utilities:diagnostics' => 'System Diagnostics', + 'diagnostics' => 'System diagnostics', + 'diagnostics:report' => 'Diagnostics Report', + 'diagnostics:description' => 'The following diagnostic report can be useful for diagnosing problems with Elgg. The developers of Elgg may request that you attach it to a bug report.', + 'diagnostics:download' => 'Download', + 'diagnostics:header' => '======================================================================== Elgg Diagnostic Report Generated %s by %s ======================================================================== ', - 'diagnostics:report:basic' => ' + 'diagnostics:report:basic' => ' Elgg Release %s, version %s ------------------------------------------------------------------------', - 'diagnostics:report:php' => ' + 'diagnostics:report:php' => ' PHP info: %s ------------------------------------------------------------------------', - 'diagnostics:report:plugins' => ' + 'diagnostics:report:plugins' => ' Installed plugins and details: %s ------------------------------------------------------------------------', - 'diagnostics:report:md5' => ' + 'diagnostics:report:md5' => ' Installed files and checksums: %s ------------------------------------------------------------------------', - 'diagnostics:report:globals' => ' + 'diagnostics:report:globals' => ' Global variables: %s ------------------------------------------------------------------------', +); - ); - - add_translation("en",$english); -?>
\ No newline at end of file +add_translation("en", $english); diff --git a/mod/diagnostics/manifest.xml b/mod/diagnostics/manifest.xml index 1e1df8881..21e847d22 100644 --- a/mod/diagnostics/manifest.xml +++ b/mod/diagnostics/manifest.xml @@ -1,11 +1,17 @@ <?xml version="1.0" encoding="UTF-8"?> -<plugin_manifest> - <field key="author" value="Curverider Ltd" /> - <field key="version" value="1.5" /> - <field key="description" value="Elgg diagnostics tool" /> - <field key="website" value="http://www.elgg.org/" /> - <field key="copyright" value="(C) Curverider 2008-2010" /> - <field key="licence" value="GNU Public License version 2" /> - <field key="elgg_version" value="2009030702" /> - <field key="admin_interface" value="advanced" /> +<plugin_manifest xmlns="http://www.elgg.org/plugin_manifest/1.8"> + <name>Diagnostics</name> + <author>Core developers</author> + <version>1.8</version> + <category>bundled</category> + <category>development</category> + <category>admin</category> + <description>Elgg diagnostics tool</description> + <website>http://www.elgg.org/</website> + <copyright>See COPYRIGHT.txt</copyright> + <license>GNU General Public License version 2</license> + <requires> + <type>elgg_release</type> + <version>1.8</version> + </requires> </plugin_manifest> diff --git a/mod/diagnostics/start.php b/mod/diagnostics/start.php index b161e47c4..55842800a 100644 --- a/mod/diagnostics/start.php +++ b/mod/diagnostics/start.php @@ -9,31 +9,23 @@ elgg_register_event_handler('init', 'system', 'diagnostics_init'); /** * Initialise the diagnostics tool - * */ 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_add_admin_menu_item('diagnostics', elgg_echo('diagnostics'), 'utilities'); + elgg_register_admin_menu_item('administer', 'diagnostics', 'administer_utilities'); // Register some actions - $file = elgg_get_plugin_path() . "diagnostics/actions/download.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; // Get version information $version = get_version(); @@ -47,13 +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))); + // @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; } @@ -89,15 +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; - $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; } @@ -105,31 +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; 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; @@ -138,11 +121,7 @@ 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) { global $CONFIG; diff --git a/mod/diagnostics/views/default/admin/administer_utilities/diagnostics.php b/mod/diagnostics/views/default/admin/administer_utilities/diagnostics.php new file mode 100644 index 000000000..c7ff3d5fc --- /dev/null +++ b/mod/diagnostics/views/default/admin/administer_utilities/diagnostics.php @@ -0,0 +1,17 @@ +<?php +/** + * Diagnostics admin page + */ + +$diagnostics_title = elgg_echo('diagnostics:report'); +$diagnostics = '<p>' . elgg_echo('diagnostics:description') .'</p>'; +$params = array( + 'text' => elgg_echo('diagnostics:download'), + 'href' => 'action/diagnostics/download', + 'class' => 'elgg-button elgg-button-submit', + 'is_action' => true, + 'is_trusted' => true, +); +$diagnostics .= '<p>' . elgg_view('output/url', $params) . '</p>'; + +echo elgg_view_module('inline', $diagnostics_title, $diagnostics, array('class' => 'elgg-form-settings')); diff --git a/mod/diagnostics/views/default/admin/utilities/diagnostics.php b/mod/diagnostics/views/default/admin/utilities/diagnostics.php deleted file mode 100644 index 44e6fa17b..000000000 --- a/mod/diagnostics/views/default/admin/utilities/diagnostics.php +++ /dev/null @@ -1,35 +0,0 @@ -<?php - - -$title = elgg_view_title(elgg_echo('diagnostics')); - -$diagnostics = "<h3>".elgg_echo('diagnostics:report')."</h3>"; -$diagnostics .= elgg_echo('diagnostics:description'); -$diagnostics .= elgg_view('diagnostics/forms/download'); - -// unit tests -$unit_tests = "<h3>".elgg_echo('diagnostics:unittester')."</h3>"; -$unit_tests .= "<p>" . elgg_echo('diagnostics:unittester:description') . "</p>"; -$unit_tests .= "<p>" . elgg_echo('diagnostics:unittester:warning') . "</p>"; - -if (isset($CONFIG->debug)) { - // create a button to run tests - $params = array( - 'text' => elgg_echo('diagnostics:test:executeall'), - 'href' => elgg_get_site_url() . 'engine/tests/suite.php', - 'class' => 'elgg-submit-button', - ); - $unit_tests .= elgg_view('output/url', $params); -} else { - // no tests when not in debug mode - $unit_tests .= elgg_echo('diagnostics:unittester:debug'); -} - -// display admin body -echo <<<HTML -$title -<div class="admin_settings diagnostics"> - $diagnostics - $unit_tests -</div> -HTML; diff --git a/mod/diagnostics/views/default/diagnostics/forms/download.php b/mod/diagnostics/views/default/diagnostics/forms/download.php deleted file mode 100644 index e5d9af557..000000000 --- a/mod/diagnostics/views/default/diagnostics/forms/download.php +++ /dev/null @@ -1,9 +0,0 @@ -<?php -/** - * Elgg diagnostics - * - * @package ElggDiagnostics - */ - -$form_body = elgg_view('input/submit', array('value' => elgg_echo('diagnostics:download'))); -echo elgg_view('input/form', array('body' => $form_body, 'action' => "action/diagnostics/download")); |
