2
// $Id: katrin.php 8100 2010-07-15 12:39:05Z s_voec01 $
3
// Author: Sebastian Voecking <sebastian.voecking@uni-muenster.de>
7
ADEI::RequireClass('KDBConstants', TRUE);
8
ADEI::RequireClass('KDBFileIdentifier', TRUE);
9
ADEI::RequireClass('KDBPhp', TRUE);
10
ADEI::RequireClass('KDBRunIdentifier', TRUE);
12
function PrintXml($out, $xml)
14
header("Content-type: text/xml");
15
header("Cache-Control: no-cache, must-revalidate");
16
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
27
function GetContentType($filename)
29
if (substr($filename, -4) == ".png") {
32
else if (substr($filename, -4) == ".txt") {
35
else if (substr($filename, -4) == ".xml") {
36
return "application/xml";
38
else if (substr($filename, -4) == ".svg") {
39
return "image/svg+xml";
42
return "application/octet-stream";
46
function PrintFile($path, $download)
48
if (!file_exists($path))
49
throw new ADEIException("File $path does not exist");
51
$mimetype = GetContentType($path);
52
$basename = basename($path);
54
header("Content-type: $mimetype");
56
header("Content-disposition: attachment; filename=\"$basename\"");
60
function PrintError($error)
62
$xml = "<?xml version=\"1.0\"?>\n<result>\n";
63
$xml .= " <Error>$error</Error>\n</result>";
74
$target = $req->GetProp('target', NULL);
75
$run = new KDBRunIdentifier($req->GetProp('kdb_run', ''));
76
$xslt = $req->GetProp('xslt');
77
$page = $req->GetProp('kdb_page', 1);
78
$date = $req->GetProp('kdb_date', '');
79
$search = urldecode($req->GetProp('kdb_search', ''));
80
$parameters = urldecode($req->GetProp('kdb_parameters', ''));
83
$temp_file = tempnam(sys_get_temp_dir(), 'adei_katrin.');
84
$out = @fopen($temp_file, 'w');
86
throw new ADEIException("I'm not able to create temporary file \"%s\"",
93
$interval = $req->CreateInterval();
94
$start = $interval->GetWindowStart();
95
$end = $interval->GetWindowEnd();
97
PrintXml($out, $kdb->ListRuns($start, $end));
101
if ($run->IsValid()) {
102
PrintXml($out, $kdb->GetRun($_GET['run']));
105
throw new ADEIException("No run specified");
110
if (!$run->IsValid()) {
111
PrintXml($out, $kdb->ListLastRuns($date, $search, $parameters,
116
$subruns = $req->GetProp("kdb_subruns", false);
117
PrintXml($out, $kdb->GetRunDescription($run, $subruns));
121
$type = KDBConstants::FileTypeValue($req->GetProp('kdb_type'));
122
$file = new KDBFileIdentifier($run, $type);
123
$file->SetName($req->GetProp('kdb_name', ''));
125
$hardware = $req->GetProp('kdb_hardware', NULL);
126
if (isset($hardware)) {
127
$file->SetHardware(KDBConstants::HardwareValue($hardware));
130
PrintFile($kdb->GetAbsolutePath($file), $download);
134
PrintXml($out, $kdb->GetDates($search));
138
if (isset($target)) {
139
$message = "Unknown target ($target) is specified";
140
throw new ADEIException($message);
143
throw new ADEIException('The target is not specified');
147
catch (ADEIException $e) {
148
PrintError($e->getMessage());
152
echo $ADEI->TransformXML($xslt, $temp_file);