+++ /dev/null
-#####\r
-# FCKeditor - The text editor for Internet - http://www.fckeditor.net\r
-# Copyright (C) 2003-2007 Frederico Caldeira Knabben\r
-#\r
-# == BEGIN LICENSE ==\r
-#\r
-# Licensed under the terms of any of the following licenses at your\r
-# choice:\r
-#\r
-# - GNU General Public License Version 2 or later (the "GPL")\r
-# http://www.gnu.org/licenses/gpl.html\r
-#\r
-# - GNU Lesser General Public License Version 2.1 or later (the "LGPL")\r
-# http://www.gnu.org/licenses/lgpl.html\r
-#\r
-# - Mozilla Public License Version 1.1 or later (the "MPL")\r
-# http://www.mozilla.org/MPL/MPL-1.1.html\r
-#\r
-# == END LICENSE ==\r
-#\r
-# This is the File Manager Connector for Perl.\r
-#####\r
-\r
-sub GetFolders\r
-{\r
-\r
- local($resourceType, $currentFolder) = @_;\r
-\r
- # Map the virtual path to the local server path.\r
- $sServerDir = &ServerMapFolder($resourceType, $currentFolder);\r
- print "<Folders>"; # Open the "Folders" node.\r
-\r
- opendir(DIR,"$sServerDir");\r
- @files = grep(!/^\.\.?$/,readdir(DIR));\r
- closedir(DIR);\r
-\r
- foreach $sFile (@files) {\r
- if($sFile != '.' && $sFile != '..' && (-d "$sServerDir$sFile")) {\r
- $cnv_filename = &ConvertToXmlAttribute($sFile);\r
- print '<Folder name="' . $cnv_filename . '" />';\r
- }\r
- }\r
- print "</Folders>"; # Close the "Folders" node.\r
-}\r
-\r
-sub GetFoldersAndFiles\r
-{\r
-\r
- local($resourceType, $currentFolder) = @_;\r
- # Map the virtual path to the local server path.\r
- $sServerDir = &ServerMapFolder($resourceType,$currentFolder);\r
-\r
- # Initialize the output buffers for "Folders" and "Files".\r
- $sFolders = '<Folders>';\r
- $sFiles = '<Files>';\r
-\r
- opendir(DIR,"$sServerDir");\r
- @files = grep(!/^\.\.?$/,readdir(DIR));\r
- closedir(DIR);\r
-\r
- foreach $sFile (@files) {\r
- if($sFile ne '.' && $sFile ne '..') {\r
- if(-d "$sServerDir$sFile") {\r
- $cnv_filename = &ConvertToXmlAttribute($sFile);\r
- $sFolders .= '<Folder name="' . $cnv_filename . '" />' ;\r
- } else {\r
- ($iFileSize,$refdate,$filedate,$fileperm) = (stat("$sServerDir$sFile"))[7,8,9,2];\r
- if($iFileSize > 0) {\r
- $iFileSize = int($iFileSize / 1024);\r
- if($iFileSize < 1) {\r
- $iFileSize = 1;\r
- }\r
- }\r
- $cnv_filename = &ConvertToXmlAttribute($sFile);\r
- $sFiles .= '<File name="' . $cnv_filename . '" size="' . $iFileSize . '" />' ;\r
- }\r
- }\r
- }\r
- print $sFolders ;\r
- print '</Folders>'; # Close the "Folders" node.\r
- print $sFiles ;\r
- print '</Files>'; # Close the "Files" node.\r
-}\r
-\r
-sub CreateFolder\r
-{\r
-\r
- local($resourceType, $currentFolder) = @_;\r
- $sErrorNumber = '0' ;\r
- $sErrorMsg = '' ;\r
-\r
- if($FORM{'NewFolderName'} ne "") {\r
- $sNewFolderName = $FORM{'NewFolderName'};\r
- # Map the virtual path to the local server path of the current folder.\r
- $sServerDir = &ServerMapFolder($resourceType, $currentFolder);\r
- if(-w $sServerDir) {\r
- $sServerDir .= $sNewFolderName;\r
- $sErrorMsg = &CreateServerFolder($sServerDir);\r
- if($sErrorMsg == 0) {\r
- $sErrorNumber = '0';\r
- } elsif($sErrorMsg eq 'Invalid argument' || $sErrorMsg eq 'No such file or directory') {\r
- $sErrorNumber = '102'; #// Path too long.\r
- } else {\r
- $sErrorNumber = '110';\r
- }\r
- } else {\r
- $sErrorNumber = '103';\r
- }\r
- } else {\r
- $sErrorNumber = '102' ;\r
- }\r
- # Create the "Error" node.\r
- $cnv_errmsg = &ConvertToXmlAttribute($sErrorMsg);\r
- print '<Error number="' . $sErrorNumber . '" originalDescription="' . $cnv_errmsg . '" />';\r
-}\r
-\r
-sub FileUpload\r
-{\r
-eval("use File::Copy;");\r
-\r
- local($resourceType, $currentFolder) = @_;\r
-\r
- $sErrorNumber = '0' ;\r
- $sFileName = '' ;\r
- if($new_fname) {\r
- # Map the virtual path to the local server path.\r
- $sServerDir = &ServerMapFolder($resourceType,$currentFolder);\r
-\r
- # Get the uploaded file name.\r
- $sFileName = $new_fname;\r
- $sOriginalFileName = $sFileName;\r
-\r
- $iCounter = 0;\r
- while(1) {\r
- $sFilePath = $sServerDir . $sFileName;\r
- if(-e $sFilePath) {\r
- $iCounter++ ;\r
- ($path,$BaseName,$ext) = &RemoveExtension($sOriginalFileName);\r
- $sFileName = $BaseName . '(' . $iCounter . ').' . $ext;\r
- $sErrorNumber = '201';\r
- } else {\r
- copy("$img_dir/$new_fname","$sFilePath");\r
- chmod(0777,$sFilePath);\r
- unlink("$img_dir/$new_fname");\r
- last;\r
- }\r
- }\r
- } else {\r
- $sErrorNumber = '202' ;\r
- }\r
- $sFileName =~ s/"/\\"/g;\r
- print "Content-type: text/html\n\n";\r
- print '<script type="text/javascript">';\r
- print 'window.parent.frames["frmUpload"].OnUploadCompleted(' . $sErrorNumber . ',"' . $sFileName . '") ;';\r
- print '</script>';\r
- exit ;\r
-}\r
-1;\r