diff --git a/assets/js/main.js b/assets/js/main.js index 4c1ed2a..340b26e 100644 --- a/assets/js/main.js +++ b/assets/js/main.js @@ -20,6 +20,9 @@ $(document).ready(function() { errorIP(); } }); + $("#output").dblclick(function() { + getVersion(); + }); }); $(document).keydown(function(event) { @@ -41,7 +44,6 @@ function getInfo() { $("button").text("Search"); $("table").show(1000); $("#ip").text(data.ip); - data.as = (data.as == null) ? "Unknow" : data.as; data.city = (data.city == null) ? "Unknow" : data.city; data.region = (data.region == null) ? "Unknow" : data.region; data.country = (data.country == null) ? "Unknow" : data.country; @@ -49,7 +51,6 @@ function getInfo() { data.isp = (data.isp == null) ? "Unknow" : data.isp; data.scope = (data.scope == null) ? "Unknow" : data.scope; data.detail = (data.detail == null || data.detail == ' ') ? "Unknow" : data.detail; - $("#as").text(data.as); $("#city").text(data.city); $("#region").text(data.region); $("#country").text(data.country); @@ -57,17 +58,37 @@ function getInfo() { $("#isp").text(data.isp); $("#scope").text(data.scope); $("#detail").text(data.detail); + if (data.as == null) { + $("#as").text("Unknow"); + } else { + $("#as").text(data.as); + var asUri = "https://bgpview.io/asn/" + data.as.substr(2); + $("#as").html('' + data.as + ''); + } if (data.loc == null) { $("#loc").text("Unknow"); clear(); } else { var earthUri = "https://earth.google.com/web/@" + data.loc + ",0a,398836d,1y,0h,0t,0r"; - $("#loc").html('' + data.loc + ''); + $("#loc").html('' + data.loc + ''); draw(parseFloat(data.loc.split(',')[0]), parseFloat(data.loc.split(',')[1])); } }); } +function getVersion() { + $.get("/version", function(data) { + console.log(data); + data.qqwry = data.qqwry.slice(0, 4) + "-" + data.qqwry.slice(4, 6) + "-" + data.qqwry.slice(6, 8); + data.ipip = data.ipip.slice(0, 4) + "-" + data.ipip.slice(4, 6) + "-" + data.ipip.slice(6, 8); + var data_ver = ""; + data_ver += "echoIP: " + data.echoip + "\n"; + data_ver += "纯真数据库: " + data.qqwry + "\n"; + data_ver += "IPIP.net数据库: " + data.ipip; + alert(data_ver); + }); +} + function trim(str) { return str.replace(/(^\s*)|(\s*$)/g, ""); } diff --git a/assets/js/main.min.js b/assets/js/main.min.js index ce2e05e..326a585 100644 --- a/assets/js/main.min.js +++ b/assets/js/main.min.js @@ -1 +1 @@ -function getInfo(){$.get("/info/"+$("input").val(),(function(data){if(console.log(data),"F"!=data.status)if($("input").val()||$("input").val(data.ip),$("button").text("Search"),$("table").show(1e3),$("#ip").text(data.ip),data.as=null==data.as?"Unknow":data.as,data.city=null==data.city?"Unknow":data.city,data.region=null==data.region?"Unknow":data.region,data.country=null==data.country?"Unknow":data.country,data.timezone=null==data.timezone?"Unknow":data.timezone,data.isp=null==data.isp?"Unknow":data.isp,data.scope=null==data.scope?"Unknow":data.scope,data.detail=null==data.detail||" "==data.detail?"Unknow":data.detail,$("#as").text(data.as),$("#city").text(data.city),$("#region").text(data.region),$("#country").text(data.country),$("#timezone").text(data.timezone),$("#isp").text(data.isp),$("#scope").text(data.scope),$("#detail").text(data.detail),null==data.loc)$("#loc").text("Unknow"),clear();else{var earthUri="https://earth.google.com/web/@"+data.loc+",0a,398836d,1y,0h,0t,0r";$("#loc").html(''+data.loc+""),draw(parseFloat(data.loc.split(",")[0]),parseFloat(data.loc.split(",")[1]))}else errorIP()}))}function trim(str){return str.replace(/(^\s*)|(\s*$)/g,"")}function errorIP(){$("button").text("Illegal IP"),$("button").css({"border-color":"#ff406f","background-color":"#ff406f"}),$("input").focus()}function checkIP(ipStr){if(null===ipStr)return"error";var regIPv4=/^((25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(25[0-5]|2[0-4]\d|[01]?\d\d?)$/,regIPv6=/^((([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:)|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}(:[0-9A-Fa-f]{1,4}){1,2})|(([0-9A-Fa-f]{1,4}:){4}(:[0-9A-Fa-f]{1,4}){1,3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IPv4),V6=ipStr.match(regIPv6);return null===V4&&null===V6?"error":"ok"}function getQuery(name){var reg=new RegExp("(^|&)"+name+"=([^&]*)(&|$)"),result=window.location.search.substr(1).match(reg);return null!=result?unescape(result[2]):null}function clear(){var map;new mapboxgl.Map({container:"map",style:"mapbox://styles/mapbox/streets-v11",center:[0,0],zoom:1}).on("load",(function(){console.log("reset map")}))}function draw(x,y){var map=new mapboxgl.Map({container:"map",style:"mapbox://styles/mapbox/streets-v11",center:[y,x],zoom:3}),size=100,pulsingDot={width:100,height:100,data:new Uint8Array(4e4),onAdd:function(){var canvas=document.createElement("canvas");canvas.width=this.width,canvas.height=this.height,this.context=canvas.getContext("2d")},render:function(){var duration=1e3,t=performance.now()%1e3/1e3,radius=15,outerRadius=35*t+15,context=this.context;return context.clearRect(0,0,this.width,this.height),context.beginPath(),context.arc(this.width/2,this.height/2,outerRadius,0,2*Math.PI),context.fillStyle="rgba(255, 200, 200,"+(1-t)+")",context.fill(),context.beginPath(),context.arc(this.width/2,this.height/2,15,0,2*Math.PI),context.fillStyle="rgba(255, 100, 100, 1)",context.strokeStyle="white",context.lineWidth=2+4*(1-t),context.fill(),context.stroke(),this.data=context.getImageData(0,0,this.width,this.height).data,map.triggerRepaint(),!0}};map.on("load",(function(){map.addImage("pulsing-dot",pulsingDot,{pixelRatio:2}),map.addLayer({id:"points",type:"symbol",source:{type:"geojson",data:{type:"FeatureCollection",features:[{type:"Feature",geometry:{type:"Point",coordinates:[y,x]}}]}},layout:{"icon-image":"pulsing-dot"}})}))}$(document).ready((function(){null===getQuery("ip")?getInfo():($("input").val(getQuery("ip")),getInfo()),$("table").hide(),$("button").click((function(){$("button").css({"border-color":"","background-color":""}),$("button").text("Searching..."),$("table").hide(1e3),$("input").val(trim($("input").val())),""==$("input").val()||"ok"==checkIP($("input").val())?getInfo():errorIP()}))})),$(document).keydown((function(event){13==event.keyCode&&$("button").focus()})),mapboxgl.accessToken="pk.eyJ1Ijoic2hldm9ua3VhbiIsImEiOiJja20yMjlnNDYybGg2Mm5zNW40eTNnNnUwIn0.6xj6sgjWvdQgT_7OQUy_Jg"; \ No newline at end of file +function getInfo(){$.get("/info/"+$("input").val(),(function(data){if(console.log(data),"F"!=data.status){if($("input").val()||$("input").val(data.ip),$("button").text("Search"),$("table").show(1e3),$("#ip").text(data.ip),data.city=null==data.city?"Unknow":data.city,data.region=null==data.region?"Unknow":data.region,data.country=null==data.country?"Unknow":data.country,data.timezone=null==data.timezone?"Unknow":data.timezone,data.isp=null==data.isp?"Unknow":data.isp,data.scope=null==data.scope?"Unknow":data.scope,data.detail=null==data.detail||" "==data.detail?"Unknow":data.detail,$("#city").text(data.city),$("#region").text(data.region),$("#country").text(data.country),$("#timezone").text(data.timezone),$("#isp").text(data.isp),$("#scope").text(data.scope),$("#detail").text(data.detail),null==data.as)$("#as").text("Unknow");else{$("#as").text(data.as);var asUri="https://bgpview.io/asn/"+data.as.substr(2);$("#as").html(''+data.as+"")}if(null==data.loc)$("#loc").text("Unknow"),clear();else{var earthUri="https://earth.google.com/web/@"+data.loc+",0a,398836d,1y,0h,0t,0r";$("#loc").html(''+data.loc+""),draw(parseFloat(data.loc.split(",")[0]),parseFloat(data.loc.split(",")[1]))}}else errorIP()}))}function getVersion(){$.get("/version",(function(data){console.log(data),data.qqwry=data.qqwry.slice(0,4)+"-"+data.qqwry.slice(4,6)+"-"+data.qqwry.slice(6,8),data.ipip=data.ipip.slice(0,4)+"-"+data.ipip.slice(4,6)+"-"+data.ipip.slice(6,8);var data_ver="";data_ver+="echoIP: "+data.echoip+"\n",data_ver+="纯真数据库: "+data.qqwry+"\n",data_ver+="IPIP.net数据库: "+data.ipip,alert(data_ver)}))}function trim(str){return str.replace(/(^\s*)|(\s*$)/g,"")}function errorIP(){$("button").text("Illegal IP"),$("button").css({"border-color":"#ff406f","background-color":"#ff406f"}),$("input").focus()}function checkIP(ipStr){if(null===ipStr)return"error";var regIPv4=/^((25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(25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}:(:[0-9A-Fa-f]{1,4}){0,4}:(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3})|(:(:[0-9A-Fa-f]{1,4}){0,5}:(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3}))$/,V4=ipStr.match(regIPv4),V6=ipStr.match(regIPv6);return null===V4&&null===V6?"error":"ok"}function getQuery(name){var reg=new RegExp("(^|&)"+name+"=([^&]*)(&|$)"),result=window.location.search.substr(1).match(reg);return null!=result?unescape(result[2]):null}function clear(){var map;new mapboxgl.Map({container:"map",style:"mapbox://styles/mapbox/streets-v11",center:[0,0],zoom:1}).on("load",(function(){console.log("reset map")}))}function draw(x,y){var map=new mapboxgl.Map({container:"map",style:"mapbox://styles/mapbox/streets-v11",center:[y,x],zoom:3}),size=100,pulsingDot={width:100,height:100,data:new Uint8Array(4e4),onAdd:function(){var canvas=document.createElement("canvas");canvas.width=this.width,canvas.height=this.height,this.context=canvas.getContext("2d")},render:function(){var duration=1e3,t=performance.now()%1e3/1e3,radius=15,outerRadius=35*t+15,context=this.context;return context.clearRect(0,0,this.width,this.height),context.beginPath(),context.arc(this.width/2,this.height/2,outerRadius,0,2*Math.PI),context.fillStyle="rgba(255, 200, 200,"+(1-t)+")",context.fill(),context.beginPath(),context.arc(this.width/2,this.height/2,15,0,2*Math.PI),context.fillStyle="rgba(255, 100, 100, 1)",context.strokeStyle="white",context.lineWidth=2+4*(1-t),context.fill(),context.stroke(),this.data=context.getImageData(0,0,this.width,this.height).data,map.triggerRepaint(),!0}};map.on("load",(function(){map.addImage("pulsing-dot",pulsingDot,{pixelRatio:2}),map.addLayer({id:"points",type:"symbol",source:{type:"geojson",data:{type:"FeatureCollection",features:[{type:"Feature",geometry:{type:"Point",coordinates:[y,x]}}]}},layout:{"icon-image":"pulsing-dot"}})}))}$(document).ready((function(){null===getQuery("ip")?getInfo():($("input").val(getQuery("ip")),getInfo()),$("table").hide(),$("button").click((function(){$("button").css({"border-color":"","background-color":""}),$("button").text("Searching..."),$("table").hide(1e3),$("input").val(trim($("input").val())),""==$("input").val()||"ok"==checkIP($("input").val())?getInfo():errorIP()})),$("#output").dblclick((function(){getVersion()}))})),$(document).keydown((function(event){13==event.keyCode&&$("button").focus()})),mapboxgl.accessToken="pk.eyJ1Ijoic2hldm9ua3VhbiIsImEiOiJja20yMjlnNDYybGg2Mm5zNW40eTNnNnUwIn0.6xj6sgjWvdQgT_7OQUy_Jg"; \ No newline at end of file diff --git a/backend/queryInfo.php b/backend/queryInfo.php index f9c5a21..5298e9e 100644 --- a/backend/queryInfo.php +++ b/backend/queryInfo.php @@ -165,8 +165,8 @@ function getVersion() { // 获取自身及数据库版本号 $version['echoip'] = $myVersion; $qqwry = new QQWry('qqwry.dat'); $IPIP = new IPDB('ipipfree.ipdb'); - $version['qqwry.dat'] = $qqwry->getVersion(); - $version['ipip.net'] = $IPIP->getVersion(); + $version['qqwry'] = $qqwry->getVersion(); + $version['ipip'] = $IPIP->getVersion(); return $version; } @@ -195,8 +195,8 @@ function routeParam() { $version = getVersion(); if ($_GET['cli'] == "true") { // 命令行模式 echo "echoip -> " . $version['echoip'] . PHP_EOL; - echo "qqwry.dat -> " . formatDate($version['qqwry.dat']) . PHP_EOL; - echo "ipip.net -> " . formatDate($version['ipip.net']) . PHP_EOL; + echo "qqwry.dat -> " . formatDate($version['qqwry']) . PHP_EOL; + echo "ipip.net -> " . formatDate($version['ipip']) . PHP_EOL; } else { header('Content-Type: application/json; charset=utf-8'); echo json_encode($version); // 返回JSON数据 diff --git a/index.html b/index.html index 7601f66..eb095fd 100644 --- a/index.html +++ b/index.html @@ -9,9 +9,6 @@ - - - @@ -23,13 +20,19 @@ padding: 0; } - #loc { + .table { + color: #282828; + } + + #loc a, + #as a { text-decoration: none; - color: #363636; + color: #282828; transition: all 0.6s; } - #loc:hover { + #loc a:hover, + #as a:hover { color: #2d87ee; } @@ -45,20 +48,18 @@ display: none !important; } - #sub-title { + #title { margin-top: 0px; margin-bottom: 20px; } - #sub-title, - a { + #title a { text-decoration: none; color: #555; transition: all 0.6s; } - #sub-title, - a:hover { + #title a:hover { color: #5165db; } @@ -94,7 +95,7 @@
-

+

echoIP