導航:首頁 > IDC知識 > asp獲取伺服器系統

asp獲取伺服器系統

發布時間:2020-12-24 17:38:28

1、ASP如何獲取SQL伺服器上的當前時間

你把那個欄位的默認值設為 getdate() 就好了,新增記錄,那個欄位就會自動取當前時間了...

2、ASP、jS獲取伺服器時間和自己電腦系統時間

dt類的都有獲取當前時間的函數。getInstance(java)和currenttime(asp)就是。
但這兩個都是獲取當前電腦時間,即你的程序在哪裡運行就是獲取哪個時間。

從你的提問看你是想在客戶端運行程序並獲取自己電腦時間和伺服器時間。如果這樣的話:
1、獲取自己電腦系統時間,就可以用上面兩個函數實現,具體看你用什麼工具編程。
2、伺服器時間,建議在伺服器上建立一個服務,同樣用上面兩個函數可以得到伺服器的時間,問題的關鍵是這個服務要把你獲取的伺服器時間暴露出來,可以通過服務函數解決。

3、如何用ASP獲取瀏覽器的名稱,版本號及伺服器的埠號

操作系統:
<%=Request.ServerVariables("OS")%>
伺服器名稱:
<%=Request.ServerVariables("SERVER_NAME")%>

伺服器IP:
<%=Request.ServerVariables("LOCAL_ADDR")%>
CPU數量:
<%=Request.ServerVariables("NUMBER_OF_PROCESSORS")%>個

服務埠:
<%=Request.ServerVariables("SERVER_PORT")%>
Webserver及版本:
<%=Request.ServerVariables("SERVER_SOFTWARE")%>

腳本解釋引擎:
<%=ScriptEngine & "/"& ScriptEngineMajorVersion &"."&ScriptEngineMinorVersion&"."& ScriptEngineBuildVersion %>
服務協議及版本:
<%=Request.ServerVariables("SERVER_PROTOCOL")%>

腳本超時時間:
<%=Server.ScriptTimeout%>秒
網站物理路徑:
<%=request.ServerVariables("APPL_PHYSICAL_PATH")%>

<%
Dim BrowseMsg,BrowseVersion,SystemVersion
BrowseMsg=Request.ServerVariables("HTTP_USER_AGENT")
'+++++++++++一個基本判別操作系統的函數+++++++++++
Function SystemCheck()
if inStr(BrowseMsg,"Windows 98") then
SystemCheck="Windows 98"
else if inStr(BrowseMsg,"Windows NT 4.0") then
SystemCheck="Windows NT 4.0"
else if inStr(BrowseMsg,"Windows NT 5.0") then
SystemCheck="Windows NT 2000"
else
SystemCheck="未知類型"
end if
end if
end if
end Function
'由於時間的原因我沒有寫判定win95和windows xp的語句,感興趣的網友可以
'自行添加:)
'+++++++++++結束+++++++++++
if inStr(BrowseMsg,"MSIE") then
SystemVersion=CInt(Mid(BrowseMsg,inStr(BrowseMsg,"MSIE")+5,1))
response.write "您的瀏覽器的版本是 IE"&BrowseVersion&"<BR>"
response.write "您的操作系統是 "&SystemCheck()
end if
%>

4、ASP獲取伺服器及本地信息 代碼如何編寫

