dolibarr 24.0.0-beta
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.
59if (empty($user->admin) && !$user->hasRight('website', 'write')) {
60 accessforbidden('Need to have website write permission to upload files in medias directory.');
61}
62
63
64// SECURITY: You must explicitly enable this "connector". (Set it to "true").
65// WARNING: don't just set "$Config['Enabled'] = true ;", you must be sure that only
66// authenticated users can access this file or use some kind of session checking.
67$Config['Enabled'] = true;
68
69
70// Path to user files relative to the document root.
71$extEntity = (empty($entity) ? 1 : $entity); // For multicompany with external access
72
73$Config['UserFilesPath'] = DOL_URL_ROOT.'/viewimage.php?modulepart=medias'.(empty($website) ? '' : '_'.$website).'&entity='.$extEntity.'&file=';
74$Config['UserFilesAbsolutePathRelative'] = (!empty($entity) ? '/'.$entity : '').(empty($website) ? '/medias/' : ('/website/'.$website));
75
76
77// Fill the following value it you prefer to specify the absolute path for the
78// user files directory. Useful if you are using a virtual directory, symbolic
79// link or alias. Examples: 'C:\\MySite\\userfiles\\' or '/root/mysite/userfiles/'.
80// Attention: The above 'UserFilesPath' must point to the same directory.
81$Config['UserFilesAbsolutePath'] = $dolibarr_main_data_root.$Config['UserFilesAbsolutePathRelative'];
82
83// Due to security issues with Apache modules, it is recommended to leave the
84// following setting enabled.
85$Config['ForceSingleExtension'] = true;
86
87// Perform additional checks for image files.
88// If set to true, validate image size (using getimagesize).
89$Config['SecureImageUploads'] = true;
90
91// What the user can do with this connector.
92$Config['ConfigAllowedCommands'] = array('QuickUpload', 'FileUpload', 'GetFolders', 'GetFoldersAndFiles', 'CreateFolder');
93
94// Allowed Resource Types.
95$Config['ConfigAllowedTypes'] = array('File', 'Image', 'Media');
96
97// For security, HTML is allowed in the first Kb of data for files having the
98// following extensions only.
99$Config['HtmlExtensions'] = array("html", "htm", "xml", "xsd", "txt", "js");
100
101// After file is uploaded, sometimes it is required to change its permissions
102// so that it was possible to access it at the later time.
103// If possible, it is recommended to set more restrictive permissions, like 0755.
104// Set to 0 to disable this feature.
105// Note: not needed on Windows-based servers.
106$newmask = '0644';
107if (getDolGlobalString('MAIN_UMASK')) {
108 $newmask = getDolGlobalString('MAIN_UMASK');
109}
110$Config['ChmodOnUpload'] = $newmask;
111
112// See comments above.
113// Used when creating folders that does not exist.
114$newmask = '0755';
115$dirmaskdec = octdec($newmask);
116if (getDolGlobalString('MAIN_UMASK')) {
117 $dirmaskdec = octdec(getDolGlobalString('MAIN_UMASK'));
118}
119$dirmaskdec |= octdec('0200'); // Set w bit required to be able to create content for recursive subdirs files
120$newmask = decoct($dirmaskdec);
121
122$Config['ChmodOnFolderCreate'] = $newmask;
123
124/*
125 Configuration settings for each Resource Type
126
127 - AllowedExtensions: the possible extensions that can be allowed.
128 If it is empty then any file type can be uploaded.
129 - DeniedExtensions: The extensions that won't be allowed.
130 If it is empty then no restrictions are done here.
131
132 For a file to be uploaded it has to fulfill both the AllowedExtensions
133 and DeniedExtensions (that's it: not being denied) conditions.
134
135 - FileTypesPath: the virtual folder relative to the document root where
136 these resources will be located.
137 Attention: It must start and end with a slash: '/'
138
139 - FileTypesAbsolutePath: the physical path to the above folder. It must be
140 an absolute path.
141 If it's an empty string then it will be autocalculated.
142 Useful if you are using a virtual directory, symbolic link or alias.
143 Examples: 'C:\\MySite\\userfiles\\' or '/root/mysite/userfiles/'.
144 Attention: The above 'FileTypesPath' must point to the same directory.
145 Attention: It must end with a slash: '/'
146
147 - QuickUploadPath: the virtual folder relative to the document root where
148 these resources will be uploaded using the Upload tab in the resources
149 dialogs.
150 Attention: It must start and end with a slash: '/'
151
152 - QuickUploadAbsolutePath: the physical path to the above folder. It must be
153 an absolute path.
154 If it's an empty string then it will be autocalculated.
155 Useful if you are using a virtual directory, symbolic link or alias.
156 Examples: 'C:\\MySite\\userfiles\\' or '/root/mysite/userfiles/'.
157 Attention: The above 'QuickUploadPath' must point to the same directory.
158 Attention: It must end with a slash: '/'
159
160 NOTE: by default, QuickUploadPath and QuickUploadAbsolutePath point to
161 "userfiles" directory to maintain backwards compatibility with older versions of FCKeditor.
162 This is fine, but you in some cases you will be not able to browse uploaded files using file browser.
163 Example: if you click on "image button", select "Upload" tab and send image
164 to the server, image will appear in FCKeditor correctly, but because it is placed
165 directly in /userfiles/ directory, you'll be not able to see it in built-in file browser.
166 The more expected behaviour would be to send images directly to "image" subfolder.
167 To achieve that, simply change
168 $Config['QuickUploadPath']['Image'] = $Config['UserFilesPath'] ;
169 $Config['QuickUploadAbsolutePath']['Image'] = $Config['UserFilesAbsolutePath'] ;
170 into:
171 $Config['QuickUploadPath']['Image'] = $Config['FileTypesPath']['Image'] ;
172 $Config['QuickUploadAbsolutePath']['Image'] = $Config['FileTypesAbsolutePath']['Image'] ;
173
174*/
175
176$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');
177$Config['DeniedExtensions']['File'] = array();
178$Config['FileTypesPath']['File'] = $Config['UserFilesPath'].'file/';
179$Config['FileTypesAbsolutePath']['File'] = ($Config['UserFilesAbsolutePath'] == '') ? '' : $Config['UserFilesAbsolutePath'].'file/';
180$Config['QuickUploadPath']['File'] = $Config['UserFilesPath'];
181$Config['QuickUploadAbsolutePath']['File'] = $Config['UserFilesAbsolutePath'];
182
183$Config['AllowedExtensions']['Image'] = array('bmp', 'gif', 'jpeg', 'jpg', 'png', 'ai');
184if (getDolGlobalString('MAIN_ALLOW_SVG_FILES_AS_IMAGES')) {
185 $Config['AllowedExtensions']['Image'][] = 'svg';
186}
187$Config['DeniedExtensions']['Image'] = array();
188$Config['FileTypesPath']['Image'] = $Config['UserFilesPath'].'image/';
189$Config['FileTypesAbsolutePath']['Image'] = ($Config['UserFilesAbsolutePath'] == '') ? '' : $Config['UserFilesAbsolutePath'].'image/';
190$Config['QuickUploadPath']['Image'] = $Config['UserFilesPath'];
191$Config['QuickUploadAbsolutePath']['Image'] = $Config['UserFilesAbsolutePath'];
192
193$Config['AllowedExtensions']['Flash'] = array('swf', 'flv');
194$Config['DeniedExtensions']['Flash'] = array();
195$Config['FileTypesPath']['Flash'] = $Config['UserFilesPath'].'flash/';
196$Config['FileTypesAbsolutePath']['Flash'] = ($Config['UserFilesAbsolutePath'] == '') ? '' : $Config['UserFilesAbsolutePath'].'flash/';
197$Config['QuickUploadPath']['Flash'] = $Config['UserFilesPath'];
198$Config['QuickUploadAbsolutePath']['Flash'] = $Config['UserFilesAbsolutePath'];
199
200$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');
201$Config['DeniedExtensions']['Media'] = array();
202$Config['FileTypesPath']['Media'] = $Config['UserFilesPath'].'media/';
203$Config['FileTypesAbsolutePath']['Media'] = ($Config['UserFilesAbsolutePath'] == '') ? '' : $Config['UserFilesAbsolutePath'].'media/';
204$Config['QuickUploadPath']['Media'] = $Config['UserFilesPath'];
205$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.