diff options
author | Urban Müller | 2007-09-24 14:41:28 +0000 |
---|---|---|
committer | Urban Müller | 2007-09-24 14:41:28 +0000 |
commit | 47af49faf2d4f65c87cb9d6ac4e731246fe848cd (patch) | |
tree | 2eb68dbb197bb55fd7f36f367d2546ad523cf11f | |
parent | 2b349e1782802a6bee34ed72e8da9204f0db635a (diff) | |
download | itools-47af49faf2d4f65c87cb9d6ac4e731246fe848cd.tar.gz itools-47af49faf2d4f65c87cb9d6ac4e731246fe848cd.tar.bz2 itools-47af49faf2d4f65c87cb9d6ac4e731246fe848cd.zip |
sparse it:error output in shell mode
-rw-r--r-- | it.class | 23 |
1 files changed, 12 insertions, 11 deletions
@@ -122,27 +122,26 @@ function error($p = array(), $body = "", $to = "") $sendalert = true; } - if ($sendalert && (!ereg('live', $GLOBALS['ULTRASERVERTYPE']) || (time() - @filemtime($lastsentfn)) > 3600)) + $toscreen = !ereg('live', $GLOBALS['ULTRASERVERTYPE']); + + if ($sendalert && ($toscreen || (time() - @filemtime($lastsentfn)) > 3600)) { @mkdir("/tmp/alertdata"); @chmod("/tmp/alertdata", 0777); touch($lastsentfn); @chmod($lastsentfn, 0666); - $url = ($_SERVER['HTTPS'] ? "https://" : "http://") . $_SERVER['HTTP_HOST'] .$_SERVER['REQUEST_URI']; + if ($_SERVER['REMOTE_ADDR']) + $url = ($_SERVER['HTTPS'] ? "https://" : "http://") . $_SERVER['HTTP_HOST'] .$_SERVER['REQUEST_URI']; if (!$title) - $title="Error in $url"; + $title="Error in " . trim($url); if (!function_exists('memory_get_usage') || (memory_get_usage() < 50000000)) - $trace = "\n\nTrace: " . it_debug::backtrace($p['backtraceskip']); + $trace = it_debug::backtrace($p['backtraceskip']); - $body .= "\nUrl: $url$trace"; + $body .= ($url ? "\nUrl: $url" : "") . ($trace ? "\n\nTrace: " . $trace : ""); - if (!ereg('live', $GLOBALS['ULTRASERVERTYPE'])) - { - echo "<pre>$title\n$body\n</pre>"; - } - else + if (!$toscreen) { $cmd = "alert -l " . escapeshellarg($to) . " 4 " . escapeshellarg($title); @@ -154,9 +153,11 @@ function error($p = array(), $body = "", $to = "") pclose($pipe); } } + else if ($_SERVER['REMOTE_ADDR']) + echo "<pre>$title\n$body\n</pre>"; } - error_log("it::error: ".$title); + error_log("it::error: ".$title . ": " . $trace . (EDC('verbose') ? D($p['locals']) : "")); } |