menu.php3 21 KB
Newer Older
1
<?php
Leigh Stoller's avatar
Leigh Stoller committed
2 3
#
# EMULAB-COPYRIGHT
4
# Copyright (c) 2000-2003 University of Utah and the Flux Group.
Leigh Stoller's avatar
Leigh Stoller committed
5 6
# All rights reserved.
#
7

8
$login_status     = CHECKLOGIN_NOTLOGGEDIN;
9
$login_uid        = 0;
10
$drewheader       = 0;
11

12 13 14 15 16 17
#
# This has to be set so we can spit out http or https paths properly!
# Thats because browsers do not like a mix of secure and nonsecure.
# 
$BASEPATH	  = "";

18 19 20 21 22
#
# 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.
#
Chad Barb's avatar
Chad Barb committed
23
function WRITESIDEBARBUTTON($text, $base, $link ) {
24
    $link = "$base/$link";
25
    echo "<tr><td class=\"menuopt\"><a href=\"$link\">$text</a></td></tr>\n";
Chad Barb's avatar
Chad Barb committed
26
}
27

Chad Barb's avatar
Chad Barb committed
28 29 30
# same as above with "new" gif next to it.
function WRITESIDEBARBUTTON_NEW($text, $base, $link ) {
    $link = "$base/$link";
31 32
    echo "<tr><td class=\"menuopt\"><a href=\"$link\">$text</a>&nbsp;";
    echo "<img src=\"/new.gif\" /></td></tr>\n";
Chad Barb's avatar
Chad Barb committed
33 34
}

Chad Barb's avatar
Chad Barb committed
35 36 37 38 39 40 41
# same as above with "cool" gif next to it.
function WRITESIDEBARBUTTON_COOL($text, $base, $link ) {
    $link = "$base/$link";
    echo "<tr><td class=\"menuopt\"><a href=\"$link\">$text</a>&nbsp;";
    echo "<img src=\"/cool.gif\" /></td></tr>\n";
}

Leigh Stoller's avatar
Leigh Stoller committed
42 43
function WRITESIDEBARBUTTON_ABS($text, $base, $link ) {
    $link = "$link";
44
    echo "<tr><td class=\"menuopt\"><a href=\"$link\">$text</a></td></tr>\n";
Leigh Stoller's avatar
Leigh Stoller committed
45 46
}

47 48 49 50 51 52
function WRITESIDEBARBUTTON_ABSCOOL($text, $base, $link ) {
    $link = "$link";
    echo "<tr><td class=\"menuopt\"><a href=\"$link\">$text</a>&nbsp;";
    echo "<img src=\"/cool.gif\" /></td></tr>\n";
}

Chad Barb's avatar
Chad Barb committed
53 54 55 56 57
# 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";
58
    echo "<tr><td class=\"menuoptb\"><a href=\"$link\">$text</a></td></tr>\n";
Chad Barb's avatar
Chad Barb committed
59 60
}

Chad Barb's avatar
Chad Barb committed
61 62 63 64 65 66
function WRITESIDEBARLASTBUTTON_COOL($text, $base, $link) {
    $link = "$base/$link";
    echo "<tr><td class=\"menuoptb\"><a href=\"$link\">$text</a>&nbsp;";
    echo "<img src=\"/cool.gif\" /></td></tr>\n";
}

Chad Barb's avatar
Chad Barb committed
67 68
# writes a message to the sidebar, without clickability.
function WRITESIDEBARNOTICE($text) {
69
    echo "<tr><td class=\"menuopt\"><b>$text</b></td></tr>\n";
70 71 72 73 74 75 76
}

#
# WRITESIDEBAR(): Write the menu. The actual menu options the user
# sees depends on the login status and the DB status.
#
function WRITESIDEBAR() {
77 78
    global $login_status, $login_uid;
    global $TBBASE, $TBDOCBASE, $BASEPATH;
79
    global $THISHOMEBASE;
80 81 82

    #
    # The document base cannot be a mix of secure and nonsecure.
83
    #
Chad Barb's avatar
Chad Barb committed
84 85 86
    
    # create the main menu table, which also happens to reside in a form
    # (for search.)
Chad Barb's avatar
Chad Barb committed
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116

    #
    # get post time of most recent news;
    # get both displayable version and age in days.
    #
    $query_result = 
	DBQueryFatal("SELECT DATE_FORMAT(date, '%M&nbsp;%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;
	}
    }

