From 170850efefcf670c388f1dfaa9e7a05867d0277b Mon Sep 17 00:00:00 2001 From: aa820t Date: Sun, 30 Jul 2023 01:17:41 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=90=8E=E5=8F=B0=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E6=A1=86=E5=92=8C=E9=AA=8C=E8=AF=81=E7=A0=81=E9=AB=98=E5=BA=A6?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E4=B8=BA40px=20api=E7=9A=84Ems,Sms,Validate?= =?UTF-8?q?=E5=A4=9A=E8=AF=AD=E8=A8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/view/index/login.html | 3 ++- application/api/controller/Ems.php | 28 ++++++++++---------- application/api/controller/Sms.php | 34 ++++++++++++------------- application/api/controller/Validate.php | 16 ++++++------ application/api/lang/zh-cn/ems.php | 11 ++++++++ application/api/lang/zh-cn/sms.php | 12 +++++++++ application/api/lang/zh-cn/validate.php | 10 ++++++++ 7 files changed, 74 insertions(+), 40 deletions(-) create mode 100644 application/api/lang/zh-cn/ems.php create mode 100644 application/api/lang/zh-cn/sms.php create mode 100644 application/api/lang/zh-cn/validate.php diff --git a/application/admin/view/index/login.html b/application/admin/view/index/login.html index 68d4a5f8..b5b944d8 100644 --- a/application/admin/view/index/login.html +++ b/application/admin/view/index/login.html @@ -73,6 +73,7 @@ #login-form .form-control { font-size: 13px; + height: 40px; } @@ -117,7 +118,7 @@
- + {/if} diff --git a/application/api/controller/Ems.php b/application/api/controller/Ems.php index 1a37c1b5..9ee6a1ac 100644 --- a/application/api/controller/Ems.php +++ b/application/api/controller/Ems.php @@ -25,7 +25,7 @@ class Ems extends Api * * @ApiMethod (POST) * @param string $email 邮箱 - * @param string $event 事件名称 + * @param string $event 事件名称,register,changeemail,resetpwd */ public function send() { @@ -37,32 +37,32 @@ class Ems extends Api //发送前验证码 if (config('fastadmin.user_api_captcha')) { if (!\think\Validate::is($captcha, 'captcha')) { - $this->error("验证码不正确"); + $this->error(__('Verification code is incorrect')); } } $last = Emslib::get($email, $event); if ($last && time() - $last['createtime'] < 60) { - $this->error(__('发送频繁')); + $this->error(__('Send frequently')); } if ($event) { $userinfo = User::getByEmail($email); if ($event == 'register' && $userinfo) { //已被注册 - $this->error(__('已被注册')); + $this->error(__('Already registered')); } elseif (in_array($event, ['changeemail']) && $userinfo) { //被占用 - $this->error(__('已被占用')); + $this->error(__('Already occupied')); } elseif (in_array($event, ['changepwd', 'resetpwd']) && !$userinfo) { //未注册 - $this->error(__('未注册')); + $this->error(__('Not registered')); } } $ret = Emslib::send($email, null, $event); if ($ret) { - $this->success(__('发送成功')); + $this->success(__('Send successful')); } else { - $this->error(__('发送失败')); + $this->error(__('Send failed')); } } @@ -71,7 +71,7 @@ class Ems extends Api * * @ApiMethod (POST) * @param string $email 邮箱 - * @param string $event 事件名称 + * @param string $event 事件名称,register,changeemail,resetpwd * @param string $captcha 验证码 */ public function check() @@ -85,20 +85,20 @@ class Ems extends Api $userinfo = User::getByEmail($email); if ($event == 'register' && $userinfo) { //已被注册 - $this->error(__('已被注册')); + $this->error(__('Already registered')); } elseif (in_array($event, ['changeemail']) && $userinfo) { //被占用 - $this->error(__('已被占用')); + $this->error(__('Already occupied')); } elseif (in_array($event, ['changepwd', 'resetpwd']) && !$userinfo) { //未注册 - $this->error(__('未注册')); + $this->error(__('Not registered')); } } $ret = Emslib::check($email, $captcha, $event); if ($ret) { - $this->success(__('成功')); + $this->success(__('Successful')); } else { - $this->error(__('验证码不正确')); + $this->error(__('Verification code is incorrect')); } } } diff --git a/application/api/controller/Sms.php b/application/api/controller/Sms.php index df335fb4..919e95ed 100644 --- a/application/api/controller/Sms.php +++ b/application/api/controller/Sms.php @@ -20,7 +20,7 @@ class Sms extends Api * * @ApiMethod (POST) * @param string $mobile 手机号 - * @param string $event 事件名称 + * @param string $event 事件名称,register,mobilelogin,changemobile,resetpwd */ public function send() { @@ -32,31 +32,31 @@ class Sms extends Api //发送前验证码 if (config('fastadmin.user_api_captcha')) { if (!\think\Validate::is($captcha, 'captcha')) { - $this->error("验证码不正确"); + $this->error(__('Verification code is incorrect')); } } if (!$mobile || !\think\Validate::regex($mobile, "^1\d{10}$")) { - $this->error(__('手机号不正确')); + $this->error(__('Mobile is incorrect')); } $last = Smslib::get($mobile, $event); if ($last && time() - $last['createtime'] < 60) { - $this->error(__('发送频繁')); + $this->error(__('Send frequently')); } $ipSendTotal = \app\common\model\Sms::where(['ip' => $this->request->ip()])->whereTime('createtime', '-1 hours')->count(); if ($ipSendTotal >= 5) { - $this->error(__('发送频繁')); + $this->error(__('Send frequently')); } if ($event) { $userinfo = User::getByMobile($mobile); if ($event == 'register' && $userinfo) { //已被注册 - $this->error(__('已被注册')); + $this->error(__('Already registered')); } elseif (in_array($event, ['changemobile']) && $userinfo) { //被占用 - $this->error(__('已被占用')); + $this->error(__('Already occupied')); } elseif (in_array($event, ['changepwd', 'resetpwd']) && !$userinfo) { //未注册 - $this->error(__('未注册')); + $this->error(__('Not registered')); } } if (!Hook::get('sms_send')) { @@ -64,9 +64,9 @@ class Sms extends Api } $ret = Smslib::send($mobile, null, $event); if ($ret) { - $this->success(__('发送成功')); + $this->success(__('Send successful')); } else { - $this->error(__('发送失败,请检查短信配置是否正确')); + $this->error(__('Send failed, please check the SMS config is correct')); } } @@ -75,7 +75,7 @@ class Sms extends Api * * @ApiMethod (POST) * @param string $mobile 手机号 - * @param string $event 事件名称 + * @param string $event 事件名称,register,mobilelogin,changemobile,resetpwd * @param string $captcha 验证码 */ public function check() @@ -86,26 +86,26 @@ class Sms extends Api $captcha = $this->request->post("captcha"); if (!$mobile || !\think\Validate::regex($mobile, "^1\d{10}$")) { - $this->error(__('手机号不正确')); + $this->error(__('Mobile is incorrect')); } if ($event) { $userinfo = User::getByMobile($mobile); if ($event == 'register' && $userinfo) { //已被注册 - $this->error(__('已被注册')); + $this->error(__('Already registered')); } elseif (in_array($event, ['changemobile']) && $userinfo) { //被占用 - $this->error(__('已被占用')); + $this->error(__('Already occupied')); } elseif (in_array($event, ['changepwd', 'resetpwd']) && !$userinfo) { //未注册 - $this->error(__('未注册')); + $this->error(__('Not registered')); } } $ret = Smslib::check($mobile, $captcha, $event); if ($ret) { - $this->success(__('成功')); + $this->success(__('Successful')); } else { - $this->error(__('验证码不正确')); + $this->error(__('Verification code is incorrect')); } } } diff --git a/application/api/controller/Validate.php b/application/api/controller/Validate.php index adb36d0f..c3d6a1d9 100644 --- a/application/api/controller/Validate.php +++ b/application/api/controller/Validate.php @@ -32,7 +32,7 @@ class Validate extends Api $id = (int)$this->request->post('id'); $count = User::where('email', '=', $email)->where('id', '<>', $id)->count(); if ($count > 0) { - $this->error(__('邮箱已经被占用')); + $this->error(__('Email already occupied')); } $this->success(); } @@ -50,7 +50,7 @@ class Validate extends Api $id = (int)$this->request->post('id'); $count = User::where('username', '=', $username)->where('id', '<>', $id)->count(); if ($count > 0) { - $this->error(__('用户名已经被占用')); + $this->error(__('Username already occupied')); } $this->success(); } @@ -68,7 +68,7 @@ class Validate extends Api $id = (int)$this->request->post('id'); $count = User::where('nickname', '=', $nickname)->where('id', '<>', $id)->count(); if ($count > 0) { - $this->error(__('昵称已经被占用')); + $this->error(__('Nickname already occupied')); } $this->success(); } @@ -86,7 +86,7 @@ class Validate extends Api $id = (int)$this->request->post('id'); $count = User::where('mobile', '=', $mobile)->where('id', '<>', $id)->count(); if ($count > 0) { - $this->error(__('该手机号已经占用')); + $this->error(__('Mobile already occupied')); } $this->success(); } @@ -102,7 +102,7 @@ class Validate extends Api $mobile = $this->request->post('mobile'); $count = User::where('mobile', '=', $mobile)->count(); if (!$count) { - $this->error(__('手机号不存在')); + $this->error(__('Mobile not exists')); } $this->success(); } @@ -118,7 +118,7 @@ class Validate extends Api $email = $this->request->post('email'); $count = User::where('email', '=', $email)->count(); if (!$count) { - $this->error(__('邮箱不存在')); + $this->error(__('Email not exists')); } $this->success(); } @@ -137,7 +137,7 @@ class Validate extends Api $captcha = $this->request->post('captcha'); $event = $this->request->post('event'); if (!\app\common\library\Sms::check($mobile, $captcha, $event)) { - $this->error(__('验证码不正确')); + $this->error(__('Verification code is incorrect')); } $this->success(); } @@ -156,7 +156,7 @@ class Validate extends Api $captcha = $this->request->post('captcha'); $event = $this->request->post('event'); if (!\app\common\library\Ems::check($email, $captcha, $event)) { - $this->error(__('验证码不正确')); + $this->error(__('Verification code is incorrect')); } $this->success(); } diff --git a/application/api/lang/zh-cn/ems.php b/application/api/lang/zh-cn/ems.php new file mode 100644 index 00000000..951f9271 --- /dev/null +++ b/application/api/lang/zh-cn/ems.php @@ -0,0 +1,11 @@ + '验证码不正确', + 'Send frequently' => '发送频繁', + 'Already registered' => '已被注册', + 'Already occupied' => '已被占用', + 'Not registered' => '未注册', + 'Send successful' => '发送成功', + 'Send failed' => '发送失败', + 'Successful' => '成功', +]; \ No newline at end of file diff --git a/application/api/lang/zh-cn/sms.php b/application/api/lang/zh-cn/sms.php new file mode 100644 index 00000000..5a5df1cd --- /dev/null +++ b/application/api/lang/zh-cn/sms.php @@ -0,0 +1,12 @@ + '验证码不正确', + 'Mobile is incorrect' => '手机号不正确', + 'Send frequently' => '发送频繁', + 'Already registered' => '已被注册', + 'Already occupied' => '已被占用', + 'Not registered' => '未注册', + 'Send successful' => '发送成功', + 'Send failed, please check the SMS config is correct' => '发送失败,请检查短信配置是否正确', + 'Successful' => '成功', +]; \ No newline at end of file diff --git a/application/api/lang/zh-cn/validate.php b/application/api/lang/zh-cn/validate.php new file mode 100644 index 00000000..dd6878f1 --- /dev/null +++ b/application/api/lang/zh-cn/validate.php @@ -0,0 +1,10 @@ + '邮箱已经被占用', + 'Username already occupied' => '用户名已经被占用', + 'Nickname already occupied' => '昵称已经被占用', + 'Mobile already occupied' => '该手机号已经占用', + 'Mobile not exists' => '手机号不存在', + 'Email not exists' => '邮箱不存在', + 'Verification code is incorrect' => '验证码不正确', +]; \ No newline at end of file From 257e04bf9183b5a173b8fef395470f64abd56109 Mon Sep 17 00:00:00 2001 From: aa820t Date: Tue, 1 Aug 2023 07:57:06 +0800 Subject: [PATCH 2/3] =?UTF-8?q?cdnurl($url,=20true)=E5=BD=93url=E4=B8=BA?= =?UTF-8?q?=E7=A9=BA,=E4=B8=94=E5=B8=A6=E5=9F=9F=E5=90=8D=E6=97=B6,?= =?UTF-8?q?=E4=B9=9F=E7=9B=B4=E6=8E=A5=E8=BF=94=E5=9B=9E=E7=A9=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/common.php | 1 + 1 file changed, 1 insertion(+) diff --git a/application/common.php b/application/common.php index 68b9e582..f12cae60 100755 --- a/application/common.php +++ b/application/common.php @@ -87,6 +87,7 @@ if (!function_exists('cdnurl')) { */ function cdnurl($url, $domain = false) { + if(!$url) return ''; $regex = "/^((?:[a-z]+:)?\/\/|data:image\/)(.*)/i"; if (is_bool($domain)) { $cdnurl = \think\Config::get('upload.cdnurl'); From e2cb91af2de11f472cbc073995c192b56469f2c1 Mon Sep 17 00:00:00 2001 From: aa820t Date: Sat, 26 Aug 2023 11:58:47 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E5=86=99=E5=85=A5database=E6=96=AD?= =?UTF-8?q?=E7=BA=BF=E9=87=8D=E8=BF=9E=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/database.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/application/database.php b/application/database.php index 7b9f8f23..64ad5559 100755 --- a/application/database.php +++ b/application/database.php @@ -18,11 +18,11 @@ return [ // 服务器地址 'hostname' => Env::get('database.hostname', '127.0.0.1'), // 数据库名 - 'database' => Env::get('database.database', 'fastadmin'), + 'database' => Env::get('database.database', 'fastadmin_fork'), // 用户名 'username' => Env::get('database.username', 'root'), // 密码 - 'password' => Env::get('database.password', ''), + 'password' => Env::get('database.password', 'root'), // 端口 'hostport' => Env::get('database.hostport', ''), // 连接dsn @@ -53,4 +53,7 @@ return [ 'datetime_format' => false, // 是否需要进行SQL性能分析 'sql_explain' => false, + + // 是否需要断线重连 + 'break_reconnect' => false, ];