现在的位置: 首页 > 综合 > 正文

Fckeditor使用技巧

2013年09月02日 ⁄ 综合 ⁄ 共 3851字 ⁄ 字号 评论关闭

表单接受值时注意的问题

magic_quotes_gpc 打开时,所有的 (单引号), (双引号), (反斜线) and 空字符会自动转为含有反斜线的溢出字符。 所以要把magic_quotes_gpc=off才能显示正确的东西出来.

method2://$temp=str_replace('/"','',$_POST['FCKeditor1']);
//echo $temp;

 

 

fck乱码解决

1.改名为时间戳形式;

 配了FCK editor 本以为一切OK,没想到在上传中文名字的文件时,出现乱码
    
看后台代码找了半天,终于弄出来解决方法了,那就是更改FileUpLoad函数 此函数定义在
fckeditor/editor/filemanager/connectors/php/commands.php 文件中(2.5版本)。
在该函数中找到以下代码  

// Get the extension.
   $sExtension = substr( $sFileName, ( strrpos($sFileName, ‘.’) + 1 ) ) ;
   $sExtension = strtolower( $sExtension ) ;

在其后加上一句:

   $sFileName = strtotime("now").".".$sExtension;

这样文件名就是 当前时间戳+后缀名了。此方法一劳永逸。再也不用管什么英文中文名了。

2.修改编码:

处理windows下上传中文名称文件时的乱码问题(_inux下统一采用utf-8编码,不会产生问题)

找到/fck/editor/filemanager/connectors/php/util.php(line:73):

Return(utf8_encode(htmlspecialchars($value)));

改为:

Return mb_convert_encoding(htmlspecialchars($value),”UTF-8”,”GBK”);

保存。

接着找到fck/editor/filemanager/connectors/php/command.php(line177):

$sFileName = $oFile[‘name’];后面加一行:

$sFileName = mb_convert_encoding(htmlspecialchars($value),”GBK”,”auto”);

保存,Ok.

 

Phpfck的引用(非JS

 

<?php   
    include_once("FCKeditor/fckeditor.php");      //
引用FCKeditor.php这个文件
    $FCKeditor=new FCKeditor('myinfo');          //
创建FCKeditor对象的实例    
    $FCKeditor->BasePath='FCKeditor/';            //FCKeditor
所在的位置,这里它的位置就是'FCKeditor/';
    $FCkeditor->ToolbarSets="Basic";            //
工具按钮设置    
    $FCKeditor->Width='600px';         //
设置它的宽度    
    $FCKeditor->Height='300px';    //
设置它的高度                                         
?>

 

 

FCK(PHP)设置

1.修改默认菜单配置(fckconfig.js)

FCKConfig.ToolbarSets["Default"] = [
['Source','Preview','-','Image','Flash','Table','-' ,'Undo','Redo','RemoveFormat' ,"-",'JustifyLeft','JustifyCenter','JustifyRight','-','Bold','Italic','Underline'],
['FontName','FontSize','TextColor','BGColor','-','Link','Unlink','Anchor']
] ;

修改字体:

FCKConfig.FontNames    = '宋体,新宋体;黑体;隶书;华文行楷;Arial;Comic Sans MS;Courier New;Tahoma;Times New Roman;Verdana' ;

2.禁止浏览服务器功能

FCKConfig.FlashBrowser = false ;

FCKConfig.ImageBrowser = false ;

FCKConfig.LinkBrowser = false ;

// 版本BUG,影响上传
替换 FCKConfig.QuickUploadLanguage _QuickUploadLanguage

3.选择PHP服务器语言

var _FileBrowserLanguage = 'php' ;

var _QuickUploadLanguage = 'php' ;

// 开启JS代码,PHP代码

// FCKConfig.ProtectedSource.Add( /<scrīpt[/s/S]*?//scrīpt>/gi ) ; // <scrīpt> tags.
// FCKConfig.ProtectedSource.Add( /<%[/s/S]*?%>/g ) ; // ASP style server side code <%...%>
FCKConfig.ProtectedSource.Add( /</?[/s/S]*?/?>/g ) ; // PHP style server side code <?...?>

// 语言目录
FCKConfig.ContentLangDirection = 'en' ;

4.设置上传目录
editor/filemanager/upload/config.php:


$Config['Enabled'] = true ;

$upLoadPath = "/subSite/upLoadFiles/" . date("Ym") . "/";

if(!file_exists($upLoadPath))
{
createDir($_SERVER['DOCUMENT_ROOT'] . $upLoadPath);
}

$Config['UserFilesPath'] = $upLoadPath;

function createDir($dir = '')
{
if (!is_dir($dir))
{
    $temp = explode('/', $dir);
    $cur_dir = '';
    for($i=0; $i < count($temp); $i++)
    {
      $cur_dir .= $temp[$i] . '/';
    
      $oldumask = umask(0);
      if (!is_dir($cur_dir) && !file_exists($cur_dir))
      {
     mkdir($cur_dir, 0777);
      }
      umask($oldumask);
    }
    return true;
}
return false;
}

5.设置文件名,返回图片路径
editor/filemanager/upload/upload.php:

// This is the function that sends the results of the uploading process.
function SendResults( $errorNumber, $fileUrl = '', $fileName = '', $customMsg = '' )
{
$fileUrl = "http://" . $_SERVER['SERVER_NAME'] . $fileUrl;//
返回路径前加域名
echo '<scrīpt type="text/javascrīpt">' ;
echo 'window.parent.OnUploadCompleted(' . $errorNumber . ',"' . str_replace( '"', '//"', $fileUrl ) . '","' . str_replace( '"', '//"', $fileName ) . '", "' . str_replace( '"', '//"', $customMsg ) . '") ;' ;
echo '</scrīpt>';
exit;
}

$sFileName = $oFile['name'] ;
$sFileName = getRandFileName($sFileName);//
随机文件名

function getRandFileName($oFileName)
{
$nFileName = date("ymdHis") . mt_rand(1, 10);
$oFileNameArray = explode(".", $oFileName);
if(count($oFileNameArray) < 2)
{
    return $nFileName;
}
return    $nFileName . "." . $oFileNameArray[count($oFileNameArray)-1];
}

6.修改上传成功提示:

dialog/fck_image/fck_image.js

case 0 : // No errors
     //alert( 'Your file has been successfully uploaded' ) ;
     alert('
文件上传成功!') ;

同理修改FLASH上传成功提示

抱歉!评论已关闭.