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
+2 -2
View File
@@ -98,8 +98,8 @@ class Test extends Command
*/ */
public function handle() public function handle()
{ {
$str = "2023-11-14 02:59:00"; $str = "abc";
$diff = Carbon::parse($str)->diffInDays(now()); $diff = strstr($str, ",", true);
dd($diff); dd($diff);
} }
+1 -1
View File
@@ -1,6 +1,6 @@
<?php <?php
defined('VERSION_NUMBER') || define('VERSION_NUMBER', '1.8.9'); 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('IN_TRACKER') || define('IN_TRACKER', false);
defined('PROJECTNAME') || define("PROJECTNAME","NexusPHP"); defined('PROJECTNAME') || define("PROJECTNAME","NexusPHP");
defined('NEXUSPHPURL') || define("NEXUSPHPURL","https://nexusphp.org"); defined('NEXUSPHPURL') || define("NEXUSPHPURL","https://nexusphp.org");
+2 -1
View File
@@ -67,7 +67,8 @@ function getip($real = true) {
$ip = getenv('REMOTE_ADDR') ?? ''; $ip = getenv('REMOTE_ADDR') ?? '';
} }
} }
if ($real) { $ip = trim(trim($ip), ",");
if ($real && str_contains($ip, ",")) {
return strstr($ip, ",", true); return strstr($ip, ",", true);
} }
return $ip; return $ip;