[更新]修正文件上传后缀检查,同步更新后台UI

This commit is contained in:
Anyon 2017-09-27 16:22:16 +08:00
parent ac1d208534
commit 7530c06b6a
13 changed files with 803 additions and 821 deletions

View File

@ -70,9 +70,12 @@ class Auth extends BasicAdmin
$checked = Db::name('SystemAuthNode')->where(['auth' => $auth_id])->column('node');
foreach ($nodes as $key => &$node) {
$node['checked'] = in_array($node['node'], $checked);
if (empty($node['is_auth']) && substr_count($node['node'], '/') > 1) {
unset($nodes[$key]);
}
$all = $this->_apply_filter(ToolsService::arr2tree($nodes, 'node', 'pnode', '_sub_'));
$this->success('获取节点成功!', '', $all);
}
$allnode = $this->_apply_filter(ToolsService::arr2tree($nodes, 'node', 'pnode', '_sub_'));
$this->success('获取节点成功!', '', $allnode);
}
/**
@ -101,6 +104,8 @@ class Auth extends BasicAdmin
foreach ($nodes as $key => &$node) {
if (!empty($node['_sub_']) && is_array($node['_sub_'])) {
$node['_sub_'] = $this->_apply_filter($node['_sub_'], $level + 1);
} elseif ($level < 3) {
unset($nodes[$key]);
}
}
return $nodes;
@ -151,7 +156,7 @@ class Auth extends BasicAdmin
{
if (DataService::update($this->table)) {
$id = $this->request->post('id');
Db::name('SystemAuthNode')->where(['auth' => $id])->delete();
Db::name('SystemAuthNode')->where('auth', $id)->delete();
$this->success("权限删除成功!", '');
}
$this->error("权限删除失败,请稍候再试!");

View File

@ -60,7 +60,7 @@ class Config extends BasicAdmin
public function file()
{
$this->title = '文件存储配置';
$alert = ['type' => 'success', 'title' => '操作提示', 'content' => '文件引擎参数影响全局文件上传功能请勿随意修改!'];
$alert = ['type' => 'success', 'title' => '操作提示', 'content' => '文件引擎参数影响全局文件上传功能,请勿随意修改!'];
$this->assign('alert', $alert);
return $this->index();
}

View File

@ -63,7 +63,7 @@ class Index extends BasicAdmin
continue;
// 菜单链接不为空时,判断登录状态及权限验证
elseif ($menu['url'] !== '#') :
$node = join('/', array_slice(explode('/', preg_replace('/[\W]/', '/', $menu['url'])), 0, 3));
$node = join('/', array_slice(explode('/', preg_replace('/[\W^_]/', '/', $menu['url'])), 0, 3));
$menu['url'] = url($menu['url']);
// 节点需要验证验证,未登录时移除此菜单
if (isset($nodes[$node]) && $nodes[$node]['is_login'] && !session('user')) :

View File

@ -20,7 +20,7 @@ use think\Db;
/**
* 系统日志管理
* Class Log
* Class User
* @package app\admin\controller
* @author Anyon <zoujingli@qq.com>
* @date 2017/02/15 18:12

View File

@ -83,7 +83,7 @@ class Menu extends BasicAdmin
{
if ($this->request->isGet()) {
// 上级菜单处理
$_menus = Db::name($this->table)->where(['status' => '1'])->order('sort asc,id asc')->select();
$_menus = Db::name($this->table)->where('status', '1')->order('sort desc,id desc')->select();
$_menus[] = ['title' => '顶级菜单', 'id' => '0', 'pid' => '-1'];
$menus = ToolsService::arr2table($_menus);
foreach ($menus as $key => &$menu) {

View File

@ -16,6 +16,7 @@ namespace app\admin\controller;
use controller\BasicAdmin;
use service\FileService;
use think\Db;
/**
* 插件助手控制器

View File

@ -41,7 +41,7 @@ class User extends BasicAdmin
{
$this->title = '系统用户管理';
$get = $this->request->get();
$db = Db::name($this->table)->where(['is_deleted' => '0']);
$db = Db::name($this->table)->where(['is_deleted' => '0', 'type' => '系统用户']);
foreach (['username', 'phone'] as $key) {
if (isset($get[$key]) && $get[$key] !== '') {
$db->where($key, 'like', "%{$get[$key]}%");
@ -64,7 +64,7 @@ class User extends BasicAdmin
*/
public function add()
{
return $this->_form($this->table, 'form');
return $this->_form($this->table, 'form', 'id', [], ['type' => '系统用户']);
}
/**
@ -72,7 +72,7 @@ class User extends BasicAdmin
*/
public function edit()
{
return $this->_form($this->table, 'form');
return $this->_form($this->table, 'form', 'id', [], ['type' => '系统用户']);
}
/**

View File

@ -2,23 +2,16 @@
{block name="button"}
<div class="nowrap pull-right" style="margin-top:10px">
<button data-modal='{:url("$classuri/add")}' data-title="添加权限" class='layui-btn layui-btn-small'>
<i class='fa fa-plus'></i> 添加权限
</button>
<button data-update data-field='delete' data-action='{:url("$classuri/del")}'
class='layui-btn layui-btn-small layui-btn-danger'>
<i class='fa fa-remove'></i> 删除权限
</button>
<button data-modal='{:url("$classuri/add")}' data-title="添加权限" class='layui-btn layui-btn-small'><i class='fa fa-plus'></i> 添加权限</button>
<button data-update data-field='delete' data-action='{:url("$classuri/del")}' class='layui-btn layui-btn-small layui-btn-danger'><i class='fa fa-remove'></i> 删除权限</button>
</div>
{/block}
{block name="content"}
<form onsubmit="return false;" data-auto="true" method="post">
{if empty($list)}
<p class="help-block text-center well">没 有 记 录 哦!</p>
{else}
{if !empty($list)}
<input type="hidden" value="resort" name="action"/>
<table class="layui-table" lay-skin="line" lay-size="sm">
<table class="table table-hover">
<thead>
<tr>
<th class='list-table-check-td'>
@ -65,18 +58,15 @@
{if $vo.status eq 1 and auth("$classuri/forbid")}
<span class="text-explode">|</span>
<a data-update="{$vo.id}" data-field='status' data-value='0' data-action='{:url("$classuri/forbid")}'
href="javascript:void(0)">禁用</a>
<a data-update="{$vo.id}" data-field='status' data-value='0'data-action='{:url("$classuri/forbid")}' href="javascript:void(0)">禁用</a>
{elseif auth("$classuri/resume")}
<span class="text-explode">|</span>
<a data-update="{$vo.id}" data-field='status' data-value='1' data-action='{:url("$classuri/resume")}'
href="javascript:void(0)">启用</a>
<a data-update="{$vo.id}" data-field='status' data-value='1' data-action='{:url("$classuri/resume")}' href="javascript:void(0)">启用</a>
{/if}
{if auth("$classuri/del")}
<span class="text-explode">|</span>
<a data-update="{$vo.id}" data-field='delete' data-action='{:url("$classuri/del")}'
href="javascript:void(0)">删除</a>
<a data-update="{$vo.id}" data-field='delete' data-action='{:url("$classuri/del")}' href="javascript:void(0)">删除</a>
{/if}
</td>
@ -85,6 +75,8 @@
</tbody>
</table>
{if isset($page)}<p>{$page}</p>{/if}
{else}
<p class="help-blok">暂时无记录</p>
{/if}
</form>
{/block}

View File

@ -3,8 +3,7 @@
{block name="button"}
<div class="nowrap pull-right" style="margin-top:10px">
{if auth("$classuri/del")}
<button data-update data-field='delete' data-action='{:url("$classuri/del")}'
class='layui-btn layui-btn-small layui-btn-danger'>
<button data-update data-field='delete' data-action='{:url("$classuri/del")}' class='layui-btn layui-btn-small layui-btn-danger'>
<i class='fa fa-remove'></i> 删除日志
</button>
{/if}
@ -14,19 +13,19 @@
{block name="content"}
<!-- 表单搜索 开始 -->
<form class="layui-form layui-form-pane form-search" action="__SELF__" onsubmit="return false" method="get">
<div class="layui-form-item layui-inline">
<label class="layui-form-label" style="width:auto">操作者</label>
<div class="layui-input-inline">
<input name="username" value="{$Think.get.username|default=''}" placeholder="请输入操作者" class="layui-input">
<form class="animated form-search" action="__SELF__" onsubmit="return false" method="get">
<div class="row">
<div class="col-xs-3">
<div class="form-group">
<input type="text" name="username" value="{$Think.get.username|default=''}" placeholder="操作者" class="input-sm form-control">
</div>
</div>
<div class="layui-form-item layui-inline">
<label class="layui-form-label" style="width:auto">操作行为</label>
<div class="layui-input-inline">
<select name='action' class='layui-select' lay-search="">
<option value=''> - 所有记录 -</option>
<div class="col-xs-3">
<div class="form-group">
<select name='action' class='input-sm form-control'>
<option value=''> - 行为 - </option>
<!--{foreach $actions as $action}-->
<!--{if $action===$Think.get.action}-->
<option selected="selected" value='{$action}'>{$action}</option>
@ -38,22 +37,24 @@
</div>
</div>
<div class="layui-form-item layui-inline">
<label class="layui-form-label" style="width:auto">操作内容</label>
<div class="layui-input-inline">
<input name="content" value="{$Think.get.content|default=''}" placeholder="请输入操作内容" class="layui-input">
<div class="col-xs-3">
<div class="form-group">
<input type="text" name="content" value="{$Think.get.content|default=''}" placeholder="操作内容" class="input-sm form-control">
</div>
</div>
<div class="layui-form-item layui-inline">
<button class="layui-btn layui-btn-primary"><i class="layui-icon">&#xe615;</i> 搜 索</button>
<div class="col-xs-1">
<div class="form-group">
<button type="submit" class="btn btn-sm btn-white"><i class="fa fa-search"></i> 搜索</button>
</div>
</div>
</div>
</form>
<!-- 表单搜索 结束 -->
<form onsubmit="return false;" data-auto="" method="POST">
<input type="hidden" value="resort" name="action"/>
<table class="layui-table" lay-skin="line" lay-size="sm">
<table class="table table-hover">
<thead>
<tr>
<th class='list-table-check-td'>
@ -84,8 +85,5 @@
</tbody>
</table>
{if isset($page)}<p>{$page}</p>{/if}
<script>
window.form.render();
</script>
</form>
{/block}

View File

@ -19,10 +19,12 @@
欢迎登录 {:sysconf('app_name')} 后台管理 <sup>{:sysconf('app_version')}</sup>
</span>
<ul>
<!--<li class="notselect"><a href="javascript:void(0)" target="_blank">帮助</a></li>-->
<li class="notselect">
<a href="javascript:void(0)" target="_blank">帮助</a>
</li>
<li class="notselect">
<a href="http://sw.bos.baidu.com/sw-search-sp/software/4bcf5e4f1835b/ChromeStandalone_54.0.2840.99_Setup.exe">
<b>推荐使用谷歌浏览器</b>
<b>推荐谷歌浏览器</b>
</a>
</li>
</ul>
@ -41,13 +43,13 @@
<ul>
<li>
<input name='username' class="hide"/>
<input required="required" pattern="^\S{4,}$" value="admin" name="username"
<input required="required" pattern="^\S{4,}$" value="" name="username"
autofocus="autofocus" autocomplete="off" class="login-input username"
title="请输入4位及以上的字符" placeholder="请输入用户名/手机号码"/>
</li>
<li>
<input name='password' class="hide"/>
<input required="required" pattern="^\S{4,}$" value="admin" name="password"
<input required="required" pattern="^\S{4,}$" value="" name="password"
type="password" autocomplete="off" class="login-input password"
title="请输入4位及以上的字符" placeholder="请输入密码"/>
</li>
@ -62,7 +64,7 @@
<!-- 底部版权信息 开始 -->
{if sysconf('site_copy')}
<div class="footer notselect">{:sysconf('site_copy')}</div>
<div class="footer animated fadeInUp notselect">{:sysconf('site_copy')}</div>
{/if}
<!-- 底部版本信息 结束 -->

View File

@ -2,12 +2,8 @@
{block name="button"}
<div class="nowrap pull-right" style="margin-top:10px">
<button data-modal='{:url("$classuri/add")}' data-title="添加菜单" class='layui-btn layui-btn-small'><i
class='fa fa-plus'></i> 添加菜单
</button>
<button data-update data-field='delete' data-action='{:url("$classuri/del")}'
class='layui-btn layui-btn-small layui-btn-danger'><i class='fa fa-remove'></i> 删除菜单
</button>
<button data-modal='{:url("$classuri/add")}' data-title="添加菜单" class='layui-btn layui-btn-small'><i class='fa fa-plus'></i> 添加菜单</button>
<button data-update data-field='delete' data-action='{:url("$classuri/del")}' class='layui-btn layui-btn-small layui-btn-danger'><i class='fa fa-remove'></i> 删除菜单</button>
</div>
{/block}
@ -15,7 +11,7 @@
<form onsubmit="return false;" data-auto="true" method="post">
<input type="hidden" value="resort" name="action"/>
<table class="layui-table" lay-skin="line" lay-size="sm">
<table class="table table-hover">
<thead>
<tr>
<th class='list-table-check-td'>
@ -59,17 +55,14 @@
{/if}
{if $vo.status eq 1 and auth("$classuri/forbid")}
<span class="text-explode">|</span>
<a data-update="{$vo.ids}" data-field='status' data-value='0' data-action='{:url("$classuri/forbid")}'
href="javascript:void(0)">禁用</a>
<a data-update="{$vo.ids}" data-field='status' data-value='0'data-action='{:url("$classuri/forbid")}' href="javascript:void(0)">禁用</a>
{elseif auth("$classuri/resume")}
<span class="text-explode">|</span>
<a data-update="{$vo.ids}" data-field='status' data-value='1' data-action='{:url("$classuri/resume")}'
href="javascript:void(0)">启用</a>
<a data-update="{$vo.ids}" data-field='status' data-value='1' data-action='{:url("$classuri/resume")}' href="javascript:void(0)">启用</a>
{/if}
{if auth("$classuri/del")}
<span class="text-explode">|</span>
<a data-update="{$vo.ids}" data-field='delete' data-action='{:url("$classuri/del")}'
href="javascript:void(0)">删除</a>
<a data-update="{$vo.ids}" data-field='delete' data-action='{:url("$classuri/del")}' href="javascript:void(0)">删除</a>
{/if}
</td>
</tr>

View File

@ -1,6 +1,6 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<head>
<title>{:sysconf('app_name')} {:sysconf('app_version')}</title>
<meta charset="utf-8">
<link rel="icon" href="../image/favicon.ico">
@ -8,12 +8,12 @@
<meta name="viewport" content="width=device-width, initial-scale=0">
<link href="__STATIC__/plugs/uploader/webuploader.css" rel="stylesheet" type="text/css"/>
<link href="__STATIC__/plugs/uploader/theme/uploader.css" rel="stylesheet" type="text/css"/>
<script src="__STATIC__/plugs/jquery/jquery.min.js"></script>
<script src="__STATIC__/plugs/uploader/webuploader.min.js"></script>
<script src="__STATIC__/plugs/uploader/theme/upload.js"></script>
</head>
<body>
<div id="uploader">
<script src="__STATIC__/plugs/jquery/jquery.min.js" type="text/javascript"></script>
<script src="__STATIC__/plugs/uploader/webuploader.min.js" type="text/javascript"></script>
<script src="__STATIC__/plugs/uploader/theme/upload.js" type="text/javascript"></script>
</head>
<body>
<div id="uploader">
<div class="queueList">
<div id="dndArea" class="placeholder">
<div id="filePicker"></div>
@ -32,8 +32,8 @@
<div class="uploadBtn">开始上传</div>
</div>
</div>
</div>
<script>
</div>
<script>
/* global WebUploader */
/**
@ -120,7 +120,7 @@
flashVersion = (function () {
var version;
try {
version = navigator.plugins['Shockwave Flash'];
version = navigator.plugins[ 'Shockwave Flash' ];
version = version.description;
} catch (ex) {
try {
@ -130,11 +130,10 @@
}
}
version = version.match(/\d+/g);
return parseFloat(version[0] + '.' + version[1], 10);
return parseFloat(version[ 0 ] + '.' + version[ 1 ], 10);
})(),
supportTransition = (function () {
var s = document.createElement('p').style,
r = 'transition' in s || 'WebkitTransition' in s || 'MozTransition' in s || 'msTransition' in s || 'OTransition' in s;
var s = document.createElement('p').style, r = 'transition' in s || 'WebkitTransition' in s || 'MozTransition' in s || 'msTransition' in s || 'OTransition' in s;
return (s = null), r;
})(),
uploader;
@ -177,16 +176,14 @@
return;
}
WebUploader.Uploader.register({'before-send-file': 'preupload'}, {
preupload: function (file) {
WebUploader.Uploader.register({'before-send-file': 'preupload'}, {preupload: function (file) {
var me = this, owner = this.owner, deferred = WebUploader.Deferred();
owner.md5File(file.source).fail(function () {
deferred.reject();
}).then(function (md5) {
file.md5 = md5;
var data = {id: file.id, md5: md5, uptype: '{$uptype}', filename: file.name};
$.ajax("{:url('admin/plugs/upstate')}", {
dataType: 'json', method: 'post', data: data, success: function (ret) {
$.ajax("{:url('admin/plugs/upstate')}", {dataType: 'json', method: 'post', data: data, success: function (ret) {
if (ret.code !== 'NOT_FOUND') {
owner.skipFile(file);
uploaded.call(uploader, ret.data, file);
@ -285,7 +282,7 @@
uploader.on('dndAccept', function (items) {
var denied = false, len = items.length, unAllowed = 'text/plain;application/javascript ';
for (var i = 0; i < len; i++) {
if (~unAllowed.indexOf(items[i].type)) {
if (~unAllowed.indexOf(items[ i ].type)) {
denied = true;
break;
}
@ -342,11 +339,7 @@
img = $('<img src="' + src + '">');
$wrap.empty().append(img);
} else {
$.ajax('{"plugs/file/preview"|url}', {
method: 'post',
data: src,
dataType: 'json'
}).done(function (response) {
$.ajax('{"plugs/file/preview"|url}', {method: 'POST', data: src, dataType: 'json'}).done(function (response) {
if (response.result) {
img = $('<img src="' + response.result + '">');
$wrap.empty().append(img);
@ -356,7 +349,7 @@
});
}
}, thumbnailWidth, thumbnailHeight);
percentages[file.id] = [file.size, 0];
percentages[ file.id ] = [file.size, 0];
file.rotation = 0;
$upload.html('开始上传');
}
@ -371,11 +364,11 @@
// 成功
if (cur === 'error' || cur === 'invalid') {
showError(file.statusText);
percentages[file.id][1] = 1;
percentages[ file.id ][ 1 ] = 1;
} else if (cur === 'interrupt') {
showError('interrupt');
} else if (cur === 'queued') {
percentages[file.id][1] = 0;
percentages[ file.id ][ 1 ] = 0;
} else if (cur === 'progress') {
$info.remove();
$prgress.css('display', 'block');
@ -390,10 +383,9 @@
$btns.stop().animate({height: 0});
});
$btns.on('click', 'span', function () {
var index = $(this).index();
var index = $(this).index(), deg;
switch (index) {
case 0:
removeFile(file);
return uploader.removeFile(file);
case 1:
file.rotation += 90;
@ -403,7 +395,7 @@
break;
}
if (supportTransition) {
var deg = 'rotate(' + file.rotation + 'deg)';
deg = 'rotate(' + file.rotation + 'deg)';
$wrap.css({'-webkit-transform': deg, '-mos-transform': deg, '-o-transform': deg, 'transform': deg});
} else {
$wrap.css('filter', 'progid:DXImageTransform.Microsoft.BasicImage(rotation=' + (~~((file.rotation / 90) % 4 + 4) % 4) + ')');
@ -414,7 +406,7 @@
// 负责view的销毁
function removeFile(file) {
delete percentages[file.id];
delete percentages[ file.id ];
updateTotalProgress();
$('#' + file.id).off().find('.file-panel').off().end().remove();
}
@ -422,8 +414,8 @@
function updateTotalProgress() {
var loaded = 0, total = 0, spans = $progress.children(), percent;
$.each(percentages, function (k, v) {
total += v[0];
loaded += v[0] * v[1];
total += v[ 0 ];
loaded += v[ 0 ] * v[ 1 ];
});
percent = total ? loaded / total : 0;
spans.eq(0).text(Math.round(percent * 100) + '%');
@ -507,7 +499,7 @@
uploader.onUploadProgress = function (file, percentage) {
var $li = $('#' + file.id), $percent = $li.find('.progress span');
$percent.css('width', percentage * 100 + '%');
percentages[file.id][1] = percentage;
percentages[ file.id ][ 1 ] = percentage;
updateTotalProgress();
};
@ -570,6 +562,6 @@
updateTotalProgress();
});
</script>
</body>
</script>
</body>
</html>

View File

@ -14,33 +14,33 @@
{block name="content"}
<!-- 表单搜索 开始 -->
<form class="layui-form layui-form-pane form-search" action="__SELF__" onsubmit="return false" method="get">
<div class="layui-form-item layui-inline">
<label class="layui-form-label" style="width:auto">用户名</label>
<div class="layui-input-inline">
<input name="username" value="{$Think.get.username|default=''}" placeholder="请输入用户名" class="layui-input">
<form class="animated form-search" action="__SELF__" onsubmit="return false" method="get">
<div class="row">
<div class="col-xs-3">
<div class="form-group">
<input type="text" name="username" value="{$Think.get.username|default=''}" placeholder="用户名" class="input-sm form-control">
</div>
</div>
<div class="layui-form-item layui-inline">
<label class="layui-form-label" style="width:auto">手机号</label>
<div class="layui-input-inline">
<input name="phone" value="{$Think.get.phone|default=''}" placeholder="请输入手机号" class="layui-input">
<div class="col-xs-3">
<div class="form-group">
<input type="text" name="phone" value="{$Think.get.phone|default=''}" placeholder="手机号" class="input-sm form-control">
</div>
</div>
<div class="layui-form-item layui-inline">
<button class="layui-btn layui-btn-primary"><i class="layui-icon">&#xe615;</i> 搜 索</button>
<div class="col-xs-1">
<div class="form-group">
<button type="submit" class="btn btn-sm btn-white"><i class="fa fa-search"></i> 搜索</button>
</div>
</div>
</div>
</form>
<!-- 表单搜索 结束 -->
<form onsubmit="return false;" data-auto="true" method="post">
{if empty($list)}
<p class="help-block text-center well">没 有 记 录 哦!</p>
{else}
<form onsubmit="return false;" data-auto="" method="POST">
<input type="hidden" value="resort" name="action"/>
<table class="layui-table" lay-skin="line" lay-size="sm">
<table class="table table-hover">
<thead>
<tr>
<th class='list-table-check-td'>
@ -106,6 +106,5 @@
</tbody>
</table>
{if isset($page)}<p>{$page}</p>{/if}
{/if}
</form>
{/block}