You've already forked EasyImages2.0
mirror of
https://github.com/icret/EasyImages2.0.git
synced 2025-12-16 11:53:58 +08:00
v2.8.4
This commit is contained in:
@@ -20,7 +20,7 @@ class Ip2Region
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
class_exists('XdbSearcher') || include(__DIR__ . '/XdbSearcher.php');
|
||||
class_exists('XdbSearcher') or include __DIR__ . '/XdbSearcher.php';
|
||||
$this->searcher = XdbSearcher::newWithFileOnly(__DIR__ . '/ip2region.xdb');
|
||||
}
|
||||
|
||||
@@ -57,6 +57,20 @@ class Ip2Region
|
||||
return $this->memorySearch($ip);
|
||||
}
|
||||
|
||||
/**
|
||||
* 直接查询并返回名称
|
||||
* @param string $ip
|
||||
* @return string
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function simple($ip)
|
||||
{
|
||||
$geo = $this->memorySearch($ip);
|
||||
$arr = explode('|', str_replace(['0|'], '|', isset($geo['region']) ? $geo['region'] : ''));
|
||||
if (($last = array_pop($arr)) === '内网IP') $last = '';
|
||||
return join('', $arr) . (empty($last) ? '' : "[{$last}]");
|
||||
}
|
||||
|
||||
/**
|
||||
* destruct method
|
||||
* resource destroy
|
||||
|
||||
Reference in New Issue
Block a user