瀏覽代碼

Email validation constants moved to config

Visman 5 年之前
父節點
當前提交
7d1de2129c
共有 3 個文件被更改,包括 13 次插入12 次删除
  1. 2 0
      app/Models/Pages/Auth.php
  2. 4 7
      app/Models/Validators/Email.php
  3. 7 5
      app/config/main.dist.php

+ 2 - 0
app/Models/Pages/Auth.php

@@ -236,7 +236,9 @@ class Auth extends Page
                 if ($isSent) {
                     $tmpUser->activate_string = $key;
                     $tmpUser->last_email_sent = \time();
+
                     $this->c->users->update($tmpUser);
+
                     return $this->c->Message->message(\ForkBB\__('Forget mail', $this->c->config->o_admin_email), false, 200);
                 } else {
                     return $this->c->Message->message(\ForkBB\__('Error mail', $this->c->config->o_admin_email), true, 200);

+ 4 - 7
app/Models/Validators/Email.php

@@ -8,9 +8,6 @@ use ForkBB\Models\User\Model as User;
 
 class Email extends Validators
 {
-    const FLOOD = 3600;
-    const LENGTH = 80;
-
     /**
      * Проверяет email
      * WARNING!!!
@@ -29,7 +26,7 @@ class Email extends Validators
         if (null === $email) {
             return null;
         // проверка длины email в одном месте
-        } elseif (\mb_strlen($email, 'UTF-8') > self::LENGTH) {
+        } elseif (\mb_strlen($email, 'UTF-8') > $this->c->MAX_EMAIL_LENGTH) {
             $v->addError('Long email');
             return $email;
         // это не email
@@ -82,10 +79,10 @@ class Email extends Validators
             } elseif ($user instanceof User) {
                 $flood = \time() - $user->last_email_sent;
             } else {
-                $flood = self::FLOOD;
+                $flood = $this->c->FLOOD_INTERVAL;
             }
-            if ($flood < self::FLOOD) {
-                $v->addError(\ForkBB\__('Email flood', (int) ((self::FLOOD - $flood) / 60)), 'e');
+            if ($flood < $this->c->FLOOD_INTERVAL) {
+                $v->addError(\ForkBB\__('Email flood', (int) (($this->c->FLOOD_INTERVAL - $flood) / 60)), 'e');
                 $ok = false;
             }
         }

+ 7 - 5
app/config/main.dist.php

@@ -27,21 +27,23 @@ return [
         'salt' => '_SALT_FOR_HMAC_',
     ],
     'JQUERY_LINK'      => '//ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js',
-    'DEBUG'            => 2,
+    'DEBUG'            => 0,
     'MAINTENANCE_OFF'  => false,
     'GROUP_ADMIN'      => 1,
     'GROUP_MOD'        => 2,
     'GROUP_GUEST'      => 3,
     'GROUP_MEMBER'     => 4,
-    'BBCODE_INFO' => [
+    'BBCODE_INFO'      => [
         'forSign'  => ['b', 'i', 'u', 'color', 'colour', 'email', 'img', 'url'],
         'smTpl'    => '<img src="{url}" alt="{alt}">',
         'smTplTag' => 'img',
         'smTplBl'  => ['url'],
     ],
-    'MAX_POST_SIZE' => 65536,
-    'MAX_IMG_SIZE'  => '2M',
-    'MAX_FILE_SIZE' => '2M',
+    'MAX_POST_SIZE'    => 65536,
+    'MAX_IMG_SIZE'     => '2M',
+    'MAX_FILE_SIZE'    => '2M',
+    'MAX_EMAIL_LENGTH' => 80,
+    'FLOOD_INTERVAL'   => 3600,
 
     'shared' => [
         'DB' => [