Projet

Général

Profil

Paste
Télécharger (3,71 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / ckeditor / includes / filemanager.config.php @ 2e0f6994

1
<?php
2

    
3
/**
4
 * CKEditor - The text editor for the Internet - http://ckeditor.com
5
 * Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved.
6
 *
7
 * == BEGIN LICENSE ==
8
 *
9
 * Licensed under the terms of any of the following licenses of your
10
 * choice:
11
 *
12
 *  - GNU General Public License Version 2 or later (the "GPL")
13
 *    http://www.gnu.org/licenses/gpl.html
14
 *
15
 *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
16
 *    http://www.gnu.org/licenses/lgpl.html
17
 *
18
 *  - Mozilla Public License Version 1.1 or later (the "MPL")
19
 *    http://www.mozilla.org/MPL/MPL-1.1.html
20
 *
21
 * == END LICENSE ==
22
 *
23
 * @file
24
 * CKEditor Module for Drupal 7.x
25
 *
26
 * This file is required by the CKEeditor module if you want to enable CKFinder,
27
 * an advanced Ajax file browser.
28
 *
29
 */
30
$GLOBALS['devel_shutdown'] = FALSE;
31

    
32
if (!function_exists('ob_list_handlers') || ob_list_handlers()) {
33
  @ob_end_clean();
34
}
35

    
36
$ckfinder_user_files_path = '';
37
$ckfinder_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
        } while (!($bootstrap_file_found = file_exists($drupal_path . '/includes/bootstrap.inc')) && $depth < 10);
52
      }
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
        } while (!($bootstrap_file_found = file_exists($drupal_path . '/includes/bootstrap.inc')) && $depth < 10);
63
      }
64
    }
65
    if (!isset($bootstrap_file_found) || $bootstrap_file_found) {
66
      $current_cwd = getcwd();
67
      chdir($drupal_path);
68
      if (!defined('DRUPAL_ROOT')) {
69
        define('DRUPAL_ROOT', $drupal_path);
70
      }
71
      require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
72
      drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
73
      $authenticated = user_access('allow CKFinder file uploads');
74
      if (isset($_GET['id'], $_SESSION['ckeditor'][$_GET['id']]['UserFilesPath'], $_SESSION['ckeditor'][$_GET['id']]['UserFilesAbsolutePath'])) {
75
        $_SESSION['ckeditor']['UserFilesPath'] = $_SESSION['ckeditor'][$_GET['id']]['UserFilesPath'];
76
        $_SESSION['ckeditor']['UserFilesAbsolutePath'] = $_SESSION['ckeditor'][$_GET['id']]['UserFilesAbsolutePath'];
77
      }
78
      chdir($current_cwd);
79
    }
80
  }
81

    
82
  return $authenticated;
83
}
84

    
85
CheckAuthentication();
86

    
87
if (isset($_SESSION['ckeditor']['UserFilesPath'], $_SESSION['ckeditor']['UserFilesAbsolutePath'])) {
88
  $baseUrl = $_SESSION['ckeditor']['UserFilesPath'];
89
  // To deal with multiple application servers it's better to let CKFinder guess the server path based on the URL,
90
  // because the server side path changes on each request (#2127467).
91
  if (isset($_SERVER['PANTHEON_ENVIRONMENT'])) {
92
    $baseDir = resolveUrl($baseUrl);
93
  }
94
  else {
95
    $baseDir = $_SESSION['ckeditor']['UserFilesAbsolutePath'];
96
  }
97
}
98
else {
99
  // Nothing in session? Shouldn't happen... anyway let's try to upload it in the (almost) right place
100
  // Path to user files relative to the document root.
101
  $baseUrl = strtr(base_path(), array(
102
        drupal_get_path('module','ckeditor') . '/ckfinder/core/connector/php' => '',
103
      )) . variable_get('file_private_path', conf_path() . '/files') . '/';
104
  $baseDir = resolveUrl($baseUrl);
105
}