rename vague AuthPlugin used by remote and authdelete tests
[dokuwiki.git] / doku.php
blob4d203464a7fea2f46e2fb94fcb0c2ab968ab4540
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 = "51";
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 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(sprintf($lang['page_nonexist_rev'],
83 strftime($conf['dformat'],$DATE_AT),
84 wl($ID, array('rev' => $rev_n)),
85 strftime($conf['dformat'],$rev_n)));
86 $REV = $DATE_AT; //will result in a page not exists message
87 } else {
88 $REV = $rev_t;
92 //make infos about the selected page available
93 $INFO = pageinfo();
95 // handle debugging
96 if($conf['allowdebug'] && $ACT == 'debug') {
97 html_debug();
98 exit;
101 //send 404 for missing pages if configured or ID has special meaning to bots
102 if(!$INFO['exists'] &&
103 ($conf['send404'] || preg_match('/^(robots\.txt|sitemap\.xml(\.gz)?|favicon\.ico|crossdomain\.xml)$/', $ID)) &&
104 ($ACT == 'show' || (!is_array($ACT) && substr($ACT, 0, 7) == 'export_'))
106 header('HTTP/1.0 404 Not Found');
109 //prepare breadcrumbs (initialize a static var)
110 if($conf['breadcrumbs']) breadcrumbs();
112 // check upstream
113 checkUpdateMessages();
115 $tmp = array(); // No event data
116 Event::createAndTrigger('DOKUWIKI_STARTED', $tmp);
118 //close session
119 session_write_close();
121 //do the work (picks up what to do from global env)
122 act_dispatch();
124 $tmp = array(); // No event data
125 Event::createAndTrigger('DOKUWIKI_DONE', $tmp);
127 // xdebug_dump_function_profile(1);