• 网络学院
  • IT资讯
  • 操作系统
  • 网络技术
  • 软件应用
  • 办公软件
  • 编程技术
  • 网站架设
  • 数据库类
  • 平面设计
  • 多媒体类
  • 游戏资讯
  • 教学论文
  • 认证考试
PHP
  站点:
  • 首 页
  • 最新软件
  • 文章教程
  • 国内软件
  • 国外软件
  • 绿色软件
  • 源码下载
  • 字体下载
PHP IPwhois类
软件发布 PHP IPwhois类
网络软件 系统工具 应用软件 联络聊天 图形图像 多媒体类 行业软件 游戏娱乐 编程开发 安全相关 教育教学 数码软件 绿软下载
热门软件: QQ 瑞星 pplive e话通 木马克星 千千静听 office2000 五笔字根 Photoshop 视频分割
返回文章教程首页 >> 文章首页 >> 编程技术 >> PHP教程 >> PHP IPwhois类

PHP IPwhois类

添加时间: 2005-6-27 4:45:32  作者: PHP教程收集  阅读次数:135   来源: http://d9soft.com

       

原来写的IPwhois类

 <?php
/*
*
* Class : IP Whois Verson 1.0
* Info : Get IP's information form 4 whois server
* Author : PhpUp Studio
* Date : 12/12/2004
* www.d9soft.com
*
*/
class IPWhois
{
        var $server = 'whois.arin.net';
        var $target;
        var $timeout = 10;
        var $msg;
       
        function IPWhois($target)
        {
                $this->target = $target;       
        }
        function ShowInfo()
        {
                if($this->_CheckIP($this->target))
                {
                        $this->msg = $this->_GetInfo($this->server);
                        if($this->_CheckInfo($this->msg))
                        {
                                $this->msg = $this->_GetInfo($this->server);
                        }
                }
                else $this->msg = '<p>Please Enter An IP Address<br></p>';
               
                return $this->msg;       
        }
        function _CheckIP($temptarget)
        {
                if(eregi("[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}", $temptarget))
                {
                        $f = 1;
                        $detail = explode(".",$temptarget);
                        foreach($detail as $v)
                        {
                                if($v > 255 $v < 0)
                                {
                                        $f = 0;
                                        break;       
                                }       
                        }
                }
                else $f =0;
                return $f;
        }
        function _GetInfo($tempserver)
        {
                $this->msg = '';
               
                if(!$sock = fsockopen($tempserver, 43, $num, $error, $this->timeout))
                {
                        unset($sock);
                        $this->msg = "Timed-out connecting to $tempserver (port 43)";
                }
                else
                {
                        fputs($sock, "$this->target\n");
                        $this->msg .= "<p>IP Whois Information For <b>".$this->target."</b><br><br>";
                        $this->msg .= "-----------------------------------------------------------------<BR>";
                        while (!feof($sock))
                                $this->msg .= fgets($sock, 10240);
                        $this->msg .= "-----------------------------------------------------------------<BR></p>";
                }
                fclose($sock);
                return nl2br($this->msg);        
        }
        function _CheckInfo($tempmsg)
        {
                if(eregi("whois.ripe.net", $tempmsg))
                {
                        $this->server = "whois.ripe.net";
                        return 1;
                }
                elseif(eregi("whois.apnic.net", $tempmsg))
                {
                        $this->server = "whois.apnic.net";
                        return 1;
                }
                elseif(eregi("whois.lacnic.net", $tempmsg))
                {
                        $this->server = "whois.lacnic.net";
                        return 1;
                }
                else return 0;
        }
}
?>

调用

<?php
include './class.php';
$target = isset($_GET['ip'])?gethostbyname($_GET['ip']):'NULL';
if('NULL' == $target '' == $target)$result = '<p>Please Input An IP Address<br></p>';
else
{
        $whois = new IPWhois($target);
        //$result = "IP Whois Information For <b>".$_POST['ip']."</b><br><br>";
        $result = $whois->ShowInfo();
}
echo $result;
?>

 

上下文章:

 

上一篇文章: PHP新手上路(一) 下一篇文章: php+odbc+access数据库操作函数,在windows下测试通过

相关文章:

相关软件:

 

快速导航

  • 网络学院
  • 精品汇聚
  • 字体下载
  • 教程下载
  • ASP源码
  • PHP源码
  • Net源码
  • JSP 源码

编程技术分类导航

  • ASP & ASP.NET教程
  • PHP教程
  • JSP教程
  • C/C++教程
  • VB & VB.NET教程
  • VC教程
  • Delphi教程
  • BCB教程
  • VFP教程
  • PB教程
  • JAVA教程
  • XML教程
  • C#教程
  • CGI教程

本类经典文章推荐

  • VFP程序的五点经验
  • 令你的网站获得任意Google PR值的...
  • PHP和JAVA的XML-RPC中文问题解决办...
  • PHP发现安全漏洞
  • php调用mysql存储过程和函数的方法
  • 用PHP5进行三层开发
  • php与XML、XSLT、Mysql的结合运用...
  • 用GD图库生成横竖柱状图折线图的类
  • 一个全面获取图象信息的函数getIm...
  • PHP入门

PHP教程阅读排行

  • PHP新手上路(一)
  • PHP新手上路(三)
  • PHP新手上路(二)
  • php调用mysql存储过程和函数的方法
  • PHP学习之PHP变量
  • PHP新手上路(四)
  • PHP新手上路(五)
  • PHP新手上路(六)
  • php的header和asp中的redirect比较
  • 在PHP中进行GB2312与UTF-8的互换

编程技术阅读总排行

  • VB入门教程之一
  • Java连接数据库实例
  • 第二章 PowerBuilder 入门之创建新...
  • VC++之List Box/Check List Box控...
  • 第一章 什么是PowerBuilder
  • VC++ List Ctrl控件
  • VC++ Combo Box/Combo Box Ex控件
  • 学C++不得不看的一篇文章
  • VB入门教程之二
  • VC++之Button控件

广告位置

字母检索 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 回到顶部

关于我们 | 版权声明 | 免责条款 | 广告联系 | 软件发布 | 下载帮助 | 下载排行 | 网站地图 | 特别鸣谢 | 友情连接

copyright; 2005-2008 D9soft.com 第九软件网 版权所有