bzr branch
http://darksoft.org/webbzr/adei/trunk
465
by Suren A. Chilingaryan
Initial release of scheduling service |
1 |
<?php
|
469
by Suren A. Chilingaryan
Support text encoding in sched service |
2 |
if (strtolower($_REQUEST['encoding']=='text')) { |
3 |
header("Content-type: text/plain"); |
|
4 |
$text = true; |
|
471
by Suren A. Chilingaryan
Scheduler improvements |
5 |
} else { |
469
by Suren A. Chilingaryan
Support text encoding in sched service |
6 |
header("Content-type: application/json"); |
7 |
$text = false; |
|
8 |
}
|
|
9 |
||
465
by Suren A. Chilingaryan
Initial release of scheduling service |
10 |
header("Cache-Control: no-cache, must-revalidate"); |
11 |
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); |
|
12 |
||
13 |
$req = new REQUEST(); |
|
14 |
||
15 |
try { |
|
16 |
switch($_GET['target']) { |
|
17 |
case "get": |
|
18 |
$flags = 0; |
|
471
by Suren A. Chilingaryan
Scheduler improvements |
19 |
if (isset($_GET['auto_restart'])) $flags |= (filter_var($_GET['auto_restart'], FILTER_VALIDATE_BOOLEAN)?SCHEDULER::AUTO_RESTART:0); |
20 |
||
21 |
if (isset($_GET['activity'])) $activity = $_GET['activity']; |
|
22 |
else $activity = "cache"; |
|
23 |
if (isset($_GET['mode'])) $mode = $_GET['mode']; |
|
24 |
else $mode = false; // Universal mode, scheduler should decide |
|
465
by Suren A. Chilingaryan
Initial release of scheduling service |
25 |
|
471
by Suren A. Chilingaryan
Scheduler improvements |
26 |
$sched = new SCHEDULER($req, $activity, $mode, $flags); |
469
by Suren A. Chilingaryan
Support text encoding in sched service |
27 |
$item = $sched->GetProps(); |
28 |
if ($text) { |
|
471
by Suren A. Chilingaryan
Scheduler improvements |
29 |
if ($item) { |
30 |
$source = "db_server={$item['db_server']}"; |
|
31 |
if (isset($item['db_name'])) $source .= "&db_name={$item['db_name']}"; |
|
32 |
if (isset($item['db_group'])) $source .= "&db_group={$item['db_group']}"; |
|
33 |
||
34 |
$args = "-execute -source $source"; |
|
35 |
if ($item["sched_mode"] == SCHEDULER::MODE_ARCHIVE) $args .= " -archives"; |
|
474
by Suren A. Chilingaryan
Fixes |
36 |
echo "$source $args\n"; |
471
by Suren A. Chilingaryan
Scheduler improvements |
37 |
} else { |
38 |
// No output means no data
|
|
39 |
}
|
|
469
by Suren A. Chilingaryan
Support text encoding in sched service |
40 |
} else { |
41 |
echo json_encode($item); |
|
42 |
}
|
|
465
by Suren A. Chilingaryan
Initial release of scheduling service |
43 |
break; |
44 |
default: |
|
45 |
throw new ADEIException(translate("Unknown scheduler service (%s) is requested", $_GET['target'])); |
|
46 |
}
|
|
47 |
} catch (ADEIException $ae) { |
|
48 |
$ae->logInfo(NULL, $req); |
|
49 |
$error = $ae->getMessage(); |
|
50 |
}
|
|
51 |
||
52 |
if ($error) { |
|
471
by Suren A. Chilingaryan
Scheduler improvements |
53 |
if ($text) echo "Error: $error\n"; |
469
by Suren A. Chilingaryan
Support text encoding in sched service |
54 |
else echo json_encode(array("error" => $error)); |
465
by Suren A. Chilingaryan
Initial release of scheduling service |
55 |
}
|
56 |
||
57 |
||
58 |
?>
|