日期:2009-11-01 浏览次数:21044 次
'判断文件类型是否合格
Private Function CheckFileExt (fileEXT)
dim Forumupload
Forumupload="gif,jpg,bmp,jpeg"
Forumupload=split(Forumupload,",")
for i=0 to ubound(Forumupload)
if lcase(fileEXT)=lcase(trim(Forumupload(i))) then
CheckFileExt=true
exit Function
else
CheckFileExt=false
end if
next
End Function
‘验证文件内容的合法性
set MyFile = server.CreateObject ("Scripting.FileSystemObject")
set MyText = MyFile.OpenTextFile (sFile, 1) ' 读取文本文件
sTextAll = lcase(MyText.ReadAll): MyText.close
'判断用户文件中的危险操作
sStr ="8 .getfolder .createfolder .deletefolder .createdirectory
.deletedirectory"
sStr = sStr & " .saveas wscript.shell script.encode"
sNoString = split(sStr," ")
for i = 1 to sNoString(0)
if instr(sTextAll, sNoString(i)) <> 0 then
sFile = Upl.Path & sFileSave: fs.DeleteFile sFile
Response.write "<center><br><big>"& sFileSave &"文件中含有与操作目录等有关的命令"&_
"<br><font color=red>"& mid(sNoString(i),2) &"</font>,为了安全原因,<b>不能上传。<b>"&_"</big></center></HTML>"
Response.end
end if
next