You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

85 lines
2.4 KiB

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