X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=bin%2Fcron%2Fcron_validations.php;h=0b73a49084a88c6154386f8c93e0987558721b23;hb=7996ae8cd41fbb3ccd748eaed71a50f866269c6e;hp=6c67503296e0a72f4f1092b213c1ebe04ea21e11;hpb=fb813fb52d5ab65ca9a5b92b5cb9089523380d79;p=platal.git diff --git a/bin/cron/cron_validations.php b/bin/cron/cron_validations.php index 6c67503..0b73a49 100755 --- a/bin/cron/cron_validations.php +++ b/bin/cron/cron_validations.php @@ -19,15 +19,16 @@ * Foundation, Inc., * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * ***************************************************************************/ -/* vim: set sw=4 ts=4 sts=4 tw=100: - * vérifie qu'il n'y a pas de validations en cours, et maile si c'est le cas -*/ -$M_PERIOD = "INTERVAL 3 HOUR"; // période d'envoi des mails de 3h -$R_PERIOD = "INTERVAL 6 HOUR"; // période de réponse moyenne de 6h +/** Check if there is some pending validations, + * and if so sends notification email. + */ -require('connect.db.inc.php'); -require('plmailer.php'); +$M_PERIOD = "INTERVAL 3 HOUR"; // 3 hour lap (old validations) +$R_PERIOD = "INTERVAL 6 HOUR"; // 6 hour lap (very old validations) + +require 'connect.db.inc.php'; +require 'plmailer.php'; $res = XDB::query("SELECT count(r.stamp), UNIX_TIMESTAMP(MIN(r.stamp)), sum(r.stamp < NOW() - $M_PERIOD), sum(r.stamp < NOW() - $R_PERIOD) @@ -35,7 +36,7 @@ $res = XDB::query("SELECT count(r.stamp), UNIX_TIMESTAMP(MIN(r.stamp)), list($nb, $age, $nbold, $nbveryold) = $res->fetchOneRow(); $age = (time() - intval($age)) / 86400; -$head = ""; +$head = ''; if ($age > 15) { $head = "[Autodestruction du serveur] "; } elseif ($age > 7) { @@ -55,30 +56,31 @@ if (empty($nb)) { exit; } -$plural = $nb == 1 ? "" : "s"; +$plural = $nb == 1 ? '' : 's'; $mymail = new PlMailer(); $mymail->setFrom('validation@' . $globals->mail->domain); -$mymail->addTo("validation@" . $globals->mail->domain); +$mymail->addTo('validation@' . $globals->mail->domain); $mymail->setSubject($head . "Il y a $nb validation$plural non effectuée$plural"); $message = "Il y a $nb validation$plural à effectuer\n" - .(empty($nbold)?"":"dont $nbold depuis le dernier mail !!!\n") - .(empty($nbveryold)?"":"et dont *$nbveryold* ".($nbveryold == 1 ? "est" : "sont")." en retard de plus de 6h !!!") - ."\n" - ."https://www.polytechnique.org/admin/validate\n\n" - ."Par catégorie :\n"; -$res = XDB::iterRow("SELECT type, count(*) + . (empty($nbold) ? '' : "dont $nbold depuis le dernier mail !!!\n") + . (empty($nbveryold) ? '' : "et dont *$nbveryold* " . ($nbveryold == 1 ? 'est' : 'sont') . ' en retard de plus de 6h !!!') + . "\n" + . "https://www.polytechnique.org/admin/validate\n\n" + . "Par catégorie :\n"; +$res = XDB::iterRow('SELECT type, count(*) FROM requests GROUP BY type - ORDER BY type"); + ORDER BY type'); while (list($type, $nb) = $res->next()) { $message .= "- $type : $nb\n"; } -$message = wordwrap($message,78); +$message = wordwrap($message, 78); $mymail->setTxtBody($message); $mymail->send(); + // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: ?>