dedecms5.7更换kindeditor在线编辑器的解决方案

本方法是结合dedecms的系统来做的,以达到安全的效果,过程可能稍微有点麻烦

[color=red]第一步:删除/include/common.inc.php[/color][size=medium][/size]
找到以下部分,并且注释掉

if (DEBUG_LEVEL === TRUE)
{
echo '<pre>';
echo $classname.'类找不到';
echo '</pre>';
exit ();
}
else
{
header ( "location:/404.html" );
die ();
}


[color=red]第二步:下载kindeditor在线编辑器放置在/include/[/color][size=medium][/size]

[color=red]第三步:新建一个config.php放在/include/kindeditor/ 目录中[/color][size=medium][/size]
config.php代码如下

<?php
//该页仅用于检测用户登录的情况,如要手工更改系统配置,请更改common.inc.php
require_once(dirname(__FILE__)."/../common.inc.php");
require_once(dirname(__FILE__)."/../userlogin.class.php");

//获得当前脚本名称,如果你的系统被禁用了$_SERVER变量,请自行更改这个选项
$dedeNowurl = '';
$s_scriptName = '';
$isUrlOpen = @ini_get('allow_url_fopen');

$dedeNowurl = GetCurUrl();
$dedeNowurls = explode("?",$dedeNowurl);
$s_scriptName = $dedeNowurls[0];


//检验用户登录状态
$cuserLogin = new userLogin();

if($cuserLogin->getUserID() <=0 )
{
if(empty($adminDirHand))
{
ShowMsg("<b>提示:需输入后台管理目录才能登录</b><br /><form>请输入后台管理目录名:<input type='hidden' name='gotopage' value='".urlencode($dedeNowurl)."' /><input type='text' name='adminDirHand' value='dede' style='width:120px;' /><input style='width:80px;' type='submit' name='sbt' value='转入登录' /></form>", "javascript:;");
exit();
}
$gurl = "../../{$adminDirHand}/login.php?gotopage=".urlencode($dedeNowurl);
echo "<script language='javascript'>location='$gurl';</script>";
exit();
}

?>


[color=red]第四步:修改/include/kindeditor/php/upload_json.php
为以下代码[/color][size=medium][/size]

<?php
/**
* KindEditor PHP
*
* 本PHP程序是演示程序,建议不要直接在实际项目中使用。
* 如果您确定直接使用本程序,使用之前请仔细确认相关安全设置。
*
*/
require_once(dirname(__FILE__)."/../config.php");
require_once 'JSON.php';

if(empty($imgFile))
{
$imgFile='';
}
if(!is_uploaded_file($imgFile))
{
alert("你没有选择上传的文件!");
exit();
}

$imgfile_name = $_FILES['imgFile']['name'];
$imgfile_name = trim(ereg_replace("[ \r\n\t\*\%\\/\?><\|\":]{1,}", '', $imgfile_name));
if(!eregi("\.(".$cfg_imgtype.")", $imgfile_name))
{
alert("你所上传的图片类型不在许可列表,请更改系统对扩展名限定的配置!");
exit();
}

$nowtme = time();

$mdir = MyDate($cfg_addon_savetype, $nowtme);

if(!is_dir($cfg_basedir.$cfg_medias_dir."/allimg2"."/$mdir"))
{
MkdirAll($cfg_basedir.$cfg_medias_dir."/allimg2"."/$mdir",$cfg_dir_purview);
CloseFtp();
}
$filename_name = $cuserLogin->getUserID().'-'.dd2char(MyDate("ymdHis",$nowtme).mt_rand(100,999));
$filename = $mdir.'/'.$filename_name;
$fs = explode('.',$imgfile_name);
$filename = $filename.'.'.$fs[count($fs)-1];
$filename_name = $filename_name.'.'.$fs[count($fs)-1];
$fullfilename = $cfg_basedir.$cfg_medias_dir."/allimg2"."/".$filename;


$file_url=$cfg_medias_dir."/allimg2"."/".$filename;


if(!move_uploaded_file($imgFile,$fullfilename))
{
alert("上传失败");exit();
}
@unlink($imgFile);

$info = '';
$sizes[0] = 0; $sizes[1] = 0;
$sizes = getimagesize($fullfilename,$info);
$imgwidthValue = $sizes[0];
$imgheightValue = $sizes[1];
$imgsize = filesize($fullfilename);
$inquery = "INSERT INTO `#@__uploads`(arcid,title,url,mediatype,width,height,playtime,filesize,uptime,mid)
VALUES ('0','$filename','".$file_url."','1','$imgwidthValue','$imgheightValue','0','{$imgsize}','{$nowtme}','".$cuserLogin->getUserID()."'); ";
$dsql->ExecuteNoneQuery($inquery);
$fid = $dsql->GetLastID();
AddMyAddon($fid, $activepath.'/'.$filename);

header('Content-type: text/html; charset=UTF-8');
$json = new Services_JSON();
echo $json->encode(array('error' => 0, 'url' => $file_url));
exit;

function alert($msg) {
header('Content-type: text/html; charset=UTF-8');
$json = new Services_JSON();
echo $json->encode(array('error' => 1, 'message' => $msg));
exit;
}

?>

[color=red]
第五步:修改/include/inc/inc_fun_funAdmin.php
在194行后添加一个判断代码[/color][size=medium][/size]

else if($GLOBALS['cfg_html_editor']=='kindeditor')
{
$html = "";
$html .= '<script charset="utf-8" src="../include/kindeditor/kindeditor.js"></script>';
$html .= '<script>KE.show({id:"body",imageUploadJson : "/include/kindeditor/php/upload_json.php",fileManagerJson :"/include/kindeditor/php/file_manager_json.php",allowFileManager : true,width:"100%",height:"300px",newlineTag : "p",cssPath : "../include/kindeditor/index.css",afterCreate : function(id) {KE.event.ctrl(document, 13, function() {KE.sync(id);document.forms["form1"].submit();});KE.event.ctrl(KE.g[id].iframeDoc, 13, function() {KE.sync(id);document.forms["form1"].submit();});}});</script><textarea id="body" name="body" tyle="width:100%;height:300px;visibility:hidden;"></textarea>';
echo $html;
}


第六步:进入DEDECMS后台修改==系统基本参数==核心设置
编辑器的地方修改为 kindeditor

完成。。。。自行查看效果
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值