Initial commit
This commit is contained in:
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
/**
|
||||
* IP地址查询
|
||||
*/
|
||||
|
||||
namespace plugin\web\ip;
|
||||
|
||||
use app\Plugin;
|
||||
use Exception;
|
||||
use think\facade\Db;
|
||||
use think\facade\View;
|
||||
|
||||
class App extends Plugin
|
||||
{
|
||||
|
||||
const CACHE_TIME = 172800;
|
||||
|
||||
public function index()
|
||||
{
|
||||
View::assign('myip', real_ip());
|
||||
return $this->view();
|
||||
}
|
||||
|
||||
public function query(){
|
||||
$ip = input('post.ip', null, 'trim');
|
||||
$apitype = input('?post.apitype')?input('post.apitype'):'pconline';
|
||||
if(!$ip || !$apitype) return msg('error','no ip');
|
||||
if(is_numeric($ip)) $ip = long2ip($ip);
|
||||
if(filter_var($ip, FILTER_VALIDATE_IP)){
|
||||
$type = 'ip';
|
||||
}elseif(checkdomain($ip)){
|
||||
$type = 'domain';
|
||||
}else{
|
||||
return msg('error', 'IP或域名格式不正确!');
|
||||
}
|
||||
|
||||
$captcha_result = verify_captcha4();
|
||||
if($captcha_result !== true){
|
||||
return msg('error', '验证失败,请重新验证');
|
||||
}
|
||||
|
||||
if($type == 'domain'){
|
||||
$ip = gethostbyname($ip);
|
||||
if(!$ip || !filter_var($ip, FILTER_VALIDATE_IP)){
|
||||
return msg('error', '未查询到该域名的解析记录');
|
||||
}
|
||||
}
|
||||
$ipnum = bindec(decbin(ip2long($ip)));
|
||||
|
||||
if(self::CACHE_TIME > 0){
|
||||
$cache = Db::name('querycache')->where('type', 'ip')->where('key', $apitype.'-'.$ip)->find();
|
||||
if($cache && time() - strtotime($cache['uptime']) <= self::CACHE_TIME){
|
||||
$array = json_decode($cache['content'], true);
|
||||
return msg('ok','success',['data'=>$array, 'ip'=>$ip, 'ipnum'=>$ipnum, 'type'=>$type]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$classname = 'plugin\\web\\ip\\api\\'.$apitype;
|
||||
if(class_exists($classname)){
|
||||
$instance = new $classname();
|
||||
try{
|
||||
$result = $instance->query($ip);
|
||||
}catch(Exception $e){
|
||||
return msg('error', $e->getMessage());
|
||||
}
|
||||
}else{
|
||||
return msg('error', '该查询接口不存在');
|
||||
}
|
||||
|
||||
if(self::CACHE_TIME > 0 && $apitype != 'chunzhen' && $apitype != 'ip2regoin'){
|
||||
Db::name('querycache')->duplicate([
|
||||
'content' => json_encode($result),
|
||||
'uptime' => date('Y-m-d H:i:s')
|
||||
])->insertGetId([
|
||||
'type' => 'ip',
|
||||
'key' => $apitype.'-'.$ip,
|
||||
'content' => json_encode($result),
|
||||
'uptime' => date('Y-m-d H:i:s')
|
||||
]);
|
||||
}
|
||||
|
||||
return msg('ok','success',['data'=>$result, 'ip'=>$ip, 'ipnum'=>$ipnum, 'type'=>$type]);
|
||||
}
|
||||
|
||||
public function item(){
|
||||
$id = input('post.id');
|
||||
if(!$id) return msg('error','no id');
|
||||
$cache = Db::name('querycache')->where('id', $id)->find();
|
||||
if($cache){
|
||||
$array = json_decode($cache['content'], true);
|
||||
return msg('ok','success',$array);
|
||||
}else{
|
||||
return msg('error','记录不存在');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\web\ip;
|
||||
|
||||
interface api
|
||||
{
|
||||
public function query($ip);
|
||||
}
|
||||
@@ -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('接口查询失败,返回结果错误');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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('接口查询失败,返回结果错误');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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('接口查询失败,返回结果错误');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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数据');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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('&',' ',$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('接口查询失败,返回结果错误');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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数据');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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('接口查询失败,返回结果错误');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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('接口查询失败,返回结果错误');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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('接口查询失败,返回结果错误');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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('接口查询失败,返回结果错误');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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']);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,233 @@
|
||||
{extend name="common/plugin_layout" /}
|
||||
{block name="title"}{$plugin.title} - {:config_get('title')}{/block}
|
||||
{block name="main"}
|
||||
<style>
|
||||
.query-title {
|
||||
text-align: right;
|
||||
}
|
||||
</style>
|
||||
<div class="container-xl" id="app">
|
||||
<div class="col-sm-12 col-md-10 col-xl-8 center-block">
|
||||
<div class="card card-preview">
|
||||
<div class="card-inner mt-3">
|
||||
<div class="nya-title nk-ibx-action-item progress-rating">
|
||||
<span class="nk-menu-text font-weight-bold">IP地址查询</span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="form-label">IP地址/域名:</label><div class="float-right">我的IP:<a href="javascript:" @click="query_my" id="myip">{$myip}</a></div>
|
||||
<div class="form-control-wrap">
|
||||
<input type="text" v-model="input" placeholder="请输入IP地址或域名" class="form-control form-control-lg" @keyup.enter="query" ref="input" autocomplete="off">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="input">选择查询接口:</label>
|
||||
<div class="form-control-wrap">
|
||||
<div class="custom-control custom-radio mr-3 mt-1" v-for="(item,index) in apitypes" :key="index">
|
||||
<input type="radio" class="custom-control-input" v-model="apitype" name="apitype" :id="item.key" :value="item.key">
|
||||
<label class="custom-control-label" :for="item.key">{{item.title}}</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<button class="btn btn-dim btn-outline-primary btn-block card-link mb-3" @click="query" :disabled="query_disabled">
|
||||
查询
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card card-preview" v-show="showresult" style="display:none">
|
||||
<div class="card-inner mt-3">
|
||||
<div class="nya-title nk-ibx-action-item progress-rating">
|
||||
<span class="nk-menu-text font-weight-bold">查询结果</span>
|
||||
</div>
|
||||
<h6>{{result_type}} <span class="text-primary">{{result_input}}</span> 的信息:</h6>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover table-bordered">
|
||||
<tbody>
|
||||
<tr><td class="query-title">IP地址</td><td>{{result_info.ip}}</td></tr>
|
||||
<tr><td class="query-title">数字地址</td><td>{{result_info.ipnum}}</td></tr>
|
||||
<tr v-for="(item,index) in result_info.data"><td class="query-title">{{index}}</td><td>{{item}}</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card card-preview">
|
||||
<div class="card-inner">
|
||||
<h6><em class="icon ni ni-info"></em> 简介</h6>
|
||||
<div class="accordion-inner">
|
||||
IP138:查询准确性<span class="text-danger">极高</span>,部分精确到县,速度快,含运营商<span class="text-success">(支持IPv6)</span><br/>
|
||||
高德地图:查询准确性<span class="text-danger">极高</span>,部分精确到县,速度快,含运营商、经纬度<span class="text-success">(支持IPv6)</span><br/>
|
||||
腾讯地图:宽带IP的查询准确性<span class="text-danger">较高</span>,部分精确到县,IDC的IP不准确,速度快<span class="text-success">(支持IPv6)</span><br/>
|
||||
太平洋电脑网:查询准确性<span class="text-danger">较高</span>,速度快,含运营商<span class="text-success">(支持IPv6)</span><br/>
|
||||
IPIP:查询准确性<span class="text-danger">极高</span>,速度快,含运营商、AS号<span class="text-success">(支持IPv6)</span><br/>
|
||||
IP-API:国外IP查询准确性<span class="text-danger">较高</span>,国外接口延迟高,含运营商、AS号<span class="text-success">(支持IPv6)</span><br/>
|
||||
宝塔:查询准确性<span class="text-danger">较高</span>,部分精确到县,速度快,含运营商、经纬度<br/>
|
||||
淘宝:查询准确性<span class="text-danger">一般</span>,速度较快,有调用频率限制,含运营商<br/>
|
||||
纯真:本地IP数据库,查询准确性<span class="text-danger">一般</span>,速度最快,含运营商<br/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/block}
|
||||
{block name="script"}
|
||||
<script src="{$cdn_cdnjs}vue/2.6.14/vue.min.js"></script>
|
||||
<script src="{$cdn_cdnjs}jquery-cookie/1.4.1/jquery.cookie.min.js"></script>
|
||||
<script src="https://static.geetest.com/v4/gt4.js"></script>
|
||||
<script>
|
||||
new Vue({
|
||||
el: '#app',
|
||||
data: {
|
||||
query_disabled: true,
|
||||
input: '',
|
||||
apitype: 'amap',
|
||||
result_input: '',
|
||||
result_type: 'IP',
|
||||
showresult: false,
|
||||
apitypes: [
|
||||
{
|
||||
title: '高德地图',
|
||||
key: 'amap'
|
||||
},
|
||||
{
|
||||
title: 'IP138',
|
||||
key: 'ip138'
|
||||
},
|
||||
{
|
||||
title: '腾讯地图',
|
||||
key: 'tencent'
|
||||
},
|
||||
{
|
||||
title: '太平洋',
|
||||
key: 'pconline'
|
||||
},
|
||||
{
|
||||
title: 'IPIP',
|
||||
key: 'ipip'
|
||||
},
|
||||
{
|
||||
title: 'IP-API',
|
||||
key: 'ipapi'
|
||||
},
|
||||
{
|
||||
title: '宝塔',
|
||||
key: 'baota'
|
||||
},
|
||||
{
|
||||
title: '淘宝',
|
||||
key: 'taobao'
|
||||
},
|
||||
{
|
||||
title: '百度',
|
||||
key: 'baidu'
|
||||
},
|
||||
{
|
||||
title: '纯真',
|
||||
key: 'chunzhen'
|
||||
},
|
||||
],
|
||||
result_info: {
|
||||
ip: '',
|
||||
ipnum: '',
|
||||
data: [],
|
||||
},
|
||||
captcha: null
|
||||
},
|
||||
watch: {
|
||||
'apitype'(newVal) {
|
||||
$.cookie('ip_apitype',newVal)
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.$refs.input.focus();
|
||||
if($.cookie('ip_apitype')){
|
||||
this.apitype = $.cookie('ip_apitype')
|
||||
}
|
||||
var that=this;
|
||||
initGeetest4({
|
||||
captchaId: "99b142aaece96330d0f3ffb565ffb3ef",
|
||||
product: 'bind',
|
||||
protocol: 'https://',
|
||||
riskType: 'ai',
|
||||
},function (captcha) {
|
||||
captcha.onReady(function(){
|
||||
that.query_disabled=false;
|
||||
that.captcha = captcha;
|
||||
var searchip = getQueryString('ip');
|
||||
if(searchip!=null){
|
||||
that.input = searchip;
|
||||
that.query()
|
||||
}
|
||||
}).onSuccess(function(){
|
||||
var result = captcha.getValidate();
|
||||
if (!result) {
|
||||
layer.closeAll();
|
||||
return alert('请先完成验证');
|
||||
}
|
||||
var data = {ip: that.input, apitype: that.apitype};
|
||||
$.ajax({
|
||||
url: '/api/{$plugin.alias}/query',
|
||||
type: 'post',
|
||||
dataType: 'json',
|
||||
data: Object.assign(data, result),
|
||||
cache: false,
|
||||
success: function (data) {
|
||||
layer.closeAll();
|
||||
if(data.status=='ok'){
|
||||
that.result_type = data.data.type == 'domain' ? '域名' : 'IP'
|
||||
that.result_input = that.input;
|
||||
that.showresult = true;
|
||||
that.result_info = data.data;
|
||||
captcha.reset();
|
||||
}else{
|
||||
alert(data.message);
|
||||
captcha.reset();
|
||||
}
|
||||
},
|
||||
error: function () {
|
||||
layer.closeAll();
|
||||
layer.msg('服务器错误', {icon: 5});
|
||||
captcha.reset();
|
||||
}
|
||||
});
|
||||
}).onError(function(){
|
||||
alert('验证码加载失败,请刷新页面重试');
|
||||
})
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
checkURL()
|
||||
{
|
||||
var url = this.input.trim();
|
||||
if (url.indexOf(" ")>=0){
|
||||
url = url.replace(/ /g,"");
|
||||
}
|
||||
if (url.toLowerCase().indexOf("http://")==0){
|
||||
url = url.slice(7);
|
||||
}
|
||||
if (url.toLowerCase().indexOf("https://")==0){
|
||||
url = url.slice(8);
|
||||
}
|
||||
if (url.slice(url.length-1)=="/"){
|
||||
url = url.slice(0,url.length-1);
|
||||
}
|
||||
this.input = url;
|
||||
},
|
||||
query() {
|
||||
this.checkURL();
|
||||
if(this.input == ''){
|
||||
alert('查询内容不能为空');return;
|
||||
}
|
||||
layer.load(0, {shade:0.1});
|
||||
this.captcha.showCaptcha();
|
||||
},
|
||||
query_my() {
|
||||
var myip = $("#myip").text();
|
||||
if(myip == '') return;
|
||||
this.input = myip;
|
||||
layer.load(0, {shade:0.1});
|
||||
this.captcha.showCaptcha();
|
||||
}
|
||||
},
|
||||
})
|
||||
</script>
|
||||
{/block}
|
||||
Reference in New Issue
Block a user