Objective
FCKeditor is the use of a very wide range of HTML editors, this article from the asp.net of the use of FCKeditor and fckeditor.net configuration, function extension (such as the custom file upload subdirectory, custom file name, upload image post-processing, etc.), As well as the security of the preliminary elaboration.
I hope you will be able to help colleagues with the same needs save a little time, and I hope you can correct the deficiencies. Thank you.
First, the custom FCKeditor basepath
BasePath is the FCKeditor relative path in the Web site, the default is/fckeditor/, preferably in web.config appsettings:
<add key= "Fckeditor:basepath" value= "/fckeditor_2.6.3/"/>
There are many advantages to doing this:
The development environment is different from the production environment, the development environment is generally http://localhost/xxx.com/in this case the FCKeditor will have to be placed in a virtual directory http://localhost/fckeditor/, if the development of multiple Web sites is involved, And each website's fckeditor has the difference, this obviously is not the optimal;
And because the physical directory structure and the logical directory structure are different, there will be the hidden trouble of error;
If the Web.config configuration is adopted, different configurations can be used in the development environment, and the physical path of FCKeditor is consistent with the production environment;
When upgrading FCKeditor, just put the new version of the FCKeditor in the corresponding version number of the directory, modify the configuration can be. This solves the problem that different users have different errors because of the client caching problem of static resources;
You can visually see the version number of your own fckeditor.
Second, the configuration file upload directory
FCKeditor file upload (such as image upload) directory can be configured through Web.config appsettings, such as:
<add key= "Fckeditor:userfilespath" value= "/uploadfile/fckeditor/"/>
Can also be configured in/fckeditorbasepath/editor/filemanager/connectors/aspx/config.ascx, but I recommend that FCKeditor Contents of the directory can be changed without change (except Fckconfig.js), so that future upgrades can be safely replaced.
Third, custom file Upload subdirectory format
We know that a folder cannot have too many files under it (it is said that 2000 of the directory under Windows is a threshold), otherwise access to that directory can severely affect I/O performance. The FCKeditor file Store is in a single directory. I have extended the fckeditor to customize the format of the storage directory in Web.config appsettings, such as:
<add key= "Fckeditor:folderpattern" value= "%y/%m-%d/"/>
========================================
Take today's date as an example: the resulting file Upload subdirectory format is: 2008/10-21/.
The calendar of year and month format can be grouped randomly, such as:
<add key= "Fckeditor:folderpattern" value= "%y/%m/%d/"/>
The resulting file Upload subdirectory becomes the 2008/10/21/
========================================
You can also use different upload subdirectories for different logged-in users
Web.config modify the configuration of the upload subdirectory to increase%u to indicate that different users use a different upload subdirectory based on their identity
<add key= "Fckeditor:folderpattern" value= "%u/%y/%m/%d/"/>
Fckeditor_2.6.3\editor\filemanager\connectors\aspx\config.ascx to increase the logic for obtaining the identity of the current logged-on user
Copy Code code as follows:
public override void Setconfig ()
{
#region Bochuh ' s modification
Identifier for logined User
Leave blank for Default User upload folder
Logineduseridentifier = "44"; Here to get the code represented by the current logged-on user
#endregion
...... The original code in this file
}
This can be used for different users, based on their login identity (typically the user ID), to use a different directory for storage, such as: 7394/2008/10/21/(7394 is the ID of the current logged-on user)
Reference:
%u represents the identity of the current logged-on user
%y the year that represents the current time
%m represents the month of the current time
%d represents the day of the current time
iv. customizing file name formats for uploaded files
FCKeditor the rule of the file name is: If there is no duplicate file name in the current directory, then the file name after the upload is the same as the filename on the user's PC; if there are n duplicate files, the filename on the user's PC is example.xxx and the file name after the upload becomes: Example (n) . xxx
My project requires the user to upload the file name into a GUID format, so I have also extended the FCKeditor, in Web.config appsettings can be uploaded to the format of the file customization, such as:
<add key= "Fckeditor:filenamepattern" value= "%guid.%extl"/>
Such a file name as: a299e63a-7d2d-493d-bbb9-99162ef5b6b8.gif
Reference:
%guid represents a new GUID string
%FNL represents the lower case of the source file name
%FNU represents the capitalization of the source file name
%EXTL represents the lower case of the source file name extension
%extu represents the capitalization of the source file name extension
Five, the upload image to zoom processing
A lot of the content is published in the scene where FCKeditor pictures are uploaded. The content often does not need thousands of pixel size picture, for example my project, the article area is widest also is 560 pixels, so I have made an extension, in Web.config appsettings can customize the maximum width of the picture:
<add key= "fckeditor:maxwidthofuploadedimg" value= "560"/>
With this configuration, the upload image width is controlled in 560 pixels and within
Six, custom upload the image URL after the domain name
In order to speed up the rendering of the page, we can put the picture and other static resources in a separate domain name. But fckeditor default image upload URL is relative path, as shown in figure:
I added this extension to the Web.config appsettings can be configured to upload the image URL after the domain name, such as:
<add key= "Fckeditor:uploadedfilesdomain" value= "http://a.cvimg.cn/"/>
As shown in figure:
Solve the problem that prompts "invalid file type" when uploading file names containing Chinese files
This problem needs to be addressed only by adding a section of the configuration to the web.config:
Copy Code code as follows:
<location path= "Fckeditor_2.6.3/editor/filemanager/connectors/aspx/upload.aspx" >
<system.web>
<globalization requestencoding= "Utf-8" responseencoding= "gb2312"/>
</system.web>
</location>
Attention:
ResponseEncoding is the default encoding for Web sites
fckeditor_2.6.3 is FCKeditor's basepath.
Viii. Security of FCKeditor
In the 2.3.2 version of FCKeditor, there was a vulnerability to upload arbitrary files to the server via/editor/filemanager/browser/default/connectors/aspx/connector.aspx, My site has been a trick.
2.6.3 Although not found a similar problem, but generally do not use the best file to delete better:
FCKeditor BasePath root directory In addition to reserved:
/editor
/fckconfig.js
/fckpackager.xml
/fckstyles.xml
/fcktemplates.xml
/license.txt
Outside, delete all
In addition to retention in/editor/filemanager/:
/connectors/aspx/config.ascx
/connectors/aspx/upload.aspx
Outside, delete all
Delete/editor/_source/
In/editor/filemanager/connectors/aspx/config.ascx's Checkauthentication () method, increase the logic for verifying that a user is logged on
Note: The above measures only apply to the ASP.net website, other language versions of the site are not considered.
Attached: Based on the fckeditor.net_2.6.3 modified source code
Source:http://xiazai.jb51.net/201108/yuanma/fckeditor.net_2.6.3_20090713.zip
BIN (. NET 2.0): Http://xiazai.jb51.net/201108/yuanma/FredCK.FCKeditorV2_20090713.zip
The specified line for the following file was modified,
/filebrowser/config.cs Line 45, 116, 169
/filebrowser/fileworkerbase.cs Line 68, 98, 110, 125, 278
All modifications are included in the code block named "Zhubo ' modification", or you can quickly see the changes by searching for the "Zhubo ' modification" in the entire project (for example, you can set the maximum height of the picture)
Updated at 2008-11-11
New optional user ID to allow different users to use a separate picture upload subdirectory, see the above "three, custom file Upload subdirectory format" of the update section.
The new source and DLL files have also been updated.
Updated at 2009-07-06
Thanks to the new hand of the Novice's discovery, fixed the following bug: Not Configured Fckeditor:folderpattern, or Fckeditor:folderpattern is empty, upload the image after the successful path of a "/"
Updated at 2009-07-13
The picture suffix, named. gif, does not compress to prevent the animation from being lost.