"; echo " "; echo $contents; echo " "; echo ""; echo "\n"; } # # SIDEBARCELL - Make a cell for the sidebar # function SIDEBARCELL($contents, $last = 0) { echo ""; if ($last) { echo ""; } else { echo ""; } echo "$contents"; echo ""; echo ""; echo "\n"; } # # WRITETOPBARBUTTON(text, base, link): Write a button in the topbar # function WRITETOPBARBUTTON($text, $base, $link ) { $link = "$base/$link"; TOPBARCELL("$text"); } # same as above with "new" gif next to it. function WRITETOPBARBUTTON_NEW($text, $base, $link ) { $link = "$base/$link"; TOPBARCELL("$text "); } # # WRITESIDEBARDIVIDER(): Put a bit of whitespace in the sidebar # function WRITESIDEBARDIVIDER() { global $BASEPATH; echo ""; echo ""; # We have to put something in this cell, or IE ignores it. But, we don't # want to make the table row full line-height, so a space will not do. echo ""; echo ""; echo ""; echo "\n"; } # # WRITESIDEBARBUTTON(text, link): Write a button on the sidebar menu. # We do not currently try to match the current selection so that its # link looks different. Not sure its really necessary. # function WRITESIDEBARBUTTON($text, $base, $link ) { $link = "$base/$link"; SIDEBARCELL("$text"); } # same as above with "new" gif next to it. function WRITESIDEBARBUTTON_NEW($text, $base, $link ) { $link = "$base/$link"; SIDEBARCELL("$text "); } # same as above with "cool" gif next to it. function WRITESIDEBARBUTTON_COOL($text, $base, $link ) { $link = "$base/$link"; SIDEBARCELL("$text "); } function WRITESIDEBARBUTTON_ABS($text, $base, $link ) { $link = "$link"; SIDEBARCELL("$text\n"); } function WRITESIDEBARBUTTON_ABSCOOL($text, $base, $link ) { $link = "$link"; SIDEBARCELL("$text "); } # same as above, but uses a slightly different style sheet so there # is more padding below the last button. # The devil is, indeed, in the details. function WRITESIDEBARLASTBUTTON($text, $base, $link) { $link = "$base/$link"; SIDEBARCELL("$text",1); } function WRITESIDEBARLASTBUTTON_COOL($text, $base, $link) { $link = "$base/$link"; SIDEBARCELL("$text ",1); } # writes a message to the sidebar, without clickability. function WRITESIDEBARNOTICE($text) { SIDEBARCELL("$text"); } # # Something like the sidebar, but across the top, with only a few options. # Think Google. For PlanetLab users, but it would be easy enough to make # others. Still a work in progress. # function WRITEPLABTOPBAR() { echo "\n"; global $login_status, $login_uid; global $TBBASE, $TBDOCBASE, $BASEPATH; global $THISHOMEBASE; WRITETOPBARBUTTON("Create a Slice", $TBBASE, "plab_ez.php3"); WRITETOPBARBUTTON("Nodes", $TBBASE, "plabmetrics.php3"); WRITETOPBARBUTTON("My Testbed", $TBBASE, "showuser.php3?target_uid=$login_uid"); WRITETOPBARBUTTON("Advanced Experiment", $TBBASE, "beginexp_html.php3"); if ($login_status & CHECKLOGIN_TRUSTED) { # Only project/group leaders can do these options # Show a "new" icon if there are people waiting for approval $query_result = DBQueryFatal("select g.* from group_membership as authed ". "left join group_membership as g on ". " g.pid=authed.pid and g.gid=authed.gid ". "left join users as u on u.uid=g.uid ". "where u.status!='". TBDB_USERSTATUS_UNVERIFIED . "' and ". " u.status!='" . TBDB_USERSTATUS_NEWUSER . "' and g.uid!='$login_uid' and ". " g.trust='". TBDB_TRUSTSTRING_NONE . "' ". " and authed.uid='$login_uid' and ". " (authed.trust='group_root' or ". " authed.trust='project_root') ". "ORDER BY g.uid,g.pid,g.gid"); if (mysql_num_rows($query_result) > 0) { WRITETOPBARBUTTON_NEW("Approve Users", $TBBASE, "approveuser_form.php3"); } else { WRITETOPBARBUTTON("Approve Users", $TBBASE, "approveuser_form.php3"); } } WRITETOPBARBUTTON("Log Out", $TBBASE, "logout.php3?next_page=" . urlencode($TBBASE . "/login_plab.php3")); echo "
\n"; echo "
\n"; } # # Put a few things that PlanetLab users should see, but are non-essential, # across the bottom of the page rather than the top # function WRITEPLABBOTTOMBAR() { global $login_status, $login_uid; global $TBBASE, $TBDOCBASE, $BASEPATH; global $THISHOMEBASE; if ($login_uid) { $newsBase = $TBBASE; } else { $newsBase = $TBDOCBASE; } echo "

