让FCKeditor支持多用户环境(asp.net)

摘要:
目前,使用最多的html编辑器属于FCKeditor。以下是网络版本。我使用的FCKeditor服务器版本是FCKeditr。Net_2.6.3客户端版本为FCKeditor_2.6.4.1FCKeditor的配置非常简单。请参阅http://www.cnblogs.com/AlexCheng/archive/2009/08/18/1548701.html步骤1:配置web配置文件添加之间--是否启用多用户支持-->查找FCKeditor客户端/FCKeditor/editor/filemanager/connectors.aspx/config Ascx打开代码12242526/**27*此函数必须检查用户会话,以确保其28*已授权在文件浏览器中加载和访问文件。29*/30privateboolCheckAuthentication()31{32//警告:不要简单地返回“true”。通过这样做,您可以允许33//“任何人”在您的服务器中部署和侦听文件。您必须在此处执行34//某种会话验证。即使是简单的…35//36//return(会话[“已授权”]!

  在开发用户管理功能时通常遇到这样一种情况:不同用户上传的图片等文件需要彼此隔离,也就是说每个用户在服务器上需要有一个单独的文件夹用于文件或图片存储。

  目前用的最多的html编辑器要属FCKeditor。下面以.net版本为例,我介绍一下如何实现以上功能。

  我使用的FCKeditor服务器版本为FCKeditor.Net_2.6.3 客户端版本为FCKeditor_2.6.4.1。FCKeditor的配置非常简单请参考        http://www.cnblogs.com/AlexCheng/archive/2009/08/18/1548701.html

  第一步配置web.config文件在<appSettings></appSettings>之间加入

  

 

<!--FCKedit配置-->
    
<!--是否开启多用户支持-->
    
<add key="FCKeditor:MultiUser" value="true"/>
        
<add key="FCKeditor:BasePath" value="/webuser/fckeditor/"/>
    
<!--多用户存储路径:/webuser/userfiles/+Session["uid"].ToString()+"/"-->
    
<add key="FCKeditor:MultiUserPath" value="/webuser/userfiles/"/>
    
<!--Session["uid"]过期或未设置-->
<add key
="FCKeditor:UserFilesPath" value="/webuser/userfiles/temp/"/>

    找到FCKeditor客户端/fckeditor/editor/filemanager/connectors/aspx/config.ascx 打开

