comparison wiki/htdocs/applets/FCKeditor/editor/filemanager/browser/default/connectors/asp/commands.asp @ 0:77665d8e2254

tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0 (automatically generated log message) imported from: moin--main--1.5--base-0
author Thomas Waldmann <tw-public@gmx.de>
date Thu, 22 Sep 2005 15:09:50 +0000
parents
children 00a0fa898ed5
comparison
equal deleted inserted replaced
-1:000000000000 0:77665d8e2254
1 <!--
2 * FCKeditor - The text editor for internet
3 * Copyright (C) 2003-2005 Frederico Caldeira Knabben
4 *
5 * Licensed under the terms of the GNU Lesser General Public License:
6 * http://www.opensource.org/licenses/lgpl-license.php
7 *
8 * For further information visit:
9 * http://www.fckeditor.net/
10 *
11 * "Support Open Source software. What about a donation today?"
12 *
13 * File Name: commands.asp
14 * This file include the functions that handle the Command requests
15 * in the ASP Connector.
16 *
17 * File Authors:
18 * Frederico Caldeira Knabben (fredck@fckeditor.net)
19 -->
20 <%
21 Sub GetFolders( resourceType, currentFolder )
22 ' Map the virtual path to the local server path.
23 Dim sServerDir
24 sServerDir = ServerMapFolder( resourceType, currentFolder )
25
26 ' Open the "Folders" node.
27 Response.Write "<Folders>"
28
29 Dim oFSO, oCurrentFolder, oFolders, oFolder
30 Set oFSO = Server.CreateObject( "Scripting.FileSystemObject" )
31 Set oCurrentFolder = oFSO.GetFolder( sServerDir )
32 Set oFolders = oCurrentFolder.SubFolders
33
34 For Each oFolder in oFolders
35 Response.Write "<Folder name=""" & ConvertToXmlAttribute( oFolder.name ) & """ />"
36 Next
37
38 Set oFSO = Nothing
39
40 ' Close the "Folders" node.
41 Response.Write "</Folders>"
42 End Sub
43
44 Sub GetFoldersAndFiles( resourceType, currentFolder )
45 ' Map the virtual path to the local server path.
46 Dim sServerDir
47 sServerDir = ServerMapFolder( resourceType, currentFolder )
48
49 Dim oFSO, oCurrentFolder, oFolders, oFolder, oFiles, oFile
50 Set oFSO = Server.CreateObject( "Scripting.FileSystemObject" )
51 Set oCurrentFolder = oFSO.GetFolder( sServerDir )
52 Set oFolders = oCurrentFolder.SubFolders
53 Set oFiles = oCurrentFolder.Files
54
55 ' Open the "Folders" node.
56 Response.Write "<Folders>"
57
58 For Each oFolder in oFolders
59 Response.Write "<Folder name=""" & ConvertToXmlAttribute( oFolder.name ) & """ />"
60 Next
61
62 ' Close the "Folders" node.
63 Response.Write "</Folders>"
64
65 ' Open the "Files" node.
66 Response.Write "<Files>"
67
68 For Each oFile in oFiles
69 Dim iFileSize
70 iFileSize = Round( oFile.size / 1024 )
71 If ( iFileSize < 1 AND oFile.size <> 0 ) Then iFileSize = 1
72
73 Response.Write "<File name=""" & ConvertToXmlAttribute( oFile.name ) & """ size=""" & iFileSize & """ />"
74 Next
75
76 ' Close the "Files" node.
77 Response.Write "</Files>"
78 End Sub
79
80 Sub CreateFolder( resourceType, currentFolder )
81 Dim sErrorNumber
82
83 Dim sNewFolderName
84 sNewFolderName = Request.QueryString( "NewFolderName" )
85
86 If ( sNewFolderName = "" ) Then
87 sErrorNumber = "102"
88 Else
89 ' Map the virtual path to the local server path of the current folder.
90 Dim sServerDir
91 sServerDir = ServerMapFolder( resourceType, currentFolder & "/" & sNewFolderName )
92
93 On Error Resume Next
94
95 CreateServerFolder sServerDir
96
97 Dim iErrNumber, sErrDescription
98 iErrNumber = err.number
99 sErrDescription = err.Description
100
101 On Error Goto 0
102
103 Select Case iErrNumber
104 Case 0
105 sErrorNumber = "0"
106 Case 52
107 sErrorNumber = "102" ' Invalid Folder Name.
108 Case 70
109 sErrorNumber = "103" ' Security Error.
110 Case 76
111 sErrorNumber = "102" ' Path too long.
112 Case Else
113 sErrorNumber = "110"
114 End Select
115 End If
116
117 ' Create the "Error" node.
118 Response.Write "<Error number=""" & sErrorNumber & """ originalNumber=""" & iErrNumber & """ originalDescription=""" & ConvertToXmlAttribute( sErrDescription ) & """ />"
119 End Sub
120
121 Sub FileUpload( resourceType, currentFolder )
122 Dim oUploader
123 Set oUploader = New NetRube_Upload
124 oUploader.MaxSize = 0
125 oUploader.Allowed = ConfigAllowedExtensions.Item( resourceType )
126 oUploader.Denied = ConfigDeniedExtensions.Item( resourceType )
127 oUploader.GetData
128
129 Dim sErrorNumber
130 sErrorNumber = "0"
131
132 Dim sFileName, sOriginalFileName, sExtension
133 sFileName = ""
134
135 If oUploader.ErrNum > 1 Then
136 sErrorNumber = "202"
137 Else
138 ' Map the virtual path to the local server path.
139 Dim sServerDir
140 sServerDir = ServerMapFolder( resourceType, currentFolder )
141
142 Dim oFSO
143 Set oFSO = Server.CreateObject( "Scripting.FileSystemObject" )
144
145 ' Get the uploaded file name.
146 sFileName = oUploader.File( "NewFile" ).Name
147 sExtension = oUploader.File( "NewFile" ).Ext
148 sOriginalFileName = sFileName
149
150 Dim iCounter
151 iCounter = 0
152
153 Do While ( True )
154 Dim sFilePath
155 sFilePath = sServerDir & sFileName
156
157 If ( oFSO.FileExists( sFilePath ) ) Then
158 iCounter = iCounter + 1
159 sFileName = RemoveExtension( sOriginalFileName ) & "(" & iCounter & ")." & sExtension
160 sErrorNumber = "201"
161 Else
162 oUploader.SaveAs "NewFile", sFilePath
163 If oUploader.ErrNum > 0 Then sErrorNumber = "202"
164 Exit Do
165 End If
166 Loop
167 End If
168
169 Set oUploader = Nothing
170
171 Response.Clear
172
173 Response.Write "<script type=""text/javascript"">"
174 Response.Write "window.parent.frames['frmUpload'].OnUploadCompleted(" & sErrorNumber & ",'" & Replace( sFileName, "'", "\'" ) & "') ;"
175 Response.Write "</script>"
176
177 Response.End
178 End Sub
179 %>