dolibarr 25.0.0-alpha
config.inc.php
1<?php
2/*
3 * FCKeditor - The text editor for Internet - http://www.fckeditor.net
4 * Copyright (C) 2003-2010 Frederico Caldeira Knabben
5 * Copyright (C) 2024-2026 Frédéric France <frederic.france@free.fr>
6 * Copyright (C) 2026 MDW <mdeweerd@users.noreply.github.com>
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 * https://www.gnu.org/licenses/gpl.html
15 *
16 * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
17 * https://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 * Configuration file for the File Manager Connector for PHP.
25 */
26
27global $Config;
28global $website;
29
30define('NOTOKENRENEWAL', 1); // Disables token renewal
31
32// We must include the main because this page is
33// a web page that require security controls and
34// is a security hole if anybody can access without
35// being an authenticated user.
36require_once '../../../../main.inc.php';
45$uri = preg_replace('/^http(s?):\/\//i', '', $dolibarr_main_url_root);
46$pos = strstr($uri, '/'); // $pos contient alors url sans nom domaine
47if ($pos == '/') {
48 $pos = ''; // si $pos vaut /, on le met a ''
49}
50//define('DOL_URL_ROOT', $pos);
51$entity = ((!empty($_SESSION['dol_entity']) && $_SESSION['dol_entity'] > 1) ? $_SESSION['dol_entity'] : null);
52
53// By default, upload of files with this tool is no more possible.
54if (!getDolGlobalString('WYSIWYG_ALLOW_UPLOAD_MEDIA_FILES')) {
55 accessforbidden('Upload of files in medias directory using this legacy tool is no more allowed');
56}
57
58// If upload has been allowed with WYSIWYG_ALLOW_UPLOAD_MEDIA_FILES set, we check permissions.
59// This connector browses and writes into the medias directory, so it must be
60// restricted the same way as on the newer branches. Without this check any
61// authenticated user (even with no module right) could reach the file manager.
62if (empty($user->admin) && !$user->hasRight('website', 'write')) {
63 accessforbidden('Need to have website write permission to upload files in medias directory.');
64}
65
66// SECURITY: You must explicitly enable this "connector". (Set it to "true").
67// WARNING: don't just set "$Config['Enabled'] = true ;", you must be sure that only
68// authenticated users can access this file or use some kind of session checking.
69$Config['Enabled'] = true;
70
71
72// Path to user files relative to the document root.
73$extEntity = (empty($entity) ? 1 : $entity); // For multicompany with external access
74
75$Config['UserFilesPath'] = DOL_URL_ROOT.'/viewimage.php?modulepart=medias'.(empty($website) ? '' : '_'.$website).'&entity='.$extEntity.'&file=';
76$Config['UserFilesAbsolutePathRelative'] = (!empty($entity) ? '/'.$entity : '').(empty($website) ? '/medias/' : ('/website/'.$website));
77
78
79// Fill the following value it you prefer to specify the absolute path for the
80// user files directory. Useful if you are using a virtual directory, symbolic
81// link or alias. Examples: 'C:\\MySite\\userfiles\\' or '/root/mysite/userfiles/'.
82// Attention: The above 'UserFilesPath' must point to the same directory.
83$Config['UserFilesAbsolutePath'] = $dolibarr_main_data_root.$Config['UserFilesAbsolutePathRelative'];
84
85// Due to security issues with Apache modules, it is recommended to leave the
86// following setting enabled.
87$Config['ForceSingleExtension'] = true;
88
89// Perform additional checks for image files.
90// If set to true, validate image size (using getimagesize).
91$Config['SecureImageUploads'] = true;
92
93// What the user can do with this connector.
94$Config['ConfigAllowedCommands'] = array('QuickUpload', 'FileUpload', 'GetFolders', 'GetFoldersAndFiles', 'CreateFolder');
95
96// Allowed Resource Types.
97$Config['ConfigAllowedTypes'] = array('File', 'Image', 'Media');
98
99// For security, HTML is allowed in the first Kb of data for files having the
100// following extensions only.
101$Config['HtmlExtensions'] = array("html", "htm", "xml", "xsd", "txt", "js");
102
103// After file is uploaded, sometimes it is required to change its permissions
104// so that it was possible to access it at the later time.
105// If possible, it is recommended to set more restrictive permissions, like 0755.
106// Set to 0 to disable this feature.
107// Note: not needed on Windows-based servers.
108$newmask = '0644';
109if (getDolGlobalString('MAIN_UMASK')) {
110 $newmask = getDolGlobalString('MAIN_UMASK');
111}
112$Config['ChmodOnUpload'] = $newmask;
113
114// See comments above.
115// Used when creating folders that does not exist.
116$newmask = '0755';
117$dirmaskdec = octdec($newmask);
118if (getDolGlobalString('MAIN_UMASK')) {
119 $dirmaskdec = octdec(getDolGlobalString('MAIN_UMASK'));
120}
121$dirmaskdec |= octdec('0200'); // Set w bit required to be able to create content for recursive subdirs files
122$newmask = decoct($dirmaskdec);
123
124$Config['ChmodOnFolderCreate'] = $newmask;
125
126/*
127 Configuration settings for each Resource Type
128
129 - AllowedExtensions: the possible extensions that can be allowed.
130 If it is empty then any file type can be uploaded.
131 - DeniedExtensions: The extensions that won't be allowed.
132 If it is empty then no restrictions are done here.
133
134 For a file to be uploaded it has to fulfill both the AllowedExtensions
135 and DeniedExtensions (that's it: not being denied) conditions.
136
137 - FileTypesPath: the virtual folder relative to the document root where
138 these resources will be located.
139 Attention: It must start and end with a slash: '/'
140
141 - FileTypesAbsolutePath: the physical path to the above folder. It must be
142 an absolute path.
143 If it's an empty string then it will be autocalculated.
144 Useful if you are using a virtual directory, symbolic link or alias.
145 Examples: 'C:\\MySite\\userfiles\\' or '/root/mysite/userfiles/'.
146 Attention: The above 'FileTypesPath' must point to the same directory.
147 Attention: It must end with a slash: '/'
148
149 - QuickUploadPath: the virtual folder relative to the document root where
150 these resources will be uploaded using the Upload tab in the resources
151 dialogs.
152 Attention: It must start and end with a slash: '/'
153
154 - QuickUploadAbsolutePath: the physical path to the above folder. It must be
155 an absolute path.
156 If it's an empty string then it will be autocalculated.
157 Useful if you are using a virtual directory, symbolic link or alias.
158 Examples: 'C:\\MySite\\userfiles\\' or '/root/mysite/userfiles/'.
159 Attention: The above 'QuickUploadPath' must point to the same directory.
160 Attention: It must end with a slash: '/'
161
162 NOTE: by default, QuickUploadPath and QuickUploadAbsolutePath point to
163 "userfiles" directory to maintain backwards compatibility with older versions of FCKeditor.
164 This is fine, but you in some cases you will be not able to browse uploaded files using file browser.
165 Example: if you click on "image button", select "Upload" tab and send image
166 to the server, image will appear in FCKeditor correctly, but because it is placed
167 directly in /userfiles/ directory, you'll be not able to see it in built-in file browser.
168 The more expected behaviour would be to send images directly to "image" subfolder.
169 To achieve that, simply change
170 $Config['QuickUploadPath']['Image'] = $Config['UserFilesPath'] ;
171 $Config['QuickUploadAbsolutePath']['Image'] = $Config['UserFilesAbsolutePath'] ;
172 into:
173 $Config['QuickUploadPath']['Image'] = $Config['FileTypesPath']['Image'] ;
174 $Config['QuickUploadAbsolutePath']['Image'] = $Config['FileTypesAbsolutePath']['Image'] ;
175
176*/
177
178$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');
179$Config['DeniedExtensions']['File'] = array();
180$Config['FileTypesPath']['File'] = $Config['UserFilesPath'].'file/';
181$Config['FileTypesAbsolutePath']['File'] = ($Config['UserFilesAbsolutePath'] == '') ? '' : $Config['UserFilesAbsolutePath'].'file/';
182$Config['QuickUploadPath']['File'] = $Config['UserFilesPath'];
183$Config['QuickUploadAbsolutePath']['File'] = $Config['UserFilesAbsolutePath'];
184
185$Config['AllowedExtensions']['Image'] = array('bmp', 'gif', 'jpeg', 'jpg', 'png', 'ai');
186if (getDolGlobalString('MAIN_ALLOW_SVG_FILES_AS_IMAGES')) {
187 $Config['AllowedExtensions']['Image'][] = 'svg';
188}
189$Config['DeniedExtensions']['Image'] = array();
190$Config['FileTypesPath']['Image'] = $Config['UserFilesPath'].'image/';
191$Config['FileTypesAbsolutePath']['Image'] = ($Config['UserFilesAbsolutePath'] == '') ? '' : $Config['UserFilesAbsolutePath'].'image/';
192$Config['QuickUploadPath']['Image'] = $Config['UserFilesPath'];
193$Config['QuickUploadAbsolutePath']['Image'] = $Config['UserFilesAbsolutePath'];
194
195$Config['AllowedExtensions']['Flash'] = array('swf', 'flv');
196$Config['DeniedExtensions']['Flash'] = array();
197$Config['FileTypesPath']['Flash'] = $Config['UserFilesPath'].'flash/';
198$Config['FileTypesAbsolutePath']['Flash'] = ($Config['UserFilesAbsolutePath'] == '') ? '' : $Config['UserFilesAbsolutePath'].'flash/';
199$Config['QuickUploadPath']['Flash'] = $Config['UserFilesPath'];
200$Config['QuickUploadAbsolutePath']['Flash'] = $Config['UserFilesAbsolutePath'];
201
202$Config['AllowedExtensions']['Media'] = array('aiff', 'asf', 'avi', 'bmp', 'fla', 'flv', 'gif', 'jpeg', 'jpg', 'mid', 'mov', 'mp3', 'mp4', 'mpc', 'mpeg', 'mpg', 'png', 'qt', 'ram', 'rm', 'rmi', 'rmvb', 'swf', 'tif', 'tiff', 'wav', 'wma', 'wmv');
203$Config['DeniedExtensions']['Media'] = array();
204$Config['FileTypesPath']['Media'] = $Config['UserFilesPath'].'media/';
205$Config['FileTypesAbsolutePath']['Media'] = ($Config['UserFilesAbsolutePath'] == '') ? '' : $Config['UserFilesAbsolutePath'].'media/';
206$Config['QuickUploadPath']['Media'] = $Config['UserFilesPath'];
207$Config['QuickUploadAbsolutePath']['Media'] = $Config['UserFilesAbsolutePath'];
global $dolibarr_main_url_root
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.