1<?php 2 3/** 4 * DokuWiki AJAX call handler 5 * 6 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 7 * @author Andreas Gohr <andi@splitbrain.org> 8 */ 9 10if (!defined('DOKU_INC')) define('DOKU_INC', __DIR__ . '/../../../'); 11require_once(DOKU_INC . 'inc/init.php'); 12 13/* 14session_start(); 15$session = json_encode($_SESSION); 16$cookie = json_encode($_COOKIE); 17$status = json_encode(session_status()); 18*/ 19//close session 20session_write_close(); 21 22// default header, ajax call may overwrite it later 23header('Content-Type: text/html; charset=utf-8'); 24 25//call the requested function 26/* 27global $INPUT; 28if ($INPUT->has('call')) { 29 $call = $INPUT->filter([Clean::class, 'stripspecials'])->str('call'); 30 new Ajax($call); 31} else { 32 http_status(404); 33}*/ 34 35/* 36$html = "<p>session</p>\n"; 37$html.= "<code>$session</code>\n"; 38$html.= "<p>cookie</p>\n"; 39$html.= "<code>$cookie</code>\n"; 40$html.= "<p>status</p>\n"; 41$html.= "<code>$status</code>\n"; 42*/ 43$input = file_get_contents('php://input'); 44// Unpack 45$id = substr($input,0,5); 46$md5 = substr($input,5,32); 47$text = substr($input,37); 48//sleep(5); 49// Reject if md5 does not match 50if ($md5 != md5($text)) { 51 http_response_code(400); 52 die(); 53} 54$info = []; 55$html = p_render('xhtml', p_get_instructions($text), $info); 56 57echo $id.md5($html).$html; 58//echo json_encode(['input'=>$input]); 59//echo json_encode(['session'=>$_SESSION]); 60 61