Chad Barb's avatar
Chad Barb committed
117 118 119 120 121
?>
<FORM method=get ACTION="/cgi-bin/webglimpse/usr/testbed/webglimpse">
  <table class="menu" width=220 cellpadding="0" cellspacing="0">
    <tr><td class="menuheader"><b>Information</b></td></tr>
<?php
122 123 124 125 126 127
    if (0 == strcasecmp($THISHOMEBASE, "emulab.net")) {
	$rootEmulab = 1;
    } else {
	$rootEmulab = 0;
    }

128
    WRITESIDEBARBUTTON("Home", $TBDOCBASE, "index.php3");
129

130 131

    if ($rootEmulab) {
132
	WRITESIDEBARBUTTON("Other Emulabs", $TBDOCBASE,
133
			       "docwrapper.php3?docname=otheremulabs.html");
134
	WRITESIDEBARBUTTON("Join Netbed (CD)",
135 136 137 138 139 140 141 142 143
				$TBDOCBASE, "cdrom.php");
    } else {
	WRITESIDEBARBUTTON_ABS("Utah Emulab", $TBDOCBASE,
			       "http://www.emulab.net/");
	# Link ALWAYS TO UTAH
	WRITESIDEBARBUTTON_ABSCOOL("Join Netbed (CD)",
			       $TBDOCBASE, "http://www.emulab.net/cdrom.php");

    }
Chad Barb's avatar
Chad Barb committed
144

Chad Barb's avatar
Chad Barb committed
145 146 147 148 149 150
    if ($newNews) {
	WRITESIDEBARBUTTON_NEW("News $newsDate", $newsBase, "news.php3");
    } else {
	WRITESIDEBARBUTTON("News $newsDate", $newsBase, "news.php3");
    }

151
    WRITESIDEBARBUTTON("Documentation", $TBDOCBASE, "doc.php3");
152 153

    if ($rootEmulab) {
154
	WRITESIDEBARBUTTON_NEW("Papers (Aug 1)", $TBDOCBASE, "pubs.php3");
155 156 157
	WRITESIDEBARBUTTON_NEW("Software <font size=-1> ".
			       "(June 14)</font>",
			       $TBDOCBASE, "software.php3");
158 159
	WRITESIDEBARBUTTON("People", $TBDOCBASE, "people.php3");
	WRITESIDEBARBUTTON("Photo Gallery", $TBDOCBASE, "gallery/gallery.php3");
160 161
	WRITESIDEBARBUTTON_NEW("Emulab Users", $TBDOCBASE,
			   "doc/docwrapper.php3?docname=users.html");
162 163 164 165 166 167
	WRITESIDEBARLASTBUTTON("Sponsors", $TBDOCBASE,
			       "docwrapper.php3?docname=sponsors.html");
    } else {
	WRITESIDEBARLASTBUTTON("Projects on Emulab", $TBDOCBASE,
			       "projectlist.php3");
    }
168

Chad Barb's avatar
Chad Barb committed
169 170 171 172 173 174
    # create the search bit, then the second table for the Web Interface.
?>
    <tr><td class="menuoptst"><b>Search Documentation:</b></td></tr>
    <tr><td class="menuopts"><input name=query />
      <input type=submit style="font-size:10px;" value="Go" /></td></tr>
      <tr><td class="menuoptsb" style="font-size:12px;" >[
175 176
      <a href="<?php echo "$TBDOCBASE/search.php3"; ?>">Advanced 
      Search</a> ]</td></tr>
Chad Barb's avatar
Chad Barb committed
177 178 179 180 181
    </td></tr>  
  </table>
</form>
<table class="menu" width=220 cellpadding="0" cellspacing="0">
    <tr><td class="menuheader"><b>Interaction</b></td></tr>
182
<?php # BACK TO PHP
183

184
    if ($login_status & CHECKLOGIN_LOGGEDIN) {
Chad Barb's avatar
Chad Barb committed
185 186
         $freepcs = TBFreePCs();
	 WRITESIDEBARNOTICE( "($freepcs Free PCs.)" );
187
    }
