解决未登录也能文件上传的问题
This commit is contained in:
@@ -12,26 +12,7 @@ use think\facade\Session;
|
||||
use think\facade\Filesystem;
|
||||
use app\model\Attach;
|
||||
|
||||
class Upload extends Base {
|
||||
|
||||
// 使用内置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() {
|
||||
}
|
||||
|
||||
trait Upload {
|
||||
public function index(){
|
||||
$param = $this->request->get();
|
||||
|
||||
@@ -46,7 +27,7 @@ class Upload extends Base {
|
||||
'actionname' => 'index'
|
||||
]
|
||||
];
|
||||
return $this->fetch();
|
||||
return $this->fetch(root_path() . 'view/upload/index.html');
|
||||
}
|
||||
|
||||
public function server(){
|
||||
@@ -77,7 +58,7 @@ class Upload extends Base {
|
||||
'actionname' => 'server'
|
||||
]
|
||||
];
|
||||
return $this->fetch();
|
||||
return $this->fetch(root_path() . 'view/upload/server.html');
|
||||
}
|
||||
|
||||
public function upload(){
|
||||
|
||||
@@ -94,7 +94,7 @@ class Base extends \app\controller\Base {
|
||||
if (!$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 true;
|
||||
|
||||
@@ -9,11 +9,8 @@
|
||||
|
||||
namespace app\controller\admin;
|
||||
|
||||
class Upload extends Base {
|
||||
use app\controller\Upload as Uploads;
|
||||
|
||||
public function _empty() {
|
||||
$controller = controller('common/Upload');
|
||||
$action = $this->request->action();
|
||||
return $controller->$action();
|
||||
}
|
||||
class Upload extends Base {
|
||||
use Uploads;
|
||||
}
|
||||
+4
-3
@@ -12,7 +12,8 @@ use think\facade\Route;
|
||||
use think\facade\Cache;
|
||||
use app\model\Model;
|
||||
use app\model\Rewrite;
|
||||
|
||||
use app\http\middleware\Validate;
|
||||
use app\http\middleware\Admin;
|
||||
|
||||
$model = Cache::get('model_list');
|
||||
if (!$model) {
|
||||
@@ -57,7 +58,7 @@ Route::group('admin', function () {
|
||||
Route::rule('/', 'admin.Index/index');
|
||||
Route::rule('login', 'admin.Index/login');
|
||||
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');
|
||||
});
|
||||
|
||||
@@ -66,7 +67,7 @@ Route::group('user', function () {
|
||||
Route::rule('login', 'user.Index/login');
|
||||
Route::rule('logout', 'user.Index/logout');
|
||||
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');
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user