source: companies/celepar/news_admin/templates/celepar/fckeditor/to_delete/_samples/perl/sample03.cgi @ 763

Revision 763, 4.3 KB checked in by niltonneto, 15 years ago (diff)

Importação inicial do Expresso da Celepar

Line 
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: sample03.cgi
16#       Sample page.
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).
23if(Windows_check()) {
24        chdir(GetScriptPath($0));
25}
26
27sub 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
41sub GetScriptPath {
42        local($path) = @_;
43        if($path =~ /[\:\/\\]/) { $path =~ s/(.*?)[\/\\][^\/\\]+$/$1/; } else { $path = '.'; }
44        $path;
45}
46## END: Hack for IIS
47
48require '../../fckeditor.pl';
49
50# When $ENV{'PATH_INFO'} cannot be used by perl.
51# $DefRootPath = "/XXXXX/_samples/perl/sample03.cgi"; Please write in script.
52
53my $DefServerPath = "";
54my $ServerPath;
55
56        $ServerPath = &GetServerPath();
57
58        if($ENV{'REQUEST_METHOD'} eq "POST") {
59                read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
60        } else {
61                $buffer = $ENV{'QUERY_STRING'};
62        }
63        @pairs = split(/&/,$buffer);
64        foreach $pair (@pairs) {
65                ($name,$value) = split(/=/,$pair);
66                $value =~ tr/+/ /;
67                $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
68                $value =~ s/\t//g;
69                $value =~ s/\r\n/\n/g;
70                $FORM{$name} .= "\0"                    if(defined($FORM{$name}));
71                $FORM{$name} .= $value;
72        }
73
74        print "Content-type: text/html\n\n";
75        print <<"_HTML_TAG_";
76<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
77<html>
78        <head>
79                <title>FCKeditor - Sample</title>
80                <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
81                <meta name="robots" content="noindex, nofollow">
82                <link href="../sample.css" rel="stylesheet" type="text/css" />
83                <script type="text/javascript">
84
85function FCKeditor_OnComplete( editorInstance )
86{
87        var oCombo = document.getElementById( 'cmbToolbars' ) ;
88        oCombo.value = editorInstance.ToolbarSet.Name ;
89        oCombo.style.visibility = '' ;
90}
91
92function ChangeToolbar( toolbarName )
93{
94        window.location.href = window.location.pathname + "?Toolbar=" + toolbarName ;
95}
96
97                </script>
98        </head>
99        <body>
100                <h1>FCKeditor - Perl - Sample 3</h1>
101                This sample shows how to change the editor toolbar.
102                <hr>
103                <table cellpadding="0" cellspacing="0" border="0">
104                        <tr>
105                                <td>
106                                        Select the toolbar to load:&nbsp;
107                                </td>
108                                <td>
109                                        <select id="cmbToolbars" onchange="ChangeToolbar(this.value);" style="VISIBILITY: hidden">
110                                                <option value="Default" selected>Default</option>
111                                                <option value="Basic">Basic</option>
112                                        </select>
113                                </td>
114                        </tr>
115                </table>
116                <br>
117                <form action="sampleposteddata.cgi" method="post" target="_blank">
118_HTML_TAG_
119
120        #// Automatically calculates the editor base path based on the _samples directory.
121        #// This is usefull only for these samples. A real application should use something like this:
122        #// $oFCKeditor->BasePath = '/fckeditor/' ;     // '/fckeditor/' is the default value.
123
124        $sBasePath = $ServerPath;
125        $sBasePath = substr($sBasePath, 0, index( $sBasePath, "_samples" ));
126
127        &FCKeditor('FCKeditor1') ;
128        $BasePath = $sBasePath ;
129
130        if($FORM{'Toolbar'} ne "") {
131                $ToolbarSet = &specialchar_cnv( $FORM{'Toolbar'} );
132        }
133        $Value = 'This is some <strong>sample text</strong>. You are using <a href="http://www.fckeditor.net/">FCKeditor</a>.' ;
134        &Create();
135
136        print <<"_HTML_TAG_";
137                        <br>
138                        <input type="submit" value="Submit">
139                </form>
140        </body>
141</html>
142_HTML_TAG_
143
144################
145#Please use this function, rewriting it depending on a server's environment.
146################
147sub GetServerPath
148{
149my $dir;
150
151        if($DefServerPath) {
152                $dir = $DefServerPath;
153        } else {
154                if($ENV{'PATH_INFO'}) {
155                        $dir  = $ENV{'PATH_INFO'};
156                } elsif($ENV{'FILEPATH_INFO'}) {
157                        $dir  = $ENV{'FILEPATH_INFO'};
158                }
159        }
160        return($dir);
161}
Note: See TracBrowser for help on using the repository browser.