Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
226 | daniel-mar | 1 | #!/usr/bin/php |
2 | <?php |
||
3 | |||
4 | #xxx TODO: debug |
||
5 | #$argc++; |
||
6 | #$argv[] = 'oidplus:!listRoots'; |
||
7 | |||
8 | |||
9 | # TODO: try to find out namespace! |
||
10 | |||
11 | |||
12 | if (php_sapi_name() != 'cli') { |
||
13 | header('HTTP/1.1 400 Bad Request'); |
||
14 | echo "Error: This script can only run in CLI mode\n"; # TODO: +STDERR? |
||
15 | exit(2); |
||
16 | } |
||
17 | |||
18 | include_once __DIR__ . '/includes/oid_plus.inc.php'; |
||
19 | |||
20 | header('Content-Type:text/plain'); |
||
21 | |||
22 | $db = new OIDPlus(__DIR__ . '/db/local.conf', true); |
||
23 | |||
24 | $title = 'OID+ web interface [BETA]'; |
||
25 | |||
26 | try { |
||
27 | $db->addDir(__DIR__ . '/db'); |
||
28 | } catch (VolcanoException $e) { |
||
29 | header('HTTP/1.1 500 Internal Server Error'); |
||
30 | $title = 'Database error'; |
||
31 | $msg = $e->getMessage(); |
||
32 | $msg = str_replace(__DIR__, '.', $msg); |
||
33 | echo "$title\n\n"; |
||
34 | echo "An internal error occurred while reading the Volcano database. Please contact the administrator and try again later.\n\n"; # TODO: +STDERR? |
||
35 | echo "Error message:\n\n"; |
||
36 | echo "$msg\n"; |
||
37 | exit; |
||
38 | } |
||
39 | |||
40 | if ($argc != 2) { |
||
41 | echo "Syntax: $argv[0] <query>\n"; |
||
42 | exit(2); |
||
43 | } |
||
44 | |||
45 | # echo "$title\n\n"; |
||
46 | |||
47 | array_shift($argv); |
||
48 | $args = implode(' ', $argv); |
||
49 | |||
50 | $db->query($args); |