1<?php 2define("DOKU_INC", realpath(dirname(__FILE__).'/../../../../') . '/'); 3define ("DOKU_PLUGIN", DOKU_INC . 'lib/plugins/'); 4define("PAGES", DOKU_INC . 'data/pages/'); 5define("FCKEDITOR", DOKU_PLUGIN . 'ckgedit/fckeditor/editor/'); 6define('CONNECTOR', FCKEDITOR . 'filemanager/connectors/php/'); 7require_once(CONNECTOR . 'check_acl.php'); 8if(file_exists(DOKU_INC.'inc/Input.class.php')) { 9require_once(DOKU_INC.'inc/Input.class.php'); 10} 11else { 12 require_once(DOKU_PLUGIN . 'ckgedit/fckeditor/editor/filemanager/connectors/php/Input.class.php'); 13} 14require_once(CONNECTOR . 'SafeFN.class.php'); 15global $dwfck_conf; 16global $Dwfck_conf_values; 17$INPUT = new Input(); 18$page = $INPUT->str('dw_id'); 19$page = ltrim($page, ':'); 20 21$dwfck_conf = doku_config_values(); // needed for cleanID 22$Dwfck_conf_values = $dwfck_conf; 23$page = str_replace(':', '/',$page); 24$page = dwiki_encodeFN($page); 25 26if(!empty($Dwfck_conf_values['ckg_savedir'])) { 27 if (stristr(PHP_OS, 'WIN')) { 28 $path = realpath(DOKU_INC . $Dwfck_conf_values['ckg_savedir']); 29 $path .= '/pages/' . $page . '.txt'; 30 } 31 else $path = $Dwfck_conf_values['ckg_savedir'] . '/pages/' . $page . '.txt'; 32} 33else $path = PAGES . $page . '.txt'; 34 35$resp = ""; 36$headers = array(); 37$lines = file($path); 38 39foreach ($lines as $line) { 40 if (preg_match('/^=+([^=]+)=+\s*$/',$line,$matches)) { 41 $suffix_anchor = ""; 42 $suffix_header = ""; 43 if(isset($headers[$matches[1]])) { 44 $headers[$matches[1]]++; 45 $suffix_anchor = $headers[$matches[1]]; 46 $suffix_header = " [$suffix_anchor]"; 47 } 48 else { 49 $headers[$matches[1]]=0; 50 } 51 52 $resp .= trim($matches[1]) . $suffix_header . ";;" ; 53 $resp .= cleanID($matches[1]). $suffix_anchor . "@@" ; 54 } 55 56} 57 58$resp = rtrim($resp,'@'); 59echo rawurlencode($resp); 60//file_put_contents('ajax-resp.txt', "dw_id=" . $_REQUEST['dw_id'] . "\npage=$page\npath=$path\n$resp\n" ); 61 62echo "\n"; 63function doku_config_values() { 64 $dwphp = DOKU_INC . 'conf/dokuwiki.php'; 65 $localphp = DOKU_INC . 'conf/local.php'; 66 $conf['ckg_savedir']= false; 67 if(file_exists($dwphp)) 68 { 69 include($dwphp); 70 if(file_exists($localphp)) 71 { 72 include($localphp); 73 } 74 $sv = preg_replace("#^\.+/#","",$conf['savedir']); 75 if($sv != 'data') { 76 $conf['ckg_savedir']= $conf['savedir']; 77 } 78 return $conf; 79 } 80 81 return false; 82} 83?> 84 85