From d0f28e6032f764bf9bb90b2898c5cafcf6c990ad Mon Sep 17 00:00:00 2001 From: Alan Knowles Date: Thu, 28 Jul 2016 11:33:48 +0800 Subject: [PATCH] NotifySend.php --- NotifySend.php | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/NotifySend.php b/NotifySend.php index e32aa7ad..d3fa06da 100644 --- a/NotifySend.php +++ b/NotifySend.php @@ -396,10 +396,31 @@ class Pman_Core_NotifySend extends Pman continue; } + // what's the minimum timespan.. - if we have 60/hour.. that's 1 every minute. + // if it's newer that '1' minute... + // then shunt it.. + + $seconds = floor((60 * 60) / $settings['rate']); + $core_notify = DB_DataObject::factory($this->table); $core_notify->domain_id = $core_domain->id; $core_notify->whereAdd(" - sent >= NOW - INTERVAL 1 HOUR + sent >= NOW() - INTERVAL $seconds SECONDS + "); + + if($core_notify->count()){ + $old = clone($w); + $w->act_when = date("Y-m-d H:i:s", time() + $seconds); + $w->update($old); + $this->errorHandler(date('Y-m-d h:i:s ') . " Too many emails sent by {$dom}"); + } + + + + $core_notify = DB_DataObject::factory($this->table); + $core_notify->domain_id = $core_domain->id; + $core_notify->whereAdd(" + sent >= NOW() - INTERVAL 1 HOUR "); if($core_notify->count() >= $settings['rate']){ @@ -409,6 +430,9 @@ class Pman_Core_NotifySend extends Pman $this->errorHandler(date('Y-m-d h:i:s ') . " Too many emails sent by {$dom}"); } + + + $mailer->host = $server; $username = $settings['username']; $password = $settings['password']; -- 2.39.2