<%@ Page Language="JScript" ContentType="text/html" ResponseEncoding="gb2312" Debug="false" aspcompat="true" %>
<%@ Import Namespace="HoWave.Web.Admin"  %>
<script language="JavaScript" runat="server">
	function getObjVer(objName){
        var sObjVer='';
        var objTest=null;
		try{  objTest = Server.CreateObject(objName);}
		catch(e){ if(e.number==-2147221005) return ""; else return "N/A" }
		try{  sObjVer = objTest.Version; }
		catch(e){ return ""; }
		if(isNaN(parseInt(sObjVer))) return "";
		objTest = null;
		return sObjVer;
	}
</script>
<%
    if (false)
    {
           Response.Write("<script>alert('请先登录!');location.href='Admin_Login.aspx';</script>");
           Response.End();           
    }
	Response.Expires = 0;
	Response.Buffer  = true;
	var tPageStartTime = new Date();
	var sTheFile, i, j, x, y;
	sTheFile = Request.ServerVariables("SCRIPT_NAME");
	var sObjName = Request.Form("sObjName")+"";
	
	var bShowDetail = false;
	if(Request.QueryString.ToString().indexOf("ServerDetail")>-1) bShowDetail = true;
	
	
	var arrObj = new Array(
		Array( "MSWC.AdRotator", "", 1 ),
		Array( "MSWC.BrowserType", "", 1 ),
		Array( "MSWC.NextLink", "", 1 ),
		Array( "MSWC.Tools", "", 1 ),
		Array( "MSWC.Status", "", 1 ),
		Array( "MSWC.Counters", "", 1 ),
		Array( "IISSample.ContentRotator", "", 1 ),
		Array( "IISSample.PageCounter", "", 1 ),
		Array( "MSWC.PermissionChecker", "", 1 ),
		Array( "WScript.Shell", "", 1 ),
		Array( "Scripting.FileSystemObject", "", 1 ),
		Array( "ADODB.Connection", "ActiveX Data Object [ADO]", 1 ),
		Array( "CDONTS.NewMail", "Collaboration Data Object [CDO]", 1 ),
		
		Array( "SoftArtisans.FileUp", "SA-FileUp 文件上传", 2 ),
		Array( "SoftArtisans.FileManager", "SA-FM 文件管理", 2 ),
		Array( "LyfUpload.UploadFile", "LyfUpload 文件上传", 2 ),
		Array( "Persits.Upload.1", "ASPUpload 文件上传", 2 ),
		Array( "w3.upload", "w3 upload 文件上传", 2 ),
		
		Array( "iismail.iismail.1", "IISemail", 3 ),
		Array( "JMail.SMTPMail", "w3 Jmail", 3 ),
		Array( "Persits.MailSender", "ASPemail", 3 ),
		Array( "SMTPsvg.Mailer", "ASPmail", 3 ),
		Array( "dkQmail.Qmail", "dkQmail", 3 ),
		Array( "SmtpMail.SmtpMail.1", "SMTPmail", 3 ),
		Array( "Geocel.Mailer", "Geocel", 3),
		
		Array( "SoftArtisans.ImageGen", "SA 的图像读写组件", 4),
		Array( "W3Image.Image", "Dimac 的图像读写组件", 4)
	);
	if(sObjName.length) arrObj[arrObj.length] = Array( sObjName, "", 99 );

%>

<html xmlns="http://www.w3.org/1999/xhtml" >
  
<HEAD>
<META http-equiv="Content-Type" content="text/HTML; charset=gb2312">
<META http-equiv="Content-Type" content="text/HTML; charset=gb2312">
<META http-equiv="Expires" CONTENT="0">
<META http-equiv="Cache-Control" CONTENT="no-cache">
<META http-equiv="Pragma" CONTENT="no-cache">
<TITLE>服务器探针</TITLE>
<STYLE type=text/css>
BODY,tr {	FONT-SIZE: 9pt; FONT-FAMILY: "Arial", "Helvetica", "sans-serif" }

