--- /dev/null
+<%\r
+ ' FCKeditor - The text editor for Internet - http://www.fckeditor.net\r
+ ' Copyright (C) 2003-2008 Frederico Caldeira Knabben\r
+ '\r
+ ' == BEGIN LICENSE ==\r
+ '\r
+ ' Licensed under the terms of any of the following licenses at your\r
+ ' choice:\r
+ '\r
+ ' - GNU General Public License Version 2 or later (the "GPL")\r
+ ' http://www.gnu.org/licenses/gpl.html\r
+ '\r
+ ' - GNU Lesser General Public License Version 2.1 or later (the "LGPL")\r
+ ' http://www.gnu.org/licenses/lgpl.html\r
+ '\r
+ ' - Mozilla Public License Version 1.1 or later (the "MPL")\r
+ ' http://www.mozilla.org/MPL/MPL-1.1.html\r
+ '\r
+ ' == END LICENSE ==\r
+ '\r
+ ' This file include the functions that handle the Command requests\r
+ ' in the ASP Connector.\r
+%>\r
+<%\r
+Sub GetFolders( resourceType, currentFolder )\r
+ ' Map the virtual path to the local server path.\r
+ Dim sServerDir\r
+ sServerDir = ServerMapFolder( resourceType, currentFolder, "GetFolders" )\r
+\r
+ ' Open the "Folders" node.\r
+ Response.Write "<Folders>"\r
+\r
+ Dim oFSO, oCurrentFolder, oFolders, oFolder\r
+ Set oFSO = Server.CreateObject( "Scripting.FileSystemObject" )\r
+ if not (oFSO.FolderExists( sServerDir ) ) then\r
+ Set oFSO = Nothing\r
+ SendError 102, currentFolder\r
+ end if\r
+\r
+ Set oCurrentFolder = oFSO.GetFolder( sServerDir )\r
+ Set oFolders = oCurrentFolder.SubFolders\r
+\r
+ For Each oFolder in oFolders\r
+ Response.Write "<Folder name=""" & ConvertToXmlAttribute( oFolder.name ) & """ />"\r
+ Next\r
+\r
+ Set oFSO = Nothing\r
+\r
+ ' Close the "Folders" node.\r
+ Response.Write "</Folders>"\r
+End Sub\r
+\r
+Sub GetFoldersAndFiles( resourceType, currentFolder )\r
+ ' Map the virtual path to the local server path.\r
+ Dim sServerDir\r
+ sServerDir = ServerMapFolder( resourceType, currentFolder, "GetFoldersAndFiles" )\r
+\r
+ Dim oFSO, oCurrentFolder, oFolders, oFolder, oFiles, oFile\r
+ Set oFSO = Server.CreateObject( "Scripting.FileSystemObject" )\r
+ if not (oFSO.FolderExists( sServerDir ) ) then\r
+ Set oFSO = Nothing\r
+ SendError 102, currentFolder\r
+ end if\r
+\r
+ Set oCurrentFolder = oFSO.GetFolder( sServerDir )\r
+ Set oFolders = oCurrentFolder.SubFolders\r
+ Set oFiles = oCurrentFolder.Files\r
+\r
+ ' Open the "Folders" node.\r
+ Response.Write "<Folders>"\r
+\r
+ For Each oFolder in oFolders\r
+ Response.Write "<Folder name=""" & ConvertToXmlAttribute( oFolder.name ) & """ />"\r
+ Next\r
+\r
+ ' Close the "Folders" node.\r
+ Response.Write "</Folders>"\r
+\r
+ ' Open the "Files" node.\r
+ Response.Write "<Files>"\r
+\r
+ For Each oFile in oFiles\r
+ Dim iFileSize\r
+ iFileSize = Round( oFile.size / 1024 )\r
+ If ( iFileSize < 1 AND oFile.size <> 0 ) Then iFileSize = 1\r
+\r
+ Response.Write "<File name=""" & ConvertToXmlAttribute( oFile.name ) & """ size=""" & iFileSize & """ />"\r
+ Next\r
+\r
+ ' Close the "Files" node.\r
+ Response.Write "</Files>"\r
+End Sub\r
+\r
+Sub CreateFolder( resourceType, currentFolder )\r
+ Dim sErrorNumber\r
+\r
+ Dim sNewFolderName\r
+ sNewFolderName = Request.QueryString( "NewFolderName" )\r
+ sNewFolderName = SanitizeFolderName( sNewFolderName )\r
+\r
+ If ( sNewFolderName = "" OR InStr( 1, sNewFolderName, ".." ) > 0 ) Then\r
+ sErrorNumber = "102"\r
+ Else\r
+ ' Map the virtual path to the local server path of the current folder.\r
+ Dim sServerDir\r
+ sServerDir = ServerMapFolder( resourceType, CombineLocalPaths(currentFolder, sNewFolderName), "CreateFolder" )\r
+\r
+ On Error Resume Next\r
+\r
+ CreateServerFolder sServerDir\r
+\r
+ Dim iErrNumber, sErrDescription\r
+ iErrNumber = err.number\r
+ sErrDescription = err.Description\r
+\r
+ On Error Goto 0\r
+\r
+ Select Case iErrNumber\r
+ Case 0\r
+ sErrorNumber = "0"\r
+ Case 52\r
+ sErrorNumber = "102" ' Invalid Folder Name.\r
+ Case 70\r
+ sErrorNumber = "103" ' Security Error.\r
+ Case 76\r
+ sErrorNumber = "102" ' Path too long.\r
+ Case Else\r
+ sErrorNumber = "110"\r
+ End Select\r
+ End If\r
+\r
+ ' Create the "Error" node.\r
+ Response.Write "<Error number=""" & sErrorNumber & """ originalNumber=""" & iErrNumber & """ originalDescription=""" & ConvertToXmlAttribute( sErrDescription ) & """ />"\r
+End Sub\r
+\r
+Sub FileUpload( resourceType, currentFolder, sCommand )\r
+ Dim oUploader\r
+ Set oUploader = New NetRube_Upload\r
+ oUploader.MaxSize = 0\r
+ oUploader.Allowed = ConfigAllowedExtensions.Item( resourceType )\r
+ oUploader.Denied = ConfigDeniedExtensions.Item( resourceType )\r
+ oUploader.HtmlExtensions = ConfigHtmlExtensions\r
+ oUploader.GetData\r
+\r
+ Dim sErrorNumber\r
+ sErrorNumber = "0"\r
+\r
+ Dim sFileName, sOriginalFileName, sExtension\r
+ sFileName = ""\r
+\r
+ If oUploader.ErrNum > 0 Then\r
+ sErrorNumber = "202"\r
+ Else\r
+ ' Map the virtual path to the local server path.\r
+ Dim sServerDir\r
+ sServerDir = ServerMapFolder( resourceType, currentFolder, sCommand )\r
+\r
+ Dim oFSO\r
+ Set oFSO = Server.CreateObject( "Scripting.FileSystemObject" )\r
+ if not (oFSO.FolderExists( sServerDir ) ) then\r
+ sErrorNumber = "102"\r
+ else\r
+ ' Get the uploaded file name.\r
+ sFileName = oUploader.File( "NewFile" ).Name\r
+ sExtension = oUploader.File( "NewFile" ).Ext\r
+ sFileName = SanitizeFileName( sFileName )\r
+ sOriginalFileName = sFileName\r
+\r
+ Dim iCounter\r
+ iCounter = 0\r
+\r
+ Do While ( True )\r
+ Dim sFilePath\r
+ sFilePath = CombineLocalPaths(sServerDir, sFileName)\r
+\r
+ If ( oFSO.FileExists( sFilePath ) ) Then\r
+ iCounter = iCounter + 1\r
+ sFileName = RemoveExtension( sOriginalFileName ) & "(" & iCounter & ")." & sExtension\r
+ sErrorNumber = "201"\r
+ Else\r
+ oUploader.SaveAs "NewFile", sFilePath\r
+ If oUploader.ErrNum > 0 Then sErrorNumber = "202"\r
+ Exit Do\r
+ End If\r
+ Loop\r
+ end if\r
+ End If\r
+\r
+ Set oUploader = Nothing\r
+\r
+ dim sFileUrl\r
+ sFileUrl = CombinePaths( GetResourceTypePath( resourceType, sCommand ) , currentFolder )\r
+ sFileUrl = CombinePaths( sFileUrl, sFileName )\r
+\r
+ SendUploadResults sErrorNumber, sFileUrl, sFileName, ""\r
+End Sub\r
+\r
+%>\r