CKEditor and CKFinder configuration in PHP _ PHP Tutorial

Source: Internet
Author: User
CKEditor and CKFinder configuration in PHP. 1. ckeditorconfig. 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 Baidu config configuration. language 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 Baidu config

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']); // generates a textarea with name as content

Echo $ contentarea;
3. you have to add ckfinder to upload the file. Store 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.

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 it. </p>

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

$ SExtension = CKFinder_Connector_Utils_FileSystem: getExtension ($ sUnsafeFileName );
$ SUnsafeFileName = date ('ymdhis ').'. '. $ sExtension;
6. 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']);
The combination of the two is quite good, and the more important reason is the high security.


From Shunzi network

Configurations, 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 config. language =...

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.