zoukankan      html  css  js  c++  java
  • Ckeditor配置

    • 配置参考文档,主要将ckeditor中的(adapters、images、lang、plugins、skins、themes、ckeditor.js、config.js、contents.css)解压到js目录,然后“显示所有文件”,将ckeditor的目录“包含在项目中”,在发帖页面引用ckeditor.js,然后设置多行文本框的class="ckeditor"(CSS强大)(服务端控件CssClas=" ckeditor ",客户端控件要设定cols、rows属性,一般不直接用html控件),代码中仍然可以通过TextBox控件的Text属性来访问编辑器内容。
    • 由于页面提交的时候asp.net会把富文本编辑器中的html内容当成攻击内容,因此需要在aspx中的Page标签中设置 ValidateRequest="false" 来禁用攻击检测(2010中还要根据报错信息修改WebConfig来禁用XSS检测)。
    •  CKFinder是一个CKEditor插件,用来为CKEditor提供文件的上传的功能。将binRelease下的CKFinder.dll添加到项目的引用;将core、ckfinder.js、ckfinder.html、config.ascx解压到CKFinder自己的目录。按照文档修改CKEditor的config.js,将上传的处理程序设定为CKFinder,注意路径的问题。

    • 使用测试,在插入超链接、插入图片、插入文件中都有“上传”

    • 因为上传文件是非常危险的动作,因此在文件上传的时候会进行权限校验。在config.ascx的CheckAuthentication方法中校验是否有权限上传,返回true表示有权限,否则没有权限,一般修改成判断用户是否登录,并且登录用户是有上传权限的用户,可以用Session或者Membership来做。思考:如何实现只有指定IP地址的用户才能上传?
    • 在SetConfig函数中设置上传文件夹的位置BaseUrl、缩略图的位置,每种类型数据的上传路径、允许上传的文件类型AllowedExtensions等。

    为了使用ckfinder还需要在vs2010的web.config中加入
     <!--为了使用ckeditor-->
            < pages validateRequest ="false " />
            < httpRuntime requestValidationMode ="2.0 " />
     <!-- 为a了使用ckeditor -->
    以及



    • 使用ckfinder的配置,在ckeitor的config.js文件中加入如下
    • 还需要复制出“CKFinder.dll”添加到项目的引用中

    var ckfinderPath = "/SCDAadmin/js" ;
        config.filebrowserBrowseUrl = ckfinderPath + '/ckfinder/ckfinder.html';
        config.filebrowserImageBrowseLinkUrl = ckfinderPath + '/ckfinder/ckfinder.html?Type=Images' ;
        config.filebrowserFlashBrowseLinkUrl = ckfinderPath + '/ckfinder/ckfinder.html?Type=Flash' ;
        config.filebrowserUploadUrl = ckfinderPath + '/ckfinder/core/connector/aspx/connector.aspx?command=QuickUpload&type=Files' ;
        config.filebrowserImageUploadUrl = ckfinderPath + '/ckfinder/core/connector/aspx/connector.aspx?command=QuickUpload&type=Images' ;
        config.filebrowserFlashUploadUrl = ckfinderPath + '/ckfinder/core/connector/aspx/connector.aspx?command=QuickUpload&type=Flash' ;


    这时候还是有安全限制

    打开ckfinder的config.ascx
    修改里面的
    public override 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 on your system.
                  object obj = Session["admin_login" ];
            if (obj != null && Convert.ToBoolean(obj) == true)
                return true ;
            else
                return false ;
                   return false ;
                   }


  • 相关阅读:
    【NOIP2018】游记
    题解 P1441 【砝码称重】
    题解 P3128 【[USACO15DEC]最大流Max Flow】
    题解 P1949 【聪明的打字员_NOI导刊2011提高(10)】
    题解 P1966 【火柴排队】
    题解 P1895 【数字序列】
    topcoder做题
    1149E
    hdu 6589
    hdu 6579
  • 原文地址:https://www.cnblogs.com/zhxshseu/p/5292221.html
Copyright © 2011-2022 走看看