当前位置: 首页 > 图文教程 > 网络编程 > ASP > 网站图片扫描类

ASP
asp生成三维饼图的函数
ASP下的简洁的多重查询的方法与函数 真不错
发一个ASP的ADODB类代码
A利用ASP小偷和Google实现在线翻译功能的代码
ASP类型网站结合动网论坛会员的方法
Asp下实现多表单域无组件文件上传的实例
asp制作中常用到的函数库集合
易心asp分页类 v1.0
asp中xmlhttp组件发包
检测是否为数字类型的asp代码
可以获得文件的文件名的asp函数
用asp实现访问远程计算机上MDB access数据库文件的方法
用ASP实现写IIS日志的代码
asp在IE浏览器中下载服务端上的各类文件的实现方法
asp汉字中文图片验证码的实现代码
asp WAP获取手机终端信息的一段代码
asp取得数组中的最大值的方法
用asp实现的截取指定格式字符串的代码
asp jmail发邮件 详细解析
ASP编程中连接数据库和数据库操作的常用代码

ASP 中的 网站图片扫描类


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 166 ::
收藏到网摘: n/a

 

Scan.inc
<%
'说明:这是我第一次编写应用类,其中不当之处请多多指教!QQ:1168064
'属性和方法
'1、ScanType:扫描的类型。默认值:1。值:0 扫描文件和数据库 1 扫描文件 2 扫描数据库。
'2、Conn,Table,ColImg,ColID:当扫描数据库时用到,分别为连接字符串、表名、图片列名、图片对应的ID列名
'3、List:显示类型。默认值:0。值:0 失效图片 1 网络图片  2 有效图片 3 所有
'4、ScanText:扫描的图片类型。默认值:Asp/html/htm。值:文件扩展名,中间用"/"分隔。
'5、Path:扫描的路径:默认为网站根目录,请使用相对路径。例如"/dsj"
'6、Scan():方法。根据设置进行扫描
'7、File:保存扫描的所以信息。在Scan()方法后调用
'8、Folders:扫描的文件夹个数
'9、Files:扫描的文件数。
'10、TotalSize:目录的总计大小。自动显示G,M,B。
'11、Images:扫描文件中的图片个数
'12、Exists:失效个数
'13、DbImg:数据库中图片个数
'14、TotalImg:扫描的所以图片个数
'15、RunTime:扫描过程的时间。单位毫秒
'16、关于File的使用:
'    For Each Fn In ObjName.file …… Next
'    Fn.FileName:图片名称,包含路径
'    Fn.Belong:图片所在文件或数据库(文件用"|"分开)
'    Fn.Exists:是否有效。0为失效 1 为有效 -1为非本地路径,不能判断。
Option Explicit
Class MCScanImg
dim  File,ScanType,Conn,Table,ColId,ColImg,FSO,Path,List,ScanText,Spath,Version
dim Folders,Files,TotalSize,Images,Exists,sFiles,Start,EndT,RunTime,DbImg,TotalImg,Filter
Private Sub Class_Initialize
Set File = Server.Createobject("Scripting.Dictionary")
Set FSO = CreateObject("Scripting.FileSystemObject")
ScanType=1
Conn=""
Table=""
ColImg=""
ColId=""
Path ="/"
sPath = Server.MapPath("/")
List=0
ScanText="asp/htm/html"
Folders=0
Files=0
TotalSize=0
Images=0
DbImg=0
Exists=0
sFiles=0
TotalImg=0
Start=Timer
Endt=Timer
Runtime=0
Filter="src="/upload/tech/20091103/20091103100121_a0a080f42e6f13b3a2df133f073095dd.jpg")"
Version="1.00"
End Sub

Private Sub Class_Terminate 
Set File=Nothing
Set FSO = Nothing
End Sub

Public Function Scan() '开始扫描
if left(path,1)="/" then
path=Spath&Replace(path,"/","\")
else
Path=Spath&"\"&Replace(path,"/","\")
end if
If ScanType=1 then
Scanfile(Path)
ElseIf ScanType=2 Then
ScanDb()
Else
ScanFile(Path)
ScanDb()
End If
EndT=timer
RunTime=FormatNumber(EndT-Start)*1000
TotalSize=shb(TotalSize)
TotalImg=DbImg+Images
End Function

Private Sub ScanDB() '扫描数据库。这里的路径难于判断,请在InsDb中更改(If AddNum=0 后)
Dim Rs,RetStr,ReBel,SQL
SQL="Select "&ColID&","&ColIMG&" From "&Table&" Order by "&ColID&" DESC"
'On Error Resume Next
If Conn ="" OR Table="" OR ColID="" OR ColIMG = "" Then
Exit Sub
Else
Set Rs = Server.CreateObject("ADODB.RecordSet")
Rs.Open SQL,conn,3,3

While Not Rs.EOF
RetStr=Rs(1)
ReBel="表"&Table&"中的"&ColImg&"列(ID:"&Rs(0)&")"
InsDb RetStr,ReBel,0,""
Rs.MoveNext
Wend
Rs.Close
Set Rs=Nothing
End If
End Sub

Private Sub ScanFile(PathStr) '扫描文件。递归
Dim f,ff,fn,fd,fdn,RealPath,fr,fc
'Response.write PathStr&"<br>"
Set ff = fso.getfolder(pathstr)
Set f = ff.files
Set fd = ff.subfolders
If f.Count >0 Then
For Each fn In f
Files=Files+1
TotalSize=TotalSize+fn.Size
If ChkFileName(fn.Name) Then
sFiles=sFiles+1
If Right(PathStr,1) <> "\" Then
RealPath=PathStr&"\"&fn.Name
Else
RealPath=PathStr&fn.Name
End If
Set fr = FSO.OpenTextFile(RealPath,1)
fc=fr.ReadAll
'response.write RealPath&"<br>"
RegExpTest filter,fc,RealPath
End If
Next
End If

If fd.Count> 0 Then
For Each fdn In fd
Folders=Folders+1
dim temp
if right (PathStr,1) <> "\" then
temp=PathStr&"\"&fdn.Name
else
temp=PathStr&fdn.Name
end if
ScanFile(temp)
Next
End If
End Sub

Private Sub RegExpTest(Patrn, Strng