config.inc.php 9.0 KB

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