[ Index ]

PHP Cross Reference of Mambo 4.6.5

[ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/mambots/editors/mostlyce/jscripts/tiny_mce/filemanager/connectors/php/ -> connector.php (source)

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