From: Florent Bruneau Date: Sat, 10 Nov 2007 17:22:49 +0000 (+0100) Subject: Just a bit of fun... X-Git-Tag: xorg/0.9.16~213 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=816d3bd09dc09ab309cf6cdf38c451c0cc1f740b;p=platal.git Just a bit of fun... Signed-off-by: Florent Bruneau --- diff --git a/bin/cron/cron_validations.php b/bin/cron/cron_validations.php index 4cab467..c0818c1 100755 --- a/bin/cron/cron_validations.php +++ b/bin/cron/cron_validations.php @@ -29,8 +29,27 @@ $R_PERIOD = "INTERVAL 6 HOUR"; // période de réponse moyenne de 6h require('./connect.db.inc.php'); require('plmailer.php'); -$res = XDB::query("SELECT count(stamp), sum(stamp < NOW() - $M_PERIOD), sum(stamp < NOW() - $R_PERIOD) FROM x4dat.requests"); -list($nb,$nbold,$nbveryold) = $res->fetchOneRow(); +$res = XDB::query("SELECT count(r.stamp), UNIX_TIMESTAMP(MIN(r.stamp)), + sum(r.stamp < NOW() - $M_PERIOD), sum(r.stamp < NOW() - $R_PERIOD) + FROM x4dat.requests AS r"); +list($nb, $age, $nbold, $nbveryold) = $res->fetchOneRow(); + +$age = (time() - intval($age)) / 86400; +$head = ""; +if ($age > 15) { + $head = "[autodestruction du serveur] "; +} elseif ($age > 7) { + $head = "[armageddon imminent] "; +} elseif ($age > 5) { + $head = "[guerre nucléaire] "; +} elseif ($age > 3) { + $head = "[ET Téléphone maison] "; +} elseif ($age > 1) { + $head = "[réveil !] "; +} elseif (!empty($nbveryold)) { + $head = "[urgent] "; +} + if (empty($nb)) { exit; @@ -41,7 +60,7 @@ $plural = $nb == 1 ? "" : "s"; $mymail = new PlMailer(); $mymail->setFrom('validation@' . $globals->mail->domain); $mymail->addTo("validation@" . $globals->mail->domain); -$mymail->setSubject((empty($nbveryold)?"":"[urgent] ")."il y a $nb validation$plural non effectuée$plural"); +$mymail->setSubject($head . "il y a $nb validation$plural non effectuée$plural"); $message = "il y a $nb validation$plural à effectuer \n"