Update Pages\PostValidatorTrait

Add an external variable to calculate the interval.
This commit is contained in:
Visman 2021-04-02 17:38:52 +07:00
parent da36db897f
commit 2629842326

View file

@ -80,13 +80,14 @@ trait PostValidatorTrait
/**
* Проверка времени ограничения флуда
*/
public function vCheckTimeout(Validator $v, $submit)
public function vCheckTimeout(Validator $v, $submit, $attr, ?int $last)
{
if ($v->noValue($submit)) {
return null;
}
$time = \time() - (int) $this->user->last_post;
$last = $last > 0 ? $last : $this->user->last_post;
$time = \time() - $last;
if ($time < $this->user->g_post_flood) {
$v->addError(['Flood message', $this->user->g_post_flood - $time], 'e');