From: x2000habouzit Date: Wed, 20 Oct 2004 19:31:17 +0000 (+0000) Subject: should work as a nl sender X-Git-Tag: xorg/old~1217 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=8eacc437e18d7713993d1d3ffbad8373d6175c04;p=platal.git should work as a nl sender --- diff --git a/scripts/cron/send_nl.php b/scripts/cron/send_nl.php new file mode 100755 index 0000000..00afb34 --- /dev/null +++ b/scripts/cron/send_nl.php @@ -0,0 +1,68 @@ +#!/usr/bin/php4 -q +setSent(); + +while(true) { + $sql = mysql_query("SELECT ni.user_id,ni.pref, a.alias, u.prenom,u.nom, FIND_IN_SET(i.flags, 'femme') + FROM newsletter_ins AS ni + INNER JOIN auth_user_md5 AS u USING(user_id) + INNER JOIN identification AS i USING(matricule) + INNER JOIN aliases AS a ON(u.user_id=a.id AND a.type='a_vie') + WHERE ni.last<$id + LIMIT 60"); + if(!mysql_num_rows($res)) exit(0); + $sent = Array(); + while(list($uid,$fmt,$forlife,$prenom,$nom,$sexe) = mysql_fetch_row($sql)) { + $sent[] = "user_id='$uid'"; + $nl->sendTo($prenom,$nom,$forlife,$sexe,$html=='html'); + } + mysql_free_result($res); + mysql_query("UPDATE newsletter_ins SET last=$id WHERE ".implode(' OR ',$sent)); + sleep(60); +} + +?> diff --git a/scripts/migration/0.9.1/newsleter.sql b/scripts/migration/0.9.1/newsleter.sql index 81fd142..7ef071a 100644 --- a/scripts/migration/0.9.1/newsleter.sql +++ b/scripts/migration/0.9.1/newsleter.sql @@ -6,7 +6,7 @@ alter table newsletter add column head mediumtext default '' not null; alter table newsletter add column bits enum('old','sent','new') default 'new' not null; update newsletter set bits='old'; -alter table newsletter_ins add column last int; +alter table newsletter_ins add column last int not null default 0; alter table newsletter_ins add index (last); -- -- -----------------------------------------------------------------------------