Index: _source/core/config.js
===================================================================
--- _source/core/config.js	(revision 3056)
+++ _source/core/config.js	(working copy)
@@ -147,7 +147,7 @@
 	 * config.plugins = 'basicstyles,button,htmldataprocessor,toolbar,wysiwygarea';
 	 */
 
-	plugins : 'basicstyles,button,elementspath,horizontalrule,htmldataprocessor,keystrokes,newpage,pagebreak,preview,removeformat,smiley,indent,link,list,sourcearea,table,specialchar,tab,toolbar,wysiwygarea',
+	plugins : 'basicstyles,button,elementspath,filebrowser,horizontalrule,htmldataprocessor,keystrokes,newpage,pagebreak,preview,removeformat,smiley,indent,link,list,sourcearea,table,specialchar,tab,toolbar,wysiwygarea',
 
 	/**
 	 * The theme to be used to build the UI.
Index: _source/core/loader.js
===================================================================
--- _source/core/loader.js	(revision 3056)
+++ _source/core/loader.js	(working copy)
@@ -44,7 +44,7 @@
 			'core/dom/text'			: [ 'core/dom/node', 'core/dom/domobject' ],
 			'core/dom/window'		: [ 'core/dom/domobject' ],
 			'core/dtd'				: [ 'core/tools' ],
-			'core/editor'			: [ 'core/command', 'core/config', 'core/editor_basic', 'core/focusmanager', 'core/lang', 'core/plugins', 'core/skins', 'core/themes', 'core/tools', 'core/ui' ],
+			'core/editor'			: [ 'core/ajax', 'core/command', 'core/config', 'core/editor_basic', 'core/focusmanager', 'core/lang', 'core/plugins', 'core/skins', 'core/themes', 'core/tools', 'core/ui' ],
 			'core/editor_basic'		: [ 'core/event' ],
 			'core/env'				: [],
 			'core/event'			: [],
Index: _source/lang/en.js
===================================================================
--- _source/lang/en.js	(revision 3056)
+++ _source/lang/en.js	(working copy)
@@ -365,6 +365,45 @@
 		vSpace	: 'VSpace'
 	},
 
+	filebrowser :
+	{
+		errors : 
+		{
+			10 : 'Invalid command.',
+			11 : 'The resource type was not specified in the request.',
+			12 : 'The requested resource type is not valid.',
+			102 : 'Invalid file or folder name.',
+			103 : 'It was not possible to complete the request due to authorization restrictions.',
+			104 : 'It was not possible to complete the request due to file system permission restrictions.',
+			105 : 'Invalid file extension.',
+			109 : 'Invalid request.',
+			110 : 'Unknown error.',
+			115 : 'A file or folder with the same name already exists.',
+			116 : 'Folder not found. Please refresh and try again.',
+			117 : 'File not found. Please refresh the files list and try again.',
+			201 : 'A file with the same name is already available. The uploaded file has been renamed to "%1"',
+			202 : 'Invalid file',
+			203 : 'Invalid file. The file size is too big.',
+			204 : 'The uploaded file is corrupt.',
+			205 : 'No temporary folder is available for upload in the server.',
+			206 : 'Upload cancelled for security reasons. The file contains HTML like data.',
+			500 : 'The file browser is disabled for security reasons. Please contact your system administrator and check the CKFinder configuration file.',
+			501 : 'The thumbnails support is disabled.'
+		},
+		errorUnknown : 'It was not possible to complete the request. (Error %1)',
+		fileNotSelected : 'Please select a file from your computer',
+		fileInvalidChar : 'The file name cannot contain any of the following characters: \n\\ / : * ? " < > |',
+		folderCreate : 'Create Folder',
+		folderCreateTip : 'Create folder in working directory',
+		folderEmpty : 'The folder name cannot be empty',
+		folderInvalidChar : 'The folder name cannot contain any of the following characters: \n\\ / : * ? " < > |',
+		folderNew : 'Please type the new folder name: ',
+		resourceType : 'Resource Type',
+		title : 'File Browser',
+		uploadProgressLbl : '(Upload in progress, please wait...)',
+		uploadTip : 'Upload a new file in this folder',
+	},
+
 	smiley :
 	{
 		toolbar	: 'Smiley',
Index: _source/plugins/dialog/plugin.js
===================================================================
--- _source/plugins/dialog/plugin.js	(revision 3056)
+++ _source/plugins/dialog/plugin.js	(working copy)
@@ -709,6 +709,17 @@
 		},
 
 		/**
+		 * Gets the name of the dialog.
+		 * @returns {String} The name of this dialog.
+		 * @example
+		 * var dialogName = dialogObj.getName();
+		 */
+		getName : function()
+		{
+			return this._.name;
+		},
+
+		/**
 		 * Gets a dialog UI element object from a dialog page.
 		 * @param {String} pageId id of dialog page.
 		 * @param {String} elementId id of UI element.
@@ -1986,6 +1997,24 @@
 		 */
 		selectParentTab : function()
 		{
+			tabId = this.getParentTab();
+
+			this._.dialog.selectPage( tabId );
+			return this;
+		},
+
+		/**
+		 * Gets the name of the parent tab of this element.
+		 * @returns {String} The name of selected tab.
+		 * @example
+		 * focus : function()
+		 * {
+		 * 		this.getParentTab();
+		 * 		// do something else.
+		 * }
+		 */
+		getParentTab : function()
+		{
 			var element = this.getInputElement(),
 				cursor = element,
 				tabId;
@@ -1994,8 +2023,7 @@
 
 			tabId = cursor.getAttribute( 'name' );
 
-			this._.dialog.selectPage( tabId );
-			return this;
+			return tabId;
 		},
 
 		/**
Index: _source/plugins/dialogui/plugin.js
===================================================================
--- _source/plugins/dialogui/plugin.js	(revision 3056)
+++ _source/plugins/dialogui/plugin.js	(working copy)
@@ -656,12 +656,16 @@
 					this.validate = elementDefinition.validate;
 
 				var myDefinition = CKEDITOR.tools.extend( {}, elementDefinition );
+				var onClick = myDefinition.onClick; 
 				myDefinition.className = ( myDefinition.className ? myDefinition.className + ' ' : '' ) + 'cke_dialog_ui_button';
 				myDefinition.onClick = function( evt )
 				{
 					var target = elementDefinition[ 'for' ];		// [ pageId, elementId ]
-					dialog.getContentElement( target[0], target[1] ).submit();
-					this.disable();
+					if ( !onClick || onClick.call( this, evt ) !== false )
+					{
+						dialog.getContentElement( target[0], target[1] ).submit();
+						this.disable();
+					}
 				};
 
 				dialog.on( 'load', function()
@@ -1158,12 +1162,34 @@
 				},
 
 				/**
+				 * Sets the action to given value.
+				 * @param {String} value The new action.
+				 * @returns {CKEDITOR.ui.dialog.file} This object.
+				 * @example
+				 */
+				setAction : function( action )
+				{
+					this.getInputElement().getParent().$.action = action;
+					return this;
+				},
+
+				/**
+				 * Get the action assigned to the form.
+				 * @returns {String} The value of the action.
+				 * @example
+				 */
+				getAction : function( action )
+				{
+					return this.getInputElement().getParent().$.action;
+				},
+
+				/**
 				 * Redraws the file input and resets the file path in the file input.
 				 * The redraw logic is necessary because non-IE browsers tend to clear
 				 * the &lt;iframe&gt; containing the file input after closing the dialog.
 				 * @example
 				 */
