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