1<?php 2 3/** 4 * AJAX call handler for searchindex plugin 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', realpath(__DIR__ . '/../../../') . '/'); 11require_once(DOKU_INC . 'inc/init.php'); 12session_write_close(); 13header('Content-Type: application/json; charset=utf-8'); 14@ignore_user_abort(true); 15 16// we only work for admins! 17if(!auth_isadmin()) throw new Exception('access denied'); 18 19/** @var helper_plugin_searchindex $helper */ 20$helper = plugin_load('helper', 'searchindex'); 21global $INPUT; 22 23switch($INPUT->post->str('call')) { 24 case 'pagelist': 25 echo json_encode($helper->getPagelist()); 26 break; 27 case 'clearindex': 28 echo json_encode($helper->clearIndex()); 29 break; 30 case 'indexpage': 31 $page = $INPUT->post->str('page'); 32 $force = $INPUT->post->bool('force'); 33 echo json_encode($helper->indexPage($page, $force)); 34 break; 35 default: 36 throw new \Exception('The called function does not exist!'); 37} 38