2 # FCKeditor - The text editor for Internet - http://www.fckeditor.net
\r
3 # Copyright (C) 2003-2010 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
26 local($resourceType, $folderPath) = @_;
\r
28 if($resourceType eq '') {
\r
29 $rmpath = &RemoveFromEnd($GLOBALS{'UserFilesPath'},'/');
\r
30 return("$rmpath$folderPath");
\r
32 return("$GLOBALS{'UserFilesPath'}$resourceType$folderPath");
\r
38 local($fileName) = @_;
\r
39 local($path, $base, $ext);
\r
40 if($fileName !~ /\./) {
\r
43 if($fileName =~ /([^\\\/]*)\.(.*)$/) {
\r
46 if($fileName =~ /(.*)$base\.$ext$/) {
\r
50 return($path,$base,$ext);
\r
56 local($resourceType,$folderPath) = @_;
\r
58 # Get the resource type directory.
\r
59 $sResourceTypePath = $GLOBALS{'UserFilesDirectory'} . $resourceType . '/';
\r
61 # Ensure that the directory exists.
\r
62 &CreateServerFolder($sResourceTypePath);
\r
64 # Return the resource type directory combined with the required path.
\r
65 $rmpath = &RemoveFromStart($folderPath,'/');
\r
66 return("$sResourceTypePath$rmpath");
\r
71 local($folderPath) = @_;
\r
73 $folderPath =~ s/[\/][^\/]+[\/]?$//g;
\r
77 sub CreateServerFolder
\r
79 local($folderPath) = @_;
\r
81 $sParent = &GetParentFolder($folderPath);
\r
82 # Check if the parent exists, or create it.
\r
83 if(!(-e $sParent)) {
\r
84 $sErrorMsg = &CreateServerFolder($sParent);
\r
85 if($sErrorMsg == 1) {
\r
89 if(!(-e $folderPath)) {
\r
90 if (defined $CHMOD_ON_FOLDER_CREATE && !$CHMOD_ON_FOLDER_CREATE) {
\r
91 mkdir("$folderPath");
\r
95 if (defined $CHMOD_ON_FOLDER_CREATE) {
\r
96 mkdir("$folderPath",$CHMOD_ON_FOLDER_CREATE);
\r
99 mkdir("$folderPath",0777);
\r
113 # my $dir = getcwd;
\r
115 # $dir =~ s/$ENV{'DOCUMENT_ROOT'}//g;
\r
120 # $wk =~ s/\/connector\.cgi//g;
\r
122 # $current_dir = $wk;
\r
124 # $current_dir = `pwd`;
\r
126 # return($current_dir);
\r
129 if($ENV{'DOCUMENT_ROOT'}) {
\r
130 $dir = $ENV{'DOCUMENT_ROOT'};
\r
133 $workdir =~ s/\/connector\.cgi//g;
\r
134 $dir =~ s/$workdir//g;
\r