188

189 190 191 192 193 194 195 196
    #
    # Basically, we want to let admin people continue to use
    # the web interface even when nologins set. But, we want to make
    # it clear its disabled.
    # 
    if (NOLOGINS()) {
        WRITESIDEBARBUTTON("<font color=red> ".
			   "Web Interface Temporarily Unavailable</font>",
197 198
			   $TBDOCBASE, "nologins.php3");

Chad Barb's avatar
Chad Barb committed
199 200 201
        if (!$login_uid || !ISADMIN($login_uid)) {	
	    WRITESIDEBARNOTICE("Please Try Again Later");
        }
202
    }
Chad Barb's avatar
Chad Barb committed
203

204 205 206
    if ($login_status & (CHECKLOGIN_LOGGEDIN|CHECKLOGIN_MAYBEVALID)) {
	if ($login_status & CHECKLOGIN_ACTIVE) {
	    if ($login_status & CHECKLOGIN_PSWDEXPIRED) {
207
		WRITESIDEBARBUTTON("Change Your Password",
208
				   $TBBASE, "moduserinfo.php3");
209
	    }
210 211 212 213 214 215 216 217
	    elseif ($login_status & CHECKLOGIN_WEBONLY) {
		WRITESIDEBARBUTTON("My Emulab",
				   $TBBASE,
				   "showuser.php3?target_uid=$login_uid");
	    
		WRITESIDEBARBUTTON("Update User Information",
				   $TBBASE, "moduserinfo.php3");
	    }
218
	    else {
Leigh Stoller's avatar
Leigh Stoller committed
219
		WRITESIDEBARBUTTON("My Emulab",
220 221
				   $TBBASE,
				   "showuser.php3?target_uid=$login_uid");
222
	    
223
		if (ISADMIN($login_uid)) {
224 225
		    WRITESIDEBARBUTTON("New Project Approval",
				       $TBBASE, "approveproject_list.php3");
226 227 228

		    WRITESIDEBARBUTTON("Widearea User Approval",
				       $TBBASE, "approvewauser_form.php3");
229 230
		}
		if ($login_status & CHECKLOGIN_TRUSTED) {
231 232 233
                  # Only project/group leaders can do these options
                  # Show a "new" icon if there are people waiting for approval
		  $query_result =
234 235 236
		    DBQueryFatal("select g.* from group_membership as authed ".
				 "left join group_membership as g on ".
				 " g.pid=authed.pid and g.gid=authed.gid ".
237
				 "left join users as u on u.uid=g.uid ".
238
				 "where u.status!='".
239
				 TBDB_USERSTATUS_UNVERIFIED . "' and ".
240 241 242 243 244 245
				 " 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') ".
246 247 248 249 250
				 "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 {
251 252

		      WRITESIDEBARBUTTON("New User Approval",
253
				       $TBBASE, "approveuser_form.php3");
254
		  }
255
		}
256

257 258
                #
                # Since a user can be a member of more than one project,
259 260
                # display this option, and let the form decide if the 
                # user is allowed to do this.
261
                #
262
		WRITESIDEBARBUTTON("Project List",
263
				   $TBBASE, "showproject_list.php3");
264
	    
265
		if (ISADMIN($login_uid)) {
266 267 268 269
		    WRITESIDEBARBUTTON("User List",
				       $TBBASE, "showuser_list.php3");
		}
	    
270 271
		WRITESIDEBARBUTTON("Experiment List",
				   $TBBASE, "showexp_list.php3");
272 273
		WRITESIDEBARBUTTON("Begin an Experiment",
				   $TBBASE, "beginexp.php3");
274 275
		WRITESIDEBARBUTTON("ImageIDs and OSIDs",
				   $TBBASE, "showimageid_list.php3");
276
		WRITESIDEBARBUTTON("Update User Information",
277 278
				   $TBBASE, "moduserinfo.php3");
		WRITESIDEBARBUTTON("Node Reservation Status",
279
				   $TBBASE, "nodecontrol_list.php3");
280 281
		WRITESIDEBARBUTTON("Node Up/Down Status",
				   $TBDOCBASE, "updown.php3");
282 283 284
		WRITESIDEBARBUTTON("View Testbed Stats",
				   $TBBASE, "showstats.php3");
		
285 286 287 288
		if (ISADMIN($login_uid)) {
		    WRITESIDEBARBUTTON("Edit Site Variables",
				       $TBBASE, "editsitevars.php3");
		}
289 290 291 292 293 294 295 296 297 298 299 300 301

		if (ISADMIN($login_uid)) {
		    $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");
		    }
		}		

302 303 304 305
		if ($login_status & CHECKLOGIN_CVSWEB) {
		    WRITESIDEBARBUTTON("CVS Repository",
				       $TBBASE, "cvsweb/cvsweb.php3");
		}
306
	    }
307
	}
