commands.asp
上传用户:li2971742
上传日期:2021-11-18
资源大小:39096k
文件大小:5k
源码类别:

OA系统

开发平台:

C#

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