【问题标题】:Ckeditor intigration with CKfinderCKeditor 与 CKfinder 的集成
【发布时间】:2012-02-22 12:39:35
【问题描述】:

我将 Ck finder 与 Ck Editor 集成,但是当我单击浏览按钮时,一个窗口出现在我面前,并显示一条消息:

“出于安全原因,文件浏览器已禁用。请联系您的系统管理员并检查 Ck Finder 配置文件”

我不知道该怎么办

【问题讨论】:

  • 一个好的第一步是谷歌错误信息:The file browser is disabled for security reasons. Please contact your system administrator and check the Ck Finder configuration file我认为第一次点击回答了你的问题
  • 是的,我已经检查过了,也照他说的做了,但我仍然面临同样的问题
  • 好的,非常感谢Pekka,我知道任何面临这个问题的人都应该使用这个代码|函数 CheckAuthentication() { 返回真; } 而不是那个函数 CheckAuthentication() { return false; }
  • @user1210460 实际上,如果您阅读该代码上方的 cmets,它会说“不要只返回 true”;应该与 ACL 结合使用

标签: php ckfinder


【解决方案1】:
  1. 下载 CKEditor 和 CKFinder。
  2. 将两者的提取代码放在 xampp 内的一个文件夹中,如下所示。
  3. 创建包含编辑器的索引文件(index.html),如下代码。

    <html>
    <head>
    <script type="text/javascript" src="ckeditor/ckeditor.js"></script>
    <script type="text/javascript" src="ckfinder/ckfinder.js"></script>
    </head>
    <body>
        <h1>CKEditor CKFinder Integration using PHP</h1>
        <textarea id="editor1" name="editor1" rows="10" cols="80"></textarea>
    <script type="text/javascript">
    var editor = CKEDITOR.replace( 'editor1', {
        filebrowserBrowseUrl : 'ckfinder/ckfinder.html',
        filebrowserImageBrowseUrl : 'ckfinder/ckfinder.html?type=Images',
        filebrowserFlashBrowseUrl : 'ckfinder/ckfinder.html?type=Flash',
        filebrowserUploadUrl : 'ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files',
        filebrowserImageUploadUrl : 'ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images',
        filebrowserFlashUploadUrl : 'ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Flash'
    });
    CKFinder.setupCKEditor( editor, '../' );
    </script>
    </body>
    </html>
    

所以你的文件夹结构会是这样的:

文档 |_集成 |_ckeditor | |_config.js | |_... |_ckfinder | |_config.php | |_... |_上传 |_index.html
  1. 现在在 ckfinder 中打开文件 config.php 并进行以下更改:

    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'];
        return true; // not good option though; go for sessions
    }
    $baseUrl = 'http://localhost/integrated/uploads/';
    $enabled = true;
    $config['SecureImageUploads'] = false;
    $config['ChmodFolders'] = 0777 ;
    
  2. 现在打开网址http://localhost/integrated/ 并尝试上传图片。

【讨论】:

  • 虽然这在理论上可以回答这个问题,it would be preferable 在此处包含答案的基本部分,并提供链接以供参考。此处不欢迎仅提供链接的答案。
  • 您是否费心阅读“不要只在 CheckAuthentication 函数中返回 true”的评论?您现在已经为您服务器上的每个人提供了免费托管服务。
【解决方案2】:
Here:

    function CheckAuthentication()
    {

        return false;
    }

默认情况下 CheckAuthentication() 出于安全原因禁用它,因为它允许任何人将文件上传到您的服务器。

出于测试目的,您可以返回true,但关键是您实现了一些逻辑来仅授权经过身份验证的用户。

    function CheckAuthentication()
    {
        //put some logic here

        return isset($_SESSION['IsAuthorized']) && $_SESSION['IsAuthorized'];
    }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-10-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-23
    • 2018-05-12
    相关资源
    最近更新 更多