5 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
6 * @author Andreas Gohr <andi@splitbrain.org>
11 use dokuwiki\ChangeLog\PageChangeLog
;
12 use dokuwiki\Extension\Event
;
14 // update message version - always use a string to avoid localized floats!
15 $updateVersion = "55";
17 // xdebug_start_profiling();
19 if (!defined('DOKU_INC')) define('DOKU_INC', __DIR__
. '/');
21 // define all DokuWiki globals here (needed within test requests but also helps to keep track)
22 global $ACT, $INPUT, $QUERY, $ID, $REV, $DATE_AT, $IDX,
23 $DATE, $RANGE, $HIGH, $TEXT, $PRE, $SUF, $SUM, $INFO, $JSINFO;
26 if (isset($_SERVER['HTTP_X_DOKUWIKI_DO'])) {
27 $ACT = trim(strtolower($_SERVER['HTTP_X_DOKUWIKI_DO']));
28 } elseif (!empty($_REQUEST['idx'])) {
30 } elseif (isset($_REQUEST['do'])) {
31 $ACT = $_REQUEST['do'];
36 // load and initialize the core system
37 require_once(DOKU_INC
. 'inc/init.php');
40 $INPUT->set('id', str_replace("\xC2\xAD", '', $INPUT->str('id'))); //soft-hyphen
41 $QUERY = trim($INPUT->str('q'));
44 $REV = $INPUT->int('rev');
45 $DATE_AT = $INPUT->str('at');
46 $IDX = $INPUT->str('idx');
47 $DATE = $INPUT->int('date');
48 $RANGE = $INPUT->str('range');
49 $HIGH = $INPUT->param('s');
50 if (empty($HIGH)) $HIGH = getGoogleQuery();
52 if ($INPUT->post
->has('wikitext')) {
53 $TEXT = cleanText($INPUT->post
->str('wikitext'));
55 $PRE = cleanText(substr($INPUT->post
->str('prefix'), 0, -1));
56 $SUF = cleanText($INPUT->post
->str('suffix'));
57 $SUM = $INPUT->post
->str('summary');
62 $date_parse = strtotime($DATE_AT);
64 $DATE_AT = $date_parse;
65 } else { // check for UNIX Timestamp
66 $date_parse = @date
('Ymd', $DATE_AT);
67 if (!$date_parse ||
$date_parse === '19700101') {
68 msg(sprintf($lang['unable_to_parse_date'], hsc($DATE_AT)));
74 //check for existing $REV related to $DATE_AT
76 $pagelog = new PageChangeLog($ID);
77 $rev_t = $pagelog->getLastRevisionAt($DATE_AT);
82 } elseif ($rev_t === false) {
84 $rev_n = $pagelog->getRelativeRevision($DATE_AT, +
1);
87 $lang['page_nonexist_rev'],
89 wl($ID, ['rev' => $rev_n]),
93 $REV = $DATE_AT; //will result in a page not exists message
99 //make infos about the selected page available
103 if ($conf['allowdebug'] && $ACT == 'debug') {
108 //send 404 for missing pages if configured or ID has special meaning to bots
109 if (!$INFO['exists'] &&
110 ($conf['send404'] ||
preg_match('/^(robots\.txt|sitemap\.xml(\.gz)?|favicon\.ico|crossdomain\.xml)$/', $ID)) &&
111 ($ACT == 'show' ||
(!is_array($ACT) && substr($ACT, 0, 7) == 'export_'))
113 header('HTTP/1.0 404 Not Found');
116 //prepare breadcrumbs (initialize a static var)
117 if ($conf['breadcrumbs']) breadcrumbs();
120 checkUpdateMessages();
122 $tmp = []; // No event data
123 Event
::createAndTrigger('DOKUWIKI_STARTED', $tmp);
126 session_write_close();
128 //do the work (picks up what to do from global env)
131 $tmp = []; // No event data
132 Event
::createAndTrigger('DOKUWIKI_DONE', $tmp);
134 // xdebug_dump_function_profile(1);