X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;ds=sidebyside;f=include%2Fnewsletter.inc.php;h=86ce7122b01e7f52342667e0325d99df441ae7fe;hb=7d5c0b6878233e6009c6d765183591eefb6294d2;hp=b03b419b14442bca7c8b55ea9465cb2d5b4d8a4a;hpb=1dc71da137a384e771723b8a893539a7f5cc9fab;p=platal.git diff --git a/include/newsletter.inc.php b/include/newsletter.inc.php index b03b419..86ce712 100644 --- a/include/newsletter.inc.php +++ b/include/newsletter.inc.php @@ -1,6 +1,6 @@ numRows()) { - Newsletter::create(); + NewsLetter::create(); } - $res = XDB::query("SELECT * FROM newsletter WHERE bits='new'"); + $res = XDB::query("SELECT * FROM newsletter WHERE bits='new' ORDER BY id DESC LIMIT 1"); } if ($res->numRows() != 1) { throw new MailNotFound(); @@ -92,6 +92,7 @@ class NewsLetter extends MassMailer public function saveArticle(&$a) { + $a->_cid = ($a->_cid == 0) ? null : $a->_cid; if ($a->_aid >= 0) { XDB::execute('REPLACE INTO newsletter_art (id, aid, cid, pos, title, body, append) VALUES ({?}, {?}, {?}, {?}, {?}, {?}, {?})', @@ -133,7 +134,7 @@ class NewsLetter extends MassMailer $user = is_null($uid) ? S::v('uid') : $uid; $res = XDB::query("SELECT 1 FROM newsletter_ins - WHERE user_id={?}", $user); + WHERE uid={?}", $user); return $res->fetchOneCell(); } @@ -141,14 +142,14 @@ class NewsLetter extends MassMailer { $user = is_null($uid) ? S::v('uid') : $uid; XDB::execute("DELETE FROM newsletter_ins - WHERE user_id={?}", $user); + WHERE uid={?}", $user); } static public function subscribe($uid = null) { $user = is_null($uid) ? S::v('uid') : $uid; - XDB::execute("REPLACE INTO newsletter_ins (user_id,last) - VALUES ({?}, 0)", $user); + XDB::execute("REPLACE INTO newsletter_ins (uid,last) + VALUES ({?}, NULL)", $user); } protected function subscriptionWhere() @@ -308,7 +309,7 @@ class NLArticle // }}} // {{{ function getLinkIps() - public function getLinkIps(&$gethostbyname_count) + public function getLinkIps(&$blacklist_host_resolution_count) { $matches = $this->parseUrlsFromArticle(); $article_ips = array(); @@ -322,14 +323,13 @@ class NLArticle list(, $host) = explode('@', $match); } - if ($gethostbyname_count < $globals->mail->blacklist_host_resolution_limit) { + if ($blacklist_host_resolution_count >= $globals->mail->blacklist_host_resolution_limit) { break; } - if ($host != $globals->mail->alias_dom && $host != $globals->mail->alias_dom2 - && $host != $globals->mail->domain && $host != $globals->mail->domain2) { + if (!preg_match('/^(' . str_replace(' ', '|', $globals->mail->domain_whitelist) . ')$/i', $host)) { $article_ips = array_merge($article_ips, array(gethostbyname($host) => $host)); - ++$gethostbyname_count; + ++$blacklist_host_resolution_count; } } }