From c661cc7c467676bb9f2430037cebbe1d800a96bd Mon Sep 17 00:00:00 2001 From: thinkphp Date: Thu, 16 Nov 2017 17:45:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9B=E6=97=A5=E5=BF=97=E8=AE=B0?= =?UTF-8?q?=E5=BD=95=E7=9A=84ip=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Request.php | 2 +- library/think/log/driver/File.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/library/think/Request.php b/library/think/Request.php index 9d215bb5..1124700d 100644 --- a/library/think/Request.php +++ b/library/think/Request.php @@ -1265,7 +1265,7 @@ class Request * @param boolean $adv 是否进行高级模式获取(有可能被伪装) * @return mixed */ - public function ip($type = 0, $adv = false) + public function ip($type = 0, $adv = true) { $type = $type ? 1 : 0; static $ip = null; diff --git a/library/think/log/driver/File.php b/library/think/log/driver/File.php index f3abc3d7..236e21bd 100644 --- a/library/think/log/driver/File.php +++ b/library/think/log/driver/File.php @@ -12,6 +12,7 @@ namespace think\log\driver; use think\App; +use think\Request; /** * 本地化调试输出到文件 @@ -108,11 +109,10 @@ class File $message = '[ info ] ' . $current_uri . $time_str . $memory_str . $file_load . "\r\n" . $message; } $now = date($this->config['time_format']); - $server = isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : '0.0.0.0'; - $remote = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '0.0.0.0'; + $ip = Request::instance()->ip(); $method = isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : 'CLI'; $uri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : ''; - $message = "---------------------------------------------------------------\r\n[{$now}] {$server} {$remote} {$method} {$uri}\r\n" . $message; + $message = "---------------------------------------------------------------\r\n[{$now}] {$ip} {$method} {$uri}\r\n" . $message; $this->writed[$destination] = true; }