config.inc.php 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. <?php
  2. /**
  3. * Image Manager configuration file.
  4. * @author Wei Zhuo
  5. * @author Paul Moers <mail@saulmade.nl> - watermarking and replace code + several small enhancements <http://fckplugins.saulmade.nl>
  6. * @version $Id: config.inc.php,v 1.4 2006/12/17 14:53:50 thierrybo Exp $
  7. * @package ImageManager
  8. */
  9. /*
  10. File system path to the directory you want to manage the images
  11. for multiple user systems, set it dynamically.
  12. NOTE: This directory requires write access by PHP. That is,
  13. PHP must be able to create files in this directory.
  14. Able to create directories is nice, but not necessary.
  15. */
  16. //$IMConfig['base_dir'] = '/var/www/FCKeditor/images/';
  17. /*
  18. The URL to the above path, the web browser needs to be able to see it.
  19. It can be protected via .htaccess on apache or directory permissions on IIS,
  20. check you web server documentation for futher information on directory protection
  21. If this directory needs to be publicly accessiable, remove scripting capabilities
  22. for this directory (i.e. disable PHP, Perl, CGI). We only want to store assets
  23. in this directory and its subdirectories.
  24. */
  25. $language_file = array('document');
  26. require_once '../../../../../../inc/global.inc.php';
  27. api_block_anonymous_users();
  28. // Disabling access for anonymous users.
  29. api_block_anonymous_users();
  30. // Initialization of the repositories.
  31. require_once api_get_path(LIBRARY_PATH).'fckeditor/repository.php';
  32. $userId = api_get_user_id();
  33. // Choosing the repository to be used.
  34. if (api_is_in_course()) {
  35. if (!api_is_in_group()) {
  36. // 1. We are inside a course and not in a group.
  37. if (api_is_allowed_to_edit()) {
  38. // 1.1. Teacher
  39. $IMConfig['base_dir'] = api_get_path(SYS_COURSE_PATH).api_get_course_path().'/document/';
  40. $IMConfig['base_url'] = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document/';
  41. } else {
  42. // 1.2. Student
  43. $sessionId = api_get_session_id();
  44. if ($sessionId == 0) {
  45. $IMConfig['base_dir'] = api_get_path(SYS_COURSE_PATH).api_get_course_path().'/document/shared_folder/sf_user_'.$userId.'/';
  46. $IMConfig['base_url'] = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document/shared_folder/sf_user_'.$userId.'/';
  47. } else {
  48. $IMConfig['base_dir'] = api_get_path(SYS_COURSE_PATH).api_get_course_path().'/document/shared_folder_session_'.$sessionId.'/sf_user_'.$userId.'/';
  49. $IMConfig['base_url'] = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document/shared_folder_session_'.$sessionId.'/sf_user_'.$userId.'/';
  50. }
  51. }
  52. } else {
  53. // 2. Inside a course and inside a group.
  54. $IMConfig['base_dir'] = api_get_path(SYS_COURSE_PATH).api_get_course_path().'/document'.$group_properties['directory'].'/';
  55. $IMConfig['base_url'] = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document'.$group_properties['directory'].'/';
  56. }
  57. } else {
  58. if (api_is_platform_admin() && $_SESSION['this_section'] == 'platform_admin') {
  59. // 3. Platform administration activities.
  60. $IMConfig['base_dir'] = $_configuration['root_sys'].'home/default_platform_document/';
  61. $IMConfig['base_url'] = $_configuration['root_web'].'home/default_platform_document/';
  62. } else {
  63. // 4. The user is outside courses.
  64. $my_path = UserManager::get_user_picture_path_by_id($userId, 'system');
  65. $IMConfig['base_dir'] = $my_path['dir'].'my_files/';
  66. $my_path = UserManager::get_user_picture_path_by_id($userId, 'web');
  67. $IMConfig['base_url'] = $my_path['dir'].'my_files/';
  68. }
  69. }
  70. $IMConfig['server_name'] = $_SERVER['SERVER_NAME'];
  71. /*
  72. demo - when true, no saving is allowed
  73. */
  74. $IMConfig['demo'] = false;
  75. /*
  76. Possible values: true, false
  77. TRUE - If PHP on the web server is in safe mode, set this to true.
  78. SAFE MODE restrictions: directory creation will not be possible,
  79. only the GD library can be used, other libraries require
  80. Safe Mode to be off.
  81. FALSE - Set to false if PHP on the web server is not in safe mode.
  82. */
  83. $IMConfig['safe_mode'] = false;
  84. /*
  85. Possible values: 'GD', 'IM', or 'NetPBM'
  86. The image manipulation library to use, either GD or ImageMagick or NetPBM.
  87. If you have safe mode ON, or don't have the binaries to other packages,
  88. your choice is 'GD' only. Other packages require Safe Mode to be off.
  89. */
  90. define('IMAGE_CLASS', 'GD');
  91. /*
  92. After defining which library to use, if it is NetPBM or IM, you need to
  93. specify where the binary for the selected library are. And of course
  94. your server and PHP must be able to execute them (i.e. safe mode is OFF).
  95. GD does not require the following definition.
  96. */
  97. define('IMAGE_TRANSFORM_LIB_PATH', '/usr/bin/');
  98. /* ============== OPTIONAL SETTINGS ============== */
  99. /*
  100. The prefix for thumbnail files, something like .thumb will do. The
  101. thumbnails files will be named as "prefix_imagefile.ext", that is,
  102. prefix + orginal filename.
  103. */
  104. $IMConfig['thumbnail_prefix'] = '.';
  105. /*
  106. Thumbnail can also be stored in a directory, this directory
  107. will be created by PHP. If PHP is in safe mode, this parameter
  108. is ignored, you can not create directories.
  109. If you do not want to store thumbnails in a directory, set this
  110. to false or empty string '';
  111. */
  112. $IMConfig['thumbnail_dir'] = '.thumbs';
  113. /*
  114. Possible values: true, false
  115. TRUE - Allow the user to create new sub-directories in the
  116. $IMConfig['base_dir'].
  117. FALSE - No directory creation.
  118. NOTE: If $IMConfig['safe_mode'] = true, this parameter
  119. is ignored, you can not create directories
  120. */
  121. $IMConfig['allow_new_dir'] = true;
  122. /*
  123. Possible values: true, false
  124. TRUE - Allow the user to upload files.
  125. FALSE - No uploading allowed.
  126. */
  127. $IMConfig['allow_upload'] = true;
  128. /*
  129. Possible values: true, false
  130. TRUE - Allow the user to edit images.
  131. FALSE - No editing allowed.
  132. */
  133. $IMConfig['allow_edit'] = true;
  134. /*
  135. Possible values: true, false
  136. TRUE - Allow the replacement of the image with a newly uploaded image in the editor dialog.
  137. FALSE - No replacing allowed.
  138. */
  139. $IMConfig['allow_replace'] = false;
  140. /*
  141. Possible values: true, false
  142. TRUE - Allow the deletion of images
  143. FALSE - No deleting allowed
  144. */
  145. $IMConfig['allow_delete'] = true;
  146. /*
  147. Possible values: true, false
  148. TRUE - Allow the user to enter a new filename for saving the edited image.
  149. FALSE - Overwrite
  150. */
  151. $IMConfig['allow_newFileName'] = false;
  152. /*
  153. Possible values: true, false
  154. Only applies when the the user can enter a new filename (The baove settig = 'allow_newFileName' true)
  155. TRUE - Overwrite file of entered filename, if file already exist.
  156. FALSE - Save to variant of entered filename, if file already exist.
  157. */
  158. $IMConfig['allow_overwrite'] = false;
  159. /*
  160. Specify the paths of the watermarks to use (relative to $IMConfig['base_dir']).
  161. Specifying none will hide watermarking functionality.
  162. */
  163. /*
  164. $IMConfig['watermarks'] = array (
  165. "imageManager.png",
  166. "imageManager.jpg",
  167. "devshed.png",
  168. "natureWatermark.png"
  169. );
  170. */
  171. $IMConfig['watermarks'] = array();
  172. /*
  173. To limit the width and height for uploaded files, specify the maximum pixeldimensions.
  174. Specify more widthxheight sets by copying both lines and increasing the number in the second brackets.
  175. If only one set is specified, no select list will show and this set will be used by default.
  176. Setting the single set its values to either zero or empty will allow any size.
  177. */
  178. //$IMConfig['maxWidth'][0] = 333;
  179. //$IMConfig['maxHeight'][0] = 333;
  180. //$IMConfig['maxWidth'][1] = 100;
  181. //$IMConfig['maxHeight'][1] = 180;
  182. $IMConfig['maxWidth'][0] = 0;
  183. $IMConfig['maxHeight'][0] = 0;
  184. /*
  185. Uploaded files will be accepted as images if they have file extensions from the list below.
  186. */
  187. $IMConfig['accepted_extensions'] = array('gif', 'jpg', 'png', 'bmp', 'jpeg');
  188. /*
  189. Possible values: true, false
  190. TRUE - If set to true, uploaded files will be validated based on the
  191. function getImageSize, if we can get the image dimensions then
  192. I guess this should be a valid image. Otherwise the file will be rejected.
  193. FALSE - All uploaded files will be processed.
  194. NOTE: If uploading is not allowed, this parameter is ignored.
  195. */
  196. $IMConfig['validate_images'] = true;
  197. /*
  198. The default thumbnail if the thumbnails can not be created, either
  199. due to error or bad image file.
  200. */
  201. $IMConfig['default_thumbnail'] = 'img/default.gif';
  202. /*
  203. Thumbnail dimensions.
  204. */
  205. $IMConfig['thumbnail_width'] = 96;
  206. $IMConfig['thumbnail_height'] = 96;
  207. /*
  208. Image Editor temporary filename prefix.
  209. */
  210. $IMConfig['tmp_prefix'] = '.editor_';
  211. /*
  212. Language and text direction.
  213. */
  214. $IMConfig['language'] = api_get_language_isocode();
  215. $IMConfig['text_direction'] = api_get_text_direction($IMConfig['language']);