commands.asp
上传用户:wlfwy2004
上传日期:2016-12-12
资源大小:33978k
文件大小:5k
源码类别:

Jsp/Servlet

开发平台:

Java

  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.  * File Name: commands.asp
  12.  *  This file include the functions that handle the Command requests
  13.  *  in the ASP Connector.
  14.  * 
  15.  * File Authors:
  16.  *  Frederico Caldeira Knabben (fredck@fckeditor.net)
  17. -->
  18. <%
  19. Sub GetFolders( resourceType, currentFolder )
  20. ' Map the virtual path to the local server path.
  21. Dim sServerDir
  22. sServerDir = ServerMapFolder( resourceType, currentFolder )
  23. ' Open the "Folders" node.
  24. Response.Write "<Folders>"
  25. Dim oFSO, oCurrentFolder, oFolders, oFolder
  26. Set oFSO = Server.CreateObject( "Scripting.FileSystemObject" )
  27. Set oCurrentFolder = oFSO.GetFolder( sServerDir )
  28. Set oFolders = oCurrentFolder.SubFolders
  29. For Each oFolder in oFolders
  30. Response.Write "<Folder name=""" & ConvertToXmlAttribute( oFolder.name ) & """ />"
  31. Next
  32. Set oFSO = Nothing
  33. ' Close the "Folders" node.
  34. Response.Write "</Folders>"
  35. End Sub
  36. Sub GetFoldersAndFiles( resourceType, currentFolder )
  37. ' Map the virtual path to the local server path.
  38. Dim sServerDir
  39. sServerDir = ServerMapFolder( resourceType, currentFolder )
  40. Dim oFSO, oCurrentFolder, oFolders, oFolder, oFiles, oFile
  41. Set oFSO = Server.CreateObject( "Scripting.FileSystemObject" )
  42. Set oCurrentFolder = oFSO.GetFolder( sServerDir )
  43. Set oFolders = oCurrentFolder.SubFolders
  44. Set oFiles = oCurrentFolder.Files
  45. ' Open the "Folders" node.
  46. Response.Write "<Folders>"
  47. For Each oFolder in oFolders
  48. Response.Write "<Folder name=""" & ConvertToXmlAttribute( oFolder.name ) & """ />"
  49. Next
  50. ' Close the "Folders" node.
  51. Response.Write "</Folders>"
  52. ' Open the "Files" node.
  53. Response.Write "<Files>"
  54. For Each oFile in oFiles
  55. Dim iFileSize
  56. iFileSize = Round( oFile.size / 1024 )
  57. If ( iFileSize < 1 AND oFile.size <> 0 ) Then iFileSize = 1
  58. Response.Write "<File name=""" & ConvertToXmlAttribute( oFile.name ) & """ size=""" & iFileSize & """ />"
  59. Next
  60. ' Close the "Files" node.
  61. Response.Write "</Files>"
  62. End Sub
  63. Sub CreateFolder( resourceType, currentFolder )
  64. Dim sErrorNumber
  65. Dim sNewFolderName
  66. sNewFolderName = Request.QueryString( "NewFolderName" )
  67. If ( sNewFolderName = "" ) Then
  68. sErrorNumber = "102"
  69. Else
  70. ' Map the virtual path to the local server path of the current folder.
  71. Dim sServerDir
  72. sServerDir = ServerMapFolder( resourceType, currentFolder & "/" & sNewFolderName )
  73. On Error Resume Next
  74. CreateServerFolder sServerDir
  75. Dim iErrNumber, sErrDescription
  76. iErrNumber = err.number
  77. sErrDescription = err.Description
  78. On Error Goto 0
  79. Select Case iErrNumber
  80. Case 0
  81. sErrorNumber = "0"
  82. Case 52
  83. sErrorNumber = "102" ' Invalid Folder Name.
  84. Case 70
  85. sErrorNumber = "103" ' Security Error.
  86. Case 76
  87. sErrorNumber = "102" ' Path too long.
  88. Case Else
  89. sErrorNumber = "110"
  90. End Select
  91. End If
  92. ' Create the "Error" node.
  93. Response.Write "<Error number=""" & sErrorNumber & """ originalNumber=""" & iErrNumber & """ originalDescription=""" & ConvertToXmlAttribute( sErrDescription ) & """ />"
  94. End Sub
  95. Sub FileUpload( resourceType, currentFolder )
  96. Dim oUploader
  97. Set oUploader = New NetRube_Upload
  98. oUploader.MaxSize = 0
  99. oUploader.Allowed = ConfigAllowedExtensions.Item( resourceType )
  100. oUploader.Denied = ConfigDeniedExtensions.Item( resourceType )
  101. oUploader.GetData
  102. Dim sErrorNumber
  103. sErrorNumber = "0"
  104. Dim sFileName, sOriginalFileName, sExtension
  105. sFileName = ""
  106. If oUploader.ErrNum > 1 Then
  107. sErrorNumber = "202"
  108. Else
  109. ' Map the virtual path to the local server path.
  110. Dim sServerDir
  111. sServerDir = ServerMapFolder( resourceType, currentFolder )
  112. Dim oFSO
  113. Set oFSO = Server.CreateObject( "Scripting.FileSystemObject" )
  114. ' Get the uploaded file name.
  115. sFileName = oUploader.File( "NewFile" ).Name
  116. sExtension = oUploader.File( "NewFile" ).Ext
  117. sOriginalFileName = sFileName
  118. Dim iCounter
  119. iCounter = 0
  120. Do While ( True )
  121. Dim sFilePath
  122. sFilePath = sServerDir & sFileName
  123. If ( oFSO.FileExists( sFilePath ) ) Then
  124. iCounter = iCounter + 1
  125. sFileName = RemoveExtension( sOriginalFileName ) & "(" & iCounter & ")." & sExtension
  126. sErrorNumber = "201"
  127. Else
  128. oUploader.SaveAs "NewFile", sFilePath
  129. If oUploader.ErrNum > 0 Then sErrorNumber = "202"
  130. Exit Do
  131. End If
  132. Loop
  133. End If
  134. Set oUploader = Nothing
  135. Response.Clear
  136. Response.Write "<script type=""text/javascript"">"
  137. Response.Write "window.parent.frames['frmUpload'].OnUploadCompleted(" & sErrorNumber & ",'" & Replace( sFileName, "'", "'" ) & "') ;"
  138. Response.Write "</script>"
  139. Response.End
  140. End Sub
  141. %>