禁止非法访问文章分类,抛出异常
This commit is contained in:
parent
c6ac0cba25
commit
c049c1318e
@ -20,7 +20,13 @@ class Article extends BaseController
|
||||
];
|
||||
|
||||
//文章分类
|
||||
public function cate(){
|
||||
public function cate()
|
||||
{
|
||||
//非法请求参数,抛出异常
|
||||
if(count(Request::param()) >3){
|
||||
// 抛出 HTTP 异常
|
||||
throw new \think\exception\HttpException(404, '请求异常');
|
||||
}
|
||||
|
||||
//获取分类ID
|
||||
$ename = Request::param('ename');
|
||||
|
@ -14,7 +14,11 @@ Route::get('captcha/[:config]','\\think\\captcha\\CaptchaController@index');
|
||||
Route::rule('/', 'index'); // 首页访问路由
|
||||
Route::group(function () {
|
||||
Route::get('jie/:id', 'article/detail');
|
||||
Route::get('column/<ename?>/<type?>/<page?>','article/cate');
|
||||
Route::get('column/<ename?>/<type?>/<page?>','article/cate')
|
||||
->pattern([
|
||||
'ename' => '\w+',
|
||||
'page' => '\d+',
|
||||
]);
|
||||
Route::rule('add','article/add');
|
||||
Route::rule('edit/[:id]','article/edit');
|
||||
//Route::rule('del/:id','article/delete');
|
||||
|
Loading…
Reference in New Issue
Block a user