#548580 warning message related to stylesheets in fckeditor.module
[project/fckeditor.git] / filemanager.config.php
1 <?php
2
3 // $Id$
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 5.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 {
41 static $authenticated;
42
43 if (!isset($authenticated)) {
44 $result = false;
45
46 if (!empty($_SERVER['SCRIPT_FILENAME'])) {
47 $drupal_path = dirname(dirname(dirname(dirname($_SERVER['SCRIPT_FILENAME']))));
48 if(!file_exists($drupal_path . "/includes/bootstrap.inc")) {
49 $drupal_path = dirname(dirname(dirname($_SERVER['SCRIPT_FILENAME'])));
50 $depth = 2;
51 do {
52 $drupal_path = dirname($drupal_path);
53 $depth ++;
54 }
55 while(!($bootstrapFileFound = file_exists($drupal_path . "/includes/bootstrap.inc")) && $depth<10);
56 }
57 }
58 if (!isset($bootstrapFileFound) || !$bootstrapFileFound) {
59 $drupal_path = "../../../";
60 if(!file_exists($drupal_path . "/includes/bootstrap.inc")) {
61 $drupal_path = "../..";
62 do {
63 $drupal_path .= "/..";
64 $depth = substr_count($drupal_path, "..");
65 }
66 while(!($bootstrapFileFound = file_exists($drupal_path . "/includes/bootstrap.inc")) && $depth<10);
67 }
68 }
69 if (!isset($bootstrapFileFound) || $bootstrapFileFound) {
70 $fck_cwd = getcwd();
71 chdir($drupal_path);
72 require_once "./includes/bootstrap.inc";
73 drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
74 $authenticated = user_access("allow fckeditor file uploads");
75 if (isset($_SESSION['FCKeditor']['UserFilesPath'], $_SESSION['FCKeditor']['UserFilesAbsolutePath'])) {
76 $GLOBALS['fck_user_files_path'] = $_SESSION['FCKeditor']['UserFilesPath'];
77 $GLOBALS['fck_user_files_absolute_path'] = $_SESSION['FCKeditor']['UserFilesAbsolutePath'];
78 }
79 chdir($fck_cwd);
80 }
81 }
82
83 return $authenticated;
84 }
85
86 /**
87 * Note:
88 * Although in FCKeditor 2.5 $Config['Enabled'] is not used anymore,
89 * CheckAuthentication() must be called once to initialize session
90 * before sending any content
91 * Static $authenticated variable is being assigned, so
92 * application performance is not affected
93 */
94 $Config['Enabled'] = CheckAuthentication();
95
96 if (!empty($fck_user_files_path)) {
97 $Config['UserFilesPath'] = $fck_user_files_path;
98 $Config['UserFilesAbsolutePath'] = $fck_user_files_absolute_path;
99 }
100 else {
101 // Nothing in session? Shouldn't happen... anyway let's try to upload it in the (almost) right place
102 // Path to user files relative to the document root.
103 $Config['UserFilesPath'] = strtr(base_path(), array(
104 "/modules/fckeditor/fckeditor/editor/filemanager/connectors/php" => "",
105 "/modules/fckeditor/fckeditor/editor/filemanager/browser/default/connectors/php" => "",
106 "/modules/fckeditor/fckeditor/editor/filemanager/upload/php" => "",
107 )) . file_directory_path() . "/";
108 }