查询IP的PHP程序开源

2021-07-14 14:38:00 浏览数 (1)

简述

这个程序是想简单一点可以查询到 IP 以及物理地址的工具,但是它有很大的进步空间 自适应程序 就拿来做成了程序,非常轻盈 完整打包 : 4Kb 完全不用担心请求会让服务器负载大

开始

下载地址 Github,Tooc网盘(推荐) 密码:yf4a7p

代码 index.php

代码语言:javascript复制
<?php
    error_reporting(0);

    $yuMingPhp = $_GET['yuMingPhp'];
    if ($yuMingPhp != '域名 / IP / 地址') {
        // 开始获取数据
        $Result = file_get_contents("http://ip-api.com/json/" .$yuMingPhp);
        $resultJson = json_decode($Result);

        // var_dump($resultJson);
    }
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>站长工具 - by XLJ</title>

    <style>
        * {
            margin: 0;
            padding: 0;
        }
        
        html,body {
            height: 100%;
        }

        body {
            font-size: 20px;
        }
    </style>

    <!-- 引入外部文件 -->
    <link rel="stylesheet" href="css/main.css">
</head>
<body> <!-- 警告!: 源码由XLJ独立开发,并无其他人参与开发,严谨二次开发不备注原作者 源码基于开源协议MIT2.0发布 这条信息禁止删除 --> 
    <div id="Container">
        <span id="xieYi">hello</span>
        <div id="Main">
            <form action="./index.php" method="GET">
                <input type="text" value="域名 / IP / 地址" id="yuMing" name="yuMingPhp">
                <button id="souSuo" type="submit"><svg style="width: 50px; height: 50px;" t="1618623657023" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="612" width="200" height="200"><path d="M350.814815 797.392593c-5.499259 0-10.903704-2.085926-15.075556-6.257778l-113.777778-113.777778c-8.343704-8.343704-8.343704-21.807407 0-30.151111l0.18963-0.18963 113.588148-113.588148c8.343704-8.343704 21.807407-8.343704 30.151111 0s8.343704 21.807407 0 30.151111L267.188148 662.281481l98.702222 98.702223c8.343704 8.343704 8.343704 21.807407 0 30.151111-4.171852 4.171852-9.576296 6.257778-15.075555 6.257778z" p-id="613" fill="#d81e06"></path><path d="M604.728889 683.614815h-367.881482c-11.757037 0-21.333333-9.576296-21.333333-21.333334s9.576296-21.333333 21.333333-21.333333h367.881482c71.86963 0 130.37037-58.500741 130.37037-130.37037v-208.592593c0-11.757037 9.576296-21.333333 21.333334-21.333333s21.333333 9.576296 21.333333 21.333333v208.592593c0 46.08-18.014815 89.505185-50.820741 122.216296C694.139259 665.6 650.714074 683.614815 604.728889 683.614815z" p-id="614" fill="#d81e06"></path></svg></button>
                <input type="submit" value="查询" id="souSuoShouJi">
            </form>
        </div>
        <div id="shuJuMain">
            <div id="shuJuMainDiv">
                <span id="zhuangTaiShow">状态</span>
                <span id="zhuangTai"><?php if ($resultJson->status == 'success') {echo "成功";} ?></span>
                <br>
                <span id="ipShow">IP</span>
                <span id="Ip"><?php echo $resultJson->query ?></span>
                <br>
                <span id="guoJiaShow">国家</span>
                <span id="guoJia"><?php echo $resultJson->country ?></span>
                <br>
                <span id="guoJiaSuoXieShow">国家缩写</span>
                <span id="guoJiaSuoXie"><?php echo $resultJson->countryCode; ?></span>
                <br>
                <span id="shengFenShow">省份</span>
                <span id="shengFen"><?php echo $resultJson->regionName; ?></span>
                <br>
                <span id="chengShiShow">城市</span>
                <span id="chengShi"><?php echo $resultJson->city; ?></span>
            </div>
        </div>

        <footer id="Footer">
            ©版权 by <a href="https://xlj0.com">XLJ</a>
        </footer>
    </div>

    <script src="js/main.js"></script>
</body>
</html>

main.css

代码语言:javascript复制
@media screen and (min-width: 900px) {
    div#Container {
        height: 100%;
        text-align: center;
        position: relative;
    }
    
    div#Main {
        position: absolute;
        top: 50%;
        margin-top: -204px;
        left: 50%;
        margin-left: -235px;
        z-index: 2;
    
        /* display: none; */
    }
    
    input#yuMing {
        background-color: none;
        border: none;
        height: 40px;
        display: inline-block;
        font-size: 22px;
        width: 400px;
        padding: 4px 10px;
        outline: none;
        border: 1px solid #eeeeee;
        border-top-left-radius: 4px;
        border-bottom-left-radius: 4px;
    }
    
    button#souSuo {
        background: none;
        border: none;
        display: inline-block;
        width: 50px;
        height: 50px;
    
        position: absolute;
        top: 50%;
        margin-top: -25px;
        background-color: #eeeeee;
    
        border-top-right-radius: 4px;
        border-bottom-right-radius: 4px;
    
        transition: all 100ms linear;
    }
    button#souSuo:hover {
        background-color: #dddddd;
    
        transition: all 100ms linear;
    }
    
    span#xieYi {
        background-color: #ff7777;
        color: #ffffff;
        padding: 2px 4px;
        position: absolute;
        top: 50%;
        margin-top: -230px;
        left: 50%;
        margin-left: -200px;
        cursor: pointer;
        user-select: none;
        width: 3em;
    
        /* display: none; */
    }
    
    div#shuJuMain {
        width: 100%;
        height: 100%;
        display: inline-block;
        background-color: #000000;
    }
    div#shuJuMainDiv {
        margin-top: 30%;
    }
    div#shuJuMainDiv span {
        color: #ffffff;
        cursor: pointer;
        padding: 4px 8px;
        display: inline-block;
        
        transition: all 100ms linear;
    }
    div#shuJuMainDiv span:hover {
        background-color: #575757;
        
        transition: all 100ms linear;
    }
    
    span#zhuangTai {
        color: #ffc4c4 !important;
    }
    span#Ip {
        color: #ffc4c4 !important;
    }
    span#guoJia {
        color: #ffc4c4 !important;
    }
    span#guoJiaSuoXie {
        color: #ffc4c4 !important;
    }
    span#shengFen {
        color: #ffc4c4 !important;
    }
    span#chengShi {
        color: #ffc4c4 !important;
    }

    /* 底部版权 */
    footer#Footer {
        color: #ffffff;
        background-color: #000000;
        padding-bottom: 20px;
    }

    footer#Footer a {
        color: #ffffff;
    }
}

