showexp.php3 5.07 KB
Newer Older
Leigh B. Stoller's avatar
Leigh B. Stoller committed
1
2
3
<?php
include("defs.php3");

4
5
6
7
8
#
# Standard Testbed Header
#
PAGEHEADER("Show Experiment Information");

9
10
11
#
# Only known and logged in users can end experiments.
#
Leigh B. Stoller's avatar
Leigh B. Stoller committed
12
13
$uid = "";
if ( ereg("php3\?([[:alnum:]]+)",$REQUEST_URI,$Vals) ) {
14
15
    $uid=$Vals[1];
    addslashes($uid);
Leigh B. Stoller's avatar
Leigh B. Stoller committed
16
} else {
17
    unset($uid);
Leigh B. Stoller's avatar
Leigh B. Stoller committed
18
}
19
LOGGEDINORDIE($uid);
Leigh B. Stoller's avatar
Leigh B. Stoller committed
20

21
22
$isadmin = ISADMIN($uid);

Leigh B. Stoller's avatar
Leigh B. Stoller committed
23
#
24
25
# Verify form arguments.
# 
26
27
28
29
30
if (!isset($exp_pideid) ||
    strcmp($exp_pideid, "") == 0) {
    USERERROR("You must provide an experiment ID.", 1);
}

Leigh B. Stoller's avatar
Leigh B. Stoller committed
31
#
32
33
34
35
36
37
38
# First get the project (PID) from the form parameter, which came in
# as <pid>$$<eid>.
#
$exp_eid = strstr($exp_pideid, "$$");
$exp_eid = substr($exp_eid, 2);
$exp_pid = substr($exp_pideid, 0, strpos($exp_pideid, "$$", 0));

Leigh B. Stoller's avatar
Leigh B. Stoller committed
39
#
40
# Check to make sure thats this is a valid PID/EID tuple.
Leigh B. Stoller's avatar
Leigh B. Stoller committed
41
42
#
$query_result = mysql_db_query($TBDBNAME,
43
44
45
46
47
	"SELECT * FROM experiments WHERE ".
        "eid=\"$exp_eid\" and pid=\"$exp_pid\"");
if (mysql_num_rows($query_result) == 0) {
  USERERROR("The experiment $exp_eid is not a valid experiment ".
            "in project $exp_pid.", 1);
Leigh B. Stoller's avatar
Leigh B. Stoller committed
48
}
49
$exprow = mysql_fetch_array($query_result);
Leigh B. Stoller's avatar
Leigh B. Stoller committed
50

51
52
53
54
#
# Verify that this uid is a member of the project for the experiment
# being displayed.
#
55
56
if (!$isadmin) {
    $query_result = mysql_db_query($TBDBNAME,
57
	"SELECT pid FROM proj_memb WHERE uid=\"$uid\" and pid=\"$exp_pid\"");
58
59
60
61
    if (mysql_num_rows($query_result) == 0) {
        USERERROR("You are not a member of Project $exp_pid for ".
                  "Experiment: $exp_eid.", 1);
    }
Leigh B. Stoller's avatar
Leigh B. Stoller committed
62
63
64
65
66
67
68
69
70
}
?>

<center>
<h1>Experiment Information</h1>
<table align="center" border="1">

<?php

71
72
73
74
75
76
77
$exp_expires = $exprow[expt_expires];
$exp_name    = $exprow[expt_name];
$exp_created = $exprow[expt_created];
$exp_start   = $exprow[expt_start];
$exp_end     = $exprow[expt_end];
$exp_created = $exprow[expt_created];
$exp_head    = $exprow[expt_head_uid];
Leigh B. Stoller's avatar
Leigh B. Stoller committed
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93

#
# Generate the table.
# 
echo "<tr>
          <td>Name: </td>
          <td class=\"left\">$exp_eid</td>
      </tr>\n";

echo "<tr>
          <td>Long Name: </td>
          <td class=\"left\">$exp_name</td>
      </tr>\n";

echo "<tr>
          <td>Project: </td>
94
          <td class=\"left\">$exp_pid</td>
Leigh B. Stoller's avatar
Leigh B. Stoller committed
95
96
97
      </tr>\n";

echo "<tr>
Leigh B. Stoller's avatar
Leigh B. Stoller committed
98
          <td>Experiment Head: </td>
Leigh B. Stoller's avatar
Leigh B. Stoller committed
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
          <td class=\"left\">$exp_head</td>
      </tr>\n";

echo "<tr>
          <td>Created: </td>
          <td class=\"left\">$exp_created</td>
      </tr>\n";

echo "<tr>
          <td>Starts: </td>
          <td class=\"left\">$exp_start</td>
      </tr>\n";

