showexp.php3 4.92 KB
Newer Older
Leigh B. Stoller's avatar
Leigh B. Stoller committed
1
2
3
4
5
6
7
8
9
<html>
<head>
<title>Show Experiment Information</title>
<link rel="stylesheet" href="tbstyle.css" type="text/css">
</head>
<body>
<?php
include("defs.php3");

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

#
23
24
# Verify form arguments.
# 
25
26
27
28
29
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
30
#
31
32
33
34
35
36
37
# 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
38
#
39
# Check to make sure thats this is a valid PID/EID tuple.
Leigh B. Stoller's avatar
Leigh B. Stoller committed
40
41
#
$query_result = mysql_db_query($TBDBNAME,
42
43
44
45
46
	"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
47
}
48
$exprow = mysql_fetch_array($query_result);
Leigh B. Stoller's avatar
Leigh B. Stoller committed
49

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

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

<?php

68
69
70
71
72
73
74
$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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90

#
# 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>
91
          <td class=\"left\">$exp_pid</td>
Leigh B. Stoller's avatar
Leigh B. Stoller committed
92
93
94
      </tr>\n";

echo "<tr>
Leigh B. Stoller's avatar
Leigh B. Stoller committed
95
          <td>Experiment Head: </td>
Leigh B. Stoller's avatar
Leigh B. Stoller committed
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
          <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>
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135

<?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
136
              <td>Default Image</td>
137
138
139
140
141
142
          </tr>\n";

    #
    # I'm so proud!
    #
    $query_result = mysql_db_query($TBDBNAME,
Leigh B. Stoller's avatar
Leigh B. Stoller committed
143
144
	"SELECT nodes.node_id, nodes.type, nodes.def_boot_image_id ".
        "FROM nodes LEFT JOIN reserved ".
145
146
147
148
149
150
        "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
151
        $defid   = $row[def_boot_image_id];
152
153
154
        echo "<tr>
                  <td>$node_id</td>
                  <td>$type</td>
Leigh B. Stoller's avatar
Leigh B. Stoller committed
155
                  <td>$defid</td>
156
157
158
159
160
              </tr>\n";
    }
    echo "</table>\n";
}

Leigh B. Stoller's avatar
Leigh B. Stoller committed
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
#
# Lets dump the project information too.
# 
$query_result = mysql_db_query($TBDBNAME,
	"SELECT * FROM groups WHERE gid=\"$exp_pid\"");
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";

$gid		= $row[gid];
$grp_created	= $row[grp_created];
$grp_expires	= $row[grp_expires];
$grp_name	= $row[grp_name];
$grp_URL	= $row[grp_URL];
$grp_affil	= $row[grp_affil];
$grp_addr	= $row[grp_addr];
$grp_head_uid	= $row[grp_head_uid];
$cntrl_node	= $row[cntrl_node];

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

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

echo "<tr>
          <td>Project Head: </td>
          <td class=\"left\">$grp_head_uid</td>
      </tr>\n";

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

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

echo "</table>\n";

217
?>
Leigh B. Stoller's avatar
Leigh B. Stoller committed
218
219
220
</center>
</body>
</html>