| 1 |
<?php
|
| 2 |
|
| 3 |
// $Id: filemanager.config.php,v 1.1.2.1 2008/02/09 16:00:14 wwalc Exp $
|
| 4 |
/**
|
| 5 |
* FCKeditor - The text editor for Internet - http://www.fckeditor.net
|
| 6 |
* Copyright (C) 2003-2007 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 |
$fck_user_files_path = "";
|
| 35 |
$fck_user_files_absolute_path = "";
|
| 36 |
|
| 37 |
function CheckAuthentication()
|
| 38 |
{
|
| 39 |
static $authenticated;
|
| 40 |
|
| 41 |
if (!isset($authenticated)) {
|
| 42 |
$result = false;
|
| 43 |
|
| 44 |
$drupal_path = "../../../";
|
| 45 |
if(!file_exists($drupal_path . "/includes/bootstrap.inc")) {
|
| 46 |
$drupal_path = "../..";
|
| 47 |
do {
|
| 48 |
$drupal_path .= "/..";
|
| 49 |
$depth = substr_count($drupal_path, "..");
|
| 50 |
}
|
| 51 |
while(!($bootstrapFileFound = file_exists($drupal_path . "/includes/bootstrap.inc")) && $depth<10);
|
| 52 |
}
|
| 53 |
if (!isset($bootstrapFileFound) || $bootstrapFileFound) {
|
| 54 |
$fck_cwd = getcwd();
|
| 55 |
chdir($drupal_path);
|
| 56 |
require_once "./includes/bootstrap.inc";
|
| 57 |
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
|
| 58 |
$authenticated = user_access("allow fckeditor file uploads");
|
| 59 |
if (isset($_SESSION['FCKeditor']['UserFilesPath'], $_SESSION['FCKeditor']['UserFilesAbsolutePath'])) {
|
| 60 |
$GLOBALS['fck_user_files_path'] = $_SESSION['FCKeditor']['UserFilesPath'];
|
| 61 |
$GLOBALS['fck_user_files_absolute_path'] = $_SESSION['FCKeditor']['UserFilesAbsolutePath'];
|
| 62 |
}
|
| 63 |
chdir($fck_cwd);
|
| 64 |
}
|
| 65 |
}
|
| 66 |
|
| 67 |
return $authenticated;
|
| 68 |
}
|
| 69 |
|
| 70 |
/**
|
| 71 |
* Note:
|
| 72 |
* Although in FCKeditor 2.5 $Config['Enabled'] is not used anymore,
|
| 73 |
* CheckAuthentication() must be called once to initialize session
|
| 74 |
* before sending any content
|
| 75 |
* Static $authenticated variable is being assigned, so
|
| 76 |
* application performance is not affected
|
| 77 |
*/
|
| 78 |
$Config['Enabled'] = CheckAuthentication();
|
| 79 |
|
| 80 |
if (!empty($fck_user_files_path)) {
|
| 81 |
$Config['UserFilesPath'] = $fck_user_files_path;
|
| 82 |
$Config['UserFilesAbsolutePath'] = $fck_user_files_absolute_path;
|
| 83 |
}
|
| 84 |
else {
|
| 85 |
// Nothing in session? Shouldn't happen... anyway let's try to upload it in the (almost) right place
|
| 86 |
// Path to user files relative to the document root.
|
| 87 |
$Config['UserFilesPath'] = strtr(base_path(), array(
|
| 88 |
"/modules/fckeditor/fckeditor/editor/filemanager/connectors/php" => "",
|
| 89 |
"/modules/fckeditor/fckeditor/editor/filemanager/browser/default/connectors/php" => "",
|
| 90 |
"/modules/fckeditor/fckeditor/editor/filemanager/upload/php" => "",
|
| 91 |
)) . file_directory_path() . "/";
|
| 92 |
}
|