From e703a6394acfc60bfaedf21c94ec924a0e1c168a Mon Sep 17 00:00:00 2001 From: Urban Müller Date: Mon, 6 Aug 2007 14:33:27 +0000 Subject: prevent load explosions in case of mass alerts --- it.class | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'it.class') diff --git a/it.class b/it.class index 277439a..4fa274a 100644 --- a/it.class +++ b/it.class @@ -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"; -- cgit v1.2.3