Pre Merge pull request !450 from aa820t/develop

pull/450/MERGE
aa820t 2025-06-26 09:09:03 +00:00 committed by Gitee
commit 93153e853a
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
9 changed files with 80 additions and 42 deletions

View File

@ -74,6 +74,7 @@
#login-form .form-control { #login-form .form-control {
font-size: 13px; font-size: 13px;
height: 40px;
} }
</style> </style>
@ -118,7 +119,7 @@
<div class="input-group-addon"><span class="glyphicon glyphicon-option-horizontal" aria-hidden="true"></span></div> <div class="input-group-addon"><span class="glyphicon glyphicon-option-horizontal" aria-hidden="true"></span></div>
<input type="text" name="captcha" class="form-control" placeholder="{:__('Captcha')}" data-rule="{:__('Captcha')}:required;length({$Think.config.captcha.length})" autocomplete="off"/> <input type="text" name="captcha" class="form-control" placeholder="{:__('Captcha')}" data-rule="{:__('Captcha')}:required;length({$Think.config.captcha.length})" autocomplete="off"/>
<span class="input-group-addon" style="padding:0;border:none;cursor:pointer;"> <span class="input-group-addon" style="padding:0;border:none;cursor:pointer;">
<img src="{:rtrim('__PUBLIC__', '/')}/index.php?s=/captcha" width="100" height="30" onclick="this.src = '{:rtrim('__PUBLIC__', '/')}/index.php?s=/captcha&r=' + Math.random();"/> <img src="{:rtrim('__PUBLIC__', '/')}/index.php?s=/captcha" width="100" height="40" onclick="this.src = '{:rtrim('__PUBLIC__', '/')}/index.php?s=/captcha&r=' + Math.random();"/>
</span> </span>
</div> </div>
{/if} {/if}

View File

@ -25,7 +25,7 @@ class Ems extends Api
* *
* @ApiMethod (POST) * @ApiMethod (POST)
* @param string $email 邮箱 * @param string $email 邮箱
* @param string $event 事件名称 * @param string $event 事件名称,register,changeemail,resetpwd
*/ */
public function send() public function send()
{ {
@ -49,13 +49,13 @@ class Ems extends Api
} }
if (!\think\Validate::is($captcha, 'captcha')) { if (!\think\Validate::is($captcha, 'captcha')) {
$this->error("验证码不正确"); $this->error(__('Verification code is incorrect'));
} }
} }
$last = Emslib::get($email, $event); $last = Emslib::get($email, $event);
if ($last && time() - $last['createtime'] < 60) { if ($last && time() - $last['createtime'] < 60) {
$this->error(__('发送频繁')); $this->error(__('Send frequently'));
} }
$ipSendTotal = \app\common\model\Ems::where(['ip' => $this->request->ip()])->whereTime('createtime', '-1 hours')->count(); $ipSendTotal = \app\common\model\Ems::where(['ip' => $this->request->ip()])->whereTime('createtime', '-1 hours')->count();
@ -67,20 +67,20 @@ class Ems extends Api
$userinfo = User::getByEmail($email); $userinfo = User::getByEmail($email);
if ($event == 'register' && $userinfo) { if ($event == 'register' && $userinfo) {
//已被注册 //已被注册
$this->error(__('已被注册')); $this->error(__('Already registered'));
} elseif (in_array($event, ['changeemail']) && $userinfo) { } elseif (in_array($event, ['changeemail']) && $userinfo) {
//被占用 //被占用
$this->error(__('已被占用')); $this->error(__('Already occupied'));
} elseif (in_array($event, ['changepwd', 'resetpwd']) && !$userinfo) { } elseif (in_array($event, ['changepwd', 'resetpwd']) && !$userinfo) {
//未注册 //未注册
$this->error(__('未注册')); $this->error(__('Not registered'));
} }
} }
$ret = Emslib::send($email, null, $event); $ret = Emslib::send($email, null, $event);
if ($ret) { if ($ret) {
$this->success(__('发送成功')); $this->success(__('Send successful'));
} else { } else {
$this->error(__('发送失败')); $this->error(__('Send failed'));
} }
} }
@ -89,7 +89,7 @@ class Ems extends Api
* *
* @ApiMethod (POST) * @ApiMethod (POST)
* @param string $email 邮箱 * @param string $email 邮箱
* @param string $event 事件名称 * @param string $event 事件名称,register,changeemail,resetpwd
* @param string $captcha 验证码 * @param string $captcha 验证码
*/ */
public function check() public function check()
@ -114,20 +114,20 @@ class Ems extends Api
$userinfo = User::getByEmail($email); $userinfo = User::getByEmail($email);
if ($event == 'register' && $userinfo) { if ($event == 'register' && $userinfo) {
//已被注册 //已被注册
$this->error(__('已被注册')); $this->error(__('Already registered'));
} elseif (in_array($event, ['changeemail']) && $userinfo) { } elseif (in_array($event, ['changeemail']) && $userinfo) {
//被占用 //被占用
$this->error(__('已被占用')); $this->error(__('Already occupied'));
} elseif (in_array($event, ['changepwd', 'resetpwd']) && !$userinfo) { } elseif (in_array($event, ['changepwd', 'resetpwd']) && !$userinfo) {
//未注册 //未注册
$this->error(__('未注册')); $this->error(__('Not registered'));
} }
} }
$ret = Emslib::check($email, $captcha, $event); $ret = Emslib::check($email, $captcha, $event);
if ($ret) { if ($ret) {
$this->success(__('成功')); $this->success(__('Successful'));
} else { } else {
$this->error(__('验证码不正确')); $this->error(__('Verification code is incorrect'));
} }
} }
} }

