spewlogfile.php3 1.37 KB
Newer Older
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
<?php
include("defs.php3");
include("showstuff.php3");

#
# Standard Testbed Header
#
#PAGEHEADER("Watch Experiment Log");

#
# Only known and logged in users can end experiments.
#
$uid = GETLOGIN();
LOGGEDINORDIE($uid);

$isadmin = ISADMIN($uid);

#
# Verify page arguments.
# 
if (!isset($pid) ||
    strcmp($pid, "") == 0) {
    USERERROR("You must provide a Project ID.", 1);
}
if (!isset($eid) ||
    strcmp($eid, "") == 0) {
    USERERROR("You must provide an Experiment ID.", 1);
}

#
# Check to make sure this is a valid PID/EID tuple.

if (! TBValidExperiment($pid, $eid)) {
    USERERROR("The experiment $pid/$eid is not a valid experiment!", 1);
}

#
# Verify permission.
#
if (! TBExptAccessCheck($uid, $pid, $eid, $TB_EXPT_READINFO)) {
    USERERROR("You do not have permission to view the log for $pid/$eid!", 1);
}

#
# Check for a logfile. This file is transient, so it could be gone by
# the time we get to reading it.
#
48
49
50
51
52
$query_result =
    DBQueryFatal("select logfile from experiments ".
		 "where pid='$pid' and eid='$eid' and logfile is not null");

if (mysql_num_rows($query_result) == 0) {
53
54
55
56
57
58
59
60
61
62
63
64
65
    USERERROR("Experiment $pid/$eid is no longer in transition!", 1);
}

header("Content-Type: text/plain");

$retval = 0;
$result = system("$TBSUEXEC_PATH $uid $pid spewlogfile $pid $eid", $retval);

if ($retval) {
    USERERROR("Experiment $pid/$eid is no longer in transition!", 1);
}

?>