Merge pull request #3938 from dokuwiki/svglogo
[dokuwiki.git] / doku.php
blob4b5c32f231e9576d984f3941965f340f2e9e3c80
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 - always use a string to avoid localized floats!
12 use dokuwiki\Extension\Event;
14 $updateVersion = "55";
16 // xdebug_start_profiling();
18 if(!defined('DOKU_INC')) define('DOKU_INC', dirname(__FILE__).'/');
20 // define all DokuWiki globals here (needed within test requests but also helps to keep track)
21 global $ACT, $INPUT, $QUERY, $ID, $REV, $DATE_AT, $IDX,
22 $DATE, $RANGE, $HIGH, $TEXT, $PRE, $SUF, $SUM, $INFO, $JSINFO;
25 if(isset($_SERVER['HTTP_X_DOKUWIKI_DO'])) {
26 $ACT = trim(strtolower($_SERVER['HTTP_X_DOKUWIKI_DO']));
27 } elseif(!empty($_REQUEST['idx'])) {
28 $ACT = 'index';
29 } elseif(isset($_REQUEST['do'])) {
30 $ACT = $_REQUEST['do'];
31 } else {
32 $ACT = 'show';
35 // load and initialize the core system
36 require_once(DOKU_INC.'inc/init.php');
38 //import variables
39 $INPUT->set('id', str_replace("\xC2\xAD", '', $INPUT->str('id'))); //soft-hyphen
40 $QUERY = trim($INPUT->str('q'));
41 $ID = getID();
43 $REV = $INPUT->int('rev');
44 $DATE_AT = $INPUT->str('at');
45 $IDX = $INPUT->str('idx');
46 $DATE = $INPUT->int('date');
47 $RANGE = $INPUT->str('range');
48 $HIGH = $INPUT->param('s');
49 if(empty($HIGH)) $HIGH = getGoogleQuery();
51 if($INPUT->post->has('wikitext')) {
52 $TEXT = cleanText($INPUT->post->str('wikitext'));
54 $PRE = cleanText(substr($INPUT->post->str('prefix'), 0, -1));
55 $SUF = cleanText($INPUT->post->str('suffix'));
56 $SUM = $INPUT->post->str('summary');
59 //parse DATE_AT
60 if($DATE_AT) {
61 $date_parse = strtotime($DATE_AT);
62 if($date_parse) {
63 $DATE_AT = $date_parse;
64 } else { // check for UNIX Timestamp
65 $date_parse = @date('Ymd',$DATE_AT);
66 if(!$date_parse || $date_parse === '19700101') {
67 msg(sprintf($lang['unable_to_parse_date'], hsc($DATE_AT)));
68 $DATE_AT = null;
73 //check for existing $REV related to $DATE_AT
74 if($DATE_AT) {
75 $pagelog = new \dokuwiki\ChangeLog\PageChangeLog($ID);
76 $rev_t = $pagelog->getLastRevisionAt($DATE_AT);
77 if($rev_t === '') { //current revision
78 $REV = null;
79 $DATE_AT = null;
80 } else if ($rev_t === false) { //page did not exist
81 $rev_n = $pagelog->getRelativeRevision($DATE_AT,+1);
82 msg(
83 sprintf(
84 $lang['page_nonexist_rev'],
85 dformat($DATE_AT),
86 wl($ID, array('rev' => $rev_n)),
87 dformat($rev_n)
90 $REV = $DATE_AT; //will result in a page not exists message
91 } else {
92 $REV = $rev_t;
96 //make infos about the selected page available
97 $INFO = pageinfo();
99 // handle debugging
100 if($conf['allowdebug'] && $ACT == 'debug') {
101 html_debug();
102 exit;
105 //send 404 for missing pages if configured or ID has special meaning to bots
106 if(!$INFO['exists'] &&
107 ($conf['send404'] || preg_match('/^(robots\.txt|sitemap\.xml(\.gz)?|favicon\.ico|crossdomain\.xml)$/', $ID)) &&
108 ($ACT == 'show' || (!is_array($ACT) && substr($ACT, 0, 7) == 'export_'))
110 header('HTTP/1.0 404 Not Found');
113 //prepare breadcrumbs (initialize a static var)
114 if($conf['breadcrumbs']) breadcrumbs();
116 // check upstream
117 checkUpdateMessages();
119 $tmp = array(); // No event data
120 Event::createAndTrigger('DOKUWIKI_STARTED', $tmp);
122 //close session
123 session_write_close();
125 //do the work (picks up what to do from global env)
126 act_dispatch();
128 $tmp = array(); // No event data
129 Event::createAndTrigger('DOKUWIKI_DONE', $tmp);
131 // xdebug_dump_function_profile(1);