[ Index ]
 

Code source de FCKeditor 2.4

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/editor/filemanager/browser/default/connectors/asp/ -> commands.asp (source)

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


Généré le : Sun Feb 25 15:28:05 2007 par Balluche grâce à PHPXref 0.7