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 ...
* 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
have not yet fixed (that is, get rid of that regex thing at the top of
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 user.
* 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
page, as a simple button (so you gotta press two things). I think this
appproach is fine.
......@@ -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
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!).
* 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
include("defs.php3");
PAGEHEADER("New User");
$uid = "";
if ( ereg("php3\?([[:alnum:]]+)",$REQUEST_URI,$Vals) ) {
$uid=$Vals[1];
......@@ -130,7 +126,8 @@ else {
echo "<tr>
<td>*Username:</td>
<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";
echo "<tr>
......@@ -197,12 +194,13 @@ else {
#
# The only common field!
#
# XXX Note CONSTANT size in expression: PID is 12 chars max.
# Note PID max length.
#
echo "<tr>
<td>*Project:</td>
<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";
?>
......@@ -210,9 +208,10 @@ echo "<tr>
<b><input type="submit" value="Submit"></b></td></tr>
</form>
</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
include("defs.php3");
#
# Standard Testbed Header
#
PAGEHEADER("New Project Approved");
#
# Only known and logged in users can do this.
#
......@@ -236,7 +235,8 @@ else {
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
include("defs.php3");
#
# Standard Testbed Header
#
PAGEHEADER("New Project Approval");
#
# Only known and logged in users can do this.
#
......@@ -107,6 +106,9 @@ echo "<tr>
</tr>
</form>
</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
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.
#
......@@ -104,7 +103,10 @@ while ($projectrow = mysql_fetch_array($query_result)) {
</tr>\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
include("defs.php3");
#
# Standard Testbed Header
#
PAGEHEADER("New Users Approved");
#
# Only known and logged in users can be verified.
#
......@@ -228,7 +227,8 @@ while (list ($header, $value) = each ($HTTP_POST_VARS)) {
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
include("defs.php3");
#
# Standard Testbed Header
#
PAGEHEADER("New Users Approval Form");
#
# Only known and logged in users can be verified.
#
......@@ -166,7 +165,10 @@ echo "<tr>
<b><input type='submit' value='Submit' name='OK'></td>
</tr>
</form>
</table>
</body>
</html>\n";
</table>\n";
#
# Standard Testbed Footer
#
PAGEFOOTER();
?>
<html>
<head>
<title>Begin an Experiment</title>
<link rel="stylesheet" href="tbstyle.css" type="text/css">
</head>
<body>
<?php
include("defs.php3");
#
# Standard Testbed Header
#
PAGEHEADER("Begin an Experiment Form");
#
# Only known and logged in users can begin experiments.
#
......@@ -76,12 +75,12 @@ echo " </td>
#
# Experiment ID and Long Name:
#
# XXX Note CONSTANT in expression!
# Note DB max length.
#
echo "<tr>
<td>*Name (no blanks):</td>
<td><input type=\"text\" name=\"exp_id\"
size=\"19\" maxlength=\"19\">
size=$TBDB_EIDLEN maxlength=$TBDB_EIDLEN>
</td>
</tr>\n";
......@@ -144,5 +143,10 @@ echo "<tr>
</tr>
</form>
</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
include("defs.php3");
#
# Standard Testbed Header
#
PAGEHEADER("Begin an Experiment");
$mydebug = 0;
#
# 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
# informative. Be sure to correlate these checks with any changes made to
# the project form. Note that this sequence of statements results in
# only the last bad field being displayed, but thats okay. The user will
# eventually figure out that fields marked with * mean something!
# the project form.
#
$formerror="No Error";
if (!isset($uid) ||
strcmp($uid, "") == 0) {
$formerror = "Username";
FORMERROR("Username");
}
if (!isset($exp_pid) ||
strcmp($exp_pid, "") == 0) {
$formerror = "Select Project";
FORMERROR("Select Project");
}
if (!isset($exp_id) ||
strcmp($exp_id, "") == 0) {
$formerror = "Experiment Name (short)";
FORMERROR("Experiment Name (short)");
}
if (!isset($exp_name) ||
strcmp($exp_name, "") == 0) {
$formerror = "Experiment Name (long)";
FORMERROR("Experiment Name (long)");
}
if (!isset($exp_created) ||
strcmp($exp_created, "") == 0) {
$formerror = "Experiment Created";
}
if ($formerror != "No Error") {
USERERROR("Missing field; Please go back and fill out ".
"the \"$formerror\" field!", 1);
FORMERROR("Experiment Created");
}
#
......@@ -49,14 +41,9 @@ if ($formerror != "No Error") {
LOGGEDINORDIE($uid);
#
# 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 one more than 19, since other parts of the system
# may concatenate them together with a hyphen.
# Database limits
#
# XXX Note CONSTANT in expression!
#
if (strlen($exp_id) > 19) {
if (strlen($exp_id) > $TBDB_EIDLEN) {
USERERROR("The experiment name \"$exp_id\" is too long! ".
"Please select another.", 1);
}
......@@ -304,6 +291,8 @@ mail($TBMAIL_WWW, "TESTBED: New Experiment Created",
"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>";
#$TBMAIL_WWW = "Testbed WWW <stoller@fast.cs.utah.edu>";
#$TBMAIL_APPROVE = "Testbed Approval <stoller@fast.cs.utah.edu>";
$TBDBNAME = "tbdb";
$TBDIR = "/usr/testbed/";
$TBWWW_DIR = "$TBDIR"."www/";
$TBBIN_DIR = "$TBDIR"."bin/";
......@@ -30,6 +29,11 @@ $TBAUTHTIMEOUT = 10800;
$TBAUTHDOMAIN = ".emulab.net";
#$TBAUTHDOMAIN = "golden-gw.ballmoss.com";
#
# Database constants and the like.
#
include("dbdefs.php3");
#
# Generate the KEY from a name
#
......@@ -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?
#
......@@ -110,6 +122,40 @@ function ISADMIN($uid) {
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)!
#
......
<html>
<head>
<title>Terminate Experiment</title>
<link rel="stylesheet" href="tbstyle.css" type="text/css">
</head>
<body>
<?php
include("defs.php3");
#
# Standard Testbed Header
#
PAGEHEADER("Terminate Experiment");
#
# Only known and logged in users can end experiments.
#
......@@ -172,9 +171,11 @@ if (! $query_result) {
echo "<center><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
include("defs.php3");
#
# Standard Testbed Header
#
PAGEHEADER("Terminate Experiment Form");
#
# Only known and logged in users can end experiments.
#
......@@ -105,5 +104,10 @@ echo " </td>
</form>
</table>
</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
include("defs.php3");
#
# Standard Testbed Header
#
PAGEHEADER("Modify User Information Form");
#
# Only known and logged in users can modify info.
#
......@@ -136,5 +135,10 @@ echo "<tr>
</form>
</table>
</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
include("defs.php3");
#
# Standard Testbed Header
#
PAGEHEADER("Modify User Information");
#
# 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
......@@ -15,39 +14,33 @@ include("defs.php3");
# 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) ||
strcmp($uid, "") == 0) {
$formerror = "Username";
FORMERROR("Username");
}
if (!isset($usr_name) ||
strcmp($usr_name, "") == 0) {
$formerror = "Full Name";
FORMERROR("Full Name");
}
if (!isset($usr_email) ||
strcmp($usr_email, "") == 0) {
$formerror = "Email Address";
FORMERROR("Email Address");
}
if (!isset($usr_addr) ||
strcmp($usr_addr, "") == 0) {
$formerror = "Mailing Address";
FORMERROR("Mailing Address");
}
if (!isset($usr_phone) ||
strcmp($usr_phone, "") == 0) {
$formerror = "Phone #";
FORMERROR("Phone #");
}
if (!isset($usr_title) ||
strcmp($usr_title, "") == 0) {
$formerror = "Title/Position";
FORMERROR("Title/Position");
}
if (!isset($usr_affil) ||
strcmp($usr_affil, "") == 0) {
$formerror = "Institutional Affiliation";
}
if ($formerror != "No Error") {
USERERROR("Missing field; Please go back and fill out ".
"the \"$formerror\" field!", 1);
FORMERROR("Institutional Affiliation");
}
#
......@@ -121,7 +114,12 @@ if (! $insert_result) {
<center>
<br>
<br>
<h3>User information successfully modified!<h3><p>
<h3>User information successfully modified!</h3><p>
</center>
</body>
</html>
<?php
#
# Standard Testbed Footer
#
PAGEFOOTER();
?>
<html>
<head>
<title>Utah Testbed Project Request</title>
<link rel='stylesheet' href='tbstyle.css' type='text/css'>
</head>
<body>
<?php
include("defs.php3");
#
# Standard Testbed Header
#
PAGEHEADER("Start a New Project");
#
# 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
# informative. Be sure to correlate these checks with any changes made to
# the project form. Note that this sequence of statements results in
# only the last bad field being displayed, but thats okay. The user will
# eventually figure out that fields marked with * mean something!
# the project form.
#
$formerror="No Error";
if (!isset($pid) ||
strcmp($pid, "ucb-omcast") == 0) {
$formerror = "Name";
FORMERROR("Name");
}
if (!isset($proj_head_uid) ||
strcmp($proj_head_uid, "") == 0) {
$formerror = "Username";
FORMERROR("Username");
}
if (!isset($proj_name) ||
strcmp($proj_name, "UCB Overlay Multicast") == 0) {
$formerror = "Long Name";
FORMERROR("Long Name");
}
if (!isset($proj_members) ||
strcmp($proj_members, "") == 0) {
$formerror = "Estimated #of Project Members";
FORMERROR("Estimated #of Project Members");
}
if (!isset($proj_pcs) ||
strcmp($proj_pcs, "") == 0) {
$formerror = "Estimated #of PCs";
FORMERROR("Estimated #of PCs");
}
if (!isset($proj_sharks) ||
strcmp($proj_sharks, "") == 0) {
$formerror = "Estimated #of Sharks";
FORMERROR("Estimated #of Sharks");
}
if (!isset($proj_why) ||
strcmp($proj_why, "") == 0) {
$formerror = "Please describe your project";
FORMERROR("Please describe your project");
}
if (!isset($usr_name) ||
strcmp($usr_name, "") == 0) {
$formerror = "Full Name";
FORMERROR("Full Name");
}
if (!isset($proj_URL) ||
strcmp($proj_URL, "http://www.cs.berkeley.edu/netgrp/omcast/") == 0) {
$formerror = "Project URL";
FORMERROR("Project URL");
}
if (!isset($usr_email) ||
strcmp($usr_email, "") == 0) {
$formerror = "Email Address";
FORMERROR("Email Address");
}
if (!isset($usr_addr) ||
strcmp($usr_addr, "") == 0) {
$formerror = "Postal Address";
FORMERROR("Postal Address");
}
if (!isset($usr_affil) ||
strcmp($usr_affil, "UCB Networks Group") == 0) {
$formerror = "Institutional Afilliation";
FORMERROR("Institutional Afilliation");
}
if (!isset($usr_title) ||
strcmp($usr_title, "Professor Emeritus") == 0) {
$formerror = "Title/Position";
FORMERROR("Title/Position");
}
if (!isset($usr_phones) ||
strcmp($usr_phones, "") == 0) {
$formerror = "Phone #";
}
if ($formerror != "No Error") {
USERERROR("Missing field; ".
"Please go back and fill out the \"$formerror\" field!", 1);
FORMERROR("Phone #");
}
#
# Database limit; PID must be 12 chars or less.
# UID must be 8 chars or less.
# Check database length limits.
#
# XXX Note CONSTANT in expression!
#
if (strlen($pid) > 12) {
if (strlen($pid) > $TBDB_PIDLEN) {
USERERROR("The project name \"$pid\" is too long! ".
"Please select another.", 1);
}
if (strlen($proj_head_uid) > 8) {
if (strlen($proj_head_uid) > $TBDB_UIDLEN) {
USERERROR("The name \"$proj_head_uid\" is too long! ".
"Please select another.", 1);
}
......@@ -322,6 +310,9 @@ if (! $returning) {
and approved, you will be classified as an active user, and will