-				reset : function()
+				reset : function( action )
 				{
 					var frameElement = CKEDITOR.document.getById( this._.frameId ),
 						frameDocument = frameElement.$.contentWindow.document,
@@ -1172,7 +1198,7 @@
 					frameDocument.open();
 					frameDocument.write( [ '<html><head><title></title></head><body style="margin: 0; overflow: hidden; background: transparent;">',
 							'<form enctype="multipart/form-data" method="POST" action="',
-							CKEDITOR.tools.htmlEncode( elementDefinition.action ),
+							CKEDITOR.tools.htmlEncode( action || elementDefinition.action ),
 							'">',
 							'<input type="file" name="',
 							CKEDITOR.tools.htmlEncode( elementDefinition.id || 'cke_upload' ),
Index: _source/plugins/filebrowser/_dev/test.html
===================================================================
--- _source/plugins/filebrowser/_dev/test.html	(revision 0)
+++ _source/plugins/filebrowser/_dev/test.html	(revision 0)
@@ -0,0 +1,204 @@
+﻿<!--
+/*
+ * Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.html or http://ckeditor.com/license
+ */
+-->
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+	<title>CKEditor File Manager - Connector Tests</title>
+	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+	<script type="text/javascript">
+
+function BuildBaseUrl( command )
+{
+	var sUrl =
+		document.getElementById('cmbConnector').value +
+		'?command=' + command ;
+
+	if ( command != 'Init' )
+	{
+		sUrl +=
+			'&type=' + document.getElementById('cmbType').value +
+			'&currentFolder=' + encodeURIComponent( document.getElementById('txtFolder').value ) ;
+	}
+
+	return sUrl ;
+}
+
+function SetFrameUrl( url )
+{
+	if ( document.all )
+		eRunningFrame.document.location = url ;
+	else
+		document.getElementById('eRunningFrame').src = url ;
+
+	document.getElementById('eUrl').value = url ;
+}
+
+function CallUrlField()
+{
+	SetFrameUrl( document.getElementById('eUrl').value ) ;
+	return false ;
+}
+
+function Init()
+{
+	SetFrameUrl( BuildBaseUrl( 'Init' ) ) ;
+	return false ;
+}
+
+function GetFolders()
+{
+	SetFrameUrl( BuildBaseUrl( 'GetFolders' ) ) ;
+	return false ;
+}
+
+function GetFoldersAndFiles()
+{
+	SetFrameUrl( BuildBaseUrl( 'GetFoldersAndFiles' ) ) ;
+	return false ;
+}
+
+function OnUploadCompleted( errorNumber, fileUrl, fileName )
+{
+	// QuickUpload uses 3 parameters and the order is different than the FileUpload
+	if ( !fileName )
+		fileName = fileUrl ;
+
+	switch ( errorNumber )
+	{
+		case 0 :
+			alert( 'File uploaded with no errors' ) ;
+			break ;
+		case 201 :
+			alert( 'A file with the same name is already available. The uploaded file has been renamed to "' + fileName + '"' ) ;
+			break ;
+		case 202 :
+			alert( 'Invalid file' ) ;
+			break ;
+		case 500 :
+			alert( 'The connector is disabled' ) ;
+			break ;
+		default :
+			alert( 'Error on file upload. Error number: ' + errorNumber ) ;
+			break ;
+	}
+}
+
+this.frames.frmUpload = this ;
+
+function SetCreateFolderAction()
+{
+	var sUrl = BuildBaseUrl( 'CreateFolder' ) ;
+	document.getElementById('eUrl').value = sUrl ;
+	document.getElementById('frmCreateFolder').action = sUrl ;    
+}
+
+function SetAction()
+{
+	var sUrl = BuildBaseUrl( 'FileUpload' ) ;
+	document.getElementById('eUrl').value = sUrl ;
+	document.getElementById('frmUpload').action = sUrl ;
+}
+
+function SetQuickAction()
+{
+	var sUrl = BuildBaseUrl( 'QuickUpload' ) ;
+	document.getElementById('eUrl').value = sUrl ;
+	document.getElementById('frmQuickUpload').action = sUrl ;
+}
+	</script>
+</head>
+<body>
+	<table cellspacing="0" cellpadding="0" width="100%" border="0" style="height: 100%">
+		<tr>
+			<td>
+				<table cellspacing="0" cellpadding="0" border="0">
+					<tr>
+						<td>
+							Connector:<br />
+							<select id="cmbConnector" name="cmbConnector">
+								<option value="../core/connector/asp/connector.asp">ASP</option>
+								<option value="../core/connector/aspx/connector.aspx">ASP.NET</option>
+								<option value="../core/connector/cfm/connector.cfm">CFM</option>
+								<option value="../core/connector/php/connector.php" selected="selected">PHP</option>
+							</select>
+						</td>
+						<td>
+							&nbsp;&nbsp;&nbsp;</td>
+						<td>
+							Current Folder<br />
+							<input id="txtFolder" type="text" value="/" name="txtFolder" /></td>
+						<td>
+							&nbsp;&nbsp;&nbsp;</td>
+						<td>
+							Resource Type<br />
+							<select id="cmbType" name="cmbType">
+								<option value="Files" selected="selected">File</option>
+								<option value="Images">Image</option>
+								<option value="Flash">Flash</option>
+								<option value="Invalid">Invalid Type (for testing)</option>
+							</select>
+						</td>
+					</tr>
+				</table>
+				<br />
+				<table cellspacing="0" cellpadding="0" border="0">
+					<tr>
+						<td valign="top">
+							<a href="#" onclick="Init();">Init</a>
+						</td>
+						<td>&nbsp;&nbsp;&nbsp;</td>
+						<td valign="top">
+							<a href="#" onclick="GetFolders();">Get Folders</a>
+						</td>
+						<td>&nbsp;&nbsp;&nbsp;</td>
+						<td valign="top">
+							<a href="#" onclick="GetFoldersAndFiles();">Get Folders And Files</a>
+						</td>
+						<td>&nbsp;&nbsp;&nbsp;</td>
+						<td valign="top">
+							<form id="frmCreateFolder" action="" target="eRunningFrame" method="post" enctype="multipart/form-data">
+								Create Folder
+								<input id="txtFolderName" type="text" name="newFolderName" />
+								<input type="submit" value="Create" onclick="SetCreateFolderAction();" />
+							</form>
+						</td>
+						<td>&nbsp;&nbsp;&nbsp;</td>
+						<td valign="top">
+							<form id="frmUpload" action="" target="eRunningFrame" method="post" enctype="multipart/form-data">
+								Upload
+								<input id="txtFileUpload" type="file" name="NewFile" />
+								<input type="submit" value="Upload" onclick="SetAction();" />
+							</form>
+
+							<form id="frmQuickUpload" action="" target="eRunningFrame" method="post" enctype="multipart/form-data">
+								Quick
+								<input id="txtQuickUpload" type="file" name="NewFile" />
+								<input type="submit" value="Upload" onclick="SetQuickAction();" />
+							</form>
+						</td>
+					</tr>
+				</table>
+				<table width="100%">
+					<tr>
+						<td style="white-space: nowrap">
+							URL:&nbsp;</td>
+						<td style="width: 100%">
+							<input id="eUrl" style="width: 100%" /></td>
+						<td>
+							<input id="xBtnUrl" type="button" value="Call URL" onclick="CallUrlField();" /></td>
+					</tr>
+				</table>
+			</td>
+		</tr>
+		<tr>
+			<td valign="top" style="height: 100%">
+				<iframe id="eRunningFrame" name="eRunningFrame" width="100%" height="100%" src="javascript:''"></iframe>
+			</td>
+		</tr>
+	</table>
+</body>
+</html>
Index: _source/plugins/filebrowser/config.php
===================================================================
--- _source/plugins/filebrowser/config.php	(revision 0)
+++ _source/plugins/filebrowser/config.php	(revision 0)
@@ -0,0 +1,121 @@
+<?php
+/*
+Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+/**
+ * This function must check the user session to be sure that he/she is
+ * authorized to upload and access files in the File Browser.
+ *
+ * @return boolean
+ */
+function CheckAuthentication()
+{
+    // WARNING : DO NOT simply return "true". By doing so, you are allowing
+    // "anyone" to upload and list the files in your server. You must implement
+    // some kind of session validation here. Even something very simple as...
+    //
+    // return isset($_SESSION['IsAuthorized']) && $_SESSION['IsAuthorized'];
+    //
+    // ... where $_SESSION['IsAuthorized'] is set to "true" as soon as the
+    // user logs in your system.
+
+    // %REMOVE_START%
+    // Attention: In the development version (SVN) the PHP connector is enabled by default.
+    return true;
+    // %REMOVE_END%
+    return false;
+}
+
+// To make it easy to configure CKEditor file manager, the $baseUrl and $baseDir can be used.
+// Those are helper variables used later in this config file.
+
+// $baseUrl : the base path used to build the final URL for the resources handled
+// in CKEditor. If empty, the default value (/userfiles/) is used.
+//
+// Examples:
+//  $baseUrl = 'http://example.com/userfiles/';
+//  $baseUrl = '/userfiles/';
+//
+// ATTENTION: The trailing slash is required.
+$baseUrl = '/userfiles/';
+
+// $baseDir : the path to the local directory (in the server) which points to the
+// above $baseUrl URL. This is the path used by CKEditor to handle the files in
+// the server. Full write permissions must be granted to this directory.
+//
+// Examples:
+// You may point it to a directory directly:
+//
+//  $baseDir = '/home/login/public_html/userfiles/';
+//  $baseDir = 'C:/SiteDir/userfiles/';
+//
+// Or you may let CKEditor discover the path, based on $baseUrl:
+//
+//  $baseDir = resolveUrl($baseUrl);
+//
+// ATTENTION: The trailing slash is required.
+$baseDir = resolveUrl($baseUrl);
+$baseDir = 'D:/xampp/htdocs/userfiles/'; //%REMOVE_LINE%
+
+// ResourceType : defines the "resource types" handled in CKEditor. A resource
+// type is nothing more than a way to group files under different paths, each one
+// having different configuration settings.
+$config['ResourceType'][] = Array(
+    'name' => 'Files', // Single quotes not allowed
+    'url' => $baseUrl . 'files',
+    'directory' => $baseDir . 'files',
+    'allowedExtensions' => '7z,aiff,asf,avi,bmp,csv,doc,fla,flv,gif,gz,gzip,jpeg,jpg,mid,mov,mp3,mp4,mpc,mpeg,mpg,ods,odt,pdf,png,ppt,pxd,qt,ram,rar,rm,rmi,rmvb,rtf,sdc,sitd,swf,sxc,sxw,tar,tgz,tif,tiff,txt,vsd,wav,wma,wmv,xls,zip',
+    'deniedExtensions' => ''
+);
+
+$config['ResourceType'][] = Array(
+    'name' => 'Images',
+    'url' => $baseUrl . 'images',
+    'directory' => $baseDir . 'images',
+    'allowedExtensions' => 'bmp,gif,jpeg,jpg,png',
+    'deniedExtensions' => ''
+);
+
+$config['ResourceType'][] = Array(
+    'name' => 'Flash',
+    'url' => $baseUrl . 'flash',
+    'directory' => $baseDir . 'flash',
+    'allowedExtensions' => 'swf,flv',
+    'deniedExtensions' => ''
+);
+
+// Due to security issues with Apache modules, it is recommended to leave the
+// following setting enabled.
+$config['ForceSingleExtension'] = true ;
+
+// Perform additional checks for image files.
+// If set to true, validate image size (using getimagesize).
+$config['SecureImageUploads'] = true;
+
+// For security, HTML is allowed in the first Kb of data for files having the
+// following extensions only.
+$config['HtmlExtensions'] = array("html", "htm", "xml", "xsd", "txt", "js") ;
+
+// After file is uploaded, sometimes it is required to change its permissions
+// so that it was possible to access it at the later time.
+// If possible, it is recommended to set more restrictive permissions, like 0755.
+// Set to 0 to disable this feature.
+// Note: not needed on Windows-based servers.
+$config['ChmodFiles'] = 0777 ;
+
+// See comments above.
+// Used when creating folders that does not exist.
+$config['ChmodFolders'] = 0755 ;
+
+// If you have iconv enabled (visit http://php.net/iconv for more information),
+// you can use this directive to specify the encoding of file names in your
+// operating system. Acceptable values can be found at:
+//  http://www.gnu.org/software/libiconv/
+//
+// Examples:
+//  $config['FilesystemEncoding'] = 'CP1250';
+//  $config['FilesystemEncoding'] = 'ISO-8859-2';
+$config['FilesystemEncoding'] = 'UTF-8';
+$config['FilesystemEncoding'] = 'CP1250'; //%REMOVE_LINE%
\ No newline at end of file
Index: _source/plugins/filebrowser/core/connector/php/connector.php
===================================================================
--- _source/plugins/filebrowser/core/connector/php/connector.php	(revision 0)
+++ _source/plugins/filebrowser/core/connector/php/connector.php	(revision 0)
@@ -0,0 +1,59 @@
+<?php
+/*
+* Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+* For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+/**
+ * define required constants
+ */
+require_once "./constants.php";
+
+/**
+ * we need this class in each call
+ */
+require_once CKEDITOR_CONNECTOR_LIB_DIR . "/CommandHandler/CommandHandlerBase.php";
+/**
+ * singleton factory
+ */
+require_once CKEDITOR_CONNECTOR_LIB_DIR . "/Core/Factory.php";
+/**
+ * utils class
+ */
+require_once CKEDITOR_CONNECTOR_LIB_DIR . "/Utils/Misc.php";
+
+/**
+ * Simple function required by config.php - discover the server side path
+ * to the directory relative to the "$baseUrl" attribute
+ *
+ * @package CKEditor
+ * @subpackage Connector
+ * @param string $baseUrl
+ * @return string
+ */
+function resolveUrl($baseUrl) {
+    $fileSystem =& CKEditor_Connector_Core_Factory::getInstance("Utils_FileSystem");
+    return $fileSystem->getDocumentRootPath() . $baseUrl;
+}
+
+$utilsSecurity =& CKEditor_Connector_Core_Factory::getInstance("Utils_Security");
+$utilsSecurity->getRidOfMagicQuotes();
+
+/**
+ * $config must be initialised
+ */
+$config = array();
+/**
+ * read config file
+ */
+require_once CKEDITOR_CONNECTOR_CONFIG_FILE_PATH;
+
+CKEditor_Connector_Core_Factory::initFactory();
+$connector =& CKEditor_Connector_Core_Factory::getInstance("Core_Connector");
+
+if (isset($_GET['command'])) {
+    $connector->executeCommand($_GET['command']);
+}
+else {
+    $connector->handleInvalidCommand();
+}
Index: _source/plugins/filebrowser/core/connector/php/constants.php
===================================================================
--- _source/plugins/filebrowser/core/connector/php/constants.php	(revision 0)
+++ _source/plugins/filebrowser/core/connector/php/constants.php	(revision 0)
@@ -0,0 +1,51 @@
+<?php
+/*
+* Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+* For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+/**
+ * No errors
+ */
+define('CKEDITOR_CONNECTOR_ERROR_NONE',0);
+define('CKEDITOR_CONNECTOR_ERROR_CUSTOM_ERROR',1);
+define('CKEDITOR_CONNECTOR_ERROR_INVALID_COMMAND',10);
+define('CKEDITOR_CONNECTOR_ERROR_TYPE_NOT_SPECIFIED',11);
+define('CKEDITOR_CONNECTOR_ERROR_INVALID_TYPE',12);
+define('CKEDITOR_CONNECTOR_ERROR_INVALID_NAME',102);
+define('CKEDITOR_CONNECTOR_ERROR_UNAUTHORIZED',103);
+define('CKEDITOR_CONNECTOR_ERROR_ACCESS_DENIED',104);
+define('CKEDITOR_CONNECTOR_ERROR_INVALID_EXTENSION',105);
+define('CKEDITOR_CONNECTOR_ERROR_INVALID_REQUEST',109);
+define('CKEDITOR_CONNECTOR_ERROR_UNKNOWN',110);
+define('CKEDITOR_CONNECTOR_ERROR_ALREADY_EXIST',115);
+define('CKEDITOR_CONNECTOR_ERROR_FOLDER_NOT_FOUND',116);
+define('CKEDITOR_CONNECTOR_ERROR_FILE_NOT_FOUND',117);
+define('CKEDITOR_CONNECTOR_ERROR_UPLOADED_FILE_RENAMED',201);
+define('CKEDITOR_CONNECTOR_ERROR_UPLOADED_INVALID',202);
+define('CKEDITOR_CONNECTOR_ERROR_UPLOADED_TOO_BIG',203);
+define('CKEDITOR_CONNECTOR_ERROR_UPLOADED_CORRUPT',204);
+define('CKEDITOR_CONNECTOR_ERROR_UPLOADED_NO_TMP_DIR',205);
+define('CKEDITOR_CONNECTOR_ERROR_UPLOADED_WRONG_HTML_FILE',206);
+define('CKEDITOR_CONNECTOR_ERROR_CONNECTOR_DISABLED',500);
+
+define('CKEDITOR_CONNECTOR_DEFAULT_USER_FILES_PATH', "/userfiles/");
+define('CKEDITOR_CONNECTOR_CONFIG_FILE_PATH', "./../../../config.php");
+
+if (version_compare(phpversion(), '6', '>=')) {
+    define('CKEDITOR_CONNECTOR_PHP_MODE', 6);
+}
+else if (version_compare(phpversion(), '5', '>=')) {
+    define('CKEDITOR_CONNECTOR_PHP_MODE', 5);
+}
+else {
+    define('CKEDITOR_CONNECTOR_PHP_MODE', 4);
+}
+
+if (CKEDITOR_CONNECTOR_PHP_MODE == 4) {
+    define('CKEDITOR_CONNECTOR_LIB_DIR', "./php4");
+} else {
+    define('CKEDITOR_CONNECTOR_LIB_DIR', "./php5");
+}
+
+define('CKEDITOR_REGEX_IMAGES_EXT', '/\.(jpg|gif|png|bmp|jpeg)$/i');
Index: _source/plugins/filebrowser/core/connector/php/php4/CommandHandler/CommandHandlerBase.php
===================================================================
--- _source/plugins/filebrowser/core/connector/php/php4/CommandHandler/CommandHandlerBase.php	(revision 0)
+++ _source/plugins/filebrowser/core/connector/php/php4/CommandHandler/CommandHandlerBase.php	(revision 0)
@@ -0,0 +1,110 @@
+<?php
+/*
+* Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+* For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+/**
+ * @package CKEditor
+ * @subpackage CommandHandlers
+ */
+
+/**
+ * Base commands handler
+ *
+ * @package CKEditor
+ * @subpackage CommandHandlers
+ * @abstract
+ */
+class CKEditor_Connector_CommandHandler_CommandHandlerBase
+{
+    /**
+     * CKEditor_Connector_Core_Connector object
+     *
+     * @access protected
+     * @var CKEditor_Connector_Core_Connector
+     */
+    var $_connector;
+    /**
+     * CKEditor_Connector_Core_FolderHandler object
+     *
+     * @access protected
+     * @var CKEditor_Connector_Core_FolderHandler
+     */
+    var $_currentFolder;
+    /**
+     * Error handler object
+     *
+     * @access protected
+     * @var CKEditor_Connector_ErrorHandler_Base|CKEditor_Connector_ErrorHandler_FileUpload|CKEditor_Connector_ErrorHandler_Http
+     */
+    var $_errorHandler;
+
+    function CKEditor_Connector_CommandHandler_CommandHandlerBase()
+    {
+        $this->_currentFolder =& CKEditor_Connector_Core_Factory::getInstance("Core_FolderHandler");
+        $this->_connector =& CKEditor_Connector_Core_Factory::getInstance("Core_Connector");
+        $this->_errorHandler =& $this->_connector->getErrorHandler();
+    }
+
+    /**
+     * Get Folder Handler
+     *
+     * @access public
+     * @return CKEditor_Connector_Core_FolderHandler
+     */
+    function getFolderHandler()
+    {
+        if (is_null($this->_currentFolder)) {
+            $this->_currentFolder =& CKEditor_Connector_Core_Factory::getInstance("Core_FolderHandler");
+        }
+
+        return $this->_currentFolder;
+    }
+
+    /**
+     * Check whether Connector is enabled
+     * @access protected
+     *
+     */
+    function checkConnector()
+    {
+        $_config =& CKEditor_Connector_Core_Factory::getInstance("Core_Config");
+        if (!$_config->getIsEnabled()) {
+            $this->_errorHandler->throwError(CKEDITOR_CONNECTOR_ERROR_CONNECTOR_DISABLED);
+        }
+    }
+
+    /**
+     * Check request
+     * @access protected
+     *
+     */
+    function checkRequest()
+    {
+        if (preg_match(",(/\.)|[[:cntrl:]]|(//)|(\\\\)|([\:\*\?\"\<\>\|]),", $this->_currentFolder->getClientPath())) {
+            $this->_errorHandler->throwError(CKEDITOR_CONNECTOR_ERROR_INVALID_NAME);
+        }
+
+        $_resourceTypeConfig = $this->_currentFolder->getResourceTypeConfig();
+
+        if (is_null($_resourceTypeConfig)) {
+            $this->_errorHandler->throwError(CKEDITOR_CONNECTOR_ERROR_INVALID_TYPE);
+        }
+
+        $_clientPath = $this->_currentFolder->getClientPath();
+
+        if (!is_dir($this->_currentFolder->getServerPath())) {
+            if ($_clientPath == "/") {
+                if (!CKEditor_Connector_Utils_FileSystem::createDirectoryRecursively($this->_currentFolder->getServerPath())) {
+                    /**
+                     * @todo handle error
+                     */
+                }
+            }
+            else {
+                $this->_errorHandler->throwError(CKEDITOR_CONNECTOR_ERROR_FOLDER_NOT_FOUND);
+            }
+        }
+    }
+}
\ No newline at end of file
Index: _source/plugins/filebrowser/core/connector/php/php4/CommandHandler/CreateFolder.php
===================================================================
--- _source/plugins/filebrowser/core/connector/php/php4/CommandHandler/CreateFolder.php	(revision 0)
+++ _source/plugins/filebrowser/core/connector/php/php4/CommandHandler/CreateFolder.php	(revision 0)
@@ -0,0 +1,78 @@
+<?php
+/*
+* Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+* For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+/**
+ * @package CKEditor
+ * @subpackage CommandHandlers
+ */
+
+/**
+ * Include base XML command handler
+ */
+require_once CKEDITOR_CONNECTOR_LIB_DIR . "/CommandHandler/XmlCommandHandlerBase.php";
+
+/**
+ * Handle CreateFolder command
+ *
+ * @package CKEditor
+ * @subpackage CommandHandlers
+ */
+class CKEditor_Connector_CommandHandler_CreateFolder extends CKEditor_Connector_CommandHandler_XmlCommandHandlerBase
+{
+    /**
+     * Command name
+     *
+     * @access private
+     * @var string
+     */
+    var $command = "CreateFolder";
+
+    /**
+     * handle request and build XML
+     * @access protected
+     *
+     */
+    function buildXml()
+    {
+        $_config =& CKEditor_Connector_Core_Factory::getInstance("Core_Config");
+
+        $_resourceTypeConfig = $this->_currentFolder->getResourceTypeConfig();
+        $sNewFolderName = isset($_POST["newFolderName"]) ? $_POST["newFolderName"] : "";
+        $sNewFolderName = CKEditor_Connector_Utils_FileSystem::convertToFilesystemEncoding($sNewFolderName);
+
+        if (!CKEditor_Connector_Utils_FileSystem::checkFileName($sNewFolderName)) {
+            $this->_errorHandler->throwError(CKEDITOR_CONNECTOR_ERROR_INVALID_NAME);
+        }
+
+        $sServerDir = CKEditor_Connector_Utils_FileSystem::combinePaths($this->_currentFolder->getServerPath(), $sNewFolderName);
+        if (!is_writeable($this->_currentFolder->getServerPath())) {
+            $this->_errorHandler->throwError(CKEDITOR_CONNECTOR_ERROR_ACCESS_DENIED);
+        }
+
+        $bCreated = false;
+
+        if (file_exists($sServerDir)) {
+            $this->_errorHandler->throwError(CKEDITOR_CONNECTOR_ERROR_ALREADY_EXIST);
+        }
+
+        if ($perms = $_config->getChmodFolders()) {
+            $oldUmask = umask(0);
+            $bCreated = @mkdir($sServerDir, $perms);
+            umask($oldUmask);
+        }
+        else {
+            $bCreated = @mkdir($sServerDir);
+        }
+
+        if (!$bCreated) {
+            $this->_errorHandler->throwError(CKEDITOR_CONNECTOR_ERROR_ACCESS_DENIED);
+        } else {
+            $oNewFolderNode = new CKEditor_Connector_Utils_XmlNode("NewFolder");
+            $this->_connectorNode->addChild($oNewFolderNode);
+            $oNewFolderNode->addAttribute("name", CKEditor_Connector_Utils_FileSystem::convertToConnectorEncoding($sNewFolderName));
+        }
+    }
+}
\ No newline at end of file
Index: _source/plugins/filebrowser/core/connector/php/php4/CommandHandler/FileUpload.php
===================================================================
--- _source/plugins/filebrowser/core/connector/php/php4/CommandHandler/FileUpload.php	(revision 0)
+++ _source/plugins/filebrowser/core/connector/php/php4/CommandHandler/FileUpload.php	(revision 0)
@@ -0,0 +1,151 @@
+<?php
+/*
+* Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+* For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+/**
+ * @package CKEditor
+ * @subpackage CommandHandlers
+ */
+
+/**
+ * Handle FileUpload command
+ *
+ * @package CKEditor
+ * @subpackage CommandHandlers
+ */
+class CKEditor_Connector_CommandHandler_FileUpload extends CKEditor_Connector_CommandHandler_CommandHandlerBase
+{
+    /**
+     * Command name
+     *
+     * @access protected
+     * @var string
+     */
+    var $command = "FileUpload";
+
+    /**
+     * send response (save uploaded file)
+     * @access public
+     *
+     */
+    function sendResponse()
+    {
+        $iErrorNumber = CKEDITOR_CONNECTOR_ERROR_NONE;
+
+        $oRegistry =& CKEditor_Connector_Core_Factory::getInstance("Core_Registry");
+        $oRegistry->set("FileUpload_fileName", "unknown file");
+
+        $uploadedFile = array_shift($_FILES);
+
+        if (!isset($uploadedFile['name'])) {
+            $this->_errorHandler->throwError(CKEDITOR_CONNECTOR_ERROR_UPLOADED_INVALID);
+        }
+
+        $sFileName = CKEditor_Connector_Utils_FileSystem::convertToFilesystemEncoding(basename($uploadedFile['name']));
+        $oRegistry->set("FileUpload_fileName", $sFileName);
+
+        $this->checkConnector();
+        $this->checkRequest();
+
+        if (!CKEditor_Connector_Utils_FileSystem::checkFileName($sFileName)) {
+            $this->_errorHandler->throwError(CKEDITOR_CONNECTOR_ERROR_INVALID_NAME);
+        }
+
+        $_config =& CKEditor_Connector_Core_Factory::getInstance("Core_Config");
+        $_resourceTypeConfig = $this->_currentFolder->getResourceTypeConfig();
+
+        $resourceTypeInfo = $this->_currentFolder->getResourceTypeConfig();
+        if (!$resourceTypeInfo->checkExtension($sFileName)) {
+            $this->_errorHandler->throwError(CKEDITOR_CONNECTOR_ERROR_INVALID_EXTENSION);
+        }
+
+        $sFileNameOrginal = $sFileName;
+        $oRegistry->set("FileUpload_fileName", $sFileName);
+
+        $htmlExtensions = $_config->getHtmlExtensions();
+        $sExtension = CKEditor_Connector_Utils_FileSystem::getExtension($sFileNameOrginal);
+
+        if ($htmlExtensions
+        && !CKEditor_Connector_Utils_Misc::inArrayCaseInsensitive($sExtension, $htmlExtensions)
+        && ($detectHtml = CKEditor_Connector_Utils_FileSystem::detectHtml($uploadedFile['tmp_name'])) === true ) {
+            $this->_errorHandler->throwError(CKEDITOR_CONNECTOR_ERROR_UPLOADED_WRONG_HTML_FILE);
+        }
+
+        $sExtension = CKEditor_Connector_Utils_FileSystem::getExtension($sFileNameOrginal);
+        $secureImageUploads = $_config->getSecureImageUploads();
+        if ($secureImageUploads
+        && ($isImageValid = CKEditor_Connector_Utils_FileSystem::isImageValid($uploadedFile['tmp_name'], $sExtension)) === false ) {
+            $this->_errorHandler->throwError(CKEDITOR_CONNECTOR_ERROR_UPLOADED_CORRUPT);
+        }
+
+        switch ($uploadedFile['error']) {
+            case UPLOAD_ERR_OK:
+                break;
+
+            case UPLOAD_ERR_INI_SIZE:
+            case UPLOAD_ERR_FORM_SIZE:
+                $this->_errorHandler->throwError(CKEDITOR_CONNECTOR_ERROR_UPLOADED_TOO_BIG);
+                break;
+
+            case UPLOAD_ERR_PARTIAL:
+            case UPLOAD_ERR_NO_FILE:
+                $this->_errorHandler->throwError(CKEDITOR_CONNECTOR_ERROR_UPLOADED_CORRUPT);
+                break;
+
+            case UPLOAD_ERR_NO_TMP_DIR:
+                $this->_errorHandler->throwError(CKEDITOR_CONNECTOR_ERROR_UPLOADED_NO_TMP_DIR);
+                break;
+
+            case UPLOAD_ERR_CANT_WRITE:
+                $this->_errorHandler->throwError(CKEDITOR_CONNECTOR_ERROR_ACCESS_DENIED);
+                break;
+
+            case UPLOAD_ERR_EXTENSION:
+                $this->_errorHandler->throwError(CKEDITOR_CONNECTOR_ERROR_ACCESS_DENIED);
+                break;
+        }
+
+        $sServerDir = $this->_currentFolder->getServerPath();
+        $iCounter = 0;
+
+        while (true)
+        {
+            $sFilePath = CKEditor_Connector_Utils_FileSystem::combinePaths($sServerDir, $sFileName);
+
+            if (file_exists($sFilePath)) {
+                $iCounter++;
+                $sFileName =
+                CKEditor_Connector_Utils_FileSystem::getFileNameWithoutExtension($sFileNameOrginal) .
+                "(" . $iCounter . ")" . "." .
+                CKEditor_Connector_Utils_FileSystem::getExtension($sFileNameOrginal);
+                $oRegistry->set("FileUpload_fileName", $sFileName);
+
+                $iErrorNumber = CKEDITOR_CONNECTOR_ERROR_UPLOADED_FILE_RENAMED;
+            } else {
+                if (false === move_uploaded_file($uploadedFile['tmp_name'], $sFilePath)) {
+                    $iErrorNumber = CKEDITOR_CONNECTOR_ERROR_ACCESS_DENIED;
+                }
+                else {
+                    if (isset($detectHtml) && $detectHtml === -1 && CKEditor_Connector_Utils_FileSystem::detectHtml($sFilePath) === true) {
+                        @unlink($sFilePath);
+                        $this->_errorHandler->throwError(CKEDITOR_CONNECTOR_ERROR_UPLOADED_WRONG_HTML_FILE);
+                    }
+                    else if (isset($isImageValid) && $isImageValid === -1 && CKEditor_Connector_Utils_FileSystem::isImageValid($sFilePath, $sExtension) === false) {
+                        @unlink($sFilePath);
+                        $this->_errorHandler->throwError(CKEDITOR_CONNECTOR_ERROR_UPLOADED_CORRUPT);
+                    }
+                }
+                if (is_file($sFilePath) && ($perms = $_config->getChmodFiles())) {
+                    $oldumask = umask(0);
+                    chmod($sFilePath, $perms);
+                    umask($oldumask);
+                }
+                break;
+            }
+        }
+
+        $this->_errorHandler->throwError($iErrorNumber, $sFileName, false);
+    }
+}
Index: _source/plugins/filebrowser/core/connector/php/php4/CommandHandler/GetFolders.php
===================================================================
--- _source/plugins/filebrowser/core/connector/php/php4/CommandHandler/GetFolders.php	(revision 0)
+++ _source/plugins/filebrowser/core/connector/php/php4/CommandHandler/GetFolders.php	(revision 0)
@@ -0,0 +1,80 @@
+<?php
+/*
+* Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+* For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+/**
+ * @package CKEditor
+ * @subpackage CommandHandlers
+ */
+
+/**
+ * Include base XML command handler
+ */
+require_once CKEDITOR_CONNECTOR_LIB_DIR . "/CommandHandler/XmlCommandHandlerBase.php";
+
+/**
+ * Handle GetFolders command
+ *
+ * @package CKEditor
+ * @subpackage CommandHandlers
+ */
+class CKEditor_Connector_CommandHandler_GetFolders extends CKEditor_Connector_CommandHandler_XmlCommandHandlerBase
+{
+    /**
+     * Command name
+     *
+     * @access private
+     * @var string
+     */
+    var $command = "GetFolders";
+
+    /**
+     * handle request and build XML
+     * @access protected
+     *
+     */
+    function buildXml()
+    {
+        $_config =& CKEditor_Connector_Core_Factory::getInstance("Core_Config");
+
+        // Map the virtual path to the local server path.
+        $_sServerDir = $this->_currentFolder->getServerPath();
+
+        if (!is_dir($_sServerDir)) {
+            $this->_errorHandler->throwError(CKEDITOR_CONNECTOR_ERROR_FOLDER_NOT_FOUND);
+        }
+
+        // Create the "Folders" node.
+        $oFoldersNode = new CKEditor_Connector_Utils_XmlNode("Folders");
+        $this->_connectorNode->addChild($oFoldersNode);
+
+        $files = array();
+        if ($dh = @opendir($_sServerDir)) {
+            while (($file = readdir($dh)) !== false) {
+                if ($file != "." && $file != ".." && is_dir($_sServerDir . $file)) {
+                    $files[] = $file;
+                }
+            }
+            closedir($dh);
+        } else {
+            $this->_errorHandler->throwError(CKEDITOR_CONNECTOR_ERROR_ACCESS_DENIED);
+        }
+
+        $resourceTypeInfo = $this->_currentFolder->getResourceTypeConfig();
+
+        if (sizeof($files)>0) {
+            natcasesort($files);
+            $i=0;
+            foreach ($files as $file) {
+                // Create the "Folder" node.
+                $oFolderNode[$i] = new CKEditor_Connector_Utils_XmlNode("Folder");
+                $oFoldersNode->addChild($oFolderNode[$i]);
+                $oFolderNode[$i]->addAttribute("name", CKEditor_Connector_Utils_FileSystem::convertToConnectorEncoding($file));
+
+                $i++;
+            }
+        }
+    }
+}
Index: _source/plugins/filebrowser/core/connector/php/php4/CommandHandler/GetFoldersAndFiles.php
===================================================================
--- _source/plugins/filebrowser/core/connector/php/php4/CommandHandler/GetFoldersAndFiles.php	(revision 0)
+++ _source/plugins/filebrowser/core/connector/php/php4/CommandHandler/GetFoldersAndFiles.php	(revision 0)
@@ -0,0 +1,122 @@
+<?php
+/*
+* Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+* For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+/**
+ * @package CKEditor
+ * @subpackage CommandHandlers
+ */
+
+/**
+ * Include base XML command handler
+ */
+require_once CKEDITOR_CONNECTOR_LIB_DIR . "/CommandHandler/XmlCommandHandlerBase.php";
+
+/**
+ * Handle GetFiles command
+ *
+ * @package CKEditor
+ * @subpackage CommandHandlers
+ */
+class CKEditor_Connector_CommandHandler_GetFoldersAndFiles extends CKEditor_Connector_CommandHandler_XmlCommandHandlerBase
+{
+    /**
+     * Command name
+     *
+     * @access private
+     * @var string
+     */
+    var $command = "GetFiles";
+
+    /**
+     * handle request and build XML
+     * @access protected
+     *
+     */
+    function buildXml()
+    {
+        $_config =& CKEditor_Connector_Core_Factory::getInstance("Core_Config");
+
+        // Map the virtual path to the local server path.
+        $_sServerDir = $this->_currentFolder->getServerPath();
+
+        $files = array();
+        $folders = array();
+        if ($dh = @opendir($_sServerDir)) {
+            while (($file = readdir($dh)) !== false) {
+                if ($file == "." || $file == "..") {
+                    continue;
+                }
+                else if (!is_dir($_sServerDir . $file)) {
+                    $files[] = $file;
+                }
+                else {
+                    $folders[] = $file;
+                }
+            }
+            closedir($dh);
+        }
+        else {
+            $this->_errorHandler->throwError(CKEDITOR_CONNECTOR_ERROR_ACCESS_DENIED);
+        }
+
+        // Create the "Folders" node.
+        $oFoldersNode = new CKEditor_Connector_Utils_XmlNode("Folders");
+        $this->_connectorNode->addChild($oFoldersNode);
+
+
+        $resourceTypeInfo = $this->_currentFolder->getResourceTypeConfig();
+
+        if (sizeof($folders)>0) {
+            natcasesort($folders);
+            $i=0;
+            foreach ($folders as $file) {
+                // Create the "Folder" node.
+                $oFolderNode[$i] = new CKEditor_Connector_Utils_XmlNode("Folder");
+                $oFoldersNode->addChild($oFolderNode[$i]);
+                $oFolderNode[$i]->addAttribute("name", CKEditor_Connector_Utils_FileSystem::convertToConnectorEncoding($file));
+
+                $i++;
+            }
+        }
+
+        // Create the "Files" node.
+        $oFilesNode = new CKEditor_Connector_Utils_XmlNode("Files");
+        $this->_connectorNode->addChild($oFilesNode);
+
+        if (!is_dir($_sServerDir)) {
+            $this->_errorHandler->throwError(CKEDITOR_CONNECTOR_ERROR_FOLDER_NOT_FOUND);
+        }
+
+        if (sizeof($files)>0) {
+            natcasesort($files);
+            $i=0;
+            foreach ($files as $file) {
+                $filemtime = @filemtime($_sServerDir . $file);
+
+                //otherwise file doesn't exist or we can't get it's filename properly
+                if ($filemtime !== false) {
+                    $filename = basename($file);
+                    if (!$resourceTypeInfo->checkExtension($filename, false)) {
+                        continue;
+                    }
+                    $oFileNode[$i] = new CKEditor_Connector_Utils_XmlNode("File");
+                    $oFilesNode->addChild($oFileNode[$i]);
+                    $oFileNode[$i]->addAttribute("name", CKEditor_Connector_Utils_FileSystem::convertToConnectorEncoding(basename($file)));
+                    $oFileNode[$i]->addAttribute("date", @date("YmdHi", $filemtime));
+                    $size = filesize($_sServerDir . $file);
+                    if ($size && $size<1024) {
+                        $size = 1;
+                    }
+                    else {
+                        $size = (int)round($size / 1024);
+                    }
+                    $oFileNode[$i]->addAttribute("size", $size);
+                    $i++;
+                }
+            }
+        }
+    }
+}
Index: _source/plugins/filebrowser/core/connector/php/php4/CommandHandler/Init.php
===================================================================
--- _source/plugins/filebrowser/core/connector/php/php4/CommandHandler/Init.php	(revision 0)
+++ _source/plugins/filebrowser/core/connector/php/php4/CommandHandler/Init.php	(revision 0)
@@ -0,0 +1,97 @@
+<?php
+/*
+* Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+* For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+/**
+ * @package CKEditor
+ * @subpackage CommandHandlers
+ */
+
+/**
+ * Include base XML command handler
+ */
+require_once CKEDITOR_CONNECTOR_LIB_DIR . "/CommandHandler/XmlCommandHandlerBase.php";
+
+/**
+ * Handle Init command
+ *
+ * @package CKEditor
+ * @subpackage CommandHandlers
+ */
+class CKEditor_Connector_CommandHandler_Init extends CKEditor_Connector_CommandHandler_XmlCommandHandlerBase
+{
+    /**
+     * Command name
+     *
+     * @access private
+     * @var string
+     */
+    var $command = "Init";
+
+    function mustCheckRequest()
+    {
+        return false;
+    }
+
+    /**
+     * Must add CurrentFolder node?
+     *
+     * @return boolean
+     * @access protected
+     */
+    function mustAddCurrentFolderNode()
+    {
+        return false;
+    }
+
+    /**
+     * handle request and build XML
+     * @access protected
+     *
+     */
+    function buildXml()
+    {
+        $_config =& CKEditor_Connector_Core_Factory::getInstance("Core_Config");
+
+        // Create the "ConnectorInfo" node.
+        $_oConnInfo = new CKEditor_Connector_Utils_XmlNode("ConnectorInfo");
+        $this->_connectorNode->addChild($_oConnInfo);
+        $_oConnInfo->addAttribute("enabled", $_config->getIsEnabled() ? "true" : "false");
+
+        if (!$_config->getIsEnabled()) {
+            $this->_errorHandler->throwError(CKEDITOR_CONNECTOR_ERROR_CONNECTOR_DISABLED);
+        }
+
+        // Create the "ResourceTypes" node.
+        $_oResourceTypes = new CKEditor_Connector_Utils_XmlNode("ResourceTypes");
+        $this->_connectorNode->addChild($_oResourceTypes);
+
+        // Load the resource types in an array.
+        $_aTypes = $_config->getDefaultResourceTypes();
+
+        if (!sizeof($_aTypes)) {
+            $_aTypes = $_config->getResourceTypeNames();
+        }
+
+        $_aTypesSize = sizeof($_aTypes);
+        if ($_aTypesSize) {
+            for ($i = 0; $i < $_aTypesSize; $i++)
+            {
+                $_resourceTypeName = $_aTypes[$i];
+
+                if (!isset($_GET['type']) || $_GET['type'] === $_resourceTypeName) {
+                    $_oTypeInfo = $_config->getResourceTypeConfig($_resourceTypeName);
+                    $_oResourceType[$i] = new CKEditor_Connector_Utils_XmlNode("ResourceType");
+                    $_oResourceTypes->addChild($_oResourceType[$i]);
+
+                    $_oResourceType[$i]->addAttribute("name", $_resourceTypeName);
+                    $_oResourceType[$i]->addAttribute("url", $_oTypeInfo->getUrl());
+                    $_oResourceType[$i]->addAttribute("allowedExtensions", implode(",", $_oTypeInfo->getAllowedExtensions()));
+                    $_oResourceType[$i]->addAttribute("deniedExtensions", implode(",", $_oTypeInfo->getDeniedExtensions()));
+                }
+            }
+        }
+    }
+}
Index: _source/plugins/filebrowser/core/connector/php/php4/CommandHandler/QuickUpload.php
===================================================================
--- _source/plugins/filebrowser/core/connector/php/php4/CommandHandler/QuickUpload.php	(revision 0)
+++ _source/plugins/filebrowser/core/connector/php/php4/CommandHandler/QuickUpload.php	(revision 0)
@@ -0,0 +1,40 @@
+<?php
+/*
+* Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+* For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+/**
+ * @package CKEditor
+ * @subpackage CommandHandlers
+ */
+
+/**
+ * Include file upload command handler
+ */
+require_once CKEDITOR_CONNECTOR_LIB_DIR . "/CommandHandler/FileUpload.php";
+
+/**
+ * Handle QuickUpload command
+ *
+ * @package CKEditor
+ * @subpackage CommandHandlers
+ */
+class CKEditor_Connector_CommandHandler_QuickUpload extends CKEditor_Connector_CommandHandler_FileUpload
+{
+    /**
+     * Command name
+     *
+     * @access protected
+     * @var string
+     */
+    var $command = "QuickUpload";
+
+    function sendResponse()
+    {
+        $oRegistry =& CKEditor_Connector_Core_Factory::getInstance("Core_Registry");
+        $oRegistry->set("FileUpload_url", $this->_currentFolder->getUrl());
+
+        return parent::sendResponse();
+    }
+}
Index: _source/plugins/filebrowser/core/connector/php/php4/CommandHandler/XmlCommandHandlerBase.php
===================================================================
--- _source/plugins/filebrowser/core/connector/php/php4/CommandHandler/XmlCommandHandlerBase.php	(revision 0)
+++ _source/plugins/filebrowser/core/connector/php/php4/CommandHandler/XmlCommandHandlerBase.php	(revision 0)
@@ -0,0 +1,106 @@
+<?php
+/*
+* Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+* For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+/**
+ * @package CKEditor
+ * @subpackage CommandHandlers
+ */
+
+/**
+ * Include base command handler
+ */
+require_once CKEDITOR_CONNECTOR_LIB_DIR . "/CommandHandler/CommandHandlerBase.php";
+/**
+ * Include xml utils
+ */
+require_once CKEDITOR_CONNECTOR_LIB_DIR . "/Core/Xml.php";
+
+/**
+ * Base XML commands handler
+ *
+ * @package CKEditor
+ * @subpackage CommandHandlers
+ * @abstract
+ */
+abstract class CKEditor_Connector_CommandHandler_XmlCommandHandlerBase extends CKEditor_Connector_CommandHandler_CommandHandlerBase
+{
+    /**
+     * Connector node - CKEditor_Connector_Utils_XmlNode object
+     *
+     * @var CKEditor_Connector_Utils_XmlNode
+     * @access protected
+     */
+    var $_connectorNode;
+
+    /**
+     * send response
+     * @access public
+     *
+     */
+    function sendResponse()
+    {
+        $xml =& CKEditor_Connector_Core_Factory::getInstance("Core_Xml");
+        $this->_connectorNode =& $xml->getConnectorNode();
+
+        $this->checkConnector();
+        if ($this->mustCheckRequest()) {
+            $this->checkRequest();
+        }
+
+        $resourceTypeName = $this->_currentFolder->getResourceTypeName();
+        if (!empty($resourceTypeName)) {
+            $this->_connectorNode->addAttribute("resourceType", $this->_currentFolder->getResourceTypeName());
+        }
+
+        if ($this->mustAddCurrentFolderNode()) {
+            $_currentFolder = new CKEditor_Connector_Utils_XmlNode("CurrentFolder");
+            $this->_connectorNode->addChild($_currentFolder);
+            $_currentFolder->addAttribute("path", CKEditor_Connector_Utils_FileSystem::convertToConnectorEncoding($this->_currentFolder->getClientPath()));
+
+            $this->_errorHandler->setCatchAllErros(true);
+            $_url = $this->_currentFolder->getUrl();
+            $_currentFolder->addAttribute("url", is_null($_url) ? "" : CKEditor_Connector_Utils_FileSystem::convertToConnectorEncoding($_url));
+            $this->_errorHandler->setCatchAllErros(false);
+        }
+
+        $this->buildXml();
+
+        $_oErrorNode =& $xml->getErrorNode();
+        $_oErrorNode->addAttribute("number", "0");
+
+        echo $this->_connectorNode->asXML();
+        exit;
+    }
+
+    /**
+     * Must check request?
+     *
+     * @return boolean
+     * @access protected
+     */
+    function mustCheckRequest()
+    {
+        return true;
+    }
+
+    /**
+     * Must add CurrentFolder node?
+     *
+     * @return boolean
+     * @access protected
+     */
+    function mustAddCurrentFolderNode()
+    {
+        return true;
+    }
+
+    /**
+     * @access protected
+     * @abstract
+     * @return void
+     */
+    abstract function buildXml();
+}
Index: _source/plugins/filebrowser/core/connector/php/php4/Core/Config.php
===================================================================
--- _source/plugins/filebrowser/core/connector/php/php4/Core/Config.php	(revision 0)
+++ _source/plugins/filebrowser/core/connector/php/php4/Core/Config.php	(revision 0)
@@ -0,0 +1,273 @@
+<?php
+/*
+* Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+* For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+/**
+ * @package CKEditor
+ * @subpackage Config
+ */
+
+/**
+ * Include resource type config class
+ */
+require_once CKEDITOR_CONNECTOR_LIB_DIR . "/Core/ResourceTypeConfig.php";
+
+/**
+ * Main config parser
+ *
+ *
+ * @package CKEditor
+ * @subpackage Config
+
+ * @global string $GLOBALS['config']
+ */
+class CKEditor_Connector_Core_Config
+{
+    /**
+     * Is CKEditor enabled
+     *
+     * @var boolean
+     * @access private
+     */
+    var $_isEnabled = false;
+    /**
+     * ResourceType config cache
+     *
+     * @var array
+     * @access private
+     */
+    var $_resourceTypeConfigCache = array();
+    /**
+     * Array with default resource types names
+     *
+     * @access private
+     * @var array
+     */
+    var $_defaultResourceTypes = array();
+    /**
+     * Filesystem encoding
+     *
+     * @var string
+     * @access private
+     */
+    var $_filesystemEncoding;
+    /**
+     * Check double extension
+     *
+     * @var boolean
+     * @access private
+     */
+    var $_checkDoubleExtension = true;
+    /**
+     * If set to true, validate image size
+     *
+     * @var boolean
+     * @access private
+     */
+    var $_secureImageUploads = true;
+    /**
+     * For security, HTML is allowed in the first Kb of data for files having the following extensions only
+     *
+     * @var array
+     * @access private
+     */
+    var $_htmlExtensions = array('html', 'htm', 'xml', 'xsd', 'txt', 'js');
+    /**
+     * Chmod files after upload to the following permission
+     *
+     * @var integer
+     * @access private
+     */
+    var $_chmodFiles = 0777;
+    /**
+     * Chmod directories after creation
+     *
+     * @var integer
+     * @access private
+     */
+    var $_chmodFolders = 0755;
+
+    function CKEditor_Connector_Core_Config()
+    {
+        $this->loadValues();
+    }
+
+    /**
+	 * Get file system encoding, returns null if encoding is not set
+	 *
+	 * @access public
+	 * @return string
+	 */
+    function getFilesystemEncoding()
+    {
+        return $this->_filesystemEncoding;
+    }
+
+    /**
+	 * Get "secureImageUploads" value
+	 *
+	 * @access public
+	 * @return boolean
+	 */
+    function getSecureImageUploads()
+    {
+        return $this->_secureImageUploads;
+    }
+
+    /**
+	 * Get "htmlExtensions" value
+	 *
+	 * @access public
+	 * @return array
+	 */
+    function getHtmlExtensions()
+    {
+        return $this->_htmlExtensions;
+    }
+
+    /**
+	 * Get "Check double extension" value
+	 *
+	 * @access public
+	 * @return boolean
+	 */
+    function getCheckDoubleExtension()
+    {
+        return $this->_checkDoubleExtension;
+    }
+
+    /**
+	 * Get default resource types
+	 *
+	 * @access public
+	 * @return array()
+	 */
+    function getDefaultResourceTypes()
+    {
+        return $this->_defaultResourceTypes;
+    }
+
+    /**
+	 * Is CKEditor enabled
+	 *
+	 * @access public
+	 * @return boolean
+	 */
+    function getIsEnabled()
+    {
+        return $this->_isEnabled;
+    }
+
+    /**
+	* Get chmod settings for uploaded files
+	*
+	* @access public
+	* @return integer
+	*/
+    function getChmodFiles()
+    {
+        return $this->_chmodFiles;
+    }
+
+    /**
+	* Get chmod settings for created directories
+	*
+	* @access public
+	* @return integer
+	*/
+    function getChmodFolders()
+    {
+        return $this->_chmodFolders;
+    }
+
+    /**
+	 * Get resourceTypeName config
+	 *
+	 * @param string $resourceTypeName
+	 * @return CKEditor_Connector_Core_ResourceTypeConfig|null
+	 * @access public
+	 */
+    function &getResourceTypeConfig($resourceTypeName)
+    {
+        $_null = null;
+
+        if (isset($this->_resourceTypeConfigCache[$resourceTypeName])) {
+            return $this->_resourceTypeConfigCache[$resourceTypeName];
+        }
+
+        if (!isset($GLOBALS['config']['ResourceType']) || !is_array($GLOBALS['config']['ResourceType'])) {
+            return $_null;
+        }
+
+        reset($GLOBALS['config']['ResourceType']);
+        while (list($_key,$_resourceTypeNode) = each($GLOBALS['config']['ResourceType'])) {
+            if ($_resourceTypeNode['name'] === $resourceTypeName) {
+                $this->_resourceTypeConfigCache[$resourceTypeName] = new CKEditor_Connector_Core_ResourceTypeConfig($_resourceTypeNode);
+
+                return $this->_resourceTypeConfigCache[$resourceTypeName];
+            }
+        }
+
+        return $_null;
+    }
+
+    /**
+     * Load values from config
+     *
+     * @access private
+     */
+    function loadValues()
+    {
+        if (function_exists('CheckAuthentication')) {
+            $this->_isEnabled = CheckAuthentication();
+        }
+        if (isset($GLOBALS['config']['FilesystemEncoding'])) {
+            $this->_filesystemEncoding = (string)$GLOBALS['config']['FilesystemEncoding'];
+        }
+        if (isset($GLOBALS['config']['CheckDoubleExtension'])) {
+            $this->_checkDoubleExtension = CKEditor_Connector_Utils_Misc::booleanValue($GLOBALS['config']['CheckDoubleExtension']);
+        }
+        if (isset($GLOBALS['config']['SecureImageUploads'])) {
+            $this->_secureImageUploads = CKEditor_Connector_Utils_Misc::booleanValue($GLOBALS['config']['SecureImageUploads']);
+        }
+        if (isset($GLOBALS['config']['HtmlExtensions'])) {
+            $this->_htmlExtensions = (array)$GLOBALS['config']['HtmlExtensions'];
+        }
+        if (isset($GLOBALS['config']['ChmodFiles'])) {
+            $this->_chmodFiles = $GLOBALS['config']['ChmodFiles'];
+        }
+        if (isset($GLOBALS['config']['ChmodFolders'])) {
+            $this->_chmodFolders = $GLOBALS['config']['ChmodFolders'];
+        }
+        if (isset($GLOBALS['config']['DefaultResourceTypes'])) {
+            $_defaultResourceTypes = (string)$GLOBALS['config']['DefaultResourceTypes'];
+            if (strlen($_defaultResourceTypes)) {
+                $this->_defaultResourceTypes = explode(",", $_defaultResourceTypes);
+            }
+        }
+    }
+
+    /**
+     * Get all resource type names defined in config
+     *
+     * @return array
+     * @access public
+     */
+    function getResourceTypeNames()
+    {
+        if (!isset($GLOBALS['config']['ResourceType']) || !is_array($GLOBALS['config']['ResourceType'])) {
+            return array();
+        }
+
+        $_names = array();
+        foreach ($GLOBALS['config']['ResourceType'] as $key => $_resourceType) {
+            if (isset($_resourceType['name'])) {
+                $_names[] = (string)$_resourceType['name'];
+            }
+        }
+
+        return $_names;
+    }
+}
\ No newline at end of file
Index: _source/plugins/filebrowser/core/connector/php/php4/Core/Connector.php
===================================================================
--- _source/plugins/filebrowser/core/connector/php/php4/Core/Connector.php	(revision 0)
+++ _source/plugins/filebrowser/core/connector/php/php4/Core/Connector.php	(revision 0)
@@ -0,0 +1,93 @@
+<?php
+/*
+* Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+* For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+/**
+ * @package CKEditor
+ * @subpackage Core
+ */
+
+/**
+ * Executes all commands
+ *
+ * @package CKEditor
+ * @subpackage Core
+ */
+class CKEditor_Connector_Core_Connector
+{
+    /**
+     * Registry
+     *
+     * @var CKEditor_Connector_Core_Registry
+     * @access private
+     */
+    var $_registry;
+
+    function CKEditor_Connector_Core_Connector()
+    {
+        $this->_registry =& CKEditor_Connector_Core_Factory::getInstance("Core_Registry");
+        $this->_registry->set("errorHandler", "ErrorHandler_Base");
+    }
+
+    /**
+     * Generic handler for invalid commands
+     * @access public
+     *
+     */
+    function handleInvalidCommand()
+    {
+        $oErrorHandler =& $this->getErrorHandler();
+        $oErrorHandler->throwError(CKEDITOR_CONNECTOR_ERROR_INVALID_COMMAND);
+    }
+
+    /**
+     * Execute command
+     *
+     * @param string $command
+     * @access public
+     */
+    function executeCommand($command)
+    {
+        switch ($command)
+        {
+            case 'FileUpload':
+                $this->_registry->set("errorHandler", "ErrorHandler_FileUpload");
+                $obj =& CKEditor_Connector_Core_Factory::getInstance("CommandHandler_".$command);
+                $obj->sendResponse();
+                break;
+
+            case 'QuickUpload':
+                $this->_registry->set("errorHandler", "ErrorHandler_QuickUpload");
+                $obj =& CKEditor_Connector_Core_Factory::getInstance("CommandHandler_".$command);
+                $obj->sendResponse();
+                break;
+
+            case 'CreateFolder':
+            case 'GetFolders':
+            case 'GetFoldersAndFiles':
+            case 'Init':
+                $obj =& CKEditor_Connector_Core_Factory::getInstance("CommandHandler_".$command);
+                $obj->sendResponse();
+                break;
+
+            default:
+                $this->handleInvalidCommand();
+                break;
+        }
+    }
+
+    /**
+     * Get error handler
+     *
+     * @access public
+     * @return CKEditor_Connector_ErrorHandler_Base|CKEditor_Connector_ErrorHandler_FileUpload|CKEditor_Connector_ErrorHandler_Http
+     */
+    function &getErrorHandler()
+    {
+        $_errorHandler = $this->_registry->get("errorHandler");
+        $oErrorHandler =& CKEditor_Connector_Core_Factory::getInstance($_errorHandler);
+        return $oErrorHandler;
+    }
+}
\ No newline at end of file
Index: _source/plugins/filebrowser/core/connector/php/php4/Core/Factory.php
===================================================================
--- _source/plugins/filebrowser/core/connector/php/php4/Core/Factory.php	(revision 0)
+++ _source/plugins/filebrowser/core/connector/php/php4/Core/Factory.php	(revision 0)
@@ -0,0 +1,58 @@
+<?php
+/*
+* Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+* For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+/**
+ * @package CKEditor
+ * @subpackage Core
+ */
+
+/**
+ * Sigleton factory creating objects
+ *
+ * @package CKEditor
+ * @subpackage Core
+ */
+class CKEditor_Connector_Core_Factory
+{
+    static $instances = array();
+
+    /**
+     * Initiate factory
+     * @static
+     */
+    function initFactory()
+    {
+    }
+
+    /**
+     * Get instance of specified class
+     * Short and Long class names are possible
+     * <code>
+     * $obj1 =& CKEditor_Connector_Core_Factory::getInstance("CKEditor_Connector_Core_Xml");
+     * $obj2 =& CKEditor_Connector_Core_Factory::getInstance("Core_Xml");
+     * </code>
+     *
+     * @param string $className class name
+     * @static
+     * @access public
+     * @return object
+     */
+    function &getInstance($className)
+    {
+        $namespace = "CKEditor_Connector_";
+
+        $baseName = str_replace($namespace,"",$className);
+
+        $className = $namespace.$baseName;
+
+        if (!isset(CKEditor_Connector_Core_Factory::$instances[$className])) {
+            require_once CKEDITOR_CONNECTOR_LIB_DIR . "/" . str_replace("_","/",$baseName).".php";
+            CKEditor_Connector_Core_Factory::$instances[$className] = new $className;
+        }
+
+        return CKEditor_Connector_Core_Factory::$instances[$className];
+    }
+}
\ No newline at end of file
Index: _source/plugins/filebrowser/core/connector/php/php4/Core/FolderHandler.php
===================================================================
--- _source/plugins/filebrowser/core/connector/php/php4/Core/FolderHandler.php	(revision 0)
+++ _source/plugins/filebrowser/core/connector/php/php4/Core/FolderHandler.php	(revision 0)
@@ -0,0 +1,172 @@
+<?php
+/*
+* Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+* For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+/**
+ * @package CKEditor
+ * @subpackage Core
+ */
+
+/**
+ * Include file system utils class
+ */
+require_once CKEDITOR_CONNECTOR_LIB_DIR . "/Utils/FileSystem.php";
+
+/**
+ * @package CKEditor
+ * @subpackage Core
+ */
+class CKEditor_Connector_Core_FolderHandler
+{
+    /**
+     * CKEditor_Connector_Core_ResourceTypeConfig object
+     *
+     * @var CKEditor_Connector_Core_ResourceTypeConfig
+     * @access private
+     */
+    var $_resourceTypeConfig;
+    /**
+     * ResourceType name
+     *
+     * @var string
+     * @access private
+     */
+    var $_resourceTypeName = "";
+    /**
+     * Client path
+     *
+     * @var string
+     * @access private
+     */
+    var $_clientPath = "/";
+    /**
+     * Url
+     *
+     * @var string
+     * @access private
+     */
+    var $_url;
+    /**
+     * Server path
+     *
+     * @var string
+     * @access private
+     */
+    var $_serverPath;
+    /**
+     * Folder info
+     *
+     * @var mixed
+     * @access private
+     */
+    var $_folderInfo;
+
+    function CKEditor_Connector_Core_FolderHandler()
+    {
+        if (isset($_GET["type"])) {
+            $this->_resourceTypeName = (string)$_GET["type"];
+        }
+
+        if (isset($_GET["currentFolder"])) {
+            $this->_clientPath = CKEditor_Connector_Utils_FileSystem::convertToFilesystemEncoding((string)$_GET["currentFolder"]);
+        }
+
+        if (!strlen($this->_clientPath)) {
+            $this->_clientPath = "/";
+        }
+        else {
+            if (substr($this->_clientPath, -1, 1) != "/") {
+                $this->_clientPath .= "/";
+            }
+            if (substr($this->_clientPath, 0, 1) != "/") {
+                $this->_clientPath = "/" . $this->_clientPath;
+            }
+        }
+    }
+
+    /**
+     * Get resource type config
+     *
+     * @return CKEditor_Connector_Core_ResourceTypeConfig
+     * @access public
+     */
+    function &getResourceTypeConfig()
+    {
+        if (!isset($this->_resourceTypeConfig)) {
+            $_config =& CKEditor_Connector_Core_Factory::getInstance("Core_Config");
+            $this->_resourceTypeConfig = $_config->getResourceTypeConfig($this->_resourceTypeName);
+        }
+
+        if (is_null($this->_resourceTypeConfig)) {
+            $connector =& CKEditor_Connector_Core_Factory::getInstance("Core_Connector");
+            $oErrorHandler =& $connector->getErrorHandler();
+            $oErrorHandler->throwError(CKEDITOR_CONNECTOR_ERROR_INVALID_TYPE);
+        }
+
+        return $this->_resourceTypeConfig;
+    }
+
+    /**
+     * Get resource type name
+     *
+     * @return string
+     * @access public
+     */
+    function getResourceTypeName()
+    {
+        return $this->_resourceTypeName;
+    }
+
+    /**
+     * Get Client path
+     *
+     * @return string
+     * @access public
+     */
+    function getClientPath()
+    {
+        return $this->_clientPath;
+    }
+
+    /**
+     * Get Url
+     *
+     * @return string
+     * @access public
+     */
+    function getUrl()
+    {
+        if (is_null($this->_url)) {
+            $this->_resourceTypeConfig = $this->getResourceTypeConfig();
+            if (is_null($this->_resourceTypeConfig)) {
+                $connector =& CKEditor_Connector_Core_Factory::getInstance("Core_Connector");
+                $oErrorHandler =& $connector->getErrorHandler();
+                $oErrorHandler->throwError(CKEDITOR_CONNECTOR_ERROR_INVALID_TYPE);
+                $this->_url = "";
+            }
+            else {
+                $this->_url = $this->_resourceTypeConfig->getUrl() . ltrim($this->getClientPath(), "/");
+            }
+        }
+
+        return $this->_url;
+    }
+
+    /**
+     * Get server path
+     *
+     * @return string
+     * @access public
+     */
+    function getServerPath()
+    {
+        if (is_null($this->_serverPath)) {
+            $this->_resourceTypeConfig = $this->getResourceTypeConfig();
+            $this->_serverPath = CKEditor_Connector_Utils_FileSystem::combinePaths($this->_resourceTypeConfig->getDirectory(), ltrim($this->_clientPath, "/"));
+        }
+
+        return $this->_serverPath;
+    }
+}
\ No newline at end of file
Index: _source/plugins/filebrowser/core/connector/php/php4/Core/Registry.php
===================================================================
--- _source/plugins/filebrowser/core/connector/php/php4/Core/Registry.php	(revision 0)
+++ _source/plugins/filebrowser/core/connector/php/php4/Core/Registry.php	(revision 0)
@@ -0,0 +1,65 @@
+<?php
+/*
+* Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+* For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+/**
+ * @package CKEditor
+ * @subpackage Core
+ */
+
+/**
+ * Registry for storing global variables values (not references)
+ *
+ * @package CKEditor
+ * @subpackage Core
+ */
+class CKEditor_Connector_Core_Registry
+{
+    /**
+     * Arrat that stores all values
+     *
+     * @var array
+     * @access private
+     */
+    var $_store = array();
+
+    /**
+     * Chacke if value has been set
+     *
+     * @param string $key
+     * @return boolean
+     * @access private
+     */
+    function isValid($key)
+    {
+        return array_key_exists($key, $this->_store);
+    }
+
+    /**
+     * Set value
+     *
+     * @param string $key
+     * @param mixed $obj
+     * @access public
+     */
+    function set($key, $obj)
+    {
+        $this->_store[$key] = $obj;
+    }
+
+    /**
+     * Get value
+     *
+     * @param string $key
+     * @return mixed
+     * @access public
+     */
+    function get($key)
+    {
+        if ($this->isValid($key)) {
+            return $this->_store[$key];
+        }
+    }
+}
\ No newline at end of file
Index: _source/plugins/filebrowser/core/connector/php/php4/Core/ResourceTypeConfig.php
===================================================================
--- _source/plugins/filebrowser/core/connector/php/php4/Core/ResourceTypeConfig.php	(revision 0)
+++ _source/plugins/filebrowser/core/connector/php/php4/Core/ResourceTypeConfig.php	(revision 0)
@@ -0,0 +1,253 @@
+<?php
+/*
+* Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+* For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+/**
+ * @package CKEditor
+ * @subpackage Config
+ */
+
+/**
+ * This class keeps resource types configuration
+ *
+ * @package CKEditor
+ * @subpackage Config
+ */
+class CKEditor_Connector_Core_ResourceTypeConfig
+{
+    /**
+     * Resource name
+     *
+     * @var string
+     * @access private
+     */
+    var $_name = "";
+    /**
+     * Resource url
+     *
+     * @var string
+     * @access private
+     */
+    var $_url = "";
+    /**
+     * Directory path on a server
+     *
+     * @var string
+     * @access private
+     */
+    var $_directory = "";
+    /**
+     * Array with allowed extensions
+     *
+     * @var array[]string
+     * @access private
+     */
+    var $_allowedExtensions = array();
+    /**
+     * Array with denied extensions
+     *
+     * @var array[]string
+     * @access private
+     */
+    var $_deniedExtensions = array();
+    /**
+     * used for CKEditor_Connector_Core_Config object caching
+     *
+     * @var CKEditor_Connector_Core_Config
+     * @access private
+     */
+    var $_config;
+
+    /**
+     * Get ResourceType configuration
+     *
+     * @param string $resourceTypeNode
+     * @return array
+     *
+     */
+    function CKEditor_Connector_Core_ResourceTypeConfig($resourceTypeNode)
+    {
+        if (isset($resourceTypeNode["name"])) {
+            $this->_name = $resourceTypeNode["name"];
+        }
+
+        if (isset($resourceTypeNode["url"])) {
+            $this->_url = $resourceTypeNode["url"];
+        }
+
+        if (!strlen($this->_url)) {
+            $this->_url = "/";
+        }
+        else if (substr($this->_url,-1,1) != "/") {
+            $this->_url .= "/";
+        }
+
+        if (isset($resourceTypeNode["directory"])) {
+            $this->_directory = $resourceTypeNode["directory"];
+        }
+
+        if (!strlen($this->_directory)) {
+            $this->_directory = resolveUrl($this->_url);
+        }
+
+        if (isset($resourceTypeNode["allowedExtensions"])) {
+            if (is_array($resourceTypeNode["allowedExtensions"])) {
+                foreach ($resourceTypeNode["allowedExtensions"] as $extension) {
+                    $this->_allowedExtensions[] = strtolower(trim((string)$e));
+                }
+            }
+            else {
+                $resourceTypeNode["allowedExtensions"] = trim((string)$resourceTypeNode["allowedExtensions"]);
+                if (strlen($resourceTypeNode["allowedExtensions"])) {
+                    $extensions = explode(",", $resourceTypeNode["allowedExtensions"]);
+                    foreach ($extensions as $e) {
+                        $this->_allowedExtensions[] = strtolower(trim($e));
+                    }
+                }
+            }
+        }
+
+        if (isset($resourceTypeNode["deniedExtensions"])) {
+            if (is_array($resourceTypeNode["deniedExtensions"])) {
+
+                foreach ($resourceTypeNode["deniedExtensions"] as $extension) {
+                    $this->_deniedExtensions[] = strtolower(trim((string)$e));
+                }
+            }
+            else {
+                $resourceTypeNode["deniedExtensions"] = trim((string)$resourceTypeNode["deniedExtensions"]);
+                if (strlen($resourceTypeNode["deniedExtensions"])) {
+                    $extensions = explode(",", $resourceTypeNode["deniedExtensions"]);
+                    foreach ($extensions as $e) {
+                        $this->_deniedExtensions[] = strtolower(trim($e));
+                    }
+                }
+            }
+        }
+    }
+
+    /**
+     * Get name
+     *
+     * @access public
+     * @return string
+     */
+    function getName()
+    {
+        return $this->_name;
+    }
+
+    /**
+     * Get url
+     *
+     * @access public
+     * @return string
+     */
+    function getUrl()
+    {
+        return $this->_url;
+    }
+
+    /**
+     * Get directory
+     *
+     * @access public
+     * @return string
+     */
+    function getDirectory()
+    {
+        return $this->_directory;
+    }
+
+    /**
+     * Get allowed extensions
+     *
+     * @access public
+     * @return array[]string
+     */
+    function getAllowedExtensions()
+    {
+        return $this->_allowedExtensions;
+    }
+
+    /**
+     * Get denied extensions
+     *
+     * @access public
+     * @return array[]string
+     */
+    function getDeniedExtensions()
+    {
+        return $this->_deniedExtensions;
+    }
+
+    /**
+     * Check extension, return true if file name is valid.
+     * Return false if extension is on denied list.
+     * If allowed extensions are defined, return false if extension isn't on allowed list.
+     *
+     * @access public
+     * @param string $extension extension
+     * @param boolean $renameIfRequired whether try to rename file or not
+     * @return boolean
+     */
+    function checkExtension(&$fileName, $renameIfRequired = true)
+    {
+        if (strpos($fileName, '.') === false) {
+            return true;
+        }
+
+        if (is_null($this->_config)) {
+            $this->_config =& CKEditor_Connector_Core_Factory::getInstance("Core_Config");
+        }
+
+        $toCheck = array();
+
+        if ($this->_config->getCheckDoubleExtension()) {
+            $pieces = explode('.', $fileName);
+
+            // First, check the last extension (ex. in file.php.jpg, the "jpg").
+            if ( !$this->checkSingleExtension( $pieces[sizeof($pieces)-1] ) ) {
+                return false;
+            }
+
+            if ($renameIfRequired) {
+                // Check the other extensions, rebuilding the file name. If an extension is
+                // not allowed, replace the dot with an underscore.
+                $fileName = $pieces[0] ;
+                for ($i=1; $i<sizeof($pieces)-1; $i++) {
+                    $fileName .= $this->checkSingleExtension( $pieces[$i] ) ? '.' : '_' ;
+                    $fileName .= $pieces[$i];
+                }
+
+                // Add the last extension to the final name.
+                $fileName .= '.' . $pieces[sizeof($pieces)-1] ;
+            }
+        }
+        else {
+            // Check only the last extension (ex. in file.php.jpg, only "jpg").
+            return $this->checkSingleExtension( substr($fileName, strrpos($fileName,'.')+1) );
+        }
+
+        return true;
+    }
+
+    function checkSingleExtension($extension)
+    {
+        $extension = strtolower(ltrim($extension,'.'));
+
+        if (sizeof($this->_deniedExtensions)) {
+            if (in_array($extension, $this->_deniedExtensions)) {
+                return false;
+            }
+        }
+
+        if (sizeof($this->_allowedExtensions)) {
+            return in_array($extension, $this->_allowedExtensions);
+        }
+
+        return true;
+    }
+}
Index: _source/plugins/filebrowser/core/connector/php/php4/Core/Xml.php
===================================================================
--- _source/plugins/filebrowser/core/connector/php/php4/Core/Xml.php	(revision 0)
+++ _source/plugins/filebrowser/core/connector/php/php4/Core/Xml.php	(revision 0)
@@ -0,0 +1,120 @@
+<?php
+/*
+* Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+* For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+/**
+ * @package CKEditor
+ * @subpackage Core
+ */
+
+/**
+ * Include basic Xml library
+ */
+require_once CKEDITOR_CONNECTOR_LIB_DIR . "/Utils/XmlNode.php";
+
+/**
+ * XML document
+ *
+ * @package CKEditor
+ * @subpackage Core
+ */
+class CKEditor_Connector_Core_Xml
+{
+    /**
+     * Connector node (root)
+     *
+     * @var CKEditor_Connector_Utils_XmlNode
+     * @access private
+     */
+    var $_connectorNode;
+    /**
+     * Error node
+     *
+     * @var CKEditor_Connector_Utils_XmlNode
+     * @access private
+     */
+    var $_errorNode;
+
+    function CKEditor_Connector_Core_Xml()
+    {
+        $this->sendXmlHeaders();
+        echo $this->getXMLDeclaration();
+        $this->_connectorNode = new CKEditor_Connector_Utils_XmlNode("Connector");
+        $this->_errorNode = new CKEditor_Connector_Utils_XmlNode("Error");
+        $this->_connectorNode->addChild($this->_errorNode);
+    }
+
+    /**
+     * Return connector node
+     *
+     * @return CKEditor_Connector_Utils_XmlNode
+     * @access public
+     */
+    function &getConnectorNode()
+    {
+        return $this->_connectorNode;
+    }
+
+    /**
+     * Return error node
+     *
+     * @return CKEditor_Connector_Utils_XmlNode
+     * @access public
+     */
+    function &getErrorNode()
+    {
+        return $this->_errorNode;
+    }
+
+    /**
+     * Send XML headers to the browser (and force browser not to use cache)
+     * @access private
+     */
+    function sendXmlHeaders()
+    {
+        // Prevent the browser from caching the result.
+        // Date in the past
+        header('Expires: Mon, 26 Jul 1997 05:00:00 GMT') ;
+        // always modified
+        header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT') ;
+        // HTTP/1.1
+        header('Cache-Control: no-store, no-cache, must-revalidate') ;
+        header('Cache-Control: post-check=0, pre-check=0', false) ;
+        // HTTP/1.0
+        header('Pragma: no-cache') ;
+
+        // Set the response format.
+        header( 'Content-Type:text/xml; charset=utf-8' ) ;
+    }
+
+    /**
+     * Return XML declaration
+     *
+     * @access private
+     * @return string
+     */
+    function getXMLDeclaration()
+    {
+        return '<?xml version="1.0" encoding="utf-8"?>';
+    }
+
+    /**
+     * Send error message to the browser. If error number is set to 1, $text (custom error message) will be displayed
+     * Don't call this function directly
+     *
+     * @access public
+     * @param int $number error number
+     * @param string $text Custom error message (optional)
+     */
+    function raiseError( $number, $text = false)
+    {
+        $this->_errorNode->addAttribute("number", intval($number));
+        if (false!=$text) {
+            $this->_errorNode->addAttribute("text", $text);
+        }
+
+        echo $this->_connectorNode->asXML();
+    }
+}
\ No newline at end of file
Index: _source/plugins/filebrowser/core/connector/php/php4/ErrorHandler/Base.php
===================================================================
--- _source/plugins/filebrowser/core/connector/php/php4/ErrorHandler/Base.php	(revision 0)
+++ _source/plugins/filebrowser/core/connector/php/php4/ErrorHandler/Base.php	(revision 0)
@@ -0,0 +1,76 @@
+<?php
+/*
+* Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+* For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+/**
+ * @package CKEditor
+ * @subpackage ErrorHandler
+ */
+
+/**
+ * Basic error handler
+ *
+ * @package CKEditor
+ * @subpackage ErrorHandler
+ */
+class CKEditor_Connector_ErrorHandler_Base
+{
+    /**
+     * Try/catch emulation, if set to true, error handler will not throw any error
+     *
+     * @var boolean
+     * @access protected
+     */
+    var $_catchAllErrors = false;
+    /**
+     * Array with error numbers that should be ignored
+     *
+     * @var array[]int
+     * @access protected
+     */
+    var $_skipErrorsArray = array();
+
+    /**
+     * Set whether all errors should be ignored
+     *
+     * @param boolean $newValue
+     * @access public
+     */
+    function setCatchAllErros($newValue)
+    {
+        $this->_catchAllErrors = $newValue ? true : false;
+    }
+
+    /**
+     * Set which errors should be ignored
+     *
+     * @param array $newArray
+     */
+    function setSkipErrorsArray($newArray)
+    {
+        if (is_array($newArray)) {
+            $this->_skipErrorsArray = $newArray;
+        }
+    }
+
+    /**
+     * Throw connector error, return true if error has been thrown, false if error has been catched
+     *
+     * @param int $number
+     * @param string $text
+     * @access public
+     */
+    function throwError($number, $text = false)
+    {
+        if ($this->_catchAllErrors || in_array($number, $this->_skipErrorsArray)) {
+            return false;
+        }
+
+        $_xml =& CKEditor_Connector_Core_Factory::getInstance("Core_Xml");
+        $_xml->raiseError($number,$text);
+
+        exit;
+    }
+}
\ No newline at end of file
Index: _source/plugins/filebrowser/core/connector/php/php4/ErrorHandler/FileUpload.php
===================================================================
--- _source/plugins/filebrowser/core/connector/php/php4/ErrorHandler/FileUpload.php	(revision 0)
+++ _source/plugins/filebrowser/core/connector/php/php4/ErrorHandler/FileUpload.php	(revision 0)
@@ -0,0 +1,54 @@
+<?php
+/*
+* Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+* For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+/**
+ * @package CKEditor
+ * @subpackage ErrorHandler
+ */
+
+/**
+ * Include base error handling class
+ */
+require_once CKEDITOR_CONNECTOR_LIB_DIR . "/ErrorHandler/Base.php";
+
+/**
+ * File upload error handler
+ *
+ * @package CKEditor
+ * @subpackage ErrorHandler
+ */
+class CKEditor_Connector_ErrorHandler_FileUpload extends CKEditor_Connector_ErrorHandler_Base
+{
+    /**
+     * Throw file upload error, return true if error has been thrown, false if error has been catched
+     *
+     * @param int $number
+     * @param string $text
+     * @access public
+     */
+    function throwError($number, $text = false, $exit = true)
+    {
+        if ($this->_catchAllErrors || in_array($number, $this->_skipErrorsArray)) {
+            return false;
+        }
+
+        $oRegistry =& CKEditor_Connector_Core_Factory::getInstance("Core_Registry");
+        $sFileName = $oRegistry->get("FileUpload_fileName");
+
+        echo "<script type=\"text/javascript\">";
+        if (empty($text)) {
+            echo "window.parent.OnUploadCompleted(" . $number . ") ;";
+        }
+        else {
+            echo "window.parent.OnUploadCompleted(" . $number . ",'" . str_replace("'", "\\'", $sFileName) . "') ;";
+        }
+        echo "</script>";
+
+        if ($exit) {
+            exit;
+        }
+    }
+}
\ No newline at end of file
Index: _source/plugins/filebrowser/core/connector/php/php4/ErrorHandler/Http.php
===================================================================
--- _source/plugins/filebrowser/core/connector/php/php4/ErrorHandler/Http.php	(revision 0)
+++ _source/plugins/filebrowser/core/connector/php/php4/ErrorHandler/Http.php	(revision 0)
@@ -0,0 +1,62 @@
+<?php
+/*
+* Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+* For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+/**
+ * @package CKEditor
+ * @subpackage ErrorHandler
+ */
+
+/**
+ * Include base error handling class
+ */
+require_once CKEDITOR_CONNECTOR_LIB_DIR . "/ErrorHandler/Base.php";
+
+/**
+ * HTTP error handler
+ *
+ * @package CKEditor
+ * @subpackage ErrorHandler
+ */
+class CKEditor_Connector_ErrorHandler_Http extends CKEditor_Connector_ErrorHandler_Base
+{
+    /**
+     * Throw file upload error, return true if error has been thrown, false if error has been catched
+     *
+     * @param int $number
+     * @param string $text
+     * @access public
+     */
+    function throwError($number, $text = false, $exit = true)
+    {
+        if ($this->_catchAllErrors || in_array($number, $this->_skipErrorsArray)) {
+            return false;
+        }
+
+        switch ($number)
+        {
+            case CKEDITOR_CONNECTOR_ERROR_INVALID_REQUEST:
+            case CKEDITOR_CONNECTOR_ERROR_INVALID_NAME:
+            case CKEDITOR_CONNECTOR_ERROR_UNAUTHORIZED:
+                header("HTTP/1.0 403 Forbidden");
+                header("X-CKEditor-Error: ". $number);
+                break;
+
+            case CKEDITOR_CONNECTOR_ERROR_ACCESS_DENIED:
+                header("HTTP/1.0 500 Internal Server Error");
+                header("X-CKEditor-Error: ".$number);
+                break;
+
+            default:
+                header("HTTP/1.0 404 Not Found");
+                header("X-CKEditor-Error: ". $number);
+                break;
+        }
+
+        if ($exit) {
+            exit;
+        }
+    }
+}
\ No newline at end of file
Index: _source/plugins/filebrowser/core/connector/php/php4/ErrorHandler/QuickUpload.php
===================================================================
--- _source/plugins/filebrowser/core/connector/php/php4/ErrorHandler/QuickUpload.php	(revision 0)
+++ _source/plugins/filebrowser/core/connector/php/php4/ErrorHandler/QuickUpload.php	(revision 0)
@@ -0,0 +1,55 @@
+<?php
+/*
+* Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+* For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+/**
+ * @package CKEditor
+ * @subpackage ErrorHandler
+ */
+
+/**
+ * Include base error handling class
+ */
+require_once CKEDITOR_CONNECTOR_LIB_DIR . "/ErrorHandler/Base.php";
+
+/**
+ * File upload error handler
+ *
+ * @package CKEditor
+ * @subpackage ErrorHandler
+ */
+class CKEditor_Connector_ErrorHandler_QuickUpload extends CKEditor_Connector_ErrorHandler_Base
+{
+    /**
+     * Throw file upload error, return true if error has been thrown, false if error has been catched
+     *
+     * @param int $number
+     * @param string $text
+     * @access public
+     */
+    function throwError($number, $text = false, $exit = true)
+    {
+        if ($this->_catchAllErrors || in_array($number, $this->_skipErrorsArray)) {
+            return false;
+        }
+
+        $oRegistry =& CKEditor_Connector_Core_Factory::getInstance("Core_Registry");
+        $sFileName = $oRegistry->get("FileUpload_fileName");
+        $sFileUrl = $oRegistry->get("FileUpload_url");
+
+        echo "<script type=\"text/javascript\">";
+        if (empty($text)) {
+            echo "window.parent.OnUploadCompleted(" . $number . ", '', '', '') ;";
+        }
+        else {
+            echo "window.parent.OnUploadCompleted(" . $number . ", '" .str_replace("'", "\\'", $sFileUrl . $sFileName). "', '" . str_replace("'", "\\'", $sFileName) . "', '') ;";
+        }
+        echo "</script>";
+
+        if ($exit) {
+            exit;
+        }
+    }
+}
\ No newline at end of file
Index: _source/plugins/filebrowser/core/connector/php/php4/Utils/FileSystem.php
===================================================================
--- _source/plugins/filebrowser/core/connector/php/php4/Utils/FileSystem.php	(revision 0)
+++ _source/plugins/filebrowser/core/connector/php/php4/Utils/FileSystem.php	(revision 0)
@@ -0,0 +1,409 @@
+<?php
+/*
+* Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+* For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+/**
+ * @package CKEditor
+ * @subpackage Utils
+ */
+
+/**
+ * @package CKEditor
+ * @subpackage Utils
+ */
+class CKEditor_Connector_Utils_FileSystem
+{
+
+    /**
+     * This function behaves similar to System.IO.Path.Combine in C#, the only diffrenece is that it also accepts null values and treat them as empty string
+     *
+     * @static
+     * @access public
+     * @param string $path1 first path
+     * @param string $path2 scecond path
+     * @return string
+     */
+    function combinePaths($path1, $path2)
+    {
+        if (is_null($path1))  {
+            $path1 = "";
+        }
+        if (is_null($path2))  {
+            $path2 = "";
+        }
+        if (!strlen($path2)) {
+            if (strlen($path1)) {
+                $_lastCharP1 = substr($path1, -1, 1);
+                if ($_lastCharP1 != "/" && $_lastCharP1 != "\\") {
+                    $path1 .= DIRECTORY_SEPARATOR;
+                }
+            }
+        }
+        else {
+            $_firstCharP2 = substr($path2, 0, 1);
+            if (strlen($path1)) {
+                if (strpos($path2, $path1)===0) {
+                    return $path2;
+                }
+                $_lastCharP1 = substr($path1, -1, 1);
+                if ($_lastCharP1 != "/" && $_lastCharP1 != "\\" && $_firstCharP2 != "/" && $_firstCharP2 != "\\") {
+                    $path1 .= DIRECTORY_SEPARATOR;
+                }
+            }
+            else {
+                return $path2;
+            }
+        }
+        return $path1 . $path2;
+    }
+
+    /**
+     * Check whether $fileName is a valid file name, return true on success
+     *
+     * @static
+     * @access public
+     * @param string $fileName
+     * @return boolean
+     */
+    function checkFileName($fileName)
+    {
+        if (is_null($fileName) || !strlen($fileName) || substr($fileName,-1,1)=="." || false!==strpos($fileName, "..")) {
+            return false;
+        }
+
+        if (preg_match(",[[:cntrl:]]|[/\\:\*\?\"\<\>\|],", $fileName)) {
+            return false;
+        }
+
+        return true;
+    }
+
+    /**
+     * Unlink file/folder
+     *
+     * @static
+     * @access public
+     * @param string $path
+     * @return boolean
+     */
+    function unlink($path)
+    {
+        /*    make sure the path exists    */
+        if (!file_exists($path)) {
+            return false;
+        }
+
+        /*    If it is a file or link, just delete it    */
+        if (is_file($path) || is_link($path)) {
+            return @unlink($path);
+        }
+
+        /*    Scan the dir and recursively unlink    */
+        $files = scandir($path);
+        if ($files) {
+            foreach($files as $filename)
+            {
+                if ($filename == '.' || $filename == '..') {
+                    continue;
+                }
+                $file = str_replace('//','/',$path.'/'.$filename);
+                CKEditor_Connector_Utils_FileSystem::unlink($file);
+            }
+        }
+
+        /*    Remove the parent dir    */
+        if (!@rmdir($path)) {
+            return false;
+        }
+
+        return true;
+    }
+
+    /**
+     * Return file name without extension (without dot & last part after dot)
+     *
+     * @static
+     * @access public
+     * @param string $fileName
+     * @return string
+     */
+    function getFileNameWithoutExtension($fileName)
+    {
+        $dotPos = strrpos( $fileName, '.' );
+        if (false === $dotPos) {
+            return $fileName;
+        }
+
+        return substr($fileName, 0, $dotPos);
+    }
+
+    /**
+     * Get file extension (only last part - e.g. extension of file.foo.bar.jpg = jpg)
+     *
+     * @static
+     * @access public
+     * @param string $fileName
+     * @return string
+     */
+    function getExtension( $fileName )
+    {
+        $dotPos = strrpos( $fileName, '.' );
+        if (false === $dotPos) {
+            return "";
+        }
+
+        return substr( $fileName, strrpos( $fileName, '.' ) +1 ) ;
+    }
+
+    /**
+     * Convert file name from UTF-8 to system encoding
+     *
+     * @static
+     * @access public
+     * @param string $fileName
+     * @return string
+     */
+    function convertToFilesystemEncoding($fileName)
+    {
+        $_config =& CKEditor_Connector_Core_Factory::getInstance("Core_Config");
+        $encoding = $_config->getFilesystemEncoding();
+        if (is_null($encoding) || strcasecmp($encoding, "UTF-8") == 0 || strcasecmp($encoding, "UTF8") == 0) {
+            return $fileName;
+        }
+
+        if (!function_exists("iconv")) {
+            if (strcasecmp($encoding, "ISO-8859-1") == 0 || strcasecmp($encoding, "ISO8859-1") == 0 || strcasecmp($encoding, "Latin1") == 0) {
+                return str_replace("\0", "_", utf8_decode($fileName));
+            } else if (function_exists('mb_convert_encoding')) {
+                /**
+                 * @todo check whether charset is supported - mb_list_encodings
+                 */
+                $encoded = @mb_convert_encoding($fileName, $encoding, 'UTF-8');
+                if (@mb_strlen($fileName, "UTF-8") != @mb_strlen($encoded, $encoding)) {
+                    return str_replace("\0", "_", preg_replace("/[^[:ascii:]]/u","_",$fileName));
+                }
+                else {
+                    return str_replace("\0", "_", $encoded);
+                }
+            } else {
+                return str_replace("\0", "_", preg_replace("/[^[:ascii:]]/u","_",$fileName));
+            }
+        }
+
+        $converted = @iconv("UTF-8", $encoding . "//IGNORE//TRANSLIT", $fileName);
+        if ($converted === false) {
+            return str_replace("\0", "_", preg_replace("/[^[:ascii:]]/u","_",$fileName));
+        }
+
+        return $converted;
+    }
+
+    /**
+     * Convert file name from system encoding into UTF-8
+     *
+     * @static
+     * @access public
+     * @param string $fileName
+     * @return string
+     */
+    function convertToConnectorEncoding($fileName)
+    {
+        $_config =& CKEditor_Connector_Core_Factory::getInstance("Core_Config");
+        $encoding = $_config->getFilesystemEncoding();
+        if (is_null($encoding) || strcasecmp($encoding, "UTF-8") == 0 || strcasecmp($encoding, "UTF8") == 0) {
+            return $fileName;
+        }
+
+        if (!function_exists("iconv")) {
+            if (strcasecmp($encoding, "ISO-8859-1") == 0 || strcasecmp($encoding, "ISO8859-1") == 0 || strcasecmp($encoding, "Latin1") == 0) {
+                return utf8_encode($fileName);
+            } else {
+                return $fileName;
+            }
+        }
+
+        $converted = @iconv($encoding, "UTF-8", $fileName);
+
+        if ($converted === false) {
+            return $fileName;
+        }
+
+        return $converted;
+    }
+
+    /**
+     * Find document root
+     *
+     * @return string
+     * @access public
+     */
+    function getDocumentRootPath()
+    {
+        /**
+         * The absolute pathname of the currently executing script.
+         * If a script is executed with the CLI, as a relative path, such as file.php or ../file.php,
+         * $_SERVER['SCRIPT_FILENAME'] will contain the relative path specified by the user.
+         */
+        if (isset($_SERVER['SCRIPT_FILENAME'])) {
+            $sRealPath = dirname($_SERVER['SCRIPT_FILENAME']);
+        }
+        else {
+            /**
+             * realpath — Returns canonicalized absolute pathname
+             */
+            $sRealPath = realpath( './' ) ;
+        }
+
+        /**
+         * The filename of the currently executing script, relative to the document root.
+         * For instance, $_SERVER['PHP_SELF'] in a script at the address http://example.com/test.php/foo.bar
+         * would be /test.php/foo.bar.
+         */
+        $sSelfPath = dirname($_SERVER['PHP_SELF']);
+
+        return substr($sRealPath, 0, strlen($sRealPath) - strlen($sSelfPath));
+    }
+
+    /**
+     * Create directory recursively
+     *
+     * @access public
+     * @static
+     * @param string $dir
+     * @return boolean
+     */
+    function createDirectoryRecursively($dir)
+    {
+        if (DIRECTORY_SEPARATOR === "\\") {
+            $dir = str_replace("/", "\\", $dir);
+        }
+        else if (DIRECTORY_SEPARATOR === "/") {
+            $dir = str_replace("\\", "/", $dir);
+        }
+
+        $_config =& CKEditor_Connector_Core_Factory::getInstance("Core_Config");
+        if ($perms = $_config->getChmodFolders()) {
+            $oldUmask = umask(0);
+            $bCreated = @mkdir($dir, $perms, true);
+            umask($oldUmask);
+        }
+        else {
+            $bCreated = @mkdir($dir, 0777, true);
+        }
+
+        return $bCreated;
+    }
+
+    /**
+     * 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.
+     *
+     * @static
+     * @access public
+     * @param string $filePath absolute path to file
+     * @return boolean
+    */
+    function detectHtml($filePath)
+    {
+        $fp = @fopen($filePath, 'rb');
+        if ( $fp === false || !flock( $fp, LOCK_SH ) ) {
+            return -1 ;
+        }
+        $chunk = fread($fp, 1024);
+        flock( $fp, LOCK_UN ) ;
+        fclose($fp);
+
+        $chunk = strtolower($chunk);
+
+        if (!$chunk) {
+            return false;
+        }
+
+        $chunk = trim($chunk);
+
+        if (preg_match("/<!DOCTYPE\W*X?HTML/sim", $chunk)) {
+            return true;
+        }
+
+        $tags = array('<body', '<head', '<html', '<img', '<pre', '<script', '<table', '<title');
+
+        foreach( $tags as $tag ) {
+            if (false !== strpos($chunk, $tag)) {
+                return true ;
+            }
+        }
+
+        //type = javascript
+        if (preg_match('!type\s*=\s*[\'"]?\s*(?:\w*/)?(?:ecma|java)!sim', $chunk)) {
+            return true ;
+        }
+
+        //href = javascript
+        //src = javascript
+        //data = javascript
+        if (preg_match('!(?:href|src|data)\s*=\s*[\'"]?\s*(?:ecma|java)script:!sim',$chunk)) {
+            return true ;
+        }
+
+        //url(javascript
+        if (preg_match('!url\s*\(\s*[\'"]?\s*(?:ecma|java)script:!sim', $chunk)) {
+            return true ;
+        }
+
+        return false ;
+    }
+
+    /**
+     * Check file content.
+     * Currently this function validates only image files.
+     * Returns false if file is invalid.
+     *
+     * @static
+     * @access public
+     * @param string $filePath absolute path to file
+     * @param string $extension file extension
+     * @param integer $detectionLevel 0 = none, 1 = use getimagesize for images, 2 = use DetectHtml for images
+     * @return boolean
+    */
+    function isImageValid($filePath, $extension)
+    {
+        if (!@is_readable($filePath)) {
+            return -1;
+        }
+
+        $imageCheckExtensions = array('gif', 'jpeg', 'jpg', 'png', 'psd', 'bmp', 'tiff');
+
+        // version_compare is available since PHP4 >= 4.0.7
+        if ( function_exists( 'version_compare' ) ) {
+            $sCurrentVersion = phpversion();
+            if ( version_compare( $sCurrentVersion, "4.2.0" ) >= 0 ) {
+                $imageCheckExtensions[] = "tiff";
+                $imageCheckExtensions[] = "tif";
+            }
+            if ( version_compare( $sCurrentVersion, "4.3.0" ) >= 0 ) {
+                $imageCheckExtensions[] = "swc";
+            }
+            if ( version_compare( $sCurrentVersion, "4.3.2" ) >= 0 ) {
+                $imageCheckExtensions[] = "jpc";
+                $imageCheckExtensions[] = "jp2";
+                $imageCheckExtensions[] = "jpx";
+                $imageCheckExtensions[] = "jb2";
+                $imageCheckExtensions[] = "xbm";
+                $imageCheckExtensions[] = "wbmp";
+            }
+        }
+
+        if ( !in_array( $extension, $imageCheckExtensions ) ) {
+            return true;
+        }
+
+        if ( @getimagesize( $filePath ) === false ) {
+            return false ;
+        }
+
+        return true;
+    }
+}
Index: _source/plugins/filebrowser/core/connector/php/php4/Utils/Misc.php
===================================================================
--- _source/plugins/filebrowser/core/connector/php/php4/Utils/Misc.php	(revision 0)
+++ _source/plugins/filebrowser/core/connector/php/php4/Utils/Misc.php	(revision 0)
@@ -0,0 +1,55 @@
+<?php
+/*
+* Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+* For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+/**
+ * @package CKEditor
+ * @subpackage Utils
+ */
+
+/**
+ * @package CKEditor
+ * @subpackage Utils
+ */
+class CKEditor_Connector_Utils_Misc
+{
+    /**
+     * Convert any value to boolean, strings like "false", "FalSE" and "off" are also considered as false
+     *
+     * @static
+     * @access public
+     * @param mixed $value
+     * @return boolean
+     */
+    function booleanValue($value)
+    {
+        if (strcasecmp("false", $value) == 0 || strcasecmp("off", $value) == 0 || !$value) {
+            return false;
+        } else {
+            return true;
+        }
+    }
+
+    /**
+    * Checks if a value exists in an array (case insensitive)
+    *
+    * @static
+    * @access public
+    * @param string $needle
+    * @param array $haystack
+    * @return boolean
+    */
+    function inArrayCaseInsensitive($needle, $haystack)
+    {
+        if (!$haystack || !is_array($haystack)) {
+            return false;
+        }
+        $lcase = array();
+        foreach ($haystack as $key => $val) {
+            $lcase[$key] = strtolower($val);
+        }
+        return in_array($needle, $lcase);
+    }
+}
\ No newline at end of file
Index: _source/plugins/filebrowser/core/connector/php/php4/Utils/Security.php
===================================================================
--- _source/plugins/filebrowser/core/connector/php/php4/Utils/Security.php	(revision 0)
+++ _source/plugins/filebrowser/core/connector/php/php4/Utils/Security.php	(revision 0)
@@ -0,0 +1,65 @@
+<?php
+/*
+* Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+* For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+/**
+ * @package CKEditor
+ * @subpackage Utils
+ */
+
+/**
+ * @package CKEditor
+ * @subpackage Utils
+ */
+class CKEditor_Connector_Utils_Security
+{
+
+    /**
+     * Strip quotes from global arrays
+     * @access public
+     */
+    function getRidOfMagicQuotes()
+    {
+        if (CKEDITOR_CONNECTOR_PHP_MODE<6 && get_magic_quotes_gpc()) {
+            if (!empty($_GET)) {
+                $this->stripQuotes($_GET);
+            }
+            if (!empty($_POST)) {
+                $this->stripQuotes($_POST);
+            }
+            if (!empty($_COOKIE)) {
+                $this->stripQuotes($_COOKIE);
+            }
+            if (!empty($_FILES)) {
+                while (list($k,$v) = each($_FILES)) {
+                    if (isset($_FILES[$k]['name'])) {
+                        $this->stripQuotes($_FILES[$k]['name']);
+                    }
+                }
+            }
+        }
+    }
+
+    /**
+     * Strip quotes from variable
+     *
+     * @access public
+     * @param mixed $var
+     * @param int $depth current depth
+     * @param int $howDeep maximum depth
+     */
+    function stripQuotes(&$var, $depth=0, $howDeep=5)
+    {
+        if (is_array($var)) {
+            if ($depth++<$howDeep) {
+                while (list($k,$v) = each($var)) {
+                    $this->stripQuotes($var[$k], $depth, $howDeep);
+                }
+            }
+        } else {
+            $var = stripslashes($var);
+        }
+    }
+}
Index: _source/plugins/filebrowser/core/connector/php/php4/Utils/XmlNode.php
===================================================================
--- _source/plugins/filebrowser/core/connector/php/php4/Utils/XmlNode.php	(revision 0)
+++ _source/plugins/filebrowser/core/connector/php/php4/Utils/XmlNode.php	(revision 0)
@@ -0,0 +1,129 @@
+<?php
+/*
+* Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+* For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+/**
+ * @package CKEditor
+ * @subpackage Utils
+ */
+
+/**
+ * Simple class which provides some basic API for creating XML nodes and adding attributes
+ *
+ * @package CKEditor
+ * @subpackage Utils
+ */
+class CKEditor_Connector_Utils_XmlNode
+{
+    /**
+     * Array that stores XML attributes
+     *
+     * @access private
+     * @var array
+     */
+    var $_attributes = array();
+    /**
+     * Array that stores child nodes
+     *
+     * @access private
+     * @var array
+     */
+    var $_childNodes = array();
+    /**
+     * Node name
+     *
+     * @access private
+     * @var string
+     */
+    var $_name;
+    /**
+     * Node value
+     *
+     * @access private
+     * @var string
+     */
+    var $_value;
+
+    /**
+     * Create new node
+     *
+     * @param string $nodeName node name
+     * @param string $nodeValue node value
+     * @return CKEditor_Connector_Utils_XmlNode
+     */
+    function CKEditor_Connector_Utils_XmlNode($nodeName, $nodeValue = null)
+    {
+        $this->_name = $nodeName;
+        if (!is_null($nodeValue)) {
+            $this->_value = $nodeValue;
+        }
+    }
+
+    /**
+     * Add attribute
+     *
+     * @param string $name
+     * @param string $value
+     * @access public
+     */
+    function addAttribute($name, $value)
+    {
+        $this->_attributes[$name] = $value;
+    }
+
+    /**
+     * Adds new child at the end of the children
+     *
+     * @param CKEditor_Connector_Utils_XmlNode $node
+     * @access public
+     */
+    function addChild(&$node)
+    {
+        $this->_childNodes[] =& $node;
+    }
+
+    /**
+     * Return a well-formed XML string based on CKEditor_Connector_Utils_XmlNode element
+     *
+     * @return string
+     * @access public
+     */
+    function asXML()
+    {
+        $ret = "<" . $this->_name;
+
+        //print Attributes
+        if (sizeof($this->_attributes)>0) {
+            foreach ($this->_attributes as $_name => $_value) {
+                $ret .= " " . $_name . '="' . htmlspecialchars($_value) . '"';
+            }
+        }
+
+        //if there is nothing more todo, close empty tag and exit
+        if (is_null($this->_value) && !sizeof($this->_childNodes)) {
+            $ret .= " />";
+            return $ret;
+        }
+
+        //close opening tag
+        $ret .= ">";
+
+        //print value
+        if (!is_null($this->_value)) {
+            $ret .= htmlspecialchars($this->_value);
+        }
+
+        //print child nodes
+        if (sizeof($this->_childNodes)>0) {
+            foreach ($this->_childNodes as $_node) {
+                $ret .= $_node->asXml();
+            }
+        }
+
+        $ret .= "</" . $this->_name . ">";
+
+        return $ret;
+    }
+}
\ No newline at end of file
Index: _source/plugins/filebrowser/core/connector/php/php5/CommandHandler/CommandHandlerBase.php
===================================================================
--- _source/plugins/filebrowser/core/connector/php/php5/CommandHandler/CommandHandlerBase.php	(revision 0)
+++ _source/plugins/filebrowser/core/connector/php/php5/CommandHandler/CommandHandlerBase.php	(revision 0)
@@ -0,0 +1,110 @@
+<?php
+/*
+* Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+* For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+/**
+ * @package CKEditor
+ * @subpackage CommandHandlers
+ */
+
+/**
+ * Base commands handler
+ *
+ * @package CKEditor
+ * @subpackage CommandHandlers
+ * @abstract
+ */
+class CKEditor_Connector_CommandHandler_CommandHandlerBase
+{
+    /**
+     * CKEditor_Connector_Core_Connector object
+     *
+     * @access protected
+     * @var CKEditor_Connector_Core_Connector
+     */
+    protected $_connector;
+    /**
+     * CKEditor_Connector_Core_FolderHandler object
+     *
+     * @access protected
+     * @var CKEditor_Connector_Core_FolderHandler
+     */
+    protected $_currentFolder;
+    /**
+     * Error handler object
+     *
+     * @access protected
+     * @var CKEditor_Connector_ErrorHandler_Base|CKEditor_Connector_ErrorHandler_FileUpload|CKEditor_Connector_ErrorHandler_Http
+     */
+    protected $_errorHandler;
+
+    function __construct()
+    {
+        $this->_currentFolder =& CKEditor_Connector_Core_Factory::getInstance("Core_FolderHandler");
+        $this->_connector =& CKEditor_Connector_Core_Factory::getInstance("Core_Connector");
+        $this->_errorHandler =& $this->_connector->getErrorHandler();
+    }
+
+    /**
+     * Get Folder Handler
+     *
+     * @access public
+     * @return CKEditor_Connector_Core_FolderHandler
+     */
+    public function getFolderHandler()
+    {
+        if (is_null($this->_currentFolder)) {
+            $this->_currentFolder =& CKEditor_Connector_Core_Factory::getInstance("Core_FolderHandler");
+        }
+
+        return $this->_currentFolder;
+    }
+
+    /**
+     * Check whether Connector is enabled
+     * @access protected
+     *
+     */
+    protected function checkConnector()
+    {
+        $_config =& CKEditor_Connector_Core_Factory::getInstance("Core_Config");
+        if (!$_config->getIsEnabled()) {
+            $this->_errorHandler->throwError(CKEDITOR_CONNECTOR_ERROR_CONNECTOR_DISABLED);
+        }
+    }
+
+    /**
+     * Check request
+     * @access protected
+     *
+     */
+    protected function checkRequest()
+    {
+        if (preg_match(",(/\.)|[[:cntrl:]]|(//)|(\\\\)|([\:\*\?\"\<\>\|]),", $this->_currentFolder->getClientPath())) {
+            $this->_errorHandler->throwError(CKEDITOR_CONNECTOR_ERROR_INVALID_NAME);
+        }
+
+        $_resourceTypeConfig = $this->_currentFolder->getResourceTypeConfig();
+
+        if (is_null($_resourceTypeConfig)) {
+            $this->_errorHandler->throwError(CKEDITOR_CONNECTOR_ERROR_INVALID_TYPE);
+        }
+
+        $_clientPath = $this->_currentFolder->getClientPath();
+
+        if (!is_dir($this->_currentFolder->getServerPath())) {
+            if ($_clientPath == "/") {
+                if (!CKEditor_Connector_Utils_FileSystem::createDirectoryRecursively($this->_currentFolder->getServerPath())) {
+                    /**
+                     * @todo handle error
+                     */
+                }
+            }
+            else {
+                $this->_errorHandler->throwError(CKEDITOR_CONNECTOR_ERROR_FOLDER_NOT_FOUND);
+            }
+        }
+    }
+}
\ No newline at end of file
Index: _source/plugins/filebrowser/core/connector/php/php5/CommandHandler/CreateFolder.php
===================================================================
--- _source/plugins/filebrowser/core/connector/php/php5/CommandHandler/CreateFolder.php	(revision 0)
+++ _source/plugins/filebrowser/core/connector/php/php5/CommandHandler/CreateFolder.php	(revision 0)
@@ -0,0 +1,78 @@
+<?php
+/*
+* Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+* For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+/**
+ * @package CKEditor
+ * @subpackage CommandHandlers
+ */
+
+/**
+ * Include base XML command handler
+ */
+require_once CKEDITOR_CONNECTOR_LIB_DIR . "/CommandHandler/XmlCommandHandlerBase.php";
+
+/**
+ * Handle CreateFolder command
+ *
+ * @package CKEditor
+ * @subpackage CommandHandlers
+ */
+class CKEditor_Connector_CommandHandler_CreateFolder extends CKEditor_Connector_CommandHandler_XmlCommandHandlerBase
+{
+    /**
+     * Command name
+     *
+     * @access private
+     * @var string
+     */
+    private $command = "CreateFolder";
+
+    /**
+     * handle request and build XML
+     * @access protected
+     *
+     */
+    protected function buildXml()
+    {
+        $_config =& CKEditor_Connector_Core_Factory::getInstance("Core_Config");
+
+        $_resourceTypeConfig = $this->_currentFolder->getResourceTypeConfig();
+        $sNewFolderName = isset($_POST["newFolderName"]) ? $_POST["newFolderName"] : "";
+        $sNewFolderName = CKEditor_Connector_Utils_FileSystem::convertToFilesystemEncoding($sNewFolderName);
+
+        if (!CKEditor_Connector_Utils_FileSystem::checkFileName($sNewFolderName)) {
+            $this->_errorHandler->throwError(CKEDITOR_CONNECTOR_ERROR_INVALID_NAME);
+        }
+
+        $sServerDir = CKEditor_Connector_Utils_FileSystem::combinePaths($this->_currentFolder->getServerPath(), $sNewFolderName);
+        if (!is_writeable($this->_currentFolder->getServerPath())) {
+            $this->_errorHandler->throwError(CKEDITOR_CONNECTOR_ERROR_ACCESS_DENIED);
+        }
+
+        $bCreated = false;
+
+        if (file_exists($sServerDir)) {
+            $this->_errorHandler->throwError(CKEDITOR_CONNECTOR_ERROR_ALREADY_EXIST);
+        }
+
+        if ($perms = $_config->getChmodFolders()) {
+            $oldUmask = umask(0);
+            $bCreated = @mkdir($sServerDir, $perms);
+            umask($oldUmask);
+        }
+        else {
+            $bCreated = @mkdir($sServerDir);
+        }
+
+        if (!$bCreated) {
+            $this->_errorHandler->throwError(CKEDITOR_CONNECTOR_ERROR_ACCESS_DENIED);
+        } else {
+            $oNewFolderNode = new CKEditor_Connector_Utils_XmlNode("NewFolder");
+            $this->_connectorNode->addChild($oNewFolderNode);
+            $oNewFolderNode->addAttribute("name", CKEditor_Connector_Utils_FileSystem::convertToConnectorEncoding($sNewFolderName));
+        }
+    }
+}
\ No newline at end of file
Index: _source/plugins/filebrowser/core/connector/php/php5/CommandHandler/FileUpload.php
===================================================================
--- _source/plugins/filebrowser/core/connector/php/php5/CommandHandler/FileUpload.php	(revision 0)
+++ _source/plugins/filebrowser/core/connector/php/php5/CommandHandler/FileUpload.php	(revision 0)
@@ -0,0 +1,151 @@
+<?php
+/*
+* Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+* For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+/**
+ * @package CKEditor
+ * @subpackage CommandHandlers
+ */
+
+/**
+ * Handle FileUpload command
+ *
+ * @package CKEditor
+ * @subpackage CommandHandlers
+ */
+class CKEditor_Connector_CommandHandler_FileUpload extends CKEditor_Connector_CommandHandler_CommandHandlerBase
+{
+    /**
+     * Command name
+     *
+     * @access protected
+     * @var string
+     */
+    protected $command = "FileUpload";
+
+    /**
+     * send response (save uploaded file)
+     * @access public
+     *
+     */
+    public function sendResponse()
+    {
+        $iErrorNumber = CKEDITOR_CONNECTOR_ERROR_NONE;
+
+        $oRegistry =& CKEditor_Connector_Core_Factory::getInstance("Core_Registry");
+        $oRegistry->set("FileUpload_fileName", "unknown file");
+
+        $uploadedFile = array_shift($_FILES);
+
+        if (!isset($uploadedFile['name'])) {
+            $this->_errorHandler->throwError(CKEDITOR_CONNECTOR_ERROR_UPLOADED_INVALID);
+        }
+
+        $sFileName = CKEditor_Connector_Utils_FileSystem::convertToFilesystemEncoding(basename($uploadedFile['name']));
+        $oRegistry->set("FileUpload_fileName", $sFileName);
+
+        $this->checkConnector();
+        $this->checkRequest();
+
+        if (!CKEditor_Connector_Utils_FileSystem::checkFileName($sFileName)) {
+            $this->_errorHandler->throwError(CKEDITOR_CONNECTOR_ERROR_INVALID_NAME);
+        }
+
+        $_config =& CKEditor_Connector_Core_Factory::getInstance("Core_Config");
+        $_resourceTypeConfig = $this->_currentFolder->getResourceTypeConfig();
+
+        $resourceTypeInfo = $this->_currentFolder->getResourceTypeConfig();
+        if (!$resourceTypeInfo->checkExtension($sFileName)) {
+            $this->_errorHandler->throwError(CKEDITOR_CONNECTOR_ERROR_INVALID_EXTENSION);
+        }
+
+        $sFileNameOrginal = $sFileName;
+        $oRegistry->set("FileUpload_fileName", $sFileName);
+
+        $htmlExtensions = $_config->getHtmlExtensions();
+        $sExtension = CKEditor_Connector_Utils_FileSystem::getExtension($sFileNameOrginal);
+
+        if ($htmlExtensions
+        && !CKEditor_Connector_Utils_Misc::inArrayCaseInsensitive($sExtension, $htmlExtensions)
+        && ($detectHtml = CKEditor_Connector_Utils_FileSystem::detectHtml($uploadedFile['tmp_name'])) === true ) {
+            $this->_errorHandler->throwError(CKEDITOR_CONNECTOR_ERROR_UPLOADED_WRONG_HTML_FILE);
+        }
+
+        $sExtension = CKEditor_Connector_Utils_FileSystem::getExtension($sFileNameOrginal);
+        $secureImageUploads = $_config->getSecureImageUploads();
+        if ($secureImageUploads
+        && ($isImageValid = CKEditor_Connector_Utils_FileSystem::isImageValid($uploadedFile['tmp_name'], $sExtension)) === false ) {
+            $this->_errorHandler->throwError(CKEDITOR_CONNECTOR_ERROR_UPLOADED_CORRUPT);
+        }
+
+        switch ($uploadedFile['error']) {
+            case UPLOAD_ERR_OK:
+                break;
+
+            case UPLOAD_ERR_INI_SIZE:
+            case UPLOAD_ERR_FORM_SIZE:
+                $this->_errorHandler->throwError(CKEDITOR_CONNECTOR_ERROR_UPLOADED_TOO_BIG);
+                break;
+
+            case UPLOAD_ERR_PARTIAL:
+            case UPLOAD_ERR_NO_FILE:
+                $this->_errorHandler->throwError(CKEDITOR_CONNECTOR_ERROR_UPLOADED_CORRUPT);
+                break;
+
+            case UPLOAD_ERR_NO_TMP_DIR:
+                $this->_errorHandler->throwError(CKEDITOR_CONNECTOR_ERROR_UPLOADED_NO_TMP_DIR);
+                break;
+
+            case UPLOAD_ERR_CANT_WRITE:
+                $this->_errorHandler->throwError(CKEDITOR_CONNECTOR_ERROR_ACCESS_DENIED);
+                break;
+
+            case UPLOAD_ERR_EXTENSION:
+                $this->_errorHandler->throwError(CKEDITOR_CONNECTOR_ERROR_ACCESS_DENIED);
+                break;
+        }
+
+        $sServerDir = $this->_currentFolder->getServerPath();
+        $iCounter = 0;
+
+        while (true)
+        {
+            $sFilePath = CKEditor_Connector_Utils_FileSystem::combinePaths($sServerDir, $sFileName);
+
+            if (file_exists($sFilePath)) {
+                $iCounter++;
+                $sFileName =
+                CKEditor_Connector_Utils_FileSystem::getFileNameWithoutExtension($sFileNameOrginal) .
+                "(" . $iCounter . ")" . "." .
+                CKEditor_Connector_Utils_FileSystem::getExtension($sFileNameOrginal);
+                $oRegistry->set("FileUpload_fileName", $sFileName);
+
+                $iErrorNumber = CKEDITOR_CONNECTOR_ERROR_UPLOADED_FILE_RENAMED;
+            } else {
+                if (false === move_uploaded_file($uploadedFile['tmp_name'], $sFilePath)) {
+                    $iErrorNumber = CKEDITOR_CONNECTOR_ERROR_ACCESS_DENIED;
+                }
+                else {
+                    if (isset($detectHtml) && $detectHtml === -1 && CKEditor_Connector_Utils_FileSystem::detectHtml($sFilePath) === true) {
+                        @unlink($sFilePath);
+                        $this->_errorHandler->throwError(CKEDITOR_CONNECTOR_ERROR_UPLOADED_WRONG_HTML_FILE);
+                    }
+                    else if (isset($isImageValid) && $isImageValid === -1 && CKEditor_Connector_Utils_FileSystem::isImageValid($sFilePath, $sExtension) === false) {
+                        @unlink($sFilePath);
+                        $this->_errorHandler->throwError(CKEDITOR_CONNECTOR_ERROR_UPLOADED_CORRUPT);
+                    }
+                }
+                if (is_file($sFilePath) && ($perms = $_config->getChmodFiles())) {
+                    $oldumask = umask(0);
+                    chmod($sFilePath, $perms);
+                    umask($oldumask);
+                }
+                break;
+            }
+        }
+
+        $this->_errorHandler->throwError($iErrorNumber, $sFileName, false);
+    }
+}
Index: _source/plugins/filebrowser/core/connector/php/php5/CommandHandler/GetFolders.php
===================================================================
--- _source/plugins/filebrowser/core/connector/php/php5/CommandHandler/GetFolders.php	(revision 0)
+++ _source/plugins/filebrowser/core/connector/php/php5/CommandHandler/GetFolders.php	(revision 0)
@@ -0,0 +1,80 @@
+<?php
+/*
+* Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+* For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+/**
+ * @package CKEditor
+ * @subpackage CommandHandlers
+ */
+
+/**
+ * Include base XML command handler
+ */
+require_once CKEDITOR_CONNECTOR_LIB_DIR . "/CommandHandler/XmlCommandHandlerBase.php";
+
+/**
+ * Handle GetFolders command
+ *
+ * @package CKEditor
+ * @subpackage CommandHandlers
+ */
+class CKEditor_Connector_CommandHandler_GetFolders extends CKEditor_Connector_CommandHandler_XmlCommandHandlerBase
+{
+    /**
+     * Command name
+     *
+     * @access private
+     * @var string
+     */
+    private $command = "GetFolders";
+
+    /**
+     * handle request and build XML
+     * @access protected
+     *
+     */
+    protected function buildXml()
+    {
+        $_config =& CKEditor_Connector_Core_Factory::getInstance("Core_Config");
+
+        // Map the virtual path to the local server path.
+        $_sServerDir = $this->_currentFolder->getServerPath();
+
+        if (!is_dir($_sServerDir)) {
+            $this->_errorHandler->throwError(CKEDITOR_CONNECTOR_ERROR_FOLDER_NOT_FOUND);
+        }
+
+        // Create the "Folders" node.
+        $oFoldersNode = new CKEditor_Connector_Utils_XmlNode("Folders");
+        $this->_connectorNode->addChild($oFoldersNode);
+
+        $files = array();
+        if ($dh = @opendir($_sServerDir)) {
+            while (($file = readdir($dh)) !== false) {
+                if ($file != "." && $file != ".." && is_dir($_sServerDir . $file)) {
+                    $files[] = $file;
+                }
+            }
+            closedir($dh);
+        } else {
+            $this->_errorHandler->throwError(CKEDITOR_CONNECTOR_ERROR_ACCESS_DENIED);
+        }
+
+        $resourceTypeInfo = $this->_currentFolder->getResourceTypeConfig();
+
+        if (sizeof($files)>0) {
+            natcasesort($files);
+            $i=0;
+            foreach ($files as $file) {
+                // Create the "Folder" node.
+                $oFolderNode[$i] = new CKEditor_Connector_Utils_XmlNode("Folder");
+                $oFoldersNode->addChild($oFolderNode[$i]);
+                $oFolderNode[$i]->addAttribute("name", CKEditor_Connector_Utils_FileSystem::convertToConnectorEncoding($file));
+
+                $i++;
+            }
+        }
+    }
+}
Index: _source/plugins/filebrowser/core/connector/php/php5/CommandHandler/GetFoldersAndFiles.php
===================================================================
--- _source/plugins/filebrowser/core/connector/php/php5/CommandHandler/GetFoldersAndFiles.php	(revision 0)
+++ _source/plugins/filebrowser/core/connector/php/php5/CommandHandler/GetFoldersAndFiles.php	(revision 0)
@@ -0,0 +1,122 @@
+<?php
+/*
+* Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+* For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+/**
+ * @package CKEditor
+ * @subpackage CommandHandlers
+ */
+
+/**
+ * Include base XML command handler
+ */
+require_once CKEDITOR_CONNECTOR_LIB_DIR . "/CommandHandler/XmlCommandHandlerBase.php";
+
+/**
+ * Handle GetFiles command
+ *
+ * @package CKEditor
+ * @subpackage CommandHandlers
+ */
+class CKEditor_Connector_CommandHandler_GetFoldersAndFiles extends CKEditor_Connector_CommandHandler_XmlCommandHandlerBase
+{
+    /**
+     * Command name
+     *
+     * @access private
+     * @var string
+     */
+    private $command = "GetFiles";
+
+    /**
+     * handle request and build XML
+     * @access protected
+     *
+     */
+    protected function buildXml()
+    {
+        $_config =& CKEditor_Connector_Core_Factory::getInstance("Core_Config");
+
+        // Map the virtual path to the local server path.
+        $_sServerDir = $this->_currentFolder->getServerPath();
+
+        $files = array();
+        $folders = array();
+        if ($dh = @opendir($_sServerDir)) {
+            while (($file = readdir($dh)) !== false) {
+                if ($file == "." || $file == "..") {
+                    continue;
+                }
+                else if (!is_dir($_sServerDir . $file)) {
+                    $files[] = $file;
+                }
+                else {
+                    $folders[] = $file;
+                }
+            }
+            closedir($dh);
+        }
+        else {
+            $this->_errorHandler->throwError(CKEDITOR_CONNECTOR_ERROR_ACCESS_DENIED);
+        }
+
+        // Create the "Folders" node.
+        $oFoldersNode = new CKEditor_Connector_Utils_XmlNode("Folders");
+        $this->_connectorNode->addChild($oFoldersNode);
+
+
+        $resourceTypeInfo = $this->_currentFolder->getResourceTypeConfig();
+
+        if (sizeof($folders)>0) {
+            natcasesort($folders);
+            $i=0;
+            foreach ($folders as $file) {
+                // Create the "Folder" node.
+                $oFolderNode[$i] = new CKEditor_Connector_Utils_XmlNode("Folder");
+                $oFoldersNode->addChild($oFolderNode[$i]);
+                $oFolderNode[$i]->addAttribute("name", CKEditor_Connector_Utils_FileSystem::convertToConnectorEncoding($file));
+
+                $i++;
+            }
+        }
+
+        // Create the "Files" node.
+        $oFilesNode = new CKEditor_Connector_Utils_XmlNode("Files");
+        $this->_connectorNode->addChild($oFilesNode);
+
+        if (!is_dir($_sServerDir)) {
+            $this->_errorHandler->throwError(CKEDITOR_CONNECTOR_ERROR_FOLDER_NOT_FOUND);
+        }
+
+        if (sizeof($files)>0) {
+            natcasesort($files);
+            $i=0;
+            foreach ($files as $file) {
+                $filemtime = @filemtime($_sServerDir . $file);
+
+                //otherwise file doesn't exist or we can't get it's filename properly
+                if ($filemtime !== false) {
+                    $filename = basename($file);
+                    if (!$resourceTypeInfo->checkExtension($filename, false)) {
+                        continue;
+                    }
+                    $oFileNode[$i] = new CKEditor_Connector_Utils_XmlNode("File");
+                    $oFilesNode->addChild($oFileNode[$i]);
+                    $oFileNode[$i]->addAttribute("name", CKEditor_Connector_Utils_FileSystem::convertToConnectorEncoding(basename($file)));
+                    $oFileNode[$i]->addAttribute("date", @date("YmdHi", $filemtime));
+                    $size = filesize($_sServerDir . $file);
+                    if ($size && $size<1024) {
+                        $size = 1;
+                    }
+                    else {
+                        $size = (int)round($size / 1024);
+                    }
+                    $oFileNode[$i]->addAttribute("size", $size);
+                    $i++;
+                }
+            }
+        }
+    }
+}
Index: _source/plugins/filebrowser/core/connector/php/php5/CommandHandler/Init.php
===================================================================
--- _source/plugins/filebrowser/core/connector/php/php5/CommandHandler/Init.php	(revision 0)
+++ _source/plugins/filebrowser/core/connector/php/php5/CommandHandler/Init.php	(revision 0)
@@ -0,0 +1,97 @@
+<?php
+/*
+* Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+* For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+/**
+ * @package CKEditor
+ * @subpackage CommandHandlers
+ */
+
+/**
+ * Include base XML command handler
+ */
+require_once CKEDITOR_CONNECTOR_LIB_DIR . "/CommandHandler/XmlCommandHandlerBase.php";
+
+/**
+ * Handle Init command
+ *
+ * @package CKEditor
+ * @subpackage CommandHandlers
+ */
+class CKEditor_Connector_CommandHandler_Init extends CKEditor_Connector_CommandHandler_XmlCommandHandlerBase
+{
+    /**
+     * Command name
+     *
+     * @access private
+     * @var string
+     */
+    private $command = "Init";
+
+    protected function mustCheckRequest()
+    {
+        return false;
+    }
+
+    /**
+     * Must add CurrentFolder node?
+     *
+     * @return boolean
+     * @access protected
+     */
+    protected function mustAddCurrentFolderNode()
+    {
+        return false;
+    }
+
+    /**
+     * handle request and build XML
+     * @access protected
+     *
+     */
+    protected function buildXml()
+    {
+        $_config =& CKEditor_Connector_Core_Factory::getInstance("Core_Config");
+
+        // Create the "ConnectorInfo" node.
+        $_oConnInfo = new CKEditor_Connector_Utils_XmlNode("ConnectorInfo");
+        $this->_connectorNode->addChild($_oConnInfo);
+        $_oConnInfo->addAttribute("enabled", $_config->getIsEnabled() ? "true" : "false");
+
+        if (!$_config->getIsEnabled()) {
+            $this->_errorHandler->throwError(CKEDITOR_CONNECTOR_ERROR_CONNECTOR_DISABLED);
+        }
+
+        // Create the "ResourceTypes" node.
+        $_oResourceTypes = new CKEditor_Connector_Utils_XmlNode("ResourceTypes");
+        $this->_connectorNode->addChild($_oResourceTypes);
+
+        // Load the resource types in an array.
+        $_aTypes = $_config->getDefaultResourceTypes();
+
+        if (!sizeof($_aTypes)) {
+            $_aTypes = $_config->getResourceTypeNames();
+        }
+
+        $_aTypesSize = sizeof($_aTypes);
+        if ($_aTypesSize) {
+            for ($i = 0; $i < $_aTypesSize; $i++)
+            {
+                $_resourceTypeName = $_aTypes[$i];
+
+                if (!isset($_GET['type']) || $_GET['type'] === $_resourceTypeName) {
+                    $_oTypeInfo = $_config->getResourceTypeConfig($_resourceTypeName);
+                    $_oResourceType[$i] = new CKEditor_Connector_Utils_XmlNode("ResourceType");
+                    $_oResourceTypes->addChild($_oResourceType[$i]);
+
+                    $_oResourceType[$i]->addAttribute("name", $_resourceTypeName);
+                    $_oResourceType[$i]->addAttribute("url", $_oTypeInfo->getUrl());
+                    $_oResourceType[$i]->addAttribute("allowedExtensions", implode(",", $_oTypeInfo->getAllowedExtensions()));
+                    $_oResourceType[$i]->addAttribute("deniedExtensions", implode(",", $_oTypeInfo->getDeniedExtensions()));
+                }
+            }
+        }
+    }
+}
Index: _source/plugins/filebrowser/core/connector/php/php5/CommandHandler/QuickUpload.php
===================================================================
--- _source/plugins/filebrowser/core/connector/php/php5/CommandHandler/QuickUpload.php	(revision 0)
+++ _source/plugins/filebrowser/core/connector/php/php5/CommandHandler/QuickUpload.php	(revision 0)
@@ -0,0 +1,40 @@
+<?php
+/*
+* Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+* For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+/**
+ * @package CKEditor
+ * @subpackage CommandHandlers
+ */
+
+/**
+ * Include file upload command handler
+ */
+require_once CKEDITOR_CONNECTOR_LIB_DIR . "/CommandHandler/FileUpload.php";
+
+/**
+ * Handle QuickUpload command
+ *
+ * @package CKEditor
+ * @subpackage CommandHandlers
+ */
+class CKEditor_Connector_CommandHandler_QuickUpload extends CKEditor_Connector_CommandHandler_FileUpload
+{
+    /**
+     * Command name
+     *
+     * @access protected
+     * @var string
+     */
+    protected $command = "QuickUpload";
+
+    function sendResponse()
+    {
+        $oRegistry =& CKEditor_Connector_Core_Factory::getInstance("Core_Registry");
+        $oRegistry->set("FileUpload_url", $this->_currentFolder->getUrl());
+
+        return parent::sendResponse();
+    }
+}
Index: _source/plugins/filebrowser/core/connector/php/php5/CommandHandler/XmlCommandHandlerBase.php
===================================================================
--- _source/plugins/filebrowser/core/connector/php/php5/CommandHandler/XmlCommandHandlerBase.php	(revision 0)
+++ _source/plugins/filebrowser/core/connector/php/php5/CommandHandler/XmlCommandHandlerBase.php	(revision 0)
@@ -0,0 +1,106 @@
+<?php
+/*
+* Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+* For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+/**
+ * @package CKEditor
+ * @subpackage CommandHandlers
+ */
+
+/**
+ * Include base command handler
+ */
+require_once CKEDITOR_CONNECTOR_LIB_DIR . "/CommandHandler/CommandHandlerBase.php";
+/**
+ * Include xml utils
+ */
+require_once CKEDITOR_CONNECTOR_LIB_DIR . "/Core/Xml.php";
+
+/**
+ * Base XML commands handler
+ *
+ * @package CKEditor
+ * @subpackage CommandHandlers
+ * @abstract
+ */
+abstract class CKEditor_Connector_CommandHandler_XmlCommandHandlerBase extends CKEditor_Connector_CommandHandler_CommandHandlerBase
+{
+    /**
+     * Connector node - CKEditor_Connector_Utils_XmlNode object
+     *
+     * @var CKEditor_Connector_Utils_XmlNode
+     * @access protected
+     */
+    protected $_connectorNode;
+
+    /**
+     * send response
+     * @access public
+     *
+     */
+    public function sendResponse()
+    {
+        $xml =& CKEditor_Connector_Core_Factory::getInstance("Core_Xml");
+        $this->_connectorNode =& $xml->getConnectorNode();
+
+        $this->checkConnector();
+        if ($this->mustCheckRequest()) {
+            $this->checkRequest();
+        }
+
+        $resourceTypeName = $this->_currentFolder->getResourceTypeName();
+        if (!empty($resourceTypeName)) {
+            $this->_connectorNode->addAttribute("resourceType", $this->_currentFolder->getResourceTypeName());
+        }
+
+        if ($this->mustAddCurrentFolderNode()) {
+            $_currentFolder = new CKEditor_Connector_Utils_XmlNode("CurrentFolder");
+            $this->_connectorNode->addChild($_currentFolder);
+            $_currentFolder->addAttribute("path", CKEditor_Connector_Utils_FileSystem::convertToConnectorEncoding($this->_currentFolder->getClientPath()));
+
+            $this->_errorHandler->setCatchAllErros(true);
+            $_url = $this->_currentFolder->getUrl();
+            $_currentFolder->addAttribute("url", is_null($_url) ? "" : CKEditor_Connector_Utils_FileSystem::convertToConnectorEncoding($_url));
+            $this->_errorHandler->setCatchAllErros(false);
+        }
+
+        $this->buildXml();
+
+        $_oErrorNode =& $xml->getErrorNode();
+        $_oErrorNode->addAttribute("number", "0");
+
+        echo $this->_connectorNode->asXML();
+        exit;
+    }
+
+    /**
+     * Must check request?
+     *
+     * @return boolean
+     * @access protected
+     */
+    protected function mustCheckRequest()
+    {
+        return true;
+    }
+
+    /**
+     * Must add CurrentFolder node?
+     *
+     * @return boolean
+     * @access protected
+     */
+    protected function mustAddCurrentFolderNode()
+    {
+        return true;
+    }
+
+    /**
+     * @access protected
+     * @abstract
+     * @return void
+     */
+    abstract protected function buildXml();
+}
Index: _source/plugins/filebrowser/core/connector/php/php5/Core/Config.php
===================================================================
--- _source/plugins/filebrowser/core/connector/php/php5/Core/Config.php	(revision 0)
+++ _source/plugins/filebrowser/core/connector/php/php5/Core/Config.php	(revision 0)
@@ -0,0 +1,273 @@
+<?php
+/*
+* Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+* For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+/**
+ * @package CKEditor
+ * @subpackage Config
+ */
+
+/**
+ * Include resource type config class
+ */
+require_once CKEDITOR_CONNECTOR_LIB_DIR . "/Core/ResourceTypeConfig.php";
+
+/**
+ * Main config parser
+ *
+ *
+ * @package CKEditor
+ * @subpackage Config
+
+ * @global string $GLOBALS['config']
+ */
+class CKEditor_Connector_Core_Config
+{
+    /**
+     * Is CKEditor enabled
+     *
+     * @var boolean
+     * @access private
+     */
+    private $_isEnabled = false;
+    /**
+     * ResourceType config cache
+     *
+     * @var array
+     * @access private
+     */
+    private $_resourceTypeConfigCache = array();
+    /**
+     * Array with default resource types names
+     *
+     * @access private
+     * @var array
+     */
+    private $_defaultResourceTypes = array();
+    /**
+     * Filesystem encoding
+     *
+     * @var string
+     * @access private
+     */
+    private $_filesystemEncoding;
+    /**
+     * Check double extension
+     *
+     * @var boolean
+     * @access private
+     */
+    private $_checkDoubleExtension = true;
+    /**
+     * If set to true, validate image size
+     *
+     * @var boolean
+     * @access private
+     */
+    private $_secureImageUploads = true;
+    /**
+     * For security, HTML is allowed in the first Kb of data for files having the following extensions only
+     *
+     * @var array
+     * @access private
+     */
+    private $_htmlExtensions = array('html', 'htm', 'xml', 'xsd', 'txt', 'js');
+    /**
+     * Chmod files after upload to the following permission
+     *
+     * @var integer
+     * @access private
+     */
+    private $_chmodFiles = 0777;
+    /**
+     * Chmod directories after creation
+     *
+     * @var integer
+     * @access private
+     */
+    private $_chmodFolders = 0755;
+
+    function __construct()
+    {
+        $this->loadValues();
+    }
+
+    /**
+	 * Get file system encoding, returns null if encoding is not set
+	 *
+	 * @access public
+	 * @return string
+	 */
+    public function getFilesystemEncoding()
+    {
+        return $this->_filesystemEncoding;
+    }
+
+    /**
+	 * Get "secureImageUploads" value
+	 *
+	 * @access public
+	 * @return boolean
+	 */
+    public function getSecureImageUploads()
+    {
+        return $this->_secureImageUploads;
+    }
+
+    /**
+	 * Get "htmlExtensions" value
+	 *
+	 * @access public
+	 * @return array
+	 */
+    public function getHtmlExtensions()
+    {
+        return $this->_htmlExtensions;
+    }
+
+    /**
+	 * Get "Check double extension" value
+	 *
+	 * @access public
+	 * @return boolean
+	 */
+    public function getCheckDoubleExtension()
+    {
+        return $this->_checkDoubleExtension;
+    }
+
+    /**
+	 * Get default resource types
+	 *
+	 * @access public
+	 * @return array()
+	 */
+    public function getDefaultResourceTypes()
+    {
+        return $this->_defaultResourceTypes;
+    }
+
+    /**
+	 * Is CKEditor enabled
+	 *
+	 * @access public
+	 * @return boolean
+	 */
+    public function getIsEnabled()
+    {
+        return $this->_isEnabled;
+    }
+
+    /**
+	* Get chmod settings for uploaded files
+	*
+	* @access public
+	* @return integer
+	*/
+    public function getChmodFiles()
+    {
+        return $this->_chmodFiles;
+    }
+
+    /**
+	* Get chmod settings for created directories
+	*
+	* @access public
+	* @return integer
+	*/
+    public function getChmodFolders()
+    {
+        return $this->_chmodFolders;
+    }
+
+    /**
+	 * Get resourceTypeName config
+	 *
+	 * @param string $resourceTypeName
+	 * @return CKEditor_Connector_Core_ResourceTypeConfig|null
+	 * @access public
+	 */
+    public function &getResourceTypeConfig($resourceTypeName)
+    {
+        $_null = null;
+
+        if (isset($this->_resourceTypeConfigCache[$resourceTypeName])) {
+            return $this->_resourceTypeConfigCache[$resourceTypeName];
+        }
+
+        if (!isset($GLOBALS['config']['ResourceType']) || !is_array($GLOBALS['config']['ResourceType'])) {
+            return $_null;
+        }
+
+        reset($GLOBALS['config']['ResourceType']);
+        while (list($_key,$_resourceTypeNode) = each($GLOBALS['config']['ResourceType'])) {
+            if ($_resourceTypeNode['name'] === $resourceTypeName) {
+                $this->_resourceTypeConfigCache[$resourceTypeName] = new CKEditor_Connector_Core_ResourceTypeConfig($_resourceTypeNode);
+
+                return $this->_resourceTypeConfigCache[$resourceTypeName];
+            }
+        }
+
+        return $_null;
+    }
+
+    /**
+     * Load values from config
+     *
+     * @access private
+     */
+    private function loadValues()
+    {
+        if (function_exists('CheckAuthentication')) {
+            $this->_isEnabled = CheckAuthentication();
+        }
+        if (isset($GLOBALS['config']['FilesystemEncoding'])) {
+            $this->_filesystemEncoding = (string)$GLOBALS['config']['FilesystemEncoding'];
+        }
+        if (isset($GLOBALS['config']['CheckDoubleExtension'])) {
+            $this->_checkDoubleExtension = CKEditor_Connector_Utils_Misc::booleanValue($GLOBALS['config']['CheckDoubleExtension']);
+        }
+        if (isset($GLOBALS['config']['SecureImageUploads'])) {
+            $this->_secureImageUploads = CKEditor_Connector_Utils_Misc::booleanValue($GLOBALS['config']['SecureImageUploads']);
+        }
+        if (isset($GLOBALS['config']['HtmlExtensions'])) {
+            $this->_htmlExtensions = (array)$GLOBALS['config']['HtmlExtensions'];
+        }
+        if (isset($GLOBALS['config']['ChmodFiles'])) {
+            $this->_chmodFiles = $GLOBALS['config']['ChmodFiles'];
+        }
+        if (isset($GLOBALS['config']['ChmodFolders'])) {
+            $this->_chmodFolders = $GLOBALS['config']['ChmodFolders'];
+        }
+        if (isset($GLOBALS['config']['DefaultResourceTypes'])) {
+            $_defaultResourceTypes = (string)$GLOBALS['config']['DefaultResourceTypes'];
+            if (strlen($_defaultResourceTypes)) {
+                $this->_defaultResourceTypes = explode(",", $_defaultResourceTypes);
+            }
+        }
+    }
+
+    /**
+     * Get all resource type names defined in config
+     *
+     * @return array
+     * @access public
+     */
+    public function getResourceTypeNames()
+    {
+        if (!isset($GLOBALS['config']['ResourceType']) || !is_array($GLOBALS['config']['ResourceType'])) {
+            return array();
+        }
+
+        $_names = array();
+        foreach ($GLOBALS['config']['ResourceType'] as $key => $_resourceType) {
+            if (isset($_resourceType['name'])) {
+                $_names[] = (string)$_resourceType['name'];
+            }
+        }
+
+        return $_names;
+    }
+}
\ No newline at end of file
Index: _source/plugins/filebrowser/core/connector/php/php5/Core/Connector.php
===================================================================
--- _source/plugins/filebrowser/core/connector/php/php5/Core/Connector.php	(revision 0)
+++ _source/plugins/filebrowser/core/connector/php/php5/Core/Connector.php	(revision 0)
@@ -0,0 +1,93 @@
+<?php
+/*
+* Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+* For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+/**
+ * @package CKEditor
+ * @subpackage Core
+ */
+
+/**
+ * Executes all commands
+ *
+ * @package CKEditor
+ * @subpackage Core
+ */
+class CKEditor_Connector_Core_Connector
+{
+    /**
+     * Registry
+     *
+     * @var CKEditor_Connector_Core_Registry
+     * @access private
+     */
+    private $_registry;
+
+    function __construct()
+    {
+        $this->_registry =& CKEditor_Connector_Core_Factory::getInstance("Core_Registry");
+        $this->_registry->set("errorHandler", "ErrorHandler_Base");
+    }
+
+    /**
+     * Generic handler for invalid commands
+     * @access public
+     *
+     */
+    public function handleInvalidCommand()
+    {
+        $oErrorHandler =& $this->getErrorHandler();
+        $oErrorHandler->throwError(CKEDITOR_CONNECTOR_ERROR_INVALID_COMMAND);
+    }
+
+    /**
+     * Execute command
+     *
+     * @param string $command
+     * @access public
+     */
+    public function executeCommand($command)
+    {
+        switch ($command)
+        {
+            case 'FileUpload':
+                $this->_registry->set("errorHandler", "ErrorHandler_FileUpload");
+                $obj =& CKEditor_Connector_Core_Factory::getInstance("CommandHandler_".$command);
+                $obj->sendResponse();
+                break;
+
+            case 'QuickUpload':
+                $this->_registry->set("errorHandler", "ErrorHandler_QuickUpload");
+                $obj =& CKEditor_Connector_Core_Factory::getInstance("CommandHandler_".$command);
+                $obj->sendResponse();
+                break;
+
+            case 'CreateFolder':
+            case 'GetFolders':
+            case 'GetFoldersAndFiles':
+            case 'Init':
+                $obj =& CKEditor_Connector_Core_Factory::getInstance("CommandHandler_".$command);
+                $obj->sendResponse();
+                break;
+
+            default:
+                $this->handleInvalidCommand();
+                break;
+        }
+    }
+
+    /**
+     * Get error handler
+     *
+     * @access public
+     * @return CKEditor_Connector_ErrorHandler_Base|CKEditor_Connector_ErrorHandler_FileUpload|CKEditor_Connector_ErrorHandler_Http
+     */
+    public function &getErrorHandler()
+    {
+        $_errorHandler = $this->_registry->get("errorHandler");
+        $oErrorHandler =& CKEditor_Connector_Core_Factory::getInstance($_errorHandler);
+        return $oErrorHandler;
+    }
+}
\ No newline at end of file
Index: _source/plugins/filebrowser/core/connector/php/php5/Core/Factory.php
===================================================================
--- _source/plugins/filebrowser/core/connector/php/php5/Core/Factory.php	(revision 0)
+++ _source/plugins/filebrowser/core/connector/php/php5/Core/Factory.php	(revision 0)
@@ -0,0 +1,58 @@
+<?php
+/*
+* Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+* For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+/**
+ * @package CKEditor
+ * @subpackage Core
+ */
+
+/**
+ * Sigleton factory creating objects
+ *
+ * @package CKEditor
+ * @subpackage Core
+ */
+class CKEditor_Connector_Core_Factory
+{
+    static $instances = array();
+
+    /**
+     * Initiate factory
+     * @static
+     */
+    static function initFactory()
+    {
+    }
+
+    /**
+     * Get instance of specified class
+     * Short and Long class names are possible
+     * <code>
+     * $obj1 =& CKEditor_Connector_Core_Factory::getInstance("CKEditor_Connector_Core_Xml");
+     * $obj2 =& CKEditor_Connector_Core_Factory::getInstance("Core_Xml");
+     * </code>
+     *
+     * @param string $className class name
+     * @static
+     * @access public
+     * @return object
+     */
+    public static function &getInstance($className)
+    {
+        $namespace = "CKEditor_Connector_";
+
+        $baseName = str_replace($namespace,"",$className);
+
+        $className = $namespace.$baseName;
+
+        if (!isset(CKEditor_Connector_Core_Factory::$instances[$className])) {
+            require_once CKEDITOR_CONNECTOR_LIB_DIR . "/" . str_replace("_","/",$baseName).".php";
+            CKEditor_Connector_Core_Factory::$instances[$className] = new $className;
+        }
+
+        return CKEditor_Connector_Core_Factory::$instances[$className];
+    }
+}
\ No newline at end of file
Index: _source/plugins/filebrowser/core/connector/php/php5/Core/FolderHandler.php
===================================================================
--- _source/plugins/filebrowser/core/connector/php/php5/Core/FolderHandler.php	(revision 0)
+++ _source/plugins/filebrowser/core/connector/php/php5/Core/FolderHandler.php	(revision 0)
@@ -0,0 +1,172 @@
+<?php
+/*
+* Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+* For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+/**
+ * @package CKEditor
+ * @subpackage Core
+ */
+
+/**
+ * Include file system utils class
+ */
+require_once CKEDITOR_CONNECTOR_LIB_DIR . "/Utils/FileSystem.php";
+
+/**
+ * @package CKEditor
+ * @subpackage Core
+ */
+class CKEditor_Connector_Core_FolderHandler
+{
+    /**
+     * CKEditor_Connector_Core_ResourceTypeConfig object
+     *
+     * @var CKEditor_Connector_Core_ResourceTypeConfig
+     * @access private
+     */
+    private $_resourceTypeConfig;
+    /**
+     * ResourceType name
+     *
+     * @var string
+     * @access private
+     */
+    private $_resourceTypeName = "";
+    /**
+     * Client path
+     *
+     * @var string
+     * @access private
+     */
+    private $_clientPath = "/";
+    /**
+     * Url
+     *
+     * @var string
+     * @access private
+     */
+    private $_url;
+    /**
+     * Server path
+     *
+     * @var string
+     * @access private
+     */
+    private $_serverPath;
+    /**
+     * Folder info
+     *
+     * @var mixed
+     * @access private
+     */
+    private $_folderInfo;
+
+    function __construct()
+    {
+        if (isset($_GET["type"])) {
+            $this->_resourceTypeName = (string)$_GET["type"];
+        }
+
+        if (isset($_GET["currentFolder"])) {
+            $this->_clientPath = CKEditor_Connector_Utils_FileSystem::convertToFilesystemEncoding((string)$_GET["currentFolder"]);
+        }
+
+        if (!strlen($this->_clientPath)) {
+            $this->_clientPath = "/";
+        }
+        else {
+            if (substr($this->_clientPath, -1, 1) != "/") {
+                $this->_clientPath .= "/";
+            }
+            if (substr($this->_clientPath, 0, 1) != "/") {
+                $this->_clientPath = "/" . $this->_clientPath;
+            }
+        }
+    }
+
+    /**
+     * Get resource type config
+     *
+     * @return CKEditor_Connector_Core_ResourceTypeConfig
+     * @access public
+     */
+    public function &getResourceTypeConfig()
+    {
+        if (!isset($this->_resourceTypeConfig)) {
+            $_config =& CKEditor_Connector_Core_Factory::getInstance("Core_Config");
+            $this->_resourceTypeConfig = $_config->getResourceTypeConfig($this->_resourceTypeName);
+        }
+
+        if (is_null($this->_resourceTypeConfig)) {
+            $connector =& CKEditor_Connector_Core_Factory::getInstance("Core_Connector");
+            $oErrorHandler =& $connector->getErrorHandler();
+            $oErrorHandler->throwError(CKEDITOR_CONNECTOR_ERROR_INVALID_TYPE);
+        }
+
+        return $this->_resourceTypeConfig;
+    }
+
+    /**
+     * Get resource type name
+     *
+     * @return string
+     * @access public
+     */
+    public function getResourceTypeName()
+    {
+        return $this->_resourceTypeName;
+    }
+
+    /**
+     * Get Client path
+     *
+     * @return string
+     * @access public
+     */
+    public function getClientPath()
+    {
+        return $this->_clientPath;
+    }
+
+    /**
+     * Get Url
+     *
+     * @return string
+     * @access public
+     */
+    public function getUrl()
+    {
+        if (is_null($this->_url)) {
+            $this->_resourceTypeConfig = $this->getResourceTypeConfig();
+            if (is_null($this->_resourceTypeConfig)) {
+                $connector =& CKEditor_Connector_Core_Factory::getInstance("Core_Connector");
+                $oErrorHandler =& $connector->getErrorHandler();
+                $oErrorHandler->throwError(CKEDITOR_CONNECTOR_ERROR_INVALID_TYPE);
+                $this->_url = "";
+            }
+            else {
+                $this->_url = $this->_resourceTypeConfig->getUrl() . ltrim($this->getClientPath(), "/");
+            }
+        }
+
+        return $this->_url;
+    }
+
+    /**
+     * Get server path
+     *
+     * @return string
+     * @access public
+     */
+    public function getServerPath()
+    {
+        if (is_null($this->_serverPath)) {
+            $this->_resourceTypeConfig = $this->getResourceTypeConfig();
+            $this->_serverPath = CKEditor_Connector_Utils_FileSystem::combinePaths($this->_resourceTypeConfig->getDirectory(), ltrim($this->_clientPath, "/"));
+        }
+
+        return $this->_serverPath;
+    }
+}
\ No newline at end of file
Index: _source/plugins/filebrowser/core/connector/php/php5/Core/Registry.php
===================================================================
--- _source/plugins/filebrowser/core/connector/php/php5/Core/Registry.php	(revision 0)
+++ _source/plugins/filebrowser/core/connector/php/php5/Core/Registry.php	(revision 0)
@@ -0,0 +1,65 @@
+<?php
+/*
+* Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+* For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+/**
+ * @package CKEditor
+ * @subpackage Core
+ */
+
+/**
+ * Registry for storing global variables values (not references)
+ *
+ * @package CKEditor
+ * @subpackage Core
+ */
+class CKEditor_Connector_Core_Registry
+{
+    /**
+     * Arrat that stores all values
+     *
+     * @var array
+     * @access private
+     */
+    private $_store = array();
+
+    /**
+     * Chacke if value has been set
+     *
+     * @param string $key
+     * @return boolean
+     * @access private
+     */
+    private function isValid($key)
+    {
+        return array_key_exists($key, $this->_store);
+    }
+
+    /**
+     * Set value
+     *
+     * @param string $key
+     * @param mixed $obj
+     * @access public
+     */
+    public function set($key, $obj)
+    {
+        $this->_store[$key] = $obj;
+    }
+
+    /**
+     * Get value
+     *
+     * @param string $key
+     * @return mixed
+     * @access public
+     */
+    public function get($key)
+    {
+        if ($this->isValid($key)) {
+            return $this->_store[$key];
+        }
+    }
+}
\ No newline at end of file
Index: _source/plugins/filebrowser/core/connector/php/php5/Core/ResourceTypeConfig.php
===================================================================
--- _source/plugins/filebrowser/core/connector/php/php5/Core/ResourceTypeConfig.php	(revision 0)
+++ _source/plugins/filebrowser/core/connector/php/php5/Core/ResourceTypeConfig.php	(revision 0)
@@ -0,0 +1,253 @@
+<?php
+/*
+* Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+* For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+/**
+ * @package CKEditor
+ * @subpackage Config
+ */
+
+/**
+ * This class keeps resource types configuration
+ *
+ * @package CKEditor
+ * @subpackage Config
+ */
+class CKEditor_Connector_Core_ResourceTypeConfig
+{
+    /**
+     * Resource name
+     *
+     * @var string
+     * @access private
+     */
+    private $_name = "";
+    /**
+     * Resource url
+     *
+     * @var string
+     * @access private
+     */
+    private $_url = "";
+    /**
+     * Directory path on a server
+     *
+     * @var string
+     * @access private
+     */
+    private $_directory = "";
+    /**
+     * Array with allowed extensions
+     *
+     * @var array[]string
+     * @access private
+     */
+    private $_allowedExtensions = array();
+    /**
+     * Array with denied extensions
+     *
+     * @var array[]string
+     * @access private
+     */
+    private $_deniedExtensions = array();
+    /**
+     * used for CKEditor_Connector_Core_Config object caching
+     *
+     * @var CKEditor_Connector_Core_Config
+     * @access private
+     */
+    private $_config;
+
+    /**
+     * Get ResourceType configuration
+     *
+     * @param string $resourceTypeNode
+     * @return array
+     *
+     */
+    function __construct($resourceTypeNode)
+    {
+        if (isset($resourceTypeNode["name"])) {
+            $this->_name = $resourceTypeNode["name"];
+        }
+
+        if (isset($resourceTypeNode["url"])) {
+            $this->_url = $resourceTypeNode["url"];
+        }
+
+        if (!strlen($this->_url)) {
+            $this->_url = "/";
+        }
+        else if (substr($this->_url,-1,1) != "/") {
+            $this->_url .= "/";
+        }
+
+        if (isset($resourceTypeNode["directory"])) {
+            $this->_directory = $resourceTypeNode["directory"];
+        }
+
+        if (!strlen($this->_directory)) {
+            $this->_directory = resolveUrl($this->_url);
+        }
+
+        if (isset($resourceTypeNode["allowedExtensions"])) {
+            if (is_array($resourceTypeNode["allowedExtensions"])) {
+                foreach ($resourceTypeNode["allowedExtensions"] as $extension) {
+                    $this->_allowedExtensions[] = strtolower(trim((string)$e));
+                }
+            }
+            else {
+                $resourceTypeNode["allowedExtensions"] = trim((string)$resourceTypeNode["allowedExtensions"]);
+                if (strlen($resourceTypeNode["allowedExtensions"])) {
+                    $extensions = explode(",", $resourceTypeNode["allowedExtensions"]);
+                    foreach ($extensions as $e) {
+                        $this->_allowedExtensions[] = strtolower(trim($e));
+                    }
+                }
+            }
+        }
+
+        if (isset($resourceTypeNode["deniedExtensions"])) {
+            if (is_array($resourceTypeNode["deniedExtensions"])) {
+
+                foreach ($resourceTypeNode["deniedExtensions"] as $extension) {
+                    $this->_deniedExtensions[] = strtolower(trim((string)$e));
+                }
+            }
+            else {
+                $resourceTypeNode["deniedExtensions"] = trim((string)$resourceTypeNode["deniedExtensions"]);
+                if (strlen($resourceTypeNode["deniedExtensions"])) {
+                    $extensions = explode(",", $resourceTypeNode["deniedExtensions"]);
+                    foreach ($extensions as $e) {
+                        $this->_deniedExtensions[] = strtolower(trim($e));
+                    }
+                }
+            }
+        }
+    }
+
+    /**
+     * Get name
+     *
+     * @access public
+     * @return string
+     */
+    public function getName()
+    {
+        return $this->_name;
+    }
+
+    /**
+     * Get url
+     *
+     * @access public
+     * @return string
+     */
+    public function getUrl()
+    {
+        return $this->_url;
+    }
+
+    /**
+     * Get directory
+     *
+     * @access public
+     * @return string
+     */
+    public function getDirectory()
+    {
+        return $this->_directory;
+    }
+
+    /**
+     * Get allowed extensions
+     *
+     * @access public
+     * @return array[]string
+     */
+    public function getAllowedExtensions()
+    {
+        return $this->_allowedExtensions;
+    }
+
+    /**
+     * Get denied extensions
+     *
+     * @access public
+     * @return array[]string
+     */
+    public function getDeniedExtensions()
+    {
+        return $this->_deniedExtensions;
+    }
+
+    /**
+     * Check extension, return true if file name is valid.
+     * Return false if extension is on denied list.
+     * If allowed extensions are defined, return false if extension isn't on allowed list.
+     *
+     * @access public
+     * @param string $extension extension
+     * @param boolean $renameIfRequired whether try to rename file or not
+     * @return boolean
+     */
+    public function checkExtension(&$fileName, $renameIfRequired = true)
+    {
+        if (strpos($fileName, '.') === false) {
+            return true;
+        }
+
+        if (is_null($this->_config)) {
+            $this->_config =& CKEditor_Connector_Core_Factory::getInstance("Core_Config");
+        }
+
+        $toCheck = array();
+
+        if ($this->_config->getCheckDoubleExtension()) {
+            $pieces = explode('.', $fileName);
+
+            // First, check the last extension (ex. in file.php.jpg, the "jpg").
+            if ( !$this->checkSingleExtension( $pieces[sizeof($pieces)-1] ) ) {
+                return false;
+            }
+
+            if ($renameIfRequired) {
+                // Check the other extensions, rebuilding the file name. If an extension is
+                // not allowed, replace the dot with an underscore.
+                $fileName = $pieces[0] ;
+                for ($i=1; $i<sizeof($pieces)-1; $i++) {
+                    $fileName .= $this->checkSingleExtension( $pieces[$i] ) ? '.' : '_' ;
+                    $fileName .= $pieces[$i];
+                }
+
+                // Add the last extension to the final name.
+                $fileName .= '.' . $pieces[sizeof($pieces)-1] ;
+            }
+        }
+        else {
+            // Check only the last extension (ex. in file.php.jpg, only "jpg").
+            return $this->checkSingleExtension( substr($fileName, strrpos($fileName,'.')+1) );
+        }
+
+        return true;
+    }
+
+    public function checkSingleExtension($extension)
+    {
+        $extension = strtolower(ltrim($extension,'.'));
+
+        if (sizeof($this->_deniedExtensions)) {
+            if (in_array($extension, $this->_deniedExtensions)) {
+                return false;
+            }
+        }
+
+        if (sizeof($this->_allowedExtensions)) {
+            return in_array($extension, $this->_allowedExtensions);
+        }
+
+        return true;
+    }
+}
Index: _source/plugins/filebrowser/core/connector/php/php5/Core/Xml.php
===================================================================
--- _source/plugins/filebrowser/core/connector/php/php5/Core/Xml.php	(revision 0)
+++ _source/plugins/filebrowser/core/connector/php/php5/Core/Xml.php	(revision 0)
@@ -0,0 +1,120 @@
+<?php
+/*
+* Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+* For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+/**
+ * @package CKEditor
+ * @subpackage Core
+ */
+
+/**
+ * Include basic Xml library
+ */
+require_once CKEDITOR_CONNECTOR_LIB_DIR . "/Utils/XmlNode.php";
+
+/**
+ * XML document
+ *
+ * @package CKEditor
+ * @subpackage Core
+ */
+class CKEditor_Connector_Core_Xml
+{
+    /**
+     * Connector node (root)
+     *
+     * @var CKEditor_Connector_Utils_XmlNode
+     * @access private
+     */
+    private $_connectorNode;
+    /**
+     * Error node
+     *
+     * @var CKEditor_Connector_Utils_XmlNode
+     * @access private
+     */
+    private $_errorNode;
+
+    function __construct()
+    {
+        $this->sendXmlHeaders();
+        echo $this->getXMLDeclaration();
+        $this->_connectorNode = new CKEditor_Connector_Utils_XmlNode("Connector");
+        $this->_errorNode = new CKEditor_Connector_Utils_XmlNode("Error");
+        $this->_connectorNode->addChild($this->_errorNode);
+    }
+
+    /**
+     * Return connector node
+     *
+     * @return CKEditor_Connector_Utils_XmlNode
+     * @access public
+     */
+    public function &getConnectorNode()
+    {
+        return $this->_connectorNode;
+    }
+
+    /**
+     * Return error node
+     *
+     * @return CKEditor_Connector_Utils_XmlNode
+     * @access public
+     */
+    public function &getErrorNode()
+    {
+        return $this->_errorNode;
+    }
+
+    /**
+     * Send XML headers to the browser (and force browser not to use cache)
+     * @access private
+     */
+    private function sendXmlHeaders()
+    {
+        // Prevent the browser from caching the result.
+        // Date in the past
+        header('Expires: Mon, 26 Jul 1997 05:00:00 GMT') ;
+        // always modified
+        header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT') ;
+        // HTTP/1.1
+        header('Cache-Control: no-store, no-cache, must-revalidate') ;
+        header('Cache-Control: post-check=0, pre-check=0', false) ;
+        // HTTP/1.0
+        header('Pragma: no-cache') ;
+
+        // Set the response format.
+        header( 'Content-Type:text/xml; charset=utf-8' ) ;
+    }
+
+    /**
+     * Return XML declaration
+     *
+     * @access private
+     * @return string
+     */
+    private function getXMLDeclaration()
+    {
+        return '<?xml version="1.0" encoding="utf-8"?>';
+    }
+
+    /**
+     * Send error message to the browser. If error number is set to 1, $text (custom error message) will be displayed
+     * Don't call this function directly
+     *
+     * @access public
+     * @param int $number error number
+     * @param string $text Custom error message (optional)
+     */
+    public function raiseError( $number, $text = false)
+    {
+        $this->_errorNode->addAttribute("number", intval($number));
+        if (false!=$text) {
+            $this->_errorNode->addAttribute("text", $text);
+        }
+
+        echo $this->_connectorNode->asXML();
+    }
+}
\ No newline at end of file
Index: _source/plugins/filebrowser/core/connector/php/php5/ErrorHandler/Base.php
===================================================================
--- _source/plugins/filebrowser/core/connector/php/php5/ErrorHandler/Base.php	(revision 0)
+++ _source/plugins/filebrowser/core/connector/php/php5/ErrorHandler/Base.php	(revision 0)
@@ -0,0 +1,76 @@
+<?php
+/*
+* Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+* For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+/**
+ * @package CKEditor
+ * @subpackage ErrorHandler
+ */
+
+/**
+ * Basic error handler
+ *
+ * @package CKEditor
+ * @subpackage ErrorHandler
+ */
+class CKEditor_Connector_ErrorHandler_Base
+{
+    /**
+     * Try/catch emulation, if set to true, error handler will not throw any error
+     *
+     * @var boolean
+     * @access protected
+     */
+    protected $_catchAllErrors = false;
+    /**
+     * Array with error numbers that should be ignored
+     *
+     * @var array[]int
+     * @access protected
+     */
+    protected $_skipErrorsArray = array();
+
+    /**
+     * Set whether all errors should be ignored
+     *
+     * @param boolean $newValue
+     * @access public
+     */
+    public function setCatchAllErros($newValue)
+    {
+        $this->_catchAllErrors = $newValue ? true : false;
+    }
+
+    /**
+     * Set which errors should be ignored
+     *
+     * @param array $newArray
+     */
+    public function setSkipErrorsArray($newArray)
+    {
+        if (is_array($newArray)) {
+            $this->_skipErrorsArray = $newArray;
+        }
+    }
+
+    /**
+     * Throw connector error, return true if error has been thrown, false if error has been catched
+     *
+     * @param int $number
+     * @param string $text
+     * @access public
+     */
+    public function throwError($number, $text = false)
+    {
+        if ($this->_catchAllErrors || in_array($number, $this->_skipErrorsArray)) {
+            return false;
+        }
+
+        $_xml =& CKEditor_Connector_Core_Factory::getInstance("Core_Xml");
+        $_xml->raiseError($number,$text);
+
+        exit;
+    }
+}
\ No newline at end of file
Index: _source/plugins/filebrowser/core/connector/php/php5/ErrorHandler/FileUpload.php
===================================================================
--- _source/plugins/filebrowser/core/connector/php/php5/ErrorHandler/FileUpload.php	(revision 0)
+++ _source/plugins/filebrowser/core/connector/php/php5/ErrorHandler/FileUpload.php	(revision 0)
@@ -0,0 +1,54 @@
+<?php
+/*
+* Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+* For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+/**
+ * @package CKEditor
+ * @subpackage ErrorHandler
+ */
+
+/**
+ * Include base error handling class
+ */
+require_once CKEDITOR_CONNECTOR_LIB_DIR . "/ErrorHandler/Base.php";
+
+/**
+ * File upload error handler
+ *
+ * @package CKEditor
+ * @subpackage ErrorHandler
+ */
+class CKEditor_Connector_ErrorHandler_FileUpload extends CKEditor_Connector_ErrorHandler_Base
+{
+    /**
+     * Throw file upload error, return true if error has been thrown, false if error has been catched
+     *
+     * @param int $number
+     * @param string $text
+     * @access public
+     */
+    public function throwError($number, $text = false, $exit = true)
+    {
+        if ($this->_catchAllErrors || in_array($number, $this->_skipErrorsArray)) {
+            return false;
+        }
+
+        $oRegistry =& CKEditor_Connector_Core_Factory::getInstance("Core_Registry");
+        $sFileName = $oRegistry->get("FileUpload_fileName");
+
+        echo "<script type=\"text/javascript\">";
+        if (empty($text)) {
+            echo "window.parent.OnUploadCompleted(" . $number . ") ;";
+        }
+        else {
+            echo "window.parent.OnUploadCompleted(" . $number . ",'" . str_replace("'", "\\'", $sFileName) . "') ;";
+        }
+        echo "</script>";
+
+        if ($exit) {
+            exit;
+        }
+    }
+}
\ No newline at end of file
Index: _source/plugins/filebrowser/core/connector/php/php5/ErrorHandler/Http.php
===================================================================
--- _source/plugins/filebrowser/core/connector/php/php5/ErrorHandler/Http.php	(revision 0)
+++ _source/plugins/filebrowser/core/connector/php/php5/ErrorHandler/Http.php	(revision 0)
@@ -0,0 +1,62 @@
+<?php
+/*
+* Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+* For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+/**
+ * @package CKEditor
+ * @subpackage ErrorHandler
+ */
+
+/**
+ * Include base error handling class
+ */
+require_once CKEDITOR_CONNECTOR_LIB_DIR . "/ErrorHandler/Base.php";
+
+/**
+ * HTTP error handler
+ *
+ * @package CKEditor
+ * @subpackage ErrorHandler
+ */
+class CKEditor_Connector_ErrorHandler_Http extends CKEditor_Connector_ErrorHandler_Base
+{
+    /**
+     * Throw file upload error, return true if error has been thrown, false if error has been catched
+     *
+     * @param int $number
+     * @param string $text
+     * @access public
+     */
+    public function throwError($number, $text = false, $exit = true)
+    {
+        if ($this->_catchAllErrors || in_array($number, $this->_skipErrorsArray)) {
+            return false;
+        }
+
+        switch ($number)
+        {
+            case CKEDITOR_CONNECTOR_ERROR_INVALID_REQUEST:
+            case CKEDITOR_CONNECTOR_ERROR_INVALID_NAME:
+            case CKEDITOR_CONNECTOR_ERROR_UNAUTHORIZED:
+                header("HTTP/1.0 403 Forbidden");
+                header("X-CKEditor-Error: ". $number);
+                break;
+
+            case CKEDITOR_CONNECTOR_ERROR_ACCESS_DENIED:
+                header("HTTP/1.0 500 Internal Server Error");
+                header("X-CKEditor-Error: ".$number);
+                break;
+
+            default:
+                header("HTTP/1.0 404 Not Found");
+                header("X-CKEditor-Error: ". $number);
+                break;
+        }
+
+        if ($exit) {
+            exit;
+        }
+    }
+}
\ No newline at end of file
Index: _source/plugins/filebrowser/core/connector/php/php5/ErrorHandler/QuickUpload.php
===================================================================
--- _source/plugins/filebrowser/core/connector/php/php5/ErrorHandler/QuickUpload.php	(revision 0)
+++ _source/plugins/filebrowser/core/connector/php/php5/ErrorHandler/QuickUpload.php	(revision 0)
@@ -0,0 +1,55 @@
+<?php
+/*
+* Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+* For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+/**
+ * @package CKEditor
+ * @subpackage ErrorHandler
+ */
+
+/**
+ * Include base error handling class
+ */
+require_once CKEDITOR_CONNECTOR_LIB_DIR . "/ErrorHandler/Base.php";
+
+/**
+ * File upload error handler
+ *
+ * @package CKEditor
+ * @subpackage ErrorHandler
+ */
+class CKEditor_Connector_ErrorHandler_QuickUpload extends CKEditor_Connector_ErrorHandler_Base
+{
+    /**
+     * Throw file upload error, return true if error has been thrown, false if error has been catched
+     *
+     * @param int $number
+     * @param string $text
+     * @access public
+     */
+    public function throwError($number, $text = false, $exit = true)
+    {
+        if ($this->_catchAllErrors || in_array($number, $this->_skipErrorsArray)) {
+            return false;
+        }
+
+        $oRegistry =& CKEditor_Connector_Core_Factory::getInstance("Core_Registry");
+        $sFileName = $oRegistry->get("FileUpload_fileName");
+        $sFileUrl = $oRegistry->get("FileUpload_url");
+
+        echo "<script type=\"text/javascript\">";
+        if (empty($text)) {
+            echo "window.parent.OnUploadCompleted(" . $number . ", '', '', '') ;";
+        }
+        else {
+            echo "window.parent.OnUploadCompleted(" . $number . ", '" .str_replace("'", "\\'", $sFileUrl . $sFileName). "', '" . str_replace("'", "\\'", $sFileName) . "', '') ;";
+        }
+        echo "</script>";
+
+        if ($exit) {
+            exit;
+        }
+    }
+}
\ No newline at end of file
Index: _source/plugins/filebrowser/core/connector/php/php5/Utils/FileSystem.php
===================================================================
--- _source/plugins/filebrowser/core/connector/php/php5/Utils/FileSystem.php	(revision 0)
+++ _source/plugins/filebrowser/core/connector/php/php5/Utils/FileSystem.php	(revision 0)
@@ -0,0 +1,409 @@
+<?php
+/*
+* Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+* For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+/**
+ * @package CKEditor
+ * @subpackage Utils
+ */
+
+/**
+ * @package CKEditor
+ * @subpackage Utils
+ */
+class CKEditor_Connector_Utils_FileSystem
+{
+
+    /**
+     * This function behaves similar to System.IO.Path.Combine in C#, the only diffrenece is that it also accepts null values and treat them as empty string
+     *
+     * @static
+     * @access public
+     * @param string $path1 first path
+     * @param string $path2 scecond path
+     * @return string
+     */
+    public static function combinePaths($path1, $path2)
+    {
+        if (is_null($path1))  {
+            $path1 = "";
+        }
+        if (is_null($path2))  {
+            $path2 = "";
+        }
+        if (!strlen($path2)) {
+            if (strlen($path1)) {
+                $_lastCharP1 = substr($path1, -1, 1);
+                if ($_lastCharP1 != "/" && $_lastCharP1 != "\\") {
+                    $path1 .= DIRECTORY_SEPARATOR;
+                }
+            }
+        }
+        else {
+            $_firstCharP2 = substr($path2, 0, 1);
+            if (strlen($path1)) {
+                if (strpos($path2, $path1)===0) {
+                    return $path2;
+                }
+                $_lastCharP1 = substr($path1, -1, 1);
+                if ($_lastCharP1 != "/" && $_lastCharP1 != "\\" && $_firstCharP2 != "/" && $_firstCharP2 != "\\") {
+                    $path1 .= DIRECTORY_SEPARATOR;
+                }
+            }
+            else {
+                return $path2;
+            }
+        }
+        return $path1 . $path2;
+    }
+
+    /**
+     * Check whether $fileName is a valid file name, return true on success
+     *
+     * @static
+     * @access public
+     * @param string $fileName
+     * @return boolean
+     */
+    public static function checkFileName($fileName)
+    {
+        if (is_null($fileName) || !strlen($fileName) || substr($fileName,-1,1)=="." || false!==strpos($fileName, "..")) {
+            return false;
+        }
+
+        if (preg_match(",[[:cntrl:]]|[/\\:\*\?\"\<\>\|],", $fileName)) {
+            return false;
+        }
+
+        return true;
+    }
+
+    /**
+     * Unlink file/folder
+     *
+     * @static
+     * @access public
+     * @param string $path
+     * @return boolean
+     */
+    public static function unlink($path)
+    {
+        /*    make sure the path exists    */
+        if (!file_exists($path)) {
+            return false;
+        }
+
+        /*    If it is a file or link, just delete it    */
+        if (is_file($path) || is_link($path)) {
+            return @unlink($path);
+        }
+
+        /*    Scan the dir and recursively unlink    */
+        $files = scandir($path);
+        if ($files) {
+            foreach($files as $filename)
+            {
+                if ($filename == '.' || $filename == '..') {
+                    continue;
+                }
+                $file = str_replace('//','/',$path.'/'.$filename);
+                CKEditor_Connector_Utils_FileSystem::unlink($file);
+            }
+        }
+
+        /*    Remove the parent dir    */
+        if (!@rmdir($path)) {
+            return false;
+        }
+
+        return true;
+    }
+
+    /**
+     * Return file name without extension (without dot & last part after dot)
+     *
+     * @static
+     * @access public
+     * @param string $fileName
+     * @return string
+     */
+    public static function getFileNameWithoutExtension($fileName)
+    {
+        $dotPos = strrpos( $fileName, '.' );
+        if (false === $dotPos) {
+            return $fileName;
+        }
+
+        return substr($fileName, 0, $dotPos);
+    }
+
+    /**
+     * Get file extension (only last part - e.g. extension of file.foo.bar.jpg = jpg)
+     *
+     * @static
+     * @access public
+     * @param string $fileName
+     * @return string
+     */
+    public static function getExtension( $fileName )
+    {
+        $dotPos = strrpos( $fileName, '.' );
+        if (false === $dotPos) {
+            return "";
+        }
+
+        return substr( $fileName, strrpos( $fileName, '.' ) +1 ) ;
+    }
+
+    /**
+     * Convert file name from UTF-8 to system encoding
+     *
+     * @static
+     * @access public
+     * @param string $fileName
+     * @return string
+     */
+    public static function convertToFilesystemEncoding($fileName)
+    {
+        $_config =& CKEditor_Connector_Core_Factory::getInstance("Core_Config");
+        $encoding = $_config->getFilesystemEncoding();
+        if (is_null($encoding) || strcasecmp($encoding, "UTF-8") == 0 || strcasecmp($encoding, "UTF8") == 0) {
+            return $fileName;
+        }
+
+        if (!function_exists("iconv")) {
+            if (strcasecmp($encoding, "ISO-8859-1") == 0 || strcasecmp($encoding, "ISO8859-1") == 0 || strcasecmp($encoding, "Latin1") == 0) {
+                return str_replace("\0", "_", utf8_decode($fileName));
+            } else if (function_exists('mb_convert_encoding')) {
+                /**
+                 * @todo check whether charset is supported - mb_list_encodings
+                 */
+                $encoded = @mb_convert_encoding($fileName, $encoding, 'UTF-8');
+                if (@mb_strlen($fileName, "UTF-8") != @mb_strlen($encoded, $encoding)) {
+                    return str_replace("\0", "_", preg_replace("/[^[:ascii:]]/u","_",$fileName));
+                }
+                else {
+                    return str_replace("\0", "_", $encoded);
+                }
+            } else {
+                return str_replace("\0", "_", preg_replace("/[^[:ascii:]]/u","_",$fileName));
+            }
+        }
+
+        $converted = @iconv("UTF-8", $encoding . "//IGNORE//TRANSLIT", $fileName);
+        if ($converted === false) {
+            return str_replace("\0", "_", preg_replace("/[^[:ascii:]]/u","_",$fileName));
+        }
+
+        return $converted;
+    }
+
+    /**
+     * Convert file name from system encoding into UTF-8
+     *
+     * @static
+     * @access public
+     * @param string $fileName
+     * @return string
+     */
+    public static function convertToConnectorEncoding($fileName)
+    {
+        $_config =& CKEditor_Connector_Core_Factory::getInstance("Core_Config");
+        $encoding = $_config->getFilesystemEncoding();
+        if (is_null($encoding) || strcasecmp($encoding, "UTF-8") == 0 || strcasecmp($encoding, "UTF8") == 0) {
+            return $fileName;
+        }
+
+        if (!function_exists("iconv")) {
+            if (strcasecmp($encoding, "ISO-8859-1") == 0 || strcasecmp($encoding, "ISO8859-1") == 0 || strcasecmp($encoding, "Latin1") == 0) {
+                return utf8_encode($fileName);
+            } else {
+                return $fileName;
+            }
+        }
+
+        $converted = @iconv($encoding, "UTF-8", $fileName);
+
+        if ($converted === false) {
+            return $fileName;
+        }
+
+        return $converted;
+    }
+
+    /**
+     * Find document root
+     *
+     * @return string
+     * @access public
+     */
+    public function getDocumentRootPath()
+    {
+        /**
+         * The absolute pathname of the currently executing script.
+         * If a script is executed with the CLI, as a relative path, such as file.php or ../file.php,
+         * $_SERVER['SCRIPT_FILENAME'] will contain the relative path specified by the user.
+         */
+        if (isset($_SERVER['SCRIPT_FILENAME'])) {
+            $sRealPath = dirname($_SERVER['SCRIPT_FILENAME']);
+        }
+        else {
+            /**
+             * realpath — Returns canonicalized absolute pathname
+             */
+            $sRealPath = realpath( './' ) ;
+        }
+
+        /**
+         * The filename of the currently executing script, relative to the document root.
+         * For instance, $_SERVER['PHP_SELF'] in a script at the address http://example.com/test.php/foo.bar
+         * would be /test.php/foo.bar.
+         */
+        $sSelfPath = dirname($_SERVER['PHP_SELF']);
+
+        return substr($sRealPath, 0, strlen($sRealPath) - strlen($sSelfPath));
+    }
+
+    /**
+     * Create directory recursively
+     *
+     * @access public
+     * @static
+     * @param string $dir
+     * @return boolean
+     */
+    public static function createDirectoryRecursively($dir)
+    {
+        if (DIRECTORY_SEPARATOR === "\\") {
+            $dir = str_replace("/", "\\", $dir);
+        }
+        else if (DIRECTORY_SEPARATOR === "/") {
+            $dir = str_replace("\\", "/", $dir);
+        }
+
+        $_config =& CKEditor_Connector_Core_Factory::getInstance("Core_Config");
+        if ($perms = $_config->getChmodFolders()) {
+            $oldUmask = umask(0);
+            $bCreated = @mkdir($dir, $perms, true);
+            umask($oldUmask);
+        }
+        else {
+            $bCreated = @mkdir($dir, 0777, true);
+        }
+
+        return $bCreated;
+    }
+
+    /**
+     * 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.
+     *
+     * @static
+     * @access public
+     * @param string $filePath absolute path to file
+     * @return boolean
+    */
+    public static function detectHtml($filePath)
+    {
+        $fp = @fopen($filePath, 'rb');
+        if ( $fp === false || !flock( $fp, LOCK_SH ) ) {
+            return -1 ;
+        }
+        $chunk = fread($fp, 1024);
+        flock( $fp, LOCK_UN ) ;
+        fclose($fp);
+
+        $chunk = strtolower($chunk);
+
+        if (!$chunk) {
+            return false;
+        }
+
+        $chunk = trim($chunk);
+
+        if (preg_match("/<!DOCTYPE\W*X?HTML/sim", $chunk)) {
+            return true;
+        }
+
+        $tags = array('<body', '<head', '<html', '<img', '<pre', '<script', '<table', '<title');
+
+        foreach( $tags as $tag ) {
+            if (false !== strpos($chunk, $tag)) {
+                return true ;
+            }
+        }
+
+        //type = javascript
+        if (preg_match('!type\s*=\s*[\'"]?\s*(?:\w*/)?(?:ecma|java)!sim', $chunk)) {
+            return true ;
+        }
+
+        //href = javascript
+        //src = javascript
+        //data = javascript
+        if (preg_match('!(?:href|src|data)\s*=\s*[\'"]?\s*(?:ecma|java)script:!sim',$chunk)) {
+            return true ;
+        }
+
+        //url(javascript
+        if (preg_match('!url\s*\(\s*[\'"]?\s*(?:ecma|java)script:!sim', $chunk)) {
+            return true ;
+        }
+
+        return false ;
+    }
+
+    /**
+     * Check file content.
+     * Currently this function validates only image files.
+     * Returns false if file is invalid.
+     *
+     * @static
+     * @access public
+     * @param string $filePath absolute path to file
+     * @param string $extension file extension
+     * @param integer $detectionLevel 0 = none, 1 = use getimagesize for images, 2 = use DetectHtml for images
+     * @return boolean
+    */
+    public static function isImageValid($filePath, $extension)
+    {
+        if (!@is_readable($filePath)) {
+            return -1;
+        }
+
+        $imageCheckExtensions = array('gif', 'jpeg', 'jpg', 'png', 'psd', 'bmp', 'tiff');
+
+        // version_compare is available since PHP4 >= 4.0.7
+        if ( function_exists( 'version_compare' ) ) {
+            $sCurrentVersion = phpversion();
+            if ( version_compare( $sCurrentVersion, "4.2.0" ) >= 0 ) {
+                $imageCheckExtensions[] = "tiff";
+                $imageCheckExtensions[] = "tif";
+            }
+            if ( version_compare( $sCurrentVersion, "4.3.0" ) >= 0 ) {
+                $imageCheckExtensions[] = "swc";
+            }
+            if ( version_compare( $sCurrentVersion, "4.3.2" ) >= 0 ) {
+                $imageCheckExtensions[] = "jpc";
+                $imageCheckExtensions[] = "jp2";
+                $imageCheckExtensions[] = "jpx";
+                $imageCheckExtensions[] = "jb2";
+                $imageCheckExtensions[] = "xbm";
+                $imageCheckExtensions[] = "wbmp";
+            }
+        }
+
+        if ( !in_array( $extension, $imageCheckExtensions ) ) {
+            return true;
+        }
+
+        if ( @getimagesize( $filePath ) === false ) {
+            return false ;
+        }
+
+        return true;
+    }
+}
Index: _source/plugins/filebrowser/core/connector/php/php5/Utils/Misc.php
===================================================================
--- _source/plugins/filebrowser/core/connector/php/php5/Utils/Misc.php	(revision 0)
+++ _source/plugins/filebrowser/core/connector/php/php5/Utils/Misc.php	(revision 0)
@@ -0,0 +1,55 @@
+<?php
+/*
+* Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+* For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+/**
+ * @package CKEditor
+ * @subpackage Utils
+ */
+
+/**
+ * @package CKEditor
+ * @subpackage Utils
+ */
+class CKEditor_Connector_Utils_Misc
+{
+    /**
+     * Convert any value to boolean, strings like "false", "FalSE" and "off" are also considered as false
+     *
+     * @static
+     * @access public
+     * @param mixed $value
+     * @return boolean
+     */
+    public static function booleanValue($value)
+    {
+        if (strcasecmp("false", $value) == 0 || strcasecmp("off", $value) == 0 || !$value) {
+            return false;
+        } else {
+            return true;
+        }
+    }
+
+    /**
+    * Checks if a value exists in an array (case insensitive)
+    *
+    * @static
+    * @access public
+    * @param string $needle
+    * @param array $haystack
+    * @return boolean
+    */
+    public static function inArrayCaseInsensitive($needle, $haystack)
+    {
+        if (!$haystack || !is_array($haystack)) {
+            return false;
+        }
+        $lcase = array();
+        foreach ($haystack as $key => $val) {
+            $lcase[$key] = strtolower($val);
+        }
+        return in_array($needle, $lcase);
+    }
+}
\ No newline at end of file
Index: _source/plugins/filebrowser/core/connector/php/php5/Utils/Security.php
===================================================================
--- _source/plugins/filebrowser/core/connector/php/php5/Utils/Security.php	(revision 0)
+++ _source/plugins/filebrowser/core/connector/php/php5/Utils/Security.php	(revision 0)
@@ -0,0 +1,65 @@
+<?php
+/*
+* Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+* For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+/**
+ * @package CKEditor
+ * @subpackage Utils
+ */
+
+/**
+ * @package CKEditor
+ * @subpackage Utils
+ */
+class CKEditor_Connector_Utils_Security
+{
+
+    /**
+     * Strip quotes from global arrays
+     * @access public
+     */
+    public function getRidOfMagicQuotes()
+    {
+        if (CKEDITOR_CONNECTOR_PHP_MODE<6 && get_magic_quotes_gpc()) {
+            if (!empty($_GET)) {
+                $this->stripQuotes($_GET);
+            }
+            if (!empty($_POST)) {
+                $this->stripQuotes($_POST);
+            }
+            if (!empty($_COOKIE)) {
+                $this->stripQuotes($_COOKIE);
+            }
+            if (!empty($_FILES)) {
+                while (list($k,$v) = each($_FILES)) {
+                    if (isset($_FILES[$k]['name'])) {
+                        $this->stripQuotes($_FILES[$k]['name']);
+                    }
+                }
+            }
+        }
+    }
+
+    /**
+     * Strip quotes from variable
+     *
+     * @access public
+     * @param mixed $var
+     * @param int $depth current depth
+     * @param int $howDeep maximum depth
+     */
+    public function stripQuotes(&$var, $depth=0, $howDeep=5)
+    {
+        if (is_array($var)) {
+            if ($depth++<$howDeep) {
+                while (list($k,$v) = each($var)) {
+                    $this->stripQuotes($var[$k], $depth, $howDeep);
+                }
+            }
+        } else {
+            $var = stripslashes($var);
+        }
+    }
+}
Index: _source/plugins/filebrowser/core/connector/php/php5/Utils/XmlNode.php
===================================================================
--- _source/plugins/filebrowser/core/connector/php/php5/Utils/XmlNode.php	(revision 0)
+++ _source/plugins/filebrowser/core/connector/php/php5/Utils/XmlNode.php	(revision 0)
@@ -0,0 +1,129 @@
+<?php
+/*
+* Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+* For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+/**
+ * @package CKEditor
+ * @subpackage Utils
+ */
+
+/**
+ * Simple class which provides some basic API for creating XML nodes and adding attributes
+ *
+ * @package CKEditor
+ * @subpackage Utils
+ */
+class CKEditor_Connector_Utils_XmlNode
+{
+    /**
+     * Array that stores XML attributes
+     *
+     * @access private
+     * @var array
+     */
+    private $_attributes = array();
+    /**
+     * Array that stores child nodes
+     *
+     * @access private
+     * @var array
+     */
+    private $_childNodes = array();
+    /**
+     * Node name
+     *
+     * @access private
+     * @var string
+     */
+    private $_name;
+    /**
+     * Node value
+     *
+     * @access private
+     * @var string
+     */
+    private $_value;
+
+    /**
+     * Create new node
+     *
+     * @param string $nodeName node name
+     * @param string $nodeValue node value
+     * @return CKEditor_Connector_Utils_XmlNode
+     */
+    function __construct($nodeName, $nodeValue = null)
+    {
+        $this->_name = $nodeName;
+        if (!is_null($nodeValue)) {
+            $this->_value = $nodeValue;
+        }
+    }
+
+    /**
+     * Add attribute
+     *
+     * @param string $name
+     * @param string $value
+     * @access public
+     */
+    public function addAttribute($name, $value)
+    {
+        $this->_attributes[$name] = $value;
+    }
+
+    /**
+     * Adds new child at the end of the children
+     *
+     * @param CKEditor_Connector_Utils_XmlNode $node
+     * @access public
+     */
+    public function addChild(&$node)
+    {
+        $this->_childNodes[] =& $node;
+    }
+
+    /**
+     * Return a well-formed XML string based on CKEditor_Connector_Utils_XmlNode element
+     *
+     * @return string
+     * @access public
+     */
+    public function asXML()
+    {
+        $ret = "<" . $this->_name;
+
+        //print Attributes
+        if (sizeof($this->_attributes)>0) {
+            foreach ($this->_attributes as $_name => $_value) {
+                $ret .= " " . $_name . '="' . htmlspecialchars($_value) . '"';
+            }
+        }
+
+        //if there is nothing more todo, close empty tag and exit
+        if (is_null($this->_value) && !sizeof($this->_childNodes)) {
+            $ret .= " />";
+            return $ret;
+        }
+
+        //close opening tag
+        $ret .= ">";
+
+        //print value
+        if (!is_null($this->_value)) {
+            $ret .= htmlspecialchars($this->_value);
+        }
+
+        //print child nodes
+        if (sizeof($this->_childNodes)>0) {
+            foreach ($this->_childNodes as $_node) {
+                $ret .= $_node->asXml();
+            }
+        }
+
+        $ret .= "</" . $this->_name . ">";
+
+        return $ret;
+    }
+}
\ No newline at end of file
Index: _source/plugins/filebrowser/dialogs/filebrowser.js
===================================================================
--- _source/plugins/filebrowser/dialogs/filebrowser.js	(revision 0)
+++ _source/plugins/filebrowser/dialogs/filebrowser.js	(revision 0)
@@ -0,0 +1,482 @@
+/*
+Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+CKEDITOR.dialog.add( 'filebrowser', function( editor )
+{
+	var dialog, editor,
+		initialized = false,
+		imagesDirectory = CKEDITOR.plugins.getPath( 'filebrowser' ) + 'images/',
+		regexFolderUp = /[^\/]+\/$/,
+		regexInvalidChars = /[\\\/:\*\?"<>\|]/,
+		regexIconExt = new RegExp( '^(?:' + editor.config.filebrowser_icons.replace( /,/g,'|' ) + ')$', 'i' );
+
+	// This function is called by the server connector when file is uploaded.
+	this.OnUploadCompleted = function( errorNumber, fileName, customErrorMsg )
+	{
+		if ( errorNumber == editor.plugins.filebrowser.ERROR_NONE || errorNumber == editor.plugins.filebrowser.ERROR_UPLOADEDFILERENAMED )
+			loadFoldersAndFiles( dialog.type, dialog.path );
+
+		dialog.getContentElement( 'tab1', 'inputFile' ).reset();
+		dialog.getContentElement( 'tab1', 'uploadFile' ).enable();
+		dialog.getContentElement( 'tab1', 'inputFile' ).setLabel( editor.lang.filebrowser.uploadTip );
+		editor.plugins.filebrowser._detectError( editor, errorNumber, customErrorMsg, fileName );
+	};
+
+	var createFolderButton =
+	{
+		id : 'createFolder',
+		label : editor.lang.filebrowser.folderCreate,
+		title : editor.lang.filebrowser.folderCreateTip,
+		accessKey : 'C',
+		type : 'button',
+		disabled : false,
+		onClick : function()
+		{
+			var folderName;
+
+			while ( true )
+			{
+				folderName = prompt( editor.lang.filebrowser.folderNew, '' );
+				if ( folderName == null )
+					return;
+				else if ( folderName.length == 0 )
+					alert( editor.lang.filebrowser.folderEmpty );
+				else if ( regexInvalidChars.test( folderName ) )
+					alert( editor.lang.filebrowser.folderInvalidChar );
+				else
+					break;
+			}
+			createFolder( dialog.type, dialog.path, folderName );
+		}
+	};
+
+	var resourceType = function( name, url, allowedExtensions, deniedExtensions )
+	{
+		this.name = name;
+		this.url = url;
+		this.allowedExtensions = allowedExtensions.toLowerCase().split( ',' );
+		this.deniedExtensions = deniedExtensions.toLowerCase().split( ',' );
+
+		this.isExtensionAllowed = function( extension )
+		{
+			extension = extension.toLowerCase();
+
+			return ( ( !this.deniedExtensions.length || CKEDITOR.tools.indexOf( this.deniedExtensions, extension ) == -1 ) && 
+					( !this.allowedExtensions.length || CKEDITOR.tools.indexOf( this.allowedExtensions, extension ) !== -1 ) );
+		};
+	};
+
+	var getExtension = function( fileName )
+	{
+		return fileName.substr( fileName.lastIndexOf( '.' ) + 1 ).toLowerCase();
+	};
+
+	var getIcon = function( fileName )
+	{
+		var extension = getExtension( fileName );
+
+		if ( regexIconExt.test( extension ) )
+			return extension;
+		else
+			return 'default.icon';
+	};
+
+	var clearFoldersPane = function()
+	{
+		dialog.getContentElement( 'tab1', 'folders' ).getElement().setHtml( "" );
+	};
+
+	var clearResourcesList = function()
+	{
+		dialog.getContentElement( 'tab1', 'resourceslist' ).getElement().setHtml( "" );
+	};
+
+	var updateFoldersPane = function( folders, selectedFolderIndex )
+	{
+		var td, tr, 
+			table = new CKEDITOR.dom.element( 'table' ),
+			tbody = new CKEDITOR.dom.element( 'tbody' );
+
+		tr = new CKEDITOR.dom.element( 'tr' );
+		td = new CKEDITOR.dom.element( 'td' );
+		td.appendText( ".." );
+		td.addClass( 'cke_folderUp' );
+		td.on( 'click', function( evt )
+		{
+			var folderUp = this.path.replace( regexFolderUp, '' );
+
+			if ( folderUp != "/" )
+				loadFolders( this.type, folderUp.replace( regexFolderUp, '' ) );
+			else
+				clearFoldersPane();
+
+			loadFoldersAndFiles( this.type, folderUp );
+		}, dialog, {} );
+		tr.append( td );
+		tbody.append( tr );
+
+		for ( var i = 0 ; i < folders.length ; i++ )
+		{
+			tr = new CKEDITOR.dom.element( 'tr' );
+			td = new CKEDITOR.dom.element( 'td' );
+			td.appendText( folders[ i ] );
+			td.addClass( i == selectedFolderIndex ? 'cke_folderOpened' : 'cke_folder' );
+			td.on( 'click', function( evt )
+			{
+				updateFoldersPane( evt.listenerData.folders, evt.listenerData.folder );
+				loadFoldersAndFiles( this.type, this.path.replace( regexFolderUp, '' )
+						+ evt.listenerData.folders[ evt.listenerData.folder ] + "/" );
+			}, dialog,
+			{
+				folders : folders,
+				folder : i
+			} );
+			tr.append( td );
+			tbody.append( tr );
+		}
+
+		clearFoldersPane();
+		table.setStyle( 'width', '100%' );
+		table.append( tbody );
+		dialog.getContentElement( 'tab1', 'folders' ).getElement().append( table );
+	};
+
+	var getErrorNumber = function( xml )
+	{
+		return parseInt( xml.selectSingleNode( 'Connector/Error/@number' ).value );
+	};
+
+	var getErrorMessage = function( xml )
+	{
+		var node = xml.selectSingleNode( 'Connector/Error/@text' );
+		if ( !node )
+			return '';
+		return node.value;
+	};
+
+	var onInit = function( xml )
+	{
+		if ( editor.plugins.filebrowser._detectError( editor, getErrorNumber( xml ), getErrorMessage( xml ) ) )
+			return;
+
+		var name,
+			select = dialog.getContentElement( 'tab1', 'cmbResourceType' ),
+			nodes = xml.selectNodes( 'Connector/ResourceTypes/ResourceType' );
+
+		select.clear();
+		dialog.resourceTypes = {};
+
+		for ( var i = 0 ; i < nodes.length ; i++ )
+		{
+			name = nodes[ i ].attributes.getNamedItem( 'name' ).value;
+
+			dialog.resourceTypes[ name ] = new resourceType( name, nodes[ i ].attributes.getNamedItem( 'url' ).value,
+					nodes[ i ].attributes.getNamedItem( 'allowedExtensions' ).value, nodes[ i ].attributes.getNamedItem( 'deniedExtensions' ).value );
+
+			select.add( name );
+		}
+
+		initialized = true;
+		loadFoldersAndFiles( nodes[ 0 ].attributes.getNamedItem( 'name' ).value, "/" );
+	};
+
+	var onCreateFolder = function( xml )
+	{
+		if ( editor.plugins.filebrowser._detectError( editor, getErrorNumber( xml ), getErrorMessage( xml ) ) )
+			return;
+
+		loadFoldersAndFiles( dialog.type, dialog.path );
+	};
+
+	var onGetFolders = function( xml )
+	{
+		if ( editor.plugins.filebrowser._detectError( editor, getErrorNumber( xml ), getErrorMessage( xml ) ) )
+			return;
+
+		var currentFolder = xml.selectSingleNode( 'Connector/CurrentFolder' ),
+			nodes = xml.selectNodes( 'Connector/Folders/Folder' ),
+			folders = [];
+
+		for ( var i = 0 ; i < nodes.length ; i++ )
+			folders.push( nodes[ i ].attributes.getNamedItem( 'name' ).value );
+
+		updateFoldersPane( folders, currentFolder );
+	};
+
+	var onGetFoldersAndFiles = function( xml )
+	{
+		if ( editor.plugins.filebrowser._detectError( editor, getErrorNumber( xml ), getErrorMessage( xml ) ) )
+			return;
+
+		var img, td, tr, 
+			table = new CKEDITOR.dom.element( 'table' ),
+			tbody = new CKEDITOR.dom.element( 'tbody' ),
+			nodes = xml.selectNodes( 'Connector/Folders/Folder' ),
+			currentFolder = xml.selectSingleNode( 'Connector/CurrentFolder' ),
+			connector = xml.selectSingleNode( '//Connector' ),
+			files = [],
+			folders = [];
+
+		dialog.type = connector.attributes.getNamedItem( 'resourceType' ).value;
+		dialog.url = currentFolder.attributes.getNamedItem( 'url' ).value;
+		dialog.path = currentFolder.attributes.getNamedItem( 'path' ).value;
+
+		// Add the scrollbar to the table.
+		if ( CKEDITOR.env.ie )
+		{
+			dialog.getContentElement( 'tab1', 'resourceslist' ).getElement().setStyle( 'overflow-y', 'scroll' );
+			table.setStyle( 'width', '510px' );
+		}
+		else
+		{
+			table.setStyle( 'float', 'left' );
+			table.setStyle( 'display', 'table-cell' );
+			table.setStyle( 'height', '280px' );
+			table.setStyle( 'width', '100%' );
+		}
+
+		table.setStyle( 'overflow', 'auto' );
+
+		CKEDITOR.document.getById( 'cke_actualFolder' ).setHtml( dialog.path );
+
+		for ( var i = 0 ; i < nodes.length ; i++ )
+		{
+			folders.push( nodes[ i ].attributes.getNamedItem( 'name' ).value );
+			tr = new CKEDITOR.dom.element( 'tr' );
+			td = new CKEDITOR.dom.element( 'td' );
+			td.appendText( folders[ i ] );
+			td.setAttribute( 'colSpan', 3 ); // IE accepts this attribute only if "S" is uppercased.
+			td.addClass( 'cke_folder' );
+			tr.append( td );
+			tr.on( 'click', function( evt )
+					{
+						updateFoldersPane( evt.listenerData.folders, evt.listenerData.folder );
+						loadFoldersAndFiles( this.type, this.path + evt.listenerData.folders[ evt.listenerData.folder ] + "/" );
+					}, dialog, { folder : i, folders : folders } );
+			tbody.append( tr );
+		}
+
+		nodes = xml.selectNodes( 'Connector/Files/File' );
+
+		for ( var i = 0 ; i < nodes.length ; i++ )
+		{
+			files.push( nodes[ i ].attributes.getNamedItem( 'name' ).value );
+			tr = new CKEDITOR.dom.element( 'tr' );
+			td = new CKEDITOR.dom.element( 'td' );
+			img = new CKEDITOR.dom.element( 'img' );
+			img.setAttribute( "src", CKEDITOR.getUrl( imagesDirectory + 'icons/' + getIcon( files[ i ] ) + '.gif' ) );
+			td.setStyle( 'width', '20px' );
+			td.setStyle( 'text-align', 'center' );
+			td.append( img );
+			tr.append( td );
+			td = new CKEDITOR.dom.element( 'td' );
+			td.appendText( files[ i ] );
+			td.setStyle( 'vertical-align', 'middle' );
+			td.setStyle( 'width', '450px' );
+			tr.append( td );
+			td = new CKEDITOR.dom.element( 'td' );
+			td.appendText( nodes[ i ].attributes.getNamedItem( 'size' ).value + 'KB' );
+			td.setStyle( 'vertical-align', 'middle' );
+			td.setStyle( 'width', '50px' );
+			tr.append( td );
+			tr.on( 'click', function( evt )
+					{
+						var fileUrl = this.resourceTypes[ this.type ].url + this.path.substr( 1 ) + evt.listenerData.file ;
+						editor.fire( 'fileSelected', { url : fileUrl }, editor );
+						dialog.hide();
+					}, dialog, { file : files[ i ] } );
+			tbody.append( tr );
+		}
+
+		clearResourcesList();
+		table.append( tbody );
+		dialog.getContentElement( 'tab1', 'resourceslist' ).getElement().append( table );
+		dialog.getContentElement( 'tab1', 'inputFile' ).getInputElement().getParent().setAttribute( "action",
+				editor.plugins.filebrowser._commandUrl( editor, 'FileUpload', { type : dialog.type, currentFolder : dialog.path } ) );
+	};
+
+	var loadFoldersAndFiles = function( type, path )
+	{
+		CKEDITOR.ajax.loadXml( editor.plugins.filebrowser._commandUrl( editor, 'GetFoldersAndFiles', { type : type, currentFolder : path } ), onGetFoldersAndFiles );
+	};
+
+	var loadFolders = function( type, path )
+	{
+		CKEDITOR.ajax.loadXml( editor.plugins.filebrowser._commandUrl( editor, 'GetFolders', { type : type, currentFolder : path } ), onGetFolders );
+	};
+
+	var createFolder = function( type, path, folderName )
+	{
+		CKEDITOR.ajax.postXml( editor.plugins.filebrowser._commandUrl( editor, 'CreateFolder', { type : type, currentFolder : path } ), { newFolderName : folderName }, onCreateFolder );
+	};
+
+	return {
+		title : editor.lang.filebrowser.title,
+		minWidth : '730',
+		minHeight : '480',
+		onLoad : function()
+		{
+			dialog = this;
+			editor = this.getParentEditor();
+		},
+		onHide : function()
+		{
+			initialized = false;
+		},
+		onShow : function()
+		{
+			var params = {};
+			if ( editor.plugins.filebrowser.params.type )
+				params.type = editor.plugins.filebrowser.params.type;
+
+			// Don't clear the window and call the Init command if we're going back to the same place.
+			if ( !dialog.type || !dialog.path || ( !!params.type && dialog.type != params.type) || ( !!params.path && dialog.path != params.path ) )
+			{
+				clearFoldersPane();
+				clearResourcesList();
+				CKEDITOR.ajax.loadXml( editor.plugins.filebrowser._commandUrl( editor, 'Init', params ), onInit );
+			}
+		},
+		contents : 
+		[
+			{
+				id : 'tab1',
+				label : editor.lang.filebrowser.title,
+				accessKey : 'B',
+				elements : 
+				[
+					{
+						type : 'html',
+						html : '<style type="text/css">' +
+								'.cke_folder { background: url("' + CKEDITOR.getUrl( imagesDirectory + 'folder.gif' ) + '"); }' +
+								'.cke_folderOpened{ background: url("' + CKEDITOR.getUrl( imagesDirectory + 'folderOpened.gif' ) + '"); }' +
+								'.cke_folderUp { background: url("' + CKEDITOR.getUrl( imagesDirectory + 'folderUp.gif' ) + '"); }' +
+								'.cke_filebrowser .cke_dialog_ui_hbox_first {vertical-align:top;}' +
+								'.cke_folder, .cke_folderOpened, .cke_folderUp {' +
+								'padding-left:20px;' +
+								'height:16px;' +
+								'background-repeat:no-repeat;' +
+								'}' +
+								'#cke_actualFolder {' +
+								'font-weight:bold;' +
+								'font-size:120%;' +
+								'}' +
+								'</style>'
+					},
+					{
+						type : 'hbox',
+						widths : [ '140px', '540px' ],
+						align : 'left',
+						padding : 0,
+						className : 'cke_filebrowser',
+						children : 
+						[
+							{
+								type : 'vbox',
+								children : 
+								[
+									{
+										type : 'select',
+										id : 'cmbResourceType',
+										accessKey : 'R',
+										labelLayout : 'vertical',
+										label : editor.lang.filebrowser.resourceType,
+										items : [ [ editor.lang.common.notSet, '' ] ],
+										onChange : function()
+										{
+											if ( this.isChanged() && initialized )
+											{
+												loadFoldersAndFiles( this.getValue(), "/" );
+												clearFoldersPane();
+											}
+										}
+									},
+									{
+										type : 'vbox',
+										id : 'folders',
+										style : 'display:table-cell;',
+										children : []
+									}
+								]
+							},
+							{
+								type : 'vbox',
+								heights : [ '36px', '280px' ],
+								children : 
+								[
+									{
+										type : 'hbox',
+										widths : [ '36px', '' ],
+										children : 
+										[
+											{
+												type : 'html',
+												align : 'left',
+												style : 'vertical-align:middle',
+												html : '<img width="32" height="32" src="' + CKEDITOR.getUrl( imagesDirectory + 'FolderOpened32.gif' ) + '" alt=""/>'
+											},
+											{
+												type : 'html',
+												style : 'vertical-align:middle',
+												html : '<div id="cke_actualFolder"></div>'
+											},
+										]
+									},
+									{
+										type : 'vbox',
+										id : 'resourceslist',
+										style : 'height:280px;white-space: nowrap;',
+										children : []
+									},
+									{
+										type : 'hbox',
+										children : 
+										[
+											{
+												type : 'file',
+												label : editor.lang.filebrowser.uploadTip,
+												labelLayout : 'vertical',
+												action : editor.plugins.filebrowser._commandUrl( editor, 'FileUpload', { type : 'Files', currentFolder : '/' } ),
+												id : 'inputFile'
+											},
+											{
+												type : 'fileButton',
+												label : editor.lang.common.uploadSubmit,
+												id : 'uploadFile',
+												accessKey : 'S',
+												onClick : function( evt )
+												{
+													var dialog = this.getDialog(),
+														file = dialog.getContentElement( 'tab1', 'inputFile' ).getValue();
+
+													if ( !file )
+													{
+														alert( editor.lang.filebrowser.fileNotSelected );
+														return false;
+													}
+													else
+													{
+														if ( !dialog.resourceTypes[ dialog.type ].isExtensionAllowed( getExtension( file ) ) )
+														{
+															alert( editor.lang.filebrowser.errors[ editor.plugins.filebrowser.ERROR_INVALID_EXTENSION ] );
+															return false;
+														}
+														dialog.getContentElement( 'tab1', 'inputFile' ).setLabel( editor.lang.filebrowser.uploadProgressLbl );
+													}
+												},
+												'for' : [ 'tab1', 'inputFile' ]
+											}
+										]
+									}
+								]
+							}
+						]
+					}
+				]
+			}
+		],
+		buttons : [ createFolderButton, CKEDITOR.dialog.cancelButton ]
+	};
+} );
Index: _source/plugins/filebrowser/plugin.js
===================================================================
--- _source/plugins/filebrowser/plugin.js	(revision 0)
+++ _source/plugins/filebrowser/plugin.js	(revision 0)
@@ -0,0 +1,420 @@
+/*
+Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+/**
+ * @fileOverview The "filebrowser" plugin, it adds support for file uploads and browsing.
+ */
+CKEDITOR.plugins.add( 'filebrowser',
+{
+	requires : [ 'dialog' ],
+
+	ERROR_NONE : 0,
+	ERROR_CUSTOMERROR : 1,
+	ERROR_INVALID_EXTENSION : 105,
+	ERROR_UPLOADEDFILERENAMED : 201,
+
+	/**
+	 * Reference to the last opened dialog. Required by 'selectFunction' and 'uploadCompletedFunction'.
+	 * @type {CKEDITOR.dialog}
+	 */
+	_dialog : null,
+	/**
+	 * The "action" attribute that will be passed to the {@see CKEDITOR.ui.dialog.file#reset} function.
+	 * The "action" attribute is generated automatically in some cases. 
+	 * @type String
+	 */
+	_formAction : null,
+	/**
+	 * Holds the reference to the file input element to reset after file is uploaded.
+	 * Syntax: [ pageId, elementId ] 
+	 * @type Array
+	 */
+	_targetInput : null,
+	/**
+	 * Holds the reference to the UI element that will be updated when file is selected/uploaded.
+	 * Syntax: [ pageId, elementId ] 
+	 * @type Array
+	 */
+	_targetElement : null,
+	/**
+	 * The user defined function (if defined) that will be called when file is uploaded.
+	 * @type Function
+	 */
+	_onUpload : null,
+
+	_commandUrl : function( editor, command, params )
+	{
+		var url = [ CKEDITOR.getUrl( this.path + 'core/connector/' + editor.config.filebrowser_connector + '/connector.' + editor.config.filebrowser_connector ) ];
+		url.push( ( url[0].indexOf( '?' ) >= 0 ? '&' : '?' ) + 'command=' + command );
+		if ( params )
+		{
+			for ( var i in params )
+				url.push( "&" + i + "=" + encodeURIComponent( params[i] ) );
+		}
+		return url.join( "" );
+	},
+
+	_detectError : function( editor, errorNumber, customError ) 
+	{
+		if ( errorNumber == this.ERROR_NONE )
+			return false;
+		
+		var errorMessage;
+		
+		if ( errorNumber == this.ERROR_CUSTOMERROR )
+			errorMessage = customError;
+		else
+		{
+			errorMessage = editor.lang.filebrowser.errors[ errorNumber ];
+
+			if ( errorMessage )
+			{
+				// Replace any string placeholder (%1, %2, ...), taking the values
+				// from the detectError arguments.
+				var replaceArgs = arguments;
+				var replacePlaceholders = function( match, number )
+				{
+					return ( replaceArgs[ parseInt( number ) + 1 ] );
+				};
+				errorMessage = errorMessage.replace( /%(\d+)/g, replacePlaceholders );
+			}
+			else
+				errorMessage = editor.lang.filebrowser.errorUnknown.replace( /%1/, errorNumber );
+		}
+
+		alert( errorMessage );
+
+		return ( errorNumber != this.ERROR_UPLOADEDFILERENAMED );
+	},
+
+	init : function( editor, pluginPath )
+	{
+		editor.addCommand( 'filebrowser', new CKEDITOR.dialogCommand( 'filebrowser' ) );
+		CKEDITOR.dialog.add( 'filebrowser', this.path + 'dialogs/filebrowser.js' );
+
+		/**
+		 * Updates the target element with the url of uploaded/selected file.
+		 * @param {String} url The url of a file.
+		 */
+		var updateTargetElement = function( url )
+		{
+			url = encodeURI( url ).replace( /#/g, '%23' );
+			var plugin = editor.plugins.filebrowser;
+
+			// If there is a reference to targetElement, update it.
+			if ( plugin._targetElement )
+			{
+				var element = plugin._dialog.getContentElement( 
+						plugin._targetElement[0], plugin._targetElement[1] );
+				if ( element )
+					element.setValue( url );
+			}
+			// If targetElement is empty, find the first element with id 'url' and update it.
+			else
+			{
+				var widgetFound = false;
+				plugin._dialog.foreach( function( widget )
+						{
+							if ( !widgetFound && widget.id == 'url' )
+							{
+								widget.setValue( url );
+								widget.getDialog().selectPage( widget.getParentTab() );
+								widgetFound = true;
+							}
+						});
+			}
+		};
+
+		/**
+		 * Opens Browser in a popup. The "width" and "height" parameters accept
+		 * numbers (pixels) or percent (of screen size) values.
+		 * @param {String} url The url of the external file browser.
+		 * @param {String} width Popup window width.
+		 * @param {String} height Popup window height.
+		 */
+		var popup = function( url, width, height )
+		{
+			width = width || '80%';
+			height = height || '70%';
+
+			if ( typeof width == 'string' && width.length > 1 && width.substr( width.length - 1, 1 ) == '%' )
+				width = parseInt( window.screen.width * parseInt( width ) / 100 );
+
+			if ( typeof height == 'string' && height.length > 1 && height.substr( height.length - 1, 1 ) == '%' )
+				height = parseInt( window.screen.height * parseInt( height ) / 100 );
+
+			if ( width < 640 )
+				width = 640;
+
+			if ( height < 420 )
+				height = 420;
+
+			var top = parseInt( ( window.screen.height - height ) / 2 ),
+				left = parseInt( ( window.screen.width  - width ) / 2 ),
+				options = 'location=no,menubar=no,toolbar=no,dependent=yes,minimizable=no,modal=yes,alwaysRaised=yes,resizable=yes' +
+				',width='  + width +
+				',height=' + height +
+				',top='  + top +
+				',left=' + left;
+
+			var popupWindow = window.open( '', null, options, true );
+
+			// Blocked by a popup blocker.
+			if ( !popupWindow )
+				return false;
+
+			try
+			{
+				popupWindow.moveTo( left, top );
+				popupWindow.resizeTo( width, height );
+				popupWindow.focus();
+				popupWindow.location.href = url;
+			}
+			catch (e)
+			{
+				popupWindow = window.open( url, null, options, true );
+			}
+
+			return true ;
+		};
+
+		/**
+		 * The onlick function assigned to the 'Browse Server' button.
+		 * Opens the file browser and updates target field when file is selected.
+		 * @param {CKEDITOR.event} evt The event object.
+		 */
+		var browseServer = function( evt )
+		{
+			var dialog = this.getDialog();
+			var editor = dialog.getParentEditor();
+			var plugin = editor.plugins.filebrowser;
+
+			// Save references to fields required by the 'selectFunction'.
+			plugin._dialog = dialog; 
+			if ( this.filebrowser.updateOnSelect )
+			{
+				plugin._targetElement = this.filebrowser.updateOnSelect;
+			}
+			else 
+			{
+				var parentTab = this.getParentTab();
+				if ( dialog.getContentElement( parentTab, 'url' ) )
+					plugin._targetElement = [ parentTab, 'url' ];
+				else
+					plugin._targetElement = null;
+			}
+
+			// If url attribute is set, call the external browser.
+			if ( this.filebrowser.url || editor.config.filebrowser_browse_url )
+			{
+				// Function that is called when the user selects a file in external file browser.
+				var selectFunction = this.filebrowser.selectFunction || 'SetUrl';
+
+				this.getElement().getWindow().$[selectFunction] = function( fileUrl, data )
+				{
+					updateTargetElement( fileUrl );
+				};
+
+				popup( this.filebrowser.url || editor.config.filebrowser_browse_url );
+			}
+			// Call the built-in file browser otherwise.
+			else
+			{
+				if ( this.filebrowser.params )
+				{
+					// If params is set to 'auto', create the default params object.
+					if ( this.filebrowser.params == 'auto' )
+					{
+						plugin.params = { currentFolder : '/' };
+
+						// Assign initial resource type for image and flash dialogs. 
+						switch ( dialog.getName() )
+						{
+							case 'image':
+								plugin.params.type = editor.config.filebrowser_resourcetype_image;
+								break;
+							case 'flash':
+								plugin.params.type = editor.config.filebrowser_resourcetype_flash;
+								break;
+						}
+					}
+					else
+						plugin.params = this.filebrowser.params;
+				}
+				else
+					plugin.params = {};
+
+				editor.openDialog( 'filebrowser' );
+			}
+		};
+
+		/**
+		 * The onlick function assigned to the 'Upload' button.
+		 * Makes the final decision whether form is really submitted and updates target field when file is uploaded.
+		 * @param {CKEDITOR.event} evt The event object.
+		 */
+		var uploadFile = function( evt )
+		{
+			var dialog = this.getDialog();
+			var editor = dialog.getParentEditor();
+			var plugin = editor.plugins.filebrowser;
+
+			// Update variables that will be used by the 'OnUploadCompleted' function.
+			plugin._onUpload = this.filebrowser.onUpload;
+			plugin._dialog = dialog;
+			plugin._targetInput = this['for'];
+			plugin._formAction = dialog.getContentElement( this['for'][0], this['for'][1] ).getAction();
+
+			// If user didn't select the file, stop the upload.
+			if ( !dialog.getContentElement( this['for'][0], this['for'][1] ).getValue() )
+			{
+				alert( editor.lang.filebrowser.fileNotSelected );
+				return false;
+			}
+
+			// targetElement will be updated with the url of uploaded file.
+			if ( this.filebrowser.updateOnUpload )
+				plugin._targetElement = this.filebrowser.updateOnUpload;
+			else 
+			{
+				var parentTab = this.getParentTab();
+				if ( dialog.getContentElement( parentTab, 'url' ) )
+					plugin._targetElement = [ parentTab, 'url' ];
+				else
+					plugin._targetElement = null;
+			}
+
+			// Function to be called by the server connector after file is uploaded.
+			var uploadCompletedFunction = this.filebrowser.uploadCompletedFunction || 'OnUploadCompleted';
+
+			this.getElement().getWindow().$[uploadCompletedFunction] = function( errorNumber, fileName, customErrorMsg )
+			{
+				plugin._dialog.getContentElement( plugin._targetInput[0], plugin._targetInput[1] ).reset( plugin._formAction );
+
+				if ( plugin._onUpload && plugin._onUpload( errorNumber, fileName, customErrorMsg ) === false )
+					return;
+
+				if ( !plugin._detectError( editor, errorNumber, customErrorMsg, fileName ) )
+					updateTargetElement( fileName );
+			};
+		};
+
+		/**
+		 * Setups the file element. 
+		 * @param {CKEDITOR.ui.dialog.file} fileInput The file element used during file upload.
+		 * @param {Object} filebrowser Object containing filebrowser settings assigned to the fileButton
+		 * associated with this file element.
+		 */
+		var setupFileElement = function( fileInput, filebrowser )
+		{
+			fileInput.filebrowser = filebrowser;
+			// Set the action attribute in parent form.
+			// This function is called only once, before the first upload.
+			fileInput.onChange = function( evt )
+			{
+				var dialog = this.getDialog();
+				var editor = dialog.getParentEditor();
+
+				if ( this.filebrowser.url )
+					this.setAction( this.filebrowser.url );
+				else if ( editor.config.filebrowser_upload_url )
+					this.setAction( editor.config.filebrowser_upload_url );
+				else
+				{
+					var params;
+
+					// If params is set to 'auto', create the default params object.
+					if ( this.filebrowser.params == 'auto' )
+					{
+						params = { currentFolder : '/' };
+
+						// Assign initial resource type for image and flash dialogs. 
+						switch ( dialog.getName() )
+						{
+							case 'image':
+								params.type = editor.config.filebrowser_resourcetype_image;
+								break;
+							case 'flash':
+								params.type = editor.config.filebrowser_resourcetype_flash;
+							default:
+								params.type = editor.config.filebrowser_resourcetype_default;
+								break;
+						}
+					}
+					else
+						params = this.filebrowser.params;
+
+					this.setAction( editor.plugins.filebrowser._commandUrl( editor, this.filebrowser.action, params ) );
+				}
+			};
+		};
+
+		/**
+		 * Traverse through the content definition and attach filebrowser
+		 * to elements with 'filebrowser' attribute.
+		 * @param {CKEDITOR.dialog.dialogDefinitionObject} definition
+		 * @param {Array} elements Array of {@link CKEDITOR.dialog.contentDefinition} objects.
+		 */
+		var attachFileBrowser = function( definition, elements )
+		{
+			var element, fileInput;
+
+			for ( var i in elements )
+			{
+				element = elements[i];
+
+				if ( element.type == 'hbox' || element.type == 'vbox' )
+					attachFileBrowser( definition, element.children );
+
+				if ( !element.filebrowser )
+					continue;
+
+				if ( element.filebrowser.action == 'Browse' )
+				{
+					element.onClick = browseServer; 
+				}
+				else if ( element.filebrowser.action == 'QuickUpload' && element['for'] )
+				{
+					setupFileElement( definition.getContents( element['for'][0] ).get( element['for'][1] ), element.filebrowser );
+					element.onClick = uploadFile; 
+				}
+			}
+		};
+
+		editor.on( 'fileSelected', function( evt )
+				{
+					updateTargetElement( evt.data.url );
+				});
+
+		CKEDITOR.on( 'dialogDefinition', function( evt )
+				{
+					var i, browseButton, fileButton;
+
+					// Attach 'filebrowser' attributes to elements with special id.
+					for ( i in evt.data.definition.contents )
+					{
+						browseButton = evt.data.definition.contents[i].get( 'browse' );
+						if ( browseButton )
+							browseButton.filebrowser = { action : 'Browse', params : 'auto' };
+
+						fileButton = evt.data.definition.contents[i].get( 'uploadButton' );
+						if ( fileButton && evt.data.definition.getContents( fileButton['for'][0] ).get( fileButton['for'][1] ).action == 'filebrowser' )
+							fileButton.filebrowser = { action : 'QuickUpload', params : 'auto' };
+					}
+
+					// Associate filebrowser to elements with 'filebrowser' attribute.
+					for ( i in evt.data.definition.contents )
+						attachFileBrowser( evt.data.definition, evt.data.definition.contents[i].elements );
+				});
+	}
+} );
+
+CKEDITOR.tools.extend( CKEDITOR.config, {
+	filebrowser_connector : 'php',
+	filebrowser_icons : 'ai,avi,bmp,cs,dll,doc,exe,fla,gif,htm,html,jpg,js,mdb,mp3,pdf,png,ppt,rdp,swf,swt,txt,vsd,xls,xml,zip',
+	filebrowser_resourcetype_image : 'Images',
+	filebrowser_resourcetype_flash : 'Flash',
+	filebrowser_resourcetype_default : 'Files'
+} );
Index: _source/plugins/link/dialogs/link.js
===================================================================
--- _source/plugins/link/dialogs/link.js	(revision 3056)
+++ _source/plugins/link/dialogs/link.js	(working copy)
@@ -1008,7 +1008,7 @@
 				case 'url':
 					var protocol = ( data.url && data.url.protocol ) || 'http://',
 						url = ( data.url && data.url.url ) || '';
-					attributes._cke_saved_href = protocol + url;
+					attributes._cke_saved_href = ( url.indexOf( '/' ) === 0 ) ? url : protocol + url;
 					break;
 				case 'anchor':
 					var name = ( data.anchor && data.anchor.name ),
Index: _source/plugins/link/plugin.js
===================================================================
--- _source/plugins/link/plugin.js	(revision 3056)
+++ _source/plugins/link/plugin.js	(working copy)
@@ -125,7 +125,7 @@
 {
 	linkUploadTab : true,
 	linkBrowseServer : true,
-	linkUploadAction : 'nowhere.php',
+	linkUploadAction : 'filebrowser',
 	linkShowAdvancedTab : true,
 	linkShowTargetTab : true
 } );
Index: ckeditor.pack
===================================================================
--- ckeditor.pack	(revision 3056)
+++ ckeditor.pack	(working copy)
@@ -82,6 +82,8 @@
 					'_source/core/dom.js',
 					'_source/core/tools.js',
 					'_source/core/dtd.js',
+					'_source/core/xml.js',
+					'_source/core/ajax.js',
 					'_source/core/dom/event.js',
 					'_source/core/dom/domobject.js',
 					'_source/core/dom/node.js',
@@ -123,6 +125,7 @@
 					'_source/plugins/keystrokes/plugin.js',
 					'_source/plugins/newpage/plugin.js',
 					'_source/plugins/removeformat/plugin.js',
+					'_source/plugins/filebrowser/filebrowser.js',
 					'_source/plugins/smiley/plugin.js',
 					'_source/plugins/sourcearea/plugin.js',
 					'_source/plugins/specialchar/plugin.js',

