Summary of CKEditor and CKFinder configuration problems in PHP

Source: Internet
Author: User

1./ckeditor/config. js, configuration file. If you do not want to write too much, you can directly write the default configuration (language, menu bar, width). You can configure it in Baidu config if necessary.

Config. language = 'en'; config. skin = 'v2'; config. uiColor = '# AADC6E'; config. toolbar = 'basic ';....

2. Most official demos like to use js to configure the editor area. I am too troublesome to write php, so I have to look at the built-in php class.

Require_once ROOTPATH. "Ckeditor/ckeditor. php "; $ CKEditor = new CKEditor (); $ CKEditor-> returnOutput = true; // set the output of available variables $ CKEditor-> basePath = '/ckeditor /'; // set the path $ contentarea = $ CKEditor-> editor ("content", $ rs ['contents']); // generate a textarea with name as content

Echo $ contentarea;

3. If you need to upload the files, you have to add ckfinder. Put ckfinder and ckeditor in the same directory.

Open/ckfinder/config. php: first set the first function CheckAuthentication (). This function needs to be written according to its own rules. Only when return is true can files be uploaded to the server, of course, it is not recommended to directly write return true, which will cause security problems. It is convenient to use session.

Session_start (); function CheckAuthentication () {if (isset ($ _ SESSION ['useidtor'])

Return true; else return false ;}

4. File upload location:/ckfinder/config. php: find $ baseUrl. I have been trying to write a method to locate the path. It is really hard to do. Later I had to use sesssion. If a website needs to be uploaded to a different location, the session can be used for locating. Copy codeThe Code is as follows: if (isset ($ _ SESSION ['useidtor']) {

Switch ($ _ SESSION ['useidtor']) {case 'addr1': $ baseUrl = '/Addr1/uploadfile/'; case 'addr2 ': $ baseUrl = '/addr2/upfiles /';}

} Else {

$ BaseUrl = '/upfiles /';}

5. For the uploaded file name, ckfinder will name the file according to the original name, and garbled characters may occur in Chinese. Therefore, we recommend that you rename the file by date. Open/ckfinder/core/connector/php/php5/CommandHandler/FileUpload. php and find/p.

$ SUnsafeFileName = CKFinder_Connector_Utils_FileSystem: convertToFilesystemEncoding (CKFinder_Connector_Utils_Misc: mbBasename ($ uploadedFile ['name ']);

$ SExtension = CKFinder_Connector_Utils_FileSystem: getExtension ($ sUnsafeFileName); $ sUnsafeFileName = date ('ymdhis '). '. '. $ SExtension; 6. Use ckfinder.

Require_once ROOTPATH. "Ckeditor/ckeditor. php"; require_once ROOTPATH. 'Ckfinder/ckfinder. php ';

$ CKEditor = new CKEditor (); $ CKEditor-> returnOutput = true; $ CKEditor-> basePath = '/ckeditor /';

CKFinder: SetupCKEditor ($ CKEditor, '/ckfinder/'); // note that this is a relative path. Relative to the root directory, you cannot use an absolute path.

$ Contentarea = $ CKEditor-> editor ("content", $ rs ['contents']); it works well with both of them, the more important reason is the high security.

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: 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.