308
	elseif ($login_status & (CHECKLOGIN_UNVERIFIED|CHECKLOGIN_NEWUSER)) {
309 310
	    WRITESIDEBARBUTTON("New User Verification",
			       $TBBASE, "verifyusr_form.php3");
311
	    WRITESIDEBARBUTTON("Update User Information",
312
			       $TBBASE, "moduserinfo.php3");
313
	}
314
	elseif ($login_status & (CHECKLOGIN_UNAPPROVED)) {
315
	    WRITESIDEBARBUTTON("Update User Information",
316
			       $TBBASE, "moduserinfo.php3");
317
	}
318 319 320
	#
	# Standard options for logged in users!
	# 
321
	WRITESIDEBARBUTTON("Start Project", $TBBASE, "newproject.php3");
Chad Barb's avatar
Chad Barb committed
322
	WRITESIDEBARLASTBUTTON("Join Project",  $TBBASE, "joinproject.php3");
323
    }
324

Chad Barb's avatar
Chad Barb committed
325
    WRITESIDEBARLASTBUTTON_COOL("Take our Survey",
326 327
	    $TBDOCBASE, "survey.php3");

328 329 330 331 332
    #
    # Cons up a nice message.
    # 
    switch ($login_status & CHECKLOGIN_STATUSMASK) {
    case CHECKLOGIN_LOGGEDIN:
Chad Barb's avatar
Chad Barb committed
333
	$login_message = "'$login_uid' Logged in.";
334 335
	    
	if ($login_status & CHECKLOGIN_PSWDEXPIRED)
Chad Barb's avatar
Chad Barb committed
336
	    $login_message = "$login_message<br>(Password Expired!)";
337
	elseif ($login_status & CHECKLOGIN_UNAPPROVED)
Chad Barb's avatar
Chad Barb committed
338
	    $login_message = "$login_message<br>(Unapproved!)";
339
	break;
340
    case CHECKLOGIN_TIMEDOUT:
Chad Barb's avatar
Chad Barb committed
341
	$login_message = "Login Timed out.";
342
	break;
343 344
    default:
	$login_message = 0;
345
	break;
346 347
    }

Chad Barb's avatar
Chad Barb committed
348
    if ($login_message) {
349
      echo "<tr>";
Chad Barb's avatar
Chad Barb committed
350
      echo "<td class=\"menufooter\" style='padding-top: 6px;' ><center><b>";
351 352
      echo "$login_message</b></center></td>";
      echo "</tr>";
Chad Barb's avatar
Chad Barb committed
353 354
    }

355 356
    #
    # Now the login/logout box. Remember, already inside a table.
357 358
    # 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
359
    # http or https, since we do not want to mix them, since they
360
    # cause warnings.
361
    # 
362
    if ($login_status & (CHECKLOGIN_LOGGEDIN|CHECKLOGIN_MAYBEVALID)) {
363 364 365 366 367 368
      echo "<tr>";
      echo "<td class=\"menufooter\" align=center valign=center>";
      echo "<a href=\"$TBBASE/logout.php3?uid=$login_uid\">";
      echo "<img alt=\"logoff\" border=0 ";
      echo "src=\"$BASEPATH/logoff.gif\"></a>\n";
      echo "</td></tr>\n";
369
    }
