/adei/trunk

To get this branch, use:
bzr branch http://darksoft.org/webbzr/adei/trunk
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
<?php
if (strtolower($_REQUEST['encoding']=='text')) {
    header("Content-type: text/plain");
    $text = true;
} else {
    header("Content-type: application/json");
    $text = false;
}

header("Cache-Control: no-cache, must-revalidate");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");

$req = new REQUEST();

try {
    switch($_GET['target']) {
      case "get":
        $flags = 0;
        if (isset($_GET['auto_restart'])) $flags |= (filter_var($_GET['auto_restart'], FILTER_VALIDATE_BOOLEAN)?SCHEDULER::AUTO_RESTART:0);
        
        if (isset($_GET['activity'])) $activity = $_GET['activity'];
        else $activity = "cache";
        if (isset($_GET['mode'])) $mode = $_GET['mode'];
        else $mode = false;     // Universal mode, scheduler should decide
            
        $sched = new SCHEDULER($req, $activity, $mode, $flags);
        $item = $sched->GetProps();
        if ($text) {
            if ($item) {
	        $source = "db_server={$item['db_server']}";
	        if (isset($item['db_name'])) $source .= "&db_name={$item['db_name']}";
	        if (isset($item['db_group'])) $source .= "&db_group={$item['db_group']}";
	        
	        $args = "-execute -source $source";
	        if ($item["sched_mode"] == SCHEDULER::MODE_ARCHIVE) $args .= " -archives";
	        echo "$source $args\n";
            } else {
                // No output means no data
            }
        } else {
            echo json_encode($item);
        }
      break;
      default:
	throw new ADEIException(translate("Unknown scheduler service (%s) is requested", $_GET['target']));
    }
} catch (ADEIException $ae) {
    $ae->logInfo(NULL, $req);
    $error = $ae->getMessage();
}

if ($error) {
    if ($text) echo "Error: $error\n";
    else echo json_encode(array("error" => $error));
}


?>