annotate wiki/htdocs/applets/FCKeditor/editor/filemanager/connectors/perl/io.pl @ 3983:45d71759f13b

add recent version of fckeditor 2.6.3b
author Byeongweon [tasyblue@gmail.com]
date Mon, 28 Jul 2008 01:34:03 +0900
parents
children 1d37117f8ca6
rev   line source
3983
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
1 #####
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
2 # FCKeditor - The text editor for Internet - http://www.fckeditor.net
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
3 # Copyright (C) 2003-2008 Frederico Caldeira Knabben
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
4 #
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
5 # == BEGIN LICENSE ==
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
6 #
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
7 # Licensed under the terms of any of the following licenses at your
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
8 # choice:
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
9 #
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
10 # - GNU General Public License Version 2 or later (the "GPL")
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
11 # http://www.gnu.org/licenses/gpl.html
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
12 #
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
13 # - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
14 # http://www.gnu.org/licenses/lgpl.html
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
15 #
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
16 # - Mozilla Public License Version 1.1 or later (the "MPL")
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
17 # http://www.mozilla.org/MPL/MPL-1.1.html
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
18 #
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
19 # == END LICENSE ==
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
20 #
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
21 # This is the File Manager Connector for Perl.
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
22 #####
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
23
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
24 sub GetUrlFromPath
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
25 {
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
26 local($resourceType, $folderPath) = @_;
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
27
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
28 if($resourceType eq '') {
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
29 $rmpath = &RemoveFromEnd($GLOBALS{'UserFilesPath'},'/');
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
30 return("$rmpath$folderPath");
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
31 } else {
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
32 return("$GLOBALS{'UserFilesPath'}$resourceType$folderPath");
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
33 }
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
34 }
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
35
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
36 sub RemoveExtension
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
37 {
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
38 local($fileName) = @_;
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
39 local($path, $base, $ext);
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
40 if($fileName !~ /\./) {
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
41 $fileName .= '.';
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
42 }
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
43 if($fileName =~ /([^\\\/]*)\.(.*)$/) {
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
44 $base = $1;
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
45 $ext = $2;
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
46 if($fileName =~ /(.*)$base\.$ext$/) {
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
47 $path = $1;
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
48 }
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
49 }
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
50 return($path,$base,$ext);
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
51
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
52 }
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
53
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
54 sub ServerMapFolder
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
55 {
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
56 local($resourceType,$folderPath) = @_;
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
57
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
58 # Get the resource type directory.
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
59 $sResourceTypePath = $GLOBALS{'UserFilesDirectory'} . $resourceType . '/';
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
60
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
61 # Ensure that the directory exists.
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
62 &CreateServerFolder($sResourceTypePath);
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
63
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
64 # Return the resource type directory combined with the required path.
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
65 $rmpath = &RemoveFromStart($folderPath,'/');
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
66 return("$sResourceTypePath$rmpath");
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
67 }
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
68
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
69 sub GetParentFolder
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
70 {
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
71 local($folderPath) = @_;
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
72
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
73 $folderPath =~ s/[\/][^\/]+[\/]?$//g;
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
74 return $folderPath;
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
75 }
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
76
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
77 sub CreateServerFolder
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
78 {
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
79 local($folderPath) = @_;
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
80
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
81 $sParent = &GetParentFolder($folderPath);
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
82 # Check if the parent exists, or create it.
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
83 if(!(-e $sParent)) {
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
84 $sErrorMsg = &CreateServerFolder($sParent);
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
85 if($sErrorMsg == 1) {
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
86 return(1);
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
87 }
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
88 }
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
89 if(!(-e $folderPath)) {
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
90 if (defined $CHMOD_ON_FOLDER_CREATE && !$CHMOD_ON_FOLDER_CREATE) {
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
91 mkdir("$folderPath");
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
92 }
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
93 else {
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
94 umask(000);
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
95 if (defined $CHMOD_ON_FOLDER_CREATE) {
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
96 mkdir("$folderPath",$CHMOD_ON_FOLDER_CREATE);
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
97 }
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
98 else {
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
99 mkdir("$folderPath",0777);
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
100 }
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
101 }
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
102
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
103 return(0);
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
104 } else {
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
105 return(1);
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
106 }
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
107 }
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
108
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
109 sub GetRootPath
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
110 {
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
111 #use Cwd;
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
112
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
113 # my $dir = getcwd;
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
114 # print $dir;
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
115 # $dir =~ s/$ENV{'DOCUMENT_ROOT'}//g;
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
116 # print $dir;
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
117 # return($dir);
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
118
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
119 # $wk = $0;
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
120 # $wk =~ s/\/connector\.cgi//g;
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
121 # if($wk) {
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
122 # $current_dir = $wk;
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
123 # } else {
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
124 # $current_dir = `pwd`;
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
125 # }
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
126 # return($current_dir);
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
127 use Cwd;
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
128
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
129 if($ENV{'DOCUMENT_ROOT'}) {
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
130 $dir = $ENV{'DOCUMENT_ROOT'};
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
131 } else {
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
132 my $dir = getcwd;
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
133 $workdir =~ s/\/connector\.cgi//g;
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
134 $dir =~ s/$workdir//g;
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
135 }
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
136 return($dir);
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
137
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
138
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
139
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
140 }
45d71759f13b add recent version of fckeditor 2.6.3b
Byeongweon [tasyblue@gmail.com]
parents:
diff changeset
141 1;