IPIP.php 324 B

123456789101112131415161718192021
  1. <?php
  2. namespace App\Components;
  3. use ipip\db\City;
  4. class IPIP {
  5. /**
  6. * 查询IP地址的详细信息
  7. *
  8. * @param string $ip IPv4
  9. *
  10. * @return array|null
  11. */
  12. public static function ip($ip): ?array {
  13. $filePath = public_path('ipip.ipdb');
  14. $loc = new City($filePath);
  15. return $loc->findMap($ip, 'CN');
  16. }
  17. }