source: trunk/expressoMail1_2/inc/fckeditor.php @ 1036

Revision 1036, 4.2 KB checked in by amuller, 15 years ago (diff)

Ticket #559 - Atualização de segurança

Line 
1<?php
2        $GLOBALS['phpgw_info']['flags'] = array(
3                'currentapp' => 'expressoMail1_2',
4                'nonavbar'   => true,
5                'noheader'   => true
6        );
7
8        require_once $_SERVER[ 'DOCUMENT_ROOT' ] . '/header.inc.php';
9/*
10 * FCKeditor - The text editor for internet
11 * Copyright (C) 2003-2006 Frederico Caldeira Knabben
12 *
13 * Licensed under the terms of the GNU Lesser General Public License:
14 *              http://www.opensource.org/licenses/lgpl-license.php
15 *
16 * For further information visit:
17 *              http://www.fckeditor.net/
18 *
19 * "Support Open Source software. What about a donation today?"
20 *
21 * File Name: fckeditor.php
22 *      This is the integration file for PHP.
23 *     
24 *      It defines the FCKeditor class that can be used to create editor
25 *      instances in PHP pages on server side.
26 *
27 * File Authors:
28 *              Frederico Caldeira Knabben (fredck@fckeditor.net)
29 */
30
31class FCKeditor
32{
33        var $InstanceName ;
34        var $BasePath ;
35        var $Width ;
36        var $Height ;
37        var $ToolbarSet ;
38        var $Value ;
39        var $Config ;
40
41        // PHP 5 Constructor (by Marcus Bointon <coolbru@users.sourceforge.net>)
42        function __construct( $instanceName )
43        {
44                $this->InstanceName     = $instanceName ;
45                $this->BasePath         = '/fckeditor/' ;
46                $this->Width            = '100%' ;
47                $this->Height           = '275' ;
48                $this->ToolbarSet       = 'Default' ;
49                $this->Value            = '' ;
50
51                $this->Config           = array() ;
52        }
53       
54        // PHP 4 Contructor
55        function FCKeditor( $instanceName )
56        {
57                $this->__construct( $instanceName ) ;
58        }
59
60        function Create()
61        {
62                return $this->CreateHtml() ;
63        }
64       
65        function CreateHtml()
66        {
67                $HtmlValue = htmlspecialchars( $this->Value ) ;
68
69                $Html = '<div>' ;
70               
71                if ( $this->IsCompatible() )
72                {
73                        if ( isset( $_GET['fcksource'] ) && $_GET['fcksource'] == "true" )
74                                $File = 'fckeditor.original.html' ;
75                        else
76                                $File = 'fckeditor.html' ;
77
78                        $Link = "{$this->BasePath}editor/{$File}?InstanceName={$this->InstanceName}" ;
79                       
80                        if ( $this->ToolbarSet != '' )
81                                $Link .= "&amp;Toolbar={$this->ToolbarSet}" ;
82
83                        // Render the linked hidden field.
84                        $Html .= "<input type=\"hidden\" id=\"{$this->InstanceName}\" name=\"{$this->InstanceName}\" value=\"{$HtmlValue}\" style=\"display:none\" />" ;
85
86                        // Render the configurations hidden field.
87                        $Html .= "<input type=\"hidden\" id=\"{$this->InstanceName}___Config\" value=\"" . $this->GetConfigFieldString() . "\" style=\"display:none\" />" ;
88
89                        // Render the editor IFRAME.
90                        $Html .= "<iframe id=\"{$this->InstanceName}___Frame\" src=\"{$Link}\" width=\"{$this->Width}\" height=\"{$this->Height}\" frameborder=\"0\" scrolling=\"no\"></iframe>" ;
91                }
92                else
93                {
94                        if ( strpos( $this->Width, '%' ) === false )
95                                $WidthCSS = $this->Width . 'px' ;
96                        else
97                                $WidthCSS = $this->Width ;
98
99                        if ( strpos( $this->Height, '%' ) === false )
100                                $HeightCSS = $this->Height . 'px' ;
101                        else
102                                $HeightCSS = $this->Height ;
103
104                        $Html .= "<textarea name=\"{$this->InstanceName}\" rows=\"4\" cols=\"40\" style=\"width: {$WidthCSS}; height: {$HeightCSS}\">{$HtmlValue}</textarea>" ;
105                }
106
107                $Html .= '</div>' ;
108               
109                return $Html ;
110        }
111
112        function IsCompatible()
113        {
114                global $HTTP_USER_AGENT ;
115
116                if ( isset( $HTTP_USER_AGENT ) )
117                        $sAgent = $HTTP_USER_AGENT ;
118                else
119                        $sAgent = $_SERVER['HTTP_USER_AGENT'] ;
120
121                if ( strpos($sAgent, 'MSIE') !== false && strpos($sAgent, 'mac') === false && strpos($sAgent, 'Opera') === false )
122                {
123                        $iVersion = (float)substr($sAgent, strpos($sAgent, 'MSIE') + 5, 3) ;
124                        return ($iVersion >= 5.5) ;
125                }
126                else if ( strpos($sAgent, 'Gecko/') !== false )
127                {
128                        $iVersion = (int)substr($sAgent, strpos($sAgent, 'Gecko/') + 6, 8) ;
129                        return ($iVersion >= 20030210) ;
130                }
131                else
132                        return false ;
133        }
134
135        function GetConfigFieldString()
136        {
137                $sParams = '' ;
138                $bFirst = true ;
139
140                foreach ( $this->Config as $sKey => $sValue )
141                {
142                        if ( $bFirst == false )
143                                $sParams .= '&amp;' ;
144                        else
145                                $bFirst = false ;
146                       
147                        if ( $sValue === true )
148                                $sParams .= $this->EncodeConfig( $sKey ) . '=true' ;
149                        else if ( $sValue === false )
150                                $sParams .= $this->EncodeConfig( $sKey ) . '=false' ;
151                        else
152                                $sParams .= $this->EncodeConfig( $sKey ) . '=' . $this->EncodeConfig( $sValue ) ;
153                }
154               
155                return $sParams ;
156        }
157
158        function EncodeConfig( $valueToEncode )
159        {
160                $chars = array(
161                        '&' => '%26',
162                        '=' => '%3D',
163                        '"' => '%22' ) ;
164
165                return strtr( $valueToEncode,  $chars ) ;
166        }
167}
168
169?>
Note: See TracBrowser for help on using the repository browser.