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