FCKEditor v2.6 編輯器配置圖解教程
更新時(shí)間:2008年08月15日 19:14:38 作者:
fckeditor的配置教程,看了下面的文章應(yīng)該就差不多了
集成 FCKEditor v2.6(當(dāng)前為最新版本)的基本步驟如下:
1. 下載FCKeditor 2.6 基本文件(Main Code)。將解壓縮的文件復(fù)制到項(xiàng)目的editors/FCKEditorV2 目錄下。
2. 下載 FCKeditor.Net / ASP.NET 控件,復(fù)制FredCK.FCKeditorV2.dll 文件到項(xiàng)目的bin目錄。
這樣就基本可以FCKEditor v2.6 超強(qiáng)的編輯器了,當(dāng)然還需要在Host Settings中設(shè)置默認(rèn)的編輯器。
關(guān)于 FCKEditor 的一些基本配置信息,請(qǐng)參考如下的文章:
如需要使用文件上傳功能,還需要修改代碼FCKEditorV2/editor/filemanager/connectors/config.ascx(以ASPX代碼為例)。這里限制只有登錄的用戶才可以使用文件上傳功能,并且上傳的文件只能上傳到用戶自己的目錄。根據(jù)每個(gè)用戶名自動(dòng)創(chuàng)建對(duì)應(yīng)的文件上傳目錄。


