shownsfile.php3 6.03 KB
Newer Older
1
<?php
Leigh B. Stoller's avatar
Leigh B. Stoller committed
2 3
#
# EMULAB-COPYRIGHT
4
# Copyright (c) 2000-2004 University of Utah and the Flux Group.
Leigh B. Stoller's avatar
Leigh B. Stoller committed
5 6
# All rights reserved.
#
7 8 9 10 11 12
include("defs.php3");
include("showstuff.php3");

#
# Standard Testbed Header
#
Chad Barb's avatar
Chad Barb committed
13 14 15 16 17 18 19 20 21
if (!isset($justns)) {
    $justns = 0;
}

if (!$justns) {
    PAGEHEADER("Visualization, NS File, and Details");
}


22 23 24 25 26 27 28 29 30 31

#
# 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
32
# Verify page arguments.
33
# 
Leigh B. Stoller's avatar
Leigh B. Stoller committed
34 35 36 37 38 39 40
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);
41 42
}

Chad Barb's avatar
Chad Barb committed
43 44 45 46 47
# if they dont exist, or are non-numeric, use defaults.
# note: one can use is_numeric in php4 instead of ereg.
if (!isset($zoom) || !ereg("^[0-9]{1,50}.?[0-9]{0,50}$", $zoom)) { $zoom = 1; }
if (!isset($detail) || !ereg("^[0-9]{1,50}$", $detail)) { $detail = 0; }
 
48
#
Leigh B. Stoller's avatar
Leigh B. Stoller committed
49
# Check to make sure this is a valid PID/EID tuple.
50
#
Leigh B. Stoller's avatar
Leigh B. Stoller committed
51 52 53
$query_result =
    DBQueryFatal("SELECT * FROM experiments WHERE ".
		 "eid='$eid' and pid='$pid'");
54
if (mysql_num_rows($query_result) == 0) {
Leigh B. Stoller's avatar
Leigh B. Stoller committed
55 56
  USERERROR("The experiment $eid is not a valid experiment ".
            "in project $pid.", 1);
57 58
}

59 60
$expstate = TBExptState($pid, $eid);

61 62 63 64 65
#
# 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
66 67 68
    $query_result =
	DBQueryFatal("SELECT pid FROM group_membership ".
		     "WHERE uid='$uid' and pid='$pid'");
69
    if (mysql_num_rows($query_result) == 0) {
Leigh B. Stoller's avatar
Leigh B. Stoller committed
70
        USERERROR("You are not a member of Project $pid!", 1);
71 72 73
    }
}

Chad Barb's avatar
Chad Barb committed
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
#
# if it is netbuild wanting an NS to modify, send that along
# (For now, as a disgusting hack, send node positioning along, too.)
#
if ($justns) {
    $query_result =
	DBQueryFatal("SELECT nsfile from nsfiles where pid='$pid' and eid='$eid'");
    if (mysql_num_rows($query_result)) {
	$row    = mysql_fetch_array($query_result);
	$nsfile = stripslashes($row[nsfile]);
	
	echo "$nsfile\n";
	# flush();

	$query_result = 
	    DBQueryFatal("SELECT vname, x, y FROM vis_nodes where pid='$pid' and eid='$eid'");

	while ($row = mysql_fetch_array($query_result)) {
	    $name = $row[vname];
	    $x = $row[x];
	    $y = $row[y];
	    echo "tb-set-vis-position \$$name $x $y\n";
	}
	flush();
    }
    else {
	echo "No stored NS file for $pid/$eid\n";
    }    

    return;
}

106 107 108 109 110
echo "<font size=+2><b>".
     "<a href='showproject.php3?pid=$pid'>$pid</a>/".
     "<a href='showexp.php3?pid=$pid&eid=$eid'>$eid</a>".
     "</b></font>\n";
echo "<br />\n";
111
#echo "<br />\n";
112

113 114 115 116 117 118 119 120 121 122 123
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";
}

