diff options
author | Urban Müller | 2013-12-12 16:47:33 +0100 |
---|---|---|
committer | Urban Müller | 2013-12-12 16:47:33 +0100 |
commit | ee68e001936050a0999bb3fcc12d87fa2fe04bf4 (patch) | |
tree | 07eb76ed66b4c4b713736972a0bb55cb4f1ea775 /it.class | |
parent | dfa062451083811252d469dc5636870def73c5d2 (diff) | |
download | itools-ee68e001936050a0999bb3fcc12d87fa2fe04bf4.tar.gz itools-ee68e001936050a0999bb3fcc12d87fa2fe04bf4.tar.bz2 itools-ee68e001936050a0999bb3fcc12d87fa2fe04bf4.zip |
support edge triggered errors, support special chars in blockmailid
Diffstat (limited to 'it.class')
-rw-r--r-- | it.class | 14 |
1 files changed, 13 insertions, 1 deletions
@@ -120,6 +120,8 @@ static function timerlog($label = '') * @param $p['skipfiles'] files to skip in backtrace * @param $p['blockmail'] number of seconds to block mails after having sent a mail [3600] * @param $p['blockmailid'] block mail for $p['blockmail'] seconds with same id. Default: $p['to'] + * @param $p['okstate'] give current ok label and state, e.g. telresult=1 . see failcount + * @param $p['failcount'] give number of consecutive okstate failures needed for creating an error [2] * @param $p['omitdebuginfo'] Do not add stack dump, locals and environment to output [false] * @return true if a mail was sent */ @@ -144,12 +146,22 @@ static function error($p = array(), $body = null, $to = null) # $body and $to de 'backtraceskip' => 0, 'blockmail' => 3600, 'omitdebuginfo' => false, + 'failcount' => 2, ); $p += array('blockmailid' => md5($p['to'])); @mkdir("/tmp/alertdata"); @chmod("/tmp/alertdata", 0777); + if ($p['okstate']) + { + list($okid, $okstatus) = explode("=", $p['okstate']); + $failcount = $okstatus ? 0 : file_get_contents("/tmp/alertdata/$okid") + 1; + file_put_contents("/tmp/alertdata/$okid", "$failcount\n"); + if ($failcount != $p['failcount']) + return; + } + $toscreen = getenv('NOERRORMAILS') || ini_get('display_errors') || (defined("STDOUT") && posix_isatty(STDOUT)) || EDC('astwin') || EDC('asdevel'); @fseek(STDOUT, 0, SEEK_END); # Work around PHP bug 49819: posix_isatty seeks to start @@ -174,7 +186,7 @@ static function error($p = array(), $body = null, $to = null) # $body and $to de if ($sendmail) { - $lastsentfn = "/tmp/alertdata/lastsent_" . getmyuid() . "." . $p['blockmailid']; + $lastsentfn = "/tmp/alertdata/lastsent_" . getmyuid() . "." . urlencode($p['blockmailid']); $now = time(); clearstatcache(); $lastsenttime = @filemtime($lastsentfn); |