2
# FCKeditor - The text editor for internet
3
# Copyright (C) 2003-2005 Frederico Caldeira Knabben
5
# Licensed under the terms of the GNU Lesser General Public License:
6
# http://www.opensource.org/licenses/lgpl-license.php
8
# For further information visit:
9
# http://www.fckeditor.net/
11
# "Support Open Source software. What about a donation today?"
13
# File Name: commands.pl
14
# This is the File Manager Connector for Perl.
17
# Takashi Yamaguchi (jack@omakase.net)
23
local($resourceType, $currentFolder) = @_;
25
# Map the virtual path to the local server path.
26
$sServerDir = &ServerMapFolder($resourceType, $currentFolder);
27
print "<Folders>"; # Open the "Folders" node.
29
opendir(DIR,"$sServerDir");
30
@files = grep(!/^\.\.?$/,readdir(DIR));
33
foreach $sFile (@files) {
34
if($sFile != '.' && $sFile != '..' && (-d "$sServerDir$sFile")) {
35
$cnv_filename = &ConvertToXmlAttribute($sFile);
36
print '<Folder name="' . $cnv_filename . '" />';
39
print "</Folders>"; # Close the "Folders" node.
42
sub GetFoldersAndFiles
45
local($resourceType, $currentFolder) = @_;
46
# Map the virtual path to the local server path.
47
$sServerDir = &ServerMapFolder($resourceType,$currentFolder);
49
# Initialize the output buffers for "Folders" and "Files".
50
$sFolders = '<Folders>';
53
opendir(DIR,"$sServerDir");
54
@files = grep(!/^\.\.?$/,readdir(DIR));
57
foreach $sFile (@files) {
58
if($sFile ne '.' && $sFile ne '..') {
59
if(-d "$sServerDir$sFile") {
60
$cnv_filename = &ConvertToXmlAttribute($sFile);
61
$sFolders .= '<Folder name="' . $cnv_filename . '" />' ;
63
($iFileSize,$refdate,$filedate,$fileperm) = (stat("$sServerDir$sFile"))[7,8,9,2];
65
$iFileSize = int($iFileSize / 1024);
70
$cnv_filename = &ConvertToXmlAttribute($sFile);
71
$sFiles .= '<File name="' . $cnv_filename . '" size="' . $iFileSize . '" />' ;
76
print '</Folders>'; # Close the "Folders" node.
78
print '</Files>'; # Close the "Files" node.
84
local($resourceType, $currentFolder) = @_;
88
if($FORM{'NewFolderName'} ne "") {
89
$sNewFolderName = $FORM{'NewFolderName'};
90
# Map the virtual path to the local server path of the current folder.
91
$sServerDir = &ServerMapFolder($resourceType, $currentFolder);
93
$sServerDir .= $sNewFolderName;
94
$sErrorMsg = &CreateServerFolder($sServerDir);
97
} elsif($sErrorMsg eq 'Invalid argument' || $sErrorMsg eq 'No such file or directory') {
98
$sErrorNumber = '102'; #// Path too long.
100
$sErrorNumber = '110';
103
$sErrorNumber = '103';
106
$sErrorNumber = '102' ;
108
# Create the "Error" node.
109
$cnv_errmsg = &ConvertToXmlAttribute($sErrorMsg);
110
print '<Error number="' . $sErrorNumber . '" originalDescription="' . $cnv_errmsg . '" />';
115
eval("use File::Copy;");
117
local($resourceType, $currentFolder) = @_;
119
$sErrorNumber = '0' ;
122
# Map the virtual path to the local server path.
123
$sServerDir = &ServerMapFolder($resourceType,$currentFolder);
125
# Get the uploaded file name.
126
$sFileName = $new_fname;
127
$sOriginalFileName = $sFileName;
131
$sFilePath = $sServerDir . $sFileName;
134
($path,$BaseName,$ext) = &RemoveExtension($sOriginalFileName);
135
$sFileName = $BaseName . '(' . $iCounter . ').' . $ext;
136
$sErrorNumber = '201';
138
copy("$img_dir/$new_fname","$sFilePath");
139
chmod(0777,$sFilePath);
140
unlink("$img_dir/$new_fname");
145
$sErrorNumber = '202' ;
147
$sFileName =~ s/"/\\"/g;
148
print "Content-type: text/html\n\n";
149
print '<script type="text/javascript">';
150
print 'window.parent.frames["frmUpload"].OnUploadCompleted(' . $sErrorNumber . ',"' . $sFileName . '") ;';