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