View File

@ -20,7 +20,7 @@ class Sms extends Api
* *
* @ApiMethod (POST) * @ApiMethod (POST)
* @param string $mobile 手机号 * @param string $mobile 手机号
* @param string $event 事件名称 * @param string $event 事件名称,register,mobilelogin,changemobile,resetpwd
*/ */
public function send() public function send()
{ {
@ -32,31 +32,31 @@ class Sms extends Api
//发送前验证码 //发送前验证码
if (config('fastadmin.user_api_captcha')) { if (config('fastadmin.user_api_captcha')) {
if (!\think\Validate::is($captcha, 'captcha')) { if (!\think\Validate::is($captcha, 'captcha')) {
$this->error("验证码不正确"); $this->error(__('Verification code is incorrect'));
} }
} }
if (!$mobile || !\think\Validate::regex($mobile, "^1\d{10}$")) { if (!$mobile || !\think\Validate::regex($mobile, "^1\d{10}$")) {
$this->error(__('手机号不正确')); $this->error(__('Mobile is incorrect'));
} }
$last = Smslib::get($mobile, $event); $last = Smslib::get($mobile, $event);
if ($last && time() - $last['createtime'] < 60) { 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(); $ipSendTotal = \app\common\model\Sms::where(['ip' => $this->request->ip()])->whereTime('createtime', '-1 hours')->count();
if ($ipSendTotal >= 5) { if ($ipSendTotal >= 5) {
$this->error(__('发送频繁')); $this->error(__('Send frequently'));
} }
if ($event) { if ($event) {
$userinfo = User::getByMobile($mobile); $userinfo = User::getByMobile($mobile);
if ($event == 'register' && $userinfo) { if ($event == 'register' && $userinfo) {
//已被注册 //已被注册
$this->error(__('已被注册')); $this->error(__('Already registered'));
} elseif (in_array($event, ['changemobile']) && $userinfo) { } elseif (in_array($event, ['changemobile']) && $userinfo) {
//被占用 //被占用
$this->error(__('已被占用')); $this->error(__('Already occupied'));
} elseif (in_array($event, ['changepwd', 'resetpwd']) && !$userinfo) { } elseif (in_array($event, ['changepwd', 'resetpwd']) && !$userinfo) {
//未注册 //未注册
$this->error(__('未注册')); $this->error(__('Not registered'));
} }
} }
if (!Hook::get('sms_send')) { if (!Hook::get('sms_send')) {
@ -64,9 +64,9 @@ class Sms extends Api
} }
$ret = Smslib::send($mobile, null, $event); $ret = Smslib::send($mobile, null, $event);
if ($ret) { if ($ret) {
$this->success(__('发送成功')); $this->success(__('Send successful'));
} else { } else {
$this->error(__('发送失败,请检查短信配置是否正确')); $this->error(__('Send failed, please check the SMS config is correct'));
} }
} }
@ -75,7 +75,7 @@ class Sms extends Api
* *
* @ApiMethod (POST) * @ApiMethod (POST)
* @param string $mobile 手机号 * @param string $mobile 手机号
* @param string $event 事件名称 * @param string $event 事件名称,register,mobilelogin,changemobile,resetpwd
* @param string $captcha 验证码 * @param string $captcha 验证码
*/ */
public function check() public function check()
@ -86,26 +86,26 @@ class Sms extends Api
$captcha = $this->request->post("captcha"); $captcha = $this->request->post("captcha");
if (!$mobile || !\think\Validate::regex($mobile, "^1\d{10}$")) { if (!$mobile || !\think\Validate::regex($mobile, "^1\d{10}$")) {
$this->error(__('手机号不正确')); $this->error(__('Mobile is incorrect'));
} }
if ($event) { if ($event) {
$userinfo = User::getByMobile($mobile); $userinfo = User::getByMobile($mobile);
if ($event == 'register' && $userinfo) { if ($event == 'register' && $userinfo) {
//已被注册 //已被注册
$this->error(__('已被注册')); $this->error(__('Already registered'));
} elseif (in_array($event, ['changemobile']) && $userinfo) { } elseif (in_array($event, ['changemobile']) && $userinfo) {
//被占用 //被占用
$this->error(__('已被占用')); $this->error(__('Already occupied'));
} elseif (in_array($event, ['changepwd', 'resetpwd']) && !$userinfo) { } elseif (in_array($event, ['changepwd', 'resetpwd']) && !$userinfo) {
//未注册 //未注册
$this->error(__('未注册')); $this->error(__('Not registered'));
} }
} }
$ret = Smslib::check($mobile, $captcha, $event); $ret = Smslib::check($mobile, $captcha, $event);
if ($ret) { if ($ret) {
$this->success(__('成功')); $this->success(__('Successful'));
} else { } else {
$this->error(__('验证码不正确')); $this->error(__('Verification code is incorrect'));
} }
} }
} }

