diff --git a/application/admin/controller/Common.php b/application/admin/controller/Common.php index b6569eac1e95f01f3f5adc08b5820de1a15778ff..6dbd4e079efa0d15f1cff2f0e799198a8e807041 100755 --- a/application/admin/controller/Common.php +++ b/application/admin/controller/Common.php @@ -13,7 +13,6 @@ namespace app\admin\controller; use think\Controller; use app\service\AdminPowerService; use app\service\ConfigService; -use app\service\OtherService; /** * 管理员公共控制器 @@ -60,29 +59,8 @@ 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 diff --git a/application/api/controller/Common.php b/application/api/controller/Common.php index d9339aa516a822afac952a915d1247727c879d66..f1b4e4579ccb2362e6ea8ee8cf3aafc1b6865887 100755 --- a/application/api/controller/Common.php +++ b/application/api/controller/Common.php @@ -13,7 +13,6 @@ namespace app\api\controller; use think\Controller; use app\service\ConfigService; use app\service\UserService; -use app\service\OtherService; /** * 接口公共控制器 @@ -61,27 +60,6 @@ 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)); - } } /** diff --git a/application/http/middleware/AccessInAppCheck.php b/application/http/middleware/AccessInAppCheck.php new file mode 100644 index 0000000000000000000000000000000000000000..ff80562528b4eaaf84cd0653924fc36f3c95a34b --- /dev/null +++ b/application/http/middleware/AccessInAppCheck.php @@ -0,0 +1,53 @@ +header('user-agent'))) + { + $request->in_app = 'weixin'; + + // 是否支付宝 + } else if (preg_match('~alipay~i', $request->header('user-agent'))) + { + $request->in_app = 'alipay'; + + // 默认app + } else { + $request->in_app = 'app'; + } + + return $next($request); + } +} +?> \ No newline at end of file diff --git a/application/service/OtherService.php b/application/http/middleware/SystemEnvCheck.php similarity index 60% rename from application/service/OtherService.php rename to application/http/middleware/SystemEnvCheck.php index 3d2ce47bed7876a97a881bcbbf2c143e9b6e5513..420cd19c9730c6493476502cbbe661f3e56472d3 100644 --- a/application/service/OtherService.php +++ b/application/http/middleware/SystemEnvCheck.php @@ -8,17 +8,40 @@ // +---------------------------------------------------------------------- // | Author: Devil // +---------------------------------------------------------------------- -namespace app\service; +namespace app\http\middleware; /** - * 其它处理服务层 + * 系统环境检查 * @author Devil * @blog http://gong.gg/ * @version 0.0.1 * @datetime 2016-12-01T21:51:08+0800 */ -class OtherService +class SystemEnvCheck { + /** + * 入口 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2019-01-16 + * @desc description + * @param [object] $request [请求对象] + * @param \Closure $next [闭包] + * @return [object] [请求对象] + */ + public function handle($request, \Closure $next) + { + // 环境检查 + $ret = $this->EnvironmentCheck(); + if($ret['code'] != 0) + { + exit(json_encode($ret)); + } + + return $next($request); + } + /** * 环境校验 * @author Devil @@ -27,13 +50,14 @@ class OtherService * @date 2018-12-07 * @desc description */ - public static function EnvironmentCheck() + public function EnvironmentCheck() { if(IS_AJAX) { // 请求参数数量校验是否超出php.ini限制 $max_input_vars = intval(ini_get('max_input_vars'))-5; - if(count(input('post.')) >= $max_input_vars) + $params_counbt = count(input('post.')); + if($params_counbt >= $max_input_vars) { return DataReturn('请求参数数量已超出php.ini限制[max_input_vars]', -1000); } diff --git a/application/index/controller/Common.php b/application/index/controller/Common.php index d88d17d893c7de92fd5620953408b63b4a7dea61..bf575f593269ec824ba6813e711db3983fd20603 100755 --- a/application/index/controller/Common.php +++ b/application/index/controller/Common.php @@ -18,7 +18,6 @@ use app\service\MessageService; use app\service\SearchService; use app\service\ConfigService; use app\service\LinkService; -use app\service\OtherService; /** * 前端公共控制器 @@ -65,27 +64,6 @@ 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)); - } } /** diff --git a/application/middleware.php b/application/middleware.php new file mode 100644 index 0000000000000000000000000000000000000000..227c61516a0631e4030dbdb839c2ec53b6b20a6f --- /dev/null +++ b/application/middleware.php @@ -0,0 +1,20 @@ + \ No newline at end of file