diff options
author | Urban Müller | 2007-07-26 13:02:24 +0000 |
---|---|---|
committer | Urban Müller | 2007-07-26 13:02:24 +0000 |
commit | 806a5297e7e99d455b97a4f0acaba2f40f470584 (patch) | |
tree | b9fc43ef227da87d873cf3676c08c49fa0dc1240 /debug.class | |
parent | c3cba034c8009b65c25dd4ef5f54b18d9c8ee7d4 (diff) | |
download | itools-806a5297e7e99d455b97a4f0acaba2f40f470584.tar.gz itools-806a5297e7e99d455b97a4f0acaba2f40f470584.tar.bz2 itools-806a5297e7e99d455b97a4f0acaba2f40f470584.zip |
renamed files for autoloader
Diffstat (limited to 'debug.class')
-rw-r--r-- | debug.class | 138 |
1 files changed, 0 insertions, 138 deletions
diff --git a/debug.class b/debug.class deleted file mode 100644 index 61b4889..0000000 --- a/debug.class +++ /dev/null @@ -1,138 +0,0 @@ -<?php -/* -** $Id$ -** -** debug.class - Debug Functionality for ITools -** -** ITools - the Internet Tools Library -** -** Copyright (C) 1995-2003 by the ITools Authors. -** This program is free software; you can redistribute it and/or -** modify it under the terms of either the GNU General Public License -** or the GNU Lesser General Public License, as published by the Free -** Software Foundation. See http://www.gnu.org/licenses/ for details. -*/ - -/** - * Debug functions - */ -class it_debug -{ - var $level; - -/** - * Constructor - * @param $level Debug level. All debug() calls with a level <= $level are shown. - */ -function it_debug($level=0) -{ - $this->level = isset($GLOBALS['debug_level']) ? $GLOBALS['debug_level'] : $level; -} - - -/** - * Output a message if the global debug level is higher or the same as $level - * @param $text Message to display - * @param $level Debug level - */ -function debug($text, $level = 0) -{ - if ($this->level >= $level) - { - echo (isset($_SERVER['REMOTE_ADDR']) ? nl2br("$level $text\n") : "$level $text")."\n"; - flush(); - } -} - - -/** - * Backend for functions D(), ED() and EDX() in functions.php - * @param Origargs Array containing original arguments do ED() etc - * @return String representation of dump - */ -function dump($args) -{ - $stack = debug_backtrace(); - $line = $stack[1]['line']; - $file = $stack[1]['file']; - - if (!$_SERVER['REMOTE_ADDR'] && (substr(file_get_contents($file), 0, 2) == "#!")) - $line++; - - if (ereg('(csv|txt|gif|jpg)', $_SERVER['PHP_SELF']) || !ereg('Mozilla', $_SERVER['HTTP_USER_AGENT'])) - $plain = 1; - else if ($_SERVER['REMOTE_ADDR']) - { - $blue = "<span style='color:#00c'>"; - $noblue = "</span>"; - } - else if (getenv('USER') != 'cschneid') # ;) - { - $blue = "\033[34m"; - $noblue = "\033[m"; - $red = "\033[31m"; - $nored = "\033[m"; - } - - if (!isset($GLOBALS['it_debug::dump source'][$file])) - $GLOBALS['it_debug::dump source'][$file] = file($file); - - $src = $GLOBALS['it_debug::dump source'][$file][$line-1]; - - $paramlist = preg_match('/(D|ED|EDC|EDX)\s*\(\s*([^)]+)/i', $src, $parts) ? $parts[2] : ""; - $argnames = preg_split('/\s*,\s*/', $paramlist); - - if ($parts[1] == "EDC") # First argument was stripped by EDC - array_shift($argnames); - - foreach ($args as $arg) - { - $var = array_shift($argnames); - $item = gettype($arg) == 'resource' ? trim(print_r($arg, true)) : trim(var_export($arg, true)); - - # Replace PHP 5 var_export object representation by old style - while (preg_match("#(.*\b)(\w+)::__set_state\(array\(([^()]+)\)\)(.*)#s", $item, $regs)) - { - list (, $head, $classname, $values, $tail) = $regs; - $classname = strtolower($classname); - $values = preg_replace("#'(\w+)' =>([^\n]+),#", 'var \$$1 = $2;', $values); - $item = $head . "class $classname { $values }$tail"; - } - - $item = preg_replace("#(=>?)\s*\n\s*(array|class)#", '$1 $2', $item); # array( and class on same line as key - $item = preg_replace('#array \(\s+([^({,;]+),\s+\)#', 'array( $1 )', $item); # 1-element arrays on 1 line - $item = preg_replace('#class (\S+) \{\s+([^({,;]+;)?\s+\}#', 'class $1 { $2 }', $item); # 1-element objects on 1 line - #$item = preg_replace('#\{\s*var \$attr#', '{ var $attr', $item); # move $attr on same line - $item = preg_replace("#\\(\s*\n\s*\\)#", "()", $item); # empty arrays on 1 line - #$item = preg_replace('#\s+var \$_(.|\n)*?;\s*\n#', "", $item); - $item = "$red$item$nored"; - - if (isset($_SERVER['REMOTE_ADDR']) && !$plain) - $item = htmlspecialchars($item); - - if (ereg('^[\'"]', $var)) - $r .= "$item "; - else { - $var = "$blue$var=$noblue"; - $r .= preg_match("/\n/", $item) ? "\n$var$item\n" : "$var$item "; - } - } - - if ($GLOBALS['debug_indent']) - $r = str_repeat(" ", count(debug_backtrace())-3) . $r; - - if (isset($_SERVER['REMOTE_ADDR']) && !$plain) - return "<pre style='color:#c00; text-align:left; background-color:white; margin:0'>$r</pre>\n"; - else - return "$r\n"; -} - -function backtrace() -{ - foreach (array_slice(debug_backtrace(), 1) as $call) - $line .= basename($call['file']) . ":" . $call['line'] . " "; - return $line; -} - -} -?> |