From 54a07d8697d06327a43819395c546696e857f749 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Wed, 23 Nov 2005 21:05:41 +0000 Subject: [PATCH] Create debug module in page_end() and query debug --- printer.php | 127 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 127 insertions(+) diff --git a/printer.php b/printer.php index 978929d..2dab9b4 100644 --- a/printer.php +++ b/printer.php @@ -136,6 +136,11 @@ EOD; */ function page_start($actiontitle, $pageclass = ':default:', $pagemargin = 15, $extra = '', $onload = false, $margin = 0, $dotpath = '.', $override = false) { + if ($this->registry->debug AND isset($_GET['query'])) + { + ob_start(); + } + if (constant('DONE_HEADER') AND !$override) { return; @@ -246,6 +251,23 @@ EOD; */ function page_end() { + if ($this->registry->debug AND isset($_GET['query'])) + { + ob_clean(); + ob_end_clean(); + + if (is_array($this->registry->modules['db_mysql']->history)) + { + echo '
';
+				foreach ($this->registry->modules['db_mysql']->history AS $query)
+				{
+					echo $query . "\n\n
\n\n"; + } + echo '
'; + } + exit; + } + $copyright = "\n
\n

\n\t" . $this->registry->application . ' ' . $this->registry->appversion . ", © 2002 - " . date('Y') . " Iris Studios, Inc.\n

"; if (!defined('HIDE_SETUP')) @@ -256,6 +278,111 @@ EOD; { echo "\n\n"; } + + if ($this->registry->debug) + { + // source control + $scinfo = 'Not Under Source Control'; + $possiblescms = array('cvs', 'svn', 'cvs_information', 'svn_information', 'scm', 'sc_information', 'scm_information'); + foreach ($possiblescms AS $scm) + { + if (defined(strtoupper($scm))) + { + $scinfo = constant(strtoupper($scm)); + + $type = ''; + // CVS + if (strpos($scinfo, 'RCSfile:') !== false) + { + $type = 'cvs'; + } + else if (strpos($scinfo, ',v ') !== false) + { + $type = 'cvs'; + } + // SVN + else if (strpos($scinfo, 'URL:') !== false) + { + $type = 'svn'; + } + else if (strpos($scinfo, 'https://') !== false OR strpos($scinfo, 'http://') !== false) + { + $type= 'svn'; + } + // not found so just return it + // try a SVN ID tag as we can't really tell if we're using it + else + { + $test = preg_replace('#\$' . 'Id: (.+?) (.+?) [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}(.+?) (.+?) \$#', '\\1 - SVN \\2', $scinfo); + if ($test == '$' . 'Id: $') + { + $scinfo = 'Not Under Source Control'; + } + else + { + $scinfo = $test; + } + break; + } + + if ($type == 'cvs') + { + $scinfo = preg_replace('#\$' . 'RCSfile: (.+?) \$#', '\\1', $scinfo); + $scinfo = preg_replace('#\$' . 'Revision: (.+?) \$#', 'CVS \\1', $scinfo); + $scinfo = preg_replace('#\$' . 'Id: (.+?) (.+?) [0-9]{4}/[0-9]{2}/[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2} (.+?) (.+?) \$#', '\\1 - CVS \\2', $scinfo); + } + else if ($type == 'svn') + { + $scinfo = preg_replace('#\$' . '(Head)?URL: (.+?) \$#e', "end(explode('/', '\\2'))", $scinfo); + $scinfo = preg_replace('#\$' . '(LastModified)?Revision: (.+?) \$#', 'SVN \\2', $scinfo); + $scinfo = preg_replace('#\$' . 'Id: (.+?) ([0-9].+?) [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}(.+?) (.+?) \$#', '\\1 - SVN \\2', $scinfo); + } + else + { + $scinfo = 'Not Under Source Control'; + } + break; + } + } + $scinfo = trim($scinfo); + $debug .= "\n\t
  • Source Control: $scinfo
  • "; + + // query information + if (is_object($this->registry->modules['db_mysql'])) + { + $debug .= "\n\t
  • Total Queries: " . sizeof($this->registry->modules['db_mysql']->history) . " (registry->sanitize($_SERVER['REQUEST_URI']) . ((strpos($_SERVER['REQUEST_URI'], '?') !== false) ? '&query=1' : '?query=1') . "\">?)
  • "; + } + + // total execution time + if (defined('ISSO_MT_START')) + { + $this->registry->load('functions', 'functions'); + $debug .= "\n\t
  • Total Execution Time: " . round($this->registry->modules['functions']->fetch_microtime_diff(ISSO_MT_START), 10) . "
  • "; + } + + // debug notices + $debug .= "\n\t
  • \n\t\t\n\t
  • "; + + // loaded modules + $modules = $this->registry->show_modules(true); + $debug .= "\n\t
  • \n\t\t\n\t
  • "; + + // --- END + $debug .= "\n"; + + $debug = "\n
    \n" . $this->registry->_message('Debug Information', $debug, 1, true, false); + echo "\n\n\n
    \n$debug\n
    \n\n\n"; + } echo "\n\n\n"; -- 2.22.5