Merge branch 'master' into stable
[dokuwiki.git] / doku.php
blobd861aa4fbb58c9133575f10aa180ae76236c0fde
1 <?php
2 /**
3 * DokuWiki mainscript
5 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
6 * @author Andreas Gohr <andi@splitbrain.org>
8 * @global Input $INPUT
9 */
11 // update message version
12 $updateVersion = 43;
14 // xdebug_start_profiling();
16 if(!defined('DOKU_INC')) define('DOKU_INC', dirname(__FILE__).'/');
18 if(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';
28 // load and initialize the core system
29 require_once(DOKU_INC.'inc/init.php');
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();
36 $REV = $INPUT->int('rev');
37 $IDX = $INPUT->str('idx');
38 $DATE = $INPUT->int('date');
39 $RANGE = $INPUT->str('range');
40 $HIGH = $INPUT->param('s');
41 if(empty($HIGH)) $HIGH = getGoogleQuery();
43 if($INPUT->post->has('wikitext')) {
44 $TEXT = cleanText($INPUT->post->str('wikitext'));
46 $PRE = cleanText(substr($INPUT->post->str('prefix'), 0, -1));
47 $SUF = cleanText($INPUT->post->str('suffix'));
48 $SUM = $INPUT->post->str('summary');
50 //make info about the selected page available
51 $INFO = pageinfo();
53 //export minimal info to JS, plugins can add more
54 $JSINFO['id'] = $ID;
55 $JSINFO['namespace'] = (string) $INFO['namespace'];
57 // handle debugging
58 if($conf['allowdebug'] && $ACT == 'debug') {
59 html_debug();
60 exit;
63 //send 404 for missing pages if configured or ID has special meaning to bots
64 if(!$INFO['exists'] &&
65 ($conf['send404'] || preg_match('/^(robots\.txt|sitemap\.xml(\.gz)?|favicon\.ico|crossdomain\.xml)$/', $ID)) &&
66 ($ACT == 'show' || (!is_array($ACT) && substr($ACT, 0, 7) == 'export_'))
67 ) {
68 header('HTTP/1.0 404 Not Found');
71 //prepare breadcrumbs (initialize a static var)
72 if($conf['breadcrumbs']) breadcrumbs();
74 // check upstream
75 checkUpdateMessages();
77 $tmp = array(); // No event data
78 trigger_event('DOKUWIKI_STARTED', $tmp);
80 //close session
81 session_write_close();
83 //do the work (picks up what to do from global env)
84 act_dispatch();
86 $tmp = array(); // No event data
87 trigger_event('DOKUWIKI_DONE', $tmp);
89 // xdebug_dump_function_profile(1);