@media screen and (max-width: 900px) {
    div#shuJuMain {

    }

    div#Main {
        width: 100%;
        display: inline-block;
    }
    
    input#yuMing {
        background: none;
        border: none;
        outline: none;
        width: 100%;
        margin-top: 5%;
        display: inline-block;
        font-size: 20px;
        text-align: center;
        background-color: #eeeeee;
        height: 2.5em;
    }
    
    button#souSuo {
        display: none;
    }
    button#souSuo:hover {
        
    }

    input#souSuoShouJi {
        background: none;
        border: none;
        font-size: 22px;
        display: inline-block;
        width: 100%;
        margin: 4px 0;
    }
    
    span#xieYi {
        display: none;
    }
    
    div#shuJuMain {
        
    }
    div#shuJuMainDiv {
        margin: 10px;
        background-color: #000000;
        color: #ffffff;
        padding: 10px;
    }
    div#shuJuMainDiv span {
        transition: all 100ms linear;
    }
    div#shuJuMainDiv span:hover {
        background-color: #3a3a3a;
        transition: all 100ms linear;
    }
    
    span#zhuangTai {
        
    }
    span#Ip {
        
    }
    span#guoJia {
        
    }
    span#guoJiaSuoXie {
        
    }
    span#shengFen {
        
    }
    span#chengShi {
        
    }

    /* 底部版权 */
    footer#Footer {
        color: #353535;
        display: block;
        text-align: center;
    }

    footer#Footer a {
        color: #ffa1a1;
    }
}

main.js

代码语言:javascript复制
// 版权声明,开发者 : XLJ(喜樂君)
// 基于开源协议可以进行非商业,二次开发,发布等... 禁止删除这个版权信息,如果需要商用请联系 xlj@xlj0.com
// 如果你想去除版权信息,请联系 xlj@xlj0.com

var yuMing = document.getElementById('yuMing');
var souSuo = document.getElementById('souSuo');
var xieYi = document.getElementById('xieYi');
// ---------- 

// 自定义函数
var consoleLog = function (infoOne, infoTwo) {
    console.log(infoOne, infoTwo);
}

// 版权
consoleLog('版权信息 开发者 : %c XLJ(喜樂君)', 'color: #ff0000;');
consoleLog('基于开源协议可以进行非商业,二次开发,发布等... 禁止删除这个版权信息,如果需要商用请联系 %c xlj@xlj0.com', 'color: #ff0000;');
consoleLog('禁止使用程序违法!否则法律责任自行承担,后果自负,违法包括但不限于(钓鱼,恶意跳转...等等)');
// 点击搜索框清空提示内容
yuMing.onfocus = function () {
    if (yuMing.value == '域名 / IP / 地址') {
        yuMing.value = null;
        consoleLog('Info : ', '聚焦成功,已经清空编辑框')
    } else {
        // 
    }
}
yuMing.onblur = function () {
    if (yuMing.value == '') {
        yuMing.value = '域名 / IP / 地址';
        consoleLog('Info : ', '聚焦取消,已经恢复内容')
    } else {
        // 
    }
}

// 点击查询按钮如果没有输入内容
souSuo.onclick = function () {

    if (yuMing.value == '域名 / IP / 地址') {
        alert('请输入要查询的内容');
    } else {

    }
}

// 点击复制功能
// document.getElementById('zhuangTaiShow').style.display = 'none';
document.getElementById('zhuangTai').onclick = function () {
    var zhuangTaiInfo = document.getElementById('zhuangTai').innerHTML;
    zhuangTaiInfo.select();
    document.execCommand('Copy');
    consoleLog('复制成功');
}
    
// document.getElementById('ipShow').style.display = 'none';
document.getElementById('Ip').onclick = function () {
    document.execCommand(document.getElementById('Ip').value);
}
    
// document.getElementById('guoJiaSuoXieShow').style.display = 'none';
document.getElementById('guoJiaSuoXie').onclick = function () {
    document.execCommand();
}
    
// document.getElementById('shengFenShow').style.display = 'none';
document.getElementById('shengFen').onclick = function () {
    document.execCommand();
}
    
// document.getElementById('chengShiShow').style.display = 'none';
document.getElementById('chengShi').onclick = function () {
    document.execCommand();
}

// 切换协议按钮 点击事件
// xieYi.onclick = function () {

//     var yuMingString = yuMing.value.toString();

//     if (yuMingString.substr(0, 7) == 'http://') {
//         // yuMing.value = 'https://'
//         xieYi.innerHTML = 'http';
//         consoleLog('协议更改为 https');
//     } else if (yuMingString.substr(0, 8) == 'https://') {
//         // yuMing.value = 'http://'
//         xieYi.innerHTML = 'https';
//         consoleLog('协议更改为 http');
//     }
// }

预览

0 人点赞