diff options
author | Urban Müller | 2007-11-02 12:56:28 +0000 |
---|---|---|
committer | Urban Müller | 2007-11-02 12:56:28 +0000 |
commit | 9b0f1fe9941e4636253bb9bb77f33b5b759af29b (patch) | |
tree | 5489a7bb975bb7bd03ba530af5825f74e1648fc6 /it_debug.class | |
parent | 7e71d3f6fd54e8370f051b4dd35d9b782aeeaa2e (diff) | |
download | itools-9b0f1fe9941e4636253bb9bb77f33b5b759af29b.tar.gz itools-9b0f1fe9941e4636253bb9bb77f33b5b759af29b.tar.bz2 itools-9b0f1fe9941e4636253bb9bb77f33b5b759af29b.zip |
extract source line procurement
Diffstat (limited to 'it_debug.class')
-rw-r--r-- | it_debug.class | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/it_debug.class b/it_debug.class index bd81720..3aedda7 100644 --- a/it_debug.class +++ b/it_debug.class @@ -52,6 +52,26 @@ function debug($text, $level = 0) } } +/** + * Get source line of grandparent calling this function + * @param $stacksoffs go up an extra $stacksoffs levels + */ + +function srcline($stackoffs = 0) +{ + $stack = debug_backtrace(); + $line = $stack[1 + $stackoffs]['line']; + $file = $stack[1 + $stackoffs]['file']; + + if (!isset($GLOBALS['it_debug::dump source'][$file])) + $GLOBALS['it_debug::dump source'][$file] = file($file); + + if (!$_SERVER['REMOTE_ADDR'] && substr($GLOBALS['it_debug::dump source'][$file][0], 0, 2) == "#!") + $line++; + + return $GLOBALS['it_debug::dump source'][$file][$line-1]; +} + /** * Backend for functions D(), ED() and EDX() in functions.php @@ -60,13 +80,6 @@ function debug($text, $level = 0) */ 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']) @@ -82,11 +95,7 @@ function dump($args) $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]; - + $src = it_debug::srcline(1); list($function, $paramlist) = it::match('\b(D|ED|EDC|EDX)\s*\((.*)', $src); $paramtokens = token_get_all("<?php $paramlist"); array_shift($paramtokens); |