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.
 
 
 
 
 

86 lines
2.2 KiB

  1. <?php
  2. // phpcs:ignorefile
  3. /**
  4. * AJAX Backend for indexmenu
  5. *
  6. * @author Samuele Tognini <samuele@samuele.netsons.org>
  7. * @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
  8. */
  9. //fix for Opera XMLHttpRequests
  10. if ($_POST === [] && @$HTTP_RAW_POST_DATA) {
  11. parse_str($HTTP_RAW_POST_DATA, $_POST);
  12. }
  13. require_once(DOKU_INC . 'inc/init.php');
  14. require_once(DOKU_INC . 'inc/auth.php');
  15. //close session
  16. session_write_close();
  17. $ajax_indexmenu = new ajax_indexmenu_plugin();
  18. $ajax_indexmenu->render();
  19. /**
  20. * Class ajax_indexmenu_plugin
  21. * @deprecated 2023-11 not used anymore
  22. */
  23. class ajax_indexmenu_plugin
  24. {
  25. /**
  26. * Output
  27. *
  28. * @author Samuele Tognini <samuele@samuele.netsons.org>
  29. */
  30. public function render()
  31. {
  32. $req = $_REQUEST['req'];
  33. $succ = false;
  34. //send the zip
  35. if ($req == 'send' && isset($_REQUEST['t'])) {
  36. include(DOKU_PLUGIN . 'indexmenu/inc/repo.class.php');
  37. $repo = new repo_indexmenu_plugin();
  38. $succ = $repo->sendTheme($_REQUEST['t']);
  39. }
  40. if ($succ) return;
  41. header('Content-Type: text/html; charset=utf-8');
  42. header('Cache-Control: public, max-age=3600');
  43. header('Pragma: public');
  44. if ($req === 'local') {
  45. //required for admin.php
  46. //list themes
  47. echo $this->localThemes();
  48. }
  49. }
  50. /**
  51. * Print a list of local themes
  52. * TODO: delete this funstion; copy of this function is already in action.php
  53. * @author Samuele Tognini <samuele@samuele.netsons.org>
  54. */
  55. public function localThemes()
  56. {
  57. $list = 'indexmenu,' . DOKU_URL . ",lib/plugins/indexmenu/images,";
  58. $data = [];
  59. $handle = @opendir(DOKU_PLUGIN . "indexmenu/images");
  60. while (false !== ($file = readdir($handle))) {
  61. if (
  62. is_dir(DOKU_PLUGIN . 'indexmenu/images/' . $file)
  63. && $file != "."
  64. && $file != ".."
  65. && $file != "repository"
  66. && $file != "tmp"
  67. && $file != ".svn"
  68. ) {
  69. $data[] = $file;
  70. }
  71. }
  72. closedir($handle);
  73. sort($data);
  74. $list .= implode(",", $data);
  75. return $list;
  76. }
  77. }