$text\n";
#
# XXX these blanks look bad in lynx, but add required
# spacing between menu and body
#
echo " \n";
echo "
\n";
}
#
# WRITESIDEBAR(): Write the menu. The actual menu options the user
# sees depends on the login status and the DB status.
#
function WRITESIDEBAR() {
global $login_status, $login_message, $error_message, $login_uid;
global $STATUS_NOSTATUS, $STATUS_LOGGEDIN, $STATUS_LOGGEDOUT;
global $STATUS_LOGINFAIL, $STATUS_TIMEDOUT, $STATUS_NOLOGINS;
global $TBBASE, $TBDOCBASE, $TBDBNAME, $BASEPATH, $pswd_expired;
global $THISHOMEBASE;
#
# The document base cannot be a mix of secure and nonsecure.
#
echo "
\n";
}
elseif ($login_status == $STATUS_LOGGEDIN) {
$query_result =
DBQueryFatal("SELECT status,admin ".
"FROM users WHERE uid='$login_uid'");
$row = mysql_fetch_row($query_result);
$status = $row[0];
$admin = $row[1];
#
# See if group_root in any projects, not just the last one in the DB!
#
$query_result = mysql_db_query($TBDBNAME,
"SELECT trust FROM group_membership ".
"WHERE uid='$login_uid' and ".
" (trust='group_root' or trust='project_root')");
if (mysql_num_rows($query_result)) {
$trusted = 1;
}
else {
$trusted = 0;
}
if ($status == "active" && $pswd_expired) {
WRITESIDEBARBUTTON("Change your Password",
$TBBASE, "modusr_form.php3");
}
elseif ($status == "active") {
WRITESIDEBARBUTTON("My $THISHOMEBASE",
$TBBASE,
"showuser.php3?target_uid=$login_uid");
if ($admin) {
WRITESIDEBARBUTTON("New Project Approval",
$TBBASE, "approveproject_list.php3");
}
if ($trusted) {
# Only project leaders can do these options
WRITESIDEBARBUTTON("New User Approval",
$TBBASE, "approveuser_form.php3");
}
#
# Since a user can be a member of more than one project,
# display this option, and let the form decide if the user is
# allowed to do this.
#
WRITESIDEBARBUTTON("Project Information",
$TBBASE, "showproject_list.php3");
if ($admin) {
WRITESIDEBARBUTTON("User List",
$TBBASE, "showuser_list.php3");
WRITESIDEBARBUTTON("Node Control",
$TBBASE, "nodecontrol_list.php3");
}
WRITESIDEBARBUTTON("Begin an Experiment",
$TBBASE, "beginexp_form.php3");
WRITESIDEBARBUTTON("Experiment Information",
$TBBASE, "showexp_list.php3");
WRITESIDEBARBUTTON("Update user information",
$TBBASE, "modusr_form.php3");
WRITESIDEBARBUTTON("Node Reservation Status",
$TBBASE, "reserved.php3");
WRITESIDEBARBUTTON("Node Up/Down Status",
$TBDOCBASE, "updown.php3");
}
elseif (($status == "newuser") || ($status == "unverified")) {
WRITESIDEBARBUTTON("New User Verification",
$TBBASE, "verifyusr_form.php3");
}
elseif ($status == "unapproved") {
$error_message = "Your account has not been approved yet. ".
"Please try back later";
}
}
#
# Standard options for anyone.
#
if ($login_status != $STATUS_NOLOGINS) {
WRITESIDEBARBUTTON("Start Project", $TBBASE, "newproject_form.php3");
WRITESIDEBARBUTTON("Join Project", $TBBASE, "addusr.php3");
}
switch ($login_status) {
case $STATUS_LOGGEDIN:
$login_message = "$login_uid Logged In";
if ($pswd_expired)
$login_message = "$login_message (Password Expired!)";
break;
case $STATUS_LOGGEDOUT:
$login_message = "Logged Out";
break;
case $STATUS_LOGINFAIL:
$login_message = "Login Failed";
break;
case $STATUS_TIMEDOUT:
$login_message = "Login Timed Out";
break;
case $STATUS_NOLOGINS:
$login_message = "Please Try Again Later";
break;
}
#
# Now the login/logout box. Remember, already inside a table.
# We want the links to the login/logout pages to always be https,
# but the images path depends on whether the page was loaded as
# http or https, since we do not want to mix them, since they
# cause warnings.
#
if ($login_status == $STATUS_LOGGEDIN) {
echo "
\n";
}
else {
echo "
\n";
}
if ($login_message) {
echo "
$login_message
\n";
}
#
# MOTD. Set this with the webcontrol script.
#
# The blinking is for Mike, who says he really likes it.
#
$query_result = mysql_db_query($TBDBNAME,
"SELECT message FROM loginmessage");
if (mysql_num_rows($query_result)) {
$row = mysql_fetch_row($query_result);
$message = $row[0];
echo "
$message
\n";
}
echo "
\n";
}
#
# WRITEBANNER(): write the page banner for a page.
# Called by _STARTPAGE
#
function WRITEBANNER($title) {
global $BANNERCOLOR, $THISPROJECT, $THISHOMEBASE, $BASEPATH;
echo "\n";
echo "
\n";
echo "
";
echo "
$THISHOMEBASE
$THISPROJECT
\n";
}
#
# _WRITETITLE(title): write the page title for a page.
# Called by _STARTPAGE
#
function WRITETITLE($title) {
global $TITLECOLOR, $BASEPATH;
echo "
\n";
#
# Insert a small logo here if you like.
#
echo "
$title
\n";
}
#
# Spit out a vanilla page header.
#
function PAGEHEADER($title) {
global $login_status, $TBAUTHTIMEOUT, $login_uid;
global $STATUS_NOSTATUS, $STATUS_LOGGEDIN, $STATUS_LOGGEDOUT;
global $STATUS_LOGINFAIL, $STATUS_TIMEDOUT, $STATUS_NOLOGINS;
global $TBBASE, $TBDOCBASE, $TBDBNAME;
global $CHECKLOGIN_NOTLOGGEDIN, $CHECKLOGIN_LOGGEDIN;
global $CHECKLOGIN_TIMEDOUT, $CHECKLOGIN_MAYBEVALID;
global $CHECKLOGIN_PSWDEXPIRED, $THISHOMEBASE
global $BASEPATH, $SSL_PROTOCOL, $javacode, $drewheader, $pswd_expired;
global $TBMAINSITE;
$drewheader = 1;
#
# Determine the proper basepath, which depends on whether the page
# was loaded as http or https. This lets us be consistent in the URLs
# we spit back, so that users do not get those pesky warnings. These
# warnings are generated when a page *loads* (say, images, style files),
# a mix of http and https. Links can be mixed, and in fact when there
# is no login active, we want to spit back http for the documentation,
# but https for the start/join pages.
#
if (isset($SSL_PROTOCOL)) {
$BASEPATH = $TBBASE;
}
else {
$BASEPATH = $TBDOCBASE;
}
#
# Figure out who is logged in, if anyone.
#
if (($known_uid = GETUID()) != FALSE) {
#
# Check to make sure the UID is logged in (not timed out).
#
$status = CHECKLOGIN($known_uid);
switch ($status) {
case $CHECKLOGIN_NOTLOGGEDIN:
$login_status = $STATUS_NOSTATUS;
$login_uid = 0;
break;
case $CHECKLOGIN_PSWDEXPIRED:
$pswd_expired = 1;
case $CHECKLOGIN_LOGGEDIN:
case $CHECKLOGIN_MAYBEVALID:
$login_status = $STATUS_LOGGEDIN;
$login_uid = $known_uid;
break;
case $CHECKLOGIN_TIMEDOUT:
$login_status = $STATUS_TIMEDOUT;
$login_uid = 0;
break;
}
}
#
# Check for NOLOGINS. This is complicated by the fact that we
# want to allow admin types to continue using the web interface,
# and logout anyone else that is currently logged in!
#
if ($login_status == $STATUS_LOGGEDIN && NOLOGINS()) {
$query_result = mysql_db_query($TBDBNAME,
"SELECT admin FROM users WHERE uid='$login_uid'");
$row = mysql_fetch_row($query_result);
$admin = $row[0];
if (!$admin) {
DOLOGOUT($login_uid);
$login_status = $STATUS_NOLOGINS;
}
}
elseif (NOLOGINS()) {
$login_status = $STATUS_NOLOGINS;
}
echo "
$THISHOMEBASE - $title\n";
$timeo = ($TBAUTHTIMEOUT + 120) * 1000;
#
# If logged in, initialize the refresh process.
#
if ($login_status == $STATUS_LOGGEDIN) {
echo "\n";
echo "\n";
#
# Shove the rest of the Java code through to the output.
#
for ($i = 0; $i < count($javacode); $i++) {
echo "$javacode[$i]";
}
}
if ($TBMAINSITE) {
echo "
\n";
}
echo "
\n";
# echo " \n";
echo "
\n";
#
# If logged in, start the refresh process.
#
if ($login_status == $STATUS_LOGGEDIN) {
echo "\n";
}
else {
echo "\n";
}
WRITEBANNER($title);
WRITETITLE($title);
echo "
\n";
WRITESIDEBAR();
echo "
\n";
}
#
# ENDPAGE(): This terminates the table started above.
#
function ENDPAGE() {
echo "
\n";
}
#
# Spit out a vanilla page footer.
#
function PAGEFOOTER() {
global $TBDOCBASE, $TBMAILADDR, $THISHOMEBASE;
global $TBMAINSITE, $SSL_PROTOCOL;
ENDPAGE();
echo "
\n";
}
function PAGEERROR($msg) {
global $drewheader;
if (! $drewheader)
PAGEHEADER("");
echo "$msg\n";
PAGEFOOTER();
die("");
}
#
# Sub Page/Menu Stuff
#
function WRITESUBMENUBUTTON($text, $link) {
echo "
$text\n";
#
# XXX these blanks look bad in lynx, but add required
# spacing between menu and body
#
echo " \n";
echo "
\n";
}
#
# Start/End a page within a page.
#
function SUBPAGESTART() {
echo "
\n
\n
\n";
}
function SUBPAGEEND() {
echo "
\n
\n
\n";
}
#
# Start/End a sub menu, located in the upper left of the main frame.
# Note that these cannot be used outside of the SUBPAGE macros above.
#
function SUBMENUSTART($title) {
echo "