/
getImage.php
58 lines (54 loc) · 1.91 KB
/
getImage.php
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
function download_file($file, $revalidate = False) { // $file = include path
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Transfer-Encoding: binary');
if ($revalidate) {
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
} else {
header('Date: Thu, 03 Jul 2014 00:00:00 GMT');
header('Cache-Control: max-age=31556926');
}
ob_clean();
flush();
readfile($file);
exit;
}
include("common.php.inc");
setRelease();
if (isset($_GET['type'])) {
$dbh = getDBHandle();
// depending on release, need runname or whole other sheband for paths
if ($config['release'] == "SVA1" || $config['release'] == "Y1A1") {
$sql = 'SELECT runname FROM runs WHERE expname = ?';
$stmt = $dbh->prepare($sql);
$stmt->bindParam(1, $_GET['expname'], PDO::PARAM_STR, 14);
$stmt->execute();
$res = check_or_abort($stmt);
$row = $res->fetch(PDO::FETCH_ASSOC);
if ($_GET['type'] == "fov") {
$path = str_replace("%r", $row['runname'], $config['fovpath'][$config['release']]);
$path = str_replace("%e", $_GET['expname'], $path);
download_file($path);
}
if ($_GET['type'] == "dm") {
$path = str_replace("%r", $row['runname'], $config['dmpath'][$config['release']]);
$path = str_replace("%e", $_GET['expname'], $path);
$path = str_replace("%c", sprintf("%02d", $_GET['ccd']), $path);
echo $path;
}
}
else {
if ($_GET['type'] == "dm")
echo "not available yet!";
if ($_GET['type'] == "fov")
download_file("assets/fov_not_available.png");
}
}
else {
$path = $config['fitspath'][$config['release']];
download_file($path.$_GET['name'], True);
}
?>