124 125 126 127
#
# Spit out an image that refers to a php script. That script will run and
# send back the GIF image contents.
#
128 129
if (strcmp($expstate, $TB_EXPTSTATE_NEW) &&
    strcmp($expstate, $TB_EXPTSTATE_PRERUN)) {
130 131 132
    echo "<table cellpadding='0' cellspacing='0' border='0' class='stealth'>
	    <tr><td class='stealth' width='32'>&nbsp;</td>
            <td class='stealth'><center>
Leigh B. Stoller's avatar
Leigh B. Stoller committed
133
		<img src='top2image.php3?pid=$pid&eid=$eid&zoom=$zoom&detail=$detail' align=center>
Chad Barb's avatar
Chad Barb committed
134
	    <h5>
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181
	      zoom: ";
    if ($zoom == 1.00) { 
	echo "<b>100%</b> "; 
    } else { 
	echo "<a href='shownsfile.php3?pid=$pid&eid=$eid&zoom=1.00&detail=$detail'>100%</a> ";
    }
    if ($zoom == 1.12) { 
	echo "<b>112%</b> "; 
    } else { 
	echo "<a href='shownsfile.php3?pid=$pid&eid=$eid&zoom=1.12&detail=$detail'>112%</a> ";
    }
    if ($zoom == 1.25) { 
	echo "<b>125%</b> "; 
    } else { 
	echo "<a href='shownsfile.php3?pid=$pid&eid=$eid&zoom=1.25&detail=$detail'>125%</a> ";
    }
    if ($zoom == 1.50) { 
	echo "<b>150%</b> "; 
    } else { 
	echo "<a href='shownsfile.php3?pid=$pid&eid=$eid&zoom=1.50&detail=$detail'>150%</a> ";
    }
    if ($zoom == 1.75) { 
	echo "<b>175%</b> "; 
    } else { 
	echo "<a href='shownsfile.php3?pid=$pid&eid=$eid&zoom=1.75&detail=$detail'>175%</a> ";
    }
    if ($zoom == 2.00) { 
	echo "<b>200%</b> "; 
    } else { 
	echo "<a href='shownsfile.php3?pid=$pid&eid=$eid&zoom=2.00&detail=$detail'>200%</a> ";
    }
    if ($zoom == 2.50) { 
	echo "<b>250%</b> "; 
    } else { 
	echo "<a href='shownsfile.php3?pid=$pid&eid=$eid&zoom=2.50&detail=$detail'>250%</a> ";
    }
    if ($zoom == 3.00) { 
	echo "<b>300%</b> "; 
    } else { 
	echo "<a href='shownsfile.php3?pid=$pid&eid=$eid&zoom=3.00&detail=$detail'>300%</a> ";
    }
    if ($zoom == 4.00) { 
	echo "<b>400%</b> "; 
    } else { 
	echo "<a href='shownsfile.php3?pid=$pid&eid=$eid&zoom=4.00&detail=$detail'>400%</a> ";
    }
    echo "<br>detail: ";
Chad Barb's avatar
Chad Barb committed
182
    if ($detail == 0) {
183
	if ($zoom < 1.75) {
184
      	    echo "<a href='shownsfile.php3?pid=$pid&eid=$eid&zoom=1.75&detail=1'>high</a> <b>low</b>";
Chad Barb's avatar
Chad Barb committed
185
	} else {
186
    	    echo "<a href='shownsfile.php3?pid=$pid&eid=$eid&zoom=$zoom&detail=1'>high</a> <b>low</b>";
Chad Barb's avatar
Chad Barb committed
187 188
	}
    } else {
189
    	echo "<b>high</b> <a href='shownsfile.php3?pid=$pid&eid=$eid&zoom=$zoom&detail=0'>low</a>";
Chad Barb's avatar
Chad Barb committed
190
    }
191
    echo "  </h5></center></td></tr></table>";
192 193
}

194
echo "<br>
Leigh B. Stoller's avatar
Leigh B. Stoller committed
195
      <a href=spitnsdata.php3?pid=$pid&eid=$eid><h3>NS File:</h3></a>\n";
196

Leigh B. Stoller's avatar
Leigh B. Stoller committed
197 198
$query_result =
    DBQueryFatal("SELECT nsfile from nsfiles where pid='$pid' and eid='$eid'");
199 200
if (mysql_num_rows($query_result)) {
    $row    = mysql_fetch_array($query_result);
Leigh B. Stoller's avatar
Leigh B. Stoller committed
201
    $nsfile = stripslashes($row[nsfile]);
202

203 204 205 206 207 208
    echo "<XMP>$nsfile</XMP>\n";
    flush();
}
else {
    echo "There is no stored NS file for $pid/$eid\n";
}
209

210
echo "<br>
211
      <h3>
212
         Experiment Details:
213
      </h3>\n";
214 215 216 217

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

218
if ($showevents) {
219 220 221
    $flags = "-v";
}
else {
Mike Hibler's avatar
Mike Hibler committed
222 223
    # Show event summary and firewall info.
    $flags = "-b -e -f";
224 225
}

226
$result = exec("$TBSUEXEC_PATH $uid $TBADMINGROUP webreport $flags $pid $eid",
227 228 229
 	       $output, $retval);

echo "<XMP>\n";
Leigh B. Stoller's avatar
Leigh B. Stoller committed
230
for ($i = 0; $i < count($output); $i++) {
231 232 233 234
    echo "$output[$i]\n";
}
echo "</XMP>\n";

235 236 237 238 239
#
# Standard Testbed Footer
# 
PAGEFOOTER();
?>