-
Notifications
You must be signed in to change notification settings - Fork 14
/
api.php
67 lines (60 loc) · 1.94 KB
/
api.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
<?php
if (!defined('DOKU_INC')) {
define('DOKU_INC', __DIR__ . '/../../../');
}
require_once(DOKU_INC . 'inc/init.php');
require_once(DOKU_PLUGIN . 'pluginrepo/helper/repository.php');
//close session
session_write_close();
/** @var helper_plugin_pluginrepo_repository $REPO */
$REPO = plugin_load('helper', 'pluginrepo_repository');
// query the repository
$extensions = $REPO->getFilteredPlugins(
$INPUT->arr('ext'),
$INPUT->arr('mail'),
$INPUT->int('type'),
$INPUT->arr('tag'),
$INPUT->str('order'),
$INPUT->int('limit'),
$INPUT->str('q')
);
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('X-Robots-Tag: noindex');
if ($INPUT->str('cmd') == 'ping') {
header('Content-Type: text/plain; charset=utf-8');
echo '1';
} else {
switch ($INPUT->str('fmt')) {
case 'debug':
header('Content-Type: text/plain; charset=utf-8');
print_r($extensions);
break;
case 'xml':
header('Content-Type: application/xml; charset=utf-8');
require(__DIR__ . '/classes/A2Xml.php');
$xml = xml_encode((object) $extensions, "hash");
echo $xml;
break;
case 'yaml':
header('Content-Type: text/yaml');
require(__DIR__ . '/classes/Spyc.php');
echo Spyc::YAMLDump($extensions, false, 0);
break;
case 'php':
header('Content-Type: application/vnd.php.serialized');
echo serialize($extensions);
break;
default:
$data = json_encode($extensions);
$cb = $INPUT->str('cb');
$cb = preg_replace('/\W+/', '', $cb);
if ($cb) {
header('Content-Type: text/javascript');
echo "$cb($data);";
} else {
header('Content-Type: application/json');
echo $data;
}
}
}