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

Switch the console log to an iframe. Just need the little bit of magic

that zaps the scrollbar to the bottom
parent 932414be
......@@ -8,8 +8,9 @@ include("defs.php3");
include("showstuff.php3");
#
# No PAGEHEADER since we spit out a Location header later. See below.
#
# Standard Testbed Header
#
PAGEHEADER("Console Log for $node_id");
#
# Only known and logged in users can do this.
......@@ -47,45 +48,27 @@ if (isset($linecount) && $linecount != "") {
if (! TBvalid_integer($linecount)) {
PAGEARGERROR("Illegal characters in linecount!");
}
$optarg = "-l $linecount";
$optarg = "&linecount=$linecount";
}
else {
$optarg = "";
}
#
# A cleanup function to keep the child from becoming a zombie.
#
$fp = 0;
function SPEWCLEANUP()
{
global $fp;
if (connection_aborted() && $fp) {
pclose($fp);
}
exit();
}
register_shutdown_function("SPEWCLEANUP");
$fp = popen("$TBSUEXEC_PATH $uid nobody webspewconlog $optarg $node_id", "r");
if (! $fp) {
USERERROR("Spew console log failed!", 1);
}
echo "<font size=+2>".
"Node <a href=shownode.php3?node_id=$node_id><b>$node_id</b></font></a>";
echo "<br /><br />\n";
header("Content-Type: text/plain; charset=us-ascii");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
flush();
while (!feof($fp)) {
$string = fgets($fp, 1024);
echo "$string";
flush();
}
pclose($fp);
$fp = 0;
echo "<center>
<iframe src=spewconlog.php3?node_id=${node_id}${optarg}
width=90% height=500 scrolling=auto frameborder=1>
Your user agent does not support frames or is currently configured
not to display frames. However, you may visit
<A href=spewconlog.php3?node_id=${node_id}${optarg}>the
log file directly.</A>
</iframe></center>\n";
#
# Standard Testbed Footer
#
PAGEFOOTER();
?>
<?php
#
# EMULAB-COPYRIGHT
# Copyright (c) 2005 University of Utah and the Flux Group.
# All rights reserved.
#
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, "")) {
if (! TBvalid_node_id($node_id)) {
PAGEARGERROR("Illegal characters in node_id!");
}
if (! TBValidNodeName($node_id)) {
USERERROR("$node_id is not a valid node name!", 1);
}
if (!$isadmin &&
!TBNodeAccessCheck($uid, $node_id, $TB_NODEACCESS_READINFO)) {
USERERROR("You do not have permission to view the console log ".
"for $node_id!", 1);
}
}
else {
PAGEARGERROR("Must specify a node ID!");
}
#
# Look for linecount argument
#
if (isset($linecount) && $linecount != "") {
if (! TBvalid_integer($linecount)) {
PAGEARGERROR("Illegal characters in linecount!");
}
$optarg = "-l $linecount";
}
else {
$optarg = "";
}
#
# A cleanup function to keep the child from becoming a zombie.
#
$fp = 0;
function SPEWCLEANUP()
{
global $fp;
if (connection_aborted() && $fp) {
pclose($fp);
}
exit();
}
register_shutdown_function("SPEWCLEANUP");
$fp = popen("$TBSUEXEC_PATH $uid nobody webspewconlog $optarg $node_id", "r");
if (! $fp) {
USERERROR("Spew console log failed!", 1);
}
header("Content-Type: text/plain; charset=us-ascii");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
flush();
while (!feof($fp)) {
$string = fgets($fp, 1024);
echo "$string";
flush();
}
pclose($fp);
$fp = 0;
?>
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