~ubuntu-branches/ubuntu/natty/moin/natty-updates

« back to all changes in this revision

Viewing changes to MoinMoin/web/static/htdocs/applets/FCKeditor/editor/filemanager/connectors/asp/commands.asp

  • Committer: Bazaar Package Importer
  • Author(s): Jonas Smedegaard
  • Date: 2008-06-22 21:17:13 UTC
  • mto: This revision was merged to the branch mainline in revision 18.
  • Revision ID: james.westby@ubuntu.com-20080622211713-inlv5k4eifxckelr
Import upstream version 1.7.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<%
2
 
 ' FCKeditor - The text editor for Internet - http://www.fckeditor.net
3
 
 ' Copyright (C) 2003-2010 Frederico Caldeira Knabben
4
 
 '
5
 
 ' == BEGIN LICENSE ==
6
 
 '
7
 
 ' Licensed under the terms of any of the following licenses at your
8
 
 ' choice:
9
 
 '
10
 
 '  - GNU General Public License Version 2 or later (the "GPL")
11
 
 '    http://www.gnu.org/licenses/gpl.html
12
 
 '
13
 
 '  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
14
 
 '    http://www.gnu.org/licenses/lgpl.html
15
 
 '
16
 
 '  - Mozilla Public License Version 1.1 or later (the "MPL")
17
 
 '    http://www.mozilla.org/MPL/MPL-1.1.html
18
 
 '
19
 
 ' == END LICENSE ==
20
 
 '
21
 
 ' This file include the functions that handle the Command requests
22
 
 ' in the ASP Connector.
23
 
%>
24
 
<%
25
 
Sub GetFolders( resourceType, currentFolder )
26
 
        ' Map the virtual path to the local server path.
27
 
        Dim sServerDir
28
 
        sServerDir = ServerMapFolder( resourceType, currentFolder, "GetFolders" )
29
 
 
30
 
        ' Open the "Folders" node.
31
 
        Response.Write "<Folders>"
32
 
 
33
 
        Dim oFSO, oCurrentFolder, oFolders, oFolder
34
 
        Set oFSO = Server.CreateObject( "Scripting.FileSystemObject" )
35
 
        if not (oFSO.FolderExists( sServerDir ) ) then
36
 
                Set oFSO = Nothing
37
 
                SendError 102, currentFolder
38
 
        end if
39
 
 
40
 
        Set oCurrentFolder = oFSO.GetFolder( sServerDir )
41
 
        Set oFolders = oCurrentFolder.SubFolders
42
 
 
43
 
        For Each oFolder in oFolders
