Project

General

Profile

Bug #563 » config.php

Hubert Borderiou, 10/02/2010 16:39

 
1
<?php
2
/*
3
 * FCKeditor - The text editor for Internet - http://www.fckeditor.net
4
 * Copyright (C) 2003-2009 Frederico Caldeira Knabben
5
 *
6
 * == BEGIN LICENSE ==
7
 *
8
 * Licensed under the terms of any of the following licenses at your
9
 * choice:
10
 *
11
 *  - GNU General Public License Version 2 or later (the "GPL")
12
 *    http://www.gnu.org/licenses/gpl.html
13
 *
14
 *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
15
 *    http://www.gnu.org/licenses/lgpl.html
16
 *
17
 *  - Mozilla Public License Version 1.1 or later (the "MPL")
18
 *    http://www.mozilla.org/MPL/MPL-1.1.html
19
 *
20
 * == END LICENSE ==
21
 *
22
 * Configuration file for the File Manager Connector for PHP.
23
 */
24
/*
25
Modified by hubert.borderiou@grenet.fr
26
Modified 
27
$Config['UserFilesPath'] 
28
$Config['UserWebPath']
29
for importing media
30
*/
31
// Modifications by Ivan Tcholakov, JUN-2009.
32

    
33
// Some language variables are needed.
34
$language_file = array('create_course');
35

    
36
// Loading the global initialization file, Dokeos LMS.
37
require_once '../../../../../../global.inc.php';
38

    
39
// Initialization of the repositories.
40
require_once api_get_path(LIBRARY_PATH).'fckeditor/repository.php' ;
41

    
42
global $Config ;
43

    
44
// SECURITY: You must explicitly enable this "connector". (Set it to "true").
45
// WARNING: don't just set "$Config['Enabled'] = true ;", you must be sure that only
46
//		authenticated users can access this file or use some kind of session checking.
47
$Config['Enabled'] = true ;
48

    
49
// Path to user files relative to the document root.
50
//$Config['UserFilesPath']
51
if (api_is_in_course()) {
52
	if (!api_is_in_group()) {
53
		// 1. We are inside a course and not in a group. 
54
		if (api_is_allowed_to_edit()) {
55
			// 1.1 Teacher or admin - test ok
56
			// $Config['UserFilesPath'] = api_get_path(SYS_COURSE_PATH).api_get_course_path().'/document/';
57
			$Config['UserFilesPath'] = '/'.api_get_path(COURSE_PATH).api_get_course_path().'/document/';
58
			$Config['UserWebPath'] = api_get_path(REL_COURSE_PATH).api_get_course_path().'/document/';
59
		} else {
60
			// 1.2. Student - test ok
61
			// $Config['UserFilesPath'] = api_get_path(REL_COURSE_PATH).api_get_course_path().'/document/shared_folder/sf_user_'.api_get_user_id().'/';
62
			$Config['UserFilesPath'] = '/'.api_get_path(COURSE_PATH).api_get_course_path().'/document/shared_folder/sf_user_'.api_get_user_id().'/';
63
			$Config['UserWebPath'] = api_get_path(REL_COURSE_PATH).api_get_course_path().'/document/shared_folder/sf_user_'.api_get_user_id().'/';
64
		}
65
	} else {
66
		// 2. Inside a course and inside a group. - test ok
67
		global $group_properties;
68
		// $Config['UserFilesPath'] = api_get_path(REL_COURSE_PATH).api_get_course_path().'/document'.$group_properties['directory'].'/';
69
		$Config['UserFilesPath'] = '/'.api_get_path(COURSE_PATH).api_get_course_path().'/document'.$group_properties['directory'].'/';
70
		$Config['UserWebPath'] = api_get_path(REL_COURSE_PATH).api_get_course_path().'/document'.$group_properties['directory'].'/';
71
	}
72
} else {
73
	if (api_is_platform_admin() && $_SESSION['this_section'] == 'platform_admin') {
74
		// 3. Platform administration activities. - test ok
75
  	// $Config['UserFilesPath'] = api_get_path(REL_PATH).'home/default_platform_document/';
76
		$Config['UserFilesPath'] = '/home/default_platform_document/';
77
		$Config['UserWebPath'] = '';
78
		
79
	} else {
80
		// 4. The user is outside courses. - test ok
81
		$Config['UserFilesPath'] = '/main/upload/users/'.api_get_user_id().'/my_files/';
82
		$Config['UserWebPath'] = '';
83
	}
84
}
85

    
86
// Fill the following value it you prefer to specify the absolute path for the
87
// user files directory. Useful if you are using a virtual directory, symbolic
88
// link or alias. Examples: 'C:\\MySite\\userfiles\\' or '/root/mysite/userfiles/'.
89
// Attention: The above 'UserFilesPath' must point to the same directory.
90
$Config['UserFilesAbsolutePath'] = rtrim(api_get_path(SYS_SERVER_ROOT_PATH), '/') . $Config['UserFilesPath'] ;
91

    
92
// Due to security issues with Apache modules, it is recommended to leave the
93
// following setting enabled.
94
$Config['ForceSingleExtension'] = true ;
95

    
96
// Perform additional checks for image files.
97
// If set to true, validate image size (using getimagesize).
98
$Config['SecureImageUploads'] = true;
99

    
100
// What the user can do with this connector.
101
$Config['ConfigAllowedCommands'] = array('QuickUpload', 'FileUpload', 'GetFolders', 'GetFoldersAndFiles', 'CreateFolder') ;
102

    
103
// Allowed Resource Types.
104
$Config['ConfigAllowedTypes'] = array('File', 'Audio', 'Images', 'Flash', 'Media', 'MP3', 'Video', 'Video/flv') ;
105

    
106
// For security, HTML is allowed in the first Kb of data for files having the
107
// following extensions only.
108
$Config['HtmlExtensions'] = array("html", "htm", "xhtml", "xml", "xsd", "txt", "js") ;
109

    
110
// After file is uploaded, sometimes it is required to change its permissions
111
// so that it was possible to access it at the later time.
112
// If possible, it is recommended to set more restrictive permissions, like 0755.
113
// Set to 0 to disable this feature.
114
// Note: not needed on Windows-based servers.
115
$Config['ChmodOnUpload'] = $permissions_for_new_files ;
116

    
117
// See comments above.
118
// Used when creating folders that does not exist.
119
$Config['ChmodOnFolderCreate'] = $permissions_for_new_directories ;
120

    
121
/*
122
	Configuration settings for each Resource Type
123

    
124
	- AllowedExtensions: the possible extensions that can be allowed.
125
		If it is empty then any file type can be uploaded.
126
	- DeniedExtensions: The extensions that won't be allowed.
127
		If it is empty then no restrictions are done here.
128

    
129
	For a file to be uploaded it has to fulfill both the AllowedExtensions
130
	and DeniedExtensions (that's it: not being denied) conditions.
131

    
132
	- FileTypesPath: the virtual folder relative to the document root where
133
		these resources will be located.
134
		Attention: It must start and end with a slash: '/'
135

    
136
	- FileTypesAbsolutePath: the physical path to the above folder. It must be
137
		an absolute path.
138
		If it's an empty string then it will be autocalculated.
139
		Useful if you are using a virtual directory, symbolic link or alias.
140
		Examples: 'C:\\MySite\\userfiles\\' or '/root/mysite/userfiles/'.
141
		Attention: The above 'FileTypesPath' must point to the same directory.
142
		Attention: It must end with a slash: '/'
143

    
144
	 - QuickUploadPath: the virtual folder relative to the document root where
145
		these resources will be uploaded using the Upload tab in the resources
146
		dialogs.
147
		Attention: It must start and end with a slash: '/'
148

    
149
	 - QuickUploadAbsolutePath: the physical path to the above folder. It must be
150
		an absolute path.
151
		If it's an empty string then it will be autocalculated.
152
		Useful if you are using a virtual directory, symbolic link or alias.
153
		Examples: 'C:\\MySite\\userfiles\\' or '/root/mysite/userfiles/'.
154
		Attention: The above 'QuickUploadPath' must point to the same directory.
155
		Attention: It must end with a slash: '/'
156

    
157
	 	NOTE: by default, QuickUploadPath and QuickUploadAbsolutePath point to
158
	 	"userfiles" directory to maintain backwards compatibility with older versions of FCKeditor.
159
	 	This is fine, but you in some cases you will be not able to browse uploaded files using file browser.
160
	 	Example: if you click on "image button", select "Upload" tab and send image
161
	 	to the server, image will appear in FCKeditor correctly, but because it is placed
162
	 	directly in /userfiles/ directory, you'll be not able to see it in built-in file browser.
163
	 	The more expected behaviour would be to send images directly to "image" subfolder.
164
	 	To achieve that, simply change
165
			$Config['QuickUploadPath']['Image']			= $Config['UserFilesPath'] ;
166
			$Config['QuickUploadAbsolutePath']['Image']	= $Config['UserFilesAbsolutePath'] ;
167
		into:
168
			$Config['QuickUploadPath']['Image']			= $Config['FileTypesPath']['Image'] ;
169
			$Config['QuickUploadAbsolutePath']['Image'] 	= $Config['FileTypesAbsolutePath']['Image'] ;
170

    
171
*/
172

    
173
// Files
174
$Config['AllowedExtensions']['File']			= array('7z', 'aiff', 'asf', 'avi', 'bmp', 'csv', 'doc', 'fla', 'flv', 'gif', 'gz', 'gzip', 'jpeg', 'jpg', 'mid', 'mov', 'mp3', 'mp4', 'mpc', 'mpeg', 'mpg', 'ods', 'odt', 'pdf', 'png', 'ppt', 'pxd', 'qt', 'ram', 'rar', 'rm', 'rmi', 'rmvb', 'rtf', 'sdc', 'sitd', 'swf', 'sxc', 'sxw', 'tar', 'tgz', 'tif', 'tiff', 'txt', 'vsd', 'wav', 'wma', 'wmv', 'xls', 'xml', 'zip') ;
175
$Config['DeniedExtensions']['File']				= array('php', 'php3', 'php4', 'php5', 'php6', 'phps', 'phtml', 'asp', 'aspx', 'ascx', 'jsp', 'cfm', 'cfc', 'pl', 'bat', 'exe', 'dll', 'reg', 'cgi') ;
176
$Config['FileTypesPath']['File']					= $Config['UserWebPath'];
177
$Config['FileTypesAbsolutePath']['File']		= $Config['UserFilesAbsolutePath'] ;
178
$Config['QuickUploadPath']['File']				= $Config['UserWebPath'] ;
179
$Config['QuickUploadPath']['File']				= '';
180
$Config['QuickUploadAbsolutePath']['File']		= $Config['UserFilesAbsolutePath'] ;
181

    
182
// Audio (MP3 is an alias)
183
$Config['AllowedExtensions']['Audio']			= array('mp3') ;
184
$Config['DeniedExtensions']['Audio']			= $Config['DeniedExtensions']['File'] ;
185
$Config['DeniedExtensions']['Audio']			= array() ;
186
$Config['FileTypesPath']['Audio']				= $Config['UserWebPath'] . 'audio/' ;
187
$Config['FileTypesAbsolutePath']['Audio']		= $Config['UserFilesAbsolutePath'] . 'audio/' ;
188
$Config['QuickUploadPath']['Audio']				= $Config['UserWebPath'] . 'audio/' ;
189
$Config['QuickUploadAbsolutePath']['Audio']		= $Config['UserFilesAbsolutePath'] . 'audio/' ;
190

    
191

    
192
// Images
193
$Config['AllowedExtensions']['Images']			= array('bmp', 'gif', 'jpg', 'jpeg', 'png') ;
194
$Config['DeniedExtensions']['Images']			= $Config['DeniedExtensions']['File'] ;
195
$Config['FileTypesPath']['Images']				= $Config['UserWebPath'] . 'images/' ;
196
$Config['FileTypesAbsolutePath']['Images']		= $Config['UserFilesAbsolutePath'] . 'images/' ;
197
$Config['QuickUploadPath']['Images']			= $Config['UserWebPath'] . 'images/' ;
198
$Config['QuickUploadAbsolutePath']['Images']	= $Config['UserFilesAbsolutePath'] . 'images/' ;
199

    
200
// Flash
201
$Config['AllowedExtensions']['Flash']			= array('swf') ;
202
$Config['DeniedExtensions']['Flash']			= $Config['DeniedExtensions']['File'] ;
203
$Config['FileTypesPath']['Flash']				= $Config['UserWebPath'] . 'flash/' ;
204
$Config['FileTypesAbsolutePath']['Flash']		= $Config['UserFilesAbsolutePath'] . 'flash/' ;
205
$Config['QuickUploadPath']['Flash']				= $Config['UserWebPath'] . 'flash/' ;
206
$Config['QuickUploadAbsolutePath']['Flash']		= $Config['UserFilesAbsolutePath'] . 'flash/' ;
207

    
208
// MP3 (audio)
209
$Config['AllowedExtensions']['MP3']				= $Config['AllowedExtensions']['Audio'] ;
210
$Config['DeniedExtensions']['MP3']				= $Config['DeniedExtensions']['Audio'] ;
211
$Config['FileTypesPath']['MP3']					= $Config['FileTypesPath']['Audio'] ;
212
$Config['FileTypesAbsolutePath']['MP3']			= $Config['FileTypesAbsolutePath']['Audio'] ;
213
$Config['QuickUploadPath']['MP3']				= $Config['QuickUploadPath']['Audio'] ;
214
$Config['QuickUploadAbsolutePath']['MP3']		= $Config['QuickUploadAbsolutePath']['Audio'] ;
215

    
216

    
217
// Video
218
$Config['AllowedExtensions']['Video']			= array('asf', 'avi', 'mpg', 'mpeg', 'mp4', 'mov', 'wmv') ;
219
$Config['DeniedExtensions']['Video']			= $Config['DeniedExtensions']['File'] ;
220
$Config['FileTypesPath']['Video']				= $Config['UserWebPath'] . 'video/' ;
221
$Config['FileTypesAbsolutePath']['Video']		= $Config['UserFilesAbsolutePath'] . 'video/' ;
222
$Config['QuickUploadPath']['Video']				= $Config['UserWebPath'] . 'video/' ;
223
$Config['QuickUploadAbsolutePath']['Video']		= $Config['UserFilesAbsolutePath'] . 'video/' ;
224

    
225
// Video/flv
226
$Config['AllowedExtensions']['Video/flv']		= array('flv', 'mp4' ) ;
227
$Config['DeniedExtensions']['Video/flv']		= $Config['DeniedExtensions']['File'] ;
228
$Config['FileTypesPath']['Video/flv']			= $Config['UserWebPath'] . 'video/flv/' ;
229
$Config['FileTypesAbsolutePath']['Video/flv']	= $Config['UserFilesAbsolutePath'] . 'video/flv/' ;
230
$Config['QuickUploadPath']['Video/flv']			= $Config['UserWebPath'] . 'video/flv/' ;
231
$Config['QuickUploadAbsolutePath']['Video/flv']	= $Config['UserFilesAbsolutePath'] . 'video/flv/' ;
232

    
233
?>
(1-1/4)