connectors/config.ascx 更新后的代碼如下:
/**
* This function must check the user session to be sure that he/she is
* authorized to upload and access files in the File Browser.
*/
private string m_userName;
private int m_userID;
private int m_boardID;
private bool m_isAuthenticated;
private bool 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 ( Session[ "IsAuthorized" ] != null && (bool)Session[ "IsAuthorized" ] == true );
//
// ... where Session[ "IsAuthorized" ] is set to "true" as soon as the
// user logs in your system.
string userName = HttpContext.Current.User.Identity.Name;
try
{
if (HttpContext.Current.User.Identity.IsAuthenticated)
{
string[] parts = userName.Split(';');
if (parts.Length == 3)
{
m_userID = int.Parse(parts[0]);
m_boardID = int.Parse(parts[1]);
m_userName = parts[2];
m_isAuthenticated = true;
}
}
}
catch (Exception)
{
m_userName = "";
m_userID = 0;
m_boardID = 0;
m_isAuthenticated = false;
}
return m_isAuthenticated;
}
public override void SetConfig()
{
// SECURITY: You must explicitly enable this "connector". (Set it to "true").
Enabled = CheckAuthentication();
// URL path to user files.
UserFilesPath = "/userfiles/";
// The connector tries to resolve the above UserFilesPath automatically.
// Use the following setting it you prefer to explicitely specify the
// absolute path. Examples: 'C:\\MySite\\userfiles\\' or '/root/mysite/userfiles/'.
// Attention: The above 'UserFilesPath' URL must point to the same directory.
UserFilesAbsolutePath = "";
// Due to security issues with Apache modules, it is recommended to leave the
// following setting enabled.
ForceSingleExtension = true;
// Allowed Resource Types
AllowedTypes = new string[] { "File", "Image", "Flash", "Media" };
// For security, HTML is allowed in the first Kb of data for files having the
// following extensions only.
HtmlExtensions = new string[] { "html", "htm", "xml", "xsd", "txt", "js" };
TypeConfig[ "File" ].AllowedExtensions = new string[] { "7z", "aiff", "asf", "avi", "bmp", "csv", "doc", "fla", "flv", "gif", "gz", "gzip", "jpeg", "jpg", "mid", "mov", "mp3", "mp4", "mpc", "mpeg", "mpg", "ods", "odt", "pdf", "png", "ppt", "pxd", "qt", "ram", "rar", "rm", "rmi", "rmvb", "rtf", "sdc", "sitd", "swf", "sxc", "sxw", "tar", "tgz", "tif", "tiff", "txt", "vsd", "wav", "wma", "wmv", "xls", "xml", "zip" };
TypeConfig[ "File" ].DeniedExtensions = new string[] { };
string filepath = "%UserFilesPath%" + m_userName + "/file/";
TypeConfig["File"].FilesPath = filepath;
TypeConfig["File"].FilesAbsolutePath = (UserFilesAbsolutePath == "" ? "" : "%UserFilesAbsolutePath%file/");
TypeConfig["File"].QuickUploadPath = filepath; // "%UserFilesPath%" + m_userName + "/";
TypeConfig["File"].QuickUploadAbsolutePath = filepath; // (UserFilesAbsolutePath == "" ? "" : "%UserFilesAbsolutePath%");
TypeConfig[ "Image" ].AllowedExtensions = new string[] { "bmp", "gif", "jpeg", "jpg", "png" };
TypeConfig[ "Image" ].DeniedExtensions = new string[] { };
string imagepath = "%UserFilesPath%" + m_userName + "/image/";
TypeConfig["Image"].FilesPath = imagepath;
TypeConfig["Image"].FilesAbsolutePath = (UserFilesAbsolutePath == "" ? "" : "%UserFilesAbsolutePath%image/");
TypeConfig["Image"].QuickUploadPath = imagepath; // "%UserFilesPath%" + m_userName + "/";
TypeConfig["Image"].QuickUploadAbsolutePath = (UserFilesAbsolutePath == "" ? "" : "%UserFilesAbsolutePath%");
TypeConfig[ "Flash" ].AllowedExtensions = new string[] { "swf", "flv" };
TypeConfig[ "Flash" ].DeniedExtensions = new string[] { };
TypeConfig[ "Flash" ].FilesPath = "%UserFilesPath%flash/";
TypeConfig[ "Flash" ].FilesAbsolutePath = ( UserFilesAbsolutePath == "" ? "" : "%UserFilesAbsolutePath%flash/" );
TypeConfig[ "Flash" ].QuickUploadPath = "%UserFilesPath%";
TypeConfig[ "Flash" ].QuickUploadAbsolutePath = ( UserFilesAbsolutePath == "" ? "" : "%UserFilesAbsolutePath%" );
TypeConfig[ "Media" ].AllowedExtensions = new string[] { "aiff", "asf", "avi", "bmp", "fla", "flv", "gif", "jpeg", "jpg", "mid", "mov", "mp3", "mp4", "mpc", "mpeg", "mpg", "png", "qt", "ram", "rm", "rmi", "rmvb", "swf", "tif", "tiff", "wav", "wma", "wmv" };
TypeConfig[ "Media" ].DeniedExtensions = new string[] { };
TypeConfig[ "Media" ].FilesPath = "%UserFilesPath%media/";
TypeConfig[ "Media" ].FilesAbsolutePath = ( UserFilesAbsolutePath == "" ? "" : "%UserFilesAbsolutePath%media/" );
TypeConfig[ "Media" ].QuickUploadPath = "%UserFilesPath%";
TypeConfig[ "Media" ].QuickUploadAbsolutePath = ( UserFilesAbsolutePath == "" ? "" : "%UserFilesAbsolutePath%" );
}
1. 下載FCKeditor 2.6 基本文件(Main Code)。將解壓縮的文件復(fù)制到項(xiàng)目的editors/FCKEditorV2 目錄下。
2. 下載 FCKeditor.Net / ASP.NET 控件,復(fù)制FredCK.FCKeditorV2.dll 文件到項(xiàng)目的bin目錄。
這樣就基本可以FCKEditor v2.6 超強(qiáng)的編輯器了,當(dāng)然還需要在Host Settings中設(shè)置默認(rèn)的編輯器。
關(guān)于 FCKEditor 的一些基本配置信息,請(qǐng)參考如下的文章:
如需要使用文件上傳功能,還需要修改代碼FCKEditorV2/editor/filemanager/connectors/config.ascx(以ASPX代碼為例)。這里限制只有登錄的用戶才可以使用文件上傳功能,并且上傳的文件只能上傳到用戶自己的目錄。根據(jù)每個(gè)用戶名自動(dòng)創(chuàng)建對(duì)應(yīng)的文件上傳目錄。


