~ubuntu-branches/ubuntu/intrepid/moin/intrepid-updates

« back to all changes in this revision

Viewing changes to wiki/htdocs/applets/FCKeditor/editor/filemanager/browser/mcpuk/connectors/php/connector.php

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2006-02-14 16:09:24 UTC
  • mfrom: (0.2.13 upstream)
  • Revision ID: james.westby@ubuntu.com-20060214160924-fyrx3gvknzqvt4vj
Tags: 1.5.2-1ubuntu1
Drop python2.3 package.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?php 
2
 
/*
3
 
 * FCKeditor - The text editor for internet
4
 
 * Copyright (C) 2003-2005 Frederico Caldeira Knabben
5
 
 * 
6
 
 * Licensed under the terms of the GNU Lesser General Public License:
7
 
 *              http://www.opensource.org/licenses/lgpl-license.php
8
 
 * 
9
 
 * For further information visit:
10
 
 *              http://www.fckeditor.net/
11
 
 * 
12
 
 * "Support Open Source software. What about a donation today?"
13
 
 * 
14
 
 * File Name: connector.php
15
 
 *      Main connector file, implements the State Pattern to 
16
 
 *      redirect requests to the appropriate class based on 
17
 
 *      the command name passed.
18
 
 * 
19
 
 * File Authors:
20
 
 *              Grant French (grant@mcpuk.net)
21
 
 */
22
 
//Errors in the config.php could still cause problems.
23
 
global $fckphp_config;
24
 
require_once "config.php";
25
 
 
26
 
error_reporting(E_ALL);
27
 
