xref: /dokuwiki/doku.php (revision bbead83c8ed6386087eb9782fa6add29690ec665)
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>
715fae107Sandi */
815fae107Sandi
981aafed4Sandi//  xdebug_start_profiling();
1081aafed4Sandi
11d0a27cb0SAndreas Gohr  if(!defined('DOKU_INC')) define('DOKU_INC',dirname(__FILE__).'/');
12ed7b5f09Sandi  require_once(DOKU_INC.'inc/init.php');
13ed7b5f09Sandi  require_once(DOKU_INC.'inc/common.php');
14f65bfee1Schris  require_once(DOKU_INC.'inc/events.php');
15b625487dSandi  require_once(DOKU_INC.'inc/pageutils.php');
16ed7b5f09Sandi  require_once(DOKU_INC.'inc/html.php');
17ed7b5f09Sandi  require_once(DOKU_INC.'inc/auth.php');
186b13307fSandi  require_once(DOKU_INC.'inc/actions.php');
19f3f0262cSandi
20f3f0262cSandi  //import variables
21f3f0262cSandi  $QUERY = trim($_REQUEST['id']);
226c7843b5Sandi  $ID    = getID();
23d98d4540SBen Coburn  $NS    = getNS($ID);
24f3f0262cSandi  $REV   = $_REQUEST['rev'];
25f3f0262cSandi  $ACT   = $_REQUEST['do'];
26f3f0262cSandi  $IDX   = $_REQUEST['idx'];
27f3f0262cSandi  $DATE  = $_REQUEST['date'];
28f3f0262cSandi  $RANGE = $_REQUEST['lines'];
29f3f0262cSandi  $HIGH  = $_REQUEST['s'];
30f3f0262cSandi  if(empty($HIGH)) $HIGH = getGoogleQuery();
31f3f0262cSandi
32f3f0262cSandi  $TEXT  = cleanText($_POST['wikitext']);
33f3f0262cSandi  $PRE   = cleanText($_POST['prefix']);
34f3f0262cSandi  $SUF   = cleanText($_POST['suffix']);
35f3f0262cSandi  $SUM   = $_REQUEST['summary'];
36f3f0262cSandi
37258641c6Sandi  //sanitize revision
38258641c6Sandi  $REV = preg_replace('/[^0-9]/','',$REV);
39258641c6Sandi
40f3f0262cSandi  //we accept the do param as HTTP header, too:
41f3f0262cSandi  if(!empty($_SERVER['HTTP_X_DOKUWIKI_DO'])){
42f3f0262cSandi    $ACT = trim(strtolower($_SERVER['HTTP_X_DOKUWIKI_DO']));
43f3f0262cSandi  }
44f3f0262cSandi
45f3f0262cSandi  if(!empty($IDX)) $ACT='index';
466c7843b5Sandi  //set default #FIXME not needed here? done in actions?
47f3f0262cSandi  if(empty($ACT)) $ACT = 'show';
48f3f0262cSandi
49100a97e3SAndreas Gohr  //make infos about the selected page available
50100a97e3SAndreas Gohr  $INFO = pageinfo();
51f3f0262cSandi
52100a97e3SAndreas Gohr  // handle debugging
53f42d1c75SAndreas Gohr  if($conf['allowdebug'] && $ACT == 'debug'){
54f3f0262cSandi    html_debug();
55f3f0262cSandi    exit;
56f3f0262cSandi  }
57f3f0262cSandi
582cff5827SAndreas Gohr  //send 404 for missing pages if configured or ID has special meaning to bots
592cff5827SAndreas Gohr  if(!$INFO['exists'] &&
602cff5827SAndreas Gohr     ($conf['send404'] || preg_match('/^(robots\.txt|sitemap\.xml(\.gz)?|favicon\.ico|crossdomain\.xml)$/',$ID)) &&
612cff5827SAndreas Gohr     ($ACT == 'show' || substr($ACT,0,7) == 'export_') ){
622649b1a4SAndreas Gohr    header('HTTP/1.0 404 Not Found');
632649b1a4SAndreas Gohr  }
642649b1a4SAndreas Gohr
658746e727Sandi  //prepare breadcrumbs (initialize a static var)
66*bbead83cSAnika Henke  if ($conf['breadcrumbs']) breadcrumbs();
678746e727Sandi
68c29dc6e4SAndreas Gohr  // check upstream
69c29dc6e4SAndreas Gohr  checkUpdateMessages();
70c29dc6e4SAndreas Gohr
7124bb549bSchris  trigger_event('DOKUWIKI_STARTED',$tmp=array());
72a4b5ae12Schris
738746e727Sandi  //close session
748746e727Sandi  session_write_close();
758746e727Sandi
768746e727Sandi  //do the work
776b13307fSandi  act_dispatch($ACT);
78b3222a5cSandi
7924bb549bSchris  trigger_event('DOKUWIKI_DONE', $tmp=array());
80a4b5ae12Schris
812a27e99aSandi//  xdebug_dump_function_profile(1);
82f3f0262cSandi?>
83