Index: /FCKeditor/trunk/editor/filemanager/connectors/cfm/ImageObject.cfc
===================================================================
--- /FCKeditor/trunk/editor/filemanager/connectors/cfm/ImageObject.cfc	(revision 738)
+++ /FCKeditor/trunk/editor/filemanager/connectors/cfm/ImageObject.cfc	(revision 738)
@@ -0,0 +1,273 @@
+<cfcomponent name="ImageObject">
+<!---
+	ImageObject.cfc written by Rick Root (rick@webworksllc.com)
+	
+	Related Web Sites:
+	- http://www.opensourcecf.com/imagecfc (home page)
+
+
+	This is an object oriented interface to the original
+	ImageCFC.
+
+	Example Code:
+
+	io = createObject("component","ImageObject");
+	io.setOption("defaultJpegCompression",95);
+	io.init("#ExpandPath(".")#/emily.jpg");
+	io.scaleWidth(500);
+	io.save("#ExpandPath(".")#/imagex1.jpg");
+
+	io.flipHorizontal();
+	io.save("#ExpandPath(".")#/imagex2.jpg");
+	io.revert();
+	io.filterFastBlur(2,5);
+	io.save("#ExpandPath(".")#/imagex3.jpg");
+	io.revert();
+	io.filterPosterize(32);
+	io.save("#ExpandPath(".")#/imagex4.jpg");
+
+
+	LICENSE
+	-------
+	Copyright (c) 2006, Rick Root <rick@webworksllc.com>
+	All rights reserved.
+
+	Redistribution and use in source and binary forms, with or 
+	without modification, are permitted provided that the 
+	following conditions are met:
+
+	- Redistributions of source code must retain the above 
+	  copyright notice, this list of conditions and the 
+	  following disclaimer. 
+	- Redistributions in binary form must reproduce the above 
+	  copyright notice, this list of conditions and the 
+	  following disclaimer in the documentation and/or other 
+	  materials provided with the distribution. 
+	- Neither the name of the Webworks, LLC. nor the names of 
+	  its contributors may be used to endorse or promote products 
+	  derived from this software without specific prior written 
+	  permission. 
+
+	THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
+	CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
+	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
+	MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
+	DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 
+	CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+	SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
+	BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
+	LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+	HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
+	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 
+	OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 
+	SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+--->
+
+<cfset variables.img = "">
+<cfset variables.revertimg = "">
+<cfset variables.imageCFC = createObject("component","image")>
+<cfset variables.imageInfo = structNew()>
+	<cfset variables.imageInfo.width = 0>
+	<cfset variables.imageInfo.height = 0>
+	<cfset variables.imageInfo.colorModel = "">
+	<cfset variables.imageInfo.colorspace = "">
+	<cfset variables.imageInfo.objColorModel = "">
+	<cfset variables.imageInfo.objColorspace = "">
+	<cfset variables.imageInfo.sampleModel = "">
+	<cfset variables.imageInfo.imageType = 0>
+	<cfset variables.imageInfo.misc = "">
+	<cfset variables.imageInfo.canModify = false>
+<cfset variables.imageCFC.setOption("throwonerror",true)>
+
+<!---
+
+	init(filename)        Initialize object from a file.
+	init(width, height)   Initialize with a blank image
+	init(bufferedImage)   Initiailize with an existing object
+--->
+<cffunction name="init" access="public" output="false" returnType="void">
+	<cfargument name="arg1" type="any" required="yes">
+	<cfargument name="arg2" type="any" required="no">
+
+	<cfif isDefined("arg2") and isNumeric(arg1) and isNumeric(arg2)>
+		<cfset arg1 = javacast("int",int(arg1))>
+		<cfset arg2 = javacast("int",int(arg2))>
+		<cfset variables.img = createObject("java","java.awt.image.BufferedImage")>
+		<cfset variables.img.init(arg1,arg2,variables.img.TYPE_INT_RGB)>
+	<cfelseif arg1.getClass().getName() eq "java.awt.image.BufferedImage">
+		<cfset variables.img = arg1>
+	<cfelseif isSimpleValue(arg1) and len(arg1) gt 0>
+		<cfset imageResults = variables.imageCFC.readImage(arg1, "no")>
+		<cfset variables.img = imageResults.img>
+	<cfelse>
+		<cfthrow message="Object Instantiation Error" detail="You have attempted to initialize ooimage.cfc with invalid arguments.  Please consult the documentation for correct initialization arguments.">
+	</cfif>
+	<cfif variables.revertimg eq "">
+		<cfset variables.revertimg = variables.img>
+	</cfif>
+	<cfset variables.imageInfo = imageCFC.getImageInfo(variables.img,"")>
+	<cfreturn>
+</cffunction>
+
+<cffunction name="flipHorizontal" access="public" output="true" returnType="void" hint="Flip an image horizontally.">
+	<cfset var imageResults = imageCFC.flipHorizontal(variables.img,"","")>
+	<cfset variables.revertimg = variables.img>
+	<cfset variables.img = imageResults.img>
+	<cfset variables.imageInfo = imageCFC.getImageInfo(variables.img,"")>
+</cffunction>
+
+<cffunction name="getImageInfo" access="public" output="true" returntype="struct" hint="Returns image information.">
+	<cfreturn variables.imageInfo>
+</cffunction>
+<cffunction name="getImageObject" access="public" output="true" returntype="struct" hint="Returns a java Buffered Image Object.">
+	<cfreturn variables.img>
+</cffunction>
+
+<cffunction name="flipVertical" access="public" output="true" returntype="void" hint="Flop an image vertically.">
+	<cfset var imageResults = imageCFC.flipVertical(variables.img,"","")>
+	<cfset variables.revertimg = variables.img>
+	<cfset variables.img = imageResults.img>
+	<cfset variables.imageInfo = imageCFC.getImageInfo(variables.img,"")>
+</cffunction>
+
+<cffunction name="scaleWidth" access="public" output="true" returntype="void" hint="Scale an image to a specific width.">
+	<cfargument name="newWidth" required="yes" type="numeric">
+	<cfset var imageResults = imageCFC.scaleWidth(variables.img,"","", newWidth)>
+	<cfset variables.revertimg = variables.img>
+	<cfset variables.img = imageResults.img>
+	<cfset variables.imageInfo = imageCFC.getImageInfo(variables.img,"")>
+
+</cffunction>
+
+<cffunction name="scaleHeight" access="public" output="true" returntype="void" hint="Scale an image to a specific height.">
+	<cfargument name="newHeight" required="yes" type="numeric">
+	<cfset var imageResults = imageCFC.scaleHeight(variables.img,"","", newHeight)>
+	<cfset variables.revertimg = variables.img>
+	<cfset variables.img = imageResults.img>
+	<cfset variables.imageInfo = imageCFC.getImageInfo(variables.img,"")>
+</cffunction>
+
+<cffunction name="resize" access="public" output="true" returntype="void" hint="Resize an image to a specific width and height.">
+	<cfargument name="newWidth" required="yes" type="numeric">
+	<cfargument name="newHeight" required="yes" type="numeric">
+	<cfargument name="preserveAspect" required="no" type="boolean" default="FALSE">
+	<cfargument name="cropToExact" required="no" type="boolean" default="FALSE">
+
+	<cfset var imageResults = imageCFC.resize(variables.img,"","",newWidth,newHeight,preserveAspect,cropToExact)>
+	<cfset variables.revertimg = variables.img>
+	<cfset variables.img = imageResults.img>
+	<cfset variables.imageInfo = imageCFC.getImageInfo(variables.img,"")>
+</cffunction>
+
+<cffunction name="crop" access="public" output="true" returntype="void" hint="Crop an image.">
+	<cfargument name="fromX" required="yes" type="numeric">
+	<cfargument name="fromY" required="yes" type="numeric">
+	<cfargument name="newWidth" required="yes" type="numeric">
+	<cfargument name="newHeight" required="yes" type="numeric">
+	<cfset var imageResults = imageCFC.crop(variables.img,"","",fromX,fromY,newWidth,newHeight)>
+	<cfset variables.revertimg = variables.img>
+	<cfset variables.img = imageResults.img>
+	<cfset variables.imageInfo = imageCFC.getImageInfo(variables.img,"")>
+
+</cffunction>
+
+<cffunction name="rotate" access="public" output="true" returntype="void" hint="Rotate an image (+/-)90, (+/-)180, or (+/-)270 degrees.">
+	<cfargument name="degrees" required="yes" type="numeric">
+	<cfset var imageResults = imageCFC.rotate(variables.img,"","",degrees)>
+	<cfset variables.revertimg = variables.img>
+	<cfset variables.img = imageResults.img>
+	<cfset variables.imageInfo = imageCFC.getImageInfo(variables.img,"")>
+
+</cffunction>
+
+<cffunction name="setOption" access="public" output="true" returnType="void" hint="Sets values for allowed CFC options.">
+	<cfargument name="key" type="string" required="yes">
+	<cfargument name="val" type="string" required="yes">
+	<cfif lcase(trim(key)) eq "throwonerror">
+		<cfthrow message="Option Configuration Error" detail="You cannot set the throwOnError option when using ImageObject.cfc">
+	</cfif>
+	<cfset imageCFC.setOption(key, val)>
+	
+</cffunction>
+
+<cffunction name="getOption" access="public" output="true" returnType="any" hint="Returns the current value for the specified CFC option.">
+	<cfargument name="key" type="string" required="yes">
+	<cfreturn imageCFC.getOption(key)>
+</cffunction>
+
+<cffunction name="filterFastBlur" access="public" output="true" returntype="void" hint="Internal method used for flipping and flopping images.">
+	<cfargument name="blurAmount" required="yes" type="numeric">
+	<cfargument name="iterations" required="yes" type="numeric">
+	<cfset var imageResults = imageCFC.filterFastBlur(variables.img,"","",blurAmount,iterations)>
+	<cfset variables.revertimg = variables.img>
+	<cfset variables.img = imageResults.img>
+	<cfset variables.imageInfo = imageCFC.getImageInfo(variables.img,"")>
+
+</cffunction>
+
+<cffunction name="filterSharpen" access="public" output="true" returntype="void" hint="Internal method used for flipping and flopping images.">
+	<cfset var imageResults = imageCFC.filterSharpen(variables.img,"","")>
+	<cfset variables.revertimg = variables.img>
+	<cfset variables.img = imageResults.img>
+	<cfset variables.imageInfo = imageCFC.getImageInfo(variables.img,"")>
+
+</cffunction>
+
+
+<cffunction name="filterPosterize" access="public" output="true" returntype="void" hint="Internal method used for flipping and flopping images.">
+	<cfargument name="amount" required="yes" type="string">
+	<cfset var imageResults = imageCFC.filterPosterize(variables.img,"","",amount)>
+	<cfset variables.revertimg = variables.img>
+	<cfset variables.img = imageResults.img>
+	<cfset variables.imageInfo = imageCFC.getImageInfo(variables.img,"")>
+</cffunction>
+
+
+<cffunction name="addText" access="public" output="true" returntype="void" hint="Add text to an image.">
+	<cfargument name="x" required="yes" type="numeric">
+	<cfargument name="y" required="yes" type="numeric">
+	<cfargument name="fontDetails" required="yes" type="struct">
+	<cfargument name="content" required="yes" type="String">
+	<cfset var imageResults = imageCFC.addText(variables.img,"","",x,y,fontDetails,content)>
+	<cfset variables.revertimg = variables.img>
+	<cfset variables.img = imageResults.img>
+	<cfset variables.imageInfo = imageCFC.getImageInfo(variables.img,"")>
+
+</cffunction>
+
+<cffunction name="watermark" access="public" output="false" returnType="void">
+	<cfargument name="wmImage" required="yes" type="Any">
+	<cfargument name="alpha" required="yes" type="numeric">
+	<cfargument name="placeAtX" required="yes" type="numeric">
+	<cfargument name="placeAtY" required="yes" type="numeric">
+
+	<cfset var imageResults = "">
+	<cfif isSimpleValue(wmImage)>
+		<!--- filename or URL --->
+		<cfset imageResults = imageCFC.watermark(variables.img,"","",wmImage,alpha,placeAtX,placeAtY)>
+	<cfelse>
+		<!--- must be a java object --->
+		<cfset imageResults = imageCFC.watermark(variables.img,wmImage,"","",alpha,placeAtX,placeAtY)>
+	</cfif>
+	<cfset variables.revertimg = variables.img>
+	<cfset variables.img = imageResults.img>
+	<cfset variables.imageInfo = imageCFC.getImageInfo(variables.img,"")>
+
+</cffunction>
+
+<cffunction name="save" access="public" output="false" returnType="void">
+	<cfargument name="filename" type="string" required="no">
+	<cfargument name="jpegCompression" type="numeric" required="no">
+	<cfif isDefined("arguments.jpegCompression") and isNumeric(arguments.jpegCompression)>
+		<cfset imageCFC.writeImage(filename,variables.img,jpegCompression)>
+	<cfelse>
+		<cfset imageCFC.writeImage(filename,variables.img)>
+	</cfif>
+</cffunction>
+
+<cffunction name="revert" access="public" output="true" returntype="void" hint="Undo the previous manipulation.">
+	<cfset variables.img = variables.revertimg>
+	<cfset variables.imageInfo = imageCFC.getImageInfo(variables.img,"")>
+</cffunction>
+
+</cfcomponent>
Index: /FCKeditor/trunk/editor/filemanager/connectors/cfm/cf5_connector.cfm
===================================================================
--- /FCKeditor/trunk/editor/filemanager/connectors/cfm/cf5_connector.cfm	(revision 738)
+++ /FCKeditor/trunk/editor/filemanager/connectors/cfm/cf5_connector.cfm	(revision 738)
@@ -0,0 +1,308 @@
+﻿<cfsetting enablecfoutputonly="yes" showdebugoutput="no">
+<!---
+ * FCKeditor - The text editor for Internet - http://www.fckeditor.net
+ * Copyright (C) 2003-2007 Frederico Caldeira Knabben
+ *
+ * == BEGIN LICENSE ==
+ *
+ * Licensed under the terms of any of the following licenses at your
+ * choice:
+ *
+ *  - GNU General Public License Version 2 or later (the "GPL")
+ *    http://www.gnu.org/licenses/gpl.html
+ *
+ *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
+ *    http://www.gnu.org/licenses/lgpl.html
+ *
+ *  - Mozilla Public License Version 1.1 or later (the "MPL")
+ *    http://www.mozilla.org/MPL/MPL-1.1.html
+ *
+ * == END LICENSE ==
+ *
+ * File Browser connector for ColdFusion 5.
+ * (based on the original CF connector by Hendrik Kramer - hk@lwd.de)
+ *
+ * Note:
+ * FCKeditor requires that the connector responds with UTF-8 encoded XML.
+ * As ColdFusion 5 does not fully support UTF-8 encoding, we force ASCII
+ * file and folder names in this connector to allow CF5 send a UTF-8
+ * encoded response - code points under 127 in UTF-8 are stored using a
+ * single byte, using the same encoding as ASCII, which is damn handy.
+ * This is all grand for the English speakers, like meself, but I dunno
+ * how others are gonna take to it. Well, the previous version of this
+ * connector already did this with file names and nobody seemed to mind,
+ * so fingers-crossed nobody will mind their folder names being munged too.
+ *
+--->
+
+<cfparam name="url.command">
+<cfparam name="url.type">
+<cfparam name="url.currentFolder">
+<!--- note: no serverPath url parameter - see config.cfm if you need to set the serverPath manually --->
+
+<cfinclude template="config.cfm">
+
+<cfscript>
+	userFilesPath = config.userFilesPath;
+
+	if ( userFilesPath eq "" )
+	{
+		userFilesPath = "/userfiles/";
+	}
+
+	// make sure the user files path is correctly formatted
+	userFilesPath = replace(userFilesPath, "\", "/", "ALL");
+	userFilesPath = replace(userFilesPath, '//', '/', 'ALL');
+	if ( right(userFilesPath,1) NEQ "/" )
+	{
+		userFilesPath = userFilesPath & "/";
+	}
+	if ( left(userFilesPath,1) NEQ "/" )
+	{
+		userFilesPath = "/" & userFilesPath;
+	}
+
+	// make sure the current folder is correctly formatted
+	url.currentFolder = replace(url.currentFolder, "\", "/", "ALL");
+	url.currentFolder = replace(url.currentFolder, '//', '/', 'ALL');
+	if ( right(url.currentFolder,1) neq "/" )
+	{
+		url.currentFolder = url.currentFolder & "/";
+	}
+	if ( left(url.currentFolder,1) neq "/" )
+	{
+		url.currentFolder = "/" & url.currentFolder;
+	}
+
+	if ( find("/",getBaseTemplatePath()) neq 0 )
+	{
+		fs = "/";
+	}
+	else
+	{
+		fs = "\";
+	}
+
+	// Get the base physical path to the web root for this application. The code to determine the path automatically assumes that
+	// the "FCKeditor" directory in the http request path is directly off the web root for the application and that it's not a
+	// virtual directory or a symbolic link / junction. Use the serverPath config setting to force a physical path if necessary.
+	if ( len(config.serverPath) )
+	{
+		serverPath = config.serverPath;
+
+		if ( right(serverPath,1) neq fs )
+		{
+			serverPath = serverPath & fs;
+		}
+	}
+	else
+	{
+		serverPath = replaceNoCase(getBaseTemplatePath(),replace(cgi.script_name,"/",fs,"all"),"") & replace(userFilesPath,"/",fs,"all");
+	}
+
+	xmlContent = ""; // append to this string to build content
+</cfscript>
+
+<cfif isDefined( "Config.FileTypesAbsolutePath" )
+		and structkeyexists( Config.FileTypesAbsolutePath, url.type )
+		and Len( Config.FileTypesAbsolutePath[url.type] )>
+			<cfset resourceTypeUrl = Config.FileTypesPath[url.type]>
+			<cfset userFilesServerPath = Config.FileTypesAbsolutePath[url.type] & url.currentFolder>
+<cfelse>
+	<cftry>
+	<cfset resourceTypeUrl = Config.FileTypesPath[url.type]>
+	<cfset userFilesServerPath = expandpath( resourceTypeUrl ) & url.currentFolder>
+	<!--- Catch: Parameter 1 of function ExpandPath must be a relative path --->
+	<cfcatch type="any">
+		<cfset userFilesServerPath = serverPath & Config.FileTypesPath[url.type] & url.currentFolder>
+	</cfcatch>
+	</cftry>
+</cfif>
+
+<cfset userFilesServerPath = replace( userFilesServerPath, "/", fs, "all" ) >
+<!--- get rid of double directory separators --->
+<cfset userFilesServerPath = replace( userFilesServerPath, fs & fs, fs, "all") >
+
+<cfif not config.enabled>
+
+	<cfset xmlContent = "<Error number=""1"" text=""This connector is disabled. Please check the 'editor/filemanager/connectors/cfm/config.cfm' file"" />">
+
+<cfelseif find("..",url.currentFolder)>
+
+	<cfset xmlContent = "<Error number=""102"" />">
+
+</cfif>
+
+<cfif not len(xmlContent) and not directoryexists(userFilesServerPath)>
+	<!--- create directories in physical path if they don't already exist --->
+	<cfset currentPath = "">
+	<cftry>
+		<cfloop list="#userFilesServerPath#" index="name" delimiters="#fs#">
+			<cfif currentPath eq "" and fs eq "\">
+				<!--- Without checking this, we would have in Windows \C:\ --->
+				<cfif not directoryExists(name)>
+					<cfdirectory action="create" directory="#name#" mode="755">
+				</cfif>
+			<cfelse>
+				<cfif not directoryExists(currentPath & fs & name)>
+					<cfdirectory action="create" directory="#currentPath##fs##name#" mode="755">
+				</cfif>
+			</cfif>
+
+			<cfif fs eq "\" and currentPath eq "">
+				<cfset currentPath = name>
+			<cfelse>
+				<cfset currentPath = currentPath & fs & name>
+			</cfif>
+		</cfloop>
+
+	<cfcatch type="any">
+
+	<!--- this should only occur as a result of a permissions problem --->
+	<cfset xmlContent = "<Error number=""103"" />">
+
+	</cfcatch>
+	</cftry>
+</cfif>
+
+<cfif not len(xmlContent)>
+
+	<!--- no errors thus far - run command --->
+
+	<!--- we need to know the physical path to the current folder for all commands --->
+	<cfset currentFolderPath = userFilesServerPath>
+
+	<cfswitch expression="#url.command#">
+
+
+		<cfcase value="FileUpload">
+			<cfset config_included = true >
+			<cfinclude template="cf5_upload.cfm">
+			<cfabort>
+		</cfcase>
+
+
+		<cfcase value="GetFolders">
+
+			<!--- Sort directories first, name ascending --->
+			<cfdirectory
+				action="list"
+				directory="#currentFolderPath#"
+				name="qDir"
+				sort="type,name">
+
+			<cfscript>
+				i=1;
+				folders = "";
+				while( i lte qDir.recordCount ) {
+					if( not compareNoCase( qDir.type[i], "FILE" ))
+						break;
+					if( not listFind(".,..", qDir.name[i]) )
+						folders = folders & '<Folder name="#HTMLEditFormat( qDir.name[i] )#" />';
+					i=i+1;
+				}
+
+				xmlContent = xmlContent & '<Folders>' & folders & '</Folders>';
+			</cfscript>
+
+		</cfcase>
+
+
+		<cfcase value="GetFoldersAndFiles">
+
+			<!--- Sort directories first, name ascending --->
+			<cfdirectory
+				action="list"
+				directory="#currentFolderPath#"
+				name="qDir"
+				sort="type,name">
+
+			<cfscript>
+				i=1;
+				folders = "";
+				files = "";
+				while( i lte qDir.recordCount ) {
+					if( not compareNoCase( qDir.type[i], "DIR" ) and not listFind(".,..", qDir.name[i]) ) {
+						folders = folders & '<Folder name="#HTMLEditFormat(qDir.name[i])#" />';
+					} else if( not compareNoCase( qDir.type[i], "FILE" ) ) {
+						fileSizeKB = round(qDir.size[i] / 1024);
+						files = files & '<File name="#HTMLEditFormat(qDir.name[i])#" size="#IIf( fileSizeKB GT 0, DE( fileSizeKB ), 1)#" />';
+					}
+					i=i+1;
+				}
+
+				xmlContent = xmlContent & '<Folders>' & folders & '</Folders>';
+				xmlContent = xmlContent & '<Files>' & files & '</Files>';
+			</cfscript>
+
+		</cfcase>
+
+
+		<cfcase value="CreateFolder">
+
+			<cfparam name="url.newFolderName" default="">
+
+			<cfscript>
+				newFolderName = url.newFolderName;
+				if( reFind("[^A-Za-z0-9_\-\.]", newFolderName) ) {
+					// Munge folder name same way as we do the filename
+					// This means folder names are always US-ASCII so we don't have to worry about CF5 and UTF-8
+					newFolderName = reReplace(newFolderName, "[^A-Za-z0-9\-\.]", "_", "all");
+					newFolderName = reReplace(newFolderName, "_{2,}", "_", "all");
+					newFolderName = reReplace(newFolderName, "([^_]+)_+$", "\1", "all");
+					newFolderName = reReplace(newFolderName, "$_([^_]+)$", "\1", "all");
+				}
+			</cfscript>
+
+			<cfif not len(newFolderName) or len(newFolderName) gt 255>
+				<cfset errorNumber = 102>
+			<cfelseif directoryExists(currentFolderPath & newFolderName)>
+				<cfset errorNumber = 101>
+			<cfelseif reFind("^\.\.",newFolderName)>
+				<cfset errorNumber = 103>
+			<cfelse>
+				<cfset errorNumber = 0>
+
+				<cftry>
+					<cfdirectory
+						action="create"
+						directory="#currentFolderPath##newFolderName#"
+						mode="755">
+					<cfcatch>
+						<!---
+						un-resolvable error numbers in ColdFusion:
+						* 102 : Invalid folder name.
+						* 103 : You have no permissions to create the folder.
+						--->
+						<cfset errorNumber = 110>
+					</cfcatch>
+				</cftry>
+			</cfif>
+
+			<cfset xmlContent = xmlContent & '<Error number="#errorNumber#" />'>
+
+		</cfcase>
+
+
+		<cfdefaultcase>
+
+			<cfthrow type="fckeditor.connector" message="Illegal command: #url.command#">
+
+		</cfdefaultcase>
+
+
+	</cfswitch>
+
+</cfif>
+
+<cfscript>
+	xmlHeader = '<?xml version="1.0" encoding="utf-8" ?><Connector command="#url.command#" resourceType="#url.type#">';
+	xmlHeader = xmlHeader & '<CurrentFolder path="#url.currentFolder#" url="#resourceTypeUrl##url.currentFolder#" />';
+	xmlFooter = '</Connector>';
+</cfscript>
+
+<cfheader name="Expires" value="#GetHttpTimeString(Now())#">
+<cfheader name="Pragma" value="no-cache">
+<cfheader name="Cache-Control" value="no-cache, no-store, must-revalidate">
+<cfcontent reset="true" type="text/xml; charset=UTF-8">
+<cfoutput>#xmlHeader##xmlContent##xmlFooter#</cfoutput>
Index: /FCKeditor/trunk/editor/filemanager/connectors/cfm/cf5_upload.cfm
===================================================================
--- /FCKeditor/trunk/editor/filemanager/connectors/cfm/cf5_upload.cfm	(revision 738)
+++ /FCKeditor/trunk/editor/filemanager/connectors/cfm/cf5_upload.cfm	(revision 738)
@@ -0,0 +1,242 @@
+<cfsetting enablecfoutputonly="Yes">
+<!---
+ * FCKeditor - The text editor for Internet - http://www.fckeditor.net
+ * Copyright (C) 2003-2007 Frederico Caldeira Knabben
+ *
+ * == BEGIN LICENSE ==
+ *
+ * Licensed under the terms of any of the following licenses at your
+ * choice:
+ *
+ *  - GNU General Public License Version 2 or later (the "GPL")
+ *    http://www.gnu.org/licenses/gpl.html
+ *
+ *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
+ *    http://www.gnu.org/licenses/lgpl.html
+ *
+ *  - Mozilla Public License Version 1.1 or later (the "MPL")
+ *    http://www.mozilla.org/MPL/MPL-1.1.html
+ *
+ * == END LICENSE ==
+ *
+ * This is the "File Uploader" for ColdFusion 5.
+ * Based on connector.cfm by Mark Woods (mark@thickpaddy.com)
+ *
+ * Note:
+ * FCKeditor requires that the connector responds with UTF-8 encoded XML.
+ * As ColdFusion 5 does not fully support UTF-8 encoding, we force ASCII
+ * file and folder names in this connector to allow CF5 send a UTF-8
+ * encoded response - code points under 127 in UTF-8 are stored using a
+ * single byte, using the same encoding as ASCII, which is damn handy.
+ * This is all grand for the English speakers, like meself, but I dunno
+ * how others are gonna take to it. Well, the previous version of this
+ * connector already did this with file names and nobody seemed to mind,
+ * so fingers-crossed nobody will mind their folder names being munged too.
+ *
+--->
+
+<cfparam name="url.command" default="QuickUpload">
+<cfparam name="url.type" default="File">
+<cfparam name="url.currentFolder" default="/">
+
+<cfif not isDefined("config_included")>
+	<cfinclude template="config.cfm">
+</cfif>
+
+<cfscript>
+	function SendUploadResults(errorNumber, fileUrl, fileName, customMsg)
+	{
+		WriteOutput('<script type="text/javascript">');
+		WriteOutput('window.parent.OnUploadCompleted(' & errorNumber & ', "' & JSStringFormat(fileUrl) & '", "' & JSStringFormat(fileName) & '", "' & JSStringFormat(customMsg) & '");' );
+		WriteOutput('</script>');
+	}
+</cfscript>
+
+<cfif NOT config.enabled>
+	<cfset SendUploadResults(1, "", "", "This file uploader is disabled. Please check the ""editor/filemanager/connectors/cfm/config.cfm"" file")>
+	<cfabort>
+</cfif>
+
+
+<cfscript>
+	userFilesPath = config.userFilesPath;
+
+	if ( userFilesPath eq "" ) {
+		userFilesPath = "/userfiles/";
+	}
+
+	// make sure the user files path is correctly formatted
+	userFilesPath = replace(userFilesPath, "\", "/", "ALL");
+	userFilesPath = replace(userFilesPath, '//', '/', 'ALL');
+	if ( right(userFilesPath,1) NEQ "/" ) {
+		userFilesPath = userFilesPath & "/";
+	}
+	if ( left(userFilesPath,1) NEQ "/" ) {
+		userFilesPath = "/" & userFilesPath;
+	}
+
+	// make sure the current folder is correctly formatted
+	url.currentFolder = replace(url.currentFolder, "\", "/", "ALL");
+	url.currentFolder = replace(url.currentFolder, '//', '/', 'ALL');
+	if ( right(url.currentFolder,1) neq "/" ) {
+		url.currentFolder = url.currentFolder & "/";
+	}
+	if ( left(url.currentFolder,1) neq "/" ) {
+		url.currentFolder = "/" & url.currentFolder;
+	}
+
+	if (find("/",getBaseTemplatePath())) {
+		fs = "/";
+	} else {
+		fs = "\";
+	}
+
+	// Get the base physical path to the web root for this application. The code to determine the path automatically assumes that
+	// the "FCKeditor" directory in the http request path is directly off the web root for the application and that it's not a
+	// virtual directory or a symbolic link / junction. Use the serverPath config setting to force a physical path if necessary.
+	if ( len(config.serverPath) ) {
+		serverPath = config.serverPath;
+
+		if ( right(serverPath,1) neq fs ) {
+			serverPath = serverPath & fs;
+		}
+	} else {
+		serverPath = replaceNoCase(getBaseTemplatePath(),replace(cgi.script_name,"/",fs,"all"),"") & replace(userFilesPath,"/",fs,"all");
+	}
+
+</cfscript>
+
+<cfif url.command eq "QuickUpload">
+	<cfif isDefined( "Config.QuickUploadAbsolutePath" )
+			and structkeyexists( Config.QuickUploadAbsolutePath, url.type )
+			and Len( Config.QuickUploadAbsolutePath[url.type] )>
+				<cfset resourceTypeUrl = Config.QuickUploadPath[url.type]>
+				<cfset userFilesServerPath = Config.QuickUploadAbsolutePath[url.type] & url.currentFolder>
+	<cfelse>
+		<cftry>
+		<cfset resourceTypeUrl = Config.QuickUploadPath[url.type]>
+		<cfset userFilesServerPath = expandpath( resourceTypeUrl ) & url.currentFolder>
+		<!--- Catch: Parameter 1 of function ExpandPath must be a relative path --->
+		<cfcatch type="any">
+			<cfset userFilesServerPath = serverPath & Config.QuickUploadPath[url.type] & url.currentFolder>
+		</cfcatch>
+		</cftry>
+	</cfif>
+<cfelse>
+	<cfif isDefined( "Config.FileTypesAbsolutePath" )
+			and structkeyexists( Config.FileTypesAbsolutePath, url.type )
+			and Len( Config.FileTypesAbsolutePath[url.type] )>
+				<cfset resourceTypeUrl = Config.FileTypesPath[url.type]>
+				<cfset userFilesServerPath = Config.FileTypesAbsolutePath[url.type] & url.currentFolder>
+	<cfelse>
+		<cftry>
+		<cfset resourceTypeUrl = Config.FileTypesPath[url.type]>
+		<cfset userFilesServerPath = expandpath( resourceTypeUrl ) & url.currentFolder>
+		<!--- Catch: Parameter 1 of function ExpandPath must be a relative path --->
+		<cfcatch type="any">
+			<cfset userFilesServerPath = serverPath & Config.FileTypesPath[url.type] & url.currentFolder>
+		</cfcatch>
+		</cftry>
+	</cfif>
+</cfif>
+
+<cfset userFilesServerPath = replace( userFilesServerPath, "/", fs, "all" ) >
+<!--- get rid of double directory separators --->
+<cfset userFilesServerPath = replace( userFilesServerPath, fs & fs, fs, "all") >
+
+<cfset currentFolderPath = userFilesServerPath>
+<cfset resourceType = url.type>
+
+<cfset fileName = "">
+<cfset fileExt = "">
+
+<!--- Can be overwritten. The last value will be sent with the result --->
+<cfset customMsg = "">
+
+<cftry>
+
+	<!--- first upload the file with an unique filename --->
+	<cffile action="upload"
+		fileField="NewFile"
+		destination="#currentFolderPath#"
+		nameConflict="makeunique"
+		mode="644"
+		attributes="normal">
+
+	<cfif cffile.fileSize EQ 0>
+		<cfthrow>
+	</cfif>
+
+	<cfset lAllowedExtensions = config.allowedExtensions[#resourceType#]>
+	<cfset lDeniedExtensions = config.deniedExtensions[#resourceType#]>
+
+	<cfif ( len(lAllowedExtensions) and not listFindNoCase(lAllowedExtensions,cffile.ServerFileExt) )
+		or ( len(lDeniedExtensions) and listFindNoCase(lDeniedExtensions,cffile.ServerFileExt) )>
+
+		<cfset errorNumber = "202">
+		<cffile action="delete" file="#cffile.ServerDirectory##fs##cffile.ServerFile#">
+
+	<cfelse>
+
+		<cfscript>
+		errorNumber = 0;
+		fileName = cffile.ClientFileName;
+		fileExt = cffile.ServerFileExt;
+
+		// munge filename for html download. Only a-z, 0-9, _, - and . are allowed
+		if( reFind("[^A-Za-z0-9_\-\.]", fileName) ) {
+			fileName = reReplace(fileName, "[^A-Za-z0-9\-\.]", "_", "ALL");
+			fileName = reReplace(fileName, "_{2,}", "_", "ALL");
+			fileName = reReplace(fileName, "([^_]+)_+$", "\1", "ALL");
+			fileName = reReplace(fileName, "$_([^_]+)$", "\1", "ALL");
+		}
+
+		// When the original filename already exists, add numbers (0), (1), (2), ... at the end of the filename.
+		if( compare( cffile.ServerFileName, fileName ) ) {
+			counter = 0;
+			tmpFileName = fileName;
+			while( fileExists("#currentFolderPath##fileName#.#fileExt#") ) {
+				counter = counter + 1;
+				fileName = tmpFileName & '(#counter#)';
+			}
+		}
+		</cfscript>
+
+		<!--- Rename the uploaded file, if neccessary --->
+		<cfif compare(cffile.ServerFileName,fileName)>
+
+			<cfset errorNumber = "201">
+			<cffile
+				action="rename"
+				source="#currentFolderPath##cffile.ServerFileName#.#cffile.ServerFileExt#"
+				destination="#currentFolderPath##fileName#.#fileExt#"
+				mode="644"
+				attributes="normal">
+
+		</cfif>
+
+	</cfif>
+
+	<cfcatch type="any">
+
+		<cfset errorNumber = "1">
+		<cfset customMsg = cfcatch.message >
+
+	</cfcatch>
+
+</cftry>
+
+
+<cfif errorNumber EQ 0>
+	<!--- file was uploaded succesfully --->
+	<cfset SendUploadResults(errorNumber, '#resourceTypeUrl##fileName#.#fileExt#', "", "")>
+	<cfabort>
+<cfelseif errorNumber EQ 201>
+	<!--- file was changed (201), submit the new filename --->
+	<cfset SendUploadResults(errorNumber, '#resourceTypeUrl##fileName#.#fileExt#', replace( fileName & "." & fileExt, "'", "\'", "ALL"), customMsg)>
+	<cfabort>
+<cfelse>
+	<!--- An error occured(202). Submit only the error code and a message (if available). --->
+	<cfset SendUploadResults(errorNumber, '', '', customMsg)>
+	<cfabort>
+</cfif>
Index: /FCKeditor/trunk/editor/filemanager/connectors/cfm/cf_basexml.cfm
===================================================================
--- /FCKeditor/trunk/editor/filemanager/connectors/cfm/cf_basexml.cfm	(revision 738)
+++ /FCKeditor/trunk/editor/filemanager/connectors/cfm/cf_basexml.cfm	(revision 738)
@@ -0,0 +1,68 @@
+<cfsetting enablecfoutputonly="Yes">
+<!---
+ * FCKeditor - The text editor for Internet - http://www.fckeditor.net
+ * Copyright (C) 2003-2007 Frederico Caldeira Knabben
+ *
+ * == BEGIN LICENSE ==
+ *
+ * Licensed under the terms of any of the following licenses at your
+ * choice:
+ *
+ *  - GNU General Public License Version 2 or later (the "GPL")
+ *    http://www.gnu.org/licenses/gpl.html
+ *
+ *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
+ *    http://www.gnu.org/licenses/lgpl.html
+ *
+ *  - Mozilla Public License Version 1.1 or later (the "MPL")
+ *    http://www.mozilla.org/MPL/MPL-1.1.html
+ *
+ * == END LICENSE ==
+ *
+ * This file include the functions that create the base XML output by the ColdFusion Connector (MX 6.0 and above).
+--->
+
+<cffunction name="SetXmlHeaders" returntype="void">
+	<cfheader name="Expires" value="#GetHttpTimeString(Now())#">
+	<cfheader name="Pragma" value="no-cache">
+	<cfheader name="Cache-Control" value="no-cache, no-store, must-revalidate">
+	<cfcontent reset="true" type="text/xml; charset=UTF-8">
+</cffunction>
+
+<cffunction name="CreateXmlHeader" returntype="void" output="true">
+	<cfargument name="command" required="true">
+	<cfargument name="resourceType" required="true">
+	<cfargument name="currentFolder" required="true">
+
+	<cfset SetXmlHeaders()>
+	<cfoutput><?xml version="1.0" encoding="utf-8" ?></cfoutput>
+	<cfoutput><Connector command="#ARGUMENTS.command#" resourceType="#ARGUMENTS.resourceType#"></cfoutput>
+	<cfoutput><CurrentFolder path="#HTMLEditFormat(ARGUMENTS.currentFolder)#" url="#HTMLEditFormat( GetUrlFromPath( resourceType, currentFolder, command ) )#" /></cfoutput>
+	<cfset REQUEST.HeaderSent = true>
+</cffunction>
+
+<cffunction name="CreateXmlFooter" returntype="void" output="true">
+	<cfoutput></Connector></cfoutput>
+</cffunction>
+
+<cffunction name="SendError" returntype="void" output="true">
+	<cfargument name="number" required="true" type="Numeric">
+	<cfargument name="text" required="true">
+	<cfif isDefined("REQUEST.HeaderSent") and REQUEST.HeaderSent>
+		<cfset SendErrorNode( ARGUMENTS.number, ARGUMENTS.text )>
+		<cfset CreateXmlFooter() >
+	<cfelse>
+		<cfset SetXmlHeaders()>
+		<cfoutput><?xml version="1.0" encoding="utf-8" ?></cfoutput>
+		<cfoutput><Connector></cfoutput>
+		<cfset SendErrorNode( ARGUMENTS.number, ARGUMENTS.text )>
+		<cfset CreateXmlFooter() >
+	</cfif>
+	<cfabort>
+</cffunction>
+
+<cffunction name="SendErrorNode" returntype="void" output="true">
+	<cfargument name="number" required="true" type="Numeric">
+	<cfargument name="text" required="true">
+	<cfoutput><Error number="#ARGUMENTS.number#" text="#htmleditformat(ARGUMENTS.text)#" /></cfoutput>
+</cffunction>
Index: /FCKeditor/trunk/editor/filemanager/connectors/cfm/cf_commands.cfm
===================================================================
--- /FCKeditor/trunk/editor/filemanager/connectors/cfm/cf_commands.cfm	(revision 738)
+++ /FCKeditor/trunk/editor/filemanager/connectors/cfm/cf_commands.cfm	(revision 738)
@@ -0,0 +1,213 @@
+<cfsetting enablecfoutputonly="Yes">
+<!---
+ * FCKeditor - The text editor for Internet - http://www.fckeditor.net
+ * Copyright (C) 2003-2007 Frederico Caldeira Knabben
+ *
+ * == BEGIN LICENSE ==
+ *
+ * Licensed under the terms of any of the following licenses at your
+ * choice:
+ *
+ *  - GNU General Public License Version 2 or later (the "GPL")
+ *    http://www.gnu.org/licenses/gpl.html
+ *
+ *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
+ *    http://www.gnu.org/licenses/lgpl.html
+ *
+ *  - Mozilla Public License Version 1.1 or later (the "MPL")
+ *    http://www.mozilla.org/MPL/MPL-1.1.html
+ *
+ * == END LICENSE ==
+ *
+ * This file include the functions that handle the Command requests
+ * in the ColdFusion Connector (MX 6.0 and above).
+--->
+
+<cffunction name="FileUpload" returntype="void" output="true">
+	<cfargument name="resourceType" type="string" required="yes" default="">
+	<cfargument name="currentFolder" type="string" required="yes" default="">
+	<cfargument name="sCommand" type="string" required="yes" default="">
+
+	<cfset var sFileName = "">
+	<cfset var sFilePart = "">
+	<cfset var sFileExt = "">
+	<cfset var sFileUrl = "">
+	<cfset var sTempFilePath = "">
+	<cfset var errorNumber = 0>
+	<cfset var customMsg = 0>
+	<cfset var counter = 0>
+	<cfset var destination = "">
+
+    <cftry>
+        <cffile action="UPLOAD" filefield="NewFile" destination="#GetTempDirectory()#" nameconflict="makeunique" mode="0755" />
+		<cfset sTempFilePath = CFFILE.ServerDirectory & REQUEST.fs & CFFILE.ServerFile>
+
+		<!--- Map the virtual path to the local server path. --->
+		<cfset sServerDir = ServerMapFolder( ARGUMENTS.resourceType, ARGUMENTS.currentFolder, ARGUMENTS.sCommand) >
+		<!--- Get the uploaded file name. --->
+		<cfset sFileName = SanitizeFileName( CFFILE.ClientFile ) >
+		<cfset sOriginalFileName = sFileName >
+
+		<cfif isDefined("REQUEST.Config.SecureImageUploads") and REQUEST.Config.SecureImageUploads>
+			<cfif not IsFileValid( sTempFilePath, CFFILE.ClientFileExt, REQUEST.Config.SecureImageUploads )>
+				<cftry>
+				<cffile action="delete" file="#sTempFilePath#">
+				<cfcatch type="any">
+				</cfcatch>
+				</cftry>
+				<cfthrow errorcode="202" type="fckeditor">
+			</cfif>
+		</cfif>
+
+		<cfif not IsAllowedExt( CFFILE.ClientFileExt, ARGUMENTS.resourceType )>
+			<cftry>
+			<cffile action="delete" file="#sTempFilePath#">
+			<cfcatch type="any">
+			</cfcatch>
+			</cftry>
+			<cfthrow errorcode="202" type="fckeditor">
+		</cfif>
+
+		<!--- When the original filename already exists, add numbers (0), (1), (2), ... at the end of the filename. --->
+		<cfscript>
+			sFileExt = GetExtension( sFileName ) ;
+			sFilePart = RemoveExtension( sFileName );
+			while( fileExists( sServerDir & sFileName ) )
+			{
+				counter = counter + 1;
+				sFileName = sFilePart & '(#counter#).' & CFFILE.ClientFileExt;
+				errorNumber = 201;
+			}
+		</cfscript>
+
+ 		<cfset destination = sServerDir & sFileName>
+<!---
+		<cfdump var="#sTempFilePath#">
+		<cfoutput ><br /></cfoutput>
+		<cfdump var="#destination#">
+		<cfabort>
+ --->
+		<cflock name="#destination#" timeout="30" type="Exclusive">
+		<cftry>
+			<cffile action="move" source="#sTempFilePath#" destination="#destination#" mode="755">
+			<!--- omit CF 6.1 error during moving uploaded file, just copy that file instead of moving --->
+			<cfcatch type="any">
+				<cffile action="copy" source="#sTempFilePath#" destination="#destination#" mode="755">
+			</cfcatch>
+		</cftry>
+		</cflock>
+
+		<cfset sFileUrl = CombinePaths( GetResourceTypePath( ARGUMENTS.resourceType, sCommand ) , sFileName ) >
+
+		<cfcatch type="fckeditor">
+			<cfset errorNumber = CFCATCH.ErrorCode>
+		</cfcatch>
+
+		<cfcatch type="any">
+			<cfset errorNumber = "1">
+			<cfset customMsg = CFCATCH.Message >
+		</cfcatch>
+
+    </cftry>
+
+	<cfset SendUploadResults( errorNumber, sFileUrl, sFileName, customMsg ) >
+</cffunction>
+
+<cffunction name="GetFolders" returntype="void" output="true">
+	<cfargument name="resourceType" type="String" required="true">
+	<cfargument name="currentFolder" type="String" required="true">
+
+	<cfset var i = 1>
+	<cfset var folders = "">
+	<!--- Map the virtual path to the local server path --->
+	<cfset var sServerDir = ServerMapFolder( ARGUMENTS.resourceType, ARGUMENTS.currentFolder, "GetFolders" ) >
+
+	<!--- Sort directories first, name ascending --->
+	<cfdirectory action="list" directory="#sServerDir#" name="qDir" sort="type,name">
+	<cfscript>
+		while( i lte qDir.recordCount )
+		{
+			if( compareNoCase( qDir.type[i], "FILE" ) and not listFind( ".,..", qDir.name[i] ) )
+			{
+				folders = folders & '<Folder name="#HTMLEditFormat( qDir.name[i] )#" />' ;
+			}
+			i = i + 1;
+		}
+	</cfscript>
+	<cfoutput><Folders>#folders#</Folders></cfoutput>
+</cffunction>
+
+<cffunction name="GetFoldersAndfiles" returntype="void" output="true">
+	<cfargument name="resourceType" type="String" required="true">
+	<cfargument name="currentFolder" type="String" required="true">
+
+	<cfset var i = 1>
+	<cfset var folders = "">
+	<cfset var files = "">
+	<!--- Map the virtual path to the local server path --->
+	<cfset var sServerDir = ServerMapFolder( ARGUMENTS.resourceType, ARGUMENTS.currentFolder, "GetFolders" ) >
+
+	<!--- Sort directories first, name ascending --->
+	<cfdirectory action="list" directory="#sServerDir#" name="qDir" sort="type,name">
+	<cfscript>
+		while( i lte qDir.recordCount )
+		{
+			if( not compareNoCase( qDir.type[i], "DIR" ) and not listFind( ".,..", qDir.name[i] ) )
+			{
+				folders = folders & '<Folder name="#HTMLEditFormat(qDir.name[i])#" />' ;
+			}
+			else if( not compareNoCase( qDir.type[i], "FILE" ) )
+			{
+				fileSizeKB = round(qDir.size[i] / 1024) ;
+				files = files & '<File name="#HTMLEditFormat(qDir.name[i])#" size="#IIf( fileSizeKB GT 0, DE( fileSizeKB ), 1)#" />' ;
+			}
+			i = i + 1 ;
+		}
+	</cfscript>
+	<cfoutput><Folders>#folders#</Folders></cfoutput>
+	<cfoutput><Files>#files#</Files></cfoutput>
+</cffunction>
+
+<cffunction name="CreateFolder" returntype="void" output="true">
+	<cfargument name="resourceType" required="true" type="string">
+	<cfargument name="currentFolder" required="true" type="string">
+
+	<cfset var sNewFolderName = url.newFolderName >
+	<cfset var sServerDir = "" >
+	<cfset var errorNumber = 0>
+	<cfset var sErrorMsg = "">
+	<cfset var currentFolderPath = ServerMapFolder( ARGUMENTS.resourceType, ARGUMENTS.currentFolder, 'CreateFolder' )>
+
+	<cfparam name="url.newFolderName" default="">
+
+	<cfscript>
+		sNewFolderName = SanitizeFolderName( sNewFolderName ) ;
+	</cfscript>
+
+	<cfif not len( sNewFolderName ) or len( sNewFolderName ) gt 255>
+		<cfset errorNumber = 102>
+	<cfelseif directoryExists( currentFolderPath & sNewFolderName )>
+		<cfset errorNumber = 101>
+	<cfelseif find( "..", sNewFolderName )>
+		<cfset errorNumber = 103>
+	<cfelse>
+		<cfset errorNumber = 0>
+
+		<!--- Map the virtual path to the local server path of the current folder. --->
+		<cfset sServerDir = currentFolderPath & sNewFolderName >
+
+		<cftry>
+			<cfdirectory action="create" directory="#currentFolderPath##sNewFolderName#" mode="755">
+			<cfcatch type="any">
+			<!---
+				un-resolvable error numbers in ColdFusion:
+				* 102 : Invalid folder name.
+				* 103 : You have no permissions to create the folder.
+			--->
+			<cfset errorNumber = 110>
+			</cfcatch>
+		</cftry>
+	</cfif>
+
+	<cfoutput><Error number="#errorNumber#" originalDescription="#HTMLEditFormat(sErrorMsg)#" /></cfoutput>
+</cffunction>
Index: /FCKeditor/trunk/editor/filemanager/connectors/cfm/cf_connector.cfm
===================================================================
--- /FCKeditor/trunk/editor/filemanager/connectors/cfm/cf_connector.cfm	(revision 738)
+++ /FCKeditor/trunk/editor/filemanager/connectors/cfm/cf_connector.cfm	(revision 738)
@@ -0,0 +1,89 @@
+﻿<cfsetting enablecfoutputonly="yes" showdebugoutput="no">
+<!---
+ * FCKeditor - The text editor for Internet - http://www.fckeditor.net
+ * Copyright (C) 2003-2007 Frederico Caldeira Knabben
+ *
+ * == BEGIN LICENSE ==
+ *
+ * Licensed under the terms of any of the following licenses at your
+ * choice:
+ *
+ *  - GNU General Public License Version 2 or later (the "GPL")
+ *    http://www.gnu.org/licenses/gpl.html
+ *
+ *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
+ *    http://www.gnu.org/licenses/lgpl.html
+ *
+ *  - Mozilla Public License Version 1.1 or later (the "MPL")
+ *    http://www.mozilla.org/MPL/MPL-1.1.html
+ *
+ * == END LICENSE ==
+ *
+ * File Browser connector for ColdFusion (MX 6.0 and above).
+ * (based on the original CF connector by Hendrik Kramer - hk@lwd.de)
+ *
+--->
+
+<cfparam name="url.command">
+<cfparam name="url.type">
+<cfparam name="url.currentFolder">
+
+<!--- note: no serverPath url parameter - see config.cfm if you need to set the serverPath manually --->
+
+<cfinclude template="config.cfm">
+<cfinclude template="cf_util.cfm">
+<cfinclude template="cf_io.cfm">
+<cfinclude template="cf_basexml.cfm">
+<cfinclude template="cf_commands.cfm">
+
+<cfif not Config.Enabled>
+	<cfset SendError( 1, 'This connector is disabled. Please check the "editor/filemanager/connectors/cfm/config.cfm" file' )>
+</cfif>
+
+<cfset REQUEST.Config = Config>
+<cfif find( "/", getBaseTemplatePath() ) >
+	<cfset REQUEST.Fs = "/">
+<cfelse>
+	<cfset REQUEST.Fs = "\">
+</cfif>
+
+<cfset DoResponse() >
+
+<cffunction name="DoResponse" output="true" returntype="void">
+
+	<!--- Get the main request informaiton. --->
+	<cfset var sCommand	= "#URL.Command#" >
+	<cfset var sResourceType	= URL.Type >
+	<cfset var sCurrentFolder	= GetCurrentFolder() >
+
+	<!--- Check if it is an allowed command --->
+	<cfif not IsAllowedCommand( sCommand ) >
+		<cfset SendError( 1, "The """ & sCommand & """ command isn't allowed" ) >
+	</cfif>
+
+	<!--- Check if it is an allowed type. --->
+	<cfif not IsAllowedType( sResourceType ) >
+		<cfset SendError( 1, 'Invalid type specified' ) >
+	</cfif>
+
+	<!--- File Upload doesn't have to Return XML, so it must be intercepted before anything. --->
+	<cfif sCommand eq "FileUpload">
+		<cfset FileUpload( sResourceType, sCurrentFolder, sCommand )>
+		<cfabort>
+	</cfif>
+
+	<cfset CreateXmlHeader( sCommand, sResourceType, sCurrentFolder )>
+
+	<!--- Execute the required command. --->
+	<cfif sCommand eq "GetFolders">
+		<cfset GetFolders( sResourceType, sCurrentFolder ) >
+	<cfelseif sCommand eq "GetFoldersAndFiles">
+		<cfset GetFoldersAndFiles( sResourceType, sCurrentFolder ) >
+	<cfelseif sCommand eq "CreateFolder">
+		<cfset CreateFolder( sResourceType, sCurrentFolder ) >
+	</cfif>
+
+	<cfset CreateXmlFooter()>
+
+	<cfexit>
+</cffunction>
Index: /FCKeditor/trunk/editor/filemanager/connectors/cfm/cf_io.cfm
===================================================================
--- /FCKeditor/trunk/editor/filemanager/connectors/cfm/cf_io.cfm	(revision 738)
+++ /FCKeditor/trunk/editor/filemanager/connectors/cfm/cf_io.cfm	(revision 738)
@@ -0,0 +1,288 @@
+<cfsetting enablecfoutputonly="Yes">
+<!---
+ * FCKeditor - The text editor for Internet - http://www.fckeditor.net
+ * Copyright (C) 2003-2007 Frederico Caldeira Knabben
+ *
+ * == BEGIN LICENSE ==
+ *
+ * Licensed under the terms of any of the following licenses at your
+ * choice:
+ *
+ *  - GNU General Public License Version 2 or later (the "GPL")
+ *    http://www.gnu.org/licenses/gpl.html
+ *
+ *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
+ *    http://www.gnu.org/licenses/lgpl.html
+ *
+ *  - Mozilla Public License Version 1.1 or later (the "MPL")
+ *    http://www.mozilla.org/MPL/MPL-1.1.html
+ *
+ * == END LICENSE ==
+ *
+ * This file include IO specific functions used by the ColdFusion Connector (MX 6.0 and above).
+ *
+--->
+
+<cffunction name="CombinePaths" returntype="String" output="true">
+	<cfargument name="sBasePath" required="true">
+	<cfargument name="sFolder" required="true">
+	<cfset sBasePath = RemoveFromEnd( sBasePath, "/" )>
+	<cfset sBasePath = RemoveFromEnd( sBasePath, "\" )>
+	<cfreturn sBasePath & "/" & RemoveFromStart( ARGUMENTS.sFolder, '/' )>
+</cffunction>
+
+<cffunction name="GetResourceTypePath" returntype="String" output="false">
+	<cfargument name="resourceType" required="true">
+	<cfargument name="sCommand" required="true">
+
+	<cfif ARGUMENTS.sCommand eq "QuickUpload">
+		<cfreturn REQUEST.Config['QuickUploadPath'][ARGUMENTS.resourceType]>
+	<cfelse>
+		<cfreturn REQUEST.Config['FileTypesPath'][ARGUMENTS.resourceType]>
+	</cfif>
+</cffunction>
+
+<cffunction name="GetResourceTypeDirectory" returntype="String" output="false">
+	<cfargument name="resourceType" required="true">
+	<cfargument name="sCommand" required="true">
+
+	<cfif ARGUMENTS.sCommand eq "QuickUpload">
+		<cfif isDefined( "REQUEST.Config.QuickUploadAbsolutePath" )
+			and structkeyexists( REQUEST.Config.QuickUploadAbsolutePath, ARGUMENTS.resourceType )
+			and Len( REQUEST.Config.QuickUploadAbsolutePath[ARGUMENTS.resourceType] )>
+				<cfreturn REQUEST.Config.QuickUploadAbsolutePath[ARGUMENTS.resourceType]>
+		</cfif>
+
+		<cfreturn expandpath( REQUEST.Config.QuickUploadPath[ARGUMENTS.resourceType] )>
+	<cfelse>
+		<cfif isDefined( "REQUEST.Config.FileTypesAbsolutePath" )
+			and structkeyexists( REQUEST.Config.FileTypesAbsolutePath, ARGUMENTS.resourceType )
+			and Len( REQUEST.Config.FileTypesAbsolutePath[ARGUMENTS.resourceType] )>
+				<cfreturn REQUEST.Config.FileTypesAbsolutePath[ARGUMENTS.resourceType]>
+		</cfif>
+
+		<cfreturn expandpath( REQUEST.Config.FileTypesPath[ARGUMENTS.resourceType] )>
+	</cfif>
+</cffunction>
+
+<cffunction name="GetUrlFromPath" returntype="String" output="false">
+	<cfargument name="resourceType" required="true">
+	<cfargument name="folderPath" required="true">
+	<cfargument name="sCommand" required="true">
+
+	<cfreturn CombinePaths( GetResourceTypePath( ARGUMENTS.resourceType, ARGUMENTS.sCommand ), ARGUMENTS.folderPath )>
+</cffunction>
+
+<cffunction name="RemoveExtension" output="false" returntype="String">
+	<cfargument name="fileName" required="true">
+	<cfset var pos = find( ".", reverse ( ARGUMENTS.fileName ) )>
+
+	<cfreturn mid( ARGUMENTS.fileName, 1, Len( ARGUMENTS.fileName ) - pos ) >
+</cffunction>
+
+<cffunction name="GetExtension" output="false" returntype="String">
+	<cfargument name="fileName" required="true">
+	<cfset var pos = find( ".", reverse ( ARGUMENTS.fileName ) )>
+
+	<cfif not pos>
+		<cfreturn "">
+	</cfif>
+
+	<cfreturn mid( ARGUMENTS.fileName, pos, Len( ARGUMENTS.fileName ) - pos ) >
+</cffunction>
+
+<cffunction name="ServerMapFolder" returntype="String" output="false">
+	<cfargument name="resourceType" required="true">
+	<cfargument name="folderPath" required="true">
+	<cfargument name="sCommand" required="true">
+
+	<!--- Get the resource type directory. --->
+	<cfset var sResourceTypePath = GetResourceTypeDirectory( ARGUMENTS.resourceType, ARGUMENTS.sCommand ) >
+	<!--- Ensure that the directory exists. --->
+	<cfset var sErrorMsg = CreateServerFolder( sResourceTypePath ) >
+
+	<cfif sErrorMsg neq ''>
+		<cfset SendError( 1, 'Error creating folder "' & sResourceTypePath & '" (' & sErrorMsg & ')' )>
+	</cfif>
+
+	<!--- Return the resource type directory combined with the required path. --->
+	<cfreturn CombinePaths( sResourceTypePath , ARGUMENTS.folderPath )>
+</cffunction>
+
+<cffunction name="GetParentFolder" returntype="string" output="false">
+	<cfargument name="folderPath" required="true">
+
+	<cfreturn rereplace(ARGUMENTS.folderPath, "[/\\\\][^/\\\\]+[/\\\\]?$", "")>
+</cffunction>
+
+<cffunction name="CreateServerFolder" returntype="String" output="false">
+	<cfargument name="folderPath">
+
+	<!--- Ensure the folder path has no double-slashes, or mkdir may fail on certain platforms --->
+	<cfset folderPath = rereplace(ARGUMENTS.folderPath, "//+", "/", "all")>
+
+	<cfif directoryexists(ARGUMENTS.folderPath) or fileexists(ARGUMENTS.folderPath)>
+		<cfreturn "">
+	<cfelse>
+		<cftry>
+			<cfdirectory action="create" mode="0755" directory="#ARGUMENTS.folderPath#">
+		<cfcatch type="any">
+			<cfreturn CFCATCH.Message>
+		</cfcatch>
+		</cftry>
+	</cfif>
+
+	<cfreturn "">
+</cffunction>
+
+<cffunction name="IsAllowedExt" returntype="boolean" output="false">
+	<cfargument name="sExtension" required="true">
+	<cfargument name="resourceType" required="true">
+
+	<cfif isDefined( "REQUEST.Config.AllowedExtensions." & ARGUMENTS.resourceType )
+			and listLen( REQUEST.Config.AllowedExtensions[ARGUMENTS.resourceType] )
+			and not listFindNoCase( REQUEST.Config.AllowedExtensions[ARGUMENTS.resourceType], ARGUMENTS.sExtension )>
+			<cfreturn false>
+	</cfif>
+
+	<cfif isDefined( "REQUEST.Config.DeniedExtensions." & ARGUMENTS.resourceType )
+			and listLen( REQUEST.Config.DeniedExtensions[ARGUMENTS.resourceType] )
+			and listFindNoCase( REQUEST.Config.DeniedExtensions[ARGUMENTS.resourceType], ARGUMENTS.sExtension )>
+			<cfreturn false>
+	</cfif>
+
+	<cfreturn true>
+</cffunction>
+
+<cffunction name="IsAllowedType" returntype="boolean" output="false">
+	<cfargument name="resourceType">
+
+	<cfif not listFindNoCase( REQUEST.Config.ConfigAllowedTypes, ARGUMENTS.resourceType )>
+		<cfreturn false>
+	</cfif>
+
+	<cfreturn true>
+</cffunction>
+
+<cffunction name="IsAllowedCommand" returntype="boolean" output="true">
+	<cfargument name="sCommand" required="true" type="String">
+
+	<cfif not listFindNoCase( REQUEST.Config.ConfigAllowedCommands, ARGUMENTS.sCommand )>
+		<cfreturn false>
+	</cfif>
+
+	<cfreturn true>
+</cffunction>
+
+<cffunction name="GetCurrentFolder" returntype="String" output="false">
+	<cfset var sCurrentFolder = "/">
+
+	<cfif isDefined( "URL.CurrentFolder" )>
+		<cfset sCurrentFolder = URL.CurrentFolder>
+	</cfif>
+
+	<!--- Check the current folder syntax (must begin and start with a slash). --->
+	<cfif not refind( "/$", sCurrentFolder)>
+		<cfset sCurrentFolder = sCurrentFolder & "/">
+	</cfif>
+
+	<cfif not refind( "^/", sCurrentFolder )>
+		<cfset sCurrentFolder = "/" & sCurrentFolder>
+	</cfif>
+
+	<!--- Ensure the folder path has no double-slashes, or mkdir may fail on certain platforms --->
+	<cfset sCurrentFolder = rereplace( sCurrentFolder, "//+", "/", "all" )>
+
+	<cfif find( "..", sCurrentFolder)>
+		<cfset SendError( 102, "" )>
+	</cfif>
+
+	<cfreturn sCurrentFolder>
+</cffunction>
+
+<cffunction name="SanitizeFolderName" returntype="String" output="false">
+	<cfargument name="sNewFolderName" required="true">
+
+	<!--- Do a cleanup of the folder name to avoid possible problems --->
+	<!--- Remove . \ / | : ? * " < > --->
+	<cfset sNewFolderName = rereplace( sNewFolderName, '\.+|\\+|\/+|\|+|\:+|\?+|\*+|"+|<+|>+', "_", "all" )>
+
+	<cfreturn sNewFolderName>
+</cffunction>
+
+<cffunction name="BinaryFileRead" returntype="String" output="true">
+	<cfargument name="fileName" required="true" type="string">
+	<cfargument name="bytes" required="true" type="Numeric">
+
+	<cfscript>
+	var chunk = "";
+	var fileReaderClass = "";
+	var fileReader = "";
+	var file = "";
+	var done = false;
+	var counter = 0;
+	var byteArray = "";
+
+	if( not fileExists( ARGUMENTS.fileName ) )
+	{
+		return "" ;
+	}
+
+	if (REQUEST.CFVersion gte 8)
+	{
+		 file  = FileOpen( ARGUMENTS.fileName, "readbinary" ) ;
+		 byteArray = FileRead( file, 1024 ) ;
+		 chunk = toString( toBinary( toBase64( byteArray ) ) ) ;
+		 FileClose( file ) ;
+	}
+	else
+	{
+		fileReaderClass = createObject("java", "java.io.FileInputStream");
+		fileReader = fileReaderClass.init(fileName);
+
+		while(not done)
+		{
+			char = fileReader.read();
+			counter = counter + 1;
+			if ( char eq -1 or counter eq ARGUMENTS.bytes)
+			{
+				done = true;
+			}
+			else
+			{
+				chunk = chunk & chr(char) ;
+			}
+		}
+	}
+	</cfscript>
+
+	<cfreturn chunk>
+</cffunction>
+
+<cffunction name="SendUploadResults" returntype="String" output="true">
+	<cfargument name="errorNumber" required="true" type="Numeric">
+	<cfargument name="fileUrl" required="false" type="String" default="">
+	<cfargument name="fileName" required="false" type="String" default="">
+	<cfargument name="customMsg" required="false" type="String" default="">
+
+	<cfoutput>
+		<script type="text/javascript">
+			window.parent.OnUploadCompleted( #errorNumber#, "#JSStringFormat(fileUrl)#", "#JSStringFormat(fileName)#", "#JSStringFormat(customMsg)#" );
+		</script>
+	</cfoutput>
+	<cfabort>
+</cffunction>
+
+<cffunction name="SanitizeFileName" returntype="String" output="false">
+	<cfargument name="sNewFileName" required="true">
+
+	<cfif isDefined("REQUEST.Config.ForceSingleExtension") and REQUEST.Config.ForceSingleExtension>
+		<cfset sNewFileName = rereplace( sNewFileName, '\.(?![^.]*$)', "_", "all" )>
+	</cfif>
+
+	<!--- Do a cleanup of the file name to avoid possible problems --->
+	<!--- Remove \ / | : ? * " < > --->
+	<cfset sNewFileName = rereplace( sNewFileName, '\\[.]+|\\+|\/+|\|+|\:+|\?+|\*+|"+|<+|>+', "_", "all" )>
+
+	<cfreturn sNewFileName>
+</cffunction>
Index: /FCKeditor/trunk/editor/filemanager/connectors/cfm/cf_upload.cfm
===================================================================
--- /FCKeditor/trunk/editor/filemanager/connectors/cfm/cf_upload.cfm	(revision 738)
+++ /FCKeditor/trunk/editor/filemanager/connectors/cfm/cf_upload.cfm	(revision 738)
@@ -0,0 +1,68 @@
+﻿<cfsetting enablecfoutputonly="yes" showdebugoutput="no">
+<!---
+ * FCKeditor - The text editor for Internet - http://www.fckeditor.net
+ * Copyright (C) 2003-2007 Frederico Caldeira Knabben
+ *
+ * == BEGIN LICENSE ==
+ *
+ * Licensed under the terms of any of the following licenses at your
+ * choice:
+ *
+ *  - GNU General Public License Version 2 or later (the "GPL")
+ *    http://www.gnu.org/licenses/gpl.html
+ *
+ *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
+ *    http://www.gnu.org/licenses/lgpl.html
+ *
+ *  - Mozilla Public License Version 1.1 or later (the "MPL")
+ *    http://www.mozilla.org/MPL/MPL-1.1.html
+ *
+ * == END LICENSE ==
+ *
+ * File Browser connector for ColdFusion (MX 6.0 and above).
+ * (based on the original CF connector by Hendrik Kramer - hk@lwd.de)
+--->
+
+<cfparam name="url.type" default="File">
+<cfparam name="url.currentFolder" default="/">
+
+<!--- note: no serverPath url parameter - see config.cfm if you need to set the serverPath manually --->
+
+<cfinclude template="config.cfm">
+<cfinclude template="cf_util.cfm">
+<cfinclude template="cf_io.cfm">
+<cfinclude template="cf_commands.cfm">
+
+<cfset REQUEST.Config = Config>
+<cfif find( "/", getBaseTemplatePath() ) >
+	<cfset REQUEST.Fs = "/">
+<cfelse>
+	<cfset REQUEST.Fs = "\">
+</cfif>
+
+<cfif not Config.Enabled>
+	<cfset SendUploadResults( '1', '', '', 'This file uploader is disabled. Please check the "editor/filemanager/connectors/cfm/config.cfm" file' )>
+</cfif>
+
+<cfset sCommand = 'QuickUpload'>
+<cfset sType = "File">
+
+<cfif isDefined( "URL.Type" )>
+	<cfset sType = URL.Type>
+</cfif>
+
+<cfset sCurrentFolder = GetCurrentFolder()>
+
+<!--- Is enabled the upload? --->
+<cfif not IsAllowedCommand( sCommand )>
+	<cfset SendUploadResults( "1", "", "", "The """ & sCommand & """ command isn't allowed" )>
+</cfif>
+
+<!--- Check if it is an allowed type. --->
+<cfif not IsAllowedType( sType )>
+	<cfset SendUploadResults( "1", "", "", "Invalid type specified" ) >
+</cfif>
+
+<cfset FileUpload( sType, sCurrentFolder, sCommand )>
+
+
Index: /FCKeditor/trunk/editor/filemanager/connectors/cfm/cf_util.cfm
===================================================================
--- /FCKeditor/trunk/editor/filemanager/connectors/cfm/cf_util.cfm	(revision 738)
+++ /FCKeditor/trunk/editor/filemanager/connectors/cfm/cf_util.cfm	(revision 738)
@@ -0,0 +1,145 @@
+<cfsetting enablecfoutputonly="Yes">
+<!---
+ * FCKeditor - The text editor for Internet - http://www.fckeditor.net
+ * Copyright (C) 2003-2007 Frederico Caldeira Knabben
+ *
+ * == BEGIN LICENSE ==
+ *
+ * Licensed under the terms of any of the following licenses at your
+ * choice:
+ *
+ *  - GNU General Public License Version 2 or later (the "GPL")
+ *    http://www.gnu.org/licenses/gpl.html
+ *
+ *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
+ *    http://www.gnu.org/licenses/lgpl.html
+ *
+ *  - Mozilla Public License Version 1.1 or later (the "MPL")
+ *    http://www.mozilla.org/MPL/MPL-1.1.html
+ *
+ * == END LICENSE ==
+ *
+ * This file include generic functions used by the ColdFusion Connector (MX 6.0 and above).
+--->
+
+<cffunction name="RemoveFromStart" output="false" returntype="String">
+	<cfargument name="sourceString" type="String">
+	<cfargument name="charToRemove" type="String">
+
+	<cfif left(ARGUMENTS.sourceString, 1) eq ARGUMENTS.charToRemove>
+		<cfreturn mid( ARGUMENTS.sourceString, 2, len(ARGUMENTS.sourceString) -1 )>
+	</cfif>
+
+	<cfreturn ARGUMENTS.sourceString>
+</cffunction>
+
+<cffunction name="RemoveFromEnd" output="false" returntype="String">
+	<cfargument name="sourceString" type="String">
+	<cfargument name="charToRemove" type="String">
+
+	<cfif right(ARGUMENTS.sourceString, 1) eq ARGUMENTS.charToRemove>
+		<cfreturn mid( ARGUMENTS.sourceString, 1, len(ARGUMENTS.sourceString) -1 )>
+	</cfif>
+
+	<cfreturn ARGUMENTS.sourceString>
+</cffunction>
+
+<!---
+Check file content.
+Currently this function validates only image files.
+Returns false if file is invalid.
+detectionLevel:
+	0 = none
+	1 = check image size for images,
+	2 = use DetectHtml for images
+---->
+<cffunction name="IsFileValid" returntype="boolean" output="true">
+	<cfargument name="filePath" required="true" type="String">
+	<cfargument name="extension" required="true" type="String">
+	<cfargument name="detectionLevel" required="true" type="Numeric">
+
+	<cfset var imageCFC = "">
+	<cfset var imageInfo = "">
+
+	<cfif ARGUMENTS.detectionLevel lte 0>
+		<cfreturn true>
+	</cfif>
+
+	<cfif not ListFindNoCase("gif,jpeg,jpg,png,swf,psd,bmp,iff,tiff,tif,swc,jpc,jp2,jpx,jb2,xmb,wbmp", ARGUMENTS.extension)>
+		<cfreturn true>
+	</cfif>
+
+	<cfif ARGUMENTS.detectionLevel gte 1>
+		<cftry>
+			<cfif REQUEST.CFVersion gte 8>
+				<cfset objImage = ImageRead(ARGUMENTS.filePath) >
+				<cfset imageInfo = ImageInfo(objImage)>
+				<!--- <cfimage action="info" source="#ARGUMENTS.filePath#" structName="imageInfo" /> --->
+			<cfelse>
+				<cfset imageCFC = createObject("component", "image")>
+				<cfset imageInfo = imageCFC.getImageInfo("", ARGUMENTS.filePath)>
+			</cfif>
+
+			<cfif imageInfo.height lte 0 or imageInfo.width lte 0>
+				<cfreturn false>
+			</cfif>
+		<cfcatch type="any">
+			<cfreturn false>
+		</cfcatch>
+		</cftry>
+	</cfif>
+
+	<cfif ARGUMENTS.detectionLevel gte 2>
+		<cfif DetectHtml( ARGUMENTS.filePath )>
+			<cfreturn false>
+		</cfif>
+	</cfif>
+
+	<cfreturn true>
+</cffunction>
+
+<!---
+ Detect HTML in the first KB to prevent against potential security issue with
+ IE/Safari/Opera file type auto detection bug.
+ Returns true if file contain insecure HTML code at the beginning.
+--->
+<cffunction name="DetectHtml" output="false" returntype="boolean">
+	<cfargument name="filePath" required="true" type="String">
+
+	<cfset var tags = "<body,<head,<html,<img,<pre,<script,<table,<title">
+	<cfset var chunk = lcase( Trim( BinaryFileRead( ARGUMENTS.filePath, 1024 ) ) )>
+
+	<cfif not Len(chunk)>
+		<cfreturn false>
+	</cfif>
+
+	<cfif refind('<!doctype\W*x?html', chunk)>
+		<cfreturn true>
+	</cfif>
+
+	<cfloop index = "tag" list = "#tags#">
+     	<cfif find( tag, chunk )>
+			<cfreturn true>
+		</cfif>
+	</cfloop>
+
+	<!--- type = javascript --->
+	<cfif refind('type\s*=\s*[''"]?\s*(?:\w*/)?(?:ecma|java)', chunk)>
+		<cfreturn true>
+	</cfif> >
+
+	<!--- href = javascript --->
+	<!--- src = javascript --->
+	<!--- data = javascript --->
+	<cfif refind('(?:href|src|data)\s*=\s*[\''"]?\s*(?:ecma|java)script:', chunk)>
+		<cfreturn true>
+	</cfif>
+
+	<!--- url(javascript --->
+	<cfif refind('url\s*\(\s*[\''"]?\s*(?:ecma|java)script:', chunk)>
+		<cfreturn true>
+	</cfif>
+
+	<cfreturn false>
+</cffunction>
+
Index: /FCKeditor/trunk/editor/filemanager/connectors/cfm/config.cfm
===================================================================
--- /FCKeditor/trunk/editor/filemanager/connectors/cfm/config.cfm	(revision 737)
+++ /FCKeditor/trunk/editor/filemanager/connectors/cfm/config.cfm	(revision 738)
@@ -20,37 +20,113 @@
  * == END LICENSE ==
  *
- * Configuration file for the ColdFusion Connector.
+ * Configuration file for the ColdFusion Connector (all versions).
 --->
+
 <cfscript>
-	config = StructNew();
+	Config = StructNew() ;
 
 	// SECURITY: You must explicitly enable this "connector". (Set enabled to "true")
-	config.enabled = false;
+	Config.Enabled = true ;
 
 	// Path to uploaded files relative to the document root.
-	config.userFilesPath = "/userfiles/";
+	Config.UserFilesPath = "/userfiles/" ;
 
-	// Use this to force the server path if FCKeditor is not running directly off 
-	// the root of the application or the FCKeditor directory in the URL is a virtual directory 
+	// Use this to force the server path if FCKeditor is not running directly off
+	// the root of the application or the FCKeditor directory in the URL is a virtual directory
 	// or a symbolic link / junction
 	// Example: C:\inetpub\wwwroot\myDocs\
-	config.serverPath = ""; 
+	Config.ServerPath = "" ;
 
-	config.allowedExtensions = StructNew();
-	config.deniedExtensions = StructNew();
+	// Due to security issues with Apache modules, it is reccomended to leave the
+	// following setting enabled.
+	Config.ForceSingleExtension = true ;
 
-	config.allowedExtensions["File"] = "";
-	config.deniedExtensions["File"] = "html,htm,php,php2,php3,php4,php5,phtml,pwml,inc,asp,aspx,ascx,jsp,cfm,cfc,pl,bat,exe,com,dll,vbs,js,reg,cgi,htaccess,asis,sh,shtml,shtm,phtm";
+	// Perform additional checks for image files  - check whether uploaded images are valid image files
+	// 0 = turn off
+	// 1 = validate image size
+	// 2 = most secure option, validate images also against MIME Type Detection bug that
+	//     can lead to Cross Site Scripting attacks (when image contains HTML tags in the first 1KB, some browsers may render it as a HTML file).
+	//     Attention: it may produce false positives in some situations
+	Config.SecureImageUploads = 1;
 
-	config.allowedExtensions["Image"] = "png,gif,jpg,jpeg,bmp";
-	config.deniedExtensions["Image"] = "";
+	// What the user can do with this connector
+	Config.ConfigAllowedCommands 			= "QuickUpload,FileUpload,GetFolders,GetFoldersAndFiles,CreateFolder" ;
 
-	config.allowedExtensions["Flash"] = "swf,fla";
-	config.deniedExtensions["Flash"] = "";
+	//Allowed Resource Types
+	Config.ConfigAllowedTypes 				= "File,Image,Flash,Media" ;
 
-	config.allowedExtensions["Media"] = "swf,fla,jpg,gif,jpeg,png,avi,mpg,mpeg,mp3,mp4,m4a,wma,wmv,wav,mid,midi,rmi,rm,ram,rmvb,mov,qt";
-	config.deniedExtensions["Media"] = "";
+//	Configuration settings for each Resource Type
+//
+//	- AllowedExtensions: the possible extensions that can be allowed.
+//		If it is empty then any file type can be uploaded.
+//	- DeniedExtensions: The extensions that won't be allowed.
+//		If it is empty then no restrictions are done here.
+//
+//	For a file to be uploaded it has to fullfil both the AllowedExtensions
+//	and DeniedExtensions (that's it: not being denied) conditions.
+//
+//	- FileTypesPath: the virtual folder relative to the document root where
+//		these resources will be located.
+//		Attention: It must start and end with a slash: '/'
+//
+//	- FileTypesAbsolutePath: the physical path to the above folder. It must be
+//		an absolute path.
+//		If it's an empty string then it will be autocalculated.
+//		Usefull if you are using a virtual directory, symbolic link or alias.
+//		Examples: 'C:\\MySite\\userfiles\\' or '/root/mysite/userfiles/'.
+//		Attention: The above 'FileTypesPath' must point to the same directory.
+//		Attention: It must end with a slash: '/'
+//
+//
+//	 - QuickUploadPath: the virtual folder relative to the document root where
+//		these resources will be uploaded using the Upload tab in the resources
+//		dialogs.
+//		Attention: It must start and end with a slash: '/'
+//
+//	 - QuickUploadAbsolutePath: the physical path to the above folder. It must be
+//		an absolute path.
+//		If it's an empty string then it will be autocalculated.
+//		Usefull if you are using a virtual directory, symbolic link or alias.
+//		Examples: 'C:\\MySite\\userfiles\\' or '/root/mysite/userfiles/'.
+//		Attention: The above 'QuickUploadPath' must point to the same directory.
+//		Attention: It must end with a slash: '/'
+
+	Config.AllowedExtensions 				= StructNew() ;
+	Config.DeniedExtensions 				= StructNew() ;
+	Config.FileTypesPath 					= StructNew() ;
+	Config.FileTypesAbsolutePath 			= StructNew() ;
+	Config.QuickUploadPath 					= StructNew() ;
+	Config.QuickUploadAbsolutePath 			= StructNew() ;
+
+	Config.AllowedExtensions["File"]	 	= "" ;
+	Config.DeniedExtensions["File"] 		= "html,htm,php,php2,php3,php4,php5,phtml,pwml,inc,asp,aspx,ascx,jsp,cfm,cfc,pl,bat,exe,com,dll,vbs,js,reg,cgi,htaccess,asis,sh,shtml,shtm,phtm" ;
+	Config.FileTypesPath["File"] 			= Config.UserFilesPath & 'file/' ;
+	Config.FileTypesAbsolutePath["File"] 	= iif( Config.ServerPath eq "", de(""), de(Config.ServerPath & 'file/') ) ;
+	Config.QuickUploadPath["File"] 			= Config.FileTypesPath["File"] ;
+	Config.QuickUploadAbsolutePath["File"] 	= Config.FileTypesAbsolutePath["File"] ;
+
+	Config.AllowedExtensions["Image"] 		= "png,gif,jpg,jpeg,bmp" ;
+	Config.DeniedExtensions["Image"] 		= "" ;
+	Config.FileTypesPath["Image"] 			= Config.UserFilesPath & 'image/' ;
+	Config.FileTypesAbsolutePath["Image"] 	= iif( Config.ServerPath eq "", de(""), de(Config.ServerPath & 'image/') ) ;
+	Config.QuickUploadPath["Image"] 		= Config.FileTypesPath["Image"] ;
+	Config.QuickUploadAbsolutePath["Image"] = Config.FileTypesAbsolutePath["Image"] ;
+
+	Config.AllowedExtensions["Flash"] 		= "swf,fla" ;
+	Config.DeniedExtensions["Flash"] 		= "" ;
+	Config.FileTypesPath["Flash"] 			= Config.UserFilesPath & 'flash/' ;
+	Config.FileTypesAbsolutePath["Flash"] 	= iif( Config.ServerPath eq "", de(""), de(Config.ServerPath & 'flash/') ) ;
+	Config.QuickUploadPath["Flash"] 		= Config.FileTypesPath["Flash"] ;
+	Config.QuickUploadAbsolutePath["Flash"] = Config.FileTypesAbsolutePath["Flash"] ;
+
+	Config.AllowedExtensions["Media"] 		= "swf,fla,jpg,gif,jpeg,png,avi,mpg,mpeg,mp3,mp4,m4a,wma,wmv,wav,mid,midi,rmi,rm,ram,rmvb,mov,qt" ;
+	Config.DeniedExtensions["Media"] 		= "" ;
+	Config.FileTypesPath["Media"] 			= Config.UserFilesPath & 'media/' ;
+	Config.FileTypesAbsolutePath["Media"] 	= iif( Config.ServerPath eq "", de(""), de(Config.ServerPath & 'media/') ) ;
+	Config.QuickUploadPath["Media"] 		= Config.FileTypesPath["Media"] ;
+	Config.QuickUploadAbsolutePath["Media"] = Config.FileTypesAbsolutePath["Media"] ;
 </cfscript>
 
+<cftry>
 <!--- code to maintain backwards compatibility with previous version of cfm connector --->
 <cfif isDefined("application.userFilesPath")>
@@ -82,4 +158,8 @@
 
 </cfif>
+	<!--- catch potential "The requested scope application has not been enabled" exception --->
+	<cfcatch type="any">
+	</cfcatch>
+</cftry>
 
 <cfif isDefined("FCKeditor")>
Index: /FCKeditor/trunk/editor/filemanager/connectors/cfm/connector.cfm
===================================================================
--- /FCKeditor/trunk/editor/filemanager/connectors/cfm/connector.cfm	(revision 737)
+++ /FCKeditor/trunk/editor/filemanager/connectors/cfm/connector.cfm	(revision 738)
@@ -1,3 +1,3 @@
-﻿<cfsetting enablecfoutputonly="yes" showdebugoutput="no">
+<cfsetting enablecfoutputonly="Yes">
 <!---
  * FCKeditor - The text editor for Internet - http://www.fckeditor.net
@@ -20,260 +20,12 @@
  * == END LICENSE ==
  *
- * File Browser connector for ColdFusion.
- * (based on the original CF connector by Hendrik Kramer - hk@lwd.de)
- *
- * Note:
- * FCKeditor requires that the connector responds with UTF-8 encoded XML.
- * As ColdFusion 5 does not fully support UTF-8 encoding, we force ASCII
- * file and folder names in this connector to allow CF5 send a UTF-8
- * encoded response - code points under 127 in UTF-8 are stored using a
- * single byte, using the same encoding as ASCII, which is damn handy.
- * This is all grand for the English speakers, like meself, but I dunno
- * how others are gonna take to it. Well, the previous version of this
- * connector already did this with file names and nobody seemed to mind,
- * so fingers-crossed nobody will mind their folder names being munged too.
+ * File Browser connector for ColdFusion (all versions).
  *
 --->
 
-<cfparam name="url.command">
-<cfparam name="url.type">
-<cfparam name="url.currentFolder">
-<!--- note: no serverPath url parameter - see config.cfm if you need to set the serverPath manually --->
-
-<cfinclude template="config.cfm">
-<cfinclude template="commands.cfm">
-
-<cfscript>
-	userFilesPath = config.userFilesPath;
-
-	if ( userFilesPath eq "" ) { 
-		userFilesPath = "/userfiles/"; 
-	} 
-
-	// make sure the user files path is correctly formatted
-	userFilesPath = replace(userFilesPath, "\", "/", "ALL");
-	userFilesPath = replace(userFilesPath, '//', '/', 'ALL');
-	if ( right(userFilesPath,1) NEQ "/" ) {
-		userFilesPath = userFilesPath & "/";
-	}
-	if ( left(userFilesPath,1) NEQ "/" ) {
-		userFilesPath = "/" & userFilesPath;
-	}
-
-	// make sure the current folder is correctly formatted
-	url.currentFolder = replace(url.currentFolder, "\", "/", "ALL");
-	url.currentFolder = replace(url.currentFolder, '//', '/', 'ALL');
-	if ( right(url.currentFolder,1) neq "/" ) {
-		url.currentFolder = url.currentFolder & "/";
-	}
-	if ( left(url.currentFolder,1) neq "/" ) {
-		url.currentFolder = "/" & url.currentFolder;
-	}
-
-	if ( find("/",getBaseTemplatePath()) neq 0 ) {
-		fs = "/";
-	} else {
-		fs = "\";
-	}
-
-	// Get the base physical path to the web root for this application. The code to determine the path automatically assumes that
-	// the "FCKeditor" directory in the http request path is directly off the web root for the application and that it's not a
-	// virtual directory or a symbolic link / junction. Use the serverPath config setting to force a physical path if necessary.
-	if ( len(config.serverPath) ) {
-		serverPath = config.serverPath;
-
-		if ( right(serverPath,1) neq fs ) { 
-			serverPath = serverPath & fs; 
-		} 
-	} else {
-		serverPath = replaceNoCase(getBaseTemplatePath(),replace(cgi.script_name,"/",fs,"all"),"") & replace(userFilesPath,"/",fs,"all");
-	}
-
-	// map the user files path to a physical directory
-	userFilesServerPath = serverPath & url.type & replace(url.currentFolder,"/",fs,"all");
-
-	xmlContent = ""; // append to this string to build content
-</cfscript>
-
-<cfif not config.enabled>
-
-	<cfset xmlContent = "<Error number=""1"" text=""This connector is disabled. Please check the 'editor/filemanager/connectors/cfm/config.cfm' file"" />">
-
-<cfelseif find("..",url.currentFolder)>
-
-	<cfset xmlContent = "<Error number=""102"" />">
-
+<cfset REQUEST.CFVersion = Left( SERVER.COLDFUSION.PRODUCTVERSION, Find( ",", SERVER.COLDFUSION.PRODUCTVERSION ) - 1 )>
+<cfif REQUEST.CFVersion lte 5>
+	<cfinclude template="cf5_connector.cfm">
+<cfelse>
+	<cfinclude template="cf_connector.cfm">
 </cfif>
-
-<cfif not len(xmlContent)>
-
-<!--- create directories in physical path if they don't already exist --->
-<cfset currentPath = "">
-<cftry>
-	<cfloop list="#userFilesServerPath#" index="name" delimiters="/">
-
-		<cfif not directoryExists(currentPath & fs & name)>
-				<cfdirectory action="create" directory="#currentPath##fs##name#" mode="755">
-		</cfif>
-
-		<cfset currentPath = currentPath & fs & name>
-
-	</cfloop>
-
-	<!--- create sub-directory for file type if it doesn't already exist --->
-	<!---
-		<cfif not directoryExists(userFilesServerPath & url.type)>
-		<cfdirectory action="create" directory="#userFilesServerPath##url.type#" mode="755">
-	</cfif>
-	--->
-<cfcatch>
-
-	<!--- this should only occur as a result of a permissions problem --->
-	<cfset xmlContent = "<Error number=""103"" />">
-
-</cfcatch>
-</cftry>
-
-</cfif>
-
-<cfif not len(xmlContent)>
-
-	<!--- no errors thus far - run command --->
-
-	<!--- we need to know the physical path to the current folder for all commands --->
-	<cfset currentFolderPath = userFilesServerPath>
-
-	<cfswitch expression="#url.command#">
-
-
-		<cfcase value="FileUpload">
-
-			<cfset FileUpload(url.type, currentFolderPath)>
-
-		</cfcase>
-
-
-		<cfcase value="GetFolders">
-
-			<!--- Sort directories first, name ascending --->
-			<cfdirectory
-				action="list"
-				directory="#currentFolderPath#"
-				name="qDir"
-				sort="type,name">
-
-			<cfscript>
-				i=1;
-				folders = "";
-				while( i lte qDir.recordCount ) {
-					if( not compareNoCase( qDir.type[i], "FILE" ))
-						break;
-					if( not listFind(".,..", qDir.name[i]) )
-						folders = folders & '<Folder name="#HTMLEditFormat( qDir.name[i] )#" />';
-					i=i+1;
-				}
-
-				xmlContent = xmlContent & '<Folders>' & folders & '</Folders>';
-			</cfscript>
-
-		</cfcase>
-
-
-		<cfcase value="GetFoldersAndFiles">
-
-			<!--- Sort directories first, name ascending --->
-			<cfdirectory
-				action="list"
-				directory="#currentFolderPath#"
-				name="qDir"
-				sort="type,name">
-
-			<cfscript>
-				i=1;
-				folders = "";
-				files = "";
-				while( i lte qDir.recordCount ) {
-					if( not compareNoCase( qDir.type[i], "DIR" ) and not listFind(".,..", qDir.name[i]) ) {
-						folders = folders & '<Folder name="#HTMLEditFormat(qDir.name[i])#" />';
-					} else if( not compareNoCase( qDir.type[i], "FILE" ) ) {
-						fileSizeKB = round(qDir.size[i] / 1024);
-						files = files & '<File name="#HTMLEditFormat(qDir.name[i])#" size="#IIf( fileSizeKB GT 0, DE( fileSizeKB ), 1)#" />';
-					}
-					i=i+1;
-				}
-
-				xmlContent = xmlContent & '<Folders>' & folders & '</Folders>';
-				xmlContent = xmlContent & '<Files>' & files & '</Files>';
-			</cfscript>
-
-		</cfcase>
-
-
-		<cfcase value="CreateFolder">
-
-			<cfparam name="url.newFolderName" default="">
-
-			<cfscript>
-				newFolderName = url.newFolderName;
-				if( reFind("[^A-Za-z0-9_\-\.]", newFolderName) ) {
-					// Munge folder name same way as we do the filename
-					// This means folder names are always US-ASCII so we don't have to worry about CF5 and UTF-8
-					newFolderName = reReplace(newFolderName, "[^A-Za-z0-9\-\.]", "_", "all");
-					newFolderName = reReplace(newFolderName, "_{2,}", "_", "all");
-					newFolderName = reReplace(newFolderName, "([^_]+)_+$", "\1", "all");
-					newFolderName = reReplace(newFolderName, "$_([^_]+)$", "\1", "all");
-				}
-			</cfscript>
-
-			<cfif not len(newFolderName) or len(newFolderName) gt 255>
-				<cfset errorNumber = 102>
-			<cfelseif directoryExists(currentFolderPath & newFolderName)>
-				<cfset errorNumber = 101>
-			<cfelseif reFind("^\.\.",newFolderName)>
-				<cfset errorNumber = 103>
-			<cfelse>
-				<cfset errorNumber = 0>
-
-				<cftry>
-					<cfdirectory
-						action="create"
-						directory="#currentFolderPath##newFolderName#"
-						mode="755">
-					<cfcatch>
-						<!---
-						un-resolvable error numbers in ColdFusion:
-						* 102 : Invalid folder name.
-						* 103 : You have no permissions to create the folder.
-						--->
-						<cfset errorNumber = 110>
-					</cfcatch>
-				</cftry>
-			</cfif>
-
-			<cfset xmlContent = xmlContent & '<Error number="#errorNumber#" />'>
-
-		</cfcase>
-
-
-		<cfdefaultcase>
-
-			<cfthrow type="fckeditor.connector" message="Illegal command: #url.command#">
-
-		</cfdefaultcase>
-
-
-	</cfswitch>
-
-</cfif>
-
-<cfscript>
-	xmlHeader = '<?xml version="1.0" encoding="utf-8" ?><Connector command="#url.command#" resourceType="#url.type#">';
-	xmlHeader = xmlHeader & '<CurrentFolder path="#url.currentFolder#" url="#userFilesPath##url.type##url.currentFolder#" />';
-	xmlFooter = '</Connector>';
-</cfscript>
-
-<cfheader name="Expires" value="#GetHttpTimeString(Now())#">
-<cfheader name="Pragma" value="no-cache">
-<cfheader name="Cache-Control" value="no-cache, no-store, must-revalidate">
-<cfcontent reset="true" type="text/xml; charset=UTF-8">
-<cfoutput>#xmlHeader##xmlContent##xmlFooter#</cfoutput>	
Index: /FCKeditor/trunk/editor/filemanager/connectors/cfm/image.cfc
===================================================================
--- /FCKeditor/trunk/editor/filemanager/connectors/cfm/image.cfc	(revision 738)
+++ /FCKeditor/trunk/editor/filemanager/connectors/cfm/image.cfc	(revision 738)
@@ -0,0 +1,1325 @@
+<!---
+	image.cfc v2.19, written by Rick Root (rick@webworksllc.com)
+	Derivative of work originally done originally by James Dew.
+
+	Related Web Sites:
+	- http://www.opensourcecf.com/imagecfc (home page)
+	- http://www.cfopen.org/projects/imagecfc (project page)
+
+	LICENSE
+	-------
+	Copyright (c) 2007, Rick Root <rick@webworksllc.com>
+	All rights reserved.
+
+	Redistribution and use in source and binary forms, with or
+	without modification, are permitted provided that the
+	following conditions are met:
+
+	- Redistributions of source code must retain the above
+	  copyright notice, this list of conditions and the
+	  following disclaimer.
+	- Redistributions in binary form must reproduce the above
+	  copyright notice, this list of conditions and the
+	  following disclaimer in the documentation and/or other
+	  materials provided with the distribution.
+	- Neither the name of the Webworks, LLC. nor the names of
+	  its contributors may be used to endorse or promote products
+	  derived from this software without specific prior written
+	  permission.
+
+	THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+	CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+	MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+	DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+	CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+	SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+	BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+	LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+	HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+	OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+	SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+	============================================================
+	This is a derivative work.  Following is the original
+	Copyright notice.
+	============================================================
+
+	Copyright (c) 2004 James F. Dew <jdew@yggdrasil.ca>
+
+	Permission to use, copy, modify, and distribute this software for any
+	purpose with or without fee is hereby granted, provided that the above
+	copyright notice and this permission notice appear in all copies.
+
+	THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+	WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+	MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+	ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+	WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+	ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+	OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+--->
+<!---
+	SPECIAL NOTE FOR HEADLESS SYSTEMS
+	---------------------------------
+	If you get a "cannot connect to X11 server" when running certain
+	parts of this component under Bluedragon (Linux), you must
+	add "-Djava.awt.headless=true" to the java startup line in
+	<bluedragon>/bin/StartBluedragon.sh.  This isssue is discussed
+	in the Bluedragon Installation Guide section 3.8.1 for
+	Bluedragon 6.2.1.
+
+	Bluedragon may also report a ClassNotFound exception when trying
+	to instantiate the java.awt.image.BufferedImage class.  This is
+	most likely the same issue.
+
+	If you get "This graphics environment can be used only in the
+	software emulation mode" when calling certain parts of this
+	component under Coldfusion MX, you should refer to Technote
+	ID #18747:  http://www.macromedia.com/go/tn_18747
+--->
+
+<cfcomponent displayname="Image">
+
+<cfset variables.throwOnError = "Yes">
+<cfset variables.defaultJpegCompression = "90">
+<cfset variables.interpolation = "bicubic">
+<cfset variables.textAntiAliasing = "Yes">
+<cfset variables.tempDirectory = "#expandPath(".")#">
+
+<cfset variables.javanulls = "no">
+<cftry>
+	<cfset nullvalue = javacast("null","")>
+	<cfset variables.javanulls = "yes">
+	<cfcatch type="any">
+		<cfset variables.javanulls = "no">
+		<!--- javacast null not supported, so filters won't work --->
+	</cfcatch>
+</cftry>
+<!---
+<cfif javanulls>
+	<cfset variables.blurFilter = createObject("component","blurFilter")>
+	<cfset variables.sharpenFilter = createObject("component","sharpenFilter")>
+	<cfset variables.posterizeFilter = createObject("component","posterizeFilter")>
+</cfif>
+--->
+
+<cfset variables.Math = createobject("java", "java.lang.Math")>
+<cfset variables.arrObj = createobject("java", "java.lang.reflect.Array")>
+<cfset variables.floatClass = createobject("java", "java.lang.Float").TYPE>
+<cfset variables.intClass = createobject("java", "java.lang.Integer").TYPE>
+<cfset variables.shortClass = createobject("java", "java.lang.Short").TYPE>
+
+<cffunction name="getImageInfo" access="public" output="true" returntype="struct" hint="Rotate an image (+/-)90, (+/-)180, or (+/-)270 degrees.">
+	<cfargument name="objImage" required="yes" type="Any">
+	<cfargument name="inputFile" required="yes" type="string">
+
+	<cfset var retVal = StructNew()>
+	<cfset var loadImage = StructNew()>
+	<cfset var img = "">
+
+	<cfset retVal.errorCode = 0>
+	<cfset retVal.errorMessage = "">
+
+	<cfif inputFile neq "">
+		<cfset loadImage = readImage(inputFile, "NO")>
+		<cfif loadImage.errorCode is 0>
+			<cfset img = loadImage.img>
+		<cfelse>
+			<cfset retVal = throw(loadImage.errorMessage)>
+			<cfreturn retVal>
+		</cfif>
+		<cfset retVal.metaData = getImageMetadata(loadImage.inFile)>
+	<cfelse>
+		<cfset img = objImage>
+		<cfset retVal.metadata = getImageMetadata("")>
+	</cfif>
+	<cftry>
+		<cfset retVal.width = img.getWidth()>
+		<cfset retVal.height = img.getHeight()>
+		<cfset retVal.colorModel = img.getColorModel().toString()>
+		<cfset retVal.colorspace = img.getColorModel().getColorSpace().toString()>
+		<cfset retVal.objColorModel = img.getColorModel()>
+		<cfset retVal.objColorspace = img.getColorModel().getColorSpace()>
+		<cfset retVal.sampleModel = img.getSampleModel().toString()>
+		<cfset retVal.imageType = img.getType()>
+		<cfset retVal.misc = img.toString()>
+		<cfset retVal.canModify = true>
+		<cfreturn retVal>
+		<cfcatch type="any">
+			<cfset retVal = throw( "#cfcatch.message#: #cfcatch.detail#")>
+			<cfreturn retVal>
+		</cfcatch>
+	</cftry>
+</cffunction>
+
+<cffunction name="getImageMetadata" access="private" output="false" returntype="query">
+	<cfargument name="inFile" required="yes" type="Any"><!--- java.io.File --->
+
+	<cfset var retQry = queryNew("dirName,tagName,tagValue")>
+	<cfset var paths = arrayNew(1)>
+	<cfset var loader = "">
+	<cfset var JpegMetadatareader = "">
+	<cfset var myMetadata = "">
+	<cfset var directories = "">
+	<cfset var currentDirectory = "">
+	<cfset var tags = "">
+	<cfset var currentTag = "">
+	<cfset var tagName = "">
+
+	<cftry>
+	<cfscript>
+		paths = arrayNew(1);
+		paths[1] = expandPath("metadata-extractor-2.3.1.jar");
+		loader = createObject("component", "javaloader.JavaLoader").init(paths);
+
+		//at this stage we only have access to the class, but we don't have an instance
+		JpegMetadataReader = loader.create("com.drew.imaging.jpeg.JpegMetadataReader");
+
+		myMetaData = JpegMetadataReader.readMetadata(inFile);
+		directories = myMetaData.getDirectoryIterator();
+		while (directories.hasNext()) {
+			currentDirectory = directories.next();
+			tags = currentDirectory.getTagIterator();
+			while (tags.hasNext()) {
+				currentTag = tags.next();
+				if (currentTag.getTagName() DOES NOT CONTAIN "Unknown") { //leave out the junk data
+					queryAddRow(retQry);
+					querySetCell(retQry,"dirName",replace(currentTag.getDirectoryName(),' ','_','ALL'));
+					tagName = replace(currentTag.getTagName(),' ','','ALL');
+					tagName = replace(tagName,'/','','ALL');
+					querySetCell(retQry,"tagName",tagName);
+					querySetCell(retQry,"tagValue",currentTag.getDescription());
+				}
+			}
+		}
+		return retQry;
+		</cfscript>
+		<cfcatch type="any">
+			<cfreturn retQry />
+		</cfcatch>
+	</cftry>
+</cffunction>
+
+<cffunction name="flipHorizontal" access="public" output="true" returntype="struct" hint="Flip an image horizontally.">
+	<cfargument name="objImage" required="yes" type="Any">
+	<cfargument name="inputFile" required="yes" type="string">
+	<cfargument name="outputFile" required="yes" type="string">
+	<cfargument name="jpegCompression" required="no" type="numeric" default="#variables.defaultJpegCompression#">
+
+	<cfreturn flipflop(objImage, inputFile, outputFile, "horizontal", jpegCompression)>
+</cffunction>
+
+<cffunction name="flipVertical" access="public" output="true" returntype="struct" hint="Flop an image vertically.">
+	<cfargument name="objImage" required="yes" type="Any">
+	<cfargument name="inputFile" required="yes" type="string">
+	<cfargument name="outputFile" required="yes" type="string">
+	<cfargument name="jpegCompression" required="no" type="numeric" default="#variables.defaultJpegCompression#">
+
+	<cfreturn flipflop(objImage, inputFile, outputFile, "vertical", jpegCompression)>
+</cffunction>
+
+<cffunction name="scaleWidth" access="public" output="true" returntype="struct" hint="Scale an image to a specific width.">
+	<cfargument name="objImage" required="yes" type="Any">
+	<cfargument name="inputFile" required="yes" type="string">
+	<cfargument name="outputFile" required="yes" type="string">
+	<cfargument name="newWidth" required="yes" type="numeric">
+	<cfargument name="jpegCompression" required="no" type="numeric" default="#variables.defaultJpegCompression#">
+
+	<cfreturn resize(objImage, inputFile, outputFile, newWidth, 0, "false", "false", jpegCompression)>
+</cffunction>
+
+<cffunction name="scaleHeight" access="public" output="true" returntype="struct" hint="Scale an image to a specific height.">
+	<cfargument name="objImage" required="yes" type="Any">
+	<cfargument name="inputFile" required="yes" type="string">
+	<cfargument name="outputFile" required="yes" type="string">
+	<cfargument name="newHeight" required="yes" type="numeric">
+	<cfargument name="jpegCompression" required="no" type="numeric" default="#variables.defaultJpegCompression#">
+
+	<cfreturn resize(objImage, inputFile, outputFile, 0, newHeight, "false", "false", jpegCompression)>
+</cffunction>
+
+<cffunction name="resize" access="public" output="true" returntype="struct" hint="Resize an image to a specific width and height.">
+	<cfargument name="objImage" required="yes" type="Any">
+	<cfargument name="inputFile" required="yes" type="string">
+	<cfargument name="outputFile" required="yes" type="string">
+	<cfargument name="newWidth" required="yes" type="numeric">
+	<cfargument name="newHeight" required="yes" type="numeric">
+	<cfargument name="preserveAspect" required="no" type="boolean" default="FALSE">
+	<cfargument name="cropToExact" required="no" type="boolean" default="FALSE">
+	<cfargument name="jpegCompression" required="no" type="numeric" default="#variables.defaultJpegCompression#">
+
+	<cfset var retVal = StructNew()>
+	<cfset var loadImage = StructNew()>
+	<cfset var saveImage = StructNew()>
+	<cfset var at = "">
+	<cfset var op = "">
+	<cfset var w = "">
+	<cfset var h = "">
+	<cfset var scale = 1>
+	<cfset var scaleX = 1>
+	<cfset var scaleY = 1>
+	<cfset var resizedImage = "">
+	<cfset var rh = getRenderingHints()>
+	<cfset var specifiedWidth = arguments.newWidth>
+	<cfset var specifiedHeight = arguments.newHeight>
+	<cfset var imgInfo = "">
+	<cfset var img = "">
+	<cfset var cropImageResult = "">
+	<cfset var cropOffsetX = "">
+	<cfset var cropOffsetY = "">
+
+	<cfset retVal.errorCode = 0>
+	<cfset retVal.errorMessage = "">
+
+	<cfif inputFile neq "">
+		<cfset loadImage = readImage(inputFile, "NO")>
+		<cfif loadImage.errorCode is 0>
+			<cfset img = loadImage.img>
+		<cfelse>
+			<cfset retVal = throw(loadImage.errorMessage)>
+			<cfreturn retVal>
+		</cfif>
+	<cfelse>
+		<cfset img = objImage>
+	</cfif>
+	<cfif img.getType() eq 0>
+		<cfset img = convertImageObject(img,img.TYPE_3BYTE_BGR)>
+	</cfif>
+	<cfscript>
+		resizedImage = CreateObject("java", "java.awt.image.BufferedImage");
+		at = CreateObject("java", "java.awt.geom.AffineTransform");
+		op = CreateObject("java", "java.awt.image.AffineTransformOp");
+
+		w = img.getWidth();
+		h = img.getHeight();
+
+		if (preserveAspect and cropToExact and newHeight gt 0 and newWidth gt 0)
+		{
+			if (w / h gt newWidth / newHeight){
+				newWidth = 0;
+			} else if (w / h lt newWidth / newHeight){
+				newHeight = 0;
+		    }
+		} else if (preserveAspect and newHeight gt 0 and newWidth gt 0) {
+			if (w / h gt newWidth / newHeight){
+				newHeight = 0;
+			} else if (w / h lt newWidth / newHeight){
+				newWidth = 0;
+		    }
+		}
+		if (newWidth gt 0 and newHeight eq 0) {
+			scale = newWidth / w;
+			w = newWidth;
+			h = round(h*scale);
+		} else if (newHeight gt 0 and newWidth eq 0) {
+			scale = newHeight / h;
+			h = newHeight;
+			w = round(w*scale);
+		} else if (newHeight gt 0 and newWidth gt 0) {
+			w = newWidth;
+			h = newHeight;
+		} else {
+			retVal = throw( retVal.errorMessage);
+			return retVal;
+		}
+		resizedImage.init(javacast("int",w),javacast("int",h),img.getType());
+
+		w = w / img.getWidth();
+		h = h / img.getHeight();
+
+
+
+		op.init(at.getScaleInstance(javacast("double",w),javacast("double",h)), rh);
+		// resizedImage = op.createCompatibleDestImage(img, img.getColorModel());
+		op.filter(img, resizedImage);
+
+		imgInfo = getimageinfo(resizedImage, "");
+		if (imgInfo.errorCode gt 0)
+		{
+			return imgInfo;
+		}
+
+		cropOffsetX = max( Int( (imgInfo.width/2) - (newWidth/2) ), 0 );
+		cropOffsetY = max( Int( (imgInfo.height/2) - (newHeight/2) ), 0 );
+		// There is a chance that the image is exactly the correct
+		// width and height and don't need to be cropped
+		if
+			(
+			preserveAspect and cropToExact
+			and
+			(imgInfo.width IS NOT specifiedWidth OR imgInfo.height IS NOT specifiedHeight)
+			)
+		{
+			// Get the correct offset to get the center of the image
+			cropOffsetX = max( Int( (imgInfo.width/2) - (specifiedWidth/2) ), 0 );
+			cropOffsetY = max( Int( (imgInfo.height/2) - (specifiedHeight/2) ), 0 );
+
+			cropImageResult = crop( resizedImage, "", "", cropOffsetX, cropOffsetY, specifiedWidth, specifiedHeight );
+			if ( cropImageResult.errorCode GT 0)
+			{
+				return cropImageResult;
+			} else {
+				resizedImage = cropImageResult.img;
+			}
+		}
+		if (outputFile eq "")
+		{
+			retVal.img = resizedImage;
+			return retVal;
+		} else {
+			saveImage = writeImage(outputFile, resizedImage, jpegCompression);
+			if (saveImage.errorCode gt 0)
+			{
+				return saveImage;
+			} else {
+				return retVal;
+			}
+		}
+	</cfscript>
+</cffunction>
+
+<cffunction name="crop" access="public" output="true" returntype="struct" hint="Crop an image.">
+	<cfargument name="objImage" required="yes" type="Any">
+	<cfargument name="inputFile" required="yes" type="string">
+	<cfargument name="outputFile" required="yes" type="string">
+	<cfargument name="fromX" required="yes" type="numeric">
+	<cfargument name="fromY" required="yes" type="numeric">
+	<cfargument name="newWidth" required="yes" type="numeric">
+	<cfargument name="newHeight" required="yes" type="numeric">
+	<cfargument name="jpegCompression" required="no" type="numeric" default="#variables.defaultJpegCompression#">
+
+	<cfset var retVal = StructNew()>
+	<cfset var loadImage = StructNew()>
+	<cfset var saveImage = StructNew()>
+	<cfset var croppedImage = "">
+	<cfset var rh = getRenderingHints()>
+	<cfset var img = "">
+
+	<cfset retVal.errorCode = 0>
+	<cfset retVal.errorMessage = "">
+
+	<cfif inputFile neq "">
+		<cfset loadImage = readImage(inputFile, "NO")>
+		<cfif loadImage.errorCode is 0>
+			<cfset img = loadImage.img>
+		<cfelse>
+			<cfset retVal = throw(loadImage.errorMessage)>
+			<cfreturn retVal>
+		</cfif>
+	<cfelse>
+		<cfset img = objImage>
+	</cfif>
+	<cfif img.getType() eq 0>
+		<cfset img = convertImageObject(img,img.TYPE_3BYTE_BGR)>
+	</cfif>
+	<cfscript>
+		if (fromX + newWidth gt img.getWidth()
+			OR
+			fromY + newHeight gt img.getHeight()
+			)
+		{
+			retval = throw( "The cropped image dimensions go beyond the original image dimensions.");
+			return retVal;
+		}
+		croppedImage = img.getSubimage(javaCast("int", fromX), javaCast("int", fromY), javaCast("int", newWidth), javaCast("int", newHeight) );
+		if (outputFile eq "")
+		{
+			retVal.img = croppedImage;
+			return retVal;
+		} else {
+			saveImage = writeImage(outputFile, croppedImage, jpegCompression);
+			if (saveImage.errorCode gt 0)
+			{
+				return saveImage;
+			} else {
+				return retVal;
+			}
+		}
+	</cfscript>
+</cffunction>
+
+<cffunction name="rotate" access="public" output="true" returntype="struct" hint="Rotate an image (+/-)90, (+/-)180, or (+/-)270 degrees.">
+	<cfargument name="objImage" required="yes" type="Any">
+	<cfargument name="inputFile" required="yes" type="string">
+	<cfargument name="outputFile" required="yes" type="string">
+	<cfargument name="degrees" required="yes" type="numeric">
+	<cfargument name="jpegCompression" required="no" type="numeric" default="#variables.defaultJpegCompression#">
+
+	<cfset var retVal = StructNew()>
+	<cfset var img = "">
+	<cfset var loadImage = StructNew()>
+	<cfset var saveImage = StructNew()>
+	<cfset var at = "">
+	<cfset var op = "">
+	<cfset var w = 0>
+	<cfset var h = 0>
+	<cfset var iw = 0>
+	<cfset var ih = 0>
+	<cfset var x = 0>
+	<cfset var y = 0>
+	<cfset var rotatedImage = "">
+	<cfset var rh = getRenderingHints()>
+
+	<cfset retVal.errorCode = 0>
+	<cfset retVal.errorMessage = "">
+
+	<cfif inputFile neq "">
+		<cfset loadImage = readImage(inputFile, "NO")>
+		<cfif loadImage.errorCode is 0>
+			<cfset img = loadImage.img>
+		<cfelse>
+			<cfset retVal = throw(loadImage.errorMessage)>
+			<cfreturn retVal>
+		</cfif>
+	<cfelse>
+		<cfset img = objImage>
+	</cfif>
+	<cfif img.getType() eq 0>
+		<cfset img = convertImageObject(img,img.TYPE_3BYTE_BGR)>
+	</cfif>
+	<cfif ListFind("-270,-180,-90,90,180,270",degrees) is 0>
+		<cfset retVal = throw( "At this time, image.cfc only supports rotating images in 90 degree increments.")>
+		<cfreturn retVal>
+	</cfif>
+
+	<cfscript>
+		rotatedImage = CreateObject("java", "java.awt.image.BufferedImage");
+		at = CreateObject("java", "java.awt.geom.AffineTransform");
+		op = CreateObject("java", "java.awt.image.AffineTransformOp");
+
+		iw = img.getWidth(); h = iw;
+		ih = img.getHeight(); w = ih;
+
+		if(arguments.degrees eq 180) { w = iw; h = ih; }
+
+		x = (w/2)-(iw/2);
+		y = (h/2)-(ih/2);
+
+		rotatedImage.init(javacast("int",w),javacast("int",h),img.getType());
+
+		at.rotate(arguments.degrees * 0.0174532925,w/2,h/2);
+		at.translate(x,y);
+		op.init(at, rh);
+
+		op.filter(img, rotatedImage);
+
+		if (outputFile eq "")
+		{
+			retVal.img = rotatedImage;
+			return retVal;
+		} else {
+			saveImage = writeImage(outputFile, rotatedImage, jpegCompression);
+			if (saveImage.errorCode gt 0)
+			{
+				return saveImage;
+			} else {
+				return retVal;
+			}
+		}
+	</cfscript>
+</cffunction>
+
+<cffunction name="convert" access="public" output="true" returntype="struct" hint="Convert an image from one format to another.">
+	<cfargument name="objImage" required="yes" type="Any">
+	<cfargument name="inputFile" required="yes" type="string">
+	<cfargument name="outputFile" required="yes" type="string">
+	<cfargument name="jpegCompression" required="no" type="numeric" default="#variables.defaultJpegCompression#">
+
+	<cfset var retVal = StructNew()>
+	<cfset var loadImage = StructNew()>
+	<cfset var saveImage = StructNew()>
+	<cfset var img = "">
+
+	<cfset retVal.errorCode = 0>
+	<cfset retVal.errorMessage = "">
+
+	<cfif inputFile neq "">
+		<cfset loadImage = readImage(inputFile, "NO")>
+		<cfif loadImage.errorCode is 0>
+			<cfset img = loadImage.img>
+		<cfelse>
+			<cfset retVal = throw(loadImage.errorMessage)>
+			<cfreturn retVal>
+		</cfif>
+	<cfelse>
+		<cfset img = objImage>
+	</cfif>
+
+	<cfscript>
+		if (outputFile eq "")
+		{
+			retVal = throw( "The convert method requires a valid output filename.");
+			return retVal;
+		} else {
+			saveImage = writeImage(outputFile, img, jpegCompression);
+			if (saveImage.errorCode gt 0)
+			{
+				return saveImage;
+			} else {
+				return retVal;
+			}
+		}
+	</cfscript>
+</cffunction>
+
+<cffunction name="setOption" access="public" output="true" returnType="void" hint="Sets values for allowed CFC options.">
+	<cfargument name="key" type="string" required="yes">
+	<cfargument name="val" type="string" required="yes">
+
+	<cfset var validKeys = "interpolation,textantialiasing,throwonerror,defaultJpegCompression">
+	<cfset arguments.key = lcase(trim(arguments.key))>
+	<cfset arguments.val = lcase(trim(arguments.val))>
+	<cfif listFind(validKeys, arguments.key) gt 0>
+		<cfset variables[arguments.key] = arguments.val>
+	</cfif>
+</cffunction>
+
+<cffunction name="getOption" access="public" output="true" returnType="any" hint="Returns the current value for the specified CFC option.">
+	<cfargument name="key" type="string" required="yes">
+
+	<cfset var validKeys = "interpolation,textantialiasing,throwonerror,defaultJpegCompression">
+	<cfset arguments.key = lcase(trim(arguments.key))>
+	<cfif listFindNoCase(validKeys, arguments.key) gt 0>
+		<cfreturn variables[arguments.key]>
+	<cfelse>
+		<cfreturn "">
+	</cfif>
+</cffunction>
+
+<cffunction name="getRenderingHints" access="private" output="true" returnType="any" hint="Internal method controls various aspects of rendering quality.">
+	<cfset var rh = CreateObject("java","java.awt.RenderingHints")>
+	<cfset var initMap = CreateObject("java","java.util.HashMap")>
+	<cfset initMap.init()>
+	<cfset rh.init(initMap)>
+	<cfset rh.put(rh.KEY_ALPHA_INTERPOLATION, rh.VALUE_ALPHA_INTERPOLATION_QUALITY)> <!--- QUALITY, SPEED, DEFAULT --->
+	<cfset rh.put(rh.KEY_ANTIALIASING, rh.VALUE_ANTIALIAS_ON)> <!--- ON, OFF, DEFAULT --->
+	<cfset rh.put(rh.KEY_COLOR_RENDERING, rh.VALUE_COLOR_RENDER_QUALITY)>  <!--- QUALITY, SPEED, DEFAULT --->
+	<cfset rh.put(rh.KEY_DITHERING, rh.VALUE_DITHER_DEFAULT)> <!--- DISABLE, ENABLE, DEFAULT --->
+	<cfset rh.put(rh.KEY_RENDERING, rh.VALUE_RENDER_QUALITY)> <!--- QUALITY, SPEED, DEFAULT --->
+	<cfset rh.put(rh.KEY_FRACTIONALMETRICS, rh.VALUE_FRACTIONALMETRICS_DEFAULT)> <!--- DISABLE, ENABLE, DEFAULT --->
+	<cfset rh.put(rh.KEY_STROKE_CONTROL, rh.VALUE_STROKE_DEFAULT)>
+
+	<cfif variables.textAntiAliasing>
+		<cfset rh.put(rh.KEY_TEXT_ANTIALIASING, rh.VALUE_TEXT_ANTIALIAS_ON)>
+	<cfelse>
+		<cfset rh.put(rh.KEY_TEXT_ANTIALIASING, rh.VALUE_TEXT_ANTIALIAS_OFF)>
+	</cfif>
+
+	<cfif variables.interpolation eq "nearest_neighbor">
+		<cfset rh.put(rh.KEY_INTERPOLATION, rh.VALUE_INTERPOLATION_NEAREST_NEIGHBOR)>
+	<cfelseif variables.interpolation eq "bilinear">
+		<cfset rh.put(rh.KEY_INTERPOLATION, rh.VALUE_INTERPOLATION_BILINEAR)>
+	<cfelse>
+		<cfset rh.put(rh.KEY_INTERPOLATION, rh.VALUE_INTERPOLATION_BICUBIC)>
+	</cfif>
+
+	<cfreturn rh>
+</cffunction>
+
+<cffunction name="readImage" access="public" output="true" returntype="struct" hint="Reads an image from a local file.  Requires an absolute path.">
+	<cfargument name="source" required="yes" type="string">
+	<cfargument name="forModification" required="no" type="boolean" default="yes">
+
+	<cfif isURL(source)>
+		<cfreturn readImageFromURL(source, forModification)>
+	<cfelse>
+		<cfreturn readImageFromFile(source, forModification)>
+	</cfif>
+</cffunction>
+
+<cffunction name="readImageFromFile" access="private" output="true" returntype="struct" hint="Reads an image from a local file.  Requires an absolute path.">
+	<cfargument name="inputFile" required="yes" type="string">
+	<cfargument name="forModification" required="no" type="boolean" default="yes">
+
+	<cfset var retVal = StructNew()>
+	<cfset var img = "">
+	<cfset var inFile = "">
+	<cfset var filename = getFileFromPath(inputFile)>
+	<cfset var extension = lcase(listLast(inputFile,"."))>
+	<cfset var imageIO = CreateObject("java", "javax.imageio.ImageIO")>
+	<cfset var validExtensionsToRead = ArrayToList(imageIO.getReaderFormatNames())>
+
+	<cfset retVal.errorCode = 0>
+	<cfset retVal.errorMessage = "">
+
+	<cfif not fileExists(arguments.inputFile)>
+		<cfset retVal = throw("The specified file #Chr(34)##arguments.inputFile##Chr(34)# could not be found.")>
+		<cfreturn retVal>
+	<cfelseif listLen(filename,".") lt 2>
+		<cfset retVal = throw("Sorry, image files without extensions cannot be manipulated.")>
+		<cfreturn retVal>
+	<cfelseif listFindNoCase(validExtensionsToRead, extension) is 0>
+		<cfset retVal = throw("Java is unable to read #extension# files.")>
+		<cfreturn retVal>
+	<cfelseif NOT fileExists(arguments.inputFile)>
+		<cfset retVal = throw("The specified input file does not exist.")>
+		<cfreturn retVal>
+	<cfelse>
+		<cfset img = CreateObject("java", "java.awt.image.BufferedImage")>
+		<cfset inFile = CreateObject("java", "java.io.File")>
+		<cfset inFile.init(arguments.inputFile)>
+		<cfif NOT inFile.canRead()>
+			<cfset retVal = throw("Unable to open source file #Chr(34)##arguments.inputFile##Chr(34)#.")>
+			<cfreturn retVal>
+		<cfelse>
+			<cftry>
+				<cfset img = imageIO.read(inFile)>
+				<cfcatch type="any">
+					<cfset retval = throw("An error occurred attempting to read the specified image.  #cfcatch.message# - #cfcatch.detail#")>
+					<cfreturn retVal>
+				</cfcatch>
+			</cftry>
+			<cfset retVal.img = img>
+			<cfset retVal.inFile = inFile>
+			<cfreturn retVal>
+		</cfif>
+	</cfif>
+</cffunction>
+
+<cffunction name="readImageFromURL" access="private" output="true" returntype="struct" hint="Read an image from a URL.  Requires an absolute URL.">
+	<cfargument name="inputURL" required="yes" type="string">
+	<cfargument name="forModification" required="no" type="boolean" default="yes">
+
+	<cfset var retVal = StructNew()>
+	<cfset var img = CreateObject("java", "java.awt.image.BufferedImage")>
+	<cfset var inURL	= CreateObject("java", "java.net.URL")>
+	<cfset var imageIO = CreateObject("java", "javax.imageio.ImageIO")>
+
+	<cfset retVal.errorCode = 0>
+	<cfset retVal.errorMessage = "">
+
+
+	<cfset inURL.init(arguments.inputURL)>
+	<cftry>
+		<cfset img = imageIO.read(inURL)>
+		<cfcatch type="any">
+			<cfset retval = throw("An error occurred attempting to read the specified image.  #cfcatch.message# - #cfcatch.detail#")>
+			<cfreturn retVal>
+		</cfcatch>
+	</cftry>
+	<cfset retVal.img = img>
+	<cfreturn retVal>
+</cffunction>
+
+<cffunction name="writeImage" access="public" output="true" returntype="struct" hint="Write an image to disk.">
+	<cfargument name="outputFile" required="yes" type="string">
+	<cfargument name="img" required="yes" type="any">
+	<cfargument name="jpegCompression" required="no" type="numeric" default="#variables.defaultJpegCompression#">
+
+	<cfset var retVal = StructNew()>
+	<cfset var outFile = "">
+	<cfset var filename = getFileFromPath(outputFile)>
+	<cfset var extension = lcase(listLast(filename,"."))>
+	<cfset var imageIO = CreateObject("java", "javax.imageio.ImageIO")>
+	<cfset var validExtensionsToWrite = ArrayToList(imageIO.getWriterFormatNames())>
+	<!--- used for jpeg output method --->
+	<cfset var out = "">
+	<cfset var fos = "">
+	<cfset var JPEGCodec = "">
+	<cfset var encoder = "">
+	<cfset var param = "">
+	<cfset var quality = javacast("float", jpegCompression/100)>
+	<cfset var tempOutputFile = "#variables.tempDirectory#\#createUUID()#.#extension#">
+
+	<cfset retVal.errorCode = 0>
+	<cfset retVal.errorMessage = "">
+
+	<cfif listFindNoCase(validExtensionsToWrite, extension) eq 0>
+		<cfset throw("Java is unable to write #extension# files.  Valid formats include: #validExtensionsToWrite#")>
+	</cfif>
+
+	<cfif extension neq "jpg" and extension neq "jpeg">
+		<!---
+			Simple output method for non jpeg images
+		--->
+		<cfset outFile = CreateObject("java", "java.io.File")>
+		<cfset outFile.init(tempOutputFile)>
+		<cfset imageIO.write(img, extension, outFile)>
+	<cfelse>
+		<cfscript>
+			/*
+				JPEG output method handles compression
+			*/
+			out = createObject("java", "java.io.BufferedOutputStream");
+			fos = createObject("java", "java.io.FileOutputStream");
+			fos.init(tempOutputFile);
+			out.init(fos);
+			JPEGCodec = createObject("java", "com.sun.image.codec.jpeg.JPEGCodec");
+			encoder = JPEGCodec.createJPEGEncoder(out);
+		    param = encoder.getDefaultJPEGEncodeParam(img);
+		    param.setQuality(quality, false);
+		    encoder.setJPEGEncodeParam(param);
+		    encoder.encode(img);
+		    out.close();
+		</cfscript>
+	</cfif>
+	<!--- move file to its final destination --->
+	<cffile action="MOVE" source="#tempOutputFile#" destination="#arguments.outputFile#">
+	<cfreturn retVal>
+</cffunction>
+
+<cffunction name="flipflop" access="private" output="true" returntype="struct" hint="Internal method used for flipping and flopping images.">
+	<cfargument name="objImage" required="yes" type="Any">
+	<cfargument name="inputFile" required="yes" type="string">
+	<cfargument name="outputFile" required="yes" type="string">
+	<cfargument name="direction" required="yes" type="string"><!--- horizontal or vertical --->
+	<cfargument name="jpegCompression" required="no" type="numeric" default="#variables.defaultJpegCompression#">
+
+	<cfset var retVal = StructNew()>
+	<cfset var loadImage = StructNew()>
+	<cfset var saveImage = StructNew()>
+	<cfset var flippedImage = "">
+	<cfset var rh = getRenderingHints()>
+	<cfset var img = "">
+
+	<cfset retVal.errorCode = 0>
+	<cfset retVal.errorMessage = "">
+
+	<cfif inputFile neq "">
+		<cfset loadImage = readImage(inputFile, "NO")>
+		<cfif loadImage.errorCode is 0>
+			<cfset img = loadImage.img>
+		<cfelse>
+			<cfset retVal = throw(loadImage.errorMessage)>
+			<cfreturn retVal>
+		</cfif>
+	<cfelse>
+		<cfset img = objImage>
+	</cfif>
+	<cfif img.getType() eq 0>
+		<cfset img = convertImageObject(img,img.TYPE_3BYTE_BGR)>
+	</cfif>
+	<cfscript>
+		flippedImage = CreateObject("java", "java.awt.image.BufferedImage");
+		at = CreateObject("java", "java.awt.geom.AffineTransform");
+		op = CreateObject("java", "java.awt.image.AffineTransformOp");
+
+		flippedImage.init(img.getWidth(), img.getHeight(), img.getType());
+
+		if (direction eq "horizontal") {
+			at = at.getScaleInstance(-1, 1);
+			at.translate(-img.getWidth(), 0);
+		} else {
+			at = at.getScaleInstance(1,-1);
+			at.translate(0, -img.getHeight());
+		}
+		op.init(at, rh);
+		op.filter(img, flippedImage);
+
+		if (outputFile eq "")
+		{
+			retVal.img = flippedImage;
+			return retVal;
+		} else {
+			saveImage = writeImage(outputFile, flippedImage, jpegCompression);
+			if (saveImage.errorCode gt 0)
+			{
+				return saveImage;
+			} else {
+				return retVal;
+			}
+		}
+	</cfscript>
+</cffunction>
+
+
+
+<cffunction name="filterFastBlur" access="public" output="true" returntype="struct" hint="Internal method used for flipping and flopping images.">
+	<cfargument name="objImage" required="yes" type="Any">
+	<cfargument name="inputFile" required="yes" type="string">
+	<cfargument name="outputFile" required="yes" type="string">
+	<cfargument name="blurAmount" required="yes" type="numeric">
+	<cfargument name="iterations" required="yes" type="numeric">
+	<cfargument name="jpegCompression" required="no" type="numeric" default="#variables.defaultJpegCompression#">
+
+	<cfset var retVal = StructNew()>
+	<cfset var loadImage = StructNew()>
+	<cfset var saveImage = StructNew()>
+	<cfset var srcImage = "">
+	<cfset var destImage = "">
+	<cfset var rh = getRenderingHints()>
+
+	<cfset retVal.errorCode = 0>
+	<cfset retVal.errorMessage = "">
+
+	<cfif NOT variables.javanulls>
+		<cfset throw("Sorry, but the blur filter is not supported on this platform.")>
+	</cfif>
+	<cfif inputFile neq "">
+		<cfset loadImage = readImage(inputFile, "NO")>
+		<cfif loadImage.errorCode is 0>
+			<cfset srcImage = loadImage.img>
+		<cfelse>
+			<cfset retVal = throw(loadImage.errorMessage)>
+			<cfreturn retVal>
+		</cfif>
+	<cfelse>
+		<cfset srcImage = objImage>
+	</cfif>
+	<cfif srcImage.getType() eq 0>
+		<cfset srcImage = convertImageObject(srcImage,srcImage.TYPE_3BYTE_BGR)>
+	</cfif>
+
+	<cfscript>
+
+		// initialize the blur filter
+		variables.blurFilter.init(arguments.blurAmount);
+		// move the source image into the destination image
+		// so we can repeatedly blur it.
+		destImage = srcImage;
+
+		for (i=1; i lte iterations; i=i+1)
+		{
+			// do the blur i times
+			destImage = variables.blurFilter.filter(destImage);
+		}
+
+
+		if (outputFile eq "")
+		{
+			// return the image object
+			retVal.img = destImage;
+			return retVal;
+		} else {
+			// write the image object to the specified file.
+			saveImage = writeImage(outputFile, destImage, jpegCompression);
+			if (saveImage.errorCode gt 0)
+			{
+				return saveImage;
+			} else {
+				return retVal;
+			}
+		}
+	</cfscript>
+</cffunction>
+
+<cffunction name="filterSharpen" access="public" output="true" returntype="struct" hint="Internal method used for flipping and flopping images.">
+	<cfargument name="objImage" required="yes" type="Any">
+	<cfargument name="inputFile" required="yes" type="string">
+	<cfargument name="outputFile" required="yes" type="string">
+	<cfargument name="jpegCompression" required="no" type="numeric" default="#variables.defaultJpegCompression#">
+
+	<cfset var retVal = StructNew()>
+	<cfset var loadImage = StructNew()>
+	<cfset var saveImage = StructNew()>
+	<cfset var srcImage = "">
+	<cfset var destImage = "">
+	<cfset var rh = getRenderingHints()>
+
+	<cfset retVal.errorCode = 0>
+	<cfset retVal.errorMessage = "">
+
+	<cfif NOT variables.javanulls>
+		<cfset throw("Sorry, but the blur filter is not supported on this platform.")>
+	</cfif>
+
+	<cfif inputFile neq "">
+		<cfset loadImage = readImage(inputFile, "NO")>
+		<cfif loadImage.errorCode is 0>
+			<cfset srcImage = loadImage.img>
+		<cfelse>
+			<cfset retVal = throw(loadImage.errorMessage)>
+			<cfreturn retVal>
+		</cfif>
+	<cfelse>
+		<cfset srcImage = objImage>
+	</cfif>
+	<cfif srcImage.getType() eq 0>
+		<cfset srcImage = convertImageObject(srcImage,srcImage.TYPE_3BYTE_BGR)>
+	</cfif>
+
+	<cfscript>
+		// initialize the sharpen filter
+		variables.sharpenFilter.init();
+
+		destImage = variables.sharpenFilter.filter(srcImage);
+
+
+		if (outputFile eq "")
+		{
+			// return the image object
+			retVal.img = destImage;
+			return retVal;
+		} else {
+			// write the image object to the specified file.
+			saveImage = writeImage(outputFile, destImage, jpegCompression);
+			if (saveImage.errorCode gt 0)
+			{
+				return saveImage;
+			} else {
+				return retVal;
+			}
+		}
+	</cfscript>
+</cffunction>
+
+
+<cffunction name="filterPosterize" access="public" output="true" returntype="struct" hint="Internal method used for flipping and flopping images.">
+	<cfargument name="objImage" required="yes" type="Any">
+	<cfargument name="inputFile" required="yes" type="string">
+	<cfargument name="outputFile" required="yes" type="string">
+	<cfargument name="amount" required="yes" type="string">
+	<cfargument name="jpegCompression" required="no" type="numeric" default="#variables.defaultJpegCompression#">
+
+	<cfset var retVal = StructNew()>
+	<cfset var loadImage = StructNew()>
+	<cfset var saveImage = StructNew()>
+	<cfset var srcImage = "">
+	<cfset var destImage = "">
+	<cfset var rh = getRenderingHints()>
+
+	<cfset retVal.errorCode = 0>
+	<cfset retVal.errorMessage = "">
+
+	<cfif NOT variables.javanulls>
+		<cfset throw("Sorry, but the blur filter is not supported on this platform.")>
+	</cfif>
+
+	<cfif inputFile neq "">
+		<cfset loadImage = readImage(inputFile, "NO")>
+		<cfif loadImage.errorCode is 0>
+			<cfset srcImage = loadImage.img>
+		<cfelse>
+			<cfset retVal = throw(loadImage.errorMessage)>
+			<cfreturn retVal>
+		</cfif>
+	<cfelse>
+		<cfset srcImage = objImage>
+	</cfif>
+	<cfif srcImage.getType() eq 0>
+		<cfset srcImage = convertImageObject(srcImage,srcImage.TYPE_3BYTE_BGR)>
+	</cfif>
+	<cfif srcImage.getType() neq 5>
+		<cfset throw("ImageCFC cannot posterize this image type (#srcImage.getType()#)")>
+	</cfif>
+	<cfscript>
+		// initialize the posterize filter
+		variables.posterizeFilter.init(arguments.amount);
+
+		destImage = variables.posterizeFilter.filter(srcImage);
+
+
+		if (outputFile eq "")
+		{
+			// return the image object
+			retVal.img = destImage;
+			return retVal;
+		} else {
+			// write the image object to the specified file.
+			saveImage = writeImage(outputFile, destImage, jpegCompression);
+			if (saveImage.errorCode gt 0)
+			{
+				return saveImage;
+			} else {
+				return retVal;
+			}
+		}
+	</cfscript>
+</cffunction>
+
+
+<cffunction name="addText" access="public" output="true" returntype="struct" hint="Add text to an image.">
+	<cfargument name="objImage" required="yes" type="Any">
+	<cfargument name="inputFile" required="yes" type="string">
+	<cfargument name="outputFile" required="yes" type="string">
+	<cfargument name="x" required="yes" type="numeric">
+	<cfargument name="y" required="yes" type="numeric">
+	<cfargument name="fontDetails" required="yes" type="struct">
+	<cfargument name="content" required="yes" type="String">
+	<cfargument name="jpegCompression" required="no" type="numeric" default="#variables.defaultJpegCompression#">
+
+	<cfset var retVal = StructNew()>
+	<cfset var loadImage = StructNew()>
+	<cfset var img = "">
+	<cfset var saveImage = StructNew()>
+	<cfset var g2d = "">
+	<cfset var bgImage = "">
+	<cfset var fontImage = "">
+	<cfset var overlayImage = "">
+	<cfset var Color = "">
+	<cfset var font = "">
+	<cfset var font_stream = "">
+	<cfset var ac = "">
+	<cfset var rgb = "">
+
+	<cfset retVal.errorCode = 0>
+	<cfset retVal.errorMessage = "">
+
+	<cfparam name="arguments.fontDetails.size" default="12">
+	<cfparam name="arguments.fontDetails.color" default="black">
+	<cfparam name="arguments.fontDetails.fontFile" default="">
+	<cfparam name="arguments.fontDetails.fontName" default="serif">
+
+	<cfif arguments.fontDetails.fontFile neq "" and not fileExists(arguments.fontDetails.fontFile)>
+		<cfset retVal = throw("The specified font file #Chr(34)##arguments.inputFile##Chr(34)# could not be found on the server.")>
+		<cfreturn retVal>
+	</cfif>
+	<cftry>
+		<cfset rgb = getRGB(arguments.fontDetails.color)>
+		<cfcatch type="any">
+			<cfset retVal = throw("Invalid color #Chr(34)##arguments.fontDetails.color##Chr(34)#")>
+			<cfreturn retVal>
+		</cfcatch>
+	</cftry>
+	<cfif inputFile neq "">
+		<cfset loadImage = readImage(inputFile, "NO")>
+		<cfif loadImage.errorCode is 0>
+			<cfset img = loadImage.img>
+		<cfelse>
+			<cfset retVal = throw(loadImage.errorMessage)>
+			<cfreturn retVal>
+		</cfif>
+	<cfelse>
+		<cfset img = objImage>
+	</cfif>
+	<cfif img.getType() eq 0>
+		<cfset img = convertImageObject(img,img.TYPE_3BYTE_BGR)>
+	</cfif>
+	<cfscript>
+		// load objects
+		bgImage = CreateObject("java", "java.awt.image.BufferedImage");
+		fontImage = CreateObject("java", "java.awt.image.BufferedImage");
+		overlayImage = CreateObject("java", "java.awt.image.BufferedImage");
+		Color = CreateObject("java","java.awt.Color");
+		font = createObject("java","java.awt.Font");
+		font_stream = createObject("java","java.io.FileInputStream");
+		ac = CreateObject("Java", "java.awt.AlphaComposite");
+
+		// set up basic needs
+		fontColor = Color.init(javacast("int", rgb.red), javacast("int", rgb.green), javacast("int", rgb.blue));
+
+		if (fontDetails.fontFile neq "")
+		{
+			font_stream.init(arguments.fontDetails.fontFile);
+			font = font.createFont(font.TRUETYPE_FONT, font_stream);
+			font = font.deriveFont(javacast("float",arguments.fontDetails.size));
+		} else {
+			font.init(fontDetails.fontName, evaluate(fontDetails.style), fontDetails.size);
+		}
+		// get font metrics using a 1x1 bufferedImage
+		fontImage.init(1,1,img.getType());
+		g2 = fontImage.createGraphics();
+		g2.setRenderingHints(getRenderingHints());
+		fc = g2.getFontRenderContext();
+		bounds = font.getStringBounds(content,fc);
+
+		g2 = img.createGraphics();
+		g2.setRenderingHints(getRenderingHints());
+		g2.setFont(font);
+		g2.setColor(fontColor);
+		// in case you want to change the alpha
+		// g2.setComposite(ac.getInstance(ac.SRC_OVER, 0.50));
+
+		// the location (arguments.fontDetails.size+y) doesn't really work
+		// the way I want it to.
+		g2.drawString(content,javacast("int",x),javacast("int",arguments.fontDetails.size+y));
+
+		if (outputFile eq "")
+		{
+			retVal.img = img;
+			return retVal;
+		} else {
+			saveImage = writeImage(outputFile, img, jpegCompression);
+			if (saveImage.errorCode gt 0)
+			{
+				return saveImage;
+			} else {
+				return retVal;
+			}
+		}
+	</cfscript>
+</cffunction>
+
+<cffunction name="watermark" access="public" output="false">
+	<cfargument name="objImage1" required="yes" type="Any">
+	<cfargument name="objImage2" required="yes" type="Any">
+	<cfargument name="inputFile1" required="yes" type="string">
+	<cfargument name="inputFile2" required="yes" type="string">
+	<cfargument name="alpha" required="yes" type="numeric">
+	<cfargument name="placeAtX" required="yes" type="numeric">
+	<cfargument name="placeAtY" required="yes" type="numeric">
+	<cfargument name="outputFile" required="yes" type="string">
+	<cfargument name="jpegCompression" required="no" type="numeric" default="#variables.defaultJpegCompression#">
+
+	<cfset var retVal = StructNew()>
+	<cfset var loadImage = StructNew()>
+	<cfset var originalImage = "">
+	<cfset var wmImage = "">
+	<cfset var saveImage = StructNew()>
+	<cfset var ac = "">
+	<cfset var rh = getRenderingHints()>
+
+	<cfset retVal.errorCode = 0>
+	<cfset retVal.errorMessage = "">
+
+	<cfif inputFile1 neq "">
+		<cfset loadImage = readImage(inputFile1, "NO")>
+		<cfif loadImage.errorCode is 0>
+			<cfset originalImage = loadImage.img>
+		<cfelse>
+			<cfset retVal = throw(loadImage.errorMessage)>
+			<cfreturn retVal>
+		</cfif>
+	<cfelse>
+		<cfset originalImage = objImage1>
+	</cfif>
+	<cfif originalImage.getType() eq 0>
+		<cfset originalImage = convertImageObject(originalImage,originalImage.TYPE_3BYTE_BGR)>
+	</cfif>
+
+	<cfif inputFile2 neq "">
+		<cfset loadImage = readImage(inputFile2, "NO")>
+		<cfif loadImage.errorCode is 0>
+			<cfset wmImage = loadImage.img>
+		<cfelse>
+			<cfset retVal = throw(loadImage.errorMessage)>
+			<cfreturn retVal>
+		</cfif>
+	<cfelse>
+		<cfset wmImage = objImage2>
+	</cfif>
+	<cfif wmImage.getType() eq 0>
+		<cfset wmImage = convertImageObject(wmImage,wmImage.TYPE_3BYTE_BGR)>
+	</cfif>
+
+
+	<cfscript>
+		at = CreateObject("java", "java.awt.geom.AffineTransform");
+		op = CreateObject("java", "java.awt.image.AffineTransformOp");
+		ac = CreateObject("Java", "java.awt.AlphaComposite");
+		gfx = originalImage.getGraphics();
+		gfx.setComposite(ac.getInstance(ac.SRC_OVER, alpha));
+
+		at.init();
+		// op.init(at,op.TYPE_BILINEAR);
+		op.init(at, rh);
+
+		gfx.drawImage(wmImage, op, javaCast("int",arguments.placeAtX), javacast("int", arguments.placeAtY));
+
+		gfx.dispose();
+
+		if (outputFile eq "")
+		{
+			retVal.img = originalImage;
+			return retVal;
+		} else {
+			saveImage = writeImage(outputFile, originalImage, jpegCompression);
+			if (saveImage.errorCode gt 0)
+			{
+				return saveImage;
+			} else {
+				return retVal;
+			}
+		}
+	</cfscript>
+</cffunction>
+
+<cffunction name="isURL" access="private" output="false" returnType="boolean">
+	<cfargument name="stringToCheck" required="yes" type="string">
+	<cfif REFindNoCase("^(((https?:)\/\/))[-[:alnum:]\?%,\.\/&##!@:=\+~_]+[A-Za-z0-9\/]$",stringToCheck) NEQ 0>
+		<cfreturn true>
+	<cfelse>
+		<cfreturn false>
+	</cfif>
+</cffunction>
+
+<!--- function returns RGB values in a structure for hex or the 16
+	HTML named colors --->
+<cffunction name="getRGB" access="private" output="true" returnType="struct">
+	<cfargument name="color" type="string" required="yes">
+
+	<cfset var retVal = structNew()>
+	<cfset var cnt = 0>
+	<cfset var namedColors = "aqua,black,blue,fuchsia,gray,green,lime,maroon,navy,olive,purple,red,silver,teal,white,yellow">
+	<cfset var namedColorsHexValues = "00ffff,000000,0000ff,ff00ff,808080,008000,00ff00,800000,000080,808080,ff0000,c0c0c0,008080,ffffff,ffff00">
+
+	<cfset retVal.red = 0>
+	<cfset retVal.green = 0>
+	<cfset retVal.blue = 0>
+
+	<cfset arguments.color = trim(arguments.color)>
+	<cfif len(arguments.color) is 0>
+		<cfreturn retVal>
+	<cfelseif listFind(namedColors, arguments.color) gt 0>
+		<cfset arguments.color = listGetAt(namedColorsHexValues, listFind(namedColors, arguments.color))>
+	</cfif>
+	<cfif left(arguments.color,1) eq "##">
+		<cfset arguments.color = right(arguments.color,len(arguments.color)-1)>
+	</cfif>
+	<cfif len(arguments.color) neq 6>
+		<cfreturn retVal>
+	<cfelse>
+		<cftry>
+			<cfset retVal.red = InputBaseN(mid(arguments.color,1,2),16)>
+			<cfset retVal.green = InputBaseN(mid(arguments.color,3,2),16)>
+			<cfset retVal.blue = InputBaseN(mid(arguments.color,5,2),16)>
+			<cfcatch type="any">
+				<cfset retVal.red = 0>
+				<cfset retVal.green = 0>
+				<cfset retVal.blue = 0>
+				<cfreturn retVal>
+			</cfcatch>
+		</cftry>
+	</cfif>
+	<cfreturn retVal>
+</cffunction>
+
+<cffunction name="throw" access="private" output="false" returnType="struct">
+	<cfargument name="detail" type="string" required="yes">
+	<cfargument name="force" type="boolean" required="no" default="no">
+
+	<cfset var retVal = StructNew()>
+
+	<cfif variables.throwOnError or arguments.force>
+		<cfthrow detail="#arguments.detail#" message="#arguments.detail#">
+	<cfelse>
+		<cfset retVal.errorCode = 1>
+		<cfset retVal.errorMessage = arguments.detail>
+		<cfreturn retVal>
+	</cfif>
+</cffunction>
+
+<cffunction name="debugDump" access="private">
+	<cfdump var="#arguments#"><cfabort>
+</cffunction>
+
+<cffunction name="convertImageObject" access="private" output="false" returnType="any">
+	<cfargument name="bImage" type="Any" required="yes">
+	<cfargument name="type" type="numeric" required="yes">
+
+	<cfscript>
+	// convert the image to a specified BufferedImage type and return it
+
+	var width = bImage.getWidth();
+	var height = bImage.getHeight();
+	var newImage = createObject("java","java.awt.image.BufferedImage").init(javacast("int",width), javacast("int",height), javacast("int",type));
+	// int[] rgbArray = new int[width*height];
+	var rgbArray = variables.arrObj.newInstance(variables.intClass, javacast("int",width*height));
+
+	bImage.getRGB(
+		javacast("int",0),
+		javacast("int",0),
+		javacast("int",width),
+		javacast("int",height),
+		rgbArray,
+		javacast("int",0),
+		javacast("int",width)
+		);
+	newImage.setRGB(
+		javacast("int",0),
+		javacast("int",0),
+		javacast("int",width),
+		javacast("int",height),
+		rgbArray,
+		javacast("int",0),
+		javacast("int",width)
+		);
+	return newImage;
+	</cfscript>
+
+</cffunction>
+
+</cfcomponent>
+
Index: /FCKeditor/trunk/editor/filemanager/connectors/cfm/upload.cfm
===================================================================
--- /FCKeditor/trunk/editor/filemanager/connectors/cfm/upload.cfm	(revision 737)
+++ /FCKeditor/trunk/editor/filemanager/connectors/cfm/upload.cfm	(revision 738)
@@ -1,2 +1,3 @@
+<cfsetting enablecfoutputonly="Yes">
 <!---
  * FCKeditor - The text editor for Internet - http://www.fckeditor.net
@@ -19,71 +20,12 @@
  * == END LICENSE ==
  *
- * This is the "File Uploader" for ColdFusion.
- * Based on connector.cfm by Mark Woods (mark@thickpaddy.com)
+ * This is the "File Uploader" for ColdFusion (all versions).
+ *
 --->
 
-<cfparam name="url.type" default="File">
-<cfparam name="url.currentFolder" default="/">
-
-<cfinclude template="config.cfm">
-<cfinclude template="commands.cfm">
-
-<cfif NOT config.enabled>
-	<cfset SendUploadResults(1, '', '', 'This file uploader is disabled. Please check the "editor/filemanager/connectors/cfm/config.cfm" file')>
+<cfset REQUEST.CFVersion = Left( SERVER.COLDFUSION.PRODUCTVERSION, Find( ",", SERVER.COLDFUSION.PRODUCTVERSION ) - 1 )>
+<cfif REQUEST.CFVersion lte 5>
+	<cfinclude template="cf5_upload.cfm">
 <cfelse>
-	<cfscript>
-
-		userFilesPath = config.userFilesPath;
-
-		if ( userFilesPath eq "" ) { 
-			userFilesPath = "/userfiles/"; 
-		} 
-
-		// make sure the user files path is correctly formatted
-		userFilesPath = replace(userFilesPath, "\", "/", "ALL");
-		userFilesPath = replace(userFilesPath, '//', '/', 'ALL');
-		if ( right(userFilesPath,1) NEQ "/" ) {
-			userFilesPath = userFilesPath & "/";
-		}
-		if ( left(userFilesPath,1) NEQ "/" ) {
-			userFilesPath = "/" & userFilesPath;
-		}
-
-		// make sure the current folder is correctly formatted
-		url.currentFolder = replace(url.currentFolder, "\", "/", "ALL");
-		url.currentFolder = replace(url.currentFolder, '//', '/', 'ALL');
-		if ( right(url.currentFolder,1) neq "/" ) {
-			url.currentFolder = url.currentFolder & "/";
-		}
-		if ( left(url.currentFolder,1) neq "/" ) {
-			url.currentFolder = "/" & url.currentFolder;
-		}
-
-		if (find("/",getBaseTemplatePath())) {
-			fs = "/";
-		} else {
-			fs = "\";
-		}
-
-		// Get the base physical path to the web root for this application. The code to determine the path automatically assumes that
-		// the "FCKeditor" directory in the http request path is directly off the web root for the application and that it's not a
-		// virtual directory or a symbolic link / junction. Use the serverPath config setting to force a physical path if necessary.
-		if ( len(config.serverPath) ) {
-			serverPath = config.serverPath;
-
-			if ( right(serverPath,1) neq fs ) { 
-				serverPath = serverPath & fs; 
-			} 
-		} else {
-			serverPath = replaceNoCase(getBaseTemplatePath(),replace(cgi.script_name,"/",fs,"all"),"") & replace(userFilesPath,"/",fs,"all");
-		}
-
-		// map the user files path to a physical directory
-		userFilesServerPath = serverPath & url.type & replace(url.currentFolder,"/",fs,"all");
-
-	</cfscript>
-	<cfset currentFolderPath = userFilesServerPath>
-
-	<cfset FileUpload(url.type, currentFolderPath)>
-
+	<cfinclude template="cf_upload.cfm">
 </cfif>
