[ 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/perl/ -> commands.pl (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.pl
  22  #      This is the File Manager Connector for Perl.
  23  #  
  24  #  File Authors:
  25  #          Takashi Yamaguchi (jack@omakase.net)
  26  #####
  27  
  28  sub GetFolders
  29  {
  30  
  31      local($resourceType, $currentFolder) = @_;
  32  
  33      # Map the virtual path to the local server path.
  34      $sServerDir = &ServerMapFolder($resourceType, $currentFolder);
  35      print "<Folders>";            # Open the "Folders" node.
  36  
  37      opendir(DIR,"$sServerDir");
  38      @files = grep(!/^\.\.?$/,readdir(DIR));
  39      closedir(DIR);
  40  
  41      foreach $sFile (@files) {
  42          if($sFile != '.' && $sFile != '..' && (-d "$sServerDir$sFile")) {
  43              $cnv_filename = &ConvertToXmlAttribute($sFile);
  44              print '<Folder name="' . $cnv_filename . '" />';
  45          }
  46      }
  47      print "</Folders>";            # Close the "Folders" node.
  48  }
  49  
  50  sub GetFoldersAndFiles
  51  {
  52  
  53      local($resourceType, $currentFolder) = @_;
  54      # Map the virtual path to the local server path.
  55      $sServerDir = &ServerMapFolder($resourceType,$currentFolder);
  56  
  57      # Initialize the output buffers for "Folders" and "Files".
  58      $sFolders    = '<Folders>';
  59      $sFiles        = '<Files>';
  60  
  61      opendir(DIR,"$sServerDir");
  62      @files = grep(!/^\.\.?$/,readdir(DIR));
  63      closedir(DIR);
  64  
  65      foreach $sFile (@files) {
  66          if($sFile ne '.' && $sFile ne '..') {
  67              if(-d "$sServerDir$sFile") {
  68                  $cnv_filename = &ConvertToXmlAttribute($sFile);
  69                  $sFolders .= '<Folder name="' . $cnv_filename . '" />' ;
  70              } else {
  71                  ($iFileSize,$refdate,$filedate,$fileperm) = (stat("$sServerDir$sFile"))[7,8,9,2];
  72                  if($iFileSize > 0) {
  73                      $iFileSize = int($iFileSize / 1024);
  74                      if($iFileSize < 1) {
  75                          $iFileSize = 1;
  76                      }
  77                  }
  78                  $cnv_filename = &ConvertToXmlAttribute($sFile);
  79                  $sFiles    .= '<File name="' . $cnv_filename . '" size="' . $iFileSize . '" />' ;
  80              }
  81          }
  82      }
  83      print $sFolders ;
  84      print '</Folders>';            # Close the "Folders" node.
  85      print $sFiles ;
  86      print '</Files>';            # Close the "Files" node.
  87  }
  88  
  89  sub CreateFolder
  90  {
  91  
  92      local($resourceType, $currentFolder) = @_;
  93      $sErrorNumber    = '0' ;
  94      $sErrorMsg        = '' ;
  95  
  96      if($FORM{'NewFolderName'} ne "") {
  97          $sNewFolderName = $FORM{'NewFolderName'};
  98          # Map the virtual path to the local server path of the current folder.
  99          $sServerDir = &ServerMapFolder($resourceType, $currentFolder);
 100          if(-w $sServerDir) {
 101              $sServerDir .= $sNewFolderName;
 102              $sErrorMsg = &CreateServerFolder($sServerDir);
 103              if($sErrorMsg == 0) {
 104                  $sErrorNumber = '0';
 105              } elsif($sErrorMsg eq 'Invalid argument' || $sErrorMsg eq 'No such file or directory') {
 106                  $sErrorNumber = '102';        #// Path too long.
 107              } else {
 108                  $sErrorNumber = '110';
 109              }
 110          } else {
 111              $sErrorNumber = '103';
 112          }
 113      } else {
 114          $sErrorNumber = '102' ;
 115      }
 116      # Create the "Error" node.
 117      $cnv_errmsg = &ConvertToXmlAttribute($sErrorMsg);
 118      print '<Error number="' . $sErrorNumber . '" originalDescription="' . $cnv_errmsg . '" />';
 119  }
 120  
 121  sub FileUpload
 122  {
 123  eval("use File::Copy;");
 124  
 125      local($resourceType, $currentFolder) = @_;
 126  
 127      $sErrorNumber = '0' ;
 128      $sFileName = '' ;
 129      if($new_fname) {
 130          # Map the virtual path to the local server path.
 131          $sServerDir = &ServerMapFolder($resourceType,$currentFolder);
 132  
 133          # Get the uploaded file name.
 134          $sFileName = $new_fname;
 135          $sOriginalFileName = $sFileName;
 136  
 137          $iCounter = 0;
 138          while(1) {
 139              $sFilePath = $sServerDir . $sFileName;
 140              if(-e $sFilePath) {
 141                  $iCounter++ ;
 142                  ($path,$BaseName,$ext) = &RemoveExtension($sOriginalFileName);
 143                  $sFileName = $BaseName . '(' . $iCounter . ').' . $ext;
 144                  $sErrorNumber = '201';
 145              } else {
 146                  copy("$img_dir/$new_fname","$sFilePath");
 147                  chmod(0777,$sFilePath);
 148                  unlink("$img_dir/$new_fname");
 149                  last;
 150              }
 151          }
 152      } else {
 153          $sErrorNumber = '202' ;
 154      }
 155      $sFileName    =~ s/"/\\"/g;
 156      print "Content-type: text/html\n\n";
 157      print '<script type="text/javascript">';
 158      print 'window.parent.frames["frmUpload"].OnUploadCompleted(' . $sErrorNumber . ',"' . $sFileName . '") ;';
 159      print '</script>';
 160      exit ;
 161  }
 162  1;


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