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