未经说明,本blog.csdn.net/wind7788均为本人原创代码,凡是引用或者应用请注明出处,表示对作者的尊重.
以下代码主要使用了NameValueCollection来存储信息,用HtmlTable来显示信息.以方便扩展.你也可以用xml来存储要刺探的项目,这样更有利于扩充.
<xmp>using System;
using System.Collections;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace Addr.Admin
{
///
/// Bougie 的摘要说明。
///
public class Bougie : System.Web.UI.Page
{
protected HtmlTable ServerInfo,ComInfo,ClientInfo;
protected System.Web.UI.WebControls.TextBox newCom;
protected System.Web.UI.WebControls.Button OK1;
protected System.Web.UI.WebControls.Label resultCom;
protected System.Web.UI.WebControls.Label resultAdd;
protected System.Web.UI.WebControls.TextBox newExec;
protected System.Web.UI.WebControls.ValidationSummary Val2;
protected System.Web.UI.WebControls.Button OK2;
protected System.Web.UI.WebControls.RangeValidator Val1;
protected System.Web.UI.WebControls.RequiredFieldValidator Val3;
protected System.Web.UI.HtmlControls.HtmlTableCell CopyRight;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
Response.Expires = 0;
Response.CacheControl = "no-cache";
NameValueCollection nvcServer=new NameValueCollection();
NameValueCollection nvcCom=new NameValueCollection();
NameValueCollection nvcClient=new NameValueCollection();
DateTime StartTime=DateTime.Now;
//服务器信息
nvcServer.Add("服务器名称",Server.MachineName);
nvcServer.Add("服务器IP地址",Request.ServerVariables["LOCAL_ADDR"]);
nvcServer.Add("服务器域名",Request.ServerVariables["SERVER_NAME"]);
nvcServer.Add(".NET框架版本",Environment.Version.ToString());
nvcServer.Add("服务器操作系统",Environment.OSVersion.ToString());
nvcServer.Add("IIS环境",Request.ServerVariables["SERVER_SOFTWARE"]);
nvcServer.Add("服务器端口",Request.ServerVariables["SERVER_PORT"]);
nvcServer.Add("脚本超时设置",Server.ScriptTimeout.ToString());
nvcServer.Add("服务器现在时间",DateTime.Now.ToString());
nvcServer.Add("虚拟目录绝对路径",Request.ServerVariables["APPL_PHYSICAL_PATH"]);
nvcServer.Add("执行文件绝对路进",Request.ServerVariables["PATH_TRANSLATED"]);
nvcServer.Add("HTTPS支持",Request.ServerVariables["HTTPS"]);
nvcServer.Add("SESSION总数",Session.Keys.Count.ToString());
nvcServer.Add("APPLICATION总数",Application.Keys.Count.ToString());
//组件支持情况
if (checkObject("JMail.SmtpMail"))
{
nvcCom.Add("JMail邮件","√");
}
else
{
nvcCom.Add("JMail邮件","×");
}
if (checkObject("Persits.MailSender"))
{
nvcCom.Add("Persits邮件","√");
}
else
{
nvcCom.Add("Persits邮件","×");
}
if (checkObject("Geocel.Mailer"))
{
nvcCom.Add("Geocel邮件","√");
}
else
{
nvcCom.Add("Geocel邮件","×");
}
if (checkObject("SmtpMail.SmtpMail.1"))
{
nvcCom.Add("SmtpMail邮件","√");
}
else
{
nvcCom.Add("SmtpMail邮件","×");
}
if (checkObject("Persits.Upload.1"))
{
nvcCom.Add("Persits上传","√");
}
else
{
nvcCom.Add("Persits上传","×");
}
if (checkObject("aspcn.Upload"))
{
nvcCom.Add("Paspcn上传","√");
}
else
{
nvcCom.Add("Paspcn上传","×");
}
if (checkObject("LyfUpload.UploadFile"))
{
nvcCom.Add("LyfUpload上传","√");
}
else
{
nvcCom.Add("LyfUpload上传","×");
}
if (checkObject("SoftArtisans.FileManager"))
{
nvcCom.Add("SoftArtisans文件管理","√");
}
else
{
nvcCom.Add("SoftArtisans文件管理","×");
}
if (checkObject("w3.upload"))
{
nvcCom.Add("w3上传","√");
}
else
{
nvcCom.Add("w3上传","×");
}
if (checkObject("W3Image.Image"))
{
nvcCom.Add("W3Image图像读写","√");
}
else
{
nvcCom.Add("W3Image图像读写","×");
}
if(checkObject("ADODB.Connection"))
{
nvcCom.Add("ADO数据连接","√");
}
else
{
nvcCom.Add("ADO数据连接","×");
}
if(checkObject("ADODB.RecordSet"))
{
nvcCom.Add("ADO数据集","√");
}
else
{
nvcCom.Add("ADO数据集","×");
}
if (checkObject("Scripting.FileSystemObject"))
{
nvcCom.Add("FSO","√");
}
else
{
nvcCom.Add("FSO","×");
}
if (checkObject("CDONTS.NewMail"))
{
nvcCom.Add("CDONTS邮件","√");
}
else
{
nvcCom.Add("CDONTS邮件","×");
}
//客户端信息
nvcClient.Add("客户端IP地址",Request.ServerVariables["REMOTE_ADDR"]);
HttpBrowserCapabilities HBC=Request.Browser;
nvcClient.Add("客户端操作系统",HBC.Platform.ToString());
nvcClient.Add("浏览器",HBC.Browser.ToString());
nvcClient.Add("浏览器版本",HBC.Version.ToString());
nvcClient.Add("VBS",HBC.VBScript.ToString());
nvcClient.Add("JS",HBC.JavaScript.ToString());
nvcClient.Add("ActiveX",HBC.ActiveXControls.ToString());
nvcClient.Add("JavaApplets",HBC.JavaApplets.ToString());
nvcClient.Add("语言",Request.ServerVariables["HTTP_ACCEPT_LANGUAGE"]);
nvcClient.Add("框架支持",HBC.Frames.ToString());
nvcClient.Add("Cookie支持",HBC.Cookies.ToString());
nvcClient.Add("DOM",HBC.MSDomVersion.ToString());
//写出数据
writeOut(nvcServer,ServerInfo);
writeOut(nvcCom,ComInfo);
writeOut(nvcClient,ClientInfo);
DateTime EndTime=DateTime.Now;
CopyRight.InnerHtml="本页执行时间:"+((EndTime-StartTime).TotalSeconds).ToString()+"秒 ";
CopyRight.InnerHtml+="CopyRighy ©2004 - 2006 4renx.com .netBougie version 1.0
千山一鸟作品[[email protected]]";
}
private void writeOut(NameValueCollection nvc,HtmlTable ht)
{
for(int i=0;i {
HtmlTableRow tr=new HtmlTableRow();
for(int j=0;j<2;j++)
{
HtmlTableCell td=new HtmlTableCell();
td.InnerHtml=nvc.GetKey(i).ToString();
td.Width="20%";
HtmlTableCell td1=new HtmlTableCell();
td1.InnerHtml=nvc[i].ToString();
td1.Width="30%";
tr.Controls.Add(td);
tr.Controls.Add(td1);
i++;
}
ht.Controls.Add(tr);
}
}
private bool checkObject(string obj)
{
try
{
object meobj = Server.CreateObject(obj);
return(true);
}
catch
{
return(false);
}
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
///
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
///
private void InitializeComponent()
{
this.OK1.Click += new System.EventHandler(this.OK1_Click);
this.OK2.Click += new System.EventHandler(this.OK2_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void OK1_Click(object sender, System.EventArgs e)
{
if(checkObject(newCom.Text))
{
resultCom.Text="√";
}
else
{
resultCom.Text="×";
}
}
private void OK2_Click(object sender, System.EventArgs e)
{
try
{
int sum=0;
int newData=Convert.ToInt32(newExec.Text.Trim());
DateTime startTime=DateTime.Now;
for(int i=0;i {
sum+=i;
}
DateTime endTime=DateTime.Now;
resultAdd.Text=((endTime-startTime).TotalMilliseconds).ToString()+"毫秒";
}
catch
{
resultAdd.Text="执行错误!可能是参数无效!";
}
}
}
}
</xmp>
<xmp>
<%@ Page language="c#" Codebehind="Bougie.aspx.cs" AutoEventWireup="false" Inherits="Addr.Admin.Bougie" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>Bougie</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio 7.0">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<style type="text/css">
INPUT { FONT-SIZE: 9pt }
.td { FONT-SIZE: 9pt }
.table { BORDER-RIGHT: #6595d6 1px solid; BORDER-TOP: #6595d6 1px solid; FONT-SIZE: 9pt; BORDER-LEFT: #6595d6 1px solid; BORDER-BOTTOM: #6595d6 1px solid; BORDER-COLLAPSE: collapse }
A:link { COLOR: #000000; TEXT-DECORATION: none }
A:visited { COLOR: #000000; TEXT-DECORATION: none }
A:hover { COLOR: #000000; TEXT-DECORATION: underline }
A:active { COLOR: #000000; TEXT-DECORATION: none }
BODY { MARGIN-TOP: 0px; SCROLLBAR-FACE-COLOR: #dee3e7; FONT-SIZE: 9pt; SCROLLBAR-HIGHLIGHT-COLOR: #ffffff; MARGIN-LEFT: 0px; SCROLLBAR-SHADOW-COLOR: #dee3e7; SCROLLBAR-3DLIGHT-COLOR: #d1d7dc; SCROLLBAR-ARROW-COLOR: #006699; SCROLLBAR-TRACK-COLOR: #efefef; SCROLLBAR-DARKSHADOW-COLOR: #98aab1 }
.header { FONT-WEIGHT: bold; COLOR: #ffffff }
.table1 { BORDER-RIGHT: #6595d6 1px solid; BORDER-TOP: #6595d6 1px solid; FONT-SIZE: 9pt; BORDER-LEFT: #6595d6 1px solid; BORDER-BOTTOM: #6595d6 1px solid; BORDER-COLLAPSE: collapse }
.table2 { BORDER-RIGHT: #6595d6 1px solid; BORDER-TOP: #6595d6 1px solid; FONT-SIZE: 9pt; BORDER-LEFT: #6595d6 1px solid; BORDER-BOTTOM: #6595d6 1px solid; BORDER-COLLAPSE: collapse }
.table3 { BORDER-RIGHT: #6595d6 1px solid; BORDER-TOP: #6595d6 1px solid; FONT-SIZE: 9pt; BORDER-LEFT: #6595d6 1px solid; BORDER-BOTTOM: #6595d6 1px solid; BORDER-COLLAPSE: collapse }
.table4 { BORDER-RIGHT: #6595d6 1px solid; BORDER-TOP: #6595d6 1px solid; FONT-SIZE: 9pt; BORDER-LEFT: #6595d6 1px solid; BORDER-BOTTOM: #6595d6 1px solid; BORDER-COLLAPSE: collapse }
.table5 { BORDER-RIGHT: #6595d6 1px solid; BORDER-TOP: #6595d6 1px solid; FONT-SIZE: 9pt; BORDER-LEFT: #6595d6 1px solid; BORDER-BOTTOM: #6595d6 1px solid; BORDER-COLLAPSE: collapse }
.table6 { BORDER-RIGHT: #6595d6 1px solid; BORDER-TOP: #6595d6 1px solid; FONT-SIZE: 9pt; BORDER-LEFT: #6595d6 1px solid; BORDER-BOTTOM: #6595d6 1px solid; BORDER-COLLAPSE: collapse }
.table11 { BORDER-RIGHT: #6595d6 1px solid; BORDER-TOP: #6595d6 1px solid; FONT-SIZE: 9pt; BORDER-LEFT: #6595d6 1px solid; BORDER-BOTTOM: #6595d6 1px solid; BORDER-COLLAPSE: collapse }
.table12 { BORDER-RIGHT: #6595d6 1px solid; BORDER-TOP: #6595d6 1px solid; FONT-SIZE: 9pt; BORDER-LEFT: #6595d6 1px solid; BORDER-BOTTOM: #6595d6 1px solid; BORDER-COLLAPSE: collapse }
</style>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Bougie" method="post" runat="server">
<table width="90%" border="1" align="center" cellpadding="3" cellspacing="0" bordercolor="#6595d6" class="table">
<tr bgcolor="#6595d6">
<td colspan="4" class="header">服务器信息</td>
</tr>
</table>
<table width="90%" border="1" align="center" cellpadding="3" cellspacing="0" bordercolor="#6595d6" class="table1" id="ServerInfo" runat="server">
</table>
<table width="90%" border="1" align="center" cellpadding="3" cellspacing="0" bordercolor="#6595d6" class="table2">
<tr bgcolor="#6595d6">
<td colspan="3" class="header">组件支持信息</td>
</tr>
</table>
<table width="90%" border="1" align="center" cellpadding="3" cellspacing="0" bordercolor="#6595d6" class="table11" id="ComInfo" runat="server">
</table>
<table width="90%" border="1" align="center" cellpadding="3" cellspacing="0" bordercolor="#6595d6" class="table4">
<tr bgcolor="#6595d6">
<td colspan="4" bgcolor="#6595d6" class="header">客户端信息</td>
</tr>
</table>
<table width="90%" border="1" align="center" cellpadding="3" cellspacing="0" bordercolor="#6595d6" class="table12" id="ClientInfo" runat="server">
</table>
<table width="90%" border="1" align="center" cellpadding="3" cellspacing="0" bordercolor="#6595d6" class="table6">
<tr bgcolor="#6595d6">
<td colspan="4" class="header">组件支持查询及执行效率查询</td>
</tr>
<tr>
<td width="20%">自定义组件查询</td>
<td width="30%">
<asp:TextBox id="newCom" runat="server" Wrap="False" BorderStyle="Solid" BorderWidth="1px" MaxLength="50"></asp:TextBox></td>
<td width="20%">
<asp:Button id="OK1" runat="server" Text="查询" BorderStyle="Solid" CausesValidation="False"></asp:Button></td>
<td width="30%">
<asp:Label id="resultCom" runat="server" Width="204px"></asp:Label></td>
</tr>
<tr>
<td><FONT face="宋体">加法循环测试
<asp:RangeValidator id="Val1" runat="server" ErrorMessage="错误的参数!" Display="None" ControlToValidate="newExec" MaximumValue="1000000000" MinimumValue="1"></asp:RangeValidator>
<asp:RequiredFieldValidator id="Val3" runat="server" ControlToValidate="newExec" Display="None" ErrorMessage="参数不能为空!"></asp:RequiredFieldValidator></FONT></td>
<td>
<asp:TextBox id="newExec" runat="server" Wrap="False" BorderStyle="Solid" BorderWidth="1px" MaxLength="10">10000000</asp:TextBox></td>
<td>
<asp:Button id="OK2" runat="server" Text="测试" BorderStyle="Solid"></asp:Button></td>
<td>
<asp:Label id="resultAdd" runat="server" Width="198px"></asp:Label></td>
</tr>
</table>
<table width="90%" border="0" align="center" cellpadding="3" cellspacing="0">
<tr>
<td align="middle" class="td" id="CopyRight" runat="server"> </td>
</tr>
</table>
<asp:ValidationSummary id="Val2" style="Z-INDEX: 101; LEFT: 49px; POSITION: absolute; TOP: 311px" runat="server" ShowMessageBox="True" ShowSummary="False" HeaderText="出错信息:"></asp:ValidationSummary>
</form>
</body>
</HTML>
</xmp>