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), there is a need to be able to configure Baidu config
config.language = ' en '; config.skin = ' v2 '; config.uicolor = ' #AADC6E '; config.toolbar = ' Basic ';
2, the official demo mostly like to use JS Configuration Editor area, the habit of writing PHP I was too troublesome, had to look at the built-in PHP class.
Require_once RootPath. "ckeditor/ckeditor.php"; $CKEditor = new CKEditor (); $CKEditor-"returnoutput = true;//Set Output available variables $ckeditor-" BasePath = '/ckeditor/'//set path $contentarea = $CKEditor-Editor ("Content", $rs [' contents ']);//Generate a textarea with the content of name
Echo $contentarea;
3, need to upload, had to join the Ckfinder. Place Ckfinder and CKEditor in the same level directory.
Open/ckfinder/config.php, first set the first function checkauthentication (), this function needs to write according to its own rules, as long as return true to allow uploading files to the server, It is certainly not recommended to write return true directly, which can lead to security issues. The session can be used to deal with more convenient.
Session_Start (); function checkauthentication () {if (Isset ($_session[' useeidtor '))
return true;else return false;}
4, Upload file location: Also in/ckfinder/config.php, find $baseurl, before always want to write a method to locate the path, it is difficult to do, and later had to use Sesssion, if a site, there is a need to upload to different locations, You can use session positioning.
Copy Code code as follows:
if (Isset ($_session[' Useeidtor ')) {
Switch ($_session[' useeidtor ']) {case ' Addr1 ': $baseUrl = '/addr1/uploadfile/'; case ' ADDR2 ': $baseUrl = '/addr2/upfiles/ ';}
} else {
$BASEURL = '/upfiles/';}
5, for the upload file name, Ckfinder will be named after the original name, Chinese circumstances may be garbled, so we recommend the use of the date rename. 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, the last is to 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 here is the relative path, relative to the root directory, cannot use absolute path
$contentarea = $CKEditor-"editor" ("Content", $rs [' contents ']); the combination of the two is quite good, and more importantly, the security is much higher.