ASP判断文件地址是否有效!

2008-02-23 05:31:30来源:互联网 阅读 ()

新老客户大回馈,云服务器低至5折

<%
'原创作者:小艺 QQ:52093 时间:2005.6.30
Response.Write("<head><style><!--span{ font-size: 9pt }--></style></head>")
On Error Resume Next
Dim thisurl,thistext
thisurl=Request("thisurl") '定义文件地址(非Html格式文档)!
if thisurl="" then
Response.Write("<span>请先输入文件地址!</span>")
Response.End
End if

Function objxmlhttp(xmlurl)
On Error Resume Next
Set objxml = CreateObject("Microsoft.XMLHTTP")
objxml.Open "get",xmlurl,false
objxml.setrequestheader "content-type","application/x-www-form-urlencoded"
objxml.send
objxmlhttp = objxml.responsebody
if Err then
Err.Clear
Response.Write("<span>建立连接失败,文件不存在或网络有问题!;错误原因:"&Err.Description&"!</span>")
Response.End
End if
End Function
'www.knowsky.com
Function bytes2BSTR(vIn)
strReturn = ""
For i = 1 To LenB(vIn)
ThisCharCode = AscB(MidB(vIn,i,1))
If ThisCharCode < &H80 Then
strReturn = strReturn & Chr(ThisCharCode)
Else
NextCharCode = AscB(MidB(vIn,i 1,1))
strReturn = strReturn & Chr(CLng(ThisCharCode) * &H100 CInt(NextCharCode))
i = i 1
End If
Next
bytes2BSTR = strReturn
End Function

thisurl2=Split(thisurl,",")
For Each ii In thisurl2
thistext=bytes2BSTR(objxmlhttp(ii))
if InStr(thistext,"<html>")<>0 then
Response.Write("<span>"& ii &" <b>×</b></span><br>")
Else
Response.Write("<span>"& ii &" <b>√</b></span><br>")
End if
Next

if Err then
Err.Clear
Response.Write("<span>碰到意外!;错误原因:"&Err.Description&"!</span>")
Response.End
End if
%>

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:一个比较实用的asp函数集合类

下一篇:用VB将ASP代码封装成DLL