<%@ Page Language="C#" ContentType="text/html" ResponseEncoding="gb2312" %>
<html>
<head>
<title>ASP.NET探针</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">
<!--
.jjy {
	font-size: 12px;
	height:1;
	filter:DropShadow(color=#000000,OffX=1,OffY=1,Positive=1);
}
.style5 {font-size: x-small}
-->
</style>
</head>
<body topmargin="0">
<div align="center"><form runat="server">
  <table width="760" height="80" border="1" cellpadding="0" cellspacing="0" bordercolor="#000000" bgcolor="#CCCCCC" style="border-color:Black;border-width:1px;border-style:solid;font-family:Verdana;border-collapse:collapse;">
    <tr>
      <td><div align="center" class="jjy"><font size="+4" face="楷体_GB2312">ASP.NET探针</font></div>        <div align="center">
          </div></td>
      </tr>
  </table>
  <table width="760" border="0" cellpadding="1" cellspacing="1" style="border-color:Black;border-width:1px;border-style:solid;font-family:Verdana;border-collapse:collapse;">
    <tr> 
      <td width="40%" bgcolor="#999999"><div align="center" class="jjy"><font color="#FFFFFF">.NET 
        服务器相关信息</font></div></td>
      <td>&nbsp;</td>
    </tr>
    <tr> 
      <td colspan="2"><table width="100%" border="1" cellpadding="0" cellspacing="0" bordercolor="#000000" style="border-color:Black;border-width:1px;border-style:solid;font-family:Verdana;border-collapse:collapse;">
            <tr> 
              <td width="20%" bgcolor="#CCCCCC"><span class="style5">服务器名称：</span></td>
              <td width="30%"><span class="style5"> 
                <asp:label ID="servername" runat="server" />                                
                </span></td>
              <td width="20%" bgcolor="#CCCCCC"><span class="style5">服务器操作系统：</span></td>
              <td width="30%"><span class="style5"> 
                <asp:label ID="serverms" runat="server" />                                
                </span></td>
            </tr>
            <tr> 
              <td width="20%" bgcolor="#CCCCCC"><span class="style5">服务器IP地址：</span></td>
              <td width="30%"><span class="style5"> 
                <asp:label ID="serverip" runat="server" />                                
                </span></td>
              <td width="20%" bgcolor="#CCCCCC"><span class="style5">服务器域名：</span></td>
              <td width="30%"><span class="style5"> 
                <asp:label ID="server_name" runat="server" />                                
                </span></td>
            </tr>
            <tr> 
              <td width="20%" bgcolor="#CCCCCC"><span class="style5">服务器IIS版本：</span></td>
              <td width="30%"><span class="style5"> 
                <asp:label ID="serversoft" runat="server" />                                
                </span></td>
              <td width="20%" bgcolor="#CCCCCC"><span class="style5">.NET解释引擎版本：</span></td>
              <td width="30%"><span class="style5"> 
                <asp:label ID="servernet" runat="server" />                                
                </span></td>
            </tr>
            <tr> 
              <td width="20%" bgcolor="#CCCCCC"><span class="style5">HTTPS：</span></td>
              <td width="30%"><span class="style5"> 
                <asp:label ID="serverhttps" runat="server" />                                
                </span></td>
              <td width="20%" bgcolor="#CCCCCC"><span class="style5">HTTP访问端口：</span></td>
              <td width="30%"><span class="style5"> 
                <asp:label ID="serverport" runat="server" />                                
                </span></td>
            </tr>
            <tr> 
              <td width="20%" bgcolor="#CCCCCC"><span class="style5">服务端脚本执行超时：</span></td>
              <td width="30%"><span class="style5"> 
                <asp:label ID="serverout" runat="server" />                                
                秒</span></td>
              <td width="20%" bgcolor="#CCCCCC"><span class="style5">服务器现在时间：</span></td>
              <td width="30%"><span class="style5"> 
                <asp:label ID="servertime" runat="server" />                                
                </span></td>
            </tr>
            <tr>
              <td bgcolor="#CCCCCC"><span class="style5">AspNet内存占用：</span></td>
              <td><span class="style5">
                <asp:label ID="aspnetn" runat="server" /> 
                M               
</span></td>
              <td bgcolor="#CCCCCC"><span class="style5">AspNet CPU时间:</span></td>
              <td><span class="style5">
              <asp:label ID="aspnetcpu" runat="server" /> 
              秒             
</span></td>
            </tr>
            <tr>
              <td bgcolor="#CCCCCC"><span class="style5">开机运行时长:</span></td>
              <td><span class="style5">
                <asp:label ID="serverstart" runat="server" /> 
                小时               
</span></td>
              <td bgcolor="#CCCCCC"><span class="style5">进程开始时间:</span></td>
              <td><span class="style5">
                <asp:label ID="prstart" runat="server" />                
</span></td>
            </tr>
            <tr>
              <td bgcolor="#CCCCCC"><span class="style5">CPU数：</span></td>
              <td><span class="style5">
                <asp:label ID="cpuc" runat="server" />                
个 </span></td>
              <td bgcolor="#CCCCCC"><span class="style5">服务器时区：</span></td>
              <td><span class="style5">
                <asp:label ID="serverarea" runat="server" />                
              </span> </td>
            </tr>
            <tr>
              <td bgcolor="#CCCCCC"><span class="style5">CPU类型：</span></td>
              <td colspan="3"><span class="style5">
                <asp:label ID="cputype" runat="server" />                
</span></td>
            </tr>
            <tr> 
              <td width="20%" bgcolor="#CCCCCC"><span class="style5">虚拟目录绝对路径：</span></td>
              <td colspan="3"><span class="style5"> 
                <asp:label ID="serverppath" runat="server" />                                
                </span></td>
            </tr>
            <tr> 
              <td bgcolor="#CCCCCC"><span class="style5">执行文件绝对路径：</span></td>
              <td colspan="3"><span class="style5"> 
                <asp:label ID="servernpath" runat="server" />                                
                </span></td>
            </tr>
            <tr> 
              <td width="20%" bgcolor="#CCCCCC"><span class="style5">虚拟目录Session总数：</span></td>
              <td width="30%"><span class="style5"> 
                <asp:label ID="servers" runat="server" />                                
                </span></td>
              <td width="20%" bgcolor="#CCCCCC"><span class="style5">虚拟目录Application总数：</span></td>
              <td width="30%"><span class="style5"> 
                <asp:label ID="servera" runat="server" />                                
                </span></td>
            </tr>
          </table></td>
    </tr>
    <tr> 
      <td width="260" bgcolor="#999999"><div align="center" class="jjy"><font color="#FFFFFF">常见组件支持情况</font></div></td>
      <td>&nbsp;</td>
    </tr>
    <tr> 
      <td colspan="2"><table width="100%" border="1" cellpadding="0" cellspacing="0" bordercolor="#000000" style="border-color:Black;border-width:1px;border-style:solid;font-family:Verdana;border-collapse:collapse;">
          <tr> 
            <td width="20%" bgcolor="#CCCCCC"><span class="style5">Access数据库：</span></td>
            <td width="30%"><span class="style5"> 
              <asp:label ID="serveraccess" runat="server" />                            
              </span></td>
            <td width="20%" bgcolor="#CCCCCC"><span class="style5">FSO：</span></td>
            <td width="30%"><span class="style5"> 
              <asp:label ID="serverfso" runat="server" />                            
              </span></td>
          </tr>
          <tr> 
            <td width="20%" bgcolor="#CCCCCC"><span class="style5">CDONTS邮件发送：</span></td>
            <td width="30%"><span class="style5"> 
              <asp:label ID="servercdonts" runat="server" />                            
              </span></td>
            <td width="20%" bgcolor="#CCCCCC"><span class="style5">JMail邮件收发：</span></td>
            <td width="30%"><span class="style5"> 
              <asp:label ID="jmail" runat="server"></asp:label>
              </span></td>
          </tr>
          <tr> 
            <td width="20%" bgcolor="#CCCCCC"><span class="style5">ASPemail发信：</span></td>
            <td width="30%"><span class="style5"> 
              <asp:label ID="aspemail" runat="server"></asp:label>
              </span></td>
            <td width="20%" bgcolor="#CCCCCC"><span class="style5">Geocel发信：</span></td>
            <td width="30%"><span class="style5"> 
              <asp:label ID="geocel" runat="server"></asp:label>
              </span></td>
          </tr>
          <tr> 
            <td width="20%" bgcolor="#CCCCCC"><span class="style5">SmtpMail发信：</span></td>
            <td width="30%"><span class="style5"> 
              <asp:label ID="smtpmail" runat="server"></asp:label>
              </span></td>
            <td width="20%" bgcolor="#CCCCCC"><span class="style5">ASPUpload文件上传:</span></td>
            <td width="30%"><span class="style5"> 
              <asp:label ID="aspup" runat="server"></asp:label>
              </span></td>
          </tr>
          <tr> 
            <td width="20%" bgcolor="#CCCCCC"><span class="style5">ASPCN文件上传：</span></td>
            <td width="30%"><span class="style5"> 
              <asp:label ID="aspcnup" runat="server"></asp:label>
              </span></td>
            <td width="20%" bgcolor="#CCCCCC"><span class="style5">刘云峰的文件上传组件:</span></td>
            <td width="30%"><span class="style5"> 
              <asp:label ID="lyfup" runat="server"></asp:label>
              </span></td>
          </tr>
          <tr> 
            <td width="20%" bgcolor="#CCCCCC"><span class="style5">SoftArtisans文件管理:</span></td>
            <td width="30%"><span class="style5"> 
              <asp:label ID="soft" runat="server"></asp:label>
              </span></td>
            <td width="20%" bgcolor="#CCCCCC"><span class="style5">Dimac文件上传:</span></td>
            <td width="30%"><span class="style5"> 
              <asp:label ID="dimac" runat="server"></asp:label>
              </span></td>
          </tr>
          <tr> 
            <td width="20%" bgcolor="#CCCCCC"><span class="style5">Dimac的图像读写组件:</span></td>
            <td width="30%"><span class="style5"> 
              <asp:label ID="dimacimage" runat="server"></asp:label>
              </span></td>
            <td width="20%" bgcolor="#CCCCCC"><span class="style5">自定义组件查询：</span></td>
            <td width="30%"> <table width="100%" border="0" cellpadding="0" cellspacing="0">
                <tr> 
                  <td width="72%" class="style5"> 
                    <asp:textbox ID="zujian" Rows="1" runat="server" TextMode="SingleLine" style="border-style:solid;border-color:black;border-width:1px"/>                                        </td>
                  <td width="28%"> 
                    <asp:button ID="ckzu" runat="server" Text="检测" OnClick="chkzujian"  style="background-color:#CCCCCC;border-color:black;border-width:1px"/>                                        </td>
                </tr>
              </table></td>
          </tr>
          <tr> 
            <td colspan="4"><span class="style5">请正确输入你要检测的组件的ProgId或ClassId。<br>
                <font color="#FF0000"> 
                <asp:label ID="l001" runat="server" />                                                    
              </font></span></td>
          </tr>
        </table></td>
    </tr>
    <tr> 
      <td width="260" bgcolor="#999999"><div align="center" class="jjy"><font color="#FFFFFF">浏览者相关信息</font></div></td>
      <td>&nbsp;</td>
    </tr>
    <tr> 
      <td colspan="2"><table width="100%" border="1" cellpadding="0" cellspacing="0" bordercolor="#000000" style="border-color:Black;border-width:1px;border-style:solid;font-family:Verdana;border-collapse:collapse;">
            <tr> 
              <td width="20%" bgcolor="#CCCCCC"><span class="style5">浏览者ip地址：</span></td>
              <td width="30%"><span class="style5"> 
                <asp:label ID="cip" runat="server"></asp:label>
                </span></td>
              <td width="20%" bgcolor="#CCCCCC"><span class="style5">浏览者操作系统：</span></td>
              <td width="30%"><span class="style5"> 
                <asp:label ID="ms" runat="server" />                                
              </span></td>
            </tr>
            <tr> 
              <td width="20%" bgcolor="#CCCCCC"><span class="style5">浏览器：</span></td>
              <td width="30%"><span class="style5"> 
                <asp:label ID="ie" runat="server" />                                
              </span></td>
              <td width="20%" bgcolor="#CCCCCC"><span class="style5">浏览器版本：</span></td>
              <td width="30%"><span class="style5"> 
                <asp:label ID="vi" runat="server" />                                
              </span></td>
            </tr>
            <tr> 
              <td width="20%" bgcolor="#CCCCCC"><span class="style5">JavaScript:</span></td>
              <td width="30%"><span class="style5"> 
                <asp:label ID="javas" runat="server" />                                
              </span></td>
              <td width="20%" bgcolor="#CCCCCC"><span class="style5">VBScript:</span></td>
              <td width="30%"><span class="style5"> 
                <asp:label ID="vbs" runat="server" />                                
              </span></td>
            </tr>
            <tr> 
              <td width="20%" bgcolor="#CCCCCC"><span class="style5">JavaApplets:</span></td>
              <td width="30%"><span class="style5"> 
                <asp:label ID="javaa" runat="server" />                                
              </span></td>
              <td width="20%" bgcolor="#CCCCCC"><span class="style5">Cookies:</span></td>
              <td width="30%"><span class="style5"> 
                <asp:label ID="cookies" runat="server" />                                
              </span></td>
            </tr>
            <tr> 
              <td bgcolor="#CCCCCC"><span class="style5">语言：</span></td>
              <td><span class="style5"> 
                <asp:label ID="cl" runat="server"></asp:label>
                </span></td>
              <td bgcolor="#CCCCCC"><span class="style5">Frames（分栏）:</span></td>
              <td><span class="style5"> 
                <asp:label ID="frames" runat="server" />                                
              </span></td>
            </tr>
          </table></td>
    </tr>
    <tr> 
      <td width="260" bgcolor="#999999"><div align="center" class="jjy"><font color="#FFFFFF">执行效率相关情况</font></div></td>
      <td>&nbsp;</td>
    </tr>
    <tr> 
      <td colspan="2"><table width="100%" border="1" cellpadding="0" cellspacing="0" bordercolor="Black" rules="all" class="ty" style="border-color:Black;border-width:1px;border-style:solid;font-family:Verdana;border-collapse:collapse;">
          <tr> 
            <td width="20%" bgcolor="#CCCCCC"><span class="style5">本页执行时间：</span></td>
            <td width="30%"><span class="style5"> 
              <asp:label ID="runtime" runat="server" />                            
              毫秒</span></td>
            <td width="20%" height="21" bgcolor="#CCCCCC"><span class="style5">1000万次加法循环测试：</span></td>
            <td width="30%"><span class="style5"> 
              &nbsp;
              <asp:button ID="for1000" runat="server"  OnClick="turn_chk" Text="测试" style="background-color:#CCCCCC;border-color:black;border-width:1px"/>                            
              <asp:label ID="l1000" runat="server"></asp:label>
              </span></td>
          </tr>
        </table></td>
    </tr>
  </table>
  </form>
</div>
</body>
</html>
<script language="C#" runat="server">
public void Page_Load(Object sender,EventArgs e)
{
    Response.Expires = 0;
    Response.CacheControl = "no-cache";
    if (!Page.IsPostBack)
	{

        //取得页面执行开始时间
        DateTime stime=DateTime.Now;
 
 
        //取得服务器相关信息
        servername.Text=Server.MachineName;
        serverip.Text=Request.ServerVariables["LOCAL_ADDR"];
        server_name.Text=Request.ServerVariables["SERVER_NAME"];
 
        //以下就是取值不准的地方，因为用了HTTP_USER_AGENT当做服务器信息。
        //1.0 final 使用Environment类属性，彻底解决了这一问题
        //char[] de = {';'};
        //string allhttp=Request.ServerVariables["HTTP_USER_AGENT"].ToString();
        //string[] myFilename = allhttp.Split(de);
        //servernet.Text=myFilename[myFilename.Length-1].Replace(")"," ");
        int build, major, minor,revision;
        build=Environment.Version.Build;
        major=Environment.Version.Major;
        minor=Environment.Version.Minor;
        revision=Environment.Version.Revision;
        servernet.Text=".NET CLR  "+major +"."+ minor + "." + build+"."+revision;
        serverms.Text=Environment.OSVersion.ToString();
        //服务器端浏览器版本暂时不知道怎么取得，原有不准，故删除
        //1.0 final 修改
        //serverie.Text=myFilename[1];
 
        serversoft.Text=Request.ServerVariables["SERVER_SOFTWARE"];
        serverport.Text=Request.ServerVariables["SERVER_PORT"];
        serverout.Text=Server.ScriptTimeout.ToString();
        //语言应该是浏览者信息，1.0 final 修改
        cl.Text=Request.ServerVariables["HTTP_ACCEPT_LANGUAGE"];
        servertime.Text=DateTime.Now.ToString();
        serverppath.Text=Request.ServerVariables["APPL_PHYSICAL_PATH"];
        servernpath.Text=Request.ServerVariables["PATH_TRANSLATED"];
        serverhttps.Text=Request.ServerVariables["HTTPS"];
		
        if (chkobj("ADODB.RecordSet"))
		{
            serveraccess.Text="支持";
		}
        else 
		{
		    serveraccess.Text="不支持";
		}
		
        if (chkobj("Scripting.FileSystemObject"))
		{
            serverfso.Text="支持";
		}
        else 
		{
		    serverfso.Text="不支持";
		}
		
        if (chkobj("CDONTS.NewMail"))
		{
            servercdonts.Text="支持";
		}
        else 
		{
		    servercdonts.Text="不支持";
		}
		
        servers.Text=Session.Contents.Count.ToString();
        servera.Text=Application.Contents.Count.ToString();
 
        //0.1版添加的组件验证，原有组件并未转移过来，请原谅。 
        if (chkobj("JMail.SmtpMail"))
		{
            jmail.Text="支持";
		}
        else 
		{
		    jmail.Text="不支持";
		}
 
        if (chkobj("Persits.MailSender"))
		{
            aspemail.Text="支持";
		}
        else 
		{
		    aspemail.Text="不支持";
		}

        if (chkobj("Geocel.Mailer"))
		{
            geocel.Text="支持";
		}
        else 
		{
		    geocel.Text="不支持";
		}
 
        if (chkobj("SmtpMail.SmtpMail.1"))
		{
            smtpmail.Text="支持";
		}
        else 
		{
		    smtpmail.Text="不支持";
		}
 
        if (chkobj("Persits.Upload.1"))
		{
            aspup.Text="支持";
		}
        else 
		{
		    aspup.Text="不支持";
		}

        if (chkobj("aspcn.Upload"))
		{
            aspcnup.Text="支持";
		}
        else 
		{
		    aspcnup.Text="不支持";
		}

        if (chkobj("LyfUpload.UploadFile"))
		{
            lyfup.Text="支持";
		}
        else 
		{
		    lyfup.Text="不支持";
		}
 
        if (chkobj("SoftArtisans.FileManager"))
		{
            soft.Text="支持";
		}
        else 
		{
		    soft.Text="不支持";
		}

        if (chkobj("w3.upload"))
		{
            dimac.Text="支持";
		}
        else 
		{
		    dimac.Text="不支持";
		}
 
        if (chkobj("W3Image.Image"))
		{
            dimacimage.Text="支持";
		}
        else 
		{
		    dimacimage.Text="不支持";
		}

        //取得用户浏览器信息
        HttpBrowserCapabilities bc= Request.Browser;
        ie.Text = bc.Browser.ToString();
        cookies.Text = bc.Cookies.ToString();
        frames.Text = bc.Frames.ToString();
        javaa.Text = bc.JavaApplets.ToString();
        javas.Text = bc.JavaScript.ToString();
        ms.Text = bc.Platform.ToString();
        vbs.Text = bc.VBScript.ToString();
        vi.Text = bc.Version.ToString();
 
        //取得浏览者ip地址,1.0 final 加入
        //cip.Text = Request.ServerVariables["REMOTE_ADDR"];
		//考虑到代理服务器影响，１.1修正
		cip.Text=getip();
 
        //取得页面执行结束时间
        DateTime etime=DateTime.Now;
 
 
        //计算页面执行时间
        runtime.Text=((etime-stime).TotalMilliseconds).ToString();
		
		//以下几个功能由dvnews4.0看来的。v１.1加入
		cpuc.Text=Environment.GetEnvironmentVariable("NUMBER_OF_PROCESSORS");
		cputype.Text=Environment.GetEnvironmentVariable("PROCESSOR_IDENTIFIER");
		aspnetn.Text=getaspnetn();
		aspnetcpu.Text=getaspnetcpu();
		serverstart.Text=((Double)System.Environment.TickCount/3600000).ToString("N2");
		prstart.Text=getprstart();
		serverarea.Text=(DateTime.Now-DateTime.UtcNow).TotalHours> 0 ? "+"+(DateTime.Now-DateTime.UtcNow).TotalHours.ToString() : (DateTime.Now-DateTime.UtcNow).TotalHours.ToString();
		//以上几个功能由dvnews4.0看来的。
    }
}

//组件支持验证代码

bool chkobj(string obj)
{
    try 
	{
        object meobj = Server.CreateObject(obj);
        return(true);
     }
     catch (Exception objex) 
     {
        return(false);
     }
}

//100万次循环测试，由0.1sn bulid 021203开始加入

public void turn_chk(Object Sender,EventArgs e)
{
    DateTime ontime=DateTime.Now;
    int sum=0;
    for (int i=1;i<=10000000;i++)
	{
        sum=sum+i;
    }
    DateTime endtime=DateTime.Now;
    l1000.Text=((endtime-ontime).TotalMilliseconds).ToString()+"毫秒";
}

//自定义组件检测0.1版加入

public void chkzujian(Object Sender,EventArgs e)
{
    string obj=zujian.Text;
    if (chkobj(obj))
	{
        l001.Text="检测结果：支持组件"+obj;
	}
    else 
	{
	    l001.Text="检测结果：不支持组件"+obj;
	}
}
string getaspnetn()
{
    string temp;
	try
	{
	    temp=((Double)System.Diagnostics.Process.GetCurrentProcess().WorkingSet/1048576).ToString("N2");
	}
	catch
	{
	    temp="未知";
	}
	return temp;
}
string getaspnetcpu()
{
    string temp;
	try
	{
	    temp=((TimeSpan)System.Diagnostics.Process.GetCurrentProcess().TotalProcessorTime).TotalSeconds.ToString("N0");
	}
	catch
	{
	    temp="未知";
	}
	return temp;
}

string getprstart()
{
    string temp;
	try
	{
	    temp=System.Diagnostics.Process.GetCurrentProcess().StartTime.ToString();
	}
	catch
	{
	    temp="未知";
	}
	return temp;
}

string getip()
{
    string test=Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
    if (test==null || test=="")
    {
        test=Request.ServerVariables["REMOTE_ADDR"];
    }
	return test;
}

</script>
