首页 > php教程 > PHP源码 > 正文

PHP 执行 whois 操作的代码

PHP中文网
发布: 2016-06-01 14:33:16
原创
1391人浏览过

要获取指定ip地址的whois数据,可使用如下代码

<?php
/**
    Program to perform ip whois
    Silver Moon
    m00n.silv3r@gmail.com
*/
 
$ip = "74.65.112.23";
 
$whois = get_whois($ip);
 
echo "<pre class="brush:php;toolbar:false;">$whois
登录后复制
";   /**     Get the whois content of an ip by selecting the correct server */ function get_whois($ip) {     $w = get_whois_from_server('whois.iana.org' , $ip);       preg_match('@whois\.[\w\.]*@si' , $w , $data);       $whois_server = $data[0];       //echo $whois_server;       //now get actual whois data     $whois_data = get_whois_from_server($whois_server , $ip);       return $whois_data; }   /**     Get the whois result from a whois server     return text */ function get_whois_from_server($server , $ip) {     $data = '';       #Before connecting lets check whether server alive or not       #Create the socket and connect     $f = fsockopen($server, 43, $errno, $errstr, 3);    //Open a new connection     if(!$f)     {         return '';     }       #Set the timeout limit for read     if(!stream_set_timeout($f , 3))     {         die('Unable to set set_timeout');   #Did this solve the problem ?     }       #Send the IP to the whois server     if($f)     {         fputs($f, "$ip\r\n");     }       /*         Theory : stream_set_timeout must be set after a write and before a read for it to take effect on the read operation         If it is set before the write then it will have no effect : http://in.php.net/stream_set_timeout     */       //Set the timeout limit for read     if(!stream_set_timeout($f , 3))     {         die('Unable to stream_set_timeout');    #Did this solve the problem ?     }       //Set socket in non-blocking mode     stream_set_blocking ($f, 0 );       //If connection still valid     if($f)     {         while (!feof($f))         {             $data .= fread($f , 128);         }     }       //Now return the data     return $data; }

执行结果

MVM mall 网上购物系统
MVM mall 网上购物系统

采用 php+mysql 数据库方式运行的强大网上商店系统,执行效率高速度快,支持多语言,模板和代码分离,轻松创建属于自己的个性化用户界面 v3.5更新: 1).进一步静态化了活动商品. 2).提供了一些重要UFT-8转换文件 3).修复了除了网银在线支付其它支付显示错误的问题. 4).修改了LOGO广告管理,增加LOGO链接后主页LOGO路径错误的问题 5).修改了公告无法发布的问题,可能是打压

MVM mall 网上购物系统 0
查看详情 MVM mall 网上购物系统
#
# Query terms are ambiguous.  The query is assumed to be:
#     "n 74.65.112.23"
#
# Use "?" to get help.
#
 
#
# The following results may also be obtained via:
# http://whois.arin.net/rest/nets;q=74.65.112.23?showDetails=true&showARIN=false&ext=netref2
#
 
NetRange:       74.64.0.0 - 74.79.255.255
CIDR:           74.64.0.0/12
OriginAS:
NetName:        RRNY
NetHandle:      NET-74-64-0-0-1
Parent:         NET-74-0-0-0-0
NetType:        Direct Allocation
RegDate:        2006-03-27
Updated:        2007-01-29
Ref:            http://whois.arin.net/rest/net/NET-74-64-0-0-1
 
OrgName:        Road Runner HoldCo LLC
OrgId:          RRNY
Address:        13820 Sunrise Valley Drive
City:           Herndon
StateProv:      VA
PostalCode:     20171
Country:        US
RegDate:        2000-09-28
Updated:        2011-07-06
Comment:        Allocations for this OrgID serve Road Runner residential customers out of the New York City, NY and Syracuse, NY RDCs.
Ref:            http://whois.arin.net/rest/org/RRNY
 
ReferralServer: rwhois://ipmt.rr.com:4321
 
OrgTechHandle: IPTEC-ARIN
OrgTechName:   IP Tech
OrgTechPhone:  +1-703-345-3416
OrgTechEmail:  abuse@rr.com
OrgTechRef:    http://whois.arin.net/rest/poc/IPTEC-ARIN
 
OrgAbuseHandle: ABUSE10-ARIN
OrgAbuseName:   Abuse
OrgAbusePhone:  +1-703-345-3416
OrgAbuseEmail:  abuse@rr.com
OrgAbuseRef:    http://whois.arin.net/rest/poc/ABUSE10-ARIN
 
#
# ARIN WHOIS data and services are subject to the Terms of Use
# available at: https://www.arin.net/whois_tou.html
#
登录后复制
相关标签:
php
PHP速学教程(入门到精通)
PHP速学教程(入门到精通)

PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
作者最新文章
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号