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