370
    elseif (!NOLOGINS()) {
371 372
      echo "<tr>";
      echo "<td class=\"menufooter\" align=center valign=center>";
Chad Barb's avatar
Chad Barb committed
373 374 375 376 377 378 379

      echo "<a href=\"$TBBASE/reqaccount.php3\">";
      echo "<img alt=\"Request Account\" border=0 ";
      echo "src=\"$BASEPATH/requestaccount.gif\"></a>";

      echo "<br /><b>or</b><br />";

380 381 382
      echo "<a href=\"$TBBASE/login.php3\">";
      echo "<img alt=\"logon\" border=0 ";
      echo "src=\"$BASEPATH/logon.gif\"></a>\n";
Chad Barb's avatar
Chad Barb committed
383

384
      echo "</td></tr>\n";
385
    }
386

387
    #
388
    # Login message. Set via 'web/message' site variable
389
    #
390 391 392
    $message = TBGetSiteVar("web/message");
    if (0 != strcmp($message,"")) {
	WRITESIDEBARNOTICE($message);    	
393
    }
394

Chad Barb's avatar
Chad Barb committed
395
    echo "</table>\n";
396 397
}

398 399 400 401
#
# spits out beginning part of page
#
function PAGEBEGINNING( $title ) {
Chad Barb's avatar
Chad Barb committed
402 403
    global $BASEPATH, $TBMAINSITE, $THISHOMEBASE;
    global $TBDIR, $WWW;
404 405
    global $MAINPAGE;

Chad Barb's avatar
Chad Barb committed
406
    $MAINPAGE = !strcmp($TBDIR, "/usr/testbed/"); 
407 408 409 410 411 412
  
    echo "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN' 
          'http://www.w3.org/TR/html4/loose.dtd'>
	<html>
	  <head>
	    <title>$THISHOMEBASE - $title</title>
413 414
            <!--<link rel=\"SHORTCUT ICON\" HREF=\"netbed.ico\">-->
            <link rel=\"SHORTCUT ICON\" HREF=\"netbed.png\" TYPE=\"image/png\">
415 416 417 418 419 420 421 422 423 424 425
    	    <!-- dumbed-down style sheet for any browser that groks (eg NS47). -->
	    <link REL='stylesheet' HREF='$BASEPATH/common-style.css' TYPE='text/css' />
    	    <!-- don't import full style sheet into NS47, since it does a bad job
            of handling it. NS47 doesn't understand '@import'. -->
    	    <style type='text/css' media='all'>
            <!-- @import '$BASEPATH/style.css'; -->";

    if (!$MAINPAGE) {
	echo "<!-- @import '$BASEPATH/style-nonmain.css'; -->";
    } 

426
    echo "</style>\n";
427 428

    if ($TBMAINSITE) {
429 430 431 432 433 434 435
	echo "<meta NAME=\"keywords\" ".
	           "CONTENT=\"network, emulation, internet, emulator\">\n";
	echo "<meta NAME=\"robots\" ".
	           "CONTENT=\"NOARCHIVE\">\n";
	echo "<meta NAME=\"description\" ".
                   "CONTENT=\"emulab - network emulation testbed home\">\n";
    }
436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455

    echo "</head>
            <body bgcolor='#FFFFFF' 
             topmargin='0' leftmargin='0' marginheight='0' marginwidth='0'>
            <table cellpadding='0' cellspacing='0' width='100%'>
            <tr>
              <td valign='top' class='bannercell' 
              background='$BASEPATH/headerbgbb.jpg'
              bgcolor=#3D627F ><img width=369 height=100 
              src='$BASEPATH/overlay.".strtolower($THISHOMEBASE).".gif' 
              alt='$THISHOMEBASE - the network testbed' />";
    if (!$MAINPAGE) {
	echo "<font size='+1' color='#CCFFCC'>&nbsp;<b>$WWW</b></font>";
    }
    echo "</td></tr></table>\n";

    echo "<table cellpadding='8' cellspacing='0' height='100%' width='100%'>
            <tr height='100%'>
              <td valign='top' class='leftcell' bgcolor='#ccddee'>
              <!-- sidebar begins -->";
456 457 458 459 460 461 462
}

#
# finishes sidebar td
#
function FINISHSIDEBAR()
{
463
    echo "<!-- sidebar ends -->
464
        </td>
465
        <td valign='top' width='100%' class='rightcell'>
466
          <!-- content body table -->
467
          <table class='content' width='100%' cellpadding='0' cellspacing='0'>
468
            <tr>
469
              <td class='contentheader'>";
470 471
}

