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 / sample04.cgi

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

349 lines 4.9 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/sample04.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 #!!Caution javascript \ Quart
156
157
158
159 print "Content-type: text/html\n\n";
160
161 print <<"_HTML_TAG_";
162
163 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
164
165 <html>
166
167 <head>
168
169 <title>FCKeditor - Sample</title>
170
171 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
172
173 <meta name="robots" content="noindex, nofollow">
174
175 <link href="../sample.css" rel="stylesheet" type="text/css" />
176
177 <script type="text/javascript">
178
179
180
181 function FCKeditor_OnComplete( editorInstance )
182
183 {
184
185 var oCombo = document.getElementById( 'cmbSkins' ) ;
186
187
188
189 // Get the active skin.
190
191 var sSkin = editorInstance.Config['SkinPath'] ;
192
193 sSkin = sSkin.match(/[^\\/]+(?=\\/\$)/g) ;
194
195
196
197 oCombo.value = sSkin ;
198
199 oCombo.style.visibility = '' ;
200
201 }
202
203
204
205 function ChangeSkin( skinName )
206
207 {
208
209 window.location.href = window.location.pathname + "?Skin=" + skinName ;
210
211 }
212
213
214
215 </script>
216
217 </head>
218
219 <body>
220
221 <h1>FCKeditor - Perl - Sample 4</h1>
222
223 This sample shows how to change the editor skin.
224
225 <hr>
226
227 <table cellpadding="0" cellspacing="0" border="0">
228
229 <tr>
230
231 <td>
232
233 Select the skin to load:&nbsp;
234
235 </td>
236
237 <td>
238
239 <select id="cmbSkins" onchange="ChangeSkin(this.value);" style="VISIBILITY: hidden">
240
241 <option value="default" selected>Default</option>
242
243 <option value="office2003">Office 2003</option>
244
245 <option value="silver">Silver</option>
246
247 </select>
248
249 </td>
250
251 </tr>
252
253 </table>
254
255 <br>
256
257 <form action="sampleposteddata.cgi" method="post" target="_blank">
258
259 _HTML_TAG_
260
261
262
263 #// Automatically calculates the editor base path based on the _samples directory.
264
265 #// This is usefull only for these samples. A real application should use something like this:
266
267 #// $oFCKeditor->BasePath = '/fckeditor/' ; // '/fckeditor/' is the default value.
268
269 $sBasePath = $ServerPath;
270
271 $sBasePath = substr( $sBasePath, 0, index( $sBasePath, "_samples" ) ) ;
272
273
274
275 &FCKeditor('FCKeditor1');
276
277 $BasePath = $sBasePath;
278
279
280
281 if($FORM{'Skin'} ne "") {
282
283 $Config{'SkinPath'} = $sBasePath . 'editor/skins/' . &specialchar_cnv( $FORM{'Skin'} ) . '/' ;
284
285 }
286
287 $Value = '<p>This is some <strong>sample text</strong>. You are using <a href="http://www.fckeditor.net/">FCKeditor</a>.</p>' ;
288
289 &Create() ;
290
291
292
293 print <<"_HTML_TAG_";
294
295 <br>
296
297 <input type="submit" value="Submit">
298
299 </form>
300
301 </body>
302
303 </html>
304
305 _HTML_TAG_
306
307
308
309 ################
310
311 #Please use this function, rewriting it depending on a server's environment.
312
313 ################
314
315 sub GetServerPath
316
317 {
318
319 my $dir;
320
321
322
323 if($DefServerPath) {
324
325 $dir = $DefServerPath;
326
327 } else {
328
329 if($ENV{'PATH_INFO'}) {
330
331 $dir = $ENV{'PATH_INFO'};
332
333 } elsif($ENV{'FILEPATH_INFO'}) {
334
335 $dir = $ENV{'FILEPATH_INFO'};
336
337 } elsif($ENV{'REQUEST_URI'}) {
338
339 $dir = $ENV{'REQUEST_URI'};
340
341 }
342
343 }
344
345 return($dir);
346
347 }
348
349