1<?php 2/** 3 * DokuWiki Actions 4 * 5 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 6 * @author Andreas Gohr <andi@splitbrain.org> 7 */ 8 9if(!defined('DOKU_INC')) die('meh.'); 10 11 12function act_dispatch(){ 13 $reinit = false; 14 if(defined('DOKU_UNITTEST')) { 15 // For integration test running multiple requests we need a re-init here! 16 $reinit = true; 17 } 18 $router = \dokuwiki\ActionRouter::getInstance($reinit); // is this needed here or could we delegate it to tpl_content() later? 19 20 $headers = array('Content-Type: text/html; charset=utf-8'); 21 trigger_event('ACTION_HEADERS_SEND',$headers,'act_sendheaders'); 22 23 // clear internal variables 24 unset($router); 25 unset($headers); 26 // make all globals available to the template 27 extract($GLOBALS); 28 29 include(template('main.php')); 30 // output for the commands is now handled in inc/templates.php 31 // in function tpl_content() 32} 33 34/** 35 * Send the given headers using header() 36 * 37 * @param array $headers The headers that shall be sent 38 */ 39function act_sendheaders($headers) { 40 foreach ($headers as $hdr) header($hdr); 41} 42 43/** 44 * Sanitize the action command 45 * 46 * @author Andreas Gohr <andi@splitbrain.org> 47 * 48 * @param array|string $act 49 * @return string 50 */ 51function act_clean($act){ 52 // check if the action was given as array key 53 if(is_array($act)){ 54 list($act) = array_keys($act); 55 } 56 57 //remove all bad chars 58 $act = strtolower($act); 59 $act = preg_replace('/[^1-9a-z_]+/','',$act); 60 61 if($act == 'export_html') $act = 'export_xhtml'; 62 if($act == 'export_htmlbody') $act = 'export_xhtmlbody'; 63 64 if($act === '') $act = 'show'; 65 return $act; 66} 67