/tasks/widgets/ckfinder/config.cfm

http://github.com/blueriver/MuraCMS · ColdFusion · 333 lines · 285 code · 36 blank · 12 comment · 15 complexity · a128d8a3a26acc70b5dbeb722ec72eb5 MD5 · raw file

  1. <!---
  2. ### CKFinder : Configuration File - Basic Instructions
  3. In a generic usage case, the following tasks must be done to configure
  4. CKFinder:
  5. 1. Check the baseUrl and baseDir variables.
  6. 2. If available, paste your license key in the "licenseKey" setting.
  7. 3. Create the CheckAuthentication() function that enables CKFinder for authenticated users.
  8. Other settings may be left with their default values, or used to control
  9. advanced features of CKFinder.
  10. --->
  11. <cfscript>
  12. config = structNew();
  13. currentUser=application.usermanager.read(session.mura.userID);
  14. // This function must check the user session to be sure that he/she is
  15. // authorized to upload and access files in the File Browser. '
  16. function CheckAuthentication()
  17. {
  18. if (isDefined('session.siteid') and application.permUtility.getModulePerm("00000000000000000000000000000000000",session.siteid)) {
  19. return true;
  20. } else {
  21. return false;
  22. }
  23. }
  24. config.licenseName = 'Mura CMS';
  25. config.licenseKey = 'VSYA-KXHX-KXVB-8XHA-2L6P-66LF-FDMT';
  26. /* To make it easy to configure CKFinder, the config.baseUrl and config.baseDir can be used.
  27. * Those are helper variables used later in this config file.
  28. *
  29. * config.baseUrl : the base path used to build the final URL for the resources handled
  30. * in CKFinder. If empty, the default value (/userfiles/) is used.
  31. *
  32. * Examples:
  33. * config.baseUrl = 'http://example.com/ckfinder/files/';
  34. * config.baseUrl = '/userfiles/';
  35. */
  36. //ATTENTION: The trailing slash is required.
  37. config.baseUrl = application.configBean.getAssetPath() & '/' & session.siteid & '/assets/';
  38. config.baseDir = "#application.configBean.getAssetDir()##application.configBean.getFileDelim()##session.siteid##application.configBean.getFileDelim()#assets/";
  39. /*
  40. * Thumbnails : thumbnails settings. All thumbnails will end up in the same
  41. * directory, no matter the resource type.
  42. */
  43. config.thumbnails = structNew();
  44. config.thumbnails.url = config.baseUrl & '/Thumbs';
  45. config.thumbnails.baseDir = config.baseDir & '/Thumbs';
  46. config.thumbnails.enabled = true;
  47. config.thumbnails.directAccess = true;
  48. config.thumbnails.maxWidth = 100;
  49. config.thumbnails.maxHeight = 100;
  50. config.thumbnails.quality = 80;
  51. config.thumbnailDelay = 100;
  52. /*
  53. * set the maximum size of uploaded images
  54. * if uploaded image is larger, it gets scaled down
  55. * Set to 0 to disable this feature
  56. */
  57. config.images.maxWidth = 1600;
  58. config.images.maxHeight = 1200;
  59. config.images.quality = 80;
  60. /*
  61. * config.roleSessionVar : the session variable name that CKFinder must use to retrieve
  62. * the "role" of the current user. The "role", can be used in the "AccessControl"
  63. * settings (bellow in this page).
  64. *
  65. * Note: to use session variables, session management must be enabled in Application.cfc.
  66. * In "core/connector/cfm" there is another Application.cfc file.
  67. * Assign the correct name of your application there.
  68. */
  69. config.roleSessionVar = 'CKFinder_UserRole';
  70. /*
  71. * config.accessControl : used to restrict access or features to specific folders.
  72. *
  73. * Many "config.accessControl" entries can be added. All attributes are optional.
  74. * Subfolders inherit their default settings from their parents' definitions.
  75. *
  76. * - The "role" attribute accepts the special '*' value, which means
  77. * "everybody".
  78. * - The "resourceType" attribute accepts the special value '*', which
  79. * means "all resource types".
  80. */
  81. config.accessControl = arrayNew(1);
  82. config.accessControl[1] = structNew();
  83. config.accessControl[1].role = '*';
  84. config.accessControl[1].resourceType = '*';
  85. config.accessControl[1].folder = '/';
  86. config.accessControl[1].folderView = true;
  87. config.accessControl[1].folderCreate = true;
  88. config.accessControl[1].folderRename = true;
  89. config.accessControl[1].folderDelete = true;
  90. config.accessControl[1].fileView = true;
  91. config.accessControl[1].fileUpload = true;
  92. config.accessControl[1].fileRename = true;
  93. config.accessControl[1].fileDelete = true;
  94. config.accessControl[2] = structNew();
  95. config.accessControl[2].role = '*';
  96. config.accessControl[2].resourceType = 'Files';
  97. config.accessControl[2].folder = '/';
  98. config.accessControl[2].folderView = true;
  99. config.accessControl[2].folderCreate = true;
  100. config.accessControl[2].folderRename = true;
  101. config.accessControl[2].folderDelete = true;
  102. config.accessControl[2].fileView = true;
  103. config.accessControl[2].fileUpload = true;
  104. config.accessControl[2].fileRename = true;
  105. config.accessControl[2].fileDelete = true;
  106. /*
  107. * For example, if you want to restrict the upload, rename or delete of files in
  108. * the "Logos" folder of the resource type "Images", you may uncomment the
  109. * following definition, leaving the above one:
  110. *
  111. * config.accessControl[3] = structNew();
  112. * config.accessControl[3].role = '*';
  113. * config.accessControl[3].resourceType = 'Images';
  114. * config.accessControl[3].folder = '/Logos';
  115. * config.accessControl[3].fileUpload = false;
  116. * config.accessControl[3].fileRename = false;
  117. * config.accessControl[3].fileDelete = false;
  118. *
  119. * ResourceType : defines the "resource types" handled in CKFinder. A resource
  120. * type is nothing more than a way to group files under different paths, each one
  121. * having different configuration settings.
  122. *
  123. * Each resource type name must be unique.
  124. *
  125. * When loading CKFinder, the "type" querystring parameter can be used to display
  126. * a specific type only. If "type" is omitted in the URL, the
  127. * "DefaultResourceTypes" settings is used (may contain the resource type names
  128. * separated by a comma). If left empty, all types are loaded.
  129. *
  130. * maxSize is defined in bytes, but shorthand notation may be also used.
  131. * Available options are: G, M, K (case insensitive).
  132. * 1M equals 1048576 bytes (one Megabyte), 1K equals 1024 bytes (one Kilobyte), 1G equals one Gigabyte.
  133. * Example:
  134. * config.resourceType[1].maxSize = "2M";
  135. */
  136. config.defaultResourceTypes = '';
  137. config.resourceType = arrayNew(1);
  138. config.resourceType[1] = structNew();
  139. config.resourceType[1].name = 'Files';
  140. config.resourceType[1].url = config.baseUrl & '/File';
  141. config.resourceType[1].directory = config.baseDir & '/File';
  142. config.resourceType[1].maxSize = 0;
  143. config.resourceType[1].allowedExtensions = '7z,aiff,asf,avi,bmp,csv,doc,docx,fla,flv,gif,gz,gzip,ics,jpeg,jpg,mid,mov,mp3,mp4,mpc,mpeg,mpg,ods,odt,pdf,png,ppt,pptx,pxd,qt,ram,rar,rm,rmi,rmvb,rtf,sdc,sitd,swf,sxc,sxw,tar,tgz,tif,tiff,txt,vsd,wav,wma,wmv,xls,xlsx,zip,m4v';
  144. config.resourceType[1].deniedExtensions = '';
  145. application.serviceFactory.getBean("fileWriter").touchDir(config.resourceType[1].directory);
  146. config.resourceType[2] = structNew();
  147. config.resourceType[2].name = 'Images';
  148. config.resourceType[2].url = config.baseUrl & 'Image';
  149. config.resourceType[2].directory = config.baseDir & 'Image';
  150. config.resourceType[2].maxSize = 0;
  151. config.resourceType[2].allowedExtensions = 'bmp,gif,jpeg,jpg,png';
  152. config.resourceType[2].deniedExtensions = '';
  153. application.serviceFactory.getBean("fileWriter").touchDir(config.resourceType[2].directory);
  154. config.resourceType[3] = structNew();
  155. config.resourceType[3].name = 'Flash';
  156. config.resourceType[3].url = config.baseUrl & 'Flash';
  157. config.resourceType[3].directory = config.baseDir & 'Flash';
  158. config.resourceType[3].maxSize = 0;
  159. config.resourceType[3].allowedExtensions = 'swf,flv';
  160. config.resourceType[3].deniedExtensions = '';
  161. application.serviceFactory.getBean("fileWriter").touchDir(config.resourceType[3].directory);
  162. if (isdefined("url.type")){
  163. if(currentUser.getS2() and application.configBean.getValue('fmShowApplicationRoot') neq 0){
  164. config.resourceType[4] = structNew();
  165. config.resourceType[4].name = 'Application_Root';
  166. config.resourceType[4].url = application.configBean.getContext();
  167. config.resourceType[4].directory = application.configBean.getWebRoot();
  168. config.resourceType[4].maxSize = 0;
  169. config.resourceType[4].allowedExtensions = '';
  170. config.resourceType[4].deniedExtensions = '';
  171. }
  172. if (not isdefined('application.CKFinderResources')){
  173. application.CKFinderResources=arrayNew(1);
  174. rsSites=application.settingsManager.getList();
  175. for (i=1; i lte rsSites.recordcount; i=(i+1)){
  176. temp = structNew();
  177. temp.name = '#rsSites.siteID[i]#_User_Assets';
  178. temp.url = application.configBean.getAssetPath() & '/' & rsSites.siteID[i] & '/assets/';
  179. temp.directory ="#application.configBean.getAssetDir()##application.configBean.getFileDelim()##rsSites.siteID[i]##application.configBean.getFileDelim()#assets/";
  180. temp.maxSize = 0;
  181. if(application.configBean.getValue('fmAllowedExtensions') eq ''){
  182. temp.allowedExtensions = '7z,aiff,asf,avi,bmp,csv,doc,docx,fla,flv,gif,gz,gzip,jpeg,jpg,mid,mov,mp3,mp4,mpc,mpeg,mpg,ods,odt,pdf,png,ppt,pptx,pxd,qt,ram,rar,rm,rmi,rmvb,rtf,sdc,sitd,swf,sxc,sxw,tar,tgz,tif,tiff,txt,vsd,wav,wma,wmv,xls,xlsx,zip,m4v';
  183. } else {
  184. temp.allowedExtensions = application.configBean.getValue('fmAllowedExtensions');
  185. }
  186. temp.deniedExtensions = '';
  187. arrayAppend(application.CKFinderResources,temp);
  188. if(application.configBean.getValue('fmShowSiteFiles') neq 0){
  189. temp = structNew();
  190. temp.name = '#rsSites.siteID[i]#_Site_Files';
  191. temp.url = application.configBean.getContext() & '/' & rsSites.siteID[i] & '/' ;
  192. temp.directory = application.configBean.getWebRoot() & '/' & rsSites.siteID[i] & '/';
  193. temp.maxSize = 0;
  194. temp.allowedExtensions = '';
  195. temp.deniedExtensions = '';
  196. arrayAppend(application.CKFinderResources,temp);
  197. }
  198. }
  199. }
  200. config.resourceType.addAll(application.CKFinderResources);
  201. }
  202. /*
  203. Due to security issues with Apache modules, it is recommended to leave the
  204. following setting enabled.
  205. How does it work? Suppose the following:
  206. - If "cfm" is on the denied extensions list, a file named foo.cfm cannot be
  207. uploaded.
  208. - If "rar" (or any other) extension is allowed, one can upload a file named
  209. foo.rar.
  210. - The file foo.cfm.rar has "rar" extension so, in theory, it can be also
  211. uploaded.
  212. In some conditions Apache can treat the foo.cfm.rar file just like any ColdFusion
  213. script and execute it.
  214. If checkDoubleExtension is enabled, each part of the file name after a dot is
  215. checked, not only the last part. In this way, uploading foo.cfm.rar would be
  216. denied, because "cfm" is on the denied extensions list.
  217. */
  218. config.checkDoubleExtension = true ;
  219. /*
  220. * Perform additional checks for image files
  221. * if set to true, validate image size
  222. */
  223. config.secureImageUploads = true ;
  224. /*
  225. Indicates that the file size (maxSize) for images must be checked only
  226. after scaling them. Otherwise, it is checked right after uploading.
  227. */
  228. config.checkSizeAfterScaling = true ;
  229. /* For security, HTML is allowed in the first Kb of data for files having the
  230. * following extensions only.
  231. */
  232. config.htmlExtensions = 'html,htm,xml,js,cfm,cfc' ;
  233. /*
  234. Folders to not display in CKFinder, no matter their location.
  235. No paths are accepted, only the folder name.
  236. The * and ? wildcards are accepted.
  237. */
  238. config.hideFolders = arrayNew(1);
  239. config.hideFolders[1] = ".svn" ;
  240. config.hideFolders[2] = "CVS" ;
  241. /*
  242. Files to not display in CKFinder, no matter their location.
  243. No paths are accepted, only the file name, including extension.
  244. The * and ? wildcards are accepted.
  245. */
  246. config.hideFiles = arrayNew(1);
  247. config.hideFiles[1] = ".*" ;
  248. /* Set it to false to disable uploading of the dot files
  249. * e.g. .htaccess, .ftpquota
  250. */
  251. config.allowDotFiles = true;
  252. /* Due to known issues with GetTempDirectory function, it is
  253. * recommended to set this vairiable to a valid directory
  254. * instead of using the GetTempDirectory function
  255. */
  256. config.tempDirectory = application.configBean.getTempDir();
  257. /*
  258. * After file is uploaded, sometimes it is required to change its permissions
  259. * so that it was possible to access it at the later time.
  260. * If possible, it is recommended to set more restrictive permissions, like 0755.
  261. * Set to 0 to disable this feature.
  262. * Note: not needed on Windows-based servers.
  263. *
  264. */
  265. if (application.configBean.getValue("usefilemode") eq "" or yesNoFormat(application.configBean.getValue("usefilemode"))){
  266. config.chmodFiles = 644;
  267. config.chmodFolders = 755;
  268. } else {
  269. config.chmodFiles = 0;
  270. config.chmodFolders = 0;
  271. }
  272. config.hooks = arrayNew(1);
  273. config.plugins = arrayNew(1);
  274. if (APPLICATION.CFVersion gte 8 or StructKeyExists(SERVER,"bluedragon")) {
  275. include("plugins/fileeditor/plugin.cfm");
  276. include("plugins/imageresize/plugin.cfm");
  277. // include("plugins/watermark/plugin.cfm");
  278. }
  279. </cfscript>
  280. <cfset $ = application.serviceFactory.getBean("MuraScope").init(session.siteid)>
  281. <cfif (fileExists(expandPath($.siteConfig("includePath") & '/js/finder/config.cfm') ) )>
  282. <cfinclude template="#$.siteConfig('includePath')#/js/finder/config.cfm">
  283. </cfif>
  284. <cfif (fileExists(expandPath($.siteConfig("themeIncludePath") & '/js/finder/config.cfm') ) )>
  285. <cfinclude template="#$.siteConfig('themeIncludePath')#/js/finder/config.cfm">
  286. </cfif>
  287. <cfset $.event("config",config)>
  288. <cfset $.announceEvent("onSiteCKFinderConfig")>