connector.php
上传用户:wlfwy2004
上传日期:2016-12-12
资源大小:33978k
文件大小:6k
源码类别:

Jsp/Servlet

开发平台:

Java

  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.  * File Name: connector.php
  13.  *  Main connector file, implements the State Pattern to 
  14.  *  redirect requests to the appropriate class based on 
  15.  *  the command name passed.
  16.  * 
  17.  * File Authors:
  18.  *  Grant French (grant@mcpuk.net)
  19.  */
  20. //Errors in the config.php could still cause problems.
  21. global $fckphp_config;
  22. require_once "config.php";
  23. error_reporting(E_ALL);
  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: $errlinen");
  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-------------------------------------------------------nnn");
  43. fwrite($fh,$oldData); $oldData="";
  44. fclose($fh);
  45. $reported=true;
  46. }
  47. if (!$reported) {
  48. //display error instead.
  49. echo("PHP ERROR::: <br />
  50. Error Number: $errno <br />
  51. Error Message: $errstr <br />
  52. Error File: $errfile <br />
  53. Error Line: $errline <br />");
  54. if ($fckphp_config['Debug_Trace']) echo "Error Context: ".print_r($errcontext,true)."n";
  55. if ($fckphp_config['Debug_GET']) echo "$_GET::n".print_r($_GET,true)."<br />n";
  56. if ($fckphp_config['Debug_POST']) echo "$_POST::n".print_r($_POST,true)."<br />n";
  57. if ($fckphp_config['Debug_SERVER']) echo "$_SERVER::n".print_r($_SERVER,true)."<br />n";
  58. if ($fckphp_config['Debug_SESSIONS']) echo "$_SESSIONS::n".print_r($_SESSION,true)."<br />n";
  59. echo "<br />n<br />n";
  60. }
  61. }
  62. }
  63. set_error_handler('errorHandler');
  64. if (!isset($_SERVER['DOCUMENT_ROOT'])) $_SERVER["DOCUMENT_ROOT"] = $fckphp_config['basedir'];
  65. if ($fckphp_config['Debug']===true && $fckphp_config['Debug_Output']) ob_start();
  66. outputHeaders();
  67. //These are the commands we may expect
  68. $valid_commands=$fckphp_config['Commands'];
  69. $valid_resource_types=$fckphp_config['ResourceTypes'];
  70. //Get the passed data
  71. $command=(
  72. ((isset($_GET['Command']))&&($_GET['Command']!=""))?
  73. $_GET['Command']:
  74. ""
  75. );
  76. $type=(
  77. ((isset($_GET['Type']))&&($_GET['Type']!=""))?
  78. $_GET['Type']:
  79. "File"
  80. );
  81. $cwd=str_replace("..","",
  82. (
  83. ((isset($_GET['CurrentFolder']))&&($_GET['CurrentFolder']!=""))?
  84. $_GET['CurrentFolder']:
  85. "/"
  86. )
  87. );
  88. $cwd=str_replace("..","",$cwd);
  89. $extra=(
  90. ((isset($_GET['ExtraParams']))&&($_GET['ExtraParams']!=""))?
  91. $_GET['ExtraParams']:
  92. ""
  93. );
  94. if (in_array($command,$valid_commands)) {
  95. if ($fckphp_config['auth']['Req']) {
  96. require_once "./Auth/".$fckphp_config['auth']['HandlerClass'].".php";
  97. $auth=new Auth();
  98. $fckphp_config=$auth->authenticate($extra,$fckphp_config);
  99. if ($fckphp_config['authSuccess']!==true) {
  100. header ("content-type: text/xml");
  101. echo "<?xml version="1.0" encoding="utf-8" ?>n";
  102. ?>
  103. <Connector command="authentication_failed" resourceType="authentication_failed">
  104. <CurrentFolder path="authentication_failed" url="authentication_failed" />
  105. <Error number="-1" />
  106. </Connector><?php
  107. if ($fckphp_config['Debug']===true  && $fckphp_config['Debug_Output']) recordOutput();
  108. exit(0);
  109. }
  110. }
  111. //bit of validation
  112. if (!in_array($type,$valid_resource_types)) {
  113. echo "Invalid resource type.";
  114. if ($fckphp_config['Debug']===true  && $fckphp_config['Debug_Output']) recordOutput();
  115. exit(0);
  116. }
  117. require_once "Commands/$command.php";
  118. $action=new $command($fckphp_config,$type,$cwd);
  119. $action->run();
  120. if ($fckphp_config['Debug']===true && $fckphp_config['Debug_Output']) recordOutput();
  121. } else {
  122. //No reason for me to be here.
  123. echo "Invalid command.";
  124. echo str_replace("n","<br />",print_r($_GET,true));
  125. if ($fckphp_config['Debug']===true  && $fckphp_config['Debug_Output']) recordOutput();
  126. exit(0);
  127. }
  128. function recordOutput() {
  129. global $fckphp_config;
  130. if ($fckphp_config['Debug']===true  && $fckphp_config['Debug_Output']) {
  131. $contents=ob_get_contents();
  132. if (strlen($contents)>0) {
  133. $oldData=implode("",file($fckphp_config['DebugOutput']));
  134. if ($fh=fopen($fckphp_config['DebugOutput'],"w")) {
  135. fwrite($fh,"n".date("d/m/Y H:i:s")."n");
  136. if ($fckphp_config['Debug_GET']) fwrite($fh,"n$_GET::n".print_r($_GET,true)."n");
  137. if ($fckphp_config['Debug_POST']) fwrite($fh,"n$_POST::n".print_r($_POST,true)."n");
  138. if ($fckphp_config['Debug_SERVER']) fwrite($fh,"n$_SERVER::n".print_r($_SERVER,true)."n");
  139. if ($fckphp_config['Debug_SESSIONS']) fwrite($fh,"n$_SESSIONS::n".print_r($_SESSION,true)."n");
  140. fwrite($fh,$contents);
  141. fwrite($fh,"n-------------------------------------------------------nnn");
  142. fwrite($fh,$oldData); $oldData="";
  143. fclose($fh);
  144. }
  145. }
  146. ob_flush();
  147. }
  148. }
  149. function outputHeaders() {
  150. //Anti browser caching headers
  151. //Borrowed from fatboy's implementation  (fatFCK@code247.com)
  152. // ensure file is never cached
  153. // Date in the past
  154. header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
  155. // always modified
  156. header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
  157. // HTTP/1.1
  158. header("Cache-Control: no-store, no-cache, must-revalidate");
  159. header("Cache-Control: post-check=0, pre-check=0", false);
  160. // HTTP/1.0
  161. header("Pragma: no-cache");
  162. }
  163. ?>