connectors/config.ascx 更新后的代碼如下:
復(fù)制代碼 代碼如下:
/**
* This function must check the user session to be sure that he/she is
* authorized to upload and access files in the File Browser.
*/
private string m_userName;
private int m_userID;
private int m_boardID;
private bool m_isAuthenticated;
private bool 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 ( Session[ "IsAuthorized" ] != null && (bool)Session[ "IsAuthorized" ] == true );
//
// ... where Session[ "IsAuthorized" ] is set to "true" as soon as the
// user logs in your system.
string userName = HttpContext.Current.User.Identity.Name;
try
{
if (HttpContext.Current.User.Identity.IsAuthenticated)
{
string[] parts = userName.Split(';');
if (parts.Length == 3)
{
m_userID = int.Parse(parts[0]);
m_boardID = int.Parse(parts[1]);
m_userName = parts[2];
m_isAuthenticated = true;
}
}
}
catch (Exception)
{
m_userName = "";
m_userID = 0;
m_boardID = 0;
m_isAuthenticated = false;
}
return m_isAuthenticated;
}
public override void SetConfig()
{
// SECURITY: You must explicitly enable this "connector". (Set it to "true").
Enabled = CheckAuthentication();
// URL path to user files.
UserFilesPath = "/userfiles/";
// The connector tries to resolve the above UserFilesPath automatically.
// Use the following setting it you prefer to explicitely specify the
// absolute path. Examples: 'C:\\MySite\\userfiles\\' or '/root/mysite/userfiles/'.
// Attention: The above 'UserFilesPath' URL must point to the same directory.
UserFilesAbsolutePath = "";
// Due to security issues with Apache modules, it is recommended to leave the
// following setting enabled.
ForceSingleExtension = true;
// Allowed Resource Types
AllowedTypes = new string[] { "File", "Image", "Flash", "Media" };
// For security, HTML is allowed in the first Kb of data for files having the
// following extensions only.
HtmlExtensions = new string[] { "html", "htm", "xml", "xsd", "txt", "js" };
TypeConfig[ "File" ].AllowedExtensions = new string[] { "7z", "aiff", "asf", "avi", "bmp", "csv", "doc", "fla", "flv", "gif", "gz", "gzip", "jpeg", "jpg", "mid", "mov", "mp3", "mp4", "mpc", "mpeg", "mpg", "ods", "odt", "pdf", "png", "ppt", "pxd", "qt", "ram", "rar", "rm", "rmi", "rmvb", "rtf", "sdc", "sitd", "swf", "sxc", "sxw", "tar", "tgz", "tif", "tiff", "txt", "vsd", "wav", "wma", "wmv", "xls", "xml", "zip" };
TypeConfig[ "File" ].DeniedExtensions = new string[] { };
string filepath = "%UserFilesPath%" + m_userName + "/file/";
TypeConfig["File"].FilesPath = filepath;
TypeConfig["File"].FilesAbsolutePath = (UserFilesAbsolutePath == "" ? "" : "%UserFilesAbsolutePath%file/");
TypeConfig["File"].QuickUploadPath = filepath; // "%UserFilesPath%" + m_userName + "/";
TypeConfig["File"].QuickUploadAbsolutePath = filepath; // (UserFilesAbsolutePath == "" ? "" : "%UserFilesAbsolutePath%");
TypeConfig[ "Image" ].AllowedExtensions = new string[] { "bmp", "gif", "jpeg", "jpg", "png" };
TypeConfig[ "Image" ].DeniedExtensions = new string[] { };
string imagepath = "%UserFilesPath%" + m_userName + "/image/";
TypeConfig["Image"].FilesPath = imagepath;
TypeConfig["Image"].FilesAbsolutePath = (UserFilesAbsolutePath == "" ? "" : "%UserFilesAbsolutePath%image/");
TypeConfig["Image"].QuickUploadPath = imagepath; // "%UserFilesPath%" + m_userName + "/";
TypeConfig["Image"].QuickUploadAbsolutePath = (UserFilesAbsolutePath == "" ? "" : "%UserFilesAbsolutePath%");
TypeConfig[ "Flash" ].AllowedExtensions = new string[] { "swf", "flv" };
TypeConfig[ "Flash" ].DeniedExtensions = new string[] { };
TypeConfig[ "Flash" ].FilesPath = "%UserFilesPath%flash/";
TypeConfig[ "Flash" ].FilesAbsolutePath = ( UserFilesAbsolutePath == "" ? "" : "%UserFilesAbsolutePath%flash/" );
TypeConfig[ "Flash" ].QuickUploadPath = "%UserFilesPath%";
TypeConfig[ "Flash" ].QuickUploadAbsolutePath = ( UserFilesAbsolutePath == "" ? "" : "%UserFilesAbsolutePath%" );
TypeConfig[ "Media" ].AllowedExtensions = new string[] { "aiff", "asf", "avi", "bmp", "fla", "flv", "gif", "jpeg", "jpg", "mid", "mov", "mp3", "mp4", "mpc", "mpeg", "mpg", "png", "qt", "ram", "rm", "rmi", "rmvb", "swf", "tif", "tiff", "wav", "wma", "wmv" };
TypeConfig[ "Media" ].DeniedExtensions = new string[] { };
TypeConfig[ "Media" ].FilesPath = "%UserFilesPath%media/";
TypeConfig[ "Media" ].FilesAbsolutePath = ( UserFilesAbsolutePath == "" ? "" : "%UserFilesAbsolutePath%media/" );
TypeConfig[ "Media" ].QuickUploadPath = "%UserFilesPath%";
TypeConfig[ "Media" ].QuickUploadAbsolutePath = ( UserFilesAbsolutePath == "" ? "" : "%UserFilesAbsolutePath%" );
}
相關(guān)文章
解決SyntaxHighlighter 代碼高亮不換行問題的解決方法
用SyntaxHighlighter 語法高亮插件的朋友可能都遇到過代碼顯示不換行的問題,這個(gè)問題在網(wǎng)上也找不到什么解決辦法,一直困擾了我很久,今天算是把它解決了,辦法其實(shí)簡單,下面說下如何解決2014-11-11
fckeditor在php中的用法(添加于修改寫成了函數(shù))
這里就不多說了,看代碼。后面有說明。2009-12-12
FCKEditor超級(jí)鏈接默認(rèn)新窗口打開的修改方法
經(jīng)常在后臺(tái)編輯超鏈接的朋友,希望將頁面鏈接,默認(rèn)是新窗口打開,因?yàn)檫@樣用戶體驗(yàn)好點(diǎn),所以將FCKEditor簡單的修改下。2010-06-06
百度ueditor組件上傳圖片后如何設(shè)置img里的alt屬性
百度ueditor組件,使用上傳圖片后,設(shè)置了一個(gè)alt屬性,其值是上傳圖片時(shí)的本地路徑,如果想更改的話可以參考下面的解決方法2014-09-09
解密FCKeditor 2.0 的設(shè)置.修改.使用方法
解密FCKeditor 2.0 的設(shè)置.修改.使用方法...2007-11-11
dedecms ckeditor編輯器添加鏈接默認(rèn)新窗口打開的修改方法
最近使用了dedecms ckeditor編輯器,發(fā)現(xiàn)每次都是當(dāng)前頁打開,對(duì)用戶瀏覽造成一定的麻煩,所以特改成新窗口打開,這里腳本之家小編為大家分享下2014-07-07
又一個(gè)不錯(cuò)的FCKeditor 2.2的安裝、修改和調(diào)用方法
又一個(gè)不錯(cuò)的FCKeditor 2.2的安裝、修改和調(diào)用方法...2007-11-11