.tableForm{border: #CCCCCC 1px solid; PADDING: 1px; MARGIN: 0px; WIDTH: 100%; background:white;border-spacing: 0px; BORDER-COLLAPSE: collapse; }
.tableForm td{font-size:12px; line-height:22px;background:#eeeeee; padding-right: 5px; text-align:left;}
.tableForm th{text-align:right; font-size:13px; font-weight:normal;  height:25px;background:#E0EEF5; PADDING-BOTTOM: 2px;}
.tableForm .tit{ font-size:12px; font-weight:bold; height:25px;background-color:#449AE8; color:#FFFFFF; BACKGROUND: url(images/background.gif);PADDING-BOTTOM: 2px;}
.tableForm .title{background:gray; color:black} 
</STYLE>


<script type="text/javascript" language="JavaScript">
		var sErrorMessage = "";
		function getObjByID(n) {
			//This function was re-written form DreamWeaver v4.01 by Sunrise_Chen.
			var p,i,x;
			var d=document; 
			if(!(x=d[n])&&d.all) x=d.all[n];
			for(i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
			for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=getObjByID(n,d.layers[i].document);
			if(!x && d.getElementById) x=d.getElementById(n); 
			return x;
		}
		
		function pageInit(){
			document.title = CCNS_program + " v" + CCNS_version ;
			if(!getObjByID("chkAspSupport")){
				oDiv = getObjByID("divAspSupport");
				if(oDiv){
					oDiv.style.display="none";
					oDiv.id="DisabledDiv";
				}
				oDiv = getObjByID("divNoASP");
				if(oDiv){
					oDiv.style.display="";
					oDiv.id="divServer";
				}
			}
			
			
		}

		window.onerror = new Function("return true");
	</script>
</HEAD>
<body onError="return true;">

<div id="divServerSide" style="margin:0 auto; width:100%; ">

<div id="divAspSupport" style="margin:0 auto; ">
<table width="100%" border="0" cellpadding="1" cellspacing="1" class="tableForm" align="center">
  <tr> 
    <td bgcolor="#F8F9FC"> 
        <table width="100%" border="0" cellpadding="3" cellspacing="1" class="tableForm">
          <tr>
             <td colspan="4"><span style="float:left; display:inline-block;"><b>服务器端基本信息</b> :::...</span>
             <span style="float:right; display:inline-block; color:Gray;">服务器当前时间: <%=DateTime.Now%></span></td>
           </tr>
            <tr> 
              <td class="tit" ><font color="#5C72BA">&nbsp;</font>项目</td>
              <td colspan="3" class="tit" ><font color="#5C72BA">&nbsp;</font>值</td>
            </tr>
            <tr> 
              <th width="180px"> &nbsp;域名 / IP<br> <font color="#666666">&nbsp;Domain 
                Name</font></th>
              <td colspan="3">&nbsp;<%=Request.ServerVariables("SERVER_NAME")%> 
                &nbsp;/ <%=Request.ServerVariables("LOCAL_ADDR")%> [ 端口:<%=Request.ServerVariables("SERVER_PORT")%> 
                ]</td>
            </tr>
            <tr> 
              <th> &nbsp;服务器名<br> <font color="#666666">&nbsp;Machine 
                Name</font></th>
              <td >&nbsp;<%=Environment.MachineName%></td>
              <th width="180px">&nbsp;服务器网络域名<br>
                <font color="#666666">&nbsp;Domain Name</font></th>
              <td>&nbsp;<span class="td1o21"><%=Environment.UserDomainName.ToString()%></span></td>
            </tr>
            <tr> 
              <th> &nbsp;操作系统<br> <font color="#666666">&nbsp;Operating 
                System</font></th>
              <td colspan="3"> &nbsp;<%=Environment.OSVersion.ToString()%>&nbsp; </td>
            </tr>
            <tr> 
              <th>&nbsp;系统文件夹<br> <font color="#666666">&nbsp;System 
                Directory</font></th>
              <td>&nbsp;<%=Environment.SystemDirectory.ToString()%></td>
              <th>&nbsp;运行时长<br> 
                <font color="#666666">&nbsp;TickCount</font></th>
              <td>&nbsp;<%=Math.round(Environment.TickCount/600/60)/100%> 小时</td>
            </tr>
            <tr> 
              <th> &nbsp;信息服务软件<br> <font color="#666666">&nbsp;Server 
                Software</font></th>
              <td colspan="3">&nbsp;<%=Request.ServerVariables("SERVER_SOFTWARE")%> 
                ( .NET RTL 版本: <%=Environment.Version%> ) </td>
            </tr>
            <tr> 
              <th>&nbsp;当前用户<br>
                <font color="#666666">&nbsp;Current User</font></th>
              <td>&nbsp;<span class="td1o21"><%=Environment.UserName%></span></td>
              <th>&nbsp;当前文件夹<br> <font color="#666666">&nbsp;Current 
                Directory</font></th>
              <td>&nbsp;<%=Environment.CurrentDirectory.ToString()%></td>
            </tr>
            <tr> 
              <th>&nbsp;完整地址<br> <font color="#666666">&nbsp;URL 
                &amp; Path</font></th>
              <td colspan="3">&nbsp; 
                <%
					var sHostName = Request.ServerVariables("HTTP_HOST")
					var sPostNo = Request.ServerVariables("SERVER_PORT ")
					var sUrl = Request.ServerVariables("URL")
					Response.Write("http://" + sHostName + (sPostNo=='80'?'':sPostNo) + sUrl)
				%>
                <br> &nbsp; <%=Request.ServerVariables("PATH_TRANSLATED")%> </td>
            </tr>
            <tr> 
              <th> &nbsp;相对路径<br> <font color="#666666">&nbsp;Path 
                Info</font></th>
              <td colspan="3"> 
                &nbsp;<%=Request.ServerVariables("PATH_INFO")%>  </td>
             </tr>
             <tr>
              <th> &nbsp;物理路径<br> <font color="#666666">&nbsp;Physical 
                Path</font></th>
              <td colspan="3">	
                &nbsp;<%=Request.ServerVariables("APPL_PHYSICAL_PATH")%> 
              </td>
            </tr>
            <tr> 
              <th> &nbsp;脚本引擎<br> <font color="#666666">&nbsp;ScriptEngine</font></th>
              <td colspan="3" nowrap id="divScriptEngine"> &nbsp;JScript 
                / <%=ScriptEngineMajorVersion() +"." + ScriptEngineMinorVersion() +"." + ScriptEngineBuildVersion() + " "%></td>
            </tr>
            <tr> 
              <th> &nbsp;脚本超时<br> <font color="#666666">&nbsp;script 
                Timeout</font></th>
              <td nowrap>&nbsp;<%=Server.ScriptTimeout%> 秒</td>
              <th>&nbsp;当前会话编号<br>
                <font color="#666666">&nbsp;Session ID</font></th>
              <td>&nbsp;<%=Session.SessionID%></td>
            </tr>
            <tr> 
              <th>&nbsp;本页命令行<br> <font color="#666666">&nbsp;Command Line</font></th>
              <td colspan="3">&nbsp; <span style="width:590px;word-break:break-all"><%=Environment.CommandLine%></span> 
              </td>
            </tr>
            <tr> 
              <th> &nbsp;服务器变量数<br>
                <font color="#666666">&nbsp;Application Count</font></th>
              <td nowrap>&nbsp;<%=Application.Contents.Count%></td>
              <th>&nbsp;会话变量数<br>
                <font color="#666666">&nbsp;Session Count</font></th>
              <td>&nbsp;<%=Session.Contents.Count%> </td>
            </tr>
          </table>
    </td>
  </tr>
  <tr> 
    <td height="5" class="tr1"></td>
  </tr>
</table>
<br/>
<table width="100%" border="0" cellpadding="1" cellspacing="1">
  <tr> 
    <td bgcolor="#F8F9FC">
       <table width="100%" border="0" cellpadding="3" cellspacing="1" class="tableForm">
          <tr>
             <td colspan="3"><b>服务器组件信息 :::...</b></td>
          </tr>
      
          <tr> 
            <td class="tit">&nbsp;组件名</td>
            <td width="10%" align="center"  class="tit">支持</td>
            <td width="10%" align="center"  class="tit">版本</td>
         </tr>
        <%
			var iIndex, sObjName, sObjDetail, sObjType='', iIndexCount, bShowUnSupport;
			var sObjVersion,bObjInstalled;
			iIndex = 0;
			iIndexCount = -1;
			bShowUnSupport = false;
			for(var i=0;;i++){
				if(i>=arrObj.length||iIndex!=arrObj[i][2]){
					if(iIndexCount==0&&iIndex<99){
						Response.Write(
							'<tr>\n'+
							'<td width="80%" bgcolor="#D5D5D5" style="color:#666666;" colspan="3"> &nbsp;<i>( 服务器暂不支持该类组件 )</i></td>\n'+
							'</tr>\n'
						);
					}
					if(i>=arrObj.length) break;
					iIndex=arrObj[i][2];
					iIndexCount=0;
					switch(iIndex){
						case 1: sObjType = "IIS自带组件"; break;
						case 2: sObjType = "常见的第三方文件上传和管理组件"; break;
						case 3: sObjType = "常见的第三方文件邮件发送组件"; break;
						case 4: sObjType = "常见的图像处理组件"; break;
						default: sObjType = "自定义组件"; break;
					}
					Response.Write(
						'<tr>\n'+
						'<td colspan="3"> &nbsp;■<b> '+sObjType+'</b></td>\n'+
						'</tr>\n'
					);
        		} 
				sObjName = arrObj[i][0]
				sObjDetail = arrObj[i][1];
				bObjInstalled = true;
				sObjVersion = getObjVer(sObjName);
				if(sObjVersion=="N/A"){
					bObjInstalled = false;
					sObjVersion = "";
				}
				
				if(bObjInstalled||iIndex==99){
					iIndexCount++;
					Response.Write(
						'<tr>\n'+
						'<th width="40%" style="text-align:left">'+
						' &nbsp;' + sObjName + (sObjDetail?' <font color="#666666">( ' + sObjDetail + ' )</font>':'') + '\n' +
						'</th>\n'+
						'<td width="20%" align="center">' + (bObjInstalled?"√":"×") + '</td>\n' +
						'<td width="40%" align="center">>' + sObjVersion + '</td>\n' +
						'</tr>\n'
					);
				}
        	} 
		%>            
      </table>
      </td>
  </tr>
  <tr> 
    <td height="5" class="tr1"></td>
  </tr>
</table>
<br>
  <% //if(bShowDetail){ %>

 <table width="100%" border="0" cellpadding="3" cellspacing="1" class="tableForm">
	    <tr>
	       <td colspan="2"><b>服务器端环境变量列表 :::...</b></td>
	     </tr>
          <tr> 
            <td width="30%"  class="tit"><font color="#5C72BA">&nbsp;</font>项目</td>
            <td class="tit"> <font color="#5C72BA">&nbsp;</font>值</td>
          </tr>
		  <%
		  	try{
		  	var WshShell;
		  	WshShell = Server.CreateObject("WScript.Shell");
		  %>
		  <% for(x in WshShell.Environment){ %>
          <tr> 
            <th>&nbsp;<%=x.substr(0,x.indexOf("="))%></th>
            <td style="padding: 7px;"><%=x.substr(x.indexOf("=")+1)%></td>
          </tr>
		  <% } %>
		  <% }catch(e){}%>
		  <% for(x in Request.ServerVariables){ %>
          <tr> 
            <th>&nbsp;<%=x%></th>
            <td style="padding: 7px;"><%=Request.ServerVariables(x)%></td>
          </tr>
		  <% } %>
</table>
    <br>
  <% //} %>
</div>

<table width="750" border="0" cellpadding="3" cellspacing="1" class="tbl1" id="divNoASP" style="display:none">
  <tr> 
    <td class="tr1"> <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr> 
          <td>&nbsp;<font color="#FFFFFF" face="webdings">8</font><font color="#FFFFFF" face="Verdana, Arial, Helvetica, sans-serif"> 
            <strong>其它信息 :::...</strong></font></td>
          <td align="right"><font color="#FFFAF7">Coding by Sunrise_Chen.&nbsp;</font></td>
        </tr>
      </table></td>
  </tr>
  <tr> 
    <td bgcolor="#F8F9FC"> <table width="100%" border="0" cellpadding="3" cellspacing="1" class="tbl1o1">
        <tr> 
            <td width="60%" class="td1">&nbsp;信息描述</td>
        </tr>
        <tr> 
            <td width="60%" class="td1o1" id="divErrorMessage"></td>
        </tr>
      </table></td>
  </tr>
  <tr> 
    <td height="5" class="tr1"></td>
  </tr>
</table>

</div>

<!--测试是否支持服务器脚本-->
<%="<div id='chkAspSupport'></div>"%> 
<script type="text/javascript" language="JavaScript">
	pageInit();
	if(!getObjByID("chkAspSupport"))
		sErrorMessage += "当前服务器不支持ASP.NET！<br>\n";
</script>

<script type="text/javascript" language="JavaScript">pageInit();</script>
<script type="text/javascript" id="divOperFrame"></script>

<div align="center" style="width:100%">
	<hr size="1">
	  <%="<br>本页面执行所需内存：<font color='#990000'><b>" + (Math.round(Environment.WorkingSet/1024/1024*100)/100).ToString() + "</b></FONT> KB."%>
	  <% var tPageEndTime = new Date(); %>
	  <%="执行时间：约 <font color='#990000'><b>"+((tPageEndTime-tPageStartTime)/1000)+"</b></font> 秒"%>
	 
</div>
  </body>
</html>