<html>
<head>
<link href="../css.css" rel="stylesheet" type="text/css">
</head>
<body>
<table width="50%" border="0" align="center" cellpadding="0" cellspacing="0" >
<tr>
<td>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#336699">
<tr bgcolor="" align="center">
<td height="20" colspan="2" class="htd" ><font color="#FFFFFF"><b>服 務 器 的 配 置</b></font></td>
</tr>
<tr>
<td width="40%" align="center" bgcolor="#336699" class="htd"><font color="#FFFFFF">檢取ISAPIDLL的metabase路徑</font></td>
<td align="center" bgcolor="#3366CC" class="htd"><font color="#FFf000"><%=Request.ServerVariables("APPL_MD_PATH")%></font></td>
</tr>
<tr>
<td width="40%" align="center" bgcolor="#336699" class="htd"><font color="#FFFFFF">路徑信息</font></td>
<td align="center" bgcolor="#3366CC" class="htd"><font color="#FFf000"><%=Request.ServerVariables("PATH_INFO")%></font></td>
</tr>
<tr>
<td width="40%" align="center" bgcolor="#336699" class="htd"><font color="#FFFFFF">伺服器IP地址</font></td>
<td align="center" bgcolor="#3366CC" class="htd"><font color="#FFf000"><%=Request.ServerVariables("LOCAL_ADDR")%></font></td>
</tr>
<tr>
<td width="40%" align="center" bgcolor="#336699" class="htd"><font color="#FFFFFF">顯示執行SCRIPT的虛擬路徑</font></td>
<td align="center" bgcolor="#3366CC" class="htd"><font color="#FFf000"><%=Request.ServerVariables("SCRIPT_NAME")%></font></td>
</tr>
<tr>
<td width="40%" align="center" bgcolor="#336699" class="htd"><font color="#FFFFFF">返回伺服器的主機名,DNS別名,或IP地址</font></td>
<td align="center" bgcolor="#3366CC" class="htd"><font color="#FFf000"><%=Request.ServerVariables("SERVER_NAME")%></font></td>
</tr>
<tr>
<td width="40%" align="center" bgcolor="#336699" class="htd"><font color="#FFFFFF">返回伺服器處理請求的埠</font></td>
<td align="center" bgcolor="#3366CC" class="htd"><font color="#FFf000"><%=Request.ServerVariables("SERVER_PORT")%></font></td>
</tr>
<tr>
<td width="40%" align="center" bgcolor="#336699" class="htd"><font color="#FFFFFF">協議的名稱和版本</font></td>
<td align="center" bgcolor="#3366CC" class="htd"><font color="#FFf000"><%=Request.ServerVariables("SERVER_PROTOCOL")%></font></td>
</tr>
<tr>
<td width="40%" align="center" bgcolor="#336699" class="htd"><font color="#FFFFFF">伺服器的名稱和版本</font></td>
<td align="center" bgcolor="#3366CC" class="htd"><font color="#FFf000"><%=Request.ServerVariables("SERVER_SOFTWARE")%></font></td>
</tr>
<tr>
<td width="40%" align="center" bgcolor="#336699" class="htd"><font color="#FFFFFF">伺服器操作系統內核</font></td>
<td align="center" bgcolor="#3366CC" class="htd"><font color="#FFf000"><%=Request.ServerVariables("OS")%></font></td>
</tr>
<tr>
<td width="40%" align="center" bgcolor="#336699" class="htd"><font color="#FFFFFF">腳本超時時間</font></td>
<td align="center" bgcolor="#3366CC" class="htd"><font color="#FFf000"><%=Server.ScriptTimeout%> 秒</font></td>
</tr>
<tr>
<td width="40%" align="center" bgcolor="#336699" class="htd"><font color="#FFFFFF">伺服器CPU數量</font></td>
<td align="center" bgcolor="#3366CC" class="htd"><font color="#FFf000"><%=Request.ServerVariables("NUMBER_OF_PROCESSORS")%> 個</font></td>
</tr>
<tr>
<td width="40%" align="center" bgcolor="#336699" class="htd"><font color="#FFFFFF">伺服器解譯引擎</font></td>
<td align="center" bgcolor="#3366CC" class="htd"><font color="#FFf000"><%=ScriptEngine & "/"& ScriptEngineMajorVersion &"."&ScriptEngineMinorVersion&"."& ScriptEngineBuildVersion %></font></td>
</tr>
</table>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" >
<tr>
<td height="20" colspan="2" align="center">

