Ver Fonte

发验证码邮箱

541469799@qq.com há 1 ano atrás
pai
commit
d45dd49045
2 ficheiros alterados com 9 adições e 1 exclusões
  1. 8 0
      app/common.php
  2. 1 1
      app/index/controller/Captcha.php

+ 8 - 0
app/common.php

@@ -432,6 +432,14 @@ function hide_mobile(string $mobile): string
     return substr_replace($mobile, '****', 3, 4);
 }
 
+function is_email(string $email) : bool
+{
+    if (preg_match('/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/', $email)) {
+        return true;
+    }
+    return false;
+}
+
 /**
  * 获取当前登录的商城ID
  * @return int $storeId

+ 1 - 1
app/index/controller/Captcha.php

@@ -63,7 +63,7 @@ class Captcha extends Controller
     {
         $data = $this->postForm();
         $email = $data['mobile'] ?? '';
-        if (empty($email)) {
+        if (empty($email) || !is_email($email)) {
             return $this->renderError('Invalid email address.');
         }