Commit 7bc0766e authored by Leigh Stoller's avatar Leigh Stoller

Add standard PAGEFOOTER() and PAGEHEADER() to every script (getting rid

of all that duplicated goo).
Clean up all the formerror code, calling standard FORMERROR() function.
Get rid of all the inline DB specific constants, moving them to dbdefs.php3
include file.
parent 4b2c8ff5
...@@ -63,26 +63,16 @@ I could just figure out how to add a php mode to emacs ... ...@@ -63,26 +63,16 @@ I could just figure out how to add a php mode to emacs ...
* Backup links in all the pages. * Backup links in all the pages.
* Page Footers in all the pages. Last modified, link to main testbed page,
email address of the testbed, etc.
* Change to ?uid=stoller&pid=testbed style arguments in all the pages I * Change to ?uid=stoller&pid=testbed style arguments in all the pages I
have not yet fixed (that is, get rid of that regex thing at the top of have not yet fixed (that is, get rid of that regex thing at the top of
the page to find the arguments). the page to find the arguments).
* Add a Show Project Information selection page (akin to the Show
Experiments selection page), which invokes the existing showproject
page. Useful for admin types who want to see the information for a
particular project.
* Admin page to remove a project. * Admin page to remove a project.
* Admin page to remove a user. * Admin page to remove a user.
* Admin page to remove an experiment. * Admin page to remove an experiment.
* Admin page to control node settings (OS, etc.)
* Add confirm buttons in various places. I did one in the end experiments * Add confirm buttons in various places. I did one in the end experiments
page, as a simple button (so you gotta press two things). I think this page, as a simple button (so you gotta press two things). I think this
appproach is fine. appproach is fine.
...@@ -92,8 +82,6 @@ I could just figure out how to add a php mode to emacs ... ...@@ -92,8 +82,6 @@ I could just figure out how to add a php mode to emacs ...
experiment name, downcase it. Mac was going to do this, but I don't know experiment name, downcase it. Mac was going to do this, but I don't know
if he got to it. if he got to it.
* Cleanse the database of random entries that have crept in.
* Get people to go use the pages (including modify user information!). * Get people to go use the pages (including modify user information!).
* Lastly, macrofy the entire thing and get rid the damn frames! I hate * Lastly, macrofy the entire thing and get rid the damn frames! I hate
......
<html>
<head>
<title>New User</title>
<link rel="stylesheet" href="tbstyle.css" type="text/css">
</head>
<body>
<?php <?php
include("defs.php3"); include("defs.php3");
PAGEHEADER("New User");
$uid = ""; $uid = "";
if ( ereg("php3\?([[:alnum:]]+)",$REQUEST_URI,$Vals) ) { if ( ereg("php3\?([[:alnum:]]+)",$REQUEST_URI,$Vals) ) {
$uid=$Vals[1]; $uid=$Vals[1];
...@@ -130,7 +126,8 @@ else { ...@@ -130,7 +126,8 @@ else {
echo "<tr> echo "<tr>
<td>*Username:</td> <td>*Username:</td>
<td class=\"left\"> <td class=\"left\">
<input type=\"text\" name=\"uid\" size=8 maxlength=8></td> <input type=\"text\" name=\"uid\"
size=$TBDB_UIDLEN maxlength=$TBDB_UIDLEN></td>
</tr>\n"; </tr>\n";
echo "<tr> echo "<tr>
...@@ -197,12 +194,13 @@ else { ...@@ -197,12 +194,13 @@ else {
# #
# The only common field! # The only common field!
# #
# XXX Note CONSTANT size in expression: PID is 12 chars max. # Note PID max length.
# #
echo "<tr> echo "<tr>
<td>*Project:</td> <td>*Project:</td>
<td class=\"left\"> <td class=\"left\">
<input type=\"text\" name=\"pid\" size=12></td> <input type=\"text\" name=\"pid\"
size=$TBDB_PIDLEN maxlength=$TBDB_PIDLEN></td>
</tr>\n"; </tr>\n";
?> ?>
...@@ -210,9 +208,10 @@ echo "<tr> ...@@ -210,9 +208,10 @@ echo "<tr>
<b><input type="submit" value="Submit"></b></td></tr> <b><input type="submit" value="Submit"></b></td></tr>
</form> </form>
</table> </table>
</body>
</html>
<?php
#
# Standard Testbed Footer
#
PAGEFOOTER();
?>
<html>
<head>
<title>New Users Approved</title>
<link rel='stylesheet' href='tbstyle.css' type='text/css'>
</head>
<body>
<?php <?php
include("defs.php3"); include("defs.php3");
#
# Standard Testbed Header
#
PAGEHEADER("New Project Approved");
# #
# Only known and logged in users can do this. # Only known and logged in users can do this.
# #
...@@ -236,7 +235,8 @@ else { ...@@ -236,7 +235,8 @@ else {
TBERROR("Invalid approval value $approval in approveproject.php3.", 1); TBERROR("Invalid approval value $approval in approveproject.php3.", 1);
} }
#
# Standard Testbed Footer
#
PAGEFOOTER();
?> ?>
</body>
</html>
<html>
<head>
<title>New Project Approval</title>
<link rel='stylesheet' href='tbstyle.css' type='text/css'>
</head>
<body>
<?php <?php
include("defs.php3"); include("defs.php3");
#
# Standard Testbed Header
#
PAGEHEADER("New Project Approval");
# #
# Only known and logged in users can do this. # Only known and logged in users can do this.
# #
...@@ -107,6 +106,9 @@ echo "<tr> ...@@ -107,6 +106,9 @@ echo "<tr>
</tr> </tr>
</form> </form>
</table>\n"; </table>\n";
#
# Standard Testbed Footer
#
PAGEFOOTER();
?> ?>
</body>
</html>
<html>
<head>
<title>New Project Approval List</title>
<link rel='stylesheet' href='tbstyle.css' type='text/css'>
</head>
<body>
<?php <?php
include("defs.php3"); include("defs.php3");
#
# Standard Testbed Header
#
PAGEHEADER("New Project Approval List");
# #
# Only known and logged in users can do this. uid came in with the URI. # Only known and logged in users can do this. uid came in with the URI.
# #
...@@ -104,7 +103,10 @@ while ($projectrow = mysql_fetch_array($query_result)) { ...@@ -104,7 +103,10 @@ while ($projectrow = mysql_fetch_array($query_result)) {
</tr>\n"; </tr>\n";
} }
echo "</table>\n"; echo "</table>\n";
#
# Standard Testbed Footer
#
PAGEFOOTER();
?> ?>
</body>
</html>
<html>
<head>
<title>New Users Approved</title>
<link rel='stylesheet' href='tbstyle.css' type='text/css'>
</head>
<body>
<?php <?php
include("defs.php3"); include("defs.php3");
#
# Standard Testbed Header
#
PAGEHEADER("New Users Approved");
# #
# Only known and logged in users can be verified. # Only known and logged in users can be verified.
# #
...@@ -228,7 +227,8 @@ while (list ($header, $value) = each ($HTTP_POST_VARS)) { ...@@ -228,7 +227,8 @@ while (list ($header, $value) = each ($HTTP_POST_VARS)) {
TBERROR("Invalid approval value $approval in approveuser.php3.", 1); TBERROR("Invalid approval value $approval in approveuser.php3.", 1);
} }
#
# Standard Testbed Footer
#
PAGEFOOTER();
?> ?>
</body>
</html>
<html>
<head>
<title>New User Approval</title>
<link rel='stylesheet' href='tbstyle.css' type='text/css'>
</head>
<body>
<?php <?php
include("defs.php3"); include("defs.php3");
#
# Standard Testbed Header
#
PAGEHEADER("New Users Approval Form");
# #
# Only known and logged in users can be verified. # Only known and logged in users can be verified.
# #
...@@ -166,7 +165,10 @@ echo "<tr> ...@@ -166,7 +165,10 @@ echo "<tr>
<b><input type='submit' value='Submit' name='OK'></td> <b><input type='submit' value='Submit' name='OK'></td>
</tr> </tr>
</form> </form>
</table> </table>\n";
</body>
</html>\n"; #
# Standard Testbed Footer
#
PAGEFOOTER();
?> ?>
<html>
<head>
<title>Begin an Experiment</title>
<link rel="stylesheet" href="tbstyle.css" type="text/css">
</head>
<body>
<?php <?php
include("defs.php3"); include("defs.php3");
#
# Standard Testbed Header
#
PAGEHEADER("Begin an Experiment Form");
# #
# Only known and logged in users can begin experiments. # Only known and logged in users can begin experiments.
# #
...@@ -76,12 +75,12 @@ echo " </td> ...@@ -76,12 +75,12 @@ echo " </td>
# #
# Experiment ID and Long Name: # Experiment ID and Long Name:
# #
# XXX Note CONSTANT in expression! # Note DB max length.
# #
echo "<tr> echo "<tr>
<td>*Name (no blanks):</td> <td>*Name (no blanks):</td>
<td><input type=\"text\" name=\"exp_id\" <td><input type=\"text\" name=\"exp_id\"
size=\"19\" maxlength=\"19\"> size=$TBDB_EIDLEN maxlength=$TBDB_EIDLEN>
</td> </td>
</tr>\n"; </tr>\n";
...@@ -144,5 +143,10 @@ echo "<tr> ...@@ -144,5 +143,10 @@ echo "<tr>
</tr> </tr>
</form> </form>
</table> </table>
</body>
</html> <?php
#
# Standard Testbed Footer
#
PAGEFOOTER();
?>
<html>
<head>
<title>Utah Testbed Begin Experiment</title>
<link rel='stylesheet' href='tbstyle.css' type='text/css'>
</head>
<body>
<?php <?php
include("defs.php3"); include("defs.php3");
#
# Standard Testbed Header
#
PAGEHEADER("Begin an Experiment");
$mydebug = 0; $mydebug = 0;
# #
# First off, sanity check the form to make sure all the required fields # First off, sanity check the form to make sure all the required fields
# were provided. I do this on a per field basis so that we can be # were provided. I do this on a per field basis so that we can be
# informative. Be sure to correlate these checks with any changes made to # informative. Be sure to correlate these checks with any changes made to
# the project form. Note that this sequence of statements results in # the project form.
# only the last bad field being displayed, but thats okay. The user will
# eventually figure out that fields marked with * mean something!
# #
$formerror="No Error";
if (!isset($uid) || if (!isset($uid) ||
strcmp($uid, "") == 0) { strcmp($uid, "") == 0) {
$formerror = "Username"; FORMERROR("Username");
} }
if (!isset($exp_pid) || if (!isset($exp_pid) ||
strcmp($exp_pid, "") == 0) { strcmp($exp_pid, "") == 0) {
$formerror = "Select Project"; FORMERROR("Select Project");
} }
if (!isset($exp_id) || if (!isset($exp_id) ||
strcmp($exp_id, "") == 0) { strcmp($exp_id, "") == 0) {
$formerror = "Experiment Name (short)"; FORMERROR("Experiment Name (short)");
} }
if (!isset($exp_name) || if (!isset($exp_name) ||
strcmp($exp_name, "") == 0) { strcmp($exp_name, "") == 0) {
$formerror = "Experiment Name (long)"; FORMERROR("Experiment Name (long)");
} }
if (!isset($exp_created) || if (!isset($exp_created) ||
strcmp($exp_created, "") == 0) { strcmp($exp_created, "") == 0) {
$formerror = "Experiment Created"; FORMERROR("Experiment Created");
}
if ($formerror != "No Error") {
USERERROR("Missing field; Please go back and fill out ".
"the \"$formerror\" field!", 1);
} }
# #
...@@ -49,14 +41,9 @@ if ($formerror != "No Error") { ...@@ -49,14 +41,9 @@ if ($formerror != "No Error") {
LOGGEDINORDIE($uid); LOGGEDINORDIE($uid);
# #
# Current policy is to prefix the EID with the PID. Make sure it is not # Database limits
# too long for the database. PID is 12, and the max is 32, so the user
# cannot have provided one more than 19, since other parts of the system
# may concatenate them together with a hyphen.
# #
# XXX Note CONSTANT in expression! if (strlen($exp_id) > $TBDB_EIDLEN) {
#
if (strlen($exp_id) > 19) {
USERERROR("The experiment name \"$exp_id\" is too long! ". USERERROR("The experiment name \"$exp_id\" is too long! ".
"Please select another.", 1); "Please select another.", 1);
} }
...@@ -304,6 +291,8 @@ mail($TBMAIL_WWW, "TESTBED: New Experiment Created", ...@@ -304,6 +291,8 @@ mail($TBMAIL_WWW, "TESTBED: New Experiment Created",
"Errors-To: $TBMAIL_WWW"); "Errors-To: $TBMAIL_WWW");
} }
#
# Standard Testbed Footer
#
PAGEFOOTER();
?> ?>
</body>
</html>
<?php
#
# Database Constants
#
$TBDBNAME = "tbdb";
$TBDB_UIDLEN = 8;
$TBDB_PIDLEN = 12;
#
# Current policy is to prefix the EID with the PID. Make sure it is not
# too long for the database. PID is 12, and the max is 32, so the user
# cannot have provided an EID more than 19, since other parts of the system
# may concatenate them together with a hyphen.
#
$TBDB_EIDLEN = 19;
?>
...@@ -13,7 +13,6 @@ $TBMAIL_APPROVE = "Testbed Approval <testbed-approval@flux.cs.utah.edu>"; ...@@ -13,7 +13,6 @@ $TBMAIL_APPROVE = "Testbed Approval <testbed-approval@flux.cs.utah.edu>";
#$TBMAIL_WWW = "Testbed WWW <stoller@fast.cs.utah.edu>"; #$TBMAIL_WWW = "Testbed WWW <stoller@fast.cs.utah.edu>";
#$TBMAIL_APPROVE = "Testbed Approval <stoller@fast.cs.utah.edu>"; #$TBMAIL_APPROVE = "Testbed Approval <stoller@fast.cs.utah.edu>";
$TBDBNAME = "tbdb";
$TBDIR = "/usr/testbed/"; $TBDIR = "/usr/testbed/";
$TBWWW_DIR = "$TBDIR"."www/"; $TBWWW_DIR = "$TBDIR"."www/";
$TBBIN_DIR = "$TBDIR"."bin/"; $TBBIN_DIR = "$TBDIR"."bin/";
...@@ -30,6 +29,11 @@ $TBAUTHTIMEOUT = 10800; ...@@ -30,6 +29,11 @@ $TBAUTHTIMEOUT = 10800;
$TBAUTHDOMAIN = ".emulab.net"; $TBAUTHDOMAIN = ".emulab.net";
#$TBAUTHDOMAIN = "golden-gw.ballmoss.com"; #$TBAUTHDOMAIN = "golden-gw.ballmoss.com";
#
# Database constants and the like.
#
include("dbdefs.php3");
# #
# Generate the KEY from a name # Generate the KEY from a name
# #
...@@ -90,6 +94,14 @@ function USERERROR($message, $death) { ...@@ -90,6 +94,14 @@ function USERERROR($message, $death) {
} }
} }
#
# A form error.
#
function FORMERROR($field) {
USERERROR("Missing field; ".
"Please go back and fill out the \"$field\" field!", 1);
}
# #
# Is this user an admin type? # Is this user an admin type?
# #
...@@ -110,6 +122,40 @@ function ISADMIN($uid) { ...@@ -110,6 +122,40 @@ function ISADMIN($uid) {
return $admin; return $admin;
} }
#
# Spit out a vanilla page header.
#
function PAGEHEADER($title) {
echo "<html>
<head>
<title>$title</title>
<link rel=\"stylesheet\" href=\"tbstyle.css\" type=\"text/css\">
</head>
<body>\n";
}
#
# Spit out a vanilla page footer.
#
function PAGEFOOTER() {
global $TBBASE;
echo "<br><hr>
<center>[<a href=\"$TBBASE\">Network Testbed Home</a>]</center>
<center>
[<a href=\"http://www.cs.utah.edu/flux/\">Flux Research Group</a>]
[<a href=\"http://www.cs.utah.edu/\">School of Computing</a>]
[<a href=\"http://www.utah.edu/\">University of Utah</a>]
</center>
<p align=right>
<font size=-2>
Problems? Contact
<a href=\"mailto:testbed-ops@flux.cs.utah.edu\">
Testbed Operations (testbed-ops@flux.cs.utah.edu)</a>
</body>
</html>\n";
}
# #
# Beware empty spaces (cookies)! # Beware empty spaces (cookies)!
# #
......
<html>
<head>
<title>Terminate Experiment</title>
<link rel="stylesheet" href="tbstyle.css" type="text/css">
</head>
<body>
<?php <?php
include("defs.php3"); include("defs.php3");
#
# Standard Testbed Header
#
PAGEHEADER("Terminate Experiment");
# #
# Only known and logged in users can end experiments. # Only known and logged in users can end experiments.
# #
...@@ -172,9 +171,11 @@ if (! $query_result) { ...@@ -172,9 +171,11 @@ if (! $query_result) {
echo "<center><br>"; echo "<center><br>";
echo "<h2>Experiment '$exp_eid' in project '$exp_pid' Terminated!<br>"; echo "<h2>Experiment '$exp_eid' in project '$exp_pid' Terminated!<br>";
echo "</h2></center><br>"; echo "</h2>";
echo "</center>\n";
#
# Standard Testbed Footer
#
PAGEFOOTER();
?> ?>
</center>
</body>
</html>
<html>
<head>
<title>Terminate Experiment</title>
<link rel="stylesheet" href="tbstyle.css" type="text/css">
</head>
<body>
<?php <?php
include("defs.php3"); include("defs.php3");
#
# Standard Testbed Header
#
PAGEHEADER("Terminate Experiment Form");
# #
# Only known and logged in users can end experiments. # Only known and logged in users can end experiments.
# #
...@@ -105,5 +104,10 @@ echo " </td> ...@@ -105,5 +104,10 @@ echo " </td>
</form> </form>
</table> </table>
</center> </center>
</body>
</html> <?php
#
# Standard Testbed Footer
#
PAGEFOOTER();
?>
<html>
<head>
<title>Modify User Information</title>
<link rel="stylesheet" href="tbstyle.css" type="text/css">
</head>
<body>
<?php <?php
include("defs.php3"); include("defs.php3");
#
# Standard Testbed Header
#
PAGEHEADER("Modify User Information Form");
# #
# Only known and logged in users can modify info. # Only known and logged in users can modify info.
# #
...@@ -136,5 +135,10 @@ echo "<tr> ...@@ -136,5 +135,10 @@ echo "<tr>
</form> </form>
</table> </table>
</center> </center>
</body>
</html> <?php
#
# Standard Testbed Footer
#
PAGEFOOTER();
?>
<html>
<head>
<title>Utah Testbed Modify User Information</title>
<link rel='stylesheet' href='tbstyle.css' type='text/css'>
</head>
<body>
<?php <?php
include("defs.php3"); include("defs.php3");
#
# Standard Testbed Header
#
PAGEHEADER("Modify User Information");
# #
# First off, sanity check the form to make sure all the required fields # First off, sanity check the form to make sure all the required fields
# were provided. I do this on a per field basis so that we can be # were provided. I do this on a per field basis so that we can be
...@@ -15,39 +14,33 @@ include("defs.php3"); ...@@ -15,39 +14,33 @@ include("defs.php3");
# only the last bad field being displayed, but thats okay. The user will # only the last bad field being displayed, but thats okay. The user will
# eventually figure out that fields marked with * mean something! # eventually figure out that fields marked with * mean something!
# #
$formerror="No Error";
if (!isset($uid) || if (!isset($uid) ||
strcmp($uid, "") == 0) { strcmp($uid, "") == 0) {
$formerror = "Username"; FORMERROR("Username");
} }
if (!isset($usr_name) || if (!isset($usr_name) ||
strcmp($usr_name, "") == 0) { strcmp($usr_name, "") == 0) {
$formerror = "Full Name"; FORMERROR("Full Name");
} }
if (!isset($usr_email) || if (!isset($usr_email) ||
strcmp($usr_email, "") == 0) { strcmp($usr_email, "") == 0) {
$formerror = "Email Address"; FORMERROR("Email Address");