forked from nyson/glosie
-
Notifications
You must be signed in to change notification settings - Fork 0
/
api.php
34 lines (31 loc) · 787 Bytes
/
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
<?
define("DICT_DIR", "./dicts/");
function __autoload($c) {
if(is_file("./lib/$c"))
include "./lib/$c";
else
throw new Exception("Class $c is not implemented and cannot be called!");
}
$do = isset($_GET['do']) ? $_GET['do'] : "";
switch($do) {
/* getDicts
Returns an array of the names of all available dictionaries.
*/
case 'getDicts':
$result = array();
$dh = opendir(DICT_DIR);
while($file = readdir($dh)) {
if(substr($file, 0, 1) == "." || is_dir(DICT_DIR.$file))
continue;
$cat = "Uncategorised";
$result[] = preg_replace('/^([a-zA-Z0-9\-_]+).*$/', '$1', $file);
}
echo json_encode($result);
break;
case 'get_all_lists':
$d = new Directory();
break;
case 'get_availiable_lists':
default:
echo "$do is not implemented!";
}