|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
// This file is part of BOINC. |
|
4
|
|
|
// https://boinc.berkeley.edu |
|
5
|
|
|
// Copyright (C) 2024 University of California |
|
6
|
|
|
// |
|
7
|
|
|
// BOINC is free software; you can redistribute it and/or modify it |
|
8
|
|
|
// under the terms of the GNU Lesser General Public License |
|
9
|
|
|
// as published by the Free Software Foundation, |
|
10
|
|
|
// either version 3 of the License, or (at your option) any later version. |
|
11
|
|
|
// |
|
12
|
|
|
// BOINC is distributed in the hope that it will be useful, |
|
13
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
15
|
|
|
// See the GNU Lesser General Public License for more details. |
|
16
|
|
|
// |
|
17
|
|
|
// You should have received a copy of the GNU Lesser General Public License |
|
18
|
|
|
// along with BOINC. If not, see <http://www.gnu.org/licenses/>. |
|
19
|
|
|
|
|
20
|
|
|
// get output files, individually or zipped groups |
|
21
|
|
|
// Assumes the layout used by sample_assimilator.cpp and sample_assimilate.py: |
|
22
|
|
|
// <project>/results/ |
|
23
|
|
|
// <batchid>/ (0 if not in a batch) |
|
24
|
|
|
// |
|
25
|
|
|
|
|
26
|
|
|
require_once("../inc/util.inc"); |
|
27
|
|
|
|
|
28
|
|
|
// show or download a single output file, |
|
29
|
|
|
// identified by result ID and file index |
|
30
|
|
|
// |
|
31
|
|
|
function get_file() { |
|
32
|
|
|
$path = get_str('path'); |
|
33
|
|
|
if (strstr($path, '.')) error_page('bad path'); |
|
34
|
|
|
$path = "../../$path"; |
|
35
|
|
|
|
|
36
|
|
|
$download = get_str('download', true); |
|
37
|
|
|
if ($download) { |
|
38
|
|
|
do_download($path); |
|
39
|
|
|
} else { |
|
40
|
|
|
readfile($path); |
|
41
|
|
|
} |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
// download a zip of the given directory |
|
45
|
|
|
// |
|
46
|
|
|
function get_batch() { |
|
47
|
|
|
$batch_id = get_str('batch_id'); |
|
48
|
|
|
$dir = "../../results/$batch_id"; |
|
49
|
|
|
$name = "batch_$batch_id.zip"; |
|
50
|
|
|
$cmd = "cd $dir; rm -f $name; zip $name *"; |
|
51
|
|
|
system($cmd); |
|
52
|
|
|
do_download("$dir/$name"); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
$action = get_str('action'); |
|
56
|
|
|
switch ($action) { |
|
57
|
|
|
case 'get_file': get_file(); break; |
|
58
|
|
|
case 'get_batch': get_batch(); break; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
?> |
|
62
|
|
|
|