xref: /dokuwiki/doku.php (revision 5381a7ee4e6527c7d6d6af67134ef92ba97f8745)
1f3f0262cSandi<?php
215fae107Sandi/**
315fae107Sandi * DokuWiki mainscript
415fae107Sandi *
515fae107Sandi * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
615fae107Sandi * @author     Andreas Gohr <andi@splitbrain.org>
7dbd7dc8eSAndreas Gohr *
8dbd7dc8eSAndreas Gohr * @global Input $INPUT
915fae107Sandi */
1015fae107Sandi
11ef362bb8SAnika Henke// update message version
1293d16b87SAndreas Gohr$updateVersion = 41;
13ef362bb8SAnika Henke
1481aafed4Sandi//  xdebug_start_profiling();
1581aafed4Sandi
16d0a27cb0SAndreas Gohrif(!defined('DOKU_INC')) define('DOKU_INC', dirname(__FILE__).'/');
17ab24fc7fSAdrian Lang
18ab24fc7fSAdrian Langif(isset($_SERVER['HTTP_X_DOKUWIKI_DO'])) {
19ab24fc7fSAdrian Lang    $ACT = trim(strtolower($_SERVER['HTTP_X_DOKUWIKI_DO']));
20d059be8cSAndreas Gohr} elseif(!empty($_REQUEST['idx'])) {
21ab24fc7fSAdrian Lang    $ACT = 'index';
22ab24fc7fSAdrian Lang} elseif(isset($_REQUEST['do'])) {
23ab24fc7fSAdrian Lang    $ACT = $_REQUEST['do'];
24ab24fc7fSAdrian Lang} else {
25ab24fc7fSAdrian Lang    $ACT = 'show';
26ab24fc7fSAdrian Lang}
27ab24fc7fSAdrian Lang
2816905344SAndreas Gohr// load and initialize the core system
29ed7b5f09Sandirequire_once(DOKU_INC.'inc/init.php');
30f3f0262cSandi
31f3f0262cSandi//import variables
3200d58927SMichael Hamann$INPUT->set('id', str_replace("\xC2\xAD", '', $INPUT->str('id'))); //soft-hyphen
33dbd7dc8eSAndreas Gohr$QUERY          = trim($INPUT->str('id'));
346c7843b5Sandi$ID             = getID();
35bced4159SAdrian Lang
36dbd7dc8eSAndreas Gohr$REV   = $INPUT->int('rev');
37dbd7dc8eSAndreas Gohr$IDX   = $INPUT->str('idx');
38dbd7dc8eSAndreas Gohr$DATE  = $INPUT->int('date');
39dbd7dc8eSAndreas Gohr$RANGE = $INPUT->str('range');
40dbd7dc8eSAndreas Gohr$HIGH  = $INPUT->param('s');
41f3f0262cSandiif(empty($HIGH)) $HIGH = getGoogleQuery();
42f3f0262cSandi
43dbd7dc8eSAndreas Gohrif($INPUT->post->has('wikitext')) {
44dbd7dc8eSAndreas Gohr    $TEXT = cleanText($INPUT->post->str('wikitext'));
4545a99335SAdrian Lang}
46dbd7dc8eSAndreas Gohr$PRE = cleanText(substr($INPUT->post->str('prefix'), 0, -1));
47dbd7dc8eSAndreas Gohr$SUF = cleanText($INPUT->post->str('suffix'));
48dbd7dc8eSAndreas Gohr$SUM = $INPUT->post->str('summary');
49258641c6Sandi
50*5381a7eeSElan Ruusamäe//make info about the selected page available
51100a97e3SAndreas Gohr$INFO = pageinfo();
52f3f0262cSandi
53*5381a7eeSElan Ruusamäe//export minimal info to JS, plugins can add more
5485b9dd81SAndreas Gohr$JSINFO['id']        = $ID;
5585b9dd81SAndreas Gohr$JSINFO['namespace'] = (string) $INFO['namespace'];
5672e0dc37SAndreas Gohr
57100a97e3SAndreas Gohr// handle debugging
58f42d1c75SAndreas Gohrif($conf['allowdebug'] && $ACT == 'debug') {
59f3f0262cSandi    html_debug();
60f3f0262cSandi    exit;
61f3f0262cSandi}
62f3f0262cSandi
632cff5827SAndreas Gohr//send 404 for missing pages if configured or ID has special meaning to bots
642cff5827SAndreas Gohrif(!$INFO['exists'] &&
652cff5827SAndreas Gohr    ($conf['send404'] || preg_match('/^(robots\.txt|sitemap\.xml(\.gz)?|favicon\.ico|crossdomain\.xml)$/', $ID)) &&
6651414465SAndreas Gohr    ($ACT == 'show' || (!is_array($ACT) && substr($ACT, 0, 7) == 'export_'))
6751414465SAndreas Gohr) {
682649b1a4SAndreas Gohr    header('HTTP/1.0 404 Not Found');
692649b1a4SAndreas Gohr}
702649b1a4SAndreas Gohr
718746e727Sandi//prepare breadcrumbs (initialize a static var)
72359fab8bSMichael Hamannif($conf['breadcrumbs']) breadcrumbs();
738746e727Sandi
74c29dc6e4SAndreas Gohr// check upstream
75c29dc6e4SAndreas GohrcheckUpdateMessages();
76c29dc6e4SAndreas Gohr
77c66972f2SAdrian Lang$tmp = array(); // No event data
78c66972f2SAdrian Langtrigger_event('DOKUWIKI_STARTED', $tmp);
79a4b5ae12Schris
808746e727Sandi//close session
818746e727Sandisession_write_close();
828746e727Sandi
83ead122f7SAndreas Gohr//do the work (picks up what to do from global env)
84ead122f7SAndreas Gohract_dispatch();
85b3222a5cSandi
86c66972f2SAdrian Lang$tmp = array(); // No event data
87c66972f2SAdrian Langtrigger_event('DOKUWIKI_DONE', $tmp);
88a4b5ae12Schris
892a27e99aSandi//  xdebug_dump_function_profile(1);
90