Initial commit

This commit is contained in:
net909
2023-09-28 16:21:06 +08:00
parent 498772eb04
commit ba7be004c0
640 changed files with 87745 additions and 0 deletions
+36
View File
@@ -0,0 +1,36 @@
<?php
namespace plugin\web\ip\api;
use Exception;
use plugin\web\ip\api;
/**
* {"status":"1","info":"OK","infocode":"10000","province":"北京市","city":"北京市","adcode":"110000","rectangle":"116.0119343,39.66127144;116.7829835,40.2164962"}
*/
class amap implements api
{
public function query($ip){
$type = '4';
if(filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)){
$type = '6';
}
$url = 'https://restapi.amap.com/v5/ip?key=0113a13c88697dcea6a445584d535837&type='.$type.'&ip='.$ip;
$data = get_curl($url);
$arr = json_decode($data, true);
if (isset($arr['status']) && $arr['status']=='1') {
if(empty($arr['country'])){
throw new Exception('接口查询失败:该IP信息不存在');
}
$address = $arr['country'].(isset($arr['province'])&&$arr['province']!=$arr['country']?$arr['province']:'').(isset($arr['city'])?$arr['city']:'').(isset($arr['district'])?$arr['district']:'');
$result['IP所在地'] = $address;
if(isset($arr['isp'])) $result['运营商'] = $arr['isp'];
if(isset($arr['location']) && $arr['location']!='null,null') $result['经纬度'] = $arr['location'];
return $result;
}elseif (isset($arr['info'])) {
throw new Exception('接口查询失败:'.$arr['info']);
}else{
throw new Exception('接口查询失败,返回结果错误');
}
}
}
+24
View File
@@ -0,0 +1,24 @@
<?php
namespace plugin\web\ip\api;
use Exception;
use plugin\web\ip\api;
/**
* {"status":"0","t":"","set_cache_time":"","data":[{"ExtendedLocation":"","OriginQuery":"113.97.33.248","appinfo":"","disp_type":0,"fetchkey":"113.97.33.248","location":"广东省深圳市 电信","origip":"113.97.33.248","origipquery":"113.97.33.248","resourceid":"6006","role_id":0,"shareImage":1,"showLikeShare":1,"showlamp":"1","titlecont":"IP地址查询","tplt":"ip"}]}
*/
class baidu implements api
{
public function query($ip){
$url = 'https://sp0.baidu.com/8aQDcjqpAAV3otqbppnN2DJv/api.php?query='.$ip.'&resource_id=6006&ie=utf8&format=json';
$data = get_curl($url);
$data = mb_convert_encoding($data, 'UTF-8', 'GBK');
$arr = json_decode($data, true);
if (isset($arr['data']) && count($arr['data'])>0) {
return ['IP所在地'=>$arr['data'][0]['location']];
}else{
throw new Exception('接口查询失败,返回结果错误');
}
}
}
+23
View File
@@ -0,0 +1,23 @@
<?php
namespace plugin\web\ip\api;
use Exception;
use plugin\web\ip\api;
/**
* {"113.97.33.248":{"continent":"亚洲","country":"中国","province":"广东","city":"深圳","region":"南山","carrier":"电信","division":"440305","en_country":"China","en_short_code":"CN","longitude":"113.93029","latitude":"22.53291"}}
*/
class baota implements api
{
public function query($ip){
$url = 'https://www.bt.cn/api/panel/get_ip_info?ip='.$ip;
$data = get_curl($url);
$arr = json_decode($data, true);
if (isset($arr[$ip])) {
return ['IP所在地'=>$arr[$ip]['country'].''.$arr[$ip]['province'].''.$arr[$ip]['city'].''.$arr[$ip]['region'], 'ISP运营商'=>$arr[$ip]['carrier'], '经纬度'=>$arr[$ip]['longitude'].','.$arr[$ip]['latitude']];
}else{
throw new Exception('接口查询失败,返回结果错误');
}
}
}
+22
View File
@@ -0,0 +1,22 @@
<?php
namespace plugin\web\ip\api;
use Exception;
use plugin\web\ip\api;
/**
* {"ip":"113.97.33.248","beginip":"113.97.17.0","endip":"113.97.81.255","country":"\u5e7f\u4e1c\u7701\u6df1\u5733\u5e02","area":"\u7535\u4fe1","province":"\u5e7f\u4e1c\u7701","city":"\u6df1\u5733\u5e02"}
*/
class chunzhen implements api
{
public function query($ip){
$new = new \app\lib\IpLocation();
$arr = $new->getlocation($ip);
if($arr){
return ['IP所在地'=>$arr['province'].$arr['city'], '运营商'=>$arr['area']];
}else{
throw new Exception('查无此IP数据');
}
}
}
+68
View File
@@ -0,0 +1,68 @@
<?php
namespace plugin\web\ip\api;
use Exception;
use plugin\web\ip\api;
/**
* {"status":"success","country":"加拿大","countryCode":"CA","region":"QC","regionName":"Quebec","city":"蒙特利尔","zip":"H1K","lat":45.6085,"lon":-73.5493,"timezone":"America/Toronto","isp":"Le Groupe Videotron Ltee","org":"Videotron Ltee","as":"AS5769 Videotron Telecom Ltee","query":"24.48.0.1"}
*/
class ip138 implements api
{
public function query($ip){
if(filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)){
return $this->query_ipv6($ip);
}
//return $this->query_chinaz($ip);
$url = 'https://m.ip138.com/iplookup.asp?ip='.$ip.'&action=2';
$data = get_curl($url);
preg_match('!<td class="th">ASN归属地</td><td>(.*?)</td>!', $data, $match);
if (isset($match[1])) {
return ['IP所在地'=>$match[1]];
}else{
throw new Exception('接口查询失败,返回结果错误');
}
}
public function query_chinaz($ip){
$url = 'http://mip.chinaz.com/?query='.$ip;
$data = get_curl($url);
if(strpos($data,'错误的IP地址')){
throw new Exception('错误的IP地址');
}
$data = getSubstr($data, '<td class="bg-3fa z-tc ww-5">物理地址</td>', '</td>');
$data = getSubstr($data, '<td class="z-tc">', '<br />');
$data = trim(str_replace('&amp;',' ',$data));
if ($data) {
return ['IP所在地'=>$data];
}else{
throw new Exception('接口查询失败,返回结果错误');
}
}
public function query_ipv6($ip){
$url = 'http://ip.zxinc.org/api.php?type=json&ip='.$ip;
$data = get_curl($url);
$arr = json_decode($data, true);
if (isset($arr['code']) && $arr['code']==0) {
return ['IP所在地'=>$arr['data']['location']];
}else{
throw new Exception('接口查询失败,返回结果错误');
}
}
public function query_api($ip){
$url = 'http://api.ip138.com/ip/?ip='.$ip;
$header = ['token: c10d9edc249963398634d009413758f4'];
$data = get_curl($url,0,0,0,0,0,0,$header);
$arr = json_decode($data, true);
if (isset($arr['ret']) && $arr['ret']=='ok') {
return ['IP所在地'=>$arr['data'][0].$arr['data'][1].$arr['data'][2].$arr['data'][3].' '.$arr['data'][4]];
}elseif (isset($arr['msg'])) {
throw new Exception('接口查询失败:'.$arr['msg']);
}else{
throw new Exception('接口查询失败,返回结果错误');
}
}
}
+26
View File
@@ -0,0 +1,26 @@
<?php
namespace plugin\web\ip\api;
use Exception;
use plugin\web\ip\api;
/**
* {"ip":"113.97.33.248","beginip":"113.97.17.0","endip":"113.97.81.255","country":"\u5e7f\u4e1c\u7701\u6df1\u5733\u5e02","area":"\u7535\u4fe1","province":"\u5e7f\u4e1c\u7701","city":"\u6df1\u5733\u5e02"}
*/
class ip2regoin implements api
{
public function query($ip){
$new = new \app\lib\Ip2Region();
$region = $new->search($ip);
if($region){
$region = explode('|',$region);
return [
'IP所在地'=>($region[1]?$region[1]:'').($region[2]?$region[2]:'').($region[3]?$region[3]:'').($region[4]?$region[4]:''),
'运营商'=>($region[11]?$region[11]:''),
];
}else{
throw new Exception('查无此IP数据');
}
}
}
+25
View File
@@ -0,0 +1,25 @@
<?php
namespace plugin\web\ip\api;
use Exception;
use plugin\web\ip\api;
/**
* {"status":"success","country":"加拿大","countryCode":"CA","region":"QC","regionName":"Quebec","city":"蒙特利尔","zip":"H1K","lat":45.6085,"lon":-73.5493,"timezone":"America/Toronto","isp":"Le Groupe Videotron Ltee","org":"Videotron Ltee","as":"AS5769 Videotron Telecom Ltee","query":"24.48.0.1"}
*/
class ipapi implements api
{
public function query($ip){
$url = 'http://ip-api.com/json/'.$ip.'?lang=zh-CN';
$data = get_curl($url);
$arr = json_decode($data, true);
if (isset($arr['status']) && $arr['status']=='success') {
return ['IP所在地'=>$arr['country'].' '.$arr['regionName'].' '.$arr['city'], 'AS编号'=>$arr['as'], 'ISP运营商'=>$arr['isp'], '当地时区'=>$arr['timezone']];
}elseif (isset($arr['message'])) {
throw new Exception('接口查询失败:'.$arr['message']);
}else{
throw new Exception('接口查询失败,返回结果错误');
}
}
}
+23
View File
@@ -0,0 +1,23 @@
<?php
namespace plugin\web\ip\api;
use Exception;
use plugin\web\ip\api;
/**
* {"ret":0,"data":{"country_code":"CN","country":"\u4e2d\u56fd","province":"\u5e7f\u4e1c","city":"\u6df1\u5733","isp":"chinatelecom.com.cn","asn":["AS4134 - CHINANET-BACKBONE - No.31,Jin-rong Street, CN"],"ports":[],"ip":"113.97.33.248"},"dns":[{"country_code":"CN","country":"\u4e2d\u56fd","province":"\u5e7f\u4e1c","city":"\u6df1\u5733","isp":"chinatelecom.com.cn","asn":["AS4134 - CHINANET-BACKBONE - No.31,Jin-rong Street, CN"],"ports":[],"ip":"113.97.33.248"}]}
*/
class ipip implements api
{
public function query($ip){
$url = 'https://clientapi.ipip.net/browser/chrome?ip='.$ip.'&l=zh-CN';
$data = get_curl($url);
$arr = json_decode($data, true);
if (isset($arr['ret']) && $arr['ret']==0) {
return ['IP所在地'=>$arr['data']['country'].''.$arr['data']['province'].''.$arr['data']['city'], 'ISP运营商'=>$arr['data']['isp'], 'AS编号'=>$arr['data']['asn'][0]];
}else{
throw new Exception('接口查询失败,返回结果错误');
}
}
}
+24
View File
@@ -0,0 +1,24 @@
<?php
namespace plugin\web\ip\api;
use Exception;
use plugin\web\ip\api;
/**
* {"ip":"218.89.171.143","pro":"四川省","proCode":"510000","city":"成都市","cityCode":"510100","region":"","regionCode":"0","addr":"四川省成都市 电信","regionNames":"","err":""}
*/
class pconline implements api
{
public function query($ip){
$url = 'http://whois.pconline.com.cn/ipJson.jsp?json=true&ip='.$ip;
$data = get_curl($url);
$data = mb_convert_encoding($data, "UTF-8", "GB2312");
$arr = json_decode($data, true);
if (isset($arr['addr'])) {
return ['IP所在地'=>$arr['addr']];
}else{
throw new Exception('接口查询失败,返回结果错误');
}
}
}
+26
View File
@@ -0,0 +1,26 @@
<?php
namespace plugin\web\ip\api;
use Exception;
use plugin\web\ip\api;
/**
* {"data":{"area":"","country":"中国","isp_id":"100017","queryIp":"113.97.33.248","city":"深圳","ip":"113.97.33.248","isp":"电信","county":"","region_id":"440000","area_id":"","county_id":null,"region":"广东","country_id":"CN","city_id":"440300"},"msg":"query success","code":0}
*/
class taobao implements api
{
public function query($ip){
$url = 'https://ip.taobao.com/outGetIpInfo';
$post = 'ip='.$ip.'&accessKey=alibaba-inc';
$data = get_curl($url, $post, 'https://ip.taobao.com/ipSearch');
$arr = json_decode($data, true);
if (isset($arr['code']) && $arr['code']==0) {
return ['IP所在地'=>$arr['data']['country'].$arr['data']['region'].$arr['data']['city'], '运营商'=>$arr['data']['isp']];
}elseif (isset($arr['msg'])) {
throw new Exception('接口查询失败:'.$arr['msg']);
}else{
throw new Exception('接口查询失败,返回结果错误');
}
}
}
+27
View File
@@ -0,0 +1,27 @@
<?php
namespace plugin\web\ip\api;
use Exception;
use plugin\web\ip\api;
/**
* {"status":0,"message":"Success","request_id":"345c35a0-97d5-4965-8950-5c4643a28bec","result":{"ip":"113.97.33.248","location":{"lat":22.53332,"lng":113.93041},"ad_info":{"nation":"中国","province":"广东省","city":"深圳市","district":"南山区","adcode":440305}}}
*/
class tencent implements api
{
public function query($ip){
$key = 'HOFBZ-A4AK6-BQGSI-ES7F6-HCBN2-SNFQF';
$url = 'https://apis.map.qq.com/ws/location/v1/ip?ip='.$ip.'&key='.$key;
$data = get_curl($url);
$arr = json_decode($data,true);
if(isset($arr['status']) && $arr['status']==0){
$result['code']=0;
$location = $arr['result']['location']['lng'].','.$arr['result']['location']['lat'];
$address = $arr['result']['ad_info']['nation'].$arr['result']['ad_info']['province'].$arr['result']['ad_info']['city'].$arr['result']['ad_info']['district'];
return ['IP所在地'=>$address, '经纬度'=>$location];
}else{
throw new Exception('接口查询失败:'.$arr['message']);
}
}
}