First, installationTo download the appropriate version of the website https://www.dokuwiki.org/in the site column input: http://your IP address/dokuwiki/install.php in the upper right corner of the selected language, Simplified Chinese en then will pop up this installation schematic diagram, Enable ACLs (recommended)
According to the schematic, fill in the information. Fill in the Super User, full name, e-mail, password and other information. After installation, in order to be safe, delete the install.php file, and then log in with the username password you just set. About security: http://your IP address/data/pages/wiki/dokuwiki.txt access http://your IP address/dokuwiki/doku.php
Second, the configurationClick admin button, and then appear page can be based on user management, access control list, etc. to set up management.
Third, the Chinese file name garbled problemD:\phpStudy\WWW\dokuwiki\conf\local.php on the server machine
On the last line, add:
D:\phpStudy\WWW\dokuwiki\Inc\pageutils.php on the server machine
Modify two functions: Utf8_encodefn function
function Utf8_encodefn ($file, $safe =true) {
global $conf;
if ($conf [' fnencode '] = = ' Utf-8 ') return $file;
if ($safe && preg_match (' #^[a-za-z0-9/_\-\.%]+$# ', $file)) {return
$file;
}
if ($conf [' fnencode '] = = ' safe ') {return
safefn::encode ($file);
}
Chinese support
if ($conf [' Fnencode ']== ' gb2312 ') {return
iconv (' UTF-8 ', ' GB2312 ', $file);
}
$file = UrlEncode ($file);
$file = Str_replace ('%2f ', '/', $file);
return $file;
}
and UTF8_DECODEFN functions:
function Utf8_decodefn ($file) {
global $conf;
if ($conf [' fnencode '] = = ' Utf-8 ') return $file;
if ($conf [' fnencode '] = = ' safe ') {return
safefn::d ecode ($file);
}
Chinese support
if ($conf [' Fnencode ']== ' gb2312 ') {return
iconv (' GB2312 ', ' UTF-8 ', $file);
}
Return UrlDecode ($file);
iv. installation of Plug-insAdd New page plugin markdown plugin php markdown Extra plugin Sidebar
1) Install Simplenavi plugin
2 new Data\pages\sidebar.txt, the contents are as follows:
===== Navigation directory =====
{simplenavi>}}
===== Add new page ===== {{
newpage}}
v. Support of EDITER.MD
1. Download editor.md
Https://github.com/pandao/editor.md/archive/v1.5.0.tar.gz
2. Extract to Dokuwiki\lib\editor.md\
3. Replace the function in/inc/form.php form_wikitext ($attrs), modify return results
function Form_wikitext ($attrs) {
//Mandatory attributes
unset ($attrs [' name ']);
unset ($attrs [' id ']);
$text = Str_replace ("<markdown>\n", "", $attrs [' _text ']);
$text = Str_replace ("\n</markdown>", "", $text);
/* return
' <textarea name= "wikitext" id= "Wiki__text" dir= "Auto" '
. Buildattributes ($attrs, true). ' > '. Doku_lf
. FormText ($attrs [' _text '])
. ' </textarea> ';
* * return
' <div id= ' Editormd ' contenteditable= true ' ><textarea name= ' wikitext ' > '. Doku_lf.formtext ($text)
. ' </textarea></div> ';
}
4. Change CDATA Functions in/inc/parser/xhtml.php
function CDATA ($text) {
//$this->doc. = $this->_xmlentities ($text);
return $this->doc.= $text;
}
The reason for the substitution is that some special symbols are filtered, such as:<>, and so on, because they were previously a pure character editor. And after the replacement of the xheditor itself has done a filter, again filtering will lead to the character < into <, so after removing this paragraph, only filter once
The Act_save function of 5.inc/actions.php
Savewikitext ($ID, con ($PRE, $TEXT, $SUF, True), $SUM, $INPUT->bool (' minor ')); Replace pretty mode for con with
savewikitext ($ID, con ($PRE, "<markdown>\n". $TEXT. " \n</markdown> ", $SUF, True), $SUM, $INPUT->bool (' minor ')); Use pretty mode for con
6. Add Editor.md package in/lib/tpl/dokuwiki/main.php
Add in the head section
<link rel= "stylesheet" href= "<?php echo doku_base;? >lib/editor.md/css/editormd.min.css "/>
Add in the body section
<script src= "<?php echo doku_base;? >lib/editor.md/examples/js/jquery.min.js "></script> <script src=" <?php echo doku_base;?
>lib/editor.md/editormd.js "></script> <script type=" Text/javascript "> var testeditor; $ (Function (MD) {testeditor = Editormd ("Editormd", {width: "100%", Height: 740, Path: ' <?php echo doku_base;?
>lib/editor.md/lib/', Theme: "Dark",/* Previewtheme: "Dark",
Editortheme: "Pastel-on-dark", MARKDOWN:MD, * * codefold:true,
Syncscrolling: "single", Savehtmltotextarea:true,//save HTML to Textarea Searchreplace:true,//watch:false,//Turn off Live preview HtmlDecode:
"style,script,iframe|on*",//Open HTML tag parsing, for security, default does not open Toolbar:false,//Close the toolbar//previewcodehighlight:false,//Close preview
HTML code block highlighted, default open Emoji:true, Tasklist:true, tocm:true,//Using [TOCM] Tex:true,//Open Scientific Formula Tex language support, default shutdown flowchart:true,//Open flowchart support, default shutdown sequence
Diagram:true,//Open timing/sequence diagram support, default shutdown,//dialoglockscreen:false,//Set pop-up dialog box without lock screen, global general, default to True Dialogshowmask:false,//Set pop-up dialog box to display transparent mask layer, global general, default to True//dialogdraggable:false,/
/Set Pop-up dialog box not to drag, global general, default to True//dialogmaskopacity:0.4,//Set transparent mask layer transparency, global general, default value is 0.1 Dialogmaskbgcolor: "#000",//Set the background color of transparent mask layer, global general, default to #fff Imageupload:true, imageformats : ["JPG", "JPEG", "GIF", "PNG", "BMP", "WEBP"], Imageuploadurl: "<?php echo doku_base;?" >uploadimg.php ", OnloAd:function () {}});
}); Window.onload = function () {//document.getelementbyid ("Editormd"). AddEventListener (' Paste ', function (event)
{$ ("#editormd"). On (' Paste ', function (event) {//console.log (event);
var items = (Event.clipboarddata | | event.originalEvent.clipboardData). Items;
For (var index in items) {var item = Items[index];
Console.log (item);
if (item.kind = = = ' file ') {var blob = Item.getasfile ();
var reader = new FileReader (); Reader.onload = function (event) {var base64 = Event.target.result
;
Console.log (base64); Ajax upload Picture $.post ("<?php echo doku_base;?")
>uploadimg.php ", { Screenshots:base64}, Function (RETs) {
ret = Json.parse (rets);
Layer.msg (RET.MSG);
Console.log (ret); if (ret.success = = 1) {//New line of picture display Testeditor.ins Ertvalue ("\n![]
("+ Ret.url +"));
else {alert ("screenshot upload failed:" + ret.message);
}
});
};
Reader.readasdataurl (BLOB);
}
}
}); } </script>
7. Paste Picture Auto Upload support
Modify the data/.htaccess in file to change deny from to allow from all
Upload picture save code:
<?php if (!defined (' doku_inc ')) define (' Doku_inc ', DirName (__file__). '
/');
Require_once (doku_inc. ' inc/init.php ');
$hostpath =getbaseurl (FALSE); $attachDir = '/data/media/editor/';//upload file save path, end do not bring/$maxAttachSize = 2*1024*1024;
Maximum upload size, default is 2M function upeditorimg () {Global $hostpath, $attachDir, $maxAttachSize;
Gets the size of the file $file _size=$_files[' editormd-image-file '] [' size '];
echo "$file _size $maxAttachSize";
if ($file _size > $maxAttachSize) {echo ' {"Success": 0, "message": "Cannot upload file greater than 2M"} ";
return false;
//Get the file type $file _type=$_files[' editormd-image-file '] [' type ']; if ($file _type!= "Image/jpeg" && $file _type!= ' image/pjpeg ' && $file _type!= ' image/png ') {echo ' {' suc
Cess ": 0," message ":" Picture Format exception "}";
return false; //To determine whether the upload was successful (whether Post is uploaded) if (Is_uploaded_file ($_files[' editormd-image-file '] [' tmp_name '])) {//Transfer the file to your desired Directory (do not use the copy function) $uploaded _file=$_files[' editormd-image-file ' [' Tmp_naMe '];
We create a folder for each user dynamically $save _path=$_server[' Document_root ']. $hostpath. $attachDir;
Determine if the user folder already has this folder if (!file_exists ($save _path)) {mkdir ($save _path); }//$move _to_file= $save _path. "
/". $_files[' editormd-image-file ' [' name '];
$file _true_name=$_files[' editormd-image-file ' [' name '];
$move _file_name=time (). Rand (1,1000). substr ($file _true_name,strrpos ($file _true_name, "."));
$move _to_file= $save _path. $move _file_name;
echo "$uploaded _file $move _to_file"; if (Move_uploaded_file ($uploaded _file,iconv ("Utf-8", "gb2312", $move _to_file))) {//echo $_files[' editormd-image- File ' [' Name ']. "
Upload Success ";
Echo ' {"Success": 1, "message": "Upload succeeded", "url": "'. $hostpath. $attachDir $move _file_name. '"}; $result =array (' Success ' => 1, ' message ' => ' upload success ', ' URL ' => $hostpath. $atta
ChDir. $move _file_name); Echo JSON_encode ($result);
else {//echo "upload failed";
Echo ' {' success ': 0, ' message ': ' Server save file Failed '} ';
} else {//echo "upload failed";
Echo ' {' success ': 0, ' message ': ' Upload failed '} ';
return false; }//$_post= [Screenshots] => data:image/png;base64, Ivborw0kggoaaaansuheugaaai0aaacccayaaabc1cibaaal6uleqvr4ae2dbuiu6rrh. function Upeditorscreenshots () {global $
Hostpath, $attachDir, $maxAttachSize;
$content = $_post[' screenshots '];
if (Preg_match ('/^data:image\/(\w+); Base64, (\s+)/', $content, $result)} {$file _type = $result [1];
$base 64data = $result [2];
echo "$file _type $base 64data";
$save _path = $_server[' Document_root ']. $hostpath. $attachDir;
if (!is_dir ($save _path)) {mkdir ($save _path, 0777);
$filedata = Base64_decode ($base 64data); $filename = Time (). Rand (1,1000). "."
$file _type;
if (!file_put_contents ($save _path. $filename, $filedata)) { Echo ' {' success ': 0, ' message ': ' Server save file Failed '} ';
return false;
} unset ($filedata);
Echo ' {' Success ': 1, ' message ': ' Upload succeeded ', ' url ': '. $hostpath. $attachDir $filename. ' "} ';
return true;
else {echo ' {' success ': 0, ' message ': ' Picture format exception '} ';
return false;
}//print_r ($_post);
Print_r ($_files);
if (Isset ($_files[' editormd-image-file ')) {upeditorimg ();
Exit ();
} if (Isset ($_post[' screenshots ')) {upeditorscreenshots ();
Exit (); }?>
can also directly download the modified source code:
Https://github.com/mergerly/dokuwiki/tree/stable