From ebda82d787b3620424c1dcf4336146ea06815a55 Mon Sep 17 00:00:00 2001 From: jhunkeler Date: Wed, 23 Dec 2009 17:38:13 +0000 Subject: New debugging methods implements. config.php has two new options, "show_messages", and "repeat messages". If a "show_messages" is enabled any decho statements are rendered above the site footer. git-svn-id: http://svn.3rd-infantry-division.org/testing/branches/Bayonet CMS v2@395 c5b2fb0a-d05d-0410-98c8-828840a80ff6 --- blocks/rss_agw/index.php | 19 ++++++------ footer.php | 10 +++++++ includes/debug.php | 78 +++++++++++++++++++++++++++++++++++++----------- includes/functions.php | 3 +- includes/sql.class.php | 14 ++++++--- 5 files changed, 91 insertions(+), 33 deletions(-) diff --git a/blocks/rss_agw/index.php b/blocks/rss_agw/index.php index e59414a..4438a98 100644 --- a/blocks/rss_agw/index.php +++ b/blocks/rss_agw/index.php @@ -13,38 +13,37 @@ function stripBBCode($text_to_search) { $cacheFile = dirname(__FILE__) . "/rss.cache"; $url = 'http://www.armedglobalwarfare.com/index.php?type=rss;action=.xml;limit=150'; - if(!file_exists($cacheFile)) { - decho("creating cache
"); + decho("Creating RSS cache"); $fp = fopen($cacheRead, "x+"); fclose($fp); } - decho("reading internal cache state
"); + decho("Reading internal RSS cache state"); $internal = fopen($cacheFile, "r"); $cacheRead = fread($internal, $cacheReadLength); fclose($internal); - decho("reading inbound cache data
"); - $inbound = fopen($url, "r+"); + decho("Reading inbound RSS cache data"); + $inbound = fopen($url, "r"); $cacheTempRead = fread($inbound, $cacheReadLength); fclose($inbound); - decho("comparing
"); + decho("Comparing RSS caches"); if((strncmp($cacheTempRead, $cacheRead, $cacheReadLength)) == 0) { $cacheTemp = implode('', file($url)); - decho("Length of cached RSS is " . strlen($cacheTemp) . "
"); - decho("Writing cached data to file
"); + decho("Length of cached RSS is " . strlen($cacheTemp)); + decho("Writing cached RSS data to file"); $cachefp = fopen($cacheFile, "w+"); $cacheWritten = fwrite($cachefp, $cacheTemp, strlen($cacheTemp)); fclose($cachefp); - decho("$cacheWritten bytes written to cache.
"); + decho("$cacheWritten bytes written to RSS cache.
"); } else { - decho("cache matches external source, using internal
"); + decho("RSS cache matches external source, using internal"); } $rss->load($cacheFile); diff --git a/footer.php b/footer.php index 8437681..0c4d510 100644 --- a/footer.php +++ b/footer.php @@ -24,6 +24,16 @@ $debug_output = sprintf("Page generated in %.3f seconds | Memory: real(%.3fmb) p $totaltime, ((float)memory_get_usage()/1024/1024), ((float)memory_get_peak_usage()/1024/1024), $phpversion, $db_queries, $db_fetches); ?> + + +
+   +
+ +
+
+ + "; } +/* function decho($message, $flag = REPEAT) { global $last_message, $last_message_count; @@ -130,7 +174,7 @@ function decho($message, $flag = REPEAT) $last_message = $message; } - +*/ ?> \ No newline at end of file diff --git a/includes/functions.php b/includes/functions.php index 0203d34..73c506c 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -340,8 +340,7 @@ function fatal_error_handler($buffer) { function handle_error ($errno, $errstr, $errfile, $errline) { - //error_log("$errstr in $errfile on line $errline"); - //ReportError("
$errstr
"); + //decho("Warning: $errfile:$errline, $errstr"); push_error_stack("Error Number: $errno
Error: $errstr
In File: $errfile
Line: $errline"); if($errno == FATAL || $errno == ERROR){ push_error_stack($errstr); diff --git a/includes/sql.class.php b/includes/sql.class.php index 57fdd5d..0dcd0d5 100644 --- a/includes/sql.class.php +++ b/includes/sql.class.php @@ -16,7 +16,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - + static $db_queries = 0; static $db_connections = 0; static $db_frees = 0; @@ -68,6 +68,7 @@ class Bayonet_SQL }catch(Exception $e){ } */ + return mysql_query($str); } @@ -75,12 +76,12 @@ class Bayonet_SQL { global $db_frees; ++$db_frees; - //decho("Freeing ('$result')"); + decho("Freeing result"); return mysql_free_result($result); } public function Fetch($result) - { + { return $this->FetchArray($result); } @@ -88,7 +89,8 @@ class Bayonet_SQL { global $db_fetches; ++$db_fetches; - /* Alias Fetch() prefered, so no decho information */ + /* Alias Fetch() prefered, so no decho information */ + decho("Fetching result"); return mysql_fetch_array($result,MYSQL_ASSOC); } @@ -96,6 +98,7 @@ class Bayonet_SQL { global $db_fetches; ++$db_fetches; + decho("Fetching object result"); return mysql_fetch_object($result,$class); } @@ -103,16 +106,19 @@ class Bayonet_SQL { global $db_fetches; ++$db_fetches; + decho("Fetching assoc result"); return mysql_fetch_assoc($result); } public function FetchRow($result) { + decho("Fetching single row"); return mysql_fetch_row($result); } public function Rows($result) { + decho("Fetching number of rows"); return mysql_num_rows($result); } } -- cgit