1<?php 2/** 3 * DokuWiki AJAX call handler 4 * 5 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 6 * @author Andreas Gohr <andi@splitbrain.org> 7 */ 8 9//fix for Opera XMLHttpRequests 10if(!count($_POST) && $HTTP_RAW_POST_DATA){ 11 parse_str($HTTP_RAW_POST_DATA, $_POST); 12} 13 14if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/'); 15require_once(DOKU_INC.'inc/init.php'); 16require_once(DOKU_INC.'inc/common.php'); 17require_once(DOKU_INC.'inc/pageutils.php'); 18require_once(DOKU_INC.'inc/auth.php'); 19//close sesseion 20session_write_close(); 21 22header('Content-Type: text/html; charset=utf-8'); 23 24 25//call the requested function 26$call = 'ajax_'.$_POST['call']; 27if(function_exists($call)){ 28 $call(); 29}else{ 30 print "The called function '".htmlspecialchars($call)."' does not exist!"; 31} 32 33/** 34 * Searches for matching pagenames 35 * 36 * @author Andreas Gohr <andi@splitbrain.org> 37 */ 38function ajax_qsearch(){ 39 global $conf; 40 global $lang; 41 42 $query = cleanID($_POST['q']); 43 if(empty($query)) return; 44 45 $nsdir = str_replace(':','/',getNS($query)); 46 require_once(DOKU_INC.'inc/search.php'); 47 require_once(DOKU_INC.'inc/html.php'); 48 49 $data = array(); 50 search($data,$conf['datadir'],'search_qsearch',array(query => $query),$nsdir); 51 52 if(!count($data)) return; 53 54 print '<b>'.$lang['quickhits'].'</b>'; 55 print html_buildlist($data,'qsearch','html_list_index'); 56} 57 58//Setup VIM: ex: et ts=2 enc=utf-8 : 59?> 60