ckeditor webshell .php,折腾CKeditor与CKfinder的一点心得 - WEB前台 - CKeditor -...

提到CKeditor、CKfinder,大家也许有些陌生,但提到FCKeditor,一定大名鼎鼎了。CKeditor与CKfinder就是它的新版本。

In 2009, we decided to rename the editor, bringing to light the next generation of our software: CKEditor 3.0.

需要注意的是新版本的CKeditor是不能上传和管理文件的,如果需要上传、管理文件需要安装它的姊妹产品:CKfinder。

不过貌似CKfinder是需要授权许可的(好像我在上传文件时好像看到一段话,大概意思是说你正使用的CKfinder体验版本,点击获取一个授权)。

下面说说初次使用容易遇到的问题:

一、配置:

你可以使用客户端JavaScript脚本以及你喜欢的服务器端语言(比如我这里用的PHP)来部署和配置它。

比如通过JavaScript方式来调用CKeditor编辑器及CKfinder:

01

02

{artContent}

03

04

05

06

//

07

if (typeof CKEDITOR =='undefined') {

08

document.write('加载CKEditor失败');

09

}

10

else {

11

var editor = CKEDITOR.replace('content',

12

{

13

fullPage :true

14

});

15

//ckfinder总目录的相对路径.

16

CKFinder.setupCKEditor(editor,'/ckfinder/' )

17

}

18

//]]>

19

加载CKEditor失败

通过PHP方式调用编辑器:

01

//配置CKeditor

02

require("public/ckeditor/ckeditor.php");

03

$CKEditor =new CKEditor();

04

$CKEditor->returnOutput = true;

05

$CKEditor->basePath ="public/ckeditor/";

06

$CKEditor->config['width'] = 600;

07

$CKEditor->config['toolbar'] =array(

08

array('Source','-','Undo','Redo','Find','Replace','-','Bold','TextColor','BGColor','Italic','Underline','Strike','SelectAll','RemoveFormat'),

09

//'/',

10

array('Image','Flash','Table','Rule','Link','Unlink','Anchor' ),

11

array('JustifyLeft','JustifyCenter','JustifyRight','JustifyFull','Subscript','Superscript','OrderedList','UnorderedList','Outdent','Indent','FitWindow','-'),

12

13

);

14

$config['skin'] ='office2003';

15

//配置CKfinder

16

require_once 'public/ckfinder/ckfinder.php' ;

17

$ckeditor =new CKEditor( ) ;

18

$ckeditor->basePath     ='public/ckeditor/';

19

CKFinder::SetupCKEditor($CKEditor,'/public/ckfinder/') ;

20

21

$initialValue ='被编辑内容';

22

$strEditor =$CKEditor->editor("content",$initialValue);

23

echo $strEditor;

二、因为安全原因,文件不可浏览. 请联系系统管理员并检查CKFinder配置文件.

CKeditor安装CKfinder之后直接上传文件会出现这个错误提示,原因是CKfinder有一个认证检测函数CheckAuthentication,该函数内容只有一行:return false;,大家在这里添加自己的验证方式。

编辑:CKfinder\config.php,找到function CheckAuthentication()一行,将下面的return false;改为你自己的验证函数即可。比如:

1

if(isset($_SESSION['mySession'])){

2

return true;

3

}else {

4

return false;

5

}

当然,你也可以直接将原来的return false改为return true,不过这是一种危险的做法。

三、上传的有中文文件名的文件时会出现乱码并且编辑器无法显示上传文件。

CKfinder直接将文件以原文件名保存到服务器的,不知道官方有没提供更改保存文件名的配置方法(我没找到),所以直接更改PHP文件。

打开:ckfinder\core\connector\php\php5\CommandHandler\FileUpload.php

1

//找到下面这几行,大约在59-61行左右:

2

if ($sFileName !=$sUnsafeFileName) {

3

$iErrorNumber = CKFINDER_CONNECTOR_ERROR_UPLOADED_INVALID_NAME_RENAMED;

4

}

5

//以下两行解决中文乱码问题(重命名)

6

$sExtension=CKFinder_Connector_Utils_FileSystem::getExtension($sFileName);

7

$sFileName=date("Ymd")."_".date("His").".".$sExtension;

–EOF–

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值