xref: /dokuwiki/doku.php (revision 78b874e68a5f2a45f71a91efb168761c283e3a91)
1<?php
2/**
3 * DokuWiki mainscript
4 *
5 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
6 * @author     Andreas Gohr <andi@splitbrain.org>
7 *
8 * @global Input $INPUT
9 */
10
11// update message version
12$updateVersion = 42;
13
14//  xdebug_start_profiling();
15
16if(!defined('DOKU_INC')) define('DOKU_INC', dirname(__FILE__).'/');
17
18if(isset($_SERVER['HTTP_X_DOKUWIKI_DO'])) {
19    $ACT = trim(strtolower($_SERVER['HTTP_X_DOKUWIKI_DO']));
20} elseif(!empty($_REQUEST['idx'])) {
21    $ACT = 'index';
22} elseif(isset($_REQUEST['do'])) {
23    $ACT = $_REQUEST['do'];
24} else {
25    $ACT = 'show';
26}
27
28// load and initialize the core system
29require_once(DOKU_INC.'inc/init.php');
30
31//import variables
32$INPUT->set('id', str_replace("\xC2\xAD", '', $INPUT->str('id'))); //soft-hyphen
33$QUERY          = trim($INPUT->str('id'));
34$ID             = getID();
35
36$REV   = $INPUT->int('rev');
37$DATE_AT = $INPUT->int('at');
38$IDX   = $INPUT->str('idx');
39$DATE  = $INPUT->int('date');
40$RANGE = $INPUT->str('range');
41$HIGH  = $INPUT->param('s');
42if(empty($HIGH)) $HIGH = getGoogleQuery();
43
44if($INPUT->post->has('wikitext')) {
45    $TEXT = cleanText($INPUT->post->str('wikitext'));
46}
47$PRE = cleanText(substr($INPUT->post->str('prefix'), 0, -1));
48$SUF = cleanText($INPUT->post->str('suffix'));
49$SUM = $INPUT->post->str('summary');
50
51if($DATE_AT) {
52    $pagelog = new PageChangeLog($ID);
53    $rev_t = $pagelog->getLastRevisionAt($DATE_AT);
54    if($rev_t === '') {
55        $REV = '';
56    } else if ($rev_t === false) {
57        msg('Seite gab es zu diesem Zeitpunkt noch nicht');
58        $REV = $DATE_AT;
59    } else {
60        $REV = $rev_t;
61    }
62}
63
64//make infos about the selected page available
65$INFO = pageinfo();
66
67//export minimal info to JS, plugins can add more
68$JSINFO['id']        = $ID;
69$JSINFO['namespace'] = (string) $INFO['namespace'];
70
71// handle debugging
72if($conf['allowdebug'] && $ACT == 'debug') {
73    html_debug();
74    exit;
75}
76
77//send 404 for missing pages if configured or ID has special meaning to bots
78if(!$INFO['exists'] &&
79    ($conf['send404'] || preg_match('/^(robots\.txt|sitemap\.xml(\.gz)?|favicon\.ico|crossdomain\.xml)$/', $ID)) &&
80    ($ACT == 'show' || (!is_array($ACT) && substr($ACT, 0, 7) == 'export_'))
81) {
82    header('HTTP/1.0 404 Not Found');
83}
84
85//prepare breadcrumbs (initialize a static var)
86if($conf['breadcrumbs']) breadcrumbs();
87
88// check upstream
89checkUpdateMessages();
90
91$tmp = array(); // No event data
92trigger_event('DOKUWIKI_STARTED', $tmp);
93
94//close session
95session_write_close();
96
97//do the work (picks up what to do from global env)
98act_dispatch();
99
100$tmp = array(); // No event data
101trigger_event('DOKUWIKI_DONE', $tmp);
102
103//  xdebug_dump_function_profile(1);
104