NotifySend.php
[Pman.Core] / NotifySend.php
index 5da3567..e7e1e46 100644 (file)
@@ -387,10 +387,34 @@ class Pman_Core_NotifySend extends Pman
                             continue;
                         }
                         
+                        $core_domain = DB_DataObject::factory($core_domain);
+                        if(!$core_domain->get('domain', $dom)){
+                            $core_domain = DB_DataObject::factory($core_domain);
+                            $core_domain->setFrom(array(
+                                'domain' => $dom
+                            ));
+                            $core_domain->insert();
+                        }
+                        
+                        $core_notify = DB_DataObject::factory('core_notify');
+                        $core_notify->domain_id = $core_domain->id;
+                        $core_notify->whereAdd("
+                            sent >= NOW - INTERVAL 1 HOUR
+                        ");
+                        
+                        if($core_notify->count() >= $settings['rate']){
+                            $old = clone($w);
+                            $w->act_when = date("Y-m-d H:i:s", strtotime('+1 HOUR'));
+                            $w->update($old);
+                            $this->errorHandler(date('Y-m-d h:i:s ') . " Too many emails sent by {$dom}");
+                            return;
+                        }
+                        
                         $mailer->host = $server;
                         $username = $settings['username'];
                         $password = $settings['password'];
                         
+                        
                         break;
                     }