xref: /dokuwiki/doku.php (revision d25afe95c11fffc4e844b186a94d17ce9eeb59fa)
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
9//  xdebug_start_profiling();
10
11if(!defined('DOKU_INC')) define('DOKU_INC',dirname(__FILE__).'/');
12
13if (isset($_SERVER['HTTP_X_DOKUWIKI_DO'])){
14    $ACT = trim(strtolower($_SERVER['HTTP_X_DOKUWIKI_DO']));
15} elseif (!empty($IDX)) {
16    $ACT = 'index';
17} elseif (isset($_REQUEST['do'])) {
18    $ACT = $_REQUEST['do'];
19} else {
20    $ACT = 'show';
21}
22
23require_once(DOKU_INC.'inc/init.php');
24require_once(DOKU_INC.'inc/common.php');
25require_once(DOKU_INC.'inc/events.php');
26require_once(DOKU_INC.'inc/pageutils.php');
27require_once(DOKU_INC.'inc/html.php');
28require_once(DOKU_INC.'inc/auth.php');
29require_once(DOKU_INC.'inc/actions.php');
30
31//import variables
32$QUERY = trim($_REQUEST['id']);
33$ID    = getID();
34$NS    = getNS($ID);
35$REV   = $_REQUEST['rev'];
36$IDX   = $_REQUEST['idx'];
37$DATE  = $_REQUEST['date'];
38$RANGE = $_REQUEST['lines'];
39$HIGH  = $_REQUEST['s'];
40if(empty($HIGH)) $HIGH = getGoogleQuery();
41
42$TEXT  = cleanText($_POST['wikitext']);
43$PRE   = cleanText($_POST['prefix']);
44$SUF   = cleanText($_POST['suffix']);
45$SUM   = $_REQUEST['summary'];
46
47//sanitize revision
48$REV = preg_replace('/[^0-9]/','',$REV);
49
50//make infos about the selected page available
51$INFO = pageinfo();
52
53// handle debugging
54if($conf['allowdebug'] && $ACT == 'debug'){
55    html_debug();
56    exit;
57}
58
59//send 404 for missing pages if configured or ID has special meaning to bots
60if(!$INFO['exists'] &&
61  ($conf['send404'] || preg_match('/^(robots\.txt|sitemap\.xml(\.gz)?|favicon\.ico|crossdomain\.xml)$/',$ID)) &&
62  ($ACT == 'show' || substr($ACT,0,7) == 'export_') ){
63    header('HTTP/1.0 404 Not Found');
64}
65
66//prepare breadcrumbs (initialize a static var)
67if ($conf['breadcrumbs']) breadcrumbs();
68
69// check upstream
70checkUpdateMessages();
71
72$tmp = array(); // No event data
73trigger_event('DOKUWIKI_STARTED',$tmp);
74
75//close session
76session_write_close();
77
78//do the work
79act_dispatch($ACT);
80
81$tmp = array(); // No event data
82trigger_event('DOKUWIKI_DONE', $tmp);
83
84//  xdebug_dump_function_profile(1);
85