[ Index ]
 

Code source de FCKeditor 2.4

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

title

Body

[fermer]

/editor/filemanager/upload/lasso/ -> upload.lasso (source)

   1  [//lasso
   2  /*
   3   * FCKeditor - The text editor for Internet - http://www.fckeditor.net
   4   * Copyright (C) 2003-2007 Frederico Caldeira Knabben
   5   * 
   6   * == BEGIN LICENSE ==
   7   * 
   8   * Licensed under the terms of any of the following licenses at your
   9   * choice:
  10   * 
  11   *  - GNU General Public License Version 2 or later (the "GPL")
  12   *    http://www.gnu.org/licenses/gpl.html
  13   * 
  14   *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
  15   *    http://www.gnu.org/licenses/lgpl.html
  16   * 
  17   *  - Mozilla Public License Version 1.1 or later (the "MPL")
  18   *    http://www.mozilla.org/MPL/MPL-1.1.html
  19   * 
  20   * == END LICENSE ==
  21   * 
  22   * File Name: upload.lasso
  23   *     This is the "File Uploader" for Lasso.
  24   * 
  25   * File Authors:
  26   *         Jason Huck (jason.huck@corefive.com)
  27   */
  28  
  29      /*.....................................................................     
  30      Include global configuration. See config.lasso for details.                                                                           
  31      */                                                                          
  32      include ('config.lasso');
  33  
  34  
  35      /*.....................................................................     
  36      Convert query string parameters to variables and initialize output.                                                                           
  37      */                                                                          
  38      var(
  39          'Type'            =    action_param('Type'),
  40          'CurrentFolder'    =    action_param('CurrentFolder'),
  41          'ServerPath'    =    action_param('ServerPath'),
  42          'NewFile'        =    null,
  43          'NewFileName'    =    string,
  44          'OrigFilePath'    =    string,
  45          'NewFilePath'    =    string,
  46          'errorNumber'    =    0,
  47          'customMsg'        =    ''
  48      );
  49  
  50      $Type == '' ? $Type = 'File';
  51  
  52  
  53      /*.....................................................................     
  54      Calculate the path to the current folder.                                                                           
  55      */                                                                          
  56      $ServerPath == '' ? $ServerPath = $config->find('UserFilesPath');
  57          
  58      var('currentFolderURL' = $ServerPath 
  59          + $config->find('Subdirectories')->find(action_param('Type'))
  60          + action_param('CurrentFolder')
  61      );
  62  
  63  
  64      /*.....................................................................    
  65      Custom tag sets the HTML response.                                                               
  66      */
  67      
  68      define_tag(
  69          'sendresults',
  70          -namespace='fck_',
  71          -priority='replace',
  72          -required='errorNumber',
  73          -type='integer',
  74          -optional='fileUrl',
  75          -type='string',
  76          -optional='fileName',
  77          -type='string',
  78          -optional='customMsg',
  79          -type='string',
  80          -description='Sets the HTML response for the FCKEditor Quick Upload feature.'
  81      );
  82          $__html_reply__ = '\
  83  <script type="text/javascript">
  84      window.parent.OnUploadCompleted(' + #errorNumber + ',"' 
  85          + string_replace(#fileUrl, -find='"', -replace='\\"') + '","' 
  86          + string_replace(#fileName, -find='"', -replace='\\"') + '","' 
  87          + string_replace(#customMsg, -find='"', -replace='\\"') + '");
  88  </script>
  89          ';
  90      /define_tag;
  91  
  92  
  93      if($config->find('Enabled'));
  94          /*.................................................................     
  95          Process an uploaded file.                                                                        
  96          */                                                                          
  97          inline($connection);
  98              /*.............................................................     
  99              Was a file actually uploaded?                                                              
 100              */                                                              
 101              file_uploads->size ? $NewFile = file_uploads->get(1) | $errorNumber = 202;
 102                              
 103              if($errorNumber == 0);
 104                  /*.........................................................     
 105                  Split the file's extension from the filename in order
 106                  to follow the API's naming convention for duplicate
 107                  files. (Test.txt, Test(1).txt, Test(2).txt, etc.)                                                          
 108                  */                                                          
 109                  $NewFileName = $NewFile->find('OrigName');                                                    
 110                  $OrigFilePath = $currentFolderURL + $NewFileName;
 111                  $NewFilePath = $OrigFilePath;
 112                  local('fileExtension') = '.' + $NewFile->find('OrigExtension');                    
 113                  local('shortFileName') = $NewFileName->removetrailing(#fileExtension)&;
 114      
 115      
 116                  /*.........................................................     
 117                  Make sure the file extension is allowed.                                                          
 118                  */ 
 119                                  
 120                  if($config->find('DeniedExtensions')->find($Type) >> $NewFile->find('OrigExtension'));
 121                      $errorNumber = 202;
 122                  else;
 123                      /*.....................................................     
 124                      Rename the target path until it is unique.                                                    
 125                      */                                                                                              
 126                      while(file_exists($NewFilePath));
 127                          $NewFileName = #shortFileName + '(' + loop_count + ')' + #fileExtension;
 128                          $NewFilePath = $currentFolderURL + $NewFileName;
 129                      /while;
 130                      
 131                      
 132                      /*.....................................................     
 133                      Copy the uploaded file to its final location.                                                     
 134                      */                                                      
 135                      file_copy($NewFile->find('path'), $NewFilePath);
 136      
 137      
 138                      /*.....................................................    
 139                      Set the error code for the response.                                          
 140                      */                                                                              
 141                      select(file_currenterror( -errorcode));
 142                          case(0);
 143                              $OrigFilePath != $NewFilePath ? $errorNumber = 201;
 144                          case;
 145                              $errorNumber = 202;
 146                      /select;
 147                  /if;
 148              /if;
 149          /inline;
 150      else;
 151          $errorNumber = 1;
 152          $customMsg = 'This file uploader is disabled. Please check the "editor/filemanager/upload/lasso/config.lasso" file.';
 153      /if;
 154      
 155      fck_sendresults(
 156          -errorNumber=$errorNumber,
 157          -fileUrl=$NewFilePath,
 158          -fileName=$NewFileName,
 159          -customMsg=$customMsg
 160      );
 161  ]    


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