Website image Scanning Class

Source: Internet
Author: User
Tags filter count table name valid
Scan.inc
<%
'************************************************'
' *********** website picture Scanner 1.00****************** '
' *********** Author: magician Yang ********************* '
' *********** Date: 2004.5.6*********************** '
' ***********qq:1168064************************** '
'************************************************'
' Description: This is my first time to write application classes, where the improper place please advise! qq:1168064
' Properties and methods
' 1, ScanType: type of scan. Default value: 1. Value: 0 scans files and databases 1 scans files 2 scans the database.
' 2, Conn,table,colimg,colid: used when scanning the database, respectively, for the connection string, table name, picture column name, picture corresponding ID column name
' 3, List: Display type. Default value: 0. Value: 0 Expiration picture 1 network Pictures 2 effective pictures 3 All
' 4, Scantext: Scanned picture type. Default value: Asp/html/htm. Value: File name extension, separated by "/" in the middle.
' 5, Path: Scanned path: default is site root, use relative path. such as "/DSJ"
' 6, Scan (): Method. Scan based on settings
' 7, File: Save the scanned information. Called after the scan () method
' 8, Folders: Number of folders scanned
' 9, Files: Number of documents scanned.
' 10, TotalSize: Total size of the catalog. Automatically displays g,m,b.
' 11, Images: Scan files in the number of pictures
' 12, Exists: Number of failures
' 13, dbimg: Number of pictures in the database
' 14, Totalimg: Scanned So the number of pictures
' 15, RunTime: The time of the scanning process. Unit milliseconds
' 16, about the use of file:
' For each Fn in Objname.file ... Next
' Fn.filename: Picture name, including path
' Fn.belong: The file or database where the picture resides (file with "|" Separate
' Fn.exists: Is it valid? 0 is invalid 1 is valid-1 is non-local path, cannot be judged.
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=http://www.163design.net/a/f/(. [ ^/>^/&]*) (. gif.jpg) "
version= "1.00"
End Sub

Private Sub Class_Terminate
Set file=nothing
Set FSO = Nothing
End Sub

Public Function Scan () ' Start scanning
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 () scans the database. The path here is difficult to judge, please change in 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= "&ColImg&" column in Table &Table& (ID: "&rs (0) &")
Insdb retstr,rebel,0, ""
Rs.movenext
Wend
Rs.close
Set rs=nothing
End If
End Sub

Private Sub scanfile (pathstr) ' scans files. Recursion
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& "\" &AMP;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,pathstr) ' Find pictures
Dim RegEx, Match, Matches,chk,reimg,retstr,rebel,thefile
Set RegEx = New RegExp



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.