zoukankan      html  css  js  c++  java
  • php查询ip地址来源归属地的脚本

     1 <?php
     2     header('Content-Type:text/html;charset=utf-8');
     3     
     4     if($_GET['sub']){
     5         $ip = $_GET['ip'];
     6         $msg = '';
     7         ipSearch();
     8     }
     9     
    10     function ipSearch(){
    11         global $ip,$msg;
    12         if(!$ip){
    13             $msg = '请至少填写一个ip!';
    14             return;
    15         }
    16         $arises = substr_count($ip,'.');
    17         $long = ip2long($ip);
    18         if($arises != 3 || $long == false || $long== -1){
    19             $msg = '无效ip地址,请重新输入!';
    20             return;
    21         }
    22         $content = file_get_contents('http://www.ip138.com/ips1388.asp?action=2&ip='.$ip);
    23         $content = iconv('gb2312', 'utf-8', $content);
    24         $pos = stripos($content, '<li>本站主数据');
    25         if(!$pos){
    26             $msg = '没有查询到!';
    27             return;
    28         }
    29         $endPos = stripos($content, '</li>', $pos);
    30         $jumpLen = strlen('<li>本站主数据:');
    31         $address = substr($content, $pos+$jumpLen, $endPos-$pos-$jumpLen);
    32         $msg = $address;
    33         return;
    34     }
    35     
    36 ?><!DOCTYPE html>
    37 <html>
    38 <head>
    39     <meta charset="utf-8">
    40     <title>test</title>
    41 </head>
    42 <body>
    43     <form method="get">
    44         <input type="text" name="ip" />
    45         <input type="submit" value="search" name="sub" />
    46     </form><br />
    47     <?php echo $msg; ?>
    48 </body>
    49 </html>
  • 相关阅读:
    HTTP request smuggling
    Do you really know CSS linear-gradients?
    Populating the page: how browsers work
    船舶智能管理系统API文档
    DocGuarder
    BUC LNB 器件
    BUC 与 LNB 的区别
    EIRP G/T 的意义
    语音的频率、频率分辨率、采样频率、采样点数、量化、增益
    机械波、电磁波的异同
  • 原文地址:https://www.cnblogs.com/chenyanger/p/3682934.html
Copyright © 2011-2022 走看看