From 906e375adc1c044d5488563a74af1fd46275b57d Mon Sep 17 00:00:00 2001
From: kevin_fourie {i18n arg_tracker=$kt_tracker_location}Visit the #tracker#{/i18n}
+ {i18n arg_tracker=$kt_tracker_location}Visit the #tracker#{/i18n}
{i18n}first if you believe you have found a bug. Always check for known issues relating
to the version you are using — we may already have found the problem you're referring to,
-and may have fixed it in a newer version. If we ask for your PHP_INFO data, we're
-looking for the information described below.{/i18n}System Settings
";
+ $html .= '';
+ foreach($rs as $rec)
+ {
+ $id = $rec['id'];
+ $name = $rec['name'];
+ $value = $rec['value'];
+ if (substr($name, 0, 15) == 'dashboard-state') continue;
+ $html .= "
';
+ file_put_contents($path . '/systemsettings.htm', $html);
+ }
+
+ /**
+ * Get disk usage
+ *
+ * @param string $path
+ */
+ private function capture_df($path)
+ {
+ $df = KTUtil::findCommand('externalBinary/df', 'df');
+ if (!file_exists($df) || !is_executable($df))
+ {
+ return;
+ }
+
+ $df = popen($df, 'r');
+ $content = fread($df, 10240);
+ pclose($df);
+
+ file_put_contents($path . '/df.txt', $content);
+ }
+
+ /**
+ * Get php info
+ *
+ * @param string $filename
+ */
+ private function capture_phpinfo($filename)
+ {
+ ob_start();
+ phpinfo();
+ $phpinfo = ob_get_clean();
+ file_put_contents($filename, $phpinfo);
+ }
+
+ /**
+ * Helper table to get schema
+ *
+ * @param string $folder
+ * @return string
+ */
+ private function capture_table_schema($folder)
+ {
+ $tables = array();
+ $sql = 'show tables';
+ $results = DBUtil::getResultArray($sql);
+
+ foreach($results as $rec)
+ {
+ $rec = array_values($rec);
+ $tablename = $rec[0];
+ $sql = "show create table $tablename";
+ $sql = DBUtil::getOneResultKey($sql,'Create Table');
+
+ file_put_contents($folder . '/' . $tablename . '.sql.txt', $sql);
+
+ $sql = strtolower($sql);
+ if (strpos($sql, 'innodb') === false)
+ $this->noninnodb[] = $tablename;
+ else
+ $this->innodb[] = $tablename;
+
+
+ $tables[] = $tablename;
+ }
+
+ return $tables;
+ }
+
+ /**
+ * Get database schema
+ *
+ * @param string $folder
+ * @param string $suffix
+ * @return array
+ */
+ private function capture_db_schema($folder, $suffix='')
+ {
+ $schema_folder = $folder . '/' . $suffix . 'schema';
+ mkdir($schema_folder);
+
+ return $this->capture_table_schema($schema_folder);
+ }
+
+ /**
+ * Get list of plugins
+ *
+ * @param string $filename
+ */
+ private function capture_plugins($filename)
+ {
+ $sql = 'select namespace,path, disabled, unavailable,friendly_name from plugins';
+ $result = DBUtil::getResultArray($sql);
+ $plugins = "$id $name $value\r\n";
+ }
+
+ $html .= ' Plugin Status Report
";
+
+ $plugins .= '';
+ $plugins .= '
';
+ $plugins .= 'Display Name Availability Namespace Path';
+ foreach($result as $rec)
+ {
+ $fileexists = file_exists(KT_DIR . '/' . $rec['path'])?'':'';
+ $status = ($rec['disabled'] == 0)?'':'';
+ $unavailable = ($rec['unavailable'] == 0)?'available':'unavailable';
+
+ $plugins .= ' ';
+ $plugins .= ' ' . $status . $rec['friendly_name'];
+ $plugins .= ' ' . $unavailable;
+ $plugins .= ' ' . $rec['namespace'];
+ $plugins .= ' ' . $fileexists . $rec['path'] . "\r\n";
+ }
+ $plugins .= '
Plugin name is green if enabled and orange if disabled .';
+ $plugins .= '
Availability indicates that KnowledgeTree has detected the plugin not to be available.';
+ $plugins .= '
Path is coloured red if the plugin file cannot be resolved. If the path is not resolved, it should be flagged unavailable.';
+ file_put_contents($filename, $plugins);
+ }
+
+ /**
+ * Make a zseq report
+ *
+ * @param string $tables
+ * @param string $filename
+ */
+ private function capture_zseqs($tables, $filename)
+ {
+ $zseqs = 'Table Counter Report
';
+
+ $zseqs .= '';
+ $zseqs .= '
";
+ file_put_contents($filename, $zseqs);
+ }
+
+ /**
+ * Get log files
+ *
+ * @param string $path
+ */
+ private function capture_logs($path)
+ {
+ $path = $path . '/logs';
+ mkdir($path);
+
+ $this->capture_kt_log($path);
+ $this->capture_apache_log($path);
+ $this->capture_php_log($path);
+ $this->capture_mysql_log($path);
+
+ }
+
+ /**
+ * Get Php log file. KT makes a php_error_log when tweak setting is enabled.
+ *
+ * @param string $path
+ */
+ private function capture_php_log($path)
+ {
+ $config = KTConfig::getSingleton();
+ $logdir = $config->get('urls/logDirectory');
+ $logfile = $logdir . '/php_error_log';
+ if (file_exists($logfile))
+ {
+ copy($logfile, $path . '/php-error_log.txt');
+ }
+ }
+
+ /**
+ * Get mysql log from stack. It is difficult to resolve otherwise.
+ *
+ * @param string $path
+ */
+ private function capture_mysql_log($path)
+ {
+ $stack_path = realpath(KT_DIR . '/../mysql/data');
+ if ($stack_path === false || !is_dir($stack_path))
+ {
+ return;
+ }
+
+ $dh = opendir($stack_path);
+ while (($filename = readdir($dh)) !== false)
+ {
+ if (substr($filename, -4) == '.log' && strpos($filename, 'err') !== false)
+ {
+ copy($stack_path . '/' . $filename, $path . '/mysql-' . $filename);
+ }
+ }
+ closedir($dh);
+ }
+
+ /**
+ * Get Apache log file from stack. It is difficult to resolve otherwise.
+ *
+ * @param string $path
+ */
+ private function capture_apache_log($path)
+ {
+ $stack_path = realpath(KT_DIR . '/../apache2/logs');
+ if ($stack_path === false || !is_dir($stack_path))
+ {
+ return;
+ }
+
+ $dh = opendir($stack_path);
+ while (($filename = readdir($dh)) !== false)
+ {
+ if (substr($filename, -4) == '.log' && strpos($filename, 'err') !== false)
+ {
+ copy($stack_path . '/' . $filename, $path . '/apache-' . $filename);
+ }
+ }
+ closedir($dh);
+ }
+
+ /**
+ * Get KT log file.
+ *
+ * @param string $path
+ */
+ private function capture_kt_log($path)
+ {
+ $date = date('Y-m-d');
+ $config = KTConfig::getSingleton();
+ $logdir = $config->get('urls/logDirectory');
+ $dh = opendir($logdir);
+ while (($filename = readdir($dh)) !== false)
+ {
+ if (substr($filename,0,14) != 'log-' . $date)
+ {
+ continue;
+ }
+ copy($logdir . '/' . $filename, $path . '/kt-' . $filename);
+ }
+ closedir($dh);
+ }
+
+ /**
+ * Get some basic info on Linux if possible. Get cpuinfo, loadavg, meminfo
+ *
+ * @param string $path
+ */
+ private function get_sysinfo($path)
+ {
+ if (!OS_UNIX && !is_dir('/proc'))
+ {
+ return;
+ }
+
+ $path .= '/sysinfo';
+ mkdir($path);
+
+ $this->get_sysinfo_file('cpuinfo', $path);
+ $this->get_sysinfo_file('loadavg', $path);
+ $this->get_sysinfo_file('meminfo', $path);
+
+ }
+
+ /**
+ * Helper to get linux sysinfo
+ *
+ * @param string $filename
+ * @param string $path
+ */
+ private function get_sysinfo_file($filename, $path)
+ {
+ if (!is_readable('/proc/' . $filename))
+ {
+ return;
+ }
+ $content = file_get_contents('/proc/' . $filename);
+ file_put_contents($path . '/' . $filename . '.txt', $content);
+ }
+
+ /**
+ * Helper to create the index file for the support archive.
+ *
+ * @param string $title
+ * @param string $path
+ * @param boolean $relative
+ * @return string
+ */
+
+ private function get_index_contents($title, $path, $relative = true)
+ {
+ $contents = array();
+ $dh = opendir($path);
+ while (($filename = readdir($dh)) !== false)
+ {
+ if (substr($filename,0,1) == '.') continue;
+
+ $fullname = $path . '/' . $filename;
+
+ if (!file_exists($fullname) || is_dir($fullname))
+ {
+ continue;
+ }
+
+ $contents[] = $fullname;
+ }
+ closedir($dh);
+ sort($contents);
+
+ $html = $title;
+
+ if (empty($contents))
+ {
+ $html .= 'There is no content for this section.';
+ return $html;
+ }
+
+ $dir = '';
+ if ($relative) $dir = basename($path) . '/';
+ foreach($contents as $filename)
+ {
+ $corename = basename($filename);
+ $ext = pathinfo($corename, PATHINFO_EXTENSION);
+ $basename = substr($corename, 0, -strlen($ext)-1);
+ $html .= "$basenameTable Max ID ZSEQ Status';
+
+ foreach($tables as $ztablename)
+ {
+ if (substr($ztablename, 0, 5) != 'zseq_')
+ {
+ continue;
+ }
+
+ $tablename = substr($ztablename, 5);
+ $sql = "SELECT max(id) as maxid FROM $tablename";
+ $maxid = DBUtil::getOneResultKey($sql, 'maxid');
+
+ $sql = "SELECT id FROM $ztablename";
+ $zseqid = DBUtil::getOneResultKey($sql, 'id');
+
+ $note = (is_null($maxid) || $maxid <= $zseqid)?'OK':'FAIL';
+ if ($note == 'FAIL' && $maxid > $zseqid)
+ {
+ $note = 'COUNTER PROBLEM! maxid should be less than or equal to zseq';
+ }
+ if (PEAR::isError($maxid))
+ {
+ $maxid = '??';
+ $note = "STRANGE - DB ERROR ON $tablename";
+ }
+ if (PEAR::isError($zseqid))
+ {
+ $zseqid = '??';
+ $note = "STRANGE - DB ERROR ON $ztablename";
+ }
+ if (is_null($maxid))
+ {
+ $maxid='empty';
+ }
+ if (is_null($zseqid))
+ {
+ $zseqid='empty';
+ $note = "STRANGE - ZSEQ SHOULD NOT BE EMPTY ON $ztablename";
+ }
+ $zseqs .= " $tablename $maxid $zseqid $note\r\n";
+ }
+ $zseqs .= "
";
+ }
+ return $html;
+ }
+
+ /**
+ * Create the support archvie index.htm
+ *
+ * @param string $path
+ */
+ private function create_index($path)
+ {
+ $contents = $this->get_index_contents('Support Info
', $path, false);
+
+ $contents .= $this->get_index_contents('System Info
', $path . '/sysinfo');
+ $contents .= $this->get_index_contents('Logs
', $path . '/logs');
+ $contents .= $this->get_index_contents('Schema
', $path . '/schema');
+ file_put_contents($path . '/index.htm', $contents);
+
+ }
+
+ /**
+ * Get list of tables based on InnoDB
+ *
+ * @param string $path
+ */
+
+ private function create_storage_engine($path)
+ {
+ $html = 'Table Storage Engines
';
+ $html .= '
';
+ $html .= '
';
+
+ file_put_contents($path . '/tablestorage.htm', $html);
+ }
+
+}
+
+
+
+
+?>
\ No newline at end of file
diff --git a/plugins/ktcore/admin/techsupport.php b/plugins/ktcore/admin/techsupport.php
index 20cee17..b88c6b1 100644
--- a/plugins/ktcore/admin/techsupport.php
+++ b/plugins/ktcore/admin/techsupport.php
@@ -5,32 +5,32 @@
* KnowledgeTree Open Source Edition
* Document Management Made Simple
* Copyright (C) 2004 - 2008 The Jam Warehouse Software (Pty) Limited
- *
+ *
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 3 as published by the
* Free Software Foundation.
- *
+ *
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see ';
+
+ $html .= ' InnoDB
';
+ foreach($this->innodb as $tablename)
+ {
+ $html .= "$tablename
";
+ }
+
+
+ $html .= '';
+
+ $html .= ' Non-InnoDB
';
+ foreach($this->noninnodb as $tablename)
+ {
+ $html .= "$tablename
";
+ }
+
+ $html .= '{i18n}Support and System Information{/i18n}
{capture assign=kt_tracker_location}{i18n arg_appname="$appname"}#appname# Issue Tracker{/i18n}{/capture}
-
+{i18n}The following download action allows you to download a zip archive of information that may assist the KnowledgeTree team to diagnose problems on your system. This archive contains:{/i18n}
+
+
*
+{i18n}PHP Information{/i18n}
+
*
+{i18n}Log Files (KnowledgeTree, Apache, Mysql){/i18n}
+
*
+{i18n}KnowledgeTree System Settings{/i18n}
+
*
+{i18n}KnowledgeTree Version Files{/i18n}
+
*
+{i18n}KnowledgeTree Database Schema (the structure of the database only){/i18n}
+
*
+{i18n}KnowledgeTree Database Counters Report{/i18n}
+
*
+{i18n}KnowledgeTree Database Storage Engine Report{/i18n}
+
*
+{i18n}System Information (Disk Usage, Process List, if easily detectable){/i18n}
+
*
+{i18n}MD5 Checksum of files (used to ensure files have not been tampered with){/i18n}
+
{i18n}Download Support information{/i18n} +{i18n}Download Support information{/i18n}
+ +{i18n}If you feel that the information presents to much specific information about your system (e.g. you feel that it would be a security risk to reveal aspects of it), please do sanitise the information, or ask us if you can mail it directly to the developer who is dealing with your issue.{/i18n}
-{i18n}Download PHP information{/i18n} -{i18n}Download PHP information{/i18n}
- + -- libgit2 0.21.4