diff options
author | Urban Müller | 2007-08-06 14:33:27 +0000 |
---|---|---|
committer | Urban Müller | 2007-08-06 14:33:27 +0000 |
commit | e703a6394acfc60bfaedf21c94ec924a0e1c168a (patch) | |
tree | 3b19e8f1442b19c26b89fc0e6ef5f33abf0b0d6f | |
parent | 9fe36f72df3597e155d71e27eee91c86d6995193 (diff) | |
download | itools-e703a6394acfc60bfaedf21c94ec924a0e1c168a.tar.gz itools-e703a6394acfc60bfaedf21c94ec924a0e1c168a.tar.bz2 itools-e703a6394acfc60bfaedf21c94ec924a0e1c168a.zip |
prevent load explosions in case of mass alerts
-rw-r--r-- | it.class | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -101,6 +101,7 @@ function error($p = array(), $body = "", $to = "") { $stampfn = $GLOBALS['ULTRAHOME'] . "/tmp/errstamp_" . urlencode($p['id']); $stampage = time() - @filemtime($stampfn); + $lastsentfn = "/tmp/alertdata/" . $p['id']; if ($stampage >= $p['graceperiod'] && $stampage <= $p['graceperiod'] + $p['timewindow']) $sendalert = true; @@ -109,10 +110,16 @@ function error($p = array(), $body = "", $to = "") touch($stampfn); } else + { + $lastsentfn = "/tmp/alertdata/" . getmyuid() . "." . $to; $sendalert = true; + } - if ($sendalert) + if ($sendalert && (time() - @filemtime($lastsentfn)) > 3600) { + mkdir("/tmp/alertdata"); + touch($lastsentfn); + $url = ($_SERVER['HTTPS'] ? "https://" : "http://") . $_SERVER['HTTP_HOST'] .$_SERVER['REQUEST_URI']; if (!$title) $title="Error in $url"; |