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