diff --git a/src/Controller/AppController.php b/src/Controller/AppController.php index 551fd49..2438735 100644 --- a/src/Controller/AppController.php +++ b/src/Controller/AppController.php @@ -94,7 +94,6 @@ class AppController extends Controller public function beforeFilter(EventInterface $event) { - //$this->request_ip = Configure::read('') $this->loadModel('Users'); $this->Users->checkForNewInstance(); $this->authApiUser(); @@ -150,6 +149,9 @@ class AppController extends Controller $this->set('metaGroup', !empty($this->isAdmin) ? 'Administration' : 'Cerebrate'); } } + if (mt_rand(1, 50) === 1) { + $this->FloodProtection->cleanup(); + } } private function authApiUser(): void diff --git a/src/Controller/Component/FloodProtectionComponent.php b/src/Controller/Component/FloodProtectionComponent.php index d61c6d3..6fbd0ec 100644 --- a/src/Controller/Component/FloodProtectionComponent.php +++ b/src/Controller/Component/FloodProtectionComponent.php @@ -53,6 +53,6 @@ class FloodProtectionComponent extends Component public function cleanup(): void { - $this->FloodProtection->deleteAll(['expiration' < time()]); + $this->FloodProtections->deleteAll(['expiration <' => time()]); } }