472 473 474 475
#
# Spit out a vanilla page header.
#
function PAGEHEADER($title) {
476 477
    global $login_status, $login_uid, $TBBASE, $TBDOCBASE, $THISHOMEBASE;
    global $BASEPATH, $SSL_PROTOCOL, $drewheader;
478
    global $TBMAINSITE;
479 480

    $drewheader = 1;
481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496

    #
    # 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;
    }
497

498
    #
499
    # Figure out who is logged in, if anyone.
500
    # 
501 502 503 504
    if (($known_uid = GETUID()) != FALSE) {
        #
        # Check to make sure the UID is logged in (not timed out).
        #
505 506 507
        $login_status = CHECKLOGIN($known_uid);
	if ($login_status & (CHECKLOGIN_LOGGEDIN|CHECKLOGIN_MAYBEVALID)) {
	    $login_uid = $known_uid;
508 509 510
	}
    }

511
    #
512 513
    # Check for NOLOGINS. 
    # We want to allow admin types to continue using the web interface,
514 515
    # and logout anyone else that is currently logged in!
    #
516 517 518 519
    if (NOLOGINS() && $login_uid && !ISADMIN($login_uid)) {
	DOLOGOUT($login_uid);
	$login_status = CHECKLOGIN_NOTLOGGEDIN;
	$login_uid    = 0;
520
    }
521
    
522 523
    header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
    
524
    if (1) {
525 526 527 528 529 530 531
	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"); 
    }
532 533 534 535

    PAGEBEGINNING( $title );
    WRITESIDEBAR();
    FINISHSIDEBAR();
536
    echo "<h2 class=\"nomargin\">\n";
537

538
    if ($login_uid && ISADMINISTRATOR()) {
Chad Barb's avatar
Chad Barb committed
539
	if (ISADMIN($login_uid)) {
540
	    echo "<a href=toggle.php?target_uid=$login_uid&type=adminoff&value=1>
Chad Barb's avatar
Chad Barb committed
541 542 543 544
	             <img src='/redball.gif'
                          border=0 alt='Admin On'></a>\n";
	}
	else {
545
	    echo "<a href=toggle.php?target_uid=$login_uid&type=adminoff&value=0>
Chad Barb's avatar
Chad Barb committed
546 547 548
	             <img src='/greenball.gif'
                          border=0 alt='Admin Off'></a>\n";
	}
549
    }
550 551
    $now = date("D M d g:ia T");
    echo "$title</h2></td>\n";
552
    echo "<td class=contentheader align=right>\n";
553
    if ($login_uid) {
Chad Barb's avatar
Chad Barb committed
554
	echo "<font size=-1>'<b>$login_uid</b>' Logged in.<br>$now</font>\n";
555 556 557
    }
    else {
	echo "$now";
558 559 560 561
    }
    echo "</td>";
    echo "</tr>\n";
    echo "<tr><td colspan=3 class=\"contentbody\" width=*>";
562
    echo "<!-- begin content -->\n";
563 564 565 566 567 568
}

#
# ENDPAGE(): This terminates the table started above.
# 
function ENDPAGE() {
569 570
  echo "</td></tr></table>";
  echo "</td></tr></table>";
571 572 573 574 575 576
}

