Mereged updates from DokuWiki 38
[sudaraka-org:dokuwiki-mods.git] / doku.php
1 <?php
2 /**
3  * DokuWiki mainscript
4  *
5  * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
6  * @author     Andreas Gohr <andi@splitbrain.org>
7  *
8  * @global Input $INPUT
9  */
10
11 // update message version
12 $updateVersion = 38;
13
14 //  xdebug_start_profiling();
15
16 if(!defined('DOKU_INC')) define('DOKU_INC', dirname(__FILE__).'/');
17
18 if(isset($_SERVER['HTTP_X_DOKUWIKI_DO'])) {
19     $ACT = trim(strtolower($_SERVER['HTTP_X_DOKUWIKI_DO']));
20 } elseif(!empty($_REQUEST['idx'])) {
21     $ACT = 'index';
22 } elseif(isset($_REQUEST['do'])) {
23     $ACT = $_REQUEST['do'];
24 } else {
25     $ACT = 'show';
26 }
27
28 //Disable over HTTP edits
29 if(!in_array($ACT, array('show', 'sitemap', 'export_code'))) $ACT = 'show';
30
31 // load and initialize the core system
32 require_once(DOKU_INC.'inc/init.php');
33
34 //import variables
35 $_REQUEST['id'] = str_replace("\xC2\xAD", '', $INPUT->str('id')); //soft-hyphen
36 $QUERY          = trim($INPUT->str('id'));
37 $ID             = getID();
38
39 $REV   = $INPUT->int('rev');
40 $IDX   = $INPUT->str('idx');
41 $DATE  = $INPUT->int('date');
42 $RANGE = $INPUT->str('range');
43 $HIGH  = $INPUT->param('s');
44 if(empty($HIGH)) $HIGH = getGoogleQuery();
45
46 if($INPUT->post->has('wikitext')) {
47     $TEXT = cleanText($INPUT->post->str('wikitext'));
48 }
49 $PRE = cleanText(substr($INPUT->post->str('prefix'), 0, -1));
50 $SUF = cleanText($INPUT->post->str('suffix'));
51 $SUM = $INPUT->post->str('summary');
52
53 //make infos about the selected page available
54 $INFO = pageinfo();
55
56 //export minimal infos to JS, plugins can add more
57 $JSINFO['id']        = $ID;
58 $JSINFO['namespace'] = (string) $INFO['namespace'];
59
60 // handle debugging
61 if($conf['allowdebug'] && $ACT == 'debug') {
62     html_debug();
63     exit;
64 }
65
66 //send 404 for missing pages if configured or ID has special meaning to bots
67 if(!$INFO['exists'] &&
68     ($conf['send404'] || preg_match('/^(robots\.txt|sitemap\.xml(\.gz)?|favicon\.ico|crossdomain\.xml)$/', $ID)) &&
69     ($ACT == 'show' || (!is_array($ACT) && substr($ACT, 0, 7) == 'export_'))
70 ) {
71     header('HTTP/1.0 404 Not Found');
72 }
73
74 //prepare breadcrumbs (initialize a static var)
75 if($conf['breadcrumbs']) breadcrumbs();
76
77 // check upstream
78 checkUpdateMessages();
79
80 $tmp = array(); // No event data
81 trigger_event('DOKUWIKI_STARTED', $tmp);
82
83 //close session
84 session_write_close();
85
86 //do the work
87 act_dispatch($ACT);
88
89 $tmp = array(); // No event data
90 trigger_event('DOKUWIKI_DONE', $tmp);
91
92 //  xdebug_dump_function_profile(1);