You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

137 lines
3.6 KiB

  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. use dokuwiki\ChangeLog\PageChangeLog;
  11. use dokuwiki\Extension\Event;
  12. // update message version - always use a string to avoid localized floats!
  13. $updateVersion = "55.1";
  14. // xdebug_start_profiling();
  15. if (!defined('DOKU_INC')) define('DOKU_INC', __DIR__ . '/');
  16. // define all DokuWiki globals here (needed within test requests but also helps to keep track)
  17. global $ACT, $INPUT, $QUERY, $ID, $REV, $DATE_AT, $IDX,
  18. $DATE, $RANGE, $HIGH, $TEXT, $PRE, $SUF, $SUM, $INFO, $JSINFO;
  19. if (isset($_SERVER['HTTP_X_DOKUWIKI_DO'])) {
  20. $ACT = trim(strtolower($_SERVER['HTTP_X_DOKUWIKI_DO']));
  21. } elseif (!empty($_REQUEST['idx'])) {
  22. $ACT = 'index';
  23. } elseif (isset($_REQUEST['do'])) {
  24. $ACT = $_REQUEST['do'];
  25. } else {
  26. $ACT = 'show';
  27. }
  28. // load and initialize the core system
  29. require_once(DOKU_INC . 'inc/init.php');
  30. //import variables
  31. $INPUT->set('id', str_replace("\xC2\xAD", '', $INPUT->str('id'))); //soft-hyphen
  32. $QUERY = trim($INPUT->str('q'));
  33. $ID = getID();
  34. $REV = $INPUT->int('rev');
  35. $DATE_AT = $INPUT->str('at');
  36. $IDX = $INPUT->str('idx');
  37. $DATE = $INPUT->int('date');
  38. $RANGE = $INPUT->str('range');
  39. $HIGH = $INPUT->param('s');
  40. if (empty($HIGH)) $HIGH = getGoogleQuery();
  41. if ($INPUT->post->has('wikitext')) {
  42. $TEXT = cleanText($INPUT->post->str('wikitext'));
  43. }
  44. $PRE = cleanText(substr($INPUT->post->str('prefix'), 0, -1));
  45. $SUF = cleanText($INPUT->post->str('suffix'));
  46. $SUM = $INPUT->post->str('summary');
  47. //parse DATE_AT
  48. if ($DATE_AT) {
  49. $date_parse = strtotime($DATE_AT);
  50. if ($date_parse) {
  51. $DATE_AT = $date_parse;
  52. } else { // check for UNIX Timestamp
  53. $date_parse = @date('Ymd', $DATE_AT);
  54. if (!$date_parse || $date_parse === '19700101') {
  55. msg(sprintf($lang['unable_to_parse_date'], hsc($DATE_AT)));
  56. $DATE_AT = null;
  57. }
  58. }
  59. }
  60. //check for existing $REV related to $DATE_AT
  61. if ($DATE_AT) {
  62. $pagelog = new PageChangeLog($ID);
  63. $rev_t = $pagelog->getLastRevisionAt($DATE_AT);
  64. if ($rev_t === '') {
  65. //current revision
  66. $REV = null;
  67. $DATE_AT = null;
  68. } elseif ($rev_t === false) {
  69. //page did not exist
  70. $rev_n = $pagelog->getRelativeRevision($DATE_AT, +1);
  71. msg(
  72. sprintf(
  73. $lang['page_nonexist_rev'],
  74. dformat($DATE_AT),
  75. wl($ID, ['rev' => $rev_n]),
  76. dformat($rev_n)
  77. )
  78. );
  79. $REV = $DATE_AT; //will result in a page not exists message
  80. } else {
  81. $REV = $rev_t;
  82. }
  83. }
  84. //make infos about the selected page available
  85. $INFO = pageinfo();
  86. // handle debugging
  87. if ($conf['allowdebug'] && $ACT == 'debug') {
  88. html_debug();
  89. exit;
  90. }
  91. //send 404 for missing pages if configured or ID has special meaning to bots
  92. if (
  93. !$INFO['exists'] &&
  94. ($conf['send404'] || preg_match('/^(robots\.txt|sitemap\.xml(\.gz)?|favicon\.ico|crossdomain\.xml)$/', $ID)) &&
  95. ($ACT == 'show' || (!is_array($ACT) && str_starts_with($ACT, 'export_')))
  96. ) {
  97. header('HTTP/1.0 404 Not Found');
  98. }
  99. //prepare breadcrumbs (initialize a static var)
  100. if ($conf['breadcrumbs']) breadcrumbs();
  101. // check upstream
  102. checkUpdateMessages();
  103. $tmp = []; // No event data
  104. Event::createAndTrigger('DOKUWIKI_STARTED', $tmp);
  105. //close session
  106. session_write_close();
  107. //do the work (picks up what to do from global env)
  108. act_dispatch();
  109. $tmp = []; // No event data
  110. Event::createAndTrigger('DOKUWIKI_DONE', $tmp);
  111. // xdebug_dump_function_profile(1);