Skip to content
Snippets Groups Projects
doku.php 2.23 KiB
Newer Older
andi's avatar
andi committed
<?php
andi's avatar
andi committed
/**
 * DokuWiki mainscript
 *
 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
 * @author     Andreas Gohr <andi@splitbrain.org>
 */
Adrian Lang's avatar
Adrian Lang committed
$updateVersion = 31;
andi's avatar
andi committed
//  xdebug_start_profiling();
andi's avatar
andi committed

Andreas Gohr's avatar
Andreas Gohr committed
if(!defined('DOKU_INC')) define('DOKU_INC',dirname(__FILE__).'/');

if (isset($_SERVER['HTTP_X_DOKUWIKI_DO'])){
    $ACT = trim(strtolower($_SERVER['HTTP_X_DOKUWIKI_DO']));
} elseif (!empty($_REQUEST['idx'])) {
    $ACT = 'index';
} elseif (isset($_REQUEST['do'])) {
    $ACT = $_REQUEST['do'];
} else {
    $ACT = 'show';
}

// load and initialize the core system
Andreas Gohr's avatar
Andreas Gohr committed
require_once(DOKU_INC.'inc/init.php');

//import variables
$_REQUEST['id'] = str_replace("\xC2\xAD",'',$_REQUEST['id']); //soft-hyphen
Andreas Gohr's avatar
Andreas Gohr committed
$QUERY = trim($_REQUEST['id']);
$ID    = getID();
Adrian Lang's avatar
Adrian Lang committed

// deprecated 2011-01-14
Andreas Gohr's avatar
Andreas Gohr committed
$NS    = getNS($ID);
Andreas Gohr's avatar
Andreas Gohr committed
$REV   = $_REQUEST['rev'];
$IDX   = $_REQUEST['idx'];
$DATE  = $_REQUEST['date'];
$RANGE = $_REQUEST['range'];
Andreas Gohr's avatar
Andreas Gohr committed
$HIGH  = $_REQUEST['s'];
if(empty($HIGH)) $HIGH = getGoogleQuery();

if (isset($_POST['wikitext'])) {
    $TEXT  = cleanText($_POST['wikitext']);
}
$PRE   = cleanText(substr($_POST['prefix'], 0, -1));
Andreas Gohr's avatar
Andreas Gohr committed
$SUF   = cleanText($_POST['suffix']);
$SUM   = $_REQUEST['summary'];

//sanitize revision
$REV = preg_replace('/[^0-9]/','',$REV);

//make infos about the selected page available
$INFO = pageinfo();
andi's avatar
andi committed

//export minimal infos to JS, plugins can add more
$JSINFO['id']        = $ID;
$JSINFO['namespace'] = (string) $INFO['namespace'];
Andreas Gohr's avatar
Andreas Gohr committed
// handle debugging
if($conf['allowdebug'] && $ACT == 'debug'){
andi's avatar
andi committed
    html_debug();
    exit;
Andreas Gohr's avatar
Andreas Gohr committed
}
Andreas Gohr's avatar
Andreas Gohr committed

Andreas Gohr's avatar
Andreas Gohr committed
//send 404 for missing pages if configured or ID has special meaning to bots
if(!$INFO['exists'] &&
  ($conf['send404'] || preg_match('/^(robots\.txt|sitemap\.xml(\.gz)?|favicon\.ico|crossdomain\.xml)$/',$ID)) &&
  ($ACT == 'show' || (!is_array($ACT) && substr($ACT,0,7) == 'export_')) ){
    header('HTTP/1.0 404 Not Found');
Andreas Gohr's avatar
Andreas Gohr committed
}
Andreas Gohr's avatar
Andreas Gohr committed
//prepare breadcrumbs (initialize a static var)
if ($conf['breadcrumbs']) breadcrumbs();
Andreas Gohr's avatar
Andreas Gohr committed
// check upstream
checkUpdateMessages();
Andreas Gohr's avatar
Andreas Gohr committed

$tmp = array(); // No event data
trigger_event('DOKUWIKI_STARTED',$tmp);
Andreas Gohr's avatar
Andreas Gohr committed
//close session
session_write_close();
Andreas Gohr's avatar
Andreas Gohr committed
//do the work
act_dispatch($ACT);
$tmp = array(); // No event data
trigger_event('DOKUWIKI_DONE', $tmp);
andi's avatar
andi committed
//  xdebug_dump_function_profile(1);