</td>
</tr>
<tr>
<td height="20" colspan="2" class="htd" align="center" bgcolor="#336699">
<font color="#FFFFFF"><b>瀏 覽 器 信 息</b></font>
</td>
</tr>
<tr>
<td height="20" colspan="2" align="center" bgcolor="#336699">
<%set browscap=server.createobject("mswc.browsertype")%>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" >
<tr><td width="40%" align="center" class="htd"><font color="#FFFFFF">瀏覽器類型</font></td>
<td align="center" bgcolor="#3366CC" class="htd"><font color="#FFf000"><%=browscap.browser%></font></td></tr>
<tr><td width="40%" align="center" class="htd"><font color="#FFFFFF">瀏覽器版本</font></td>
<td align="center" bgcolor="#3366CC" class="htd"><font color="#FFf000"><%=browscap.version%></font></td></tr>
<tr><td width="40%" align="center" class="htd"><font color="#FFFFFF">是否支持表格</font></td>
<td align="center" bgcolor="#3366CC" class="htd"><font color="#FFf000"><%=browscap.tables%></font></td></tr>
<tr><td width="40%" align="center" class="htd"><font color="#FFFFFF">是否支持ActiveX控制項</font></td>
<td align="center" bgcolor="#3366CC" class="htd"><font color="#FFf000"><%=browscap.activexcontrols%></font></td></tr>
<tr><td width="40%" align="center" class="htd"><font color="#FFFFFF">是否支持JavaApplets</font></td>
<td align="center" bgcolor="#3366CC" class="htd"><font color="#FFf000"><%=browscap.javaapplets%></font></td></tr>
<tr><td width="40%" align="center" class="htd"><font color="#FFFFFF">是否支持Javascript</font></td>
<td align="center" bgcolor="#3366CC" class="htd"><font color="#FFf000"><%=browscap.javascript%></font></td></tr>
<tr><td width="40%" align="center" class="htd"><font color="#FFFFFF">是否支持Cookies</font></td>
<td align="center" bgcolor="#3366CC" class="htd"><font color="#FFf000"><%=browscap.cookies%></font></td></tr>
<tr><td width="40%" align="center" class="htd"><font color="#FFFFFF">是否支持框架</font></td>
<td align="center" bgcolor="#3366CC" class="htd"><font color="#FFf000"><%=browscap.frames%></font></td></tr>
<tr><td width="40%" align="center" class="htd"><font color="#FFFFFF">是否支持VBScript</font></td>
<td align="center" bgcolor="#3366CC" class="htd"><font color="#FFf000"><%=browscap.vbscript%></font></td></tr>
</table>
<%set browscap=nothing%>
</td>
</tr>
</table>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" >
<tr>
<td height="20" colspan="2" align="center">

</td>
</tr>
<tr>
<td height="20" colspan="2" class="htd" align="center" bgcolor="#336699">
<font color="#FFFFFF"><b>磁 盤 驅 動 器 信 息</b></font>
</td>
</tr>
<tr>
<td height="20" colspan="2" >
<%
function tran(driver)
select case driver
case 0:tran="設備無法識別"
case 1:tran="軟盤驅動器"
case 2:tran="硬碟驅動器"
case 3:tran="網路硬碟驅動器"
case 4:tran="光碟驅動器"
case 5:tran="RAM虛擬磁碟"
end select
end function
set fso=server.createobject("scripting.filesystemobject")
%>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#336699">
<tr><td class="htd" align="center"><font color="#FFFFFF">盤符</font></td><td class="htd" align="center"><font color="#FFFFFF">類型</font></td><td class="htd" align="center"><font color="#FFFFFF">卷標</font></td>
<td class="htd" align="center"><font color="#FFFFFF" >總計大小</font></td><td class="htd" align="center"><font color="#FFFFFF">可用空間</font></td><td class="htd" align="center"><font color="#FFFFFF">文件系統</font></td>
<td class="htd" align="center"><font color="#FFFFFF">序列號</font></td><td class="htd" align="center"><font color="#FFFFFF">是否可用</font></td><td class="htd" align="center"><font color="#FFFFFF">路徑</font></td>
</tr>
<%
for each drv in fso.drives
response.write"<tr>"
response.write"<td class=htd align=center bgcolor=#3366CC><font color=#FFf000>" & drv.driveletter &"</font></td>"
response.write"<td class=htd align=center bgcolor=#3366CC><font color=#FFf000>" & tran(drv.drivetype) &"</font></td>"
response.write"<td class=htd align=center bgcolor=#3366CC><font color=#FFf000>" & drv.volumename &"</font></td>"
response.write"<td class=htd align=center bgcolor=#3366CC><font color=#FFf000>" & formatnumber(drv.totalsize/1024,0) &"</font></td>"
response.write"<td class=htd align=center bgcolor=#3366CC><font color=#FFf000>" & formatnumber(drv.availablespace/1024,0) &"</font></td>"
response.write"<td class=htd align=center bgcolor=#3366CC><font color=#FFf000>" & drv.filesystem &"</font></td>"
response.write"<td class=htd align=center bgcolor=#3366CC><font color=#FFf000>" & drv.serialnumber &"</font></td>"
response.write"<td class=htd align=center bgcolor=#3366CC><font color=#FFf000>" & drv.isready &"</font></td>"
response.write"<td class=htd align=center bgcolor=#3366CC><font color=#FFf000>" & drv.path &"</font></td>"
next
%>
</table>
</td>
</tr>
</table>

