showexpstats.php3 2.24 KB
Newer Older
1 2 3 4 5 6 7 8 9
<?php
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2003 University of Utah and the Flux Group.
# All rights reserved.
#
include("defs.php3");
include("showstuff.php3");

10 11 12 13 14
#
# This page needs more work to make user friendly and flexible.
# Its a hack job at the moment.
# 

15 16 17 18 19 20 21 22 23 24 25 26 27
#
# Standard Testbed Header
#
PAGEHEADER("Show Experiment Information");

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

#
28 29
# Right now we show just the last N records entered, unless the user
# requested a specific record. 
30
#
31
if (isset($record) && strcmp($record, "")) {
32 33 34 35
    $wclause = "";
    if (! $isadmin) {
	$wclause = "and s.creator='$uid'";
    }
36
    $query_result =
37 38 39 40 41
	DBQueryFatal("select s.*,r.* from experiment_stats as s ".
		     "left join experiment_resources as r on ".
		     " r.exptidx=s.exptidx ".
		     "where s.exptidx=$record $wclause ".
		     "order by r.idx desc");
42

43 44 45 46 47
    if (mysql_num_rows($query_result) == 0) {
	USERERROR("No such experiment record $record in the system!", 1);
    }
}
else {
48 49 50 51
    $wclause = "";
    if (! $isadmin) {
	$wclause = "where s.creator='$uid'";
    }
52
    $query_result =
53 54 55 56 57
	DBQueryFatal("select s.*,r.* from experiment_stats as s ".
		     "left join experiment_resources as r on ".
		     " r.exptidx=s.exptidx ".
		     "$wclause ".
		     "order by s.exptidx desc,r.idx asc limit 200");
58 59 60 61

    if (mysql_num_rows($query_result) == 0) {
	USERERROR("No experiment records in the system!", 1);
    }
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
}

#
# Use first row to get the column headers (no pretty printing yet).
# 
$row = mysql_fetch_assoc($query_result);

echo "<table align=center border=1>\n";
echo "<tr>\n";
foreach($row as $key => $value) {
    $key = str_replace("_", " ", $key);
    
    echo "<th><font size=-1>$key</font></th>\n";
}
echo "</tr>\n";

mysql_data_seek($query_result, 0);

while ($row = mysql_fetch_assoc($query_result)) {
81 82
    $rsrcidx = $row[idx];
    
83 84
    echo "<tr>\n";
    foreach($row as $key => $value) {
85 86 87 88 89 90 91 92
	if ($key == "thumbnail") {
	    echo "<td nowrap>
                     <a href='showthumb.php3?idx=$rsrcidx'>Thumbnail</a>
                  </td>\n";
	}
	else {
	    echo "<td nowrap>$value</td>\n";
	}
93 94 95 96 97 98 99 100 101 102
    }
    echo "</tr>\n";
}
echo "</table>\n";

#
# Standard Testbed Footer
# 
PAGEFOOTER();
?>