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