[ Documentation : ] [ News ]

\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_uid; global $TBBASE, $TBDOCBASE, $BASEPATH; global $THISHOMEBASE; # # The document base cannot be a mix of secure and nonsecure. # # create the main menu table, which also happens to reside in a form # (for search.) # # get post time of most recent news; # get both displayable version and age in days. # $query_result = DBQueryFatal("SELECT DATE_FORMAT(date, '%M %e') AS prettydate, ". " (TO_DAYS(NOW()) - TO_DAYS(date)) AS age ". "FROM webnews ". "ORDER BY date DESC ". "LIMIT 1"); $newsDate = ""; $newNews = 0; # # This is so an admin can use the editing features of news. # if ($login_uid) { # && ISADMIN($login_uid)) { $newsBase = $TBBASE; } else { $newsBase = $TBDOCBASE; } if ($row = mysql_fetch_array($query_result)) { $newsDate = "(".$row[prettydate].")"; if ($row[age] < 7) { $newNews = 1; } } echo "
\n"; ?> People and " . "Photos"); SIDEBARCELL("Emulab Users and " . "Sponsors",1); } else { # Link ALWAYS TO UTAH WRITESIDEBARBUTTON_ABSCOOL("Add Widearea Node (CD)", $TBDOCBASE, "http://www.emulab.net/cdrom.php"); WRITESIDEBARLASTBUTTON("Projects on Emulab", $TBDOCBASE, "projectlist.php3"); } # create the search bit, then the second table for the Web Interface. ?> \n"; echo "\n"; ?> ". "Web Interface Temporarily Unavailable", $TBDOCBASE, "nologins.php3"); if (!$login_uid || !ISADMIN($login_uid)) { WRITESIDEBARNOTICE("Please Try Again Later"); } } if ($login_status & (CHECKLOGIN_LOGGEDIN|CHECKLOGIN_MAYBEVALID)) { if ($login_status & CHECKLOGIN_ACTIVE) { if ($login_status & CHECKLOGIN_PSWDEXPIRED) { WRITESIDEBARBUTTON("Change Your Password", $TBBASE, "moduserinfo.php3"); } elseif ($login_status & CHECKLOGIN_WEBONLY) { WRITESIDEBARBUTTON("My Emulab", $TBBASE, "showuser.php3?target_uid=$login_uid"); WRITESIDEBARBUTTON("Update User Information", $TBBASE, "moduserinfo.php3"); if (ISADMIN($login_uid)) { WRITESIDEBARBUTTON("Approve New Projects", $TBBASE, "approveproject_list.php3"); WRITESIDEBARBUTTON("User List", $TBBASE, "showuser_list.php3"); WRITESIDEBARBUTTON("New User Approval", $TBBASE, "approveuser_form.php3"); } } else { WRITESIDEBARBUTTON("My Emulab", $TBBASE, "showuser.php3?target_uid=$login_uid"); # 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. # WRITESIDEBARDIVIDER(); WRITESIDEBARBUTTON("Begin an Experiment", $TBBASE, "beginexp_html.php3"); # Put _NEW back when Plab is working again. WRITESIDEBARBUTTON("Create a PlanetLab Slice", $TBBASE, "plab_ez.php3"); WRITESIDEBARBUTTON("Experiment List", $TBBASE, "showexp_list.php3"); WRITESIDEBARDIVIDER(); WRITESIDEBARBUTTON("Node Status", $TBBASE, "nodecontrol_list.php3"); SIDEBARCELL("List " . "ImageIDs or OSIDs"); if ($login_status & CHECKLOGIN_CVSWEB) { WRITESIDEBARBUTTON("CVS Repository", $TBBASE, "cvsweb/cvsweb.php3"); } if ($login_status & CHECKLOGIN_TRUSTED) { WRITESIDEBARDIVIDER(); # Only project/group leaders can do these options # Show a "new" icon if there are people waiting for approval $query_result = DBQueryFatal("select g.* from group_membership as authed ". "left join group_membership as g on ". " g.pid=authed.pid and g.gid=authed.gid ". "left join users as u on u.uid=g.uid ". "where u.status!='". TBDB_USERSTATUS_UNVERIFIED . "' and ". " u.status!='" . TBDB_USERSTATUS_NEWUSER . "' and g.uid!='$login_uid' and ". " g.trust='". TBDB_TRUSTSTRING_NONE . "' ". " and authed.uid='$login_uid' and ". " (authed.trust='group_root' or ". " authed.trust='project_root') ". "ORDER BY g.uid,g.pid,g.gid"); if (mysql_num_rows($query_result) > 0) { WRITESIDEBARBUTTON_NEW("New User Approval", $TBBASE, "approveuser_form.php3"); } else { WRITESIDEBARBUTTON("New User Approval", $TBBASE, "approveuser_form.php3"); } } if (ISADMIN($login_uid)) { WRITESIDEBARDIVIDER(); SIDEBARCELL("List " . "Projects or Users"); WRITESIDEBARBUTTON("View Testbed Stats", $TBBASE, "showstats.php3"); WRITESIDEBARBUTTON("Approve New Projects", $TBBASE, "approveproject_list.php3"); WRITESIDEBARBUTTON("Approve Widearea User", $TBBASE, "approvewauser_form.php3"); WRITESIDEBARBUTTON("Edit Site Variables", $TBBASE, "editsitevars.php3"); $query_result = DBQUeryFatal("select new_node_id from new_nodes"); if (mysql_num_rows($query_result) > 0) { WRITESIDEBARBUTTON_NEW("Add Testbed Nodes", $TBBASE, "newnodes_list.php3"); } else { WRITESIDEBARBUTTON("Add Testbed Nodes", $TBBASE, "newnodes_list.php3"); } } } } elseif ($login_status & (CHECKLOGIN_UNVERIFIED|CHECKLOGIN_NEWUSER)) { WRITESIDEBARBUTTON("New User Verification", $TBBASE, "verifyusr_form.php3"); WRITESIDEBARBUTTON("Update User Information", $TBBASE, "moduserinfo.php3"); } elseif ($login_status & (CHECKLOGIN_UNAPPROVED)) { WRITESIDEBARBUTTON("Update User Information", $TBBASE, "moduserinfo.php3"); } # # Standard options for logged in users! # WRITESIDEBARDIVIDER(); SIDEBARCELL("Start or " . "Join a Project", 1); } #WRITESIDEBARLASTBUTTON_COOL("Take our Survey", # $TBDOCBASE, "survey.php3"); # # Cons up a nice message. # switch ($login_status & CHECKLOGIN_STATUSMASK) { case CHECKLOGIN_LOGGEDIN: $login_message = "'$login_uid' Logged in."; if ($login_status & CHECKLOGIN_PSWDEXPIRED) $login_message = "$login_message
(Password Expired!)"; elseif ($login_status & CHECKLOGIN_UNAPPROVED) $login_message = "$login_message
(Unapproved!)"; break; case CHECKLOGIN_TIMEDOUT: $login_message = "Login Timed out."; break; default: $login_message = 0; break; } if ($login_message) { echo ""; echo ""; echo ""; } # # 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 & (CHECKLOGIN_LOGGEDIN|CHECKLOGIN_MAYBEVALID)) { echo ""; echo "\n"; } elseif (!NOLOGINS()) { echo ""; echo "\n"; } # # Login message. Set via 'web/message' site variable # $message = TBGetSiteVar("web/message"); if (0 != strcmp($message,"")) { WRITESIDEBARNOTICE($message); } echo "\n"; } # # spits out beginning part of page # function PAGEBEGINNING( $title, $nobanner = 0 ) { global $BASEPATH, $TBMAINSITE, $THISHOMEBASE; global $TBDIR, $WWW; global $MAINPAGE; global $TBDOCBASE; $MAINPAGE = !strcmp($TBDIR, "/usr/testbed/"); echo " $THISHOMEBASE - $title \n"; if ($TBMAINSITE) { echo "\n"; echo "\n"; echo "\n"; } echo " \n"; if (! $nobanner ) { echo "
$THISHOMEBASE - the network testbed\n"; if (!$MAINPAGE) { echo " $WWW"; } echo "
\n"; } echo "
"; } # # finishes sidebar td # function FINISHSIDEBAR() { echo " \n"; echo ""; echo "\n"; echo "
"; } # # Spit out a vanilla page header. # function PAGEHEADER($title, $view = NULL) { global $login_status, $login_uid, $TBBASE, $TBDOCBASE, $THISHOMEBASE; global $BASEPATH, $SSL_PROTOCOL, $drewheader; 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). # $login_status = CHECKLOGIN($known_uid); if ($login_status & (CHECKLOGIN_LOGGEDIN|CHECKLOGIN_MAYBEVALID)) { $login_uid = $known_uid; } } # # If no view options were specified, get the ones for the current user # if (!$view) { $view = GETUSERVIEW(); } # # Check for NOLOGINS. # We want to allow admin types to continue using the web interface, # and logout anyone else that is currently logged in! # if (NOLOGINS() && $login_uid && !ISADMIN($login_uid)) { DOLOGOUT($login_uid); $login_status = CHECKLOGIN_NOTLOGGEDIN; $login_uid = 0; } header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); if (1) { header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Cache-Control: no-cache, must-revalidate"); header("Pragma: no-cache"); } else { header("Expires: " . gmdate("D, d M Y H:i:s", time() + 300) . " GMT"); } if (isset($view['hide_banner'])) { $nobanner = 1; } else { $nobanner = 0; } PAGEBEGINNING( $title, $nobanner ); if (!isset($view['hide_sidebar'])) { WRITESIDEBAR(); } FINISHSIDEBAR(); echo "

