shownsfile.php3 2.56 KB
Newer Older
1
2
3
4
5
6
7
<?php
include("defs.php3");
include("showstuff.php3");

#
# Standard Testbed Header
#
Jay Lepreau's avatar
Jay Lepreau committed
8
PAGEHEADER("Visualization, NS File, and Details");
9
10
11
12
13
14
15
16
17
18

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

$isadmin = ISADMIN($uid);

#
Leigh B. Stoller's avatar
Leigh B. Stoller committed
19
# Verify page arguments.
20
# 
Leigh B. Stoller's avatar
Leigh B. Stoller committed
21
22
23
24
25
26
27
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);
28
29
30
}

#
Leigh B. Stoller's avatar
Leigh B. Stoller committed
31
# Check to make sure this is a valid PID/EID tuple.
32
#
Leigh B. Stoller's avatar
Leigh B. Stoller committed
33
34
35
$query_result =
    DBQueryFatal("SELECT * FROM experiments WHERE ".
		 "eid='$eid' and pid='$pid'");
36
if (mysql_num_rows($query_result) == 0) {
Leigh B. Stoller's avatar
Leigh B. Stoller committed
37
38
  USERERROR("The experiment $eid is not a valid experiment ".
            "in project $pid.", 1);
39
40
}

41
42
$expstate = TBExptState($pid, $eid);

43
44
45
46
47
#
# Verify that this uid is a member of the project for the experiment
# being displayed.
#
if (!$isadmin) {
Leigh B. Stoller's avatar
Leigh B. Stoller committed
48
49
50
    $query_result =
	DBQueryFatal("SELECT pid FROM group_membership ".
		     "WHERE uid='$uid' and pid='$pid'");
51
    if (mysql_num_rows($query_result) == 0) {
Leigh B. Stoller's avatar
Leigh B. Stoller committed
52
        USERERROR("You are not a member of Project $pid!", 1);
53
54
55
    }
}

56
57
58
59
60
61
62
63
64
65
66
if ($showevents) {
    echo "<b><a href='shownsfile.php3?pid=$pid&eid=$eid'>
                Hide Event List</a>
          </b><br><br>\n";
}
elseif (TBEventCount($pid, $eid)) {
    echo "<b><a href='shownsfile.php3?pid=$pid&eid=$eid&showevents=1'>
                Show Event List</a>
          </b><br><br>\n";
}

67
68
69
70
71
72
73
74
75
76
77
78
#
# Spit out an image that refers to a php script. That script will run and
# send back the GIF image contents.
#
if (strcmp($expstate, $TB_EXPTSTATE_ACTIVE) == 0 ||
    strcmp($expstate, $TB_EXPTSTATE_SWAPPED) == 0) {
    echo "<br>
          <center>
            <img src='top2image.php3?pid=$pid&eid=$eid' align=center>
          </center>\n";
}

Leigh B. Stoller's avatar
Leigh B. Stoller committed
79
80
81
82
$query_result =
    DBQueryFatal("SELECT nsfile from nsfiles where pid='$pid' and eid='$eid'");
if (mysql_num_rows($query_result) == 0) {
    USERERROR("There is no stored NS file for $pid/$eid", 1);
83
84
85
86
}
$row    = mysql_fetch_array($query_result);
$nsfile = $row[nsfile];

87
88
echo "<br>
      <h3>NS File:</h3>\n";
89
echo "<XMP>$nsfile</XMP>\n";
Leigh B. Stoller's avatar
Leigh B. Stoller committed
90
flush();
91

92
echo "<br>
93
94
95
      <h3>
       Experiment Details:
      </h3>\n";
96
97
98
99

$output = array();
$retval = 0;

100
if ($showevents) {
101
102
103
104
105
106
107
    $flags = "-v";
}
else {
    $flags = "-b";
}

$result = exec("$TBSUEXEC_PATH nobody flux webreport $flags $pid $eid",
108
109
110
 	       $output, $retval);

echo "<XMP>\n";
Leigh B. Stoller's avatar
Leigh B. Stoller committed
111
for ($i = 0; $i < count($output); $i++) {
112
113
114
115
    echo "$output[$i]\n";
}
echo "</XMP>\n";

116
117
118
119
120
#
# Standard Testbed Footer
# 
PAGEFOOTER();
?>