fix: 修复redis密码 优化权限
This commit is contained in:
@@ -419,6 +419,7 @@ class AdminController extends BaseController
|
|||||||
case 'year':
|
case 'year':
|
||||||
$value = str_replace(',', '-', $value);
|
$value = str_replace(',', '-', $value);
|
||||||
if (strpos($value, '-')) {
|
if (strpos($value, '-')) {
|
||||||
|
|
||||||
$arr = explode(' - ', $value);
|
$arr = explode(' - ', $value);
|
||||||
if (empty($arr)) {
|
if (empty($arr)) {
|
||||||
continue 2;
|
continue 2;
|
||||||
@@ -454,27 +455,23 @@ class AdminController extends BaseController
|
|||||||
case 'time';
|
case 'time';
|
||||||
case 'datetime';
|
case 'datetime';
|
||||||
$value = str_replace(',', '-', $value);
|
$value = str_replace(',', '-', $value);
|
||||||
|
|
||||||
if (strpos($value, '-')) {
|
if (strpos($value, '-')) {
|
||||||
$arr = explode(' - ', $value);
|
$arr = explode(' - ', $value);
|
||||||
if (!array_filter($arr)) {
|
if (!array_filter($arr)) {
|
||||||
continue 2;
|
continue 2;
|
||||||
}
|
}
|
||||||
|
$exp = 'between';
|
||||||
$exp = '=';
|
|
||||||
if ($arr[0] === '') {
|
if ($arr[0] === '') {
|
||||||
$exp = '<= TIME';
|
$exp = '<=';
|
||||||
$arr = $arr[1];
|
$arr = $arr[1];
|
||||||
} elseif ($arr[1] === '') {
|
} elseif ($arr[1] === '') {
|
||||||
$exp = '>= TIME';
|
$exp = '>=';
|
||||||
$arr = $arr[0];
|
$arr = $arr[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
$where[] = [$field, $exp, $arr];
|
$where[] = [$field, $exp, $arr];
|
||||||
} else {
|
} else {
|
||||||
$where[] = [$field, '=', $value];
|
$where[] = [$field, '=', $value];
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 'blob';
|
case 'blob';
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ class BaseController
|
|||||||
* @param string $app
|
* @param string $app
|
||||||
* @return Response
|
* @return Response
|
||||||
*/
|
*/
|
||||||
protected function retResponseError(string $msg = '404 not found', int $code = 404, string $app = 'index'): Response
|
protected function responseError(string $msg = '404 not found', int $code = 404, string $app = 'index'): Response
|
||||||
{
|
{
|
||||||
if (\request()->expectsJson()) {
|
if (\request()->expectsJson()) {
|
||||||
return json(['code' => 404, 'msg' => $msg]);
|
return json(['code' => 404, 'msg' => $msg]);
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ declare(strict_types=1);
|
|||||||
// +----------------------------------------------------------------------
|
// +----------------------------------------------------------------------
|
||||||
namespace app\admin\controller;
|
namespace app\admin\controller;
|
||||||
|
|
||||||
|
use app\admin\enums\AdminNoticeEnum;
|
||||||
use app\common\service\notice\EmailService;
|
use app\common\service\notice\EmailService;
|
||||||
use app\common\service\utils\FtpService;
|
use app\common\service\utils\FtpService;
|
||||||
use Psr\SimpleCache\InvalidArgumentException;
|
use Psr\SimpleCache\InvalidArgumentException;
|
||||||
@@ -185,9 +186,25 @@ class Index extends AdminController
|
|||||||
UserThird::count('id'),
|
UserThird::count('id'),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
$workplace = [];
|
||||||
|
foreach (AdminNoticeEnum::COLLECTION as $item) {
|
||||||
|
$workplace[$item] = AdminNotice::where([
|
||||||
|
'admin_id' => get_admin_id(),
|
||||||
|
'type' => $item
|
||||||
|
])->count('id');
|
||||||
|
}
|
||||||
|
|
||||||
|
$todoList = AdminNotice::where([
|
||||||
|
'admin_id' => get_admin_id(),
|
||||||
|
'type' => AdminNoticeEnum::TODO,
|
||||||
|
'status' => 0
|
||||||
|
])->count('id');
|
||||||
|
|
||||||
return view('/index/console', [
|
return view('/index/console', [
|
||||||
'assetsInfo' => $assetsInfo,
|
'assetsInfo' => $assetsInfo,
|
||||||
'workplace' => [],
|
'workplace' => $workplace,
|
||||||
|
'todoList' => $todoList,
|
||||||
'devOpsData' => json_encode($devOpsData, JSON_UNESCAPED_UNICODE),
|
'devOpsData' => json_encode($devOpsData, JSON_UNESCAPED_UNICODE),
|
||||||
'searchWords' => json_encode($searchWords, JSON_UNESCAPED_UNICODE),
|
'searchWords' => json_encode($searchWords, JSON_UNESCAPED_UNICODE),
|
||||||
'userGroupData' => json_encode($userGroupData, JSON_UNESCAPED_UNICODE),
|
'userGroupData' => json_encode($userGroupData, JSON_UNESCAPED_UNICODE),
|
||||||
|
|||||||
@@ -15,7 +15,9 @@ use app\admin\service\AdminRuleService;
|
|||||||
use app\AdminController;
|
use app\AdminController;
|
||||||
use app\common\model\system\AdminRules as AdminRuleModel;
|
use app\common\model\system\AdminRules as AdminRuleModel;
|
||||||
use support\Response;
|
use support\Response;
|
||||||
|
use think\db\exception\DataNotFoundException;
|
||||||
use think\db\exception\DbException;
|
use think\db\exception\DbException;
|
||||||
|
use think\db\exception\ModelNotFoundException;
|
||||||
use Webman\Http\Request;
|
use Webman\Http\Request;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -60,15 +62,29 @@ class AdminRules extends AdminController
|
|||||||
return $this->success('添加菜单成功!');
|
return $this->success('添加菜单成功!');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $this->error('添加菜单失败!');
|
|
||||||
|
$data = $this->getTableFields();
|
||||||
|
$data['pid'] = input('pid', 0);
|
||||||
|
$data['auth'] = 1;
|
||||||
|
$data['type'] = 1;
|
||||||
|
list($count, $list) = AdminRuleService::dataList(request()->all());
|
||||||
|
return view('/system/admin/rules_edit', [
|
||||||
|
'data' => $data,
|
||||||
|
'rules' => json_encode( list_to_tree($list), JSON_UNESCAPED_UNICODE),
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 编辑节点数据
|
* 编辑节点数据
|
||||||
* @return Response
|
* @return Response
|
||||||
|
* @throws DbException
|
||||||
|
* @throws DataNotFoundException
|
||||||
|
* @throws ModelNotFoundException
|
||||||
*/
|
*/
|
||||||
public function edit(): Response
|
public function edit(): Response
|
||||||
{
|
{
|
||||||
|
$id = input('id', 0);
|
||||||
|
$data = $this->model->find($id);
|
||||||
if (request()->isPost()) {
|
if (request()->isPost()) {
|
||||||
$post = \request()->post();
|
$post = \request()->post();
|
||||||
validate(\app\common\validate\system\AdminRules::class . '.edit')->check($post);
|
validate(\app\common\validate\system\AdminRules::class . '.edit')->check($post);
|
||||||
@@ -76,7 +92,12 @@ class AdminRules extends AdminController
|
|||||||
return $this->success('更新菜单成功!');
|
return $this->success('更新菜单成功!');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $this->error('更新菜单失败');
|
|
||||||
|
list($count, $list) = AdminRuleService::dataList(request()->all());
|
||||||
|
return view('/system/admin/rules_edit', [
|
||||||
|
'data' => $data,
|
||||||
|
'rules' => json_encode( list_to_tree($list), JSON_UNESCAPED_UNICODE),
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ class AdminGroupService
|
|||||||
// 查询数据
|
// 查询数据
|
||||||
$count = $model->where($where)->count();
|
$count = $model->where($where)->count();
|
||||||
$page = ($count <= $limit) ? 1 : $page;
|
$page = ($count <= $limit) ? 1 : $page;
|
||||||
$list = $model->where($where)->order("id asc")->limit($limit)->page($page)->select()->toArray();
|
$list = $model->where($where)->order("id asc")->limit((int)$limit)->page((int)$page)->select()->toArray();
|
||||||
return [$count, $list];
|
return [$count, $list];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ class ApiPermissions implements MiddlewareInterface
|
|||||||
|
|
||||||
// 是否验证登录器
|
// 是否验证登录器
|
||||||
$userInfo = UserTokenService::isLogin();
|
$userInfo = UserTokenService::isLogin();
|
||||||
if (!empty($userInfo)) {
|
if (!empty($userInfo) && isset($userInfo['id'])) {
|
||||||
$request->userId = $userInfo['id'];
|
$request->userId = $userInfo['id'];
|
||||||
$request->userInfo = $userInfo;
|
$request->userInfo = $userInfo;
|
||||||
// 是否验证API权限
|
// 是否验证API权限
|
||||||
|
|||||||
@@ -57,6 +57,11 @@ class ExceptionHandle extends ExceptionHandler
|
|||||||
{
|
{
|
||||||
switch (true) {
|
switch (true) {
|
||||||
case $exception instanceof OperateException:
|
case $exception instanceof OperateException:
|
||||||
|
return json([
|
||||||
|
'code' => $exception->getCode() ?? 101,
|
||||||
|
'msg' => $exception->getMessage(),
|
||||||
|
'data' => $exception->getData()
|
||||||
|
]);
|
||||||
case $exception instanceof ValidateException:
|
case $exception instanceof ValidateException:
|
||||||
return json(['code' => $exception->getCode() ?? 101, 'msg' => $exception->getMessage()]);
|
return json(['code' => $exception->getCode() ?? 101, 'msg' => $exception->getMessage()]);
|
||||||
case $exception instanceof DumpException:
|
case $exception instanceof DumpException:
|
||||||
|
|||||||
@@ -24,4 +24,13 @@ class OperateException extends \Exception
|
|||||||
$this->message = $message ?: ResultCode::UNKNOWN['msg'];
|
$this->message = $message ?: ResultCode::UNKNOWN['msg'];
|
||||||
parent::__construct($this->message, $this->code, $previous);
|
parent::__construct($this->message, $this->code, $previous);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取附加数据
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getData(): array
|
||||||
|
{
|
||||||
|
return $this->data;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -405,9 +405,22 @@ class Upload
|
|||||||
*/
|
*/
|
||||||
public function fileFilter($file): bool
|
public function fileFilter($file): bool
|
||||||
{
|
{
|
||||||
|
$this->fileClass = null;
|
||||||
|
$mineType = $file->getUploadMineType();
|
||||||
|
if (in_array($mineType, ['text/x-php', 'text/html'])) {
|
||||||
|
$this->_error = '禁止上传的文件类型';
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$validate = new UploadFile();
|
$validate = new UploadFile();
|
||||||
$rules = get_object_vars($validate)['rule'];
|
$rules = get_object_vars($validate)['rule'];
|
||||||
$fileExt = $this->getFileExt($file);
|
$fileExt = $file->getUploadExtension() ?: input('fileExt');
|
||||||
|
|
||||||
|
if (empty($fileExt)) {
|
||||||
|
$this->fileClass = 'file';
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($rules as $key => $value) {
|
foreach ($rules as $key => $value) {
|
||||||
$fileExtArr = explode(',', $value['fileExt']);
|
$fileExtArr = explode(',', $value['fileExt']);
|
||||||
if (in_array(strtolower($fileExt), $fileExtArr)) {
|
if (in_array(strtolower($fileExt), $fileExtArr)) {
|
||||||
@@ -419,15 +432,13 @@ class Upload
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (in_array($file->getUploadMineType(), ['text/x-php', 'text/html'])) {
|
|
||||||
$this->fileClass = null;
|
|
||||||
}
|
|
||||||
if (is_empty($this->fileClass)) {
|
if (is_empty($this->fileClass)) {
|
||||||
$this->_error = '禁止上传的文件类型';
|
$this->_error = '禁止上传的文件类型';
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// 未找到类型或验证文件失败
|
|
||||||
return !empty($this->fileClass);
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -447,7 +458,10 @@ class Upload
|
|||||||
* @param string $filePath
|
* @param string $filePath
|
||||||
* @param array $extend
|
* @param array $extend
|
||||||
* @return array
|
* @return array
|
||||||
|
* @throws DataNotFoundException
|
||||||
|
* @throws DbException
|
||||||
* @throws InvalidArgumentException
|
* @throws InvalidArgumentException
|
||||||
|
* @throws ModelNotFoundException
|
||||||
*/
|
*/
|
||||||
public function success(string $msg, string $filePath, array $extend = []): array
|
public function success(string $msg, string $filePath, array $extend = []): array
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -14,17 +14,17 @@ class UploadFile extends Validate
|
|||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public $rule = [
|
public $rule = [
|
||||||
'images'=>[
|
'images' => [
|
||||||
'fileSize' => 419430400,
|
'fileSize' => 419430400,
|
||||||
'fileExt' => 'jpg,jpeg,png,bmp,gif,svg,webp',
|
'fileExt' => 'jpg,jpeg,png,bmp,gif,svg,webp',
|
||||||
'fileMime' => 'image/jpeg,image/png,image/gif,image/svg+xml'],
|
'fileMime' => 'image/jpeg,image/png,image/gif,image/svg+xml'],
|
||||||
'video'=>[
|
'video' => [
|
||||||
'fileSize' => 419430400,
|
'fileSize' => 419430400,
|
||||||
'fileExt' => 'flv,swf,mkv,avi,rm,rmvb,mpeg,mpg,ogg,ogv,mov,wmv,mp4,webm,mp3,wav,mid'],
|
'fileExt' => 'flv,swf,mkv,avi,rm,rmvb,mpeg,mpg,ogg,ogv,mov,wmv,mp4,webm,mp3,wav,mid'],
|
||||||
'document'=>[
|
'document' => [
|
||||||
'fileSize' => 419430400,
|
'fileSize' => 419430400,
|
||||||
'fileExt' => 'txt,doc,xls,ppt,docx,xlsx,pptx'],
|
'fileExt' => 'txt,doc,xls,ppt,docx,xlsx,pptx'],
|
||||||
'files'=>[
|
'files' => [
|
||||||
'fileSize' => 419430400,
|
'fileSize' => 419430400,
|
||||||
'fileExt' => 'exe,dll,sys,so,dmg,iso,zip,rar,7z,sql,pem,pdf,psd']
|
'fileExt' => 'exe,dll,sys,so,dmg,iso,zip,rar,7z,sql,pem,pdf,psd']
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -1109,14 +1109,16 @@ if (!function_exists('check_user_third')) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!function_exists('check_admin_auth')) {
|
if (!function_exists('has_admin_auth')) {
|
||||||
/**
|
/**
|
||||||
* 检查admin权限
|
* 检查admin权限
|
||||||
* @param $method
|
* @param $method
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
function check_admin_auth($method): bool
|
|
||||||
|
function has_admin_auth($method): bool
|
||||||
{
|
{
|
||||||
|
|
||||||
if (\app\admin\service\AuthService::instance()->SuperAdmin()) {
|
if (\app\admin\service\AuthService::instance()->SuperAdmin()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ return [
|
|||||||
'dispatch_success' => app_path() . '/admin/view/public/jumptpl.html',
|
'dispatch_success' => app_path() . '/admin/view/public/jumptpl.html',
|
||||||
'exception_tpl' => app_path() . '/admin/view/error/500.html',
|
'exception_tpl' => app_path() . '/admin/view/error/500.html',
|
||||||
'error_message' => '页面错误!请稍后再试~',
|
'error_message' => '页面错误!请稍后再试~',
|
||||||
'version' => 'v1.1.8',
|
'version' => 'v1.1.9',
|
||||||
'cors_domain' => ['*', '127.0.0.1'],
|
'cors_domain' => ['*', '127.0.0.1'],
|
||||||
'api_url' => 'https://api.swiftadmin.net/',
|
'api_url' => 'https://api.swiftadmin.net/',
|
||||||
'show_error_msg' => false,
|
'show_error_msg' => false,
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
return [
|
return [
|
||||||
'default' => [
|
'default' => [
|
||||||
'host' => get_env('CACHE_HOSTNAME', '127.0.0.1'),
|
'host' => get_env('CACHE_HOSTNAME', '127.0.0.1'),
|
||||||
'password' => get_env('REDIS_PASSWORD', null),
|
'password' => get_env('CACHE_PASSWORD', null),
|
||||||
'port' => (int)get_env('CACHE_HOSTPORT',6379),
|
'port' => (int)get_env('CACHE_HOSTPORT',6379),
|
||||||
'database' => get_env('CACHE_SELECT', 0),
|
'database' => get_env('CACHE_SELECT', 0),
|
||||||
'prefix' => 'redis_',
|
'prefix' => 'redis_',
|
||||||
|
|||||||
@@ -111,7 +111,6 @@ class ZipArchives
|
|||||||
}
|
}
|
||||||
|
|
||||||
} catch (\Throwable $th) {
|
} catch (\Throwable $th) {
|
||||||
var_dump($th->getMessage());
|
|
||||||
throw new \Exception("压缩 " . $fileName . " 包失败", -115);
|
throw new \Exception("压缩 " . $fileName . " 包失败", -115);
|
||||||
} finally {
|
} finally {
|
||||||
$zip->close();
|
$zip->close();
|
||||||
|
|||||||
Reference in New Issue
Block a user