aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormarcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-08-12 18:35:03 +0000
committermarcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-08-12 18:35:03 +0000
commit116ff3ae92e54c1de9b30344e0417fb87d08175d (patch)
tree789c86df03046eda119fffcc967656721a6a3162
parentc71cfb0a82b4e2d0a1395ba9d3d96b4f9d6a1ebd (diff)
downloadelgg-116ff3ae92e54c1de9b30344e0417fb87d08175d.tar.gz
elgg-116ff3ae92e54c1de9b30344e0417fb87d08175d.tar.bz2
Closes #232: Produces a basic report plus checksums of all files in md5sum format.
To add extra information to this report add a plugin hook listening to: 'diagnostics:report' And append to $returnvalue which is a simple text buffer. git-svn-id: https://code.elgg.org/elgg/trunk@1863 36083f99-b078-4883-b0ff-0f9b5a30f544
-rw-r--r--mod/diagnostics/actions/download.php24
-rw-r--r--mod/diagnostics/index.php26
-rw-r--r--mod/diagnostics/languages/en.php44
-rw-r--r--mod/diagnostics/manifest.xml9
-rw-r--r--mod/diagnostics/start.php140
-rw-r--r--mod/diagnostics/views/default/diagnostics/forms/download.php15
6 files changed, 258 insertions, 0 deletions
diff --git a/mod/diagnostics/actions/download.php b/mod/diagnostics/actions/download.php
new file mode 100644
index 000000000..90266b793
--- /dev/null
+++ b/mod/diagnostics/actions/download.php
@@ -0,0 +1,24 @@
+<?php
+ /**
+ * Elgg diagnostics
+ *
+ * @package ElggDiagnostics
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider Ltd
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.com/
+ */
+
+ admin_gatekeeper();
+
+ $output = sprintf(elgg_echo('diagnostics:header'), date('r'), $_SESSION['user']->name);
+ $output = trigger_plugin_hook('diagnostics:report', 'all', 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));
+
+ echo $output;
+?> \ No newline at end of file
diff --git a/mod/diagnostics/index.php b/mod/diagnostics/index.php
new file mode 100644
index 000000000..37581a3d9
--- /dev/null
+++ b/mod/diagnostics/index.php
@@ -0,0 +1,26 @@
+<?php
+ /**
+ * Elgg diagnostics
+ *
+ * @package ElggDiagnostics
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider Ltd
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.com/
+ */
+
+ require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
+
+ admin_gatekeeper();
+ set_context('admin');
+
+ $title = elgg_view_title(elgg_echo('diagnostics'));
+
+ $body .= elgg_echo('diagnostics:description');
+
+ $body .= elgg_view('diagnostics/forms/download');
+
+
+
+ page_draw(elgg_echo('diagnostics'),elgg_view_layout("two_column_left_sidebar", '', $title . $body));
+?> \ No newline at end of file
diff --git a/mod/diagnostics/languages/en.php b/mod/diagnostics/languages/en.php
new file mode 100644
index 000000000..485a1bab0
--- /dev/null
+++ b/mod/diagnostics/languages/en.php
@@ -0,0 +1,44 @@
+<?php
+ /**
+ * Elgg diagnostics language pack.
+ *
+ * @package ElggDiagnostics
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider Ltd
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.com/
+ */
+
+ $english = array(
+
+ 'diagnostics' => 'System diagnostics',
+
+ '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:download' => 'Download .txt',
+
+
+ 'diagnostics:header' => '========================================================================
+Elgg Diagnostic Report
+Generated %s by %s
+========================================================================
+
+',
+ 'diagnostics:report:basic' => '
+Elgg Release %s, version %s
+
+------------------------------------------------------------------------',
+ 'diagnostics:report:plugins' => '
+Installed plugins and details:
+
+%s
+------------------------------------------------------------------------',
+ 'diagnostics:report:md5' => '
+Installed files and checksums:
+
+%s
+------------------------------------------------------------------------',
+ );
+
+ add_translation("en",$english);
+?> \ No newline at end of file
diff --git a/mod/diagnostics/manifest.xml b/mod/diagnostics/manifest.xml
new file mode 100644
index 000000000..ab5ce65b4
--- /dev/null
+++ b/mod/diagnostics/manifest.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<plugin_manifest>
+ <field key="author" value="Marcus Povey" />
+ <field key="version" value="1.0" />
+ <field key="description" value="Elgg diagnostics tool" />
+ <field key="website" value="http://www.elgg.org/" />
+ <field key="copyright" value="(C) Curverider 2008" />
+ <field key="licence" value="GNU Public License version 2" />
+</plugin_manifest> \ No newline at end of file
diff --git a/mod/diagnostics/start.php b/mod/diagnostics/start.php
new file mode 100644
index 000000000..091e67a20
--- /dev/null
+++ b/mod/diagnostics/start.php
@@ -0,0 +1,140 @@
+<?php
+ /**
+ * Elgg diagnostics
+ *
+ * @package ElggDiagnostics
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider Ltd
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.com/
+ */
+
+ /**
+ * Initialise the diagnostics tool
+ *
+ */
+ function diagnostics_init()
+ {
+ global $CONFIG;
+
+ // Register a page handler, so we can have nice URLs
+ register_page_handler('diagnostics','diagnostics_page_handler');
+
+ // Register some actions
+ register_action("diagnostics/download",false, $CONFIG->pluginspath . "diagnostics/actions/download.php");
+ }
+
+ /**
+ * Adding the diagnostics to the admin menu
+ *
+ */
+ function diagnostics_pagesetup()
+ {
+ if (get_context() == 'admin' && isadminloggedin()) {
+ global $CONFIG;
+ add_submenu_item(elgg_echo('diagnostics'), $CONFIG->wwwroot . '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");
+ }
+
+ /**
+ * Generate a basic report.
+ *
+ * @param unknown_type $hook
+ * @param unknown_type $entity_type
+ * @param unknown_type $returnvalue
+ * @param unknown_type $params
+ */
+ function diagnostics_basic_hook($hook, $entity_type, $returnvalue, $params)
+ {
+ global $CONFIG;
+
+ include_once($CONFIG->path . "version.php");
+
+ $returnvalue .= sprintf(elgg_echo('diagnostics:report:basic'), $release, $version);
+
+ return $returnvalue;
+ }
+
+ /**
+ * 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
+ */
+ function diagnostics_plugins_hook($hook, $entity_type, $returnvalue, $params)
+ {
+ $returnvalue .= sprintf(elgg_echo('diagnostics:report:plugins'), print_r(get_installed_plugins(), true));
+
+ return $returnvalue;
+ }
+
+ /**
+ * Recursively list through a directory tree producing a hash of all installed files
+ *
+ * @param starting dir $dir
+ * @param buffer $buffer
+ */
+ function diagnostics_md5_dir($dir)
+ {
+ //if (is_file(trim($dir, "/"))) {
+ $extensions_allowed = array('.php', '.gif', '.png', '.jpg');
+
+ $buffer = "";
+
+ if (in_array(strrchr(trim($dir, "/"), '.'), $extensions_allowed))
+ {
+ //$dir = trim($dir, "/");
+ $buffer .= md5_file($dir). " " . trim($dir, "/") . "\n";
+ } else if ($handle = opendir($dir)) {
+ while ($file = readdir($handle)) {
+
+ if (($file != '.') && ($file != '..')) {
+ $buffer .= diagnostics_md5_dir($dir . $file. "/", $buffer);
+ }
+ }
+ }
+
+ return $buffer;
+ }
+
+ /**
+ * 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
+ */
+ function diagnostics_sigs_hook($hook, $entity_type, $returnvalue, $params)
+ {
+ global $CONFIG;
+
+ $returnvalue .= sprintf(elgg_echo('diagnostics:report:md5'), diagnostics_md5_dir($CONFIG->path));
+
+ return $returnvalue;
+ }
+
+ // Initialise log browser
+ register_elgg_event_handler('init','system','diagnostics_init');
+ register_elgg_event_handler('pagesetup','system','diagnostics_pagesetup');
+
+ register_plugin_hook("diagnostics:report", "all", "diagnostics_basic_hook", 0); // show basics first
+ 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
+
+?> \ No newline at end of file
diff --git a/mod/diagnostics/views/default/diagnostics/forms/download.php b/mod/diagnostics/views/default/diagnostics/forms/download.php
new file mode 100644
index 000000000..dcb11d5f1
--- /dev/null
+++ b/mod/diagnostics/views/default/diagnostics/forms/download.php
@@ -0,0 +1,15 @@
+<?php
+ /**
+ * Elgg diagnostics
+ *
+ * @package ElggDiagnostics
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider Ltd
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.com/
+ */
+
+ $form_body = elgg_view('input/submit', array('value' => elgg_echo('diagnostics:download')));
+
+ echo elgg_view('input/form', array('body' => $form_body, 'action' => $CONFIG->url . "actions/diagnostics/download"))
+?> \ No newline at end of file