puzhibing
2024-02-05 640ff18d2d7f4be02ddb7f8f75e899f05545eb98
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<!--#include file="ASPJson.class.asp"-->
<!--#include file="config_loader.asp"-->
 
<%
    listTemplateName = Session.Value("ueditor_asp_listTemplateName")
 
    start = CInt(Request.Item("start"))
    size = CInt(Request.Item("size"))
    total = 0
 
    If size < 0 Then
        size = CInt(config.Item( listTemplateName + "ManagerListSize" ))
    End If
 
    path = config.Item( listTemplateName + "ManagerListPath" )
    Set extensions = config.Item( listTemplateName + "ManagerAllowFiles")
 
    Set list = new ASPJson.Collection
 
    Set fso = Server.CreateObject("Scripting.FileSystemObject")
    If fso.FolderExists(Server.MapPath(path)) = False Then
        state = "找不到目录:" + path
    Else
        Set all = ListAllFilesInFolder( fso, path )
        total = all.Count
        index = 0
        For Each file in all
            If index >= start And index < start + size Then
                Dim fileObject
                Set fileObject = new ASPJson.Collection
                fileObject.Add "url", file
                list.Add index - start, fileObject
            End If
            index = index + 1
        Next
        state = "SUCCESS"
    End If
    
    Set json = new ASPJson
    With json.data
        .Add "state", state
        .Add "list", list
        .Add "start", start
        .Add "size", size
        .Add "total", total
    End With
 
    json.PrintJson()
 
    Function ListAllFilesInFolder( fso, path )
        Dim list
        Set list = Server.CreateObject("Scripting.Dictionary")
        Set folder = fso.GetFolder(Server.MapPath(path))
        For Each file In folder.Files
            If CheckExt(file.Name) Then
                list.Add path & "/" & file.Name, true
            End If
        Next
        For Each subFolder In folder.SubFolders
            Set subList = ListAllFilesInFolder( fso, path & "/" & subFolder.Name )
            For Each subListFile In subList
                list.Add subListFile, true
            Next
        Next
        Set ListAllFilesInFolder = list
    End Function
 
    Function CheckExt( filename )
        For Each ext In extensions
            If UCase(GetExt(filename)) = UCase(extensions.Item(ext)) Then 
                CheckExt = true
                Exit Function
            End If
        Next
        CheckExt = false
    End Function
    
    Function GetExt( file )
        GetExt = Right( file, Len(file) - InStrRev(file, ".") + 1 )
    End Function
%>