Compare commits

...

6 Commits

Author SHA1 Message Date
Karson 2fe68b4c27 Merge branch '1.x' of gitee.com:karson/fastadmin into 1.x 2023-08-30 16:57:37 +08:00
Karson 31b307a4a1 优化上传异常捕获 2023-08-30 16:56:33 +08:00
Karson 7fffba8963 优化表格列表图片显示 2023-08-30 16:27:03 +08:00
Karson 4aa2666c98 优化后台菜单切换 2023-08-30 16:24:11 +08:00
Karson 940e9a0814 新增IP发送频繁检测 2023-08-30 16:22:21 +08:00
Karson 901bea7d59 修复check_url_allowed判断不全的问题 2023-08-30 16:20:55 +08:00
5 changed files with 22 additions and 22 deletions

View File

@ -137,6 +137,8 @@ class Common extends Api
$attachment = $upload->upload();
} catch (UploadException $e) {
$this->error($e->getMessage());
} catch (\Exception $e) {
$this->error($e->getMessage());
}
$this->success(__('Uploaded successful'), ['url' => $attachment->url, 'fullurl' => cdnurl($attachment->url, true)]);

View File

@ -37,6 +37,12 @@ class Ems extends Api
if ($last && time() - $last['createtime'] < 60) {
$this->error(__('发送频繁'));
}
$ipSendTotal = \app\common\model\Ems::where(['ip' => $this->request->ip()])->whereTime('createtime', '-1 hours')->count();
if ($ipSendTotal >= 5) {
$this->error(__('发送频繁'));
}
if ($event) {
$userinfo = User::getByEmail($email);
if ($event == 'register' && $userinfo) {

View File

@ -520,7 +520,7 @@ if (!function_exists('check_url_allowed')) {
}
//如果是站外链接则需要判断HOST是否允许
if (preg_match("/((http[s]?:\/\/)+(?>[a-z\-0-9]{2,}\.){1,}[a-z]{2,8})(?:\s|\/)/i", $url)) {
if (preg_match("/((http[s]?:\/\/)+((?>[a-z\-0-9]{2,}\.)+[a-z]{2,8}|((?>([0-9]{1,3}\.)){3}[0-9]{1,3}))(:[0-9]{1,5})?)(?:\s|\/)/i", $url)) {
$chkHost = parse_url(strtolower($url), PHP_URL_HOST);
if ($chkHost && in_array($chkHost, $allowedHostArr)) {
return true;

View File

@ -333,11 +333,13 @@ define(['jquery', 'bootstrap', 'backend', 'addtabs', 'adminlte', 'form'], functi
// 切换菜单栏
$(document).on("click", ".sidebar-toggle", function () {
var value = $("body").hasClass("sidebar-collapse") ? 1 : 0;
setTimeout(function () {
$(window).trigger("resize");
}, 300);
createCookie('sidebar_collapse', value);
setTimeout(function(){
var value = $("body").hasClass("sidebar-collapse") ? 1 : 0;
setTimeout(function () {
$(window).trigger("resize");
}, 300);
createCookie('sidebar_collapse', value);
}, 0);
});
// 切换多级菜单

View File

@ -726,40 +726,30 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table
return '<i class="' + value + '"></i> ' + value;
},
image: function (value, row, index) {
value = value == null || value.length === 0 ? '' : value.toString();
value = value ? value : '/assets/img/blank.gif';
var classname = typeof this.classname !== 'undefined' ? this.classname : 'img-sm img-center';
var url = Fast.api.cdnurl(value, true);
url = url.match(/^(\/|data:image\\)/) ? url : url + Config.upload.thumbstyle;
return '<a href="javascript:"><img class="' + classname + '" src="' + url + '" /></a>';
return Table.api.formatter.images.call(this, value, row, index);
},
images: function (value, row, index) {
value = value == null || value.length === 0 ? '' : value.toString();
var classname = typeof this.classname !== 'undefined' ? this.classname : 'img-sm img-center';
var arr = value != '' ? value.split(',') : [];
var arr = value !== '' ? (value.indexOf('data:image/') === -1 ? value.split(',') : [value]) : [];
var html = [];
var url;
$.each(arr, function (i, value) {
value = value ? value : '/assets/img/blank.gif';
url = Fast.api.cdnurl(value, true);
url = url.match(/^(\/|data:image\\)/) ? url : url + Config.upload.thumbstyle;
//匹配本地、data:image、或已包含标识符首字符
url = !Config.upload.thumbstyle || url.match(/^(\/|data:image\/)/) || url.indexOf(Config.upload.thumbstyle.substring(0, 1)) > -1 ? url : url + Config.upload.thumbstyle;
html.push('<a href="javascript:"><img class="' + classname + '" src="' + url + '" /></a>');
});
return html.join(' ');
},
file: function (value, row, index) {
value = value == null || value.length === 0 ? '' : value.toString();
value = Fast.api.cdnurl(value, true);
var classname = typeof this.classname !== 'undefined' ? this.classname : 'img-sm img-center';
var suffix = /[\.]?([a-zA-Z0-9]+)$/.exec(value);
suffix = suffix ? suffix[1] : 'file';
var url = Fast.api.fixurl("ajax/icon?suffix=" + suffix);
return '<a href="' + value + '" target="_blank"><img src="' + url + '" class="' + classname + '"></a>';
Table.api.formatter.files.call(this, value, row, index);
},
files: function (value, row, index) {
value = value == null || value.length === 0 ? '' : value.toString();
var classname = typeof this.classname !== 'undefined' ? this.classname : 'img-sm img-center';
var arr = value != '' ? value.split(',') : [];
var arr = value !== '' ? (value.indexOf('data:image/') === -1 ? value.split(',') : [value]) : [];
var html = [];
var suffix, url;
$.each(arr, function (i, value) {