2 # FCKeditor - The text editor for Internet - http://www.fckeditor.net
\r
3 # Copyright (C) 2003-2007 Frederico Caldeira Knabben
\r
5 # == BEGIN LICENSE ==
\r
7 # Licensed under the terms of any of the following licenses at your
\r
10 # - GNU General Public License Version 2 or later (the "GPL")
\r
11 # http://www.gnu.org/licenses/gpl.html
\r
13 # - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
\r
14 # http://www.gnu.org/licenses/lgpl.html
\r
16 # - Mozilla Public License Version 1.1 or later (the "MPL")
\r
17 # http://www.mozilla.org/MPL/MPL-1.1.html
\r
21 # This is the File Manager Connector for Perl.
\r
27 local($resourceType, $currentFolder) = @_;
\r
29 # Map the virtual path to the local server path.
\r
30 $sServerDir = &ServerMapFolder($resourceType, $currentFolder);
\r
31 print "<Folders>"; # Open the "Folders" node.
\r
33 opendir(DIR,"$sServerDir");
\r
34 @files = grep(!/^\.\.?$/,readdir(DIR));
\r
37 foreach $sFile (@files) {
\r
38 if($sFile != '.' && $sFile != '..' && (-d "$sServerDir$sFile")) {
\r
39 $cnv_filename = &ConvertToXmlAttribute($sFile);
\r
40 print '<Folder name="' . $cnv_filename . '" />';
\r
43 print "</Folders>"; # Close the "Folders" node.
\r
46 sub GetFoldersAndFiles
\r
49 local($resourceType, $currentFolder) = @_;
\r
50 # Map the virtual path to the local server path.
\r
51 $sServerDir = &ServerMapFolder($resourceType,$currentFolder);
\r
53 # Initialize the output buffers for "Folders" and "Files".
\r
54 $sFolders = '<Folders>';
\r
55 $sFiles = '<Files>';
\r
57 opendir(DIR,"$sServerDir");
\r
58 @files = grep(!/^\.\.?$/,readdir(DIR));
\r
61 foreach $sFile (@files) {
\r
62 if($sFile ne '.' && $sFile ne '..') {
\r
63 if(-d "$sServerDir$sFile") {
\r
64 $cnv_filename = &ConvertToXmlAttribute($sFile);
\r
65 $sFolders .= '<Folder name="' . $cnv_filename . '" />' ;
\r
67 ($iFileSize,$refdate,$filedate,$fileperm) = (stat("$sServerDir$sFile"))[7,8,9,2];
\r
68 if($iFileSize > 0) {
\r
69 $iFileSize = int($iFileSize / 1024);
\r
70 if($iFileSize < 1) {
\r
74 $cnv_filename = &ConvertToXmlAttribute($sFile);
\r
75 $sFiles .= '<File name="' . $cnv_filename . '" size="' . $iFileSize . '" />' ;
\r
80 print '</Folders>'; # Close the "Folders" node.
\r
82 print '</Files>'; # Close the "Files" node.
\r
88 local($resourceType, $currentFolder) = @_;
\r
89 $sErrorNumber = '0' ;
\r
92 if($FORM{'NewFolderName'} ne "") {
\r
93 $sNewFolderName = $FORM{'NewFolderName'};
\r
94 # Map the virtual path to the local server path of the current folder.
\r
95 $sServerDir = &ServerMapFolder($resourceType, $currentFolder);
\r
96 if(-w $sServerDir) {
\r
97 $sServerDir .= $sNewFolderName;
\r
98 $sErrorMsg = &CreateServerFolder($sServerDir);
\r
99 if($sErrorMsg == 0) {
\r
100 $sErrorNumber = '0';
\r
101 } elsif($sErrorMsg eq 'Invalid argument' || $sErrorMsg eq 'No such file or directory') {
\r
102 $sErrorNumber = '102'; #// Path too long.
\r
104 $sErrorNumber = '110';
\r
107 $sErrorNumber = '103';
\r
110 $sErrorNumber = '102' ;
\r
112 # Create the "Error" node.
\r
113 $cnv_errmsg = &ConvertToXmlAttribute($sErrorMsg);
\r
114 print '<Error number="' . $sErrorNumber . '" originalDescription="' . $cnv_errmsg . '" />';
\r
119 eval("use File::Copy;");
\r
121 local($resourceType, $currentFolder) = @_;
\r
123 $sErrorNumber = '0' ;
\r
126 # Map the virtual path to the local server path.
\r
127 $sServerDir = &ServerMapFolder($resourceType,$currentFolder);
\r
129 # Get the uploaded file name.
\r
130 $sFileName = $new_fname;
\r
131 $sOriginalFileName = $sFileName;
\r
135 $sFilePath = $sServerDir . $sFileName;
\r
136 if(-e $sFilePath) {
\r
138 ($path,$BaseName,$ext) = &RemoveExtension($sOriginalFileName);
\r
139 $sFileName = $BaseName . '(' . $iCounter . ').' . $ext;
\r
140 $sErrorNumber = '201';
\r
142 copy("$img_dir/$new_fname","$sFilePath");
\r
143 chmod(0777,$sFilePath);
\r
144 unlink("$img_dir/$new_fname");
\r
149 $sErrorNumber = '202' ;
\r
151 $sFileName =~ s/"/\\"/g;
\r
152 print "Content-type: text/html\n\n";
\r
153 print '<script type="text/javascript">';
\r
154 print 'window.parent.frames["frmUpload"].OnUploadCompleted(' . $sErrorNumber . ',"' . $sFileName . '") ;';
\r