FCK Settings and modifications (for PHP)

Source: Internet
Author: User
Tags config file upload php code rand

FCKeditor the latest version is 2.5.1, I spent some time to modify some of the files inside, more suitable for practical applications. Please see the details of the change process, you can also download the revised procedures, see annex.

1. Delete Editor/_source Directory
This is the source code of FCKeditor, can delete

2. Delete the language files in the Editor/lang directory except EN/ZH/ZH-CN

3. Delete editor/filemanage/connectors directory except PHP

4. Modify Fckconfig.js

Modify the default language. Note: This step should be ignored, FCKeditor seems to automatically match the browser's language
Found it


fckconfig.defaultlanguage = ' en ';
Modified to:


Fckconfig.defaultlanguage = ' ZH-CN ';
Expand fonts, add common Chinese fonts
Found it


Fckconfig.fontnames = ' Arial; Comic Sans MS; Courier New; Tahoma; Times New Roman; Verdana ';
Modified to:


Fckconfig.fontnames = ' song body; bold; official script; italics _gb2312; Arial; Comic Sans MS; Courier New; Tahoma; Times New Roman; Verdana ';
Change the font size, the font size in the FCKeditor is "smaller;larger;xx-small;" The name is not intuitive, we change it to a digital +px form
Found it


fckconfig.fontsizes = ' Smaller;larger;xx-small;x-small;small;medium;large;x-large;xx-large ';
Modified to


fckconfig.fontsizes = ' 9px;10px;11px;12px;13px;14px;16px;18px;24px;36px ';
5. Modify editor/filemanage/connectors/php/config.php
FCKeditor default is to close the file upload, if you want to open, you must modify this file
Found it


$Config [' Enabled '] = false;
Amended to


$Config [' Enabled '] = true;
6. Modify Editor/filemanage/connectors/php/io.php
FCKeditor in the upload file does not rename the file name, which will affect the file named in Chinese name
Found it

PHP Code:
Do a cleanup of the ' file name to avoid possible problems
function Sanitizefilename ($sNewFileName)
{
Global $Config;
$sNewFileName = Stripslashes ($sNewFileName);
Replace dots in the name and underscores (only one dot can there ... security issue).
if ($Config [' forcesingleextension '])
$sNewFileName = Preg_replace ('/\. [^.] *$)/', ' _ ', $sNewFileName);
Remove/| : ? * "< >
$sNewFileName = Preg_replace ('/\\|\/|\| | \:|\?| \*|"| <|>/', ' _ ', $sNewFileName);
return $sNewFileName;
}


Modified to

PHP Code:
Do a cleanup of the ' file name to avoid possible problems
function Sanitizefilename ($sNewFileName)
{
Global $Config;
$sNewFileName = Stripslashes ($sNewFileName);
Replace dots in the name and underscores (only one dot can there ... security issue).
if ($Config [' forcesingleextension '])
$sNewFileName = Preg_replace ('/\. [^.] *$)/', ' _ ', $sNewFileName);
$sExtension = substr ($sNewFileName, (Strrpos ($sNewFileName, '. ') + 1));
$sNewFileName = My_setfilename (). $sExtension;
return $sNewFileName;
}
function My_setfilename () {
$gettime = Explode (', microtime ());
$string = ' abcdefghijklmnopgrstuvwxyz0123456789 ';
$rand = ';
For ($x =0 $x <6; $x + +)
$rand. = substr ($string, Mt_rand (0,strlen ($string)-1), 1);
Return date ("Ymdhis"). substr ($gettime [0],2,6). $rand;
}


7.FCKeditor when uploading files, some of the prompt boxes appear in English, in order to facilitate the use, you can choose to make these prompts Chinese, if you do not need to, you can ignore this step
Specifically, modify the following files:
editor/filemanage/connectors/php/commands.php
editor/filemanage/connectors/php/connector.php
editor/filemanage/connectors/php/upload.php
Editor/dialog/fck_flash/fck_flash.js
Editor/dialog/fck_image/fck_image.js
Editor/dialog/fck_link/fck_link.js

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.