</td>
</tr>
</table>
</body>
</html>

5、asp獲取伺服器時間

方法很多,大致有:

1、獲取客戶端時間,與當前伺服器時間,進行比較,若時間存在過大差值,回則停止後續服務答與代碼
2、全部改用伺服器時間,這樣代碼修改量估計不小,還容易存在BUG
3、核心業務處加上時間校驗,其他的無所謂吧
由於看不到源代碼,只能幫到這個地步了

6、asp伺服器端如何獲取文本框的值

把文本框放在表單里,給文本框取名比如「aaa」

獲取值的頁面在代碼里寫:
<%
a=request("aaa")'獲取前面提交過來aaa的值
response.write(a)'列印aaa的值
%>

Request對象探討

Request是ASP里的一個內部對象,用於獲取HTTP請求中傳遞的任意信息(如頭信息、表單數據、cookies等等)。所以這是在ASP裡面最常用的內部對象,常用來獲得GET方式提交的數據(Request.QueryString)、表單POST提交的數據(Request. Form)和Cookies(Request.Cookies)。

我們用Request對象可以指定獲取某個特定方式提交的數據。比如我們用這段代碼獲得通過POST提交的數據lake2的值:request.Form("lake2");而request.queryString("CSDN")獲得GET方式提交的CSDN的值。

對於獲取HTTP數據,ASP還給了我們一個更簡單的方法:request(key),即直接使用request而不指定數據集合。此時ASP會依次在QueryString、From、Cookies、ServerVariables、ClientCertificate、Browser中檢查匹配的數據,若發現則返回數據。

上面6個集合中,ServerVariables、ClientCertificate和Browser的變數是固定了的;而QueryString、From、Cookies的變數可以任意指定。想不到Cookies可以拿來傳遞任意數據,以前倒沒有注意。

OK,test一下先。在本地web目錄新建test.asp文件,內容為:<%=request("b")%>

Step 1:直接訪問http://127.0.0.1/test.asp?b=la<b>k</b>e2,瀏覽器顯示lake2

Step 2:構造表單提交結果也如step 1

Step 3: 構造表單,GET傳遞b值為"He",同時POST的b為"She",瀏覽器顯示為"He"。呵呵,按前面的排序有個優先順序的

Step 4:Telnet到本地80埠,構造HTTP請求如下(注意Cookies哦):

GET /test.asp HTTP/1.1
Accept: */*
Accept-Language: zh-cn
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; TencentTraveler ; .NET CLR 1.1.4322)
Host: 127.0.0.1
Connection: Keep-Alive
Cookie: b=lake2 , Success !
在一堆伺服器響應數據之後,我們看到了"lake2,Success!"(Q:為什麼空格不見了?A:因為未對提交的空格進行URL編碼)。

到此,我們已理論和實際相結合的證明了Cookies可以拿來傳遞數據。

7、asp 獲取伺服器字體

一般不用這樣做.實現的可能性也不大.

放法是用FSO來讀取winnt/font目錄下的文件.
再人工看一內下裡面安裝了什麼字容體,再在程序里使用已安裝的字體.
只是前體條件是你的伺服器支持FSO,並且你有足夠的許可權.

一般做法是使用常見字體,如果你實現想用特別字體就跟伺服器空間提供商商量一下,應該也可以.

其實一般伺服器其本上都不會裝什麼字體,都是系統默認的一些字體.你用這些就好了,如:
黑體,宋體,訪宋體,楷體,隸書

8、ASP伺服器IP地址獲取

老兄這不是來重復,你前面那個127.0.0.1其實自就是localhost,可能你電腦設置了什麼吧,通常情況下是這樣顯示的http://localhost/127.0.0.1

後面那個才是你用代碼獲取的。

9、asp如何獲得伺服器所在的時區?

根據我的經驗哈,你的伺服器通常只有一個,不可能今天是這個時區,明天是那個時區,直接顯示當前時間,然後和北京時間比,差多少時間,後面在計算的時候補上。

凡是需要放到國外的程序,都應該增加一個時間調節常量。放在國內設為0,放到美國西部設為+16.凡是遇到時間的地方都增加一下時間調節常量。

10、asp 獲取伺服器端操作系統信息

伺服器操作系統:<%=Request.ServerVariables("OS")%>
伺服器的名稱和版本:<%=Request.ServerVariables("SERVER_SOFTWARE")%>
是這個

與asp獲取伺服器系統相關的知識