让FCKeditor支持多用户环境(asp.net)第1张让FCKeditor支持多用户环境(asp.net)第2张代码
  1 <%@ Control Language="C#" EnableViewState="false" AutoEventWireup="false" Inherits="FredCK.FCKeditorV2.FileBrowser.Config" %>
  2 <%--
  3  * FCKeditor - The text editor for Internet - http://www.fckeditor.net
  4  * Copyright (C) 2003-2009 Frederico Caldeira Knabben
  5  *
  6  * == BEGIN LICENSE ==
  7  *
  8  * Licensed under the terms of any of the following licenses at your
  9  * choice:
 10  *
 11  *  - GNU General Public License Version 2 or later (the "GPL")
 12  *    http://www.gnu.org/licenses/gpl.html
 13  *
 14  *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
 15  *    http://www.gnu.org/licenses/lgpl.html
 16  *
 17  *  - Mozilla Public License Version 1.1 or later (the "MPL")
 18  *    http://www.mozilla.org/MPL/MPL-1.1.html
 19  *
 20  * == END LICENSE ==
 21  *
 22  * Configuration file for the File Browser Connector for ASP.NET.
 23 --%>
 24 <script runat="server">
 25 
 26     /**
 27      * This function must check the user session to be sure that he/she is
 28      * authorized to upload and access files in the File Browser.
 29      */
 30     private bool CheckAuthentication()
 31     {
 32         // WARNING : DO NOT simply return "true". By doing so, you are allowing
 33         // "anyone" to upload and list the files in your server. You must implement
 34         // some kind of session validation here. Even something very simple as...
 35         //
 36         //        return ( Session[ "IsAuthorized" ] != null && (bool)Session[ "IsAuthorized" ] == true );
 37         //
 38         // ... where Session[ "IsAuthorized" ] is set to "true" as soon as the
 39         // user logs in your system.
 40 
 41         return true;
 42     }
 43 
 44     public override void SetConfig()
 45     {
 46         // SECURITY: You must explicitly enable this "connector". (Set it to "true").
 47         Enabled = CheckAuthentication();
 48         if (System.Configuration.ConfigurationSettings.AppSettings["FCKeditor:MultiUser"== "true")
 49         {
 50 
 51             if (HttpContext.Current.Session["uid"]!=null)
 52             {
 53                 UserFilesPath = System.Configuration.ConfigurationSettings.AppSettings["FCKeditor:MultiUserPath"+ HttpContext.Current.Session["uid"+ "/";
 54                 Session["FCKeditor:UserFilesPath"= UserFilesPath;
 55             }
 56             else
 57             {
 58                 UserFilesPath = System.Configuration.ConfigurationSettings.AppSettings["FCKeditor:UserFilesPath"];
 59                 Session["FCKeditor:UserFilesPath"= UserFilesPath;
 60             }
 61         }
 62         else
 63         {
 64             UserFilesPath = "/Upload/";
 65         }
 66         // URL path to user files.
 67         //UserFilesPath = "/Upload/";
 68 
 69         // The connector tries to resolve the above UserFilesPath automatically.
 70         // Use the following setting it you prefer to explicitely specify the
 71         // absolute path. Examples: 'C:\\MySite\\userfiles\\' or '/root/mysite/userfiles/'.
 72         // Attention: The above 'UserFilesPath' URL must point to the same directory.
 73         UserFilesAbsolutePath = "";
 74 
 75         // Due to security issues with Apache modules, it is recommended to leave the
 76         // following setting enabled.
 77         ForceSingleExtension = true;
 78 
 79         // Allowed Resource Types
 80         AllowedTypes = new string[] { "File""Image""Flash""Media" };
 81 
 82         // For security, HTML is allowed in the first Kb of data for files having the
 83         // following extensions only.
 84         HtmlExtensions = new string[] { "html""htm""xml""xsd""txt""js" };
 85 
 86         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" };
 87         TypeConfig[ "File" ].DeniedExtensions            = new string[] { };
 88         TypeConfig[ "File" ].FilesPath                    = "%UserFilesPath%file/";
 89         TypeConfig[ "File" ].FilesAbsolutePath            = ( UserFilesAbsolutePath == "" ? "" : "%UserFilesAbsolutePath%file/" );
 90         TypeConfig[ "File" ].QuickUploadPath            = "%UserFilesPath%";
 91         TypeConfig[ "File" ].QuickUploadAbsolutePath    = ( UserFilesAbsolutePath == "" ? "" : "%UserFilesAbsolutePath%" );
 92 
 93         TypeConfig[ "Image" ].AllowedExtensions            = new string[] { "bmp""gif""jpeg""jpg""png" };
 94         TypeConfig[ "Image" ].DeniedExtensions            = new string[] { };
 95         TypeConfig[ "Image" ].FilesPath                    = "%UserFilesPath%image/";
 96         TypeConfig[ "Image" ].FilesAbsolutePath            = ( UserFilesAbsolutePath == "" ? "" : "%UserFilesAbsolutePath%image/" );
 97         TypeConfig[ "Image" ].QuickUploadPath            = "%UserFilesPath%";
 98         TypeConfig[ "Image" ].QuickUploadAbsolutePath    = ( UserFilesAbsolutePath == "" ? "" : "%UserFilesAbsolutePath%" );
 99 
100         TypeConfig[ "Flash" ].AllowedExtensions            = new string[] { "swf""flv" };
101         TypeConfig[ "Flash" ].DeniedExtensions            = new string[] { };
102         TypeConfig[ "Flash" ].FilesPath                    = "%UserFilesPath%flash/";
103         TypeConfig[ "Flash" ].FilesAbsolutePath            = ( UserFilesAbsolutePath == "" ? "" : "%UserFilesAbsolutePath%flash/" );
104         TypeConfig[ "Flash" ].QuickUploadPath            = "%UserFilesPath%";
105         TypeConfig[ "Flash" ].QuickUploadAbsolutePath    = ( UserFilesAbsolutePath == "" ? "" : "%UserFilesAbsolutePath%" );
106 
107         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" };
108         TypeConfig[ "Media" ].DeniedExtensions            = new string[] { };
109         TypeConfig[ "Media" ].FilesPath                    = "%UserFilesPath%media/";
110         TypeConfig[ "Media" ].FilesAbsolutePath            = ( UserFilesAbsolutePath == "" ? "" : "%UserFilesAbsolutePath%media/" );
111         TypeConfig[ "Media" ].QuickUploadPath            = "%UserFilesPath%";
112         TypeConfig[ "Media" ].QuickUploadAbsolutePath    = ( UserFilesAbsolutePath == "" ? "" : "%UserFilesAbsolutePath%" );
113     }
114 
115 </script>
116 

 第四步,在用户登录时给Session["uid"]赋值

这样遍可实现FCKeditor多用户功能。

免责声明:内容来源于网络,仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇ESRI系列产品报价表(ArcGIS 9.2系列)Android开发记录下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

常用的富文本框插件FreeTextBox、CuteEditor、CKEditor、FCKEditor、TinyMCE、KindEditor ;和CKEditor实例

http://www.cnblogs.com/cxd4321/archive/2013/01/30/2883078.html 目前市面上用的比较多的富文本编辑器有: FreeTextBox一个有很多年历史的富文本编辑器了,使用简单,而且一般的使用是免费的,但是不开源,上传图片上传附件等功能没有,扩展性差。 CuteEditor最强大的富文本编辑器,巨牛无...

CkEditor文本编辑器配合ckfinder上传功能在.net中的使用步骤

1.官网下载ckeditor: http://ckeditor.com/download   本文使用Version:CKEditor 3.6.4 for ASP.NET, Released 8 Aug 2012 2.选择_Samples目录下面的ckeditor,删除 CHANGES.html、INSTALL.html、LICENSE.html后,把整个c...

CKEditor5入门教程

下载CKEditor5 使用CK5原因 因为CK4的内联编辑与VUE不兼容 CK4-VUE可定制内容太少 所以选择CK5 但是在兼容性上 CK5 不如CK4 网上关于CKEditor教程实在太少 有用点个赞 下载地址:https://ckeditor.com/ckeditor-5/download/ 下载后的目录结构 现在尝试安装官方提供的数学公式插件和高...

ckeditor粘贴word图片且图片文件自动上传功能

自动导入Word图片,或者粘贴Word内容时自动上传所有的图片,并且最终保留Word样式,这应该是Web编辑器里面最基本的一个需求功能了。一般情况下我们将Word内容粘贴到Web编辑器(富文本编辑器)中时,编辑器都无法自动上传图片。需要用户手动一张张上传Word图片。如果只有一张图片还能够接受,如果图片数量比较多,这种操作就显得非常的麻烦。1、只粘贴图片并...

从word中复制内容包含图片到fckeditor编辑器中

如何做到 ueditor批量上传word图片? 1、前端引用代码 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="ht...

Redmine:CKEditor插件安装

下载CKEditor插件:https://github.com/ebrahim/redmine_ckeditor; 解压到{Redmine安装目录}\apps\redmine\htdocs\vendor\plugins下,目录改名为redmine_ckeditor; 安装插件时保证Redmine在运行状态,有些插件安装时要访问MySql(例如CodeRe...