$isadmin = ISADMIN();
#
# Standard Testbed Header
#
PAGEHEADER("Node Type List");
#
# Get the list.
#
$query_result = DBQueryFatal("select * from node_types order by class,type");
if ($isadmin) {
    SUBPAGESTART();
    SUBMENUSTART("More Options");
    WRITESUBMENUBUTTON("Create a PC type", "editnodetype.php3?new_type=1&node_class=pc");
    WRITESUBMENUBUTTON("Create a Switch type", "editnodetype.php3?new_type=1&node_class=switch");
    WRITESUBMENUBUTTON("Create a device type", "editnodetype.php3?new_type=1&node_class=device");
    SUBMENUEND();
}
echo "<br>";
echo "Note that many types in this list are not accessible to most users";
if ($isadmin) {
    SUBPAGEEND();
}
if (mysql_num_rows($query_result)) {
    $table = array('#id' => 'nodetypelist', '#title' => "Node Type List", '#sortable' => "yes", '#headings' => array("class" => "Class", "type" => "Type", "isvirt" => "IsVirt", "isrem" => "IsRem", "isdyn" => "IsDyn", "isfed" => "IsFed", "issw" => "IsSwch", "isjail" => "IsJail", "issub" => "IsSub"));
    $rows = array();
    while ($row = mysql_fetch_array($query_result)) {
        $type = $row["type"];
        $url = "<a href='shownodetype.php3?node_type={$type}'>{$type}</a>";
        $tablerow = array("class" => $row["class"], "type" => $url, "isvirt" => $row["isvirtnode"], "isrem" => $row["isremotenode"], "isdyn" => $row["isdynamic"], "isfed" => $row["isfednode"], "issw" => $row["isswitch"], "isjail" => $row["isjailed"], "issub" => $row["issubnode"]);
        $rows[] = $tablerow;
    }
 function ShowRun($runidx)
 {
     $runidx = addslashes($runidx);
     $exptidx = $this->exptidx();
     $guid = $this->guid();
     $vers = $this->vers();
     $template = $this->template();
     $query_result = DBQueryFatal("select r.* from experiment_runs as r " . "left join experiment_template_instances as i on " . "     i.exptidx=r.exptidx " . "where r.exptidx='{$exptidx}' and r.idx='{$runidx}'");
     if (!mysql_num_rows($query_result)) {
         return;
     }
     $row = mysql_fetch_array($query_result);
     $start = $row['start_time'];
     $stop = $row['stop_time'];
     $runid = $row['runid'];
     $start_tag = $row['starting_archive_tag'];
     $end_tag = $row['ending_archive_tag'];
     $description = $row['description'];
     $hidden = $row['hidden'];
     # Run descriptions are metatdata that can be changed.
     # But use a naming convention.
     $desc_metaname = "__run_description_{$exptidx}_{$runidx}";
     $desc_metadata = $template->LookupMetadataByName($desc_metaname);
     if (!isset($stop)) {
         $stop = "&nbsp";
     }
     SUBPAGESTART();
     SUBMENUSTART("Run Options");
     WRITESUBMENUBUTTON("Export Record", CreateURL("template_export", $this, "runidx", $runidx));
     WRITESUBMENUBUTTON("Revise Record", CreateURL("record_revise", $this, "runidx", $runidx));
     if ($hidden) {
         WRITESUBMENUBUTTON("UnHide Record", CreateURL("toggle", $this, "runidx", $runidx, "type", "hiderun", "value", 0));
     } else {
         WRITESUBMENUBUTTON("Hide Record", CreateURL("toggle", $this, "runidx", $runidx, "type", "hiderun", "value", 1));
     }
     if (isset($end_tag) && $end_tag != "") {
         WRITESUBMENUBUTTON("View Archive", CreateURL("archive_view", $this, "tag", $end_tag));
     }
     SUBMENUEND();
     echo "<center>\n";
     echo "<table border=0 bgcolor=#000 color=#000 class=stealth " . " cellpadding=0 cellspacing=0>\n";
     echo "<tr valign=top>";
     echo "<td class=stealth align=center>\n";
     echo "<center>\n               <h3>Run Details</h3>\n             </center>\n";
     echo "<table align=center cellpadding=2 cellspacing=2 border=1>\n";
     ShowItem("Template", MakeLink("template", "guid={$guid}&version={$vers}", "{$guid}/{$vers}"));
     ShowItem("Instance", MakeLink("instance", "instance={$exptidx}", "{$exptidx}"));
     ShowItem("ID", $runidx);
     if ($hidden) {
         ShowItem("Hidden", "<font color=red>Yes</font>");
     }
     if ($description && $description != "") {
         $onmouseover = MakeMouseOver($description);
         if (strlen($description) > 40) {
             $description = substr($description, 0, 40) . " <b>... </b>";
         }
     } else {
         $onmouseover = "";
         $description = "Click to Add";
     }
     # If no metadata, assume its for an instance prior to modifiable
     # instance descriptions.
     if ($desc_metadata) {
         $desc_anchor = MakeAnchor(CreateURL("template_metadata", $template, $desc_metadata) . "&action=modify", $description, $onmouseover);
     } else {
         $desc_anchor = MakeAnchor(CreateURL("template_metadata", $template) . "&action=add" . "&metadata_type=run_description" . "&formfields[name]={$desc_metaname}", $description, $onmouseover);
     }
     ShowItem("Description", $desc_anchor);
     ShowItem("Started", $start);
     ShowItem("Stopped", $stop);
     ShowItem("Start Tag", $start_tag);
     ShowItem("End Tag", $end_tag);
     echo "</table>\n";
     echo "</td>\n";
     $query_result = DBQueryFatal("select * from experiment_run_bindings " . "where exptidx='{$exptidx}' and runidx='{$runidx}'");
     if (mysql_num_rows($query_result)) {
         $id = "{$exptidx}_{$runidx}_bindings";
         echo "<td align=center class=stealth> &nbsp &nbsp &nbsp </td>\n";
         echo "<td align=center class=stealth>\n";
         AddSortedTable($id);
         echo "<center>\n                   <h3>Run Bindings</h3>\n                  </center> \n                  <table id='{$id}'\n                         align=center border=1 cellpadding=5 cellspacing=2>\n";
         echo "<thead class='sort'>\n";
         echo "<tr>\n                    <th>Name</th>\n                    <th>Value</th>\n                  </tr>\n";
         echo "</thead>\n";
         while ($row = mysql_fetch_array($query_result)) {
             $name = $row['name'];
             $value = $row['value'];
             if (!isset($value)) {
                 $value = "&nbsp";
             }
             echo "<tr>\n                       <td>{$name}</td>\n                       <td>{$value}</td>\n                      </tr>\n";
         }
         echo "</table>\n";
         echo "</td>\n";
     }
     echo "</tr>\n";
     echo "</table>\n";
     $this->ShowRunAnnotation($runidx);
     echo "</center>\n";
     SUBPAGEEND();
 }