From 1a02bb7081f3461844af1bd10383f934c96f0300 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Wed, 25 May 2016 10:29:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3Request=E7=B1=BB=E7=9A=84base?= =?UTF-8?q?Url=E6=96=B9=E6=B3=95=20=E4=BF=AE=E6=AD=A3Hook=E7=B1=BB?= =?UTF-8?q?=E7=9A=84=E8=AD=A6=E5=91=8A=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- base.php | 1 + library/think/App.php | 2 -- library/think/Hook.php | 3 ++- library/think/Request.php | 3 ++- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/base.php b/base.php index c9b54fba..df8eba84 100644 --- a/base.php +++ b/base.php @@ -51,3 +51,4 @@ define('IS_CGI', strpos(PHP_SAPI, 'cgi') === 0 ? 1 : 0); define('IS_CLI', PHP_SAPI == 'cli' ? 1 : 0); define('IS_WIN', strstr(PHP_OS, 'WIN') ? 1 : 0); define('IS_MAC', strstr(PHP_OS, 'Darwin') ? 1 : 0); +define('NOW_TIME', $_SERVER['REQUEST_TIME']); diff --git a/library/think/App.php b/library/think/App.php index 2e7f4247..f58350f6 100644 --- a/library/think/App.php +++ b/library/think/App.php @@ -39,9 +39,7 @@ class App { is_null($request) && $request = Request::instance(); - define('NOW_TIME', $request->time()); define('REQUEST_METHOD', $request->method()); - define('HTTP_HOST', $request->host()); define('IS_GET', REQUEST_METHOD == 'GET' ? true : false); define('IS_POST', REQUEST_METHOD == 'POST' ? true : false); define('IS_PUT', REQUEST_METHOD == 'PUT' ? true : false); diff --git a/library/think/Hook.php b/library/think/Hook.php index 8e6b846c..b789d08a 100644 --- a/library/think/Hook.php +++ b/library/think/Hook.php @@ -43,8 +43,9 @@ class Hook * @param boolean $recursive 是否递归合并 * @return void */ - public static function import(array $tags, $recursive = true) + public static function import($tags, $recursive = true) { + empty($tags) && $tags = []; if (!$recursive) { // 覆盖导入 self::$tags = array_merge(self::$tags, $tags); diff --git a/library/think/Request.php b/library/think/Request.php index a63493fc..c205f970 100644 --- a/library/think/Request.php +++ b/library/think/Request.php @@ -240,7 +240,8 @@ class Request $this->baseUrl = $url; return; } elseif (!$this->baseUrl) { - $this->baseUrl = rtrim($this->url(), '?' . $this->query()); + $str = $this->url(); + $this->baseUrl = strpos($str, '?') ? strstr($str, '?', true) : $str; } return true === $url ? $this->domain() . $this->baseUrl : $this->baseUrl; }