echo "<tr>
          <td>Ends: </td>
          <td class=\"left\">$exp_end</td>
      </tr>\n";

echo "<tr>
          <td>Expires: </td>
          <td class=\"left\">$exp_expires</td>
      </tr>\n";

?>
</table>
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138

<?php

#
# Suck out the node information.
# 
$reserved_result = mysql_db_query($TBDBNAME,
	"SELECT * FROM reserved WHERE ".
        "eid=\"$exp_eid\" and pid=\"$exp_pid\"");
if (mysql_num_rows($reserved_result)) {
    echo "<h3>Reserved Nodes</h3>
          <table align=center border=1>
          <tr>
              <td>Node ID</td>
              <td>Node Type</td>
Leigh B. Stoller's avatar
Leigh B. Stoller committed
139
              <td>Default Image</td>
140
141
142
143
144
145
          </tr>\n";

    #
    # I'm so proud!
    #
    $query_result = mysql_db_query($TBDBNAME,
Leigh B. Stoller's avatar
Leigh B. Stoller committed
146
147
	"SELECT nodes.node_id, nodes.type, nodes.def_boot_image_id ".
        "FROM nodes LEFT JOIN reserved ".
148
149
150
151
152
153
        "ON nodes.node_id=reserved.node_id ".
        "WHERE reserved.eid=\"$exp_eid\" and reserved.pid=\"$exp_pid\"");

    while ($row = mysql_fetch_array($query_result)) {
        $node_id = $row[node_id];
        $type    = $row[type];
Leigh B. Stoller's avatar
Leigh B. Stoller committed
154
        $defid   = $row[def_boot_image_id];
155
156
157
        echo "<tr>
                  <td>$node_id</td>
                  <td>$type</td>
Leigh B. Stoller's avatar
Leigh B. Stoller committed
158
                  <td>$defid</td>
159
160
161
162
163
              </tr>\n";
    }
    echo "</table>\n";
}

Leigh B. Stoller's avatar
Leigh B. Stoller committed
164
165
166
167
#
# Lets dump the project information too.
# 
$query_result = mysql_db_query($TBDBNAME,
168
	"SELECT * FROM projects WHERE pid=\"$exp_pid\"");
Leigh B. Stoller's avatar
Leigh B. Stoller committed
169
170
171
172
173
174
175
176
177
178
179
if (! $query_result) {
    $err = mysql_error();
    TBERROR("Database Error getting info for project $exp_pid: $err\n", 1);
}
$row = mysql_fetch_array($query_result);

echo "<center>
      <h3>Project Information</h3>
      </center>
      <table align=center border=1>\n";

180
181
182
183
184
185
186
187
$proj_created	= $row[created];
$proj_expires	= $row[expires];
$proj_name	= $row[name];
$proj_URL	= $row[URL];
$proj_affil	= $row[affil];
$proj_addr	= $row[addr];
$proj_head_uid	= $row[head_uid];
$control_node	= $row[control_node];
Leigh B. Stoller's avatar
Leigh B. Stoller committed
188
189
190
191
192
193

#
# Generate the table.
# 
echo "<tr>
          <td>Name: </td>
194
          <td class=\"left\">$exp_pid</td>
Leigh B. Stoller's avatar
Leigh B. Stoller committed
195
196
197
198
      </tr>\n";

echo "<tr>
          <td>Long Name: </td>
199
          <td class=\"left\">$proj_name</td>
Leigh B. Stoller's avatar
Leigh B. Stoller committed
200
201
202
203
      </tr>\n";

echo "<tr>
          <td>Project Head: </td>
204
          <td class=\"left\">$proj_head_uid</td>
Leigh B. Stoller's avatar
Leigh B. Stoller committed
205
206
      </tr>\n";

207
208
209
210
211
212
echo "<tr>
          <td>URL: </td>
          <td class=\"left\">
              <A href='$proj_URL'>$proj_URL</A></td>
      </tr>\n";

Leigh B. Stoller's avatar
Leigh B. Stoller committed
213
214
echo "<tr>
          <td>Created: </td>
215
          <td class=\"left\">$proj_created</td>
Leigh B. Stoller's avatar
Leigh B. Stoller committed
216
217
218
219
      </tr>\n";

echo "<tr>
          <td>Expires: </td>
220
          <td class=\"left\">$proj_expires</td>
Leigh B. Stoller's avatar
Leigh B. Stoller committed
221
222
      </tr>\n";

223
224
echo "</table>
      </center>\n";
Leigh B. Stoller's avatar
Leigh B. Stoller committed
225

226
227
228
229
#
# Standard Testbed Footer
# 
PAGEFOOTER();
230
?>