[ Index ]

PHP Cross Reference of Drupal 6 (yi-drupal)

title

Body

[close]

/sites/all/modules/fckeditor/ -> filemanager.config.php (source)

   1  <?php
   2  
   3  // $Id: filemanager.config.php,v 1.2.2.4.2.4 2008/12/23 15:41:49 wwalc Exp $
   4  /**
   5   * FCKeditor - The text editor for Internet - http://www.fckeditor.net
   6   * Copyright (C) 2003-2008 Frederico Caldeira Knabben
   7   *
   8   * == BEGIN LICENSE ==
   9   *
  10   * Licensed under the terms of any of the following licenses at your
  11   * choice:
  12   *
  13   *  - GNU General Public License Version 2 or later (the "GPL")
  14   *    http://www.gnu.org/licenses/gpl.html
  15   *
  16   *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
  17   *    http://www.gnu.org/licenses/lgpl.html
  18   *
  19   *  - Mozilla Public License Version 1.1 or later (the "MPL")
  20   *    http://www.mozilla.org/MPL/MPL-1.1.html
  21   *
  22   * == END LICENSE ==
  23   *
  24   * @file
  25   * FCKeditor Module for Drupal 6.x
  26   *
  27   * This file is required by FCKeditor module if you want to enable built-in file management functionality
  28   *
  29   * This useful script does the following:
  30   * - authenticate users that are allowed to use file browser
  31   * - redefine the $Config['UserFilesPath'] and $Config['UserFilesAbsolutePath'] according to the values set in FCKeditor profile
  32   */
  33  
  34  $GLOBALS['devel_shutdown'] = FALSE;
  35  
  36  $fck_user_files_path = '';
  37  $fck_user_files_absolute_path = '';
  38  
  39  function CheckAuthentication() {
  40    static $authenticated;
  41  
  42    if (!isset($authenticated)) {
  43      if (!empty($_SERVER['SCRIPT_FILENAME'])) {
  44        $drupal_path = dirname(dirname(dirname(dirname($_SERVER['SCRIPT_FILENAME']))));
  45        if (!file_exists($drupal_path .'/includes/bootstrap.inc')) {
  46          $drupal_path = dirname(dirname(dirname($_SERVER['SCRIPT_FILENAME'])));
  47          $depth = 2;
  48          do {
  49            $drupal_path = dirname($drupal_path);
  50            $depth ++;
  51          }
  52          while (!($bootstrap_file_found = file_exists($drupal_path .'/includes/bootstrap.inc')) && $depth<10);
  53        }
  54      }
  55      if (!isset($bootstrap_file_found) || !$bootstrap_file_found) {
  56        $drupal_path = '../../../';
  57        if (!file_exists($drupal_path .'/includes/bootstrap.inc')) {
  58          $drupal_path = '../..';
  59          do {
  60            $drupal_path .= '/..';
  61            $depth = substr_count($drupal_path, '..');
  62          }
  63          while (!($bootstrap_file_found = file_exists($drupal_path .'/includes/bootstrap.inc')) && $depth < 10);
  64        }
  65      }
  66      if (!isset($bootstrap_file_found) || $bootstrap_file_found) {
  67        $fck_cwd = getcwd();
  68        chdir($drupal_path);
  69        require_once  './includes/bootstrap.inc';
  70        drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
  71        $authenticated = user_access('allow fckeditor file uploads');
  72        if (isset($_SESSION['FCKeditor']['UserFilesPath'], $_SESSION['FCKeditor']['UserFilesAbsolutePath'])) {
  73          $GLOBALS['fck_user_files_path'] = $_SESSION['FCKeditor']['UserFilesPath'];
  74          $GLOBALS['fck_user_files_absolute_path'] = $_SESSION['FCKeditor']['UserFilesAbsolutePath'];
  75        }
  76        chdir($fck_cwd);
  77      }
  78    }
  79  
  80    return $authenticated;
  81  }
  82  
  83  /**
  84   * Note:
  85   * Although in FCKeditor 2.5 $Config['Enabled'] is not used anymore,
  86   * CheckAuthentication() must be called once to initialize session
  87   * before sending any content
  88   * Static $authenticated variable is being assigned, so
  89   * application performance is not affected
  90   */
  91  $Config['Enabled'] = CheckAuthentication();
  92  
  93  if (!empty($fck_user_files_path)) {
  94    $Config['UserFilesPath'] = $fck_user_files_path;
  95    $Config['UserFilesAbsolutePath'] = $fck_user_files_absolute_path;
  96  }
  97  else {
  98    // Nothing in session? Shouldn't happen... anyway let's try to upload it in the (almost) right place
  99    // Path to user files relative to the document root.
 100    $Config['UserFilesPath'] = strtr(base_path(), array(
 101      '/modules/fckeditor/fckeditor/editor/filemanager/connectors/php' => '',
 102      '/modules/fckeditor/fckeditor/editor/filemanager/browser/default/connectors/php' => '',
 103      '/modules/fckeditor/fckeditor/editor/filemanager/upload/php' => '',
 104    )) . file_directory_path() .'/';
 105  }


Generated: Mon Jul 9 18:01:44 2012 Cross-referenced by PHPXref 0.7