1 | #!/usr/bin/env perl
|
---|
2 |
|
---|
3 | #####
|
---|
4 | # FCKeditor - The text editor for internet
|
---|
5 | # Copyright (C) 2003-2006 Frederico Caldeira Knabben
|
---|
6 | #
|
---|
7 | # Licensed under the terms of the GNU Lesser General Public License:
|
---|
8 | # http://www.opensource.org/licenses/lgpl-license.php
|
---|
9 | #
|
---|
10 | # For further information visit:
|
---|
11 | # http://www.fckeditor.net/
|
---|
12 | #
|
---|
13 | # "Support Open Source software. What about a donation today?"
|
---|
14 | #
|
---|
15 | # File Name: sampleposteddata.cgi
|
---|
16 | # This page lists the data posted by a form.
|
---|
17 | #
|
---|
18 | # File Authors:
|
---|
19 | # Takashi Yamaguchi (jack@omakase.net)
|
---|
20 | #####
|
---|
21 |
|
---|
22 | ## START: Hack for Windows (Not important to understand the editor code... Perl specific).
|
---|
23 | if(Windows_check()) {
|
---|
24 | chdir(GetScriptPath($0));
|
---|
25 | }
|
---|
26 |
|
---|
27 | sub Windows_check
|
---|
28 | {
|
---|
29 | # IIS,PWS(NT/95)
|
---|
30 | $www_server_os = $^O;
|
---|
31 | # Win98 & NT(SP4)
|
---|
32 | if($www_server_os eq "") { $www_server_os= $ENV{'OS'}; }
|
---|
33 | # AnHTTPd/Omni/IIS
|
---|
34 | if($ENV{'SERVER_SOFTWARE'} =~ /AnWeb|Omni|IIS\//i) { $www_server_os= 'win'; }
|
---|
35 | # Win Apache
|
---|
36 | if($ENV{'WINDIR'} ne "") { $www_server_os= 'win'; }
|
---|
37 | if($www_server_os=~ /win/i) { return(1); }
|
---|
38 | return(0);
|
---|
39 | }
|
---|
40 |
|
---|
41 | sub GetScriptPath {
|
---|
42 | local($path) = @_;
|
---|
43 | if($path =~ /[\:\/\\]/) { $path =~ s/(.*?)[\/\\][^\/\\]+$/$1/; } else { $path = '.'; }
|
---|
44 | $path;
|
---|
45 | }
|
---|
46 | ## END: Hack for IIS
|
---|
47 |
|
---|
48 | require '../../fckeditor.pl';
|
---|
49 |
|
---|
50 | if($ENV{'REQUEST_METHOD'} eq "POST") {
|
---|
51 | read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
|
---|
52 | } else {
|
---|
53 | $buffer = $ENV{'QUERY_STRING'};
|
---|
54 | }
|
---|
55 | @pairs = split(/&/,$buffer);
|
---|
56 | foreach $pair (@pairs) {
|
---|
57 | ($name,$value) = split(/=/,$pair);
|
---|
58 | $value =~ tr/+/ /;
|
---|
59 | $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
|
---|
60 | $value =~ s/\t//g;
|
---|
61 | $value =~ s/\r\n/\n/g;
|
---|
62 | $FORM{$name} .= "\0" if(defined($FORM{$name}));
|
---|
63 | $FORM{$name} .= $value;
|
---|
64 | }
|
---|
65 |
|
---|
66 | print "Content-type: text/html\n\n";
|
---|
67 | print <<"_HTML_TAG_";
|
---|
68 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
---|
69 |
|
---|
70 | <html>
|
---|
71 | <head>
|
---|
72 | <title>FCKeditor - Samples - Posted Data</title>
|
---|
73 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
---|
74 | <meta name="robots" content="noindex, nofollow">
|
---|
75 | <link href="../sample.css" rel="stylesheet" type="text/css" />
|
---|
76 | </head>
|
---|
77 | <body>
|
---|
78 | <h1>FCKeditor - Samples - Posted Data</h1>
|
---|
79 | This page lists all data posted by the form.
|
---|
80 | <hr>
|
---|
81 | <table width="100%" border="1" cellspacing="0" bordercolor="#999999">
|
---|
82 | <tr style="FONT-WEIGHT: bold; COLOR: #dddddd; BACKGROUND-COLOR: #999999">
|
---|
83 | <td nowrap>Field Name </td>
|
---|
84 | <td>Value</td>
|
---|
85 | </tr>
|
---|
86 | _HTML_TAG_
|
---|
87 |
|
---|
88 | foreach $key (keys %FORM) {
|
---|
89 | $postedValue = &specialchar_cnv($FORM{$key});
|
---|
90 | print <<"_HTML_TAG_";
|
---|
91 | <tr>
|
---|
92 | <td valign="top" nowrap><b>$key</b></td>
|
---|
93 | <td width="100%">$postedValue</td>
|
---|
94 | </tr>
|
---|
95 | _HTML_TAG_
|
---|
96 | }
|
---|
97 | print <<"_HTML_TAG_";
|
---|
98 | </table>
|
---|
99 | </body>
|
---|
100 | </html>
|
---|
101 | _HTML_TAG_
|
---|