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

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

335 lines 4.7 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/sample03.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( 'cmbToolbars' ) ;
182
183 oCombo.value = editorInstance.ToolbarSet.Name ;
184
185 oCombo.style.visibility = '' ;
186
187 }
188
189
190
191 function ChangeToolbar( toolbarName )
192
193 {
194
195 window.location.href = window.location.pathname + "?Toolbar=" + toolbarName ;
196
197 }
198
199
200
201 </script>
202
203 </head>
204
205 <body>
206
207 <h1>FCKeditor - Perl - Sample 3</h1>
208
209 This sample shows how to change the editor toolbar.
210
211 <hr>
212
213 <table cellpadding="0" cellspacing="0" border="0">
214
215 <tr>
216
217 <td>
218
219 Select the toolbar to load:&nbsp;
220
221 </td>
222
223 <td>
224
225 <select id="cmbToolbars" onchange="ChangeToolbar(this.value);" style="VISIBILITY: hidden">
226
227 <option value="Default" selected>Default</option>
228
229 <option value="Basic">Basic</option>
230
231 </select>
232
233 </td>
234
235 </tr>
236
237 </table>
238
239 <br>
240
241 <form action="sampleposteddata.cgi" method="post" target="_blank">
242
243 _HTML_TAG_
244
245
246
247 #// Automatically calculates the editor base path based on the _samples directory.
248
249 #// This is usefull only for these samples. A real application should use something like this:
250
251 #// $oFCKeditor->BasePath = '/fckeditor/' ; // '/fckeditor/' is the default value.
252
253
254
255 $sBasePath = $ServerPath;
256
257 $sBasePath = substr($sBasePath, 0, index( $sBasePath, "_samples" ));
258
259
260
261 &FCKeditor('FCKeditor1') ;
262
263 $BasePath = $sBasePath ;
264
265
266
267 if($FORM{'Toolbar'} ne "") {
268
269 $ToolbarSet = &specialchar_cnv( $FORM{'Toolbar'} );
270
271 }
272
273 $Value = '<p>This is some <strong>sample text</strong>. You are using <a href="http://www.fckeditor.net/">FCKeditor</a>.</p>' ;
274
275 &Create();
276
277
278
279 print <<"_HTML_TAG_";
280
281 <br>
282
283 <input type="submit" value="Submit">
284
285 </form>
286
287 </body>
288
289 </html>
290
291 _HTML_TAG_
292
293
294
295 ################
296
297 #Please use this function, rewriting it depending on a server's environment.
298
299 ################
300
301 sub GetServerPath
302
303 {
304
305 my $dir;
306
307
308
309 if($DefServerPath) {
310
311 $dir = $DefServerPath;
312
313 } else {
314
315 if($ENV{'PATH_INFO'}) {
316
317 $dir = $ENV{'PATH_INFO'};
318
319 } elsif($ENV{'FILEPATH_INFO'}) {
320
321 $dir = $ENV{'FILEPATH_INFO'};
322
323 } elsif($ENV{'REQUEST_URI'}) {
324
325 $dir = $ENV{'REQUEST_URI'};
326
327 }
328
329 }
330
331 return($dir);
332
333 }
334
335