#
# Spit out a vanilla page footer.
#
function PAGEFOOTER() {
577
    global $TBDOCBASE, $TBMAILADDR, $THISHOMEBASE;
Leigh Stoller's avatar
Leigh Stoller committed
578
    global $TBMAINSITE, $SSL_PROTOCOL;
579

580 581
    $today = getdate();
    $year  = $today["year"];
Chad Barb's avatar
Chad Barb committed
582

583
    echo "<!-- end content -->
Chad Barb's avatar
Chad Barb committed
584
              </td>
585 586 587 588 589
            </tr>
            <tr>
              <td colspan=2 class=contentbody>
	        <center>
                <font size=-1>
590 591 592 593 594 595
		[ <a href=http://www.cs.utah.edu/flux/>
                    The&nbsp;Flux&nbsp;Research&nbsp;Group</a> ]
		[ <a href=http://www.cs.utah.edu/>
                    School&nbsp;of&nbsp;Computing</a> ]
		[ <a href=http://www.utah.edu/>
                    The&nbsp;University&nbsp;of&nbsp;Utah</a> ]
596 597
		</font>
		<br>
Chad Barb's avatar
Chad Barb committed
598
                <!-- begin copyright -->
599
                <font size=-2>
600 601 602 603
                <a href='$TBDOCBASE/docwrapper.php3?docname=copyright.html'>
                    Copyright &copy; 2000-$year The University of Utah</a>
                </font>
                <br>
604 605
		</center>
                <p align=right>
Chad Barb's avatar
Chad Barb committed
606 607
		  <font size=-2>
                    Problems?
608
	            Contact $TBMAILADDR.
Chad Barb's avatar
Chad Barb committed
609 610
                  </font>
                </p>
611
                <!-- end copyright -->\n";
Chad Barb's avatar
Chad Barb committed
612 613

    ENDPAGE();
614

615 616 617
    # Plug the home site from all others.
    echo "\n<p><a href=\"www.emulab.net/netemu.php3\"></a>\n";

618
    echo "</body></html>\n";
619
}
620 621 622 623 624 625 626 627 628 629 630 631

function PAGEERROR($msg) {
    global $drewheader;

    if (! $drewheader)
	PAGEHEADER("");

    echo "$msg\n";

    PAGEFOOTER();
    die("");
}
632 633 634 635 636

#
# Sub Page/Menu Stuff
#
function WRITESUBMENUBUTTON($text, $link) {
Chad Barb's avatar
Chad Barb committed
637 638


639 640 641 642 643 644 645 646 647 648 649 650 651 652 653
    echo "<!-- Table row for button $text -->
          <tr>
            <td valign=center align=left nowrap>
                <b>
         	 <a class=sidebarbutton href='$link'>$text</a>\n";

    echo "      </b>
            </td>
          </tr>\n";
}

#
# Start/End a page within a page. 
#
function SUBPAGESTART() {
Chad Barb's avatar
Chad Barb committed
654
    echo "<!-- begin subpage -->";
655
    echo "<table class=\"stealth\"
656
	  cellspacing='0' cellpadding='0' width='100%' border='0'>\n
657
            <tr>\n
Chad Barb's avatar
Chad Barb committed
658
              <td class=\"stealth\"valign=top>\n";
659 660 661 662 663 664
}

function SUBPAGEEND() {
    echo "    </td>\n
            </tr>\n
          </table>\n";
Chad Barb's avatar
Chad Barb committed
665
    echo "<!-- end subpage -->";
666 667 668 669 670 671 672
}

#
# 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) {
Chad Barb's avatar
Chad Barb committed
673 674
?>
    <!-- begin submenu -->
675
    <table class='menu' cellpadding="0" cellspacing="0"
676
	style="margin-right: 6px;" >
Chad Barb's avatar
Chad Barb committed
677 678 679 680
      <tr>
        <td class="menuheader"><b><?php echo "$title";?></b></td>
      </tr>
<?php
681 682 683
}

function SUBMENUEND() {
Chad Barb's avatar
Chad Barb committed
684 685 686 687
?>
    </table>
    <!-- end submenu -->
  </td>
688
  <td class="stealth" valign=top align=left width='100%'>
Chad Barb's avatar
Chad Barb committed
689
<?php
690 691
}

692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709
# Start a new section in an existing submenu
# This includes ending the one before it
function SUBMENUSECTION($title) {
    SUBMENUSECTIONEND();
?>
      <!-- new submenu section -->
      <tr>
        <td class="menuheader"><b><?php echo "$title";?></b></td>
      </tr>
<?php
}

# End a submenu section - only need this on the last one of the table.
function SUBMENUSECTIONEND() {
?>
      <tr height=5><td></td></tr>
<?php
}
710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726

# These are here so you can wedge something else under the menu in the left column.

function SUBMENUEND_2A() {
?>
    </table>
    <!-- end submenu -->
<?php
}

function SUBMENUEND_2B() {
?>
  </td>
  <td class="stealth" valign=top align=left width='85%'>
<?php
}

727
?>