From 3126a6d02d3d56e1beeb597352aafcdcead877f4 Mon Sep 17 00:00:00 2001 From: huangdijia Date: Fri, 4 Dec 2015 13:40:24 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B7=AF=E7=94=B1=E4=BC=98=E5=8C=96=20?= =?UTF-8?q?=E6=94=AF=E6=8C=81[=E6=A8=A1=E5=9D=97/=E6=8E=A7=E5=88=B6?= =?UTF-8?q?=E5=99=A8/=E6=93=8D=E4=BD=9C/=E5=8F=82=E6=95=B01/=E5=80=BC1/?= =?UTF-8?q?=E5=8F=82=E6=95=B02/=E5=80=BC2...]=E8=B7=AF=E7=94=B1=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/app.php | 10 ++++++---- library/think/route.php | 11 +++++++++-- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/library/think/app.php b/library/think/app.php index 316b1558..56a6e7f0 100644 --- a/library/think/app.php +++ b/library/think/app.php @@ -266,25 +266,27 @@ class App // URL后缀 define('__EXT__', strtolower(pathinfo($_SERVER['PATH_INFO'], PATHINFO_EXTENSION))); $_SERVER['PATH_INFO'] = __INFO__; - if (__INFO__ && !defined('BIND_MODULE')) { + if (__INFO__) { if ($config['url_deny_suffix'] && preg_match('/\.(' . $config['url_deny_suffix'] . ')$/i', __INFO__)) { throw new Exception('URL_SUFFIX_DENY'); } + // 还原劫持后真实pathinfo + $path_info = (defined('BIND_MODULE')?BIND_MODULE.'/':'') . (defined('BIND_CONTROLLER')?BIND_CONTROLLER.'/':'') . (defined('BIND_ACTION')?BIND_ACTION.'/':'') . __INFO__; // 路由检测 if (!empty($config['url_route_on'])) { // 开启路由 则检测路由配置 Route::register($config['route']); - $result = Route::check(__INFO__, $config['pathinfo_depr']); + $result = Route::check($path_info, $config['pathinfo_depr']); if (false === $result) { // 路由无效 if ($config['url_route_must']) { throw new Exception('route not define '); } else { - $result = Route::parseUrl(__INFO__); + $result = Route::parseUrl($path_info); } } } else { - $result = Route::parseUrl(__INFO__); + $result = Route::parseUrl($path_info); } } // 去除URL后缀 diff --git a/library/think/route.php b/library/think/route.php index c755b175..ec586cf0 100644 --- a/library/think/route.php +++ b/library/think/route.php @@ -435,20 +435,27 @@ class Route if (false !== strpos($url, '?')) { // [控制器/操作?]参数1=值1&参数2=值2... $info = parse_url($url); - $path = explode('/', $info['path']); + $path = explode('/', $info['path'], 4); parse_str($info['query'], $var); } elseif (strpos($url, '/')) { // [控制器/操作] - $path = explode('/', $url); + $path = explode('/', $url, 4); } else { // 参数1=值1&参数2=值2... parse_str($url, $var); } if (isset($path)) { + $param = []; + if(!empty($path[3])) $param = explode('/', array_pop($path)); + // 解析[模块/控制器/操作] $action = array_pop($path); $action = '[rest]' == $action ? REQUEST_METHOD : $action; $controller = !empty($path) ? array_pop($path) : null; $module = !empty($path) ? array_pop($path) : null; + // 解析path额外的参数 + for ($i=0; $i [$module, $controller, $action], 'var' => $var]; }