View File

@ -32,7 +32,7 @@ class Validate extends Api
$id = (int)$this->request->post('id'); $id = (int)$this->request->post('id');
$count = User::where('email', '=', $email)->where('id', '<>', $id)->count(); $count = User::where('email', '=', $email)->where('id', '<>', $id)->count();
if ($count > 0) { if ($count > 0) {
$this->error(__('邮箱已经被占用')); $this->error(__('Email already occupied'));
} }
$this->success(); $this->success();
} }
@ -50,7 +50,7 @@ class Validate extends Api
$id = (int)$this->request->post('id'); $id = (int)$this->request->post('id');
$count = User::where('username', '=', $username)->where('id', '<>', $id)->count(); $count = User::where('username', '=', $username)->where('id', '<>', $id)->count();
if ($count > 0) { if ($count > 0) {
$this->error(__('用户名已经被占用')); $this->error(__('Username already occupied'));
} }
$this->success(); $this->success();
} }
@ -68,7 +68,7 @@ class Validate extends Api
$id = (int)$this->request->post('id'); $id = (int)$this->request->post('id');
$count = User::where('nickname', '=', $nickname)->where('id', '<>', $id)->count(); $count = User::where('nickname', '=', $nickname)->where('id', '<>', $id)->count();
if ($count > 0) { if ($count > 0) {
$this->error(__('昵称已经被占用')); $this->error(__('Nickname already occupied'));
} }
$this->success(); $this->success();
} }
@ -86,7 +86,7 @@ class Validate extends Api
$id = (int)$this->request->post('id'); $id = (int)$this->request->post('id');
$count = User::where('mobile', '=', $mobile)->where('id', '<>', $id)->count(); $count = User::where('mobile', '=', $mobile)->where('id', '<>', $id)->count();
if ($count > 0) { if ($count > 0) {
$this->error(__('该手机号已经占用')); $this->error(__('Mobile already occupied'));
} }
$this->success(); $this->success();
} }
@ -102,7 +102,7 @@ class Validate extends Api
$mobile = $this->request->post('mobile'); $mobile = $this->request->post('mobile');
$count = User::where('mobile', '=', $mobile)->count(); $count = User::where('mobile', '=', $mobile)->count();
if (!$count) { if (!$count) {
$this->error(__('手机号不存在')); $this->error(__('Mobile not exists'));
} }
$this->success(); $this->success();
} }
@ -118,7 +118,7 @@ class Validate extends Api
$email = $this->request->post('email'); $email = $this->request->post('email');
$count = User::where('email', '=', $email)->count(); $count = User::where('email', '=', $email)->count();
if (!$count) { if (!$count) {
$this->error(__('邮箱不存在')); $this->error(__('Email not exists'));
} }
$this->success(); $this->success();
} }
@ -137,7 +137,7 @@ class Validate extends Api
$captcha = $this->request->post('captcha'); $captcha = $this->request->post('captcha');
$event = $this->request->post('event'); $event = $this->request->post('event');
if (!\app\common\library\Sms::check($mobile, $captcha, $event)) { if (!\app\common\library\Sms::check($mobile, $captcha, $event)) {
$this->error(__('验证码不正确')); $this->error(__('Verification code is incorrect'));
} }
$this->success(); $this->success();
} }
@ -156,7 +156,7 @@ class Validate extends Api
$captcha = $this->request->post('captcha'); $captcha = $this->request->post('captcha');
$event = $this->request->post('event'); $event = $this->request->post('event');
if (!\app\common\library\Ems::check($email, $captcha, $event)) { if (!\app\common\library\Ems::check($email, $captcha, $event)) {
$this->error(__('验证码不正确')); $this->error(__('Verification code is incorrect'));
} }
$this->success(); $this->success();
} }

