From b106f99c9158e13f34c965b65083644e7a92c959 Mon Sep 17 00:00:00 2001 From: augushong Date: Wed, 28 Jun 2023 11:23:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96IP=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/model/PostVisit.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/app/model/PostVisit.php b/app/model/PostVisit.php index 8a470ec..614c6b5 100644 --- a/app/model/PostVisit.php +++ b/app/model/PostVisit.php @@ -1,9 +1,10 @@ getAttr('avatar'); - if(empty($value)) { + if (empty($value)) { $value = '/static/images/avatar.png'; } @@ -28,8 +29,16 @@ class PostVisit extends Model { $value = $this->getAttr('nickname'); - if(empty($value)) { - $value = 'IP用户:'.$this->getAttr('ip'); + if (empty($value)) { + $current_ip = Request::ip(); + + $ip = $this->getAttr('ip'); + + if ($current_ip == $ip) { + $value = '您的IP:' . $ip; + } else { + $value = 'IP用户:' . $ip; + } } return $value;