From f8597483d47b226234b7f8cd7ed6dd9a11b0470b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=87=91=E9=BB=8E=E6=98=8E?= Date: Fri, 15 Apr 2016 16:30:13 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86IpLocation=E7=B1=BB?= =?UTF-8?q?=E7=9A=84=E6=9E=84=E9=80=A0=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修改了IpLocation类的构造函数,允许传入的参数是一个文件的绝对路径,如果不是绝对路径,再考虑使用原来的方法在类库的当前文件夹下寻找文件。 --- ThinkPHP/Library/Org/Net/IpLocation.class.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ThinkPHP/Library/Org/Net/IpLocation.class.php b/ThinkPHP/Library/Org/Net/IpLocation.class.php index bf7c70347..8d8562e63 100644 --- a/ThinkPHP/Library/Org/Net/IpLocation.class.php +++ b/ThinkPHP/Library/Org/Net/IpLocation.class.php @@ -54,7 +54,10 @@ class IpLocation public function __construct($filename = "UTFWry.dat") { $this->fp = 0; - if (($this->fp = fopen(dirname(__FILE__) . '/' . $filename, 'rb')) !== false) { + if(!is_file($filename)) { + $filename = dirname(__FILE__) . '/' . $filename; + } + if (($this->fp = fopen($filename, 'rb')) !== false) { $this->firstip = $this->getlong(); $this->lastip = $this->getlong(); $this->totalip = ($this->lastip - $this->firstip) / 7;