Subversion Repositories oidplus

Rev

Details | Last modification | View Log | RSS feed

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