1<?php 2/** 3 * AJAX call handler for tagindex admin plugin 4 * 5 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 6 * @author Gina Häußge, Michael Klier <dokuwiki@chimeric.de> 7 * @author Andreas Gohr <andi@splitbrain.org> 8 * @author Arthur Lobert <arthur.lobert@gmail.com> 9 */ 10 11if (!defined('DOKU_INC')) define('DOKU_INC', realpath(dirname(__FILE__) . '/../../../') . '/'); 12if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); 13if (!defined('DOKU_REG')) define ('DOKU_REG', DOKU_PLUGIN.'autolink3/register/'); 14if (!defined('DOKU_PAGE')) define ('DOKU_PAGE', DOKU_INC.'data/pages'); 15if (!defined('DOKU_PAGES')) define ('DOKU_PAGES', realpath(DOKU_PAGE)); 16if (!defined('NL')) define('NL', "\n"); 17 18define('AUTH_NONE',0); 19define('AUTH_READ',1); 20define('AUTH_EDIT',2); 21define('AUTH_CREATE',4); 22define('AUTH_UPLOAD',8); 23define('AUTH_DELETE',16); 24define('AUTH_ADMIN',255); 25 26//fix for Opera XMLHttpRequests 27if(!count($_POST) && $HTTP_RAW_POST_DATA) 28{ 29 parse_str($HTTP_RAW_POST_DATA, $_POST); 30} 31 32require_once(DOKU_INC.'inc/init.php'); 33require_once(DOKU_INC.'inc/common.php'); 34require_once(DOKU_INC.'inc/events.php'); 35require_once(DOKU_INC.'inc/pageutils.php'); 36require_once(DOKU_INC.'inc/html.php'); 37require_once(DOKU_INC.'inc/auth.php'); 38require_once(DOKU_INC.'inc/actions.php'); 39require_once(DOKU_INC.'inc/init.php'); 40require_once(DOKU_INC.'inc/common.php'); 41require_once(DOKU_INC.'inc/pageutils.php'); 42require_once(DOKU_INC.'inc/auth.php'); 43require_once(DOKU_INC.'inc/search.php'); 44require_once(DOKU_INC.'inc/indexer.php'); 45 46//close session 47session_write_close(); 48header('Content-Type: text/plain; charset=utf-8'); 49 50//clear all index files 51if (@file_exists($conf['indexdir'].'/page.idx'))// new word length based index 52{ 53 $tag_idx = $conf['indexdir'].'/topic.idx'; 54} 55else 56{ // old index 57$tag_idx = $conf['cachedir'].'/topic.idx'; 58} 59$tag_helper =& plugin_load('helper', 'tag'); 60 61//call the requested function 62$call = 'ajax_'.$_POST['call']; 63if(function_exists($call)) 64{ 65 $call(); 66} 67else 68{ 69 print "The called function '".htmlspecialchars($call)."' does not exist!"; 70} 71 72function ajax_save_page() 73{ 74 if ($_POST['range'][0] == '0' && $_POST['range'][1] == '-') 75 $_POST['range'][0] = '1'; 76 $tab = rawWikiSlices($_POST['range'], $_POST['page']); 77 if ($tab[2]) 78 $text = $tab[0].$_POST['text'].'='.$tab[2]; 79 else 80 $text = $tab[0].$_POST['text'].$tab[2]; 81 saveWikiText($_POST['page'],$text,$_POST['sub'], $_POST['minor']); 82 unlock($_POST['page']); 83 print 1; 84} 85 86function ajax_get_auth() 87{ 88 global $INFO; 89 $INFO = pageinfo(); 90 91 if ($INFO['editable'] == 1){ 92 print 1; 93 } 94 else{ 95 print false; 96 } 97} 98 99function ajax_get_text() { 100 101 lock($_POST['page']); 102 $lock = $conf['lockdir'].'/_tagindexer.lock'; 103 // we're finished 104 if ($_POST['range'][0] == '0' && $_POST['range'][1] == '-') 105 $_POST['range'][0] = '1'; 106 $t = rawWikiSlices($_POST['range'], $_POST['page'], false); 107 print $t[1]; 108 } 109 110?>