解决未登录也能文件上传的问题

This commit is contained in:
molong
2022-01-09 22:49:38 +08:00
parent 53ef2ad583
commit 35fcb75a50
5 changed files with 571 additions and 592 deletions
+3 -22
View File
@@ -12,26 +12,7 @@ use think\facade\Session;
use think\facade\Filesystem; use think\facade\Filesystem;
use app\model\Attach; use app\model\Attach;
class Upload extends Base { trait Upload {
// 使用内置PHP模板引擎渲染模板输出
protected $tpl_config = [
'view_dir_name' => 'view',
'tpl_replace_string' => [
'__static__' => '/static',
'__img__' => '/static/admin/images',
'__css__' => '/static/admin/css',
'__js__' => '/static/admin/js',
'__plugins__' => '/static/plugins',
'__public__' => '/static/admin',
],
];
public $data = ['data' => [], 'code' => 0, 'msg' => ''];
protected function initialize() {
}
public function index(){ public function index(){
$param = $this->request->get(); $param = $this->request->get();
@@ -46,7 +27,7 @@ class Upload extends Base {
'actionname' => 'index' 'actionname' => 'index'
] ]
]; ];
return $this->fetch(); return $this->fetch(root_path() . 'view/upload/index.html');
} }
public function server(){ public function server(){
@@ -77,7 +58,7 @@ class Upload extends Base {
'actionname' => 'server' 'actionname' => 'server'
] ]
]; ];
return $this->fetch(); return $this->fetch(root_path() . 'view/upload/server.html');
} }
public function upload(){ public function upload(){
+1 -1
View File
@@ -94,7 +94,7 @@ class Base extends \app\controller\Base {
if (!$Auth) { if (!$Auth) {
$Auth = new \sent\auth\Auth(); $Auth = new \sent\auth\Auth();
} }
if (!$Auth->check($rule, session('userInfo.uid'), $type, $mode)) { if (!$Auth->check($rule, session('adminInfo.uid'), $type, $mode)) {
return false; return false;
} }
return true; return true;
+3 -6
View File
@@ -9,11 +9,8 @@
namespace app\controller\admin; namespace app\controller\admin;
class Upload extends Base { use app\controller\Upload as Uploads;
public function _empty() { class Upload extends Base {
$controller = controller('common/Upload'); use Uploads;
$action = $this->request->action();
return $controller->$action();
}
} }
+4 -3
View File
@@ -12,7 +12,8 @@ use think\facade\Route;
use think\facade\Cache; use think\facade\Cache;
use app\model\Model; use app\model\Model;
use app\model\Rewrite; use app\model\Rewrite;
use app\http\middleware\Validate;
use app\http\middleware\Admin;
$model = Cache::get('model_list'); $model = Cache::get('model_list');
if (!$model) { if (!$model) {
@@ -57,7 +58,7 @@ Route::group('admin', function () {
Route::rule('/', 'admin.Index/index'); Route::rule('/', 'admin.Index/index');
Route::rule('login', 'admin.Index/login'); Route::rule('login', 'admin.Index/login');
Route::rule('logout', 'admin.Index/logout'); Route::rule('logout', 'admin.Index/logout');
Route::rule('upload/:function', 'Upload/:function')->append(['from'=>'admin']); Route::rule('upload/:function', 'admin.Upload/:function')->append(['from'=>'admin']);
Route::rule(':controller/:function', 'admin.:controller/:function'); Route::rule(':controller/:function', 'admin.:controller/:function');
}); });
@@ -66,7 +67,7 @@ Route::group('user', function () {
Route::rule('login', 'user.Index/login'); Route::rule('login', 'user.Index/login');
Route::rule('logout', 'user.Index/logout'); Route::rule('logout', 'user.Index/logout');
Route::rule('register', 'user.Index/register'); Route::rule('register', 'user.Index/register');
Route::rule('upload/:function', 'Upload/:function')->append(['from'=>'user']); Route::rule('upload/:function', 'user.Upload/:function')->append(['from'=>'user']);
Route::rule(':controller/:function', 'user.:controller/:function'); Route::rule(':controller/:function', 'user.:controller/:function');
}); });