1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
|
<?php
/**
* DokuWiki mainscript
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author Andreas Gohr <andi@splitbrain.org>
*/
ini_set('short_open_tag',"1");
require_once("conf/dokuwiki.php");
require_once("inc/common.php");
require_once("inc/html.php");
require_once("inc/parser.php");
require_once("lang/en/lang.php");
require_once("lang/".$conf['lang']."/lang.php");
require_once("inc/auth.php");
//import variables
$QUERY = trim($_REQUEST['id']);
$ID = cleanID($_REQUEST['id']);
$REV = $_REQUEST['rev'];
$ACT = $_REQUEST['do'];
$IDX = $_REQUEST['idx'];
$DATE = $_REQUEST['date'];
$RANGE = $_REQUEST['lines'];
$HIGH = $_REQUEST['s'];
if(empty($HIGH)) $HIGH = getGoogleQuery();
$TEXT = cleanText($_POST['wikitext']);
$PRE = cleanText($_POST['prefix']);
$SUF = cleanText($_POST['suffix']);
$SUM = $_REQUEST['summary'];
//we accept the do param as HTTP header, too:
if(!empty($_SERVER['HTTP_X_DOKUWIKI_DO'])){
$ACT = trim(strtolower($_SERVER['HTTP_X_DOKUWIKI_DO']));
}
if(!empty($IDX)) $ACT='index';
//set defaults
if(empty($ID)) $ID = $conf['start'];
if(empty($ACT)) $ACT = 'show';
header('Content-Type: text/html; charset='.$lang['encoding']);
if($ACT == 'debug'){
html_debug();
exit;
}
//already logged in?
if($_SERVER['REMOTE_USER'] && $ACT=='login') $ACT='show';
//handle logout
if($ACT=='logout'){
auth_logoff();
$ACT='login';
}
//handle register
if($ACT=='register' && register()){
$ACT='login';
}
//do saving after spam- and conflictcheck
if($ACT == $lang['btn_save'] && auth_quickaclcheck($ID)){
if(checkwordblock()){
//spam detected
$ACT = 'wordblock';
}elseif($DATE != 0 && @filemtime(wikiFN($ID)) > $DATE ){
//newer version available -> ask what to do
$ACT = 'conflict';
}else{
//save it
saveWikiText($ID,con($PRE,$TEXT,$SUF,1),$SUM); //use pretty mode for con
//unlock it
unlock($id);
//show it
header("Location: ".wl($ID, '','doku.php',true));
exit();
}
}
//make infos about current page available
$INFO = pageinfo();
//Editing: check if locked by anyone - if not lock for my self
if(($ACT == 'edit' || $ACT == $lang['btn_preview']) && $INFO['editable']){
$lockedby = checklock($ID);
if($lockedby){
$ACT = 'locked';
}else{
lock($ID);
}
}else{
//try to unlock
unlock($ID);
}
//display some infos
if($ACT == 'check'){
check();
$ACT = 'show';
}
//check which permission is needed
if(in_array($ACT,array('preview','wordblock','conflict','lockedby'))){
if($INFO['exists']){
$permneed = AUTH_EDIT;
}else{
$permneed = AUTH_CREATE;
}
}elseif(in_array($ACT,array('login','register','search','recent'))){
$permneed = AUTH_NONE;
}else{
$permneed = AUTH_READ;
}
//start output
if(substr($ACT,0,6) != 'export') html_header();
if(html_acl($permneed)){
if($ACT == 'edit'){
html_edit();
}elseif($ACT == $lang['btn_preview']){
html_edit($TEXT);
html_show($TEXT);
}elseif($ACT == 'wordblock'){
html_edit($TEXT,'wordblock');
}elseif($ACT == 'search' && !empty($QUERY)){
html_search();
}elseif($ACT == 'revisions'){
html_revisions();
}elseif($ACT == 'diff'){
html_diff();
}elseif($ACT == 'recent'){
html_recent();
}elseif($ACT == 'index'){
html_index($IDX);
}elseif($ACT == 'backlink'){
html_backlinks();
}elseif($ACT == 'conflict'){
html_conflict(con($PRE,$TEXT,$SUF),$SUM);
html_diff(con($PRE,$TEXT,$SUF),false);
}elseif($ACT == 'locked'){
html_locked($lockedby);
}elseif($ACT == 'login'){
html_login();
}elseif($ACT == 'register' && $conf['openregister']){
html_register();
}elseif($ACT == 'export_html'){
html_head();
print "<body>\n";
print parsedWiki($ID,$REV,false);
print "</body>\n</html>\n";
}elseif($ACT == 'export_raw'){
header("Content-Type: text/plain");
print rawWiki($ID,$REV);
}else{
$ACT='show';
html_show();
}
}
if(substr($ACT,0,6) != 'export') html_footer();
?>
|