2005-01-12 21:24:54 +01:00
|
|
|
<?php
|
2023-08-31 22:44:40 +02:00
|
|
|
|
2005-01-14 17:40:57 +01:00
|
|
|
/**
|
|
|
|
* DokuWiki mainscript
|
|
|
|
*
|
|
|
|
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
|
|
|
|
* @author Andreas Gohr <andi@splitbrain.org>
|
2012-06-24 14:42:45 +02:00
|
|
|
*
|
|
|
|
* @global Input $INPUT
|
2005-01-14 17:40:57 +01:00
|
|
|
*/
|
2005-02-19 11:20:55 +01:00
|
|
|
|
2023-08-30 14:48:22 +02:00
|
|
|
use dokuwiki\ChangeLog\PageChangeLog;
|
2018-06-15 17:35:53 +02:00
|
|
|
use dokuwiki\Extension\Event;
|
|
|
|
|
2023-08-30 14:48:22 +02:00
|
|
|
// update message version - always use a string to avoid localized floats!
|
2023-04-07 15:30:10 +02:00
|
|
|
$updateVersion = "55";
|
2010-06-27 14:58:07 +02:00
|
|
|
|
2005-04-29 22:54:36 +02:00
|
|
|
// xdebug_start_profiling();
|
2005-03-20 13:49:10 +01:00
|
|
|
|
2023-08-31 00:55:36 +02:00
|
|
|
if (!defined('DOKU_INC')) define('DOKU_INC', __DIR__ . '/');
|
2014-12-17 13:14:02 +01:00
|
|
|
|
|
|
|
// define all DokuWiki globals here (needed within test requests but also helps to keep track)
|
2023-08-31 00:55:36 +02:00
|
|
|
global $ACT, $INPUT, $QUERY, $ID, $REV, $DATE_AT, $IDX,
|
|
|
|
$DATE, $RANGE, $HIGH, $TEXT, $PRE, $SUF, $SUM, $INFO, $JSINFO;
|
2014-12-17 13:14:02 +01:00
|
|
|
|
2009-10-23 10:56:01 +02:00
|
|
|
|
2023-08-31 00:55:36 +02:00
|
|
|
if (isset($_SERVER['HTTP_X_DOKUWIKI_DO'])) {
|
2009-10-23 10:56:01 +02:00
|
|
|
$ACT = trim(strtolower($_SERVER['HTTP_X_DOKUWIKI_DO']));
|
2023-08-31 00:55:36 +02:00
|
|
|
} elseif (!empty($_REQUEST['idx'])) {
|
2009-10-23 10:56:01 +02:00
|
|
|
$ACT = 'index';
|
2023-08-31 00:55:36 +02:00
|
|
|
} elseif (isset($_REQUEST['do'])) {
|
2009-10-23 10:56:01 +02:00
|
|
|
$ACT = $_REQUEST['do'];
|
|
|
|
} else {
|
|
|
|
$ACT = 'show';
|
|
|
|
}
|
|
|
|
|
2010-01-31 19:02:14 +01:00
|
|
|
// load and initialize the core system
|
2023-08-31 00:55:36 +02:00
|
|
|
require_once(DOKU_INC . 'inc/init.php');
|
2009-10-20 23:23:38 +02:00
|
|
|
|
|
|
|
//import variables
|
2013-02-20 20:26:05 +01:00
|
|
|
$INPUT->set('id', str_replace("\xC2\xAD", '', $INPUT->str('id'))); //soft-hyphen
|
2023-08-31 00:55:36 +02:00
|
|
|
$QUERY = trim($INPUT->str('q'));
|
|
|
|
$ID = getID();
|
2011-01-14 23:32:29 +01:00
|
|
|
|
2023-08-31 00:55:36 +02:00
|
|
|
$REV = $INPUT->int('rev');
|
2014-03-19 10:32:55 +01:00
|
|
|
$DATE_AT = $INPUT->str('at');
|
2023-08-31 00:55:36 +02:00
|
|
|
$IDX = $INPUT->str('idx');
|
|
|
|
$DATE = $INPUT->int('date');
|
2012-06-24 14:42:45 +02:00
|
|
|
$RANGE = $INPUT->str('range');
|
2023-08-31 00:55:36 +02:00
|
|
|
$HIGH = $INPUT->param('s');
|
|
|
|
if (empty($HIGH)) $HIGH = getGoogleQuery();
|
2009-10-20 23:23:38 +02:00
|
|
|
|
2023-08-31 00:55:36 +02:00
|
|
|
if ($INPUT->post->has('wikitext')) {
|
2012-06-24 14:43:51 +02:00
|
|
|
$TEXT = cleanText($INPUT->post->str('wikitext'));
|
2010-03-09 11:42:34 +01:00
|
|
|
}
|
2012-06-24 14:43:51 +02:00
|
|
|
$PRE = cleanText(substr($INPUT->post->str('prefix'), 0, -1));
|
|
|
|
$SUF = cleanText($INPUT->post->str('suffix'));
|
|
|
|
$SUM = $INPUT->post->str('summary');
|
2009-10-20 23:23:38 +02:00
|
|
|
|
2014-03-19 10:32:55 +01:00
|
|
|
|
|
|
|
//parse DATE_AT
|
2023-08-31 00:55:36 +02:00
|
|
|
if ($DATE_AT) {
|
2014-09-29 10:13:57 +02:00
|
|
|
$date_parse = strtotime($DATE_AT);
|
2023-08-31 00:55:36 +02:00
|
|
|
if ($date_parse) {
|
2014-09-29 10:13:57 +02:00
|
|
|
$DATE_AT = $date_parse;
|
|
|
|
} else { // check for UNIX Timestamp
|
2023-08-30 17:03:06 +02:00
|
|
|
$date_parse = @date('Ymd', $DATE_AT);
|
2023-08-31 00:55:36 +02:00
|
|
|
if (!$date_parse || $date_parse === '19700101') {
|
2017-08-01 12:03:01 +02:00
|
|
|
msg(sprintf($lang['unable_to_parse_date'], hsc($DATE_AT)));
|
2014-09-29 10:13:57 +02:00
|
|
|
$DATE_AT = null;
|
|
|
|
}
|
2014-03-19 10:32:55 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//check for existing $REV related to $DATE_AT
|
2023-08-31 00:55:36 +02:00
|
|
|
if ($DATE_AT) {
|
2023-08-30 14:48:22 +02:00
|
|
|
$pagelog = new PageChangeLog($ID);
|
2013-11-22 10:51:16 +01:00
|
|
|
$rev_t = $pagelog->getLastRevisionAt($DATE_AT);
|
2023-08-30 14:48:22 +02:00
|
|
|
if ($rev_t === '') {
|
|
|
|
//current revision
|
2014-09-29 10:13:57 +02:00
|
|
|
$REV = null;
|
|
|
|
$DATE_AT = null;
|
2023-08-30 14:48:22 +02:00
|
|
|
} elseif ($rev_t === false) {
|
|
|
|
//page did not exist
|
2023-08-30 17:03:06 +02:00
|
|
|
$rev_n = $pagelog->getRelativeRevision($DATE_AT, +1);
|
2022-04-28 09:58:06 +02:00
|
|
|
msg(
|
|
|
|
sprintf(
|
|
|
|
$lang['page_nonexist_rev'],
|
|
|
|
dformat($DATE_AT),
|
2023-08-30 14:48:22 +02:00
|
|
|
wl($ID, ['rev' => $rev_n]),
|
2022-04-28 09:58:06 +02:00
|
|
|
dformat($rev_n)
|
|
|
|
)
|
|
|
|
);
|
2014-09-29 10:13:57 +02:00
|
|
|
$REV = $DATE_AT; //will result in a page not exists message
|
2013-11-21 15:50:52 +01:00
|
|
|
} else {
|
|
|
|
$REV = $rev_t;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//make infos about the selected page available
|
2009-10-20 23:23:38 +02:00
|
|
|
$INFO = pageinfo();
|
2005-01-12 21:24:54 +01:00
|
|
|
|
2009-10-20 23:23:38 +02:00
|
|
|
// handle debugging
|
2023-08-31 00:55:36 +02:00
|
|
|
if ($conf['allowdebug'] && $ACT == 'debug') {
|
2005-01-12 21:24:54 +01:00
|
|
|
html_debug();
|
|
|
|
exit;
|
2009-10-20 23:23:38 +02:00
|
|
|
}
|
2006-02-17 23:20:40 +01:00
|
|
|
|
2009-10-20 23:23:38 +02:00
|
|
|
//send 404 for missing pages if configured or ID has special meaning to bots
|
2023-08-31 15:04:10 +02:00
|
|
|
if (
|
|
|
|
!$INFO['exists'] &&
|
2012-06-24 14:43:51 +02:00
|
|
|
($conf['send404'] || preg_match('/^(robots\.txt|sitemap\.xml(\.gz)?|favicon\.ico|crossdomain\.xml)$/', $ID)) &&
|
2023-09-15 16:25:49 +02:00
|
|
|
($ACT == 'show' || (!is_array($ACT) && str_starts_with($ACT, 'export_')))
|
2012-06-24 14:43:51 +02:00
|
|
|
) {
|
2005-11-25 13:36:14 +01:00
|
|
|
header('HTTP/1.0 404 Not Found');
|
2009-10-20 23:23:38 +02:00
|
|
|
}
|
2005-11-25 13:36:14 +01:00
|
|
|
|
2009-10-20 23:23:38 +02:00
|
|
|
//prepare breadcrumbs (initialize a static var)
|
2023-08-31 00:55:36 +02:00
|
|
|
if ($conf['breadcrumbs']) breadcrumbs();
|
2005-06-08 23:35:14 +02:00
|
|
|
|
2009-10-20 23:23:38 +02:00
|
|
|
// check upstream
|
|
|
|
checkUpdateMessages();
|
2006-09-16 23:02:29 +02:00
|
|
|
|
2023-08-30 14:48:22 +02:00
|
|
|
$tmp = []; // No event data
|
2018-06-15 17:35:53 +02:00
|
|
|
Event::createAndTrigger('DOKUWIKI_STARTED', $tmp);
|
2006-04-15 17:24:44 +02:00
|
|
|
|
2009-10-20 23:23:38 +02:00
|
|
|
//close session
|
|
|
|
session_write_close();
|
2005-06-08 23:35:14 +02:00
|
|
|
|
2013-05-05 19:59:29 +02:00
|
|
|
//do the work (picks up what to do from global env)
|
|
|
|
act_dispatch();
|
2005-01-29 12:36:21 +01:00
|
|
|
|
2023-08-30 14:48:22 +02:00
|
|
|
$tmp = []; // No event data
|
2018-06-15 17:35:53 +02:00
|
|
|
Event::createAndTrigger('DOKUWIKI_DONE', $tmp);
|
2006-04-15 17:24:44 +02:00
|
|
|
|
2005-04-29 22:54:36 +02:00
|
|
|
// xdebug_dump_function_profile(1);
|