fix getip()

This commit is contained in:
xiaomlove
2024-03-01 23:45:13 +08:00
parent 7b70ea9079
commit e653fdac6d
3 changed files with 5 additions and 4 deletions

View File

@@ -98,8 +98,8 @@ class Test extends Command
*/
public function handle()
{
$str = "2023-11-14 02:59:00";
$diff = Carbon::parse($str)->diffInDays(now());
$str = "abc";
$diff = strstr($str, ",", true);
dd($diff);
}

View File

@@ -1,6 +1,6 @@
<?php
defined('VERSION_NUMBER') || define('VERSION_NUMBER', '1.8.9');
defined('RELEASE_DATE') || define('RELEASE_DATE', '2024-02-27');
defined('RELEASE_DATE') || define('RELEASE_DATE', '2024-03-01');
defined('IN_TRACKER') || define('IN_TRACKER', false);
defined('PROJECTNAME') || define("PROJECTNAME","NexusPHP");
defined('NEXUSPHPURL') || define("NEXUSPHPURL","https://nexusphp.org");

View File

@@ -67,7 +67,8 @@ function getip($real = true) {
$ip = getenv('REMOTE_ADDR') ?? '';
}
}
if ($real) {
$ip = trim(trim($ip), ",");
if ($real && str_contains($ip, ",")) {
return strstr($ip, ",", true);
}
return $ip;