\n"; if ($login_uid && ISADMINISTRATOR()) { if (ISADMIN($login_uid)) { echo " Admin On\n"; } else { echo " Admin Off\n"; } } $now = date("D M d g:ia T"); echo "$title

\n"; if ($login_uid) { echo "'$login_uid' Logged in.
$now
\n"; } else { echo "$now"; } echo "
"; echo "\n"; if ($view['show_topbar'] == "plab") { WRITEPLABTOPBAR(); } } # # ENDPAGE(): This terminates the table started above. # function ENDPAGE() { echo "
"; echo "
"; } # # Spit out a vanilla page footer. # function PAGEFOOTER($view = NULL) { global $TBDOCBASE, $TBMAILADDR, $THISHOMEBASE; global $TBMAINSITE, $SSL_PROTOCOL; if (!$view) { $view = GETUSERVIEW(); } $today = getdate(); $year = $today["year"]; echo "\n"; if ($view['show_bottombar'] == "plab") { WRITEPLABBOTTOMBAR(); } echo " \n"; if (!$view['hide_copyright']) { echo "
[ The Flux Research Group ] [ School of Computing ] [ The University of Utah ]
Copyright © 2000-$year The University of Utah
\n"; } echo "

Problems? Contact $TBMAILADDR.

\n"; ENDPAGE(); # Plug the home site from all others. echo "\n

\n"; echo "\n"; } function PAGEERROR($msg) { global $drewheader; if (! $drewheader) PAGEHEADER("Page Error"); echo "$msg\n"; PAGEFOOTER(); die(""); } # # Sub Page/Menu Stuff # function WRITESUBMENUBUTTON($text, $link) { echo " $text\n"; echo " \n"; } # # Start/End a page within a page. # function SUBPAGESTART() { echo ""; echo "\n \n \n \n
\n"; } function SUBPAGEEND() { echo "
\n"; echo ""; } # # 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) { ?> 1, 'hide_banner' => 1, 'show_topbar' => "plab", 'show_bottombar' => 'plab', 'hide_copyright' => 1); } else { # Most users get the default view return array(); } } ?>