post请求参数数量超出php.ini限制校验

feat/task1-c-wallet
devil_gong 2019-01-15 12:39:57 +08:00
parent 186f3be6e8
commit 74c2e6d5e8
6 changed files with 116 additions and 4 deletions

View File

@ -13,6 +13,7 @@ namespace app\admin\controller;
use think\Controller;
use app\service\AdminPowerService;
use app\service\ConfigService;
use app\service\OtherService;
/**
* 管理员公共控制器
@ -59,8 +60,28 @@ class Common extends Controller
// 视图初始化
$this->ViewInit();
// 其它处理
$this->OtherHandle();
}
/**
* 其它处理
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2018-12-07
* @desc description
*/
private function OtherHandle()
{
$ret = OtherService::EnvironmentCheck();
if($ret['code'] != 0)
{
exit(json_encode($ret));
}
}
/**
* 系统初始化
* @author Devil

View File

@ -13,6 +13,7 @@ namespace app\api\controller;
use think\Controller;
use app\service\ConfigService;
use app\service\UserService;
use app\service\OtherService;
/**
* 接口公共控制器
@ -60,7 +61,27 @@ class Common extends Controller
// 公共数据初始化
$this->CommonInit();
}
// 其它处理
$this->OtherHandle();
}
/**
* 其它处理
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2018-12-07
* @desc description
*/
private function OtherHandle()
{
$ret = OtherService::EnvironmentCheck();
if($ret['code'] != 0)
{
exit(json_encode($ret));
}
}
/**
* 系统初始化

View File

@ -18,6 +18,7 @@ use app\service\MessageService;
use app\service\SearchService;
use app\service\ConfigService;
use app\service\LinkService;
use app\service\OtherService;
/**
* 前端公共控制器
@ -64,6 +65,26 @@ class Common extends Controller
// 视图初始化
$this->ViewInit();
// 其它处理
$this->OtherHandle();
}
/**
* 其它处理
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2018-12-07
* @desc description
*/
private function OtherHandle()
{
$ret = OtherService::EnvironmentCheck();
if($ret['code'] != 0)
{
exit(json_encode($ret));
}
}
/**

View File

@ -0,0 +1,45 @@
<?php
// +----------------------------------------------------------------------
// | ShopXO 国内领先企业级B2C免费开源电商系统
// +----------------------------------------------------------------------
// | Copyright (c) 2011~2018 http://shopxo.net All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: Devil
// +----------------------------------------------------------------------
namespace app\service;
/**
* 其它处理服务层
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2016-12-01T21:51:08+0800
*/
class OtherService
{
/**
* 环境校验
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2018-12-07
* @desc description
*/
public static function EnvironmentCheck()
{
if(IS_AJAX)
{
// 请求参数数量校验是否超出php.ini限制
$max_input_vars = intval(ini_get('max_input_vars'))-5;
if(count(input('post.')) >= $max_input_vars)
{
return DataReturn('请求参数数量已超出php.ini限制[max_input_vars]', -1000);
}
}
return DataReturn('success', 0);
}
}
?>

View File

@ -137,7 +137,7 @@ return [
'exception_tmpl' => Env::get('think_path') . 'tpl/think_exception.tpl',
// 错误显示信息,非调试模式有效
'error_message' => '页面错误!请稍后再试~',
'error_message' => '系统出现错误、请联系管理员或到ShopXO社区查阅~',
// 显示错误信息
'show_error_msg' => false,
// 异常处理handle类 留空使用 \think\exception\Handle

View File

@ -280,6 +280,9 @@
pre.prettyprint .atv { color: #080 } /* a markup attribute value */
pre.prettyprint .dec, pre.prettyprint .var { color: #606 } /* a declaration; a variable name */
pre.prettyprint .fun { color: red } /* a function name */
/* shopxo */
.shopxo-ask { margin-left: 15px; }
</style>
</head>
<body>
@ -410,8 +413,9 @@
<?php } ?>
<div class="copyright">
<a title="官方网站" href="http://www.shopxo.net">ShopXO</a>
<span><?php echo APPLICATION_VERSION; ?></span>
<a title="ShopXO官网" href="http://www.shopxo.net"target="_blank">ShopXO官网</a>
<span><?php echo APPLICATION_VERSION; ?></span>
<a title="ShopXO社区" href="http://ask.shopxo.net" target="_blank" class="shopxo-ask">ShopXO社区</a>
<span>{ B2C }</span>
</div>
<?php if(\think\facade\App::isDebug()) { ?>