2
' FCKeditor - The text editor for Internet - http://www.fckeditor.net
3
' Copyright (C) 2003-2007 Frederico Caldeira Knabben
7
' Licensed under the terms of any of the following licenses at your
10
' - GNU General Public License Version 2 or later (the "GPL")
11
' http://www.gnu.org/licenses/gpl.html
13
' - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
14
' http://www.gnu.org/licenses/lgpl.html
16
' - Mozilla Public License Version 1.1 or later (the "MPL")
17
' http://www.mozilla.org/MPL/MPL-1.1.html
21
' This file include the functions that handle the Command requests
22
' in the ASP Connector.
25
Sub GetFolders( resourceType, currentFolder )
26
' Map the virtual path to the local server path.
28
sServerDir = ServerMapFolder( resourceType, currentFolder, "GetFolders" )
30
' Open the "Folders" node.
31
Response.Write "<Folders>"
33
Dim oFSO, oCurrentFolder, oFolders, oFolder
34
Set oFSO = Server.CreateObject( "Scripting.FileSystemObject" )
35
if not (oFSO.FolderExists( sServerDir ) ) then
37
SendError 102, currentFolder
40
Set oCurrentFolder = oFSO.GetFolder( sServerDir )
41
Set oFolders = oCurrentFolder.SubFolders
43
For Each oFolder in oFolders
44
Response.Write "<Folder name=""" & ConvertToXmlAttribute( oFolder.name ) & """ />"
49
' Close the "Folders" node.
50
Response.Write "</Folders>"
53
Sub GetFoldersAndFiles( resourceType, currentFolder )
54
' Map the virtual path to the local server path.
56
sServerDir = ServerMapFolder( resourceType, currentFolder, "GetFoldersAndFiles" )
58
Dim oFSO, oCurrentFolder, oFolders, oFolder, oFiles, oFile
59
Set oFSO = Server.CreateObject( "Scripting.FileSystemObject" )
60
if not (oFSO.FolderExists( sServerDir ) ) then
62
SendError 102, currentFolder
65
Set oCurrentFolder = oFSO.GetFolder( sServerDir )
66
Set oFolders = oCurrentFolder.SubFolders
67
Set oFiles = oCurrentFolder.Files
69
' Open the "Folders" node.
70
Response.Write "<Folders>"
72
For Each oFolder in oFolders
73
Response.Write "<Folder name=""" & ConvertToXmlAttribute( oFolder.name ) & """ />"
76
' Close the "Folders" node.
77
Response.Write "</Folders>"
79
' Open the "Files" node.
80
Response.Write "<Files>"
82
For Each oFile in oFiles
84
iFileSize = Round( oFile.size / 1024 )
85
If ( iFileSize < 1 AND oFile.size <> 0 ) Then iFileSize = 1
87
Response.Write "<File name=""" & ConvertToXmlAttribute( oFile.name ) & """ size=""" & iFileSize & """ />"
90
' Close the "Files" node.
91
Response.Write "</Files>"
94
Sub CreateFolder( resourceType, currentFolder )
98
sNewFolderName = Request.QueryString( "NewFolderName" )
99
sNewFolderName = SanitizeFolderName( sNewFolderName )
101
If ( sNewFolderName = "" OR InStr( 1, sNewFolderName, ".." ) > 0 ) Then
104
' Map the virtual path to the local server path of the current folder.
106
sServerDir = ServerMapFolder( resourceType, CombinePaths(currentFolder, sNewFolderName), "CreateFolder" )
110
CreateServerFolder sServerDir
112
Dim iErrNumber, sErrDescription
113
iErrNumber = err.number
114
sErrDescription = err.Description
118
Select Case iErrNumber
122
sErrorNumber = "102" ' Invalid Folder Name.
124
sErrorNumber = "103" ' Security Error.
126
sErrorNumber = "102" ' Path too long.
132
' Create the "Error" node.
133
Response.Write "<Error number=""" & sErrorNumber & """ originalNumber=""" & iErrNumber & """ originalDescription=""" & ConvertToXmlAttribute( sErrDescription ) & """ />"
136
Sub FileUpload( resourceType, currentFolder, sCommand )
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
148
Dim sFileName, sOriginalFileName, sExtension
151
If oUploader.ErrNum > 0 Then
154
' Map the virtual path to the local server path.
156
sServerDir = ServerMapFolder( resourceType, currentFolder, sCommand )
159
Set oFSO = Server.CreateObject( "Scripting.FileSystemObject" )
160
if not (oFSO.FolderExists( sServerDir ) ) then
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
174
sFilePath = sServerDir & sFileName
176
If ( oFSO.FileExists( sFilePath ) ) Then
177
iCounter = iCounter + 1
178
sFileName = RemoveExtension( sOriginalFileName ) & "(" & iCounter & ")." & sExtension
181
oUploader.SaveAs "NewFile", sFilePath
182
If oUploader.ErrNum > 0 Then sErrorNumber = "202"
189
Set oUploader = Nothing
192
sFileUrl = CombinePaths( GetResourceTypePath( resourceType, sCommand ) , currentFolder )
193
sFileUrl = CombinePaths( sFileUrl, sFileName )
195
SendUploadResults sErrorNumber, sFileUrl, sFileName, ""
2
' FCKeditor - The text editor for Internet - http://www.fckeditor.net
3
' Copyright (C) 2003-2007 Frederico Caldeira Knabben
7
' Licensed under the terms of any of the following licenses at your
10
' - GNU General Public License Version 2 or later (the "GPL")
11
' http://www.gnu.org/licenses/gpl.html
13
' - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
14
' http://www.gnu.org/licenses/lgpl.html
16
' - Mozilla Public License Version 1.1 or later (the "MPL")
17
' http://www.mozilla.org/MPL/MPL-1.1.html
21
' This file include the functions that handle the Command requests
22
' in the ASP Connector.
25
Sub GetFolders( resourceType, currentFolder )
26
' Map the virtual path to the local server path.
28
sServerDir = ServerMapFolder( resourceType, currentFolder, "GetFolders" )
30
' Open the "Folders" node.
31
Response.Write "<Folders>"
33
Dim oFSO, oCurrentFolder, oFolders, oFolder
34
Set oFSO = Server.CreateObject( "Scripting.FileSystemObject" )
35
if not (oFSO.FolderExists( sServerDir ) ) then
37
SendError 102, currentFolder
40
Set oCurrentFolder = oFSO.GetFolder( sServerDir )
41
Set oFolders = oCurrentFolder.SubFolders
43
For Each oFolder in oFolders
44
Response.Write "<Folder name=""" & ConvertToXmlAttribute( oFolder.name ) & """ />"
49
' Close the "Folders" node.
50
Response.Write "</Folders>"
53
Sub GetFoldersAndFiles( resourceType, currentFolder )
54
' Map the virtual path to the local server path.
56
sServerDir = ServerMapFolder( resourceType, currentFolder, "GetFoldersAndFiles" )
58
Dim oFSO, oCurrentFolder, oFolders, oFolder, oFiles, oFile
59
Set oFSO = Server.CreateObject( "Scripting.FileSystemObject" )
60
if not (oFSO.FolderExists( sServerDir ) ) then
62
SendError 102, currentFolder
65
Set oCurrentFolder = oFSO.GetFolder( sServerDir )
66
Set oFolders = oCurrentFolder.SubFolders
67
Set oFiles = oCurrentFolder.Files
69
' Open the "Folders" node.
70
Response.Write "<Folders>"
72
For Each oFolder in oFolders
73
Response.Write "<Folder name=""" & ConvertToXmlAttribute( oFolder.name ) & """ />"
76
' Close the "Folders" node.
77
Response.Write "</Folders>"
79
' Open the "Files" node.
80
Response.Write "<Files>"
82
For Each oFile in oFiles
84
iFileSize = Round( oFile.size / 1024 )
85
If ( iFileSize < 1 AND oFile.size <> 0 ) Then iFileSize = 1
87
Response.Write "<File name=""" & ConvertToXmlAttribute( oFile.name ) & """ size=""" & iFileSize & """ />"
90
' Close the "Files" node.
91
Response.Write "</Files>"
94
Sub CreateFolder( resourceType, currentFolder )
98
sNewFolderName = Request.QueryString( "NewFolderName" )
99
sNewFolderName = SanitizeFolderName( sNewFolderName )
101
If ( sNewFolderName = "" OR InStr( 1, sNewFolderName, ".." ) > 0 ) Then
104
' Map the virtual path to the local server path of the current folder.
106
sServerDir = ServerMapFolder( resourceType, CombinePaths(currentFolder, sNewFolderName), "CreateFolder" )
110
CreateServerFolder sServerDir
112
Dim iErrNumber, sErrDescription
113
iErrNumber = err.number
114
sErrDescription = err.Description
118
Select Case iErrNumber
122
sErrorNumber = "102" ' Invalid Folder Name.
124
sErrorNumber = "103" ' Security Error.
126
sErrorNumber = "102" ' Path too long.
132
' Create the "Error" node.
133
Response.Write "<Error number=""" & sErrorNumber & """ originalNumber=""" & iErrNumber & """ originalDescription=""" & ConvertToXmlAttribute( sErrDescription ) & """ />"
136
Sub FileUpload( resourceType, currentFolder, sCommand )
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
148
Dim sFileName, sOriginalFileName, sExtension
151
If oUploader.ErrNum > 0 Then
154
' Map the virtual path to the local server path.
156
sServerDir = ServerMapFolder( resourceType, currentFolder, sCommand )
159
Set oFSO = Server.CreateObject( "Scripting.FileSystemObject" )
160
if not (oFSO.FolderExists( sServerDir ) ) then
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
174
sFilePath = sServerDir & sFileName
176
If ( oFSO.FileExists( sFilePath ) ) Then
177
iCounter = iCounter + 1
178
sFileName = RemoveExtension( sOriginalFileName ) & "(" & iCounter & ")." & sExtension
181
oUploader.SaveAs "NewFile", sFilePath
182
If oUploader.ErrNum > 0 Then sErrorNumber = "202"
189
Set oUploader = Nothing
192
sFileUrl = CombinePaths( GetResourceTypePath( resourceType, sCommand ) , currentFolder )
193
sFileUrl = CombinePaths( sFileUrl, sFileName )
195
SendUploadResults sErrorNumber, sFileUrl, sFileName, ""