View File

@ -0,0 +1,11 @@
<?php
return [
'Verification code is incorrect' => '验证码不正确',
'Send frequently' => '发送频繁',
'Already registered' => '已被注册',
'Already occupied' => '已被占用',
'Not registered' => '未注册',
'Send successful' => '发送成功',
'Send failed' => '发送失败',
'Successful' => '成功',
];

View File

@ -0,0 +1,12 @@
<?php
return [
'Verification code is incorrect' => '验证码不正确',
'Mobile is incorrect' => '手机号不正确',
'Send frequently' => '发送频繁',
'Already registered' => '已被注册',
'Already occupied' => '已被占用',
'Not registered' => '未注册',
'Send successful' => '发送成功',
'Send failed, please check the SMS config is correct' => '发送失败,请检查短信配置是否正确',
'Successful' => '成功',
];

View File

@ -0,0 +1,10 @@
<?php
return [
'Email already occupied' => '邮箱已经被占用',
'Username already occupied' => '用户名已经被占用',
'Nickname already occupied' => '昵称已经被占用',
'Mobile already occupied' => '该手机号已经占用',
'Mobile not exists' => '手机号不存在',
'Email not exists' => '邮箱不存在',
'Verification code is incorrect' => '验证码不正确',
];

View File

@ -86,6 +86,7 @@ if (!function_exists('cdnurl')) {
*/ */
function cdnurl($url, $domain = false) function cdnurl($url, $domain = false)
{ {
if(!$url) return '';
$regex = "/^((?:[a-z]+:)?\/\/|data:image\/)(.*)/i"; $regex = "/^((?:[a-z]+:)?\/\/|data:image\/)(.*)/i";
$cdnurl = \think\Config::get('upload.cdnurl'); $cdnurl = \think\Config::get('upload.cdnurl');
if (is_bool($domain) || stripos($cdnurl, '/') === 0) { if (is_bool($domain) || stripos($cdnurl, '/') === 0) {

View File

@ -18,11 +18,11 @@ return [
// 服务器地址 // 服务器地址
'hostname' => Env::get('database.hostname', '127.0.0.1'), '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'), 'username' => Env::get('database.username', 'root'),
// 密码 // 密码
'password' => Env::get('database.password', ''), 'password' => Env::get('database.password', 'root'),
// 端口 // 端口
'hostport' => Env::get('database.hostport', ''), 'hostport' => Env::get('database.hostport', ''),
// 连接dsn // 连接dsn
@ -53,4 +53,7 @@ return [
'datetime_format' => false, 'datetime_format' => false,
// 是否需要进行SQL性能分析 // 是否需要进行SQL性能分析
'sql_explain' => false, 'sql_explain' => false,
// 是否需要断线重连
'break_reconnect' => false,
]; ];