function errorHandler ($errno, $errstr, $errfile, $errline, $errcontext) {
28
 
        $reported=false;
29
 
        if (strpos($errstr,"var: Deprecated.")===false) {
30
 
                global $fckphp_config;
31
 
                if ($fckphp_config['Debug']===true && $fckphp_config['Debug_Errors']===true) {
32
 
                        $oldData=implode("",file($fckphp_config['DebugOutput']));
33
 
                        if ($fh=fopen($fckphp_config['DebugOutput'],"w")) {
34
 
                                fwrite($fh,"\n".date("d/m/Y H:i:s")."\n");
35
 
                                fwrite($fh,"PHP ERROR::: 
36
 
                                                Error Number: $errno
37
 
                                                Error Message: $errstr
38
 
                                                Error File: $errfile
39
 
                                                Error Line: $errline\n");
40
 
                                if ($fckphp_config['Debug_Trace']) fwrite($fh,"         Error Context: ".print_r($errcontext,true)."\n");
41
 
                                if ($fckphp_config['Debug_GET']) fwrite($fh,"\n\$_GET::\n".print_r($_GET,true)."\n");
42
 
                                if ($fckphp_config['Debug_POST']) fwrite($fh,"\n\$_POST::\n".print_r($_POST,true)."\n");
43
 
                                if ($fckphp_config['Debug_SERVER']) fwrite($fh,"\n\$_SERVER::\n".print_r($_SERVER,true)."\n");
44
 
                                if ($fckphp_config['Debug_SESSIONS']) fwrite($fh,"\n\$_SESSIONS::\n".print_r($_SESSION,true)."\n");
45
 
                                fwrite($fh,"\n-------------------------------------------------------\n\n\n");
46
 
                                fwrite($fh,$oldData); $oldData="";
47
 
                                fclose($fh);
48
 
                                $reported=true;
49
 
                        } 
50
 
                }
51
 
                
52
 
                if (!$reported) {
53
 
                        //display error instead.
54
 
                        echo("PHP ERROR::: <br />
55
 
                                        Error Number: $errno <br />
56
 
                                        Error Message: $errstr <br />
57
 
                                        Error File: $errfile <br />
58
 
                                        Error Line: $errline <br />");
59
 
                                
60
 
                        if ($fckphp_config['Debug_Trace']) echo "Error Context: ".print_r($errcontext,true)."\n";       
61
 
                        if ($fckphp_config['Debug_GET']) echo "\$_GET::\n".print_r($_GET,true)."<br />\n";
62
 
                        if ($fckphp_config['Debug_POST']) echo "\$_POST::\n".print_r($_POST,true)."<br />\n";
63
 
                        if ($fckphp_config['Debug_SERVER']) echo "\$_SERVER::\n".print_r($_SERVER,true)."<br />\n";
64
 
                        if ($fckphp_config['Debug_SESSIONS']) echo "\$_SESSIONS::\n".print_r($_SESSION,true)."<br />\n";
65
 
                        echo "<br />\n<br />\n";
66
 
                }
67
 
        }
68
 
}
69
 
set_error_handler('errorHandler');
70
 
 
71
 
if (!isset($_SERVER['DOCUMENT_ROOT'])) $_SERVER["DOCUMENT_ROOT"] = $fckphp_config['basedir'];
72
 
 
73
 
if ($fckphp_config['Debug']===true && $fckphp_config['Debug_Output']) ob_start();
74
 
outputHeaders();
75
 
 
76
 
//These are the commands we may expect
77
 
$valid_commands=$fckphp_config['Commands'];
78
 
$valid_resource_types=$fckphp_config['ResourceTypes'];
79
 
 
80
 
//Get the passed data
81
 
$command=(
82
 
                ((isset($_GET['Command']))&&($_GET['Command']!=""))?
83
 
                        $_GET['Command']:
84
 
                        ""
85
 
                );
86
 
                
87
 
$type=(
88
 
                ((isset($_GET['Type']))&&($_GET['Type']!=""))?
89
 
                        $_GET['Type']:
90
 
                        "File"
91
 
                );
92
 
                
93
 
$cwd=str_replace("..","",
94
 
                (
95
 
                ((isset($_GET['CurrentFolder']))&&($_GET['CurrentFolder']!=""))?
96
 
                        $_GET['CurrentFolder']:
97
 
                        "/"
98
 
                )
99
 
                );
100
 
                
101
 
$cwd=str_replace("..","",$cwd);
102
 
 
103
 
$extra=(
104
 
                ((isset($_GET['ExtraParams']))&&($_GET['ExtraParams']!=""))?
105
 
                        $_GET['ExtraParams']:
106
 
                        ""
107
 
                );
108
 
 
109
 
if (in_array($command,$valid_commands)) {
110
 
 
111
 
        if ($fckphp_config['auth']['Req']) {
112
 
                require_once "./Auth/".$fckphp_config['auth']['HandlerClass'].".php";
113
 
                
114
 
                $auth=new Auth();
115
 
                $fckphp_config=$auth->authenticate($extra,$fckphp_config);
116
 
                if ($fckphp_config['authSuccess']!==true) {
117
 
                        header ("content-type: text/xml");
118
 
                        echo "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n";
119
 
                        ?>
120
 
<Connector command="authentication_failed" resourceType="authentication_failed">
121
 
        <CurrentFolder path="authentication_failed" url="authentication_failed" />
122
 
        <Error number="-1" />
123
 
</Connector><?php
124
 
                        if ($fckphp_config['Debug']===true  && $fckphp_config['Debug_Output']) recordOutput();
125
 
                        exit(0);
126
 
                }
127
 
        }
128
 
 
129
 
        //bit of validation
130
 
        if (!in_array($type,$valid_resource_types)) {
131
 
                echo "Invalid resource type.";
132
 
                if ($fckphp_config['Debug']===true  && $fckphp_config['Debug_Output']) recordOutput();
133
 
                exit(0);
134
 
        }
135
 
        
136
 
        require_once "Commands/$command.php";
137
 
 
138
 
        $action=new $command($fckphp_config,$type,$cwd);
139
 
 
140
 
        $action->run();
141
 
        if ($fckphp_config['Debug']===true && $fckphp_config['Debug_Output']) recordOutput();
142
 
        
143
 
} else {
144
 
        //No reason for me to be here.
145
 
        echo "Invalid command.";
146
 
        echo str_replace("\n","<br />",print_r($_GET,true));
147
 
        if ($fckphp_config['Debug']===true  && $fckphp_config['Debug_Output']) recordOutput();
148
 
        exit(0);
149
 
}
150
 
 
151
 
 
152
 
function recordOutput() {
153
 
        global $fckphp_config;
154
 
 
155
 
        if ($fckphp_config['Debug']===true  && $fckphp_config['Debug_Output']) {
156
 
                $contents=ob_get_contents();
157
 
                if (strlen($contents)>0) {
158
 
                        $oldData=implode("",file($fckphp_config['DebugOutput']));
159
 
                        if ($fh=fopen($fckphp_config['DebugOutput'],"w")) {
160
 
                                fwrite($fh,"\n".date("d/m/Y H:i:s")."\n");
161
 
                                if ($fckphp_config['Debug_GET']) fwrite($fh,"\n\$_GET::\n".print_r($_GET,true)."\n");
162
 
                                if ($fckphp_config['Debug_POST']) fwrite($fh,"\n\$_POST::\n".print_r($_POST,true)."\n");
163
 
                                if ($fckphp_config['Debug_SERVER']) fwrite($fh,"\n\$_SERVER::\n".print_r($_SERVER,true)."\n");
164
 
                                if ($fckphp_config['Debug_SESSIONS']) fwrite($fh,"\n\$_SESSIONS::\n".print_r($_SESSION,true)."\n");
165
 
                                fwrite($fh,$contents);
166
 
                                fwrite($fh,"\n-------------------------------------------------------\n\n\n");
167
 
                                fwrite($fh,$oldData); $oldData="";
168
 
                                fclose($fh);
169
 
                        }
170
 
                }
171
 
                ob_flush();
172
 
        }
173
 
}
174
 
 
175
 
function outputHeaders() {
176
 
 
177
 
        //Anti browser caching headers
178
 
        //Borrowed from fatboy's implementation  (fatFCK@code247.com)
179
 
        
180
 
        // ensure file is never cached
181
 
        // Date in the past
182
 
        header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
183
 
        
184
 
        // always modified
185
 
        header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
186
 
        
187
 
        // HTTP/1.1
188
 
        header("Cache-Control: no-store, no-cache, must-revalidate");
189
 
        header("Cache-Control: post-check=0, pre-check=0", false);
190
 
        
191
 
        // HTTP/1.0
192
 
        header("Pragma: no-cache");
193
 
}
194
 
?>