From 08a08185a8edee297e6fe0f893671e1d839dfba8 Mon Sep 17 00:00:00 2001 From: fengyunljp Date: Sun, 22 Apr 2018 11:01:33 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20long2ip=20=E5=9C=A8=20PHP7?= =?UTF-8?q?=20=E4=B9=8B=E4=B8=AD=E7=9A=84=E5=85=BC=E5=AE=B9=E6=80=A7?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Access_Core.php | 11 +++++++++++ page/console.php | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Access_Core.php b/Access_Core.php index e66f39a..f83067d 100644 --- a/Access_Core.php +++ b/Access_Core.php @@ -459,5 +459,16 @@ class Access_Core 'meta_id' => $meta_id, ); } + + public function long2ip($long) { + if ($long < 0 || $long > 4294967295) return false; + $ip = ""; + for ($i=3;$i>=0;$i--) { + $ip .= (int)($long / pow(256,$i)); + $long -= (int)($long / pow(256,$i))*pow(256,$i); + if ($i>0) $ip .= "."; + } + return $ip; + } } diff --git a/page/console.php b/page/console.php index 7718a05..df47354 100644 --- a/page/console.php +++ b/page/console.php @@ -96,7 +96,7 @@ $access = new Access_Core(); - filter != 'ip'): ?> [ ? ] + long2ip($log['ip']); ?>filter != 'ip'): ?> [ ? ]