kp_info.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. error_reporting(E_ALL);
  3. date_default_timezone_set('Asia/Shanghai');
  4. ini_set('user_agent', 'Spirit');
  5. require_once 'vendor/autoload.php';
  6. use UAParser\Parser;
  7. $user_online = $_GET['g'];
  8. $or = file_get_contents("https://stevenapis.xyz/api/kp.php?action=p&g=".$user_online ."-dsssss");
  9. $data = json_decode($or,true);
  10. file_put_contents("kp/" .date('mdHis')."-".$user_online.".txt", json_encode($data, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT));
  11. $json = array();
  12. foreach ((array)$data as $user) {
  13. $ip = $user["ip"];
  14. $ua = $user["ua"];
  15. $time = $user["time"];
  16. $parser = Parser::create();
  17. $result = $parser->parse($ua);
  18. $ua = $result->device->brand ." ".$result->device->model . "/" . $result->os->toString();;
  19. // $ua = $result->originalUserAgent;
  20. $file_contents = file_get_contents('http://ip.taobao.com/outGetIpInfo?accessKey=alibaba-inc&ip='.$ip);
  21. $result = json_decode($file_contents,true)["data"];
  22. $ip = preg_replace('~(.*?):(.*?):.*~',"$1:$2:**:****",$ip);
  23. $ip = preg_replace('~(\d+)\.(\d+)\.(\d+)\.(\d+)~',"$1.$2.*.*",$ip);
  24. $addr = $result["country"] != "中国" ? $result["country"]:$result["region"]. ' ' . $result["city"] . ' ' . $result["isp"];
  25. $json[] = array(
  26. "ip" => $ip,
  27. "addr" => $addr,
  28. "ua" => $ua,
  29. "time" => $time
  30. );
  31. }
  32. echo json_encode($json, JSON_PRETTY_PRINT);