PluginProbe
Wp-Insert / 1.2
Wp-Insert v1.2
trunk 1.0 1.1 1.2 1.2.1 1.2.2 1.3.0 1.3.1 1.3.3 1.4 1.5.0 1.5.1 1.5.2 1.5.3 1.6.0 1.6.1 1.6.2 1.7 1.7.1 1.7.2 1.7.3 1.7.4 1.7.5 1.7.6 2.0 All 63 releases
wp-insert / fckeditor / _samples / perl / sample02.cgi

sample02.cgi in Wp-Insert 1.2, at fckeditor/_samples/perl/sample02.cgi

365 lines 5.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 #!/usr/bin/env perl
2
3
4
5 #####
6
7 # FCKeditor - The text editor for Internet - http://www.fckeditor.net
8
9 # Copyright (C) 2003-2009 Frederico Caldeira Knabben
10
11 #
12
13 # == BEGIN LICENSE ==
14
15 #
16
17 # Licensed under the terms of any of the following licenses at your
18
19 # choice:
20
21 #
22
23 # - GNU General Public License Version 2 or later (the "GPL")
24
25 # http://www.gnu.org/licenses/gpl.html
26
27 #
28
29 # - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
30
31 # http://www.gnu.org/licenses/lgpl.html
32
33 #
34
35 # - Mozilla Public License Version 1.1 or later (the "MPL")
36
37 # http://www.mozilla.org/MPL/MPL-1.1.html
38
39 #
40
41 # == END LICENSE ==
42
43 #
44
45 # Sample page.
46
47 #####
48
49
50
51 ## START: Hack for Windows (Not important to understand the editor code... Perl specific).
52
53 if(Windows_check()) {
54
55 chdir(GetScriptPath($0));
56
57 }
58
59
60
61 sub Windows_check
62
63 {
64
65 # IIS,PWS(NT/95)
66
67 $www_server_os = $^O;
68
69 # Win98 & NT(SP4)
70
71 if($www_server_os eq "") { $www_server_os= $ENV{'OS'}; }
72
73 # AnHTTPd/Omni/IIS
74
75 if($ENV{'SERVER_SOFTWARE'} =~ /AnWeb|Omni|IIS\//i) { $www_server_os= 'win'; }
76
77 # Win Apache
78
79 if($ENV{'WINDIR'} ne "") { $www_server_os= 'win'; }
80
81 if($www_server_os=~ /win/i) { return(1); }
82
83 return(0);
84
85 }
86
87
88
89 sub GetScriptPath {
90
91 local($path) = @_;
92
93 if($path =~ /[\:\/\\]/) { $path =~ s/(.*?)[\/\\][^\/\\]+$/$1/; } else { $path = '.'; }
94
95 $path;
96
97 }
98
99 ## END: Hack for IIS
100
101
102
103 require '../../fckeditor.pl';
104
105
106
107 # When $ENV{'PATH_INFO'} cannot be used by perl.
108
109 # $DefRootPath = "/XXXXX/_samples/perl/sample02.cgi"; Please write in script.
110
111
112
113 my $DefServerPath = "";
114
115 my $ServerPath;
116
117
118
119 $ServerPath = &GetServerPath();
120
121
122
123 if($ENV{'REQUEST_METHOD'} eq "POST") {
124
125 read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
126
127 } else {
128
129 $buffer = $ENV{'QUERY_STRING'};
130
131 }
132
133 @pairs = split(/&/,$buffer);
134
135 foreach $pair (@pairs) {
136
137 ($name,$value) = split(/=/,$pair);
138
139 $value =~ tr/+/ /;
140
141 $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
142
143 $value =~ s/\t//g;
144
145 $value =~ s/\r\n/\n/g;
146
147 $FORM{$name} .= "\0" if(defined($FORM{$name}));
148
149 $FORM{$name} .= $value;
150
151 }
152
153
154
155 print "Content-type: text/html\n\n";
156
157 print <<"_HTML_TAG_";
158
159 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
160
161 <html>
162
163 <head>
164
165 <title>FCKeditor - Sample</title>
166
167 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
168
169 <meta name="robots" content="noindex, nofollow">
170
171 <link href="../sample.css" rel="stylesheet" type="text/css" />
172
173 <script type="text/javascript">
174
175
176
177 function FCKeditor_OnComplete( editorInstance )
178
179 {
180
181 var oCombo = document.getElementById( 'cmbLanguages' ) ;
182
183 for ( code in editorInstance.Language.AvailableLanguages )
184
185 {
186
187 AddComboOption( oCombo, editorInstance.Language.AvailableLanguages[code] + ' (' + code + ')', code ) ;
188
189 }
190
191 oCombo.value = editorInstance.Language.ActiveLanguage.Code ;
192
193 }
194
195
196
197 function AddComboOption(combo, optionText, optionValue)
198
199 {
200
201 var oOption = document.createElement("OPTION") ;
202
203
204
205 combo.options.add(oOption) ;
206
207
208
209 oOption.innerHTML = optionText ;
210
211 oOption.value = optionValue ;
212
213
214
215 return oOption ;
216
217 }
218
219
220
221 function ChangeLanguage( languageCode )
222
223 {
224
225 window.location.href = window.location.pathname + "?Lang=" + languageCode ;
226
227 }
228
229 </script>
230
231 </head>
232
233 <body>
234
235 <h1>FCKeditor - Perl - Sample 2</h1>
236
237 This sample shows the editor in all its available languages.
238
239 <hr>
240
241 <table cellpadding="0" cellspacing="0" border="0">
242
243 <tr>
244
245 <td>
246
247 Select a language:&nbsp;
248
249 </td>
250
251 <td>
252
253 <select id="cmbLanguages" onchange="ChangeLanguage(this.value);">
254
255 </select>
256
257 </td>
258
259 </tr>
260
261 </table>
262
263 <br>
264
265 <form action="sampleposteddata.cgi" method="post" target="_blank">
266
267 _HTML_TAG_
268
269
270
271 #// Automatically calculates the editor base path based on the _samples directory.
272
273 #// This is usefull only for these samples. A real application should use something like this:
274
275 #// $oFCKeditor->BasePath = '/fckeditor/' ; // '/fckeditor/' is the default value.
276
277 $sBasePath = $ServerPath;
278
279 $sBasePath = substr( $sBasePath, 0, index($sBasePath,"_samples"));
280
281
282
283 &FCKeditor('FCKeditor1');
284
285 $BasePath = $sBasePath;
286
287
288
289 if($FORM{'Lang'} ne "") {
290
291 $Config{'AutoDetectLanguage'} = "false";
292
293 $Config{'DefaultLanguage'} = $FORM{'Lang'};
294
295 } else {
296
297 $Config{'AutoDetectLanguage'} = "true";
298
299 $Config{'DefaultLanguage'} = 'en' ;
300
301 }
302
303 $Value = '<p>This is some <strong>sample text</strong>. You are using <a href="http://www.fckeditor.net/">FCKeditor</a>.</p>' ;
304
305 &Create();
306
307
308
309 print <<"_HTML_TAG_";
310
311 <br>
312
313 <input type="submit" value="Submit">
314
315 </form>
316
317 </body>
318
319 </html>
320
321 _HTML_TAG_
322
323
324
325 ################
326
327 #Please use this function, rewriting it depending on a server's environment.
328
329 ################
330
331 sub GetServerPath
332
333 {
334
335 my $dir;
336
337
338
339 if($DefServerPath) {
340
341 $dir = $DefServerPath;
342
343 } else {
344
345 if($ENV{'PATH_INFO'}) {
346
347 $dir = $ENV{'PATH_INFO'};
348
349 } elsif($ENV{'FILEPATH_INFO'}) {
350
351 $dir = $ENV{'FILEPATH_INFO'};
352
353 } elsif($ENV{'REQUEST_URI'}) {
354
355 $dir = $ENV{'REQUEST_URI'};
356
357 }
358
359 }
360
361 return($dir);
362
363 }
364
365