选择显示字体大小

whois类的修改版。


   1、简化了代码。(其实就是去掉了一些用不着的变量的定义)
2、针对从internic检索到的信息过于简单,根据internic反馈的信息中的whois server进行进一步查询。比如,yahoo在whois.networksolutions.com上有更详细的信息。

<?
class whois {  

var &#36;use_cache = 1;  
var &#36;from_cache=0;  
var &#36;cache_dir = &quot;./&quot;;            // 根据你的系统自己设置

var &#36;port = 43;  
var &#36;maxlen = 100;  

// 如果你想在连接失败后自动重试,
// 设置重试次数 &#36;max_retries
var &#36;max_retries = 0;  
var &#36;sleep_val = 1;  
var &#36;retry = 0;  

var &#36;found = 0;                // 查询没有结果,次值为0
var &#36;error = 0;                // 查询过程中的出错次数
var &#36;data_min = 8;             // 我们至少应该获得8个字节的数据
var &#36;data_count = 0;  

var &#36;whois_server;
var &#36;new_whois;
var &#36;further_info = 0;


// 打开和whois server的socket连接
// 默认的是 whois.internic.net
function connect (&#36;server) {
    &#36;this->retry=0;
        while(&#36;this->retry <= &#36;this->max_retries):
                &#36;ptr = fsockopen(&#36;server, &#36;this->port);  
                if(&#36;ptr>0):  
                        &#36;this->error=0; // just in case we&#39;re on a retry  
                        return(&#36;ptr);  
                else:  
                        &#36;this->error++;  
                        &#36;this->retry++;  
                        sleep(&#36;this->sleep_val);  
                endif;  
        endwhile;  
        }  

// 获取简单的查询结果,并以行为单位,放入数组
// 国际域名查询
function rawlookup (&#36;query, &#36;server) {
    
    if(!&#36;query):  
            return( &quot;&quot;);  
    endif;

    &#36;ptr=&#36;this->connect(&#36;server);
    
    if(&#36;ptr):  
            if(!ereg(&#36;query, &quot;\n&#36;&quot;)):  
                    &#36;query .= &quot;\n&quot;;  
            endif;  
            fputs(&#36;ptr, &quot;&#36;query&quot;);  
            &#36;i=0;  
            &#36;this->found=1;  
            while(!feof(&#36;ptr)):  
                    &#36;array[&#36;i]=fgets(&#36;ptr,&#36;this->maxlen);  
                    &#36;this->data_count+=strlen(chop(&#36;array[&#36;i]));  
                    if(eregi( &quot;no match for&quot;, &#36;array[&#36;i]) eregi (&quot;no entries found&quot;, &#36;array[&#36;i])):  
                            &#36;this->found=0;  
                     elseif(eregi( &quot;whois database is down&quot;,&#36;array[&#36;i])):  
                            &#36;this->error++;  
                             &#36;this->found=0;  
                     elseif(eregi( &quot;please wait a while and try again&quot;,&#36;array[&#36;i])):  
                            &#36;this->error++;  
                             &#36;this->found=0;  
                            break;  
                    endif;  
                    if(eregi(&quot;whois server:&quot;,&#36;array[&#36;i])):
                        &#36;this->new_whois=trim(substr(trim(&#36;array[&#36;i]),(strlen(trim(&#36;array[&#36;i]))-13)*(-1)));
                        &#36;this->further_info=1;
                    endif;
                    &#36;i++;  
            endwhile;  
    
            fclose(&#36;ptr);  
    
            if(&#36;this->data_count>&#36;this->data_min):
                    return(&#36;array);          
            else:  
                    &#36;this->error++;  
            endif;  
    else:  
            &#36;this->error++;  
    endif;
        }  


// 国内域名查询
function cnrawlookup (&#36;query, &#36;server) {  
        if(!&#36;query):  
                return( &quot;&quot;);  
        endif;  

        &#36;ptr=&#36;this->connect(&#36;server);  
        if(&#36;ptr):  
                if(!ereg(&#36;query, &quot;\n&#36;&quot;)):  
                        &#36;query .= &quot;\n&quot;;  
                endif;  
                fputs(&#36;ptr, &quot;&#36;query&quot;);  
                &#36;i=0;  
                &#36;this->found=1;  
                while(!feof(&#36;ptr)):  
                        &#36;array[&#36;i]=fgets(&#36;ptr,&#36;this->maxlen);  
                        &#36;this->data_count+=strlen(chop(&#36;array[&#36;i]));  
                        if(eregi( &quot;no match for&quot;, &#36;array[&#36;i]) eregi (&quot;no entries found&quot;, &#36;array[&#36;i])):  
                                &#36;this->found=0;  
                         elseif(eregi( &quot;whois database is down&quot;,&#36;array[&#36;i])):  
                                &#36;this->error++;  
                                 &#36;this->found=0;  
                         elseif(eregi( &quot;please wait a while and try again&quot;,&#36;array[&#36;i])):  
                                &#36;this->error++;  
                                 &#36;this->found=0;  
                                break;  
                        endif;  
                        &#36;i++;  
                endwhile;  
                fclose(&#36;ptr);  

                if(&#36;this->data_count>&#36;this->data_min):
                        return(&#36;array);          
                else:  
                        &#36;this->error++;  
                endif;  
        else:  
                &#36;this->error++;  
        endif;  
        }  
};



&#36;mywhois=new whois();

&#36;thisname=&#36;servername.&#36;domainname;
// 根据国内域名或国际域名选择whois server
if (ereg(&quot;.cn&#36;&quot;,&#36;thisname))
{
    &#36;mywhois->whois_server=&quot;whois.cnnic.net.cn&quot;;
    &#36;array=&#36;mywhois->cnrawlookup(&#36;thisname,&#36;mywhois->whois_server);
}
else
{
    &#36;mywhois->whois_server=&quot;whois.internic.net&quot;;
    //&#36;mywhois->whois_server=&quot;whois.networksolutions.com&quot;;
    &#36;array=&#36;mywhois->rawlookup(&#36;thisname,&#36;mywhois->whois_server);
}



echo &quot;<h2 align=center>&quot;.&#36;thisname.&quot;</h2>&quot;;
echo &quot;<table>&quot;;
&#36;x=0;
while (&#36;x<count(&#36;array))
{
    echo &quot;<tr><td>&#36;x</td>&quot;;
    echo &quot;<td>&#36;array[&#36;x]</td>&quot;;
    &#36;x++;
}
echo &quot;</table>&quot;;

if (!ereg(&quot;.cn&#36;&quot;,&#36;thisname))
{
    echo &quot;<h2 align=center>furth infomation</h2>&quot;;
    &#36;array_further=&#36;mywhois->rawlookup(&#36;thisname,&#36;mywhois->new_whois);
    
    echo &quot;<table>&quot;;
    &#36;x=0;
    while (&#36;x<count(&#36;array_further))
    {
        echo &quot;<tr><td>&#36;x</td>&quot;;
        echo &quot;<td>&#36;array_further[&#36;x]</td>&quot;;
        &#36;x++;
    }
    echo &quot;</table>&quot;;
}

?>  


 


关键字 本文所属关键字

相关 与本文相关文章

分类 所有文章关键字导航

源码编程相关

Java   Asp   PHP   .Net   XML   C/C++   CGI   VB   Jsp   J2ee   J2se   J2me   EJB   Servlet   Tomcat   Resin   Struts   Weblogic   Eclipse   ANT   GUI   JMS   Web servise   IDEA   Webphere   Hibernate   Spring   Jboss   Applet   Swing   Socket   Javamail   Perl   Ajax   P2P   安全   模式   框架   测试   开源   游戏

SQL数据库相关

My-SQL   Ms-SQL   Access   DB2   Oracle   Sybase   SQLserver   索引   存储过程   加密   数据库   分页   视图  

手机无线相关

3G   Wap   CDMA   GRPS   GSM   IVR   彩信   短信   无线   增值业务

网页设计制作相关

HTML   CSS   网页配色   网页特效   Javascript   VBscript   Dreamweaver   Frontpage   JS   Web   网站设计

网站建设推广相关

建站经验   网站优化   网站排名   推广   Alexa

操作系统/服务器相关

Windows XP   Windows 2000   Windows 2003   Windows Me   Windows 9.x   Linux   UNIX   注册表   操作系统   服务器   应用服务器

图形图像多媒体相关

Photoshop   Fireworks   Flash   Coreldraw   Illustrator   Freehand   Photoimpact   多媒体   图形图像

标准 网站致力的规范

Valid CSS!

无不良内容,无不良广告,无恶意代码

Valid XHTML 1.0 Transitional

creativecommons