diff options
-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); |