6 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
7 * @author Andreas Gohr <andi@splitbrain.org>
12 use dokuwiki\ChangeLog\PageChangeLog
;
13 use dokuwiki\Extension\Event
;
15 // update message version - always use a string to avoid localized floats!
16 $updateVersion = "55";
18 // xdebug_start_profiling();
20 if (!defined('DOKU_INC')) define('DOKU_INC', __DIR__
. '/');
22 // define all DokuWiki globals here (needed within test requests but also helps to keep track)
23 global $ACT, $INPUT, $QUERY, $ID, $REV, $DATE_AT, $IDX,
24 $DATE, $RANGE, $HIGH, $TEXT, $PRE, $SUF, $SUM, $INFO, $JSINFO;
27 if (isset($_SERVER['HTTP_X_DOKUWIKI_DO'])) {
28 $ACT = trim(strtolower($_SERVER['HTTP_X_DOKUWIKI_DO']));
29 } elseif (!empty($_REQUEST['idx'])) {
31 } elseif (isset($_REQUEST['do'])) {
32 $ACT = $_REQUEST['do'];
37 // load and initialize the core system
38 require_once(DOKU_INC
. 'inc/init.php');
41 $INPUT->set('id', str_replace("\xC2\xAD", '', $INPUT->str('id'))); //soft-hyphen
42 $QUERY = trim($INPUT->str('q'));
45 $REV = $INPUT->int('rev');
46 $DATE_AT = $INPUT->str('at');
47 $IDX = $INPUT->str('idx');
48 $DATE = $INPUT->int('date');
49 $RANGE = $INPUT->str('range');
50 $HIGH = $INPUT->param('s');
51 if (empty($HIGH)) $HIGH = getGoogleQuery();
53 if ($INPUT->post
->has('wikitext')) {
54 $TEXT = cleanText($INPUT->post
->str('wikitext'));
56 $PRE = cleanText(substr($INPUT->post
->str('prefix'), 0, -1));
57 $SUF = cleanText($INPUT->post
->str('suffix'));
58 $SUM = $INPUT->post
->str('summary');
63 $date_parse = strtotime($DATE_AT);
65 $DATE_AT = $date_parse;
66 } else { // check for UNIX Timestamp
67 $date_parse = @date
('Ymd', $DATE_AT);
68 if (!$date_parse ||
$date_parse === '19700101') {
69 msg(sprintf($lang['unable_to_parse_date'], hsc($DATE_AT)));
75 //check for existing $REV related to $DATE_AT
77 $pagelog = new PageChangeLog($ID);
78 $rev_t = $pagelog->getLastRevisionAt($DATE_AT);
83 } elseif ($rev_t === false) {
85 $rev_n = $pagelog->getRelativeRevision($DATE_AT, +
1);
88 $lang['page_nonexist_rev'],
90 wl($ID, ['rev' => $rev_n]),
94 $REV = $DATE_AT; //will result in a page not exists message
100 //make infos about the selected page available
104 if ($conf['allowdebug'] && $ACT == 'debug') {
109 //send 404 for missing pages if configured or ID has special meaning to bots
112 ($conf['send404'] ||
preg_match('/^(robots\.txt|sitemap\.xml(\.gz)?|favicon\.ico|crossdomain\.xml)$/', $ID)) &&
113 ($ACT == 'show' ||
(!is_array($ACT) && substr($ACT, 0, 7) == 'export_'))
115 header('HTTP/1.0 404 Not Found');
118 //prepare breadcrumbs (initialize a static var)
119 if ($conf['breadcrumbs']) breadcrumbs();
122 checkUpdateMessages();
124 $tmp = []; // No event data
125 Event
::createAndTrigger('DOKUWIKI_STARTED', $tmp);
128 session_write_close();
130 //do the work (picks up what to do from global env)
133 $tmp = []; // No event data
134 Event
::createAndTrigger('DOKUWIKI_DONE', $tmp);
136 // xdebug_dump_function_profile(1);