44
 
                Response.Write "<Folder name=""" & ConvertToXmlAttribute( oFolder.name ) & """ />"
45
 
        Next
46
 
 
47
 
        Set oFSO = Nothing
48
 
 
49
 
        ' Close the "Folders" node.
50
 
        Response.Write "</Folders>"
51
 
End Sub
52
 
 
53
 
Sub GetFoldersAndFiles( resourceType, currentFolder )
54
 
        ' Map the virtual path to the local server path.
55
 
        Dim sServerDir
56
 
        sServerDir = ServerMapFolder( resourceType, currentFolder, "GetFoldersAndFiles" )
57
 
 
58
 
        Dim oFSO, oCurrentFolder, oFolders, oFolder, oFiles, oFile
59
 
        Set oFSO = Server.CreateObject( "Scripting.FileSystemObject" )
60
 
        if not (oFSO.FolderExists( sServerDir ) ) then
61
 
                Set oFSO = Nothing
62
 
                SendError 102, currentFolder
63
 
        end if
64
 
 
65
 
        Set oCurrentFolder = oFSO.GetFolder( sServerDir )
66
 
        Set oFolders    = oCurrentFolder.SubFolders
67
 
        Set oFiles              = oCurrentFolder.Files
68
 
 
69
 
        ' Open the "Folders" node.
70
 
        Response.Write "<Folders>"
71
 
 
72
 
        For Each oFolder in oFolders
73
 
                Response.Write "<Folder name=""" & ConvertToXmlAttribute( oFolder.name ) & """ />"
74
 
        Next
75
 
 
76
 
        ' Close the "Folders" node.
77
 
        Response.Write "</Folders>"
78
 
 
79
 
        ' Open the "Files" node.
80
 
        Response.Write "<Files>"
81
 
 
82
 
        For Each oFile in oFiles
83
 
                Dim iFileSize
84
 
                iFileSize = Round( oFile.size / 1024 )
85
 
                If ( iFileSize < 1 AND oFile.size <> 0 ) Then iFileSize = 1
86
 
 
87
 
                Response.Write "<File name=""" & ConvertToXmlAttribute( oFile.name ) & """ size=""" & iFileSize & """ />"
88
 
        Next
89
 
 
90
 
        ' Close the "Files" node.
91
 
        Response.Write "</Files>"
92
 
End Sub
93
 
 
94
 
Sub CreateFolder( resourceType, currentFolder )
95
 
        Dim sErrorNumber
96
 
 
97
 
        Dim sNewFolderName
98
 
        sNewFolderName = Request.QueryString( "NewFolderName" )
99
 
        sNewFolderName = SanitizeFolderName( sNewFolderName )
100
 
 
101
 
        If ( sNewFolderName = "" OR InStr( 1, sNewFolderName, ".." ) > 0  ) Then
102
 
                sErrorNumber = "102"
103
 
        Else
104
 
                ' Map the virtual path to the local server path of the current folder.
105
 
                Dim sServerDir
106
 
                sServerDir = ServerMapFolder( resourceType, CombineLocalPaths(currentFolder, sNewFolderName), "CreateFolder" )
107
 
 
108
 
                On Error Resume Next
109
 
 
110
 
                CreateServerFolder sServerDir
111
 
 
112
 
                Dim iErrNumber, sErrDescription
113
 
                iErrNumber              = err.number
114
 
                sErrDescription = err.Description
115
 
 
116
 
                On Error Goto 0
117
 
 
118
 
                Select Case iErrNumber
119
 
                        Case 0
120
 
                                sErrorNumber = "0"
121
 
                        Case 52
122
 
                                sErrorNumber = "102"    ' Invalid Folder Name.
123
 
                        Case 70
124
 
                                sErrorNumber = "103"    ' Security Error.
125
 
                        Case 76
126
 
                                sErrorNumber = "102"    ' Path too long.
127
 
                        Case Else
128
 
                                sErrorNumber = "110"
129
 
                End Select
130
 
        End If
131
 
 
132
 
        ' Create the "Error" node.
133
 
        Response.Write "<Error number=""" & sErrorNumber & """ />"
134
 
End Sub
135
 
 
136
 
Sub FileUpload( resourceType, currentFolder, sCommand )
137
 
        Dim oUploader
138
 
        Set oUploader = New NetRube_Upload
139
 
        oUploader.MaxSize       = 0
140
 
        oUploader.Allowed       = ConfigAllowedExtensions.Item( resourceType )
141
 
        oUploader.Denied        = ConfigDeniedExtensions.Item( resourceType )
142
 
        oUploader.HtmlExtensions = ConfigHtmlExtensions
143
 
        oUploader.GetData
144
 
 
145
 
        Dim sErrorNumber
146
 
        sErrorNumber = "0"
147
 
 
148
 
        Dim sFileName, sOriginalFileName, sExtension
149
 
        sFileName = ""
150
 
 
151
 
        If oUploader.ErrNum > 0 Then
152
 
                sErrorNumber = "202"
153
 
        Else
154
 
                ' Map the virtual path to the local server path.
155
 
                Dim sServerDir
156
 
                sServerDir = ServerMapFolder( resourceType, currentFolder, sCommand )
157
 
 
158
 
                Dim oFSO
159
 
                Set oFSO = Server.CreateObject( "Scripting.FileSystemObject" )
160
 
                if not (oFSO.FolderExists( sServerDir ) ) then
161
 
                        sErrorNumber = "102"
162
 
                else
163
 
                        ' Get the uploaded file name.
164
 
                        sFileName       = oUploader.File( "NewFile" ).Name
165
 
                        sExtension      = oUploader.File( "NewFile" ).Ext
166
 
                        sFileName = SanitizeFileName( sFileName )
167
 
                        sOriginalFileName = sFileName
168
 
 
169
 
                        Dim iCounter
170
 
                        iCounter = 0
171
 
 
172
 
                        Do While ( True )
173
 
                                Dim sFilePath
174
 
                                sFilePath = CombineLocalPaths(sServerDir, sFileName)
175
 
 
176
 
                                If ( oFSO.FileExists( sFilePath ) ) Then
177
 
                                        iCounter = iCounter + 1
178
 
                                        sFileName = RemoveExtension( sOriginalFileName ) & "(" & iCounter & ")." & sExtension
179
 
                                        sErrorNumber = "201"
180
 
                                Else
181
 
                                        oUploader.SaveAs "NewFile", sFilePath
182
 
                                        If oUploader.ErrNum > 0 Then sErrorNumber = "202"
183
 
                                        Exit Do
184
 
                                End If
185
 
                        Loop
186
 
                end if
187
 
        End If
188
 
 
189
 
        Set oUploader   = Nothing
190
 
 
191
 
        dim sFileUrl
192
 
        sFileUrl = CombinePaths( GetResourceTypePath( resourceType, sCommand ) , currentFolder )
193
 
        sFileUrl = CombinePaths( sFileUrl, sFileName )
194
 
 
195
 
        If ( sErrorNumber = "0" or sErrorNumber = "201" ) then
196
 
                SendUploadResults sErrorNumber, sFileUrl, sFileName, ""
197
 
        Else
198
 
                SendUploadResults sErrorNumber, "", "", ""
199
 
        End If
200
 
End Sub
201
 
 
202
 
%>