xref: /dokuwiki/lib/exe/ajax.php (revision 814e20b885024d75719ca160139e824af2bb9992)
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
9if(!defined('DOKU_INC')) define('DOKU_INC',dirname(__FILE__).'/../../');
10require_once(DOKU_INC.'inc/init.php');
11require_once(DOKU_INC.'inc/ajax_functions.php');
12
13//close session
14session_write_close();
15
16header('Content-Type: text/html; charset=utf-8');
17
18//call the requested function
19if($INPUT->has('call')) {
20    $call = $INPUT->filter('utf8_stripspecials')->str('call');
21    $callfn = 'ajax_'.$call;
22
23    if(function_exists($callfn)) {
24        $callfn();
25    } else {
26        $evt = new Doku_Event('AJAX_CALL_UNKNOWN', $call);
27        if ($evt->advise_before()) {
28            print "AJAX call '".htmlspecialchars($call)."' unknown!\n";
29        } else {
30            $evt->advise_after();
31            unset($evt);
32        }
33    }
34}