Home >Backend Development >PHP Tutorial >Setting up and modifying FCK (for PHP)_PHP tutorial
The latest version of FCKeditor is 2.5.1. I spent some time modifying some files in it to make them more suitable for practical applications. Please see the instructions for the specific modification process. You can also directly download the modified program, see the attachment.
1. Delete the editor/_source directory
This is the source code of FCKeditor, you can delete it
2. Delete the language files except en/zh/zh-cn in the editor/lang directory
3. Delete the 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
FCKConfig.DefaultLanguage = 'en' ;
Modified to:
FCKConfig.DefaultLanguage = 'zh-cn' ;
Expand fonts and add commonly used Chinese fonts
Found
FCKConfig.FontNames = 'Arial;Comic Sans MS;Courier New;Tahoma;Times New Roman;Verdana' ;
Modified to:
FCKConfig.FontNames = '宋体;黑体;official script;楷体_GB2312;Arial;Comic Sans MS;Courier New;Tahoma;Times New Roman;Verdana' ;
Modify the font size. The font size in FCKeditor is represented by names such as "smaller; larger; xx-small;", which is not intuitive enough. We will change it to the form of number + px
Found
FCKConfig.FontSizes = 'smaller;larger;xx-small;x-small;small;medium;large;x-large;xx-large' ;
Modify to
FCKConfig.FontSizes = '9px;10px;11px;12px;13px;14px;16px;18px;24px;36px' ;
5. Modify editor/filemanage/connectors/php/config.php
FCKeditor turns off file upload by default. If you want to open it, you must modify this file
Found
$Config['Enabled'] = false ;
Modify to
$Config['Enabled'] = true ;
6. Modify editor/filemanage/connectors/php/io.php
FCKeditor does not rename the file name when uploading it, which will affect files named with Chinese names
Found
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 with scores (only one dot can be there... security issue).
if ( $Config['ForceSingleExtension'] )
$sNewFileName = preg_replace( '/.(?![^.]*$)/', '_', $sNewFileName ) ;
// Remove / | : ? * " < >
$sNewFileName = preg_replace( '/\|/|||:|?|*|"|<|>/', '_', $sNewFileName );
return $sNewFileName ;
}
Modify 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 with scores (only one dot can be 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. Some prompt boxes that appear when uploading files in FCKeditor are in English. For ease of use, you can choose to Chineseize these prompts. If not, 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