Commit c937bb0c authored by Leigh Stoller's avatar Leigh Stoller

Add new admin only menu option to free a node from the node

information page. Got tired of having to past the them all by hand
between windows. Only admins can do this.

Also, add subpage menu stuff to make the page look nicer.
parent 59a8b372
<?php
include("defs.php3");
include("showstuff.php3");
#
# No PAGEHEADER since we spit out a Location header later. See below.
#
#
# Only known and logged in users can do this.
#
$uid = GETLOGIN();
LOGGEDINORDIE($uid);
$isadmin = ISADMIN($uid);
#
# Check to make sure a valid nodeid
#
if (!isset($node_id) || !strcmp($node_id, "") || !TBValidNodeName($node_id)) {
USERERROR("The node '$node_id' is not a valid node!", 1);
}
#
# Only admin users can do this.
#
if (! $isadmin) {
USERERROR("Only admininstrators can free nodes from the web interface!",
1);
}
#
# Has to be reserved of course!
#
$query_result =
DBQueryFatal("select pid,eid from reserved where node_id='$node_id'");
if (mysql_num_rows($query_result) == 0) {
USERERROR("$node_id is not currently reserved!", 1);
}
$row = mysql_fetch_array($query_result);
$pid = $row[pid];
$eid = $row[eid];
#
# We run this twice. The first time we are checking for a confirmation
# by putting up a form. The next time through the confirmation will be
# set. Or, the user can hit the cancel button, in which case we should
# probably redirect the browser back up a level.
#
if ($canceled) {
PAGEHEADER("Free Node");
echo "<center><h3><br>
Operation canceled!
</h3></center>\n";
PAGEFOOTER();
return;
}
if (!$confirmed) {
PAGEHEADER("Free Node");
echo "<center><h2><br>
Are you <b>REALLY</b>
sure you want to free node '$node_id?'
</h2>\n";
SHOWNODE($node_id);
echo "<form action='freenode.php3?node_id=$node_id' method=post>";
echo "<b><input type=submit name=confirmed value=Confirm></b>\n";
echo "<b><input type=submit name=canceled value=Cancel></b>\n";
echo "</form>\n";
echo "</center>\n";
PAGEFOOTER();
return;
}
#
# Pass it off to the script.
#
SUEXEC($uid, "nobody", "webnfree $pid $eid $node_id", 1);
#
# And send an audit message.
#
TBUserInfo($uid, $uid_name, $uid_email);
TBMAIL($TBMAIL_AUDIT,
"Node Free: $node_id",
"$node_id was deallocated via the web interface by $uid ($uid_name).\n",
"From: $uid_name <$uid_email>\n".
"Errors-To: $TBMAIL_WWW");
#
# Spit out a redirect so that the history does not include a post
# in it. The back button skips over the post and to the form.
# See above for conclusion.
#
header("Location: shownode.php3?node_id=$node_id");
?>
......@@ -41,25 +41,29 @@ if (! $isadmin) {
}
}
#
# Dump record.
#
SHOWNODE($node_id);
SUBPAGESTART();
SUBMENUSTART("Node Options");
#
# Edit option
#
echo "<br><center>
<A href='nodecontrol_form.php3?node_id=$node_id'>
Edit this the node info?</a>
</center>\n";
WRITESUBMENUBUTTON("Edit node info",
"nodecontrol_form.php3?node_id=$node_id");
if ($isadmin) {
echo "<br><p>
<center>
<A href='shownodelog.php3?node_id=$node_id'>Node Log</a>
</center>\n";
WRITESUBMENUBUTTON("Access Node Log",
"shownodelog.php3?node_id=$node_id");
WRITESUBMENUBUTTON("Free Node",
"freenode.php3?node_id=$node_id");
}
SUBMENUEND();
#
# Dump record.
#
SHOWNODE($node_id);
SUBPAGEEND();
#
# Standard Testbed Footer
......
Markdown is supported
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