|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
大家可以自己去看一看.可以说看得想呕吐.以前有次下了个动网来看.里面连基本内置函数的保护措施(函数没防御性)都没有.难怪经常补这个补那个了.可能现在.NET版会好点吧<%
判别文件名是不是正当
FunctionisFilename(aFilename)
DimsErrorStr,iNameLength,i
isFilename=TRUE
sErrorStr=Array("/","",":","*","?","""","<",">","|")
iNameLength=Len(aFilename)
IfiNameLength<1OriNameLength=nullThen
isFilename=FALSE
Else
Fori=0To8
Ifinstr(aFilename,sErrorStr(i))Then
isFilename=FALSE
EndIf
Next
EndIf
EndFunction
往失落字符串头尾的一连的回车和空格
functiontrimVBcrlf(str)
trimVBcrlf=rtrimVBcrlf(ltrimVBcrlf(str))
endfunction
往失落字符串开首的一连的回车和空格
functionltrimVBcrlf(str)
dimpos,isBlankChar
pos=1
isBlankChar=true
whileisBlankChar
ifmid(str,pos,1)=""then
pos=pos+1
elseifmid(str,pos,2)=VBcrlfthen
pos=pos+2
else
isBlankChar=false
endif
wend
ltrimVBcrlf=right(str,len(str)-pos+1)
endfunction
往失落字符串开端的一连的回车和空格
functionrtrimVBcrlf(str)
dimpos,isBlankChar
pos=len(str)
isBlankChar=true
whileisBlankCharandpos>=2
ifmid(str,pos,1)=""then
pos=pos-1
elseifmid(str,pos-1,2)=VBcrlfthen
pos=pos-2
else
isBlankChar=false
endif
wend
rtrimVBcrlf=rtrim(left(str,pos))
endfunction
判别Email是不是无效,前往1暗示准确
FunctionisEmail(aEmail)
DimiLocat,v,iLength,i,checkletter
Ifinstr(aEmail,"@")=0Orinstr(aEmail,".")=0Then
isEmail=0
EXITFUNCTION
EndIf
iLocat=instr(aEmail,"@")
Ifinstr(iLocat,aEmail,".")=0Orinstr(iLocat+1,aEmail,"@")>0Then
isEmail=0
EXITFUNCTION
EndIf
Ifleft(aEmail,1)="."Orright(aEmail,1)="."Orleft(aEmail,1)="@"Orright(aEmail,1)="@"Then
isEmail=0
EXITFUNCTION
EndIf
v="1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-.@"
iLength=len(aEmail)
Fori=1ToiLength
checkletter=mid(aEmail,i,1)
Ifinstr(v,checkletter)=0Then
isEmail=0
EXITFUNCTION
EndIf
Next
isEmail=1
EndFunction
测试用:显现服务器信息
SubshowServer
Dimname
Response.write"<Tableborder=1bordercolor=lightblueCELLSPACING=0>"
foreachnameinrequest.servervariables
Response.write"<tr>"
Response.write"<td>"&name&"</td>"
Response.write"<td>"&request.servervariables(name)&"<br></td>"
Response.write"</tr>"
next
Response.write"</table>"
EndSub
测试用:显现Rs了局集和字段称号
SubshowRs(rs)
DimstrTable,whatever
Response.write"<center><table><tr>"
foreachwhateverinrs.fields
response.write"<td><b>"&whatever.name&"</B></TD>"
next
strTable="</tr><tr><td>"&rs.GetString(,,"</td><td>","</tr><tr><td>","")&"</td></tr></table></center>"
Response.Write(strTable)
EndSub
用HTML格局显现文本
functionHTMLEncode(fString)
ifnotisnull(fString)then
fString=replace(fString,">",">")
fString=replace(fString,"<","<")
fString=Replace(fString,CHR(32),"")
fString=Replace(fString,CHR(34),""")
fString=Replace(fString,CHR(39),"")
fString=Replace(fString,CHR(13),"")
fString=Replace(fString,CHR(10)&CHR(10),"</P><P>")
fString=Replace(fString,CHR(10),"<BR>")
HTMLEncode=fString
endif
endfunction
测试用:显现调试毛病信息
SubshowError
DimsErrMsg
sErrMsg=Err.Source&""&Err.Description
Response.write"<center>"&sErrMsg&"</center>"
Err.clear
EndSub
显现笔墨计数器
SubshowCounter
Dimfs,outfile,filename,count
filename=server.mappath("count.txt")
Setfs=CreateObject("Scripting.FileSystemObject")
Iffs.fileExists(filename)Then
Setoutfile=fs.openTextFile(filename,1)
count=outfile.readline
count=count+1
Response.write"<center>扫瞄人次:"&count&"<center>"
outfile.close
Setoutfile=fs.CreateTextFile(filename)
outfile.writeline(count)
Else
Setoutfile=fs.openTextFile(filename,8,TRUE)
count=0
outfile.writeline(count)
ENDIF
outfile.close
setfs=nothing
EndSub
%>
asp,jsp,php是web开发的三大技术,asp简单易用且有microsoft做靠山,jsp功能强大是因为有java支持,php则开源跨平台.在国内,asp应用范围最广,jsp发展势头最猛,php则处于劣势.这可能与公司的支持以及技术的培训有关. |
|