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