IPIP.php 477 B

12345678910111213141516171819202122232425262728
  1. <?php
  2. namespace App\Components;
  3. use ipip\db\Reader;
  4. class IPIP
  5. {
  6. /**
  7. * 查询IP地址的详细信息
  8. *
  9. * @param string $ip IPv4
  10. *
  11. * @return \ipip\db\Info|null
  12. * @throws \Exception
  13. */
  14. public function ip($ip)
  15. {
  16. $filePath = storage_path('ipip.ipdb');
  17. $db = new Reader($filePath);
  18. //$loc = $db->find($ip);
  19. //$loc = $db->findMap($ip);
  20. $loc = $db->findInfo($ip);
  21. return $loc;
  22. }
  23. }