[更新]代码巡检优化修复

This commit is contained in:
Anyon 2017-06-24 15:01:47 +08:00
parent dd05c100bb
commit c11064ef7b
7 changed files with 28 additions and 40 deletions

View File

@ -38,9 +38,7 @@ class Index extends BasicAdmin {
NodeService::applyAuthNode(); NodeService::applyAuthNode();
$list = Db::name('SystemMenu')->where('status', '1')->order('sort asc,id asc')->select(); $list = Db::name('SystemMenu')->where('status', '1')->order('sort asc,id asc')->select();
$menus = $this->_filterMenu(ToolsService::arr2tree($list)); $menus = $this->_filterMenu(ToolsService::arr2tree($list));
$this->assign('title', '系统管理'); return view('', ['title' => '系统管理', 'menus' => $menus]);
$this->assign('menus', $menus);
return view();
} }
/** /**
@ -71,9 +69,6 @@ class Index extends BasicAdmin {
* @return View * @return View
*/ */
public function main() { public function main() {
$_version = Db::query('select version() as ver');
$version = array_pop($_version);
$this->assign('mysql_ver', $version['ver']);
if (session('user.username') === 'admin' && session('user.password') === '21232f297a57a5a743894a0e4a801fc3') { if (session('user.username') === 'admin' && session('user.password') === '21232f297a57a5a743894a0e4a801fc3') {
$url = url('admin/index/pass') . '?id=' . session('user.id'); $url = url('admin/index/pass') . '?id=' . session('user.id');
$alert = [ $alert = [
@ -84,7 +79,9 @@ class Index extends BasicAdmin {
$this->assign('alert', $alert); $this->assign('alert', $alert);
$this->assign('title', '后台首页'); $this->assign('title', '后台首页');
} }
return view(); $_version = Db::query('select version() as ver');
$version = array_pop($_version);
return view('', ['mysql_ver' => $version['ver']]);
} }
/** /**

View File

@ -55,17 +55,21 @@ class Login extends BasicAdmin {
*/ */
public function index() { public function index() {
if ($this->request->isGet()) { if ($this->request->isGet()) {
$this->assign('title', '用户登录'); return $this->fetch('', ['title' => '用户登录']);
return $this->fetch();
} else { } else {
// 输入数据效验
$username = $this->request->post('username', '', 'trim'); $username = $this->request->post('username', '', 'trim');
$password = $this->request->post('password', '', 'trim'); $password = $this->request->post('password', '', 'trim');
(empty($username) || strlen($username) < 4) && $this->error('登录账号长度不能少于4位有效字符!'); strlen($username) < 4 && $this->error('登录账号长度不能少于4位有效字符!');
(empty($password) || strlen($password) < 4) && $this->error('登录密码长度不能少于4位有效字符!'); strlen($password) < 4 && $this->error('登录密码长度不能少于4位有效字符!');
// 用户信息验证
$user = Db::name('SystemUser')->where('username', $username)->find(); $user = Db::name('SystemUser')->where('username', $username)->find();
empty($user) && $this->error('登录账号不存在,请重新输入!'); empty($user) && $this->error('登录账号不存在,请重新输入!');
($user['password'] !== md5($password)) && $this->error('登录密码与账号不匹配,请重新输入!'); ($user['password'] !== md5($password)) && $this->error('登录密码与账号不匹配,请重新输入!');
Db::name('SystemUser')->where('id', $user['id'])->update(['login_at' => ['exp', 'now()'], 'login_num' => ['exp', 'login_num+1']]); empty($user['status']) && $this->error('账号已经被禁用,请联系管理!');
// 更新登录信息
$data = ['login_at' => ['exp', 'now()'], 'login_num' => ['exp', 'login_num+1']];
Db::name('SystemUser')->where('id', $user['id'])->update($data);
session('user', $user); session('user', $user);
!empty($user['authorize']) && NodeService::applyAuthNode(); !empty($user['authorize']) && NodeService::applyAuthNode();
LogService::write('系统管理', '用户登录系统成功'); LogService::write('系统管理', '用户登录系统成功');

View File

@ -109,9 +109,9 @@ class Menu extends BasicAdmin {
*/ */
public function del() { public function del() {
if (DataService::update($this->table)) { if (DataService::update($this->table)) {
$this->success("菜单删除成功", ''); $this->success("菜单删除成功!", '');
} }
$this->error("菜单删除失败,请稍候再试!"); $this->error("菜单删除失败, 请稍候再试!");
} }
/** /**
@ -119,9 +119,9 @@ class Menu extends BasicAdmin {
*/ */
public function forbid() { public function forbid() {
if (DataService::update($this->table)) { if (DataService::update($this->table)) {
$this->success("菜单禁用成功", ''); $this->success("菜单禁用成功!", '');
} }
$this->error("菜单禁用失败,请稍候再试!"); $this->error("菜单禁用失败, 请稍候再试!");
} }
/** /**
@ -129,9 +129,9 @@ class Menu extends BasicAdmin {
*/ */
public function resume() { public function resume() {
if (DataService::update($this->table)) { if (DataService::update($this->table)) {
$this->success("菜单启用成功", ''); $this->success("菜单启用成功!", '');
} }
$this->error("菜单启用失败,请稍候再试!"); $this->error("菜单启用失败, 请稍候再试!");
} }
} }

View File

@ -38,14 +38,9 @@ class Node extends BasicAdmin {
* 显示节点列表 * 显示节点列表
*/ */
public function index() { public function index() {
$this->assign('alert', [ $alert = ['type' => 'danger', 'title' => '安全警告', 'content' => '结构为系统自动生成, 状态数据请勿随意修改!'];
'type' => 'danger', $nodes = ToolsService::arr2table(NodeService::get(), 'node', 'pnode');
'title' => '安全警告', return view('', ['title' => '系统节点管理', 'nodes' => $nodes, 'alert' => $alert]);
'content' => '结构为系统自动生成,状态数据请勿随意修改!'
]);
$this->assign('title', '系统节点管理');
$this->assign('nodes', ToolsService::arr2table(NodeService::get(), 'node', 'pnode'));
return view();
} }
/** /**

View File

@ -44,17 +44,14 @@ class Plugs extends BasicAdmin {
* @return View * @return View
*/ */
public function upfile() { public function upfile() {
$types = $this->request->get('type', 'jpg,png');
$mode = $this->request->get('mode', 'one');
$this->assign('mode', $mode);
$this->assign('types', $types);
if (!in_array(($uptype = $this->request->get('uptype')), ['local', 'qiniu'])) { if (!in_array(($uptype = $this->request->get('uptype')), ['local', 'qiniu'])) {
$uptype = sysconf('storage_type'); $uptype = sysconf('storage_type');
} }
$this->assign('uptype', $uptype); $types = $this->request->get('type', 'jpg,png');
$mode = $this->request->get('mode', 'one');
$this->assign('mimes', FileService::getFileMine($types)); $this->assign('mimes', FileService::getFileMine($types));
$this->assign('field', $this->request->get('field', 'file')); $this->assign('field', $this->request->get('field', 'file'));
return view(); return view('', ['mode' => $mode, 'types' => $types, 'uptype' => $uptype]);
} }
/** /**
@ -66,8 +63,7 @@ class Plugs extends BasicAdmin {
$md5s = str_split($this->request->post('md5'), 16); $md5s = str_split($this->request->post('md5'), 16);
if (($info = $this->request->file('file')->move('static' . DS . 'upload' . DS . $md5s[0], $md5s[1], true))) { if (($info = $this->request->file('file')->move('static' . DS . 'upload' . DS . $md5s[0], $md5s[1], true))) {
$filename = join('/', $md5s) . '.' . $info->getExtension(); $filename = join('/', $md5s) . '.' . $info->getExtension();
$site_url = FileService::getFileUrl($filename, 'local'); if (($site_url = FileService::getFileUrl($filename, 'local'))) {
if ($site_url) {
return json(['data' => ['site_url' => $site_url], 'code' => 'SUCCESS']); return json(['data' => ['site_url' => $site_url], 'code' => 'SUCCESS']);
} }
} }
@ -99,9 +95,7 @@ class Plugs extends BasicAdmin {
$time = time() + 3600; $time = time() + 3600;
$policyText = [ $policyText = [
'expiration' => date('Y-m-d', $time) . 'T' . date('H:i:s', $time) . '.000Z', 'expiration' => date('Y-m-d', $time) . 'T' . date('H:i:s', $time) . '.000Z',
'conditions' => [ 'conditions' => [['content-length-range', 0, 1048576000]]
['content-length-range', 0, 1048576000]
]
]; ];
$config['policy'] = base64_encode(json_encode($policyText)); $config['policy'] = base64_encode(json_encode($policyText));
$config['server'] = FileService::getUploadOssUrl(); $config['server'] = FileService::getUploadOssUrl();

View File

@ -41,8 +41,7 @@ class Config extends BasicAdmin {
*/ */
public function index() { public function index() {
if ($this->request->isGet()) { if ($this->request->isGet()) {
$this->assign('title', '微信接口配置'); return view('', ['title' => '微信接口配置']);
return view();
} }
foreach ($this->request->post() as $key => $vo) { foreach ($this->request->post() as $key => $vo) {
sysconf($key, $vo); sysconf($key, $vo);

View File

@ -65,7 +65,6 @@ require.config({
window.WEB_SOCKET_SWF_LOCATION = baseUrl + "../plugs/socket/WebSocketMain.swf"; window.WEB_SOCKET_SWF_LOCATION = baseUrl + "../plugs/socket/WebSocketMain.swf";
window.UEDITOR_HOME_URL = (window.ROOT_URL ? window.ROOT_URL + '/static/' : baseUrl) + 'plugs/ueditor/'; window.UEDITOR_HOME_URL = (window.ROOT_URL ? window.ROOT_URL + '/static/' : baseUrl) + 'plugs/ueditor/';
window.LAYDATE_PATH = baseUrl + '../plugs/layui/laydate/';
// UI框架初始化 // UI框架初始化
require(['pace', 'jquery', 'layui', 'bootstrap', 'jquery.cookies'], function () { require(['pace', 'jquery', 'layui', 'bootstrap', 'jquery.cookies'], function () {