mirror of
https://gitee.com/ulthon/ulthon_information.git
synced 2026-03-03 16:24:28 +08:00
优化IP显示
This commit is contained in:
@@ -1,9 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
declare (strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace app\model;
|
namespace app\model;
|
||||||
|
|
||||||
|
use think\facade\Request;
|
||||||
use think\Model;
|
use think\Model;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -17,7 +18,7 @@ class PostVisit extends Model
|
|||||||
{
|
{
|
||||||
$value = $this->getAttr('avatar');
|
$value = $this->getAttr('avatar');
|
||||||
|
|
||||||
if(empty($value)) {
|
if (empty($value)) {
|
||||||
$value = '/static/images/avatar.png';
|
$value = '/static/images/avatar.png';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -28,8 +29,16 @@ class PostVisit extends Model
|
|||||||
{
|
{
|
||||||
$value = $this->getAttr('nickname');
|
$value = $this->getAttr('nickname');
|
||||||
|
|
||||||
if(empty($value)) {
|
if (empty($value)) {
|
||||||
$value = 'IP用户:'.$this->getAttr('ip');
|
$current_ip = Request::ip();
|
||||||
|
|
||||||
|
$ip = $this->getAttr('ip');
|
||||||
|
|
||||||
|
if ($current_ip == $ip) {
|
||||||
|
$value = '您的IP:' . $ip;
|
||||||
|
} else {
|
||||||
|
$value = 'IP用户:' . $ip;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $value;
|
return $value;
|
||||||
|
|||||||
Reference in New Issue
Block a user