-#!/usr/bin/php4 -q
+#!/usr/bin/php5 -q
<?php
/***************************************************************************
- * Copyright (C) 2003-2004 Polytechnique.org *
+ * Copyright (C) 2003-2008 Polytechnique.org *
* http://opensource.polytechnique.org/ *
* *
* This program is free software; you can redistribute it and/or modify *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
***************************************************************************/
-require('./connect.db.inc.php');
-require("newsletter.inc.php");
+require_once('./connect.db.inc.php');
+require_once('../classes/plmailer.php');
+require_once("newsletter.inc.php");
$opt = getopt('i:h');
$id = intval($opt['i']);
$nl = new NewsLetter($id);
-$nl->setSent();
-
-while(true) {
- $res = $globals->xdb->iterRow(
- "SELECT ni.user_id, a.alias,
- u.prenom, IF(u.nom_usage='', u.nom, u.nom_usage),
- FIND_IN_SET('femme', u.flags),
- q.core_mail_fmt AS pref
- FROM newsletter_ins AS ni
- INNER JOIN auth_user_md5 AS u USING(user_id)
- INNER JOIN auth_user_quick AS q ON(q.user_id = u.user_id)
- INNER JOIN aliases AS a ON(u.user_id=a.id AND FIND_IN_SET('bestalias',a.flags))
- WHERE ni.last<{?}
- LIMIT 60", $id);
- if (!$res->total()) { exit; }
-
- $sent = Array();
- while (list($uid, $bestalias, $prenom, $nom, $sexe, $fmt) = $res->next()) {
- $sent[] = "user_id='$uid'";
- $nl->sendTo($prenom, $nom, $bestalias, $sexe, $fmt=='html');
- }
- $globals->xdb->execute('UPDATE newsletter_ins SET last={?} WHERE '.implode(' OR ', $sent), $id);
- sleep(60);
-}
+$nl->sendToAll();
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
?>