Commit ded94123 authored by Leigh B. Stoller's avatar Leigh B. Stoller
Browse files

Quickie set of pages for editing ImageID information, hung off the

Begin Experiment page. Rough ...
parent cedf74ed
......@@ -151,8 +151,10 @@ echo "<tr>
<li> If your NS file is using a custom OSID, you must
<a href="newosid_form.php3">create the OSID first!</a>
<li>
You can also view a <a href="showosid_list.php3"> list of OSIDs</a>
You can view a <a href="showosid_list.php3"> list of OSIDs</a>
that are available for you to use in your NS file.
<li>
You can also view a <a href="showimageid_list.php3"> list of ImageIDs.</a>
</ul>
<?php
......
<?php
include("defs.php3");
include("showstuff.php3");
#
# Standard Testbed Header
#
PAGEHEADER("Edit ImageID Information");
#
# Only known and logged in users can end experiments.
#
$uid = GETLOGIN();
LOGGEDINORDIE($uid);
$isadmin = ISADMIN($uid);
#
# Verify form arguments.
#
if (!isset($imageid) ||
strcmp($imageid, "") == 0) {
USERERROR("You must provide an ImageID.", 1);
}
#
# Check to make sure thats this is a valid Image.
#
$query_result = mysql_db_query($TBDBNAME,
"SELECT pid FROM images WHERE imageid='$imageid'");
if (mysql_num_rows($query_result) == 0) {
USERERROR("The ImageID `$imageid' is not a valid ImageID.", 1);
}
$row = mysql_fetch_array($query_result);
$pid = $row[pid];
#
# Verify that this uid is a member of the project that owns the IMAGEID.
#
if (!$isadmin && $pid) {
$query_result = mysql_db_query($TBDBNAME,
"SELECT pid FROM proj_memb WHERE uid=\"$uid\" and pid=\"$pid\"");
if (mysql_num_rows($query_result) == 0) {
USERERROR("You are not a member of the project that owns ".
"ImageID $imageid.", 1);
}
}
#
# Sanitize values and create string pieces.
#
if (isset($description) && strcmp($description, "")) {
$foo = addslashes($description);
$description = "'$foo'";
}
else {
$description = "NULL";
}
if (isset($magic) && strcmp($magic, "")) {
$foo = addslashes($magic);
$magic = "'$foo'";
}
else {
$magic = "NULL";
}
if (isset($path) && strcmp($path, "")) {
$foo = addslashes($path);
if (strcmp($path, $foo)) {
USERERROR("The path must not contain special characters!", 1);
}
$path = "'$path'";
}
else {
$path = "NULL";
}
if (isset($loadaddr) && strcmp($loadaddr, "")) {
$foo = addslashes($loadaddr);
if (strcmp($loadaddr, $foo)) {
USERERROR("The load address must not contain special characters!", 1);
}
$loadaddr = "'$loadaddr'";
}
else {
$loadaddr = "NULL";
}
#
# Create an update string
#
$query_string =
"UPDATE images SET ".
"description=$description, ".
"path=$path, ".
"magic=$magic, ".
"load_address=$loadaddr ";
$query_string = "$query_string WHERE imageid='$imageid'";
$insert_result = mysql_db_query($TBDBNAME, $query_string);
if (! $insert_result) {
$err = mysql_error();
TBERROR("Database Error changing imageid info for $inageid: $err", 1);
}
SHOWIMAGEID($imageid, 0);
#
# Edit option
#
$fooid = rawurlencode($imageid);
echo "<p><center>
Do you want to edit this ImageID?
<A href='editimageid_form.php3?imageid=$fooid'>Yes</a>
</center>\n";
#
# Standard Testbed Footer
#
PAGEFOOTER();
?>
<?php
include("defs.php3");
include("showstuff.php3");
#
# Standard Testbed Header
#
PAGEHEADER("Edit ImageID Information");
#
# Only known and logged in users can end experiments.
#
$uid = GETLOGIN();
LOGGEDINORDIE($uid);
$isadmin = ISADMIN($uid);
#
# Verify form arguments.
#
if (!isset($imageid) ||
strcmp($imageid, "") == 0) {
USERERROR("You must provide an ImageID.", 1);
}
#
# Check to make sure thats this is a valid Image.
#
$query_result = mysql_db_query($TBDBNAME,
"SELECT pid FROM images WHERE imageid='$imageid'");
if (mysql_num_rows($query_result) == 0) {
USERERROR("The ImageID `$imageid' is not a valid ImageID.", 1);
}
$row = mysql_fetch_array($query_result);
$pid = $row[pid];
#
# Verify that this uid is a member of the project that owns the IMAGEID.
#
if (!$isadmin && $pid) {
$query_result = mysql_db_query($TBDBNAME,
"SELECT pid FROM proj_memb WHERE uid=\"$uid\" and pid=\"$pid\"");
if (mysql_num_rows($query_result) == 0) {
USERERROR("You are not a member of the project that owns ".
"ImageID $imageid.", 1);
}
}
SHOWIMAGEID($imageid, 1);
#
# Standard Testbed Footer
#
PAGEFOOTER();
?>
<?php
include("defs.php3");
include("showstuff.php3");
#
# Standard Testbed Header
#
PAGEHEADER("ImageID Information");
#
# Only known and logged in users can end experiments.
#
$uid = GETLOGIN();
LOGGEDINORDIE($uid);
$isadmin = ISADMIN($uid);
#
# Verify form arguments.
#
if (!isset($imageid) ||
strcmp($imageid, "") == 0) {
USERERROR("You must provide an ImageID.", 1);
}
#
# Check to make sure thats this is a valid Image.
#
$query_result = mysql_db_query($TBDBNAME,
"SELECT pid FROM images WHERE imageid='$imageid'");
if (mysql_num_rows($query_result) == 0) {
USERERROR("The ImageID `$imageid' is not a valid ImageID.", 1);
}
$row = mysql_fetch_array($query_result);
$pid = $row[pid];
#
# Verify that this uid is a member of the project that owns the IMAGEID.
#
if (!$isadmin && $pid) {
$query_result = mysql_db_query($TBDBNAME,
"SELECT pid FROM proj_memb WHERE uid=\"$uid\" and pid=\"$pid\"");
if (mysql_num_rows($query_result) == 0) {
USERERROR("You are not a member of the project that owns ".
"ImageID $imageid.", 1);
}
}
#
# Dump record.
#
SHOWIMAGEID($imageid, 0);
#
# Edit option
#
$fooid = rawurlencode($imageid);
echo "<p><center>
Do you want to edit this ImageID?
<A href='editimageid_form.php3?imageid=$fooid'>Yes</a>
</center>\n";
#
# Standard Testbed Footer
#
PAGEFOOTER();
?>
<?php
include("defs.php3");
#
# Standard Testbed Header
#
PAGEHEADER("ImageID List");
#
#
# Only known and logged in users allowed.
#
$uid = GETLOGIN();
LOGGEDINORDIE($uid);
#
# Admin users can see all OSIDs, while normal users can only see
# ones in their projects or ones that are globally available.
#
$isadmin = ISADMIN($uid);
#
# Get the project list.
#
if ($isadmin) {
$query_result = mysql_db_query($TBDBNAME,
"SELECT * FROM images order by imageid");
}
else {
$query_result = mysql_db_query($TBDBNAME,
"select distinct i.* from images as i ".
"left join proj_memb as p on i.pid IS NULL or p.pid=i.pid ".
"where p.uid='$uid' order by i.osid");
}
if (! $query_result) {
$err = mysql_error();
TBERROR("Database Error getting user list: $err\n", 1);
}
if (mysql_num_rows($query_result) == 0) {
if ($isadmin) {
USERERROR("There are no ImageIDs!", 1);
}
else {
USERERROR("There are no ImageIDs in any of your projects!", 1);
}
}
echo "<table border=2 cellpadding=2 cellspacing=2
align='center'>\n";
echo "<tr>
<td>ImageID</td>
<td>PID</td>
<td>Description</td>
</tr>\n";
while ($row = mysql_fetch_array($query_result)) {
$imageid = $row[imageid];
$url = rawurlencode($imageid);
$descrip = $row[description];
$pid = $row[pid];
if (! $pid) {
$pid = "&nbsp";
}
echo "<tr>
<td><A href='showimageid.php3?imageid=$url'>$imageid</A></td>
<td>$pid</td>
<td>$descrip</td>\n";
echo "</tr>\n";
}
echo "</table>\n";
#
# Standard Testbed Footer
#
PAGEFOOTER();
?>
......@@ -497,6 +497,194 @@ function SHOWOSINFO($osid) {
echo "</table>\n";
}
#
# Show ImageID record.
#
function SHOWIMAGEID($imageid, $edit) {
global $TBDBNAME;
$query_result = mysql_db_query($TBDBNAME,
"SELECT * FROM images WHERE imageid='$imageid'");
$row = mysql_fetch_array($query_result);
$description = $row[description];
$loadpart = $row[loadpart];
$loadlength = $row[loadlength];
$part1_osid = $row[part1_osid];
$part2_osid = $row[part2_osid];
$part3_osid = $row[part3_osid];
$part4_osid = $row[part4_osid];
$default_osid= $row[default_osid];
$path = $row[path];
$magic = $row[magic];
$pid = $row[pid];
$loadaddr = $row[load_address];
if (!$pid)
$pid = "&nbsp";
if ($edit) {
if (!$description)
$description = "";
if (!$magic)
$magic = "";
if (!$path)
$path = "";
if (!$loadaddr)
$loadaddr = "";
}
else {
if (!$description)
$description = "&nbsp";
if (!$magic)
$magic = "&nbsp";
if (!$path)
$path = "&nbsp";
if (!$loadaddr)
$loadaddr = "&nbsp";
}
#
# Generate the table.
#
echo "<table align=center border=2 cellpadding=2 cellspacing=2>\n";
if ($edit) {
$imageid_encoded = rawurlencode($imageid);
echo "<form action='editimageid.php3?imageid=$imageid_encoded'
method=post>\n";
}
echo "<tr>
<td>ImageID: </td>
<td class=\"left\">$imageid</td>
</tr>\n";
echo "<tr>
<td>Description: </td>
<td class=left>\n";
if ($edit) {
echo "<input type=text name=description size=60
maxlength=256 value='$description'>";
}
else {
echo "$description";
}
echo " </td>
</tr>\n";
echo "<tr>
<td>Project: </td>
<td class=\"left\">$pid</td>
</tr>\n";
echo "<tr>
<td>Load Partition: </td>
<td class=\"left\">$loadpart</td>
</tr>\n";
echo "<tr>
<td>Load Length: </td>
<td class=\"left\">$loadlength</td>
</tr>\n";
if ($part1_osid) {
echo "<tr>
<td>Slice 1 OSID: </td>
<td class=\"left\">
<A href='showosinfo.php3?osid=$part1_osid'>$part1_osid</A>
</tr>\n";
}
if ($part2_osid) {
echo "<tr>
<td>Slice 2 OSID: </td>
<td class=\"left\">
<A href='showosinfo.php3?osid=$part2_osid'>$part2_osid</A>
</tr>\n";
}
if ($part3_osid) {
echo "<tr>
<td>Slice 3 OSID: </td>
<td class=\"left\">
<A href='showosinfo.php3?osid=$part3_osid'>$part3_osid</A>
</tr>\n";
}
if ($part4_osid) {
echo "<tr>
<td>Slice 4 OSID: </td>
<td class=\"left\">
<A href='showosinfo.php3?osid=$part4_osid'>$part4_osid</A>
</tr>\n";
}
if ($default_osid) {
echo "<tr>
<td>Default OSID: </td>
<td class=\"left\">
<A href='showosinfo.php3?osid=$default_osid'>
$default_osid</A>
</tr>\n";
}
echo "<tr>
<td>Path: </td>
<td class=left>\n";
if ($edit) {
echo "<input type=text name=path size=60
maxlength=256 value='$path'>";
}
else {
echo "$path";
}
echo " </td>
</tr>\n";
echo "<tr>
<td>Magic: </td>
<td class=left>\n";
if ($edit) {
echo "<input type=text name=magic size=60
maxlength=256 value='$magic'>";
}
else {
echo "$magic";
}
echo " </td>
</tr>\n";
echo "<tr>
<td>Load Address: </td>
<td class=left>\n";
if ($edit) {
echo "<input type=text name=loadaddr size=20
maxlength=256 value='$loadaddr'>";
}
else {
echo "$loadaddr";
}
echo " </td>
</tr>\n";
if ($edit) {
echo "<tr>
<td colspan=2 align=center>
<b><input type=submit value=Submit></b>
</td>
</tr>
</form>\n";
}
echo "</table>\n";
}
#
# This is an included file.
#
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment