menu.php3 16.4 KB
Newer Older
1
<?php
Leigh B. Stoller's avatar
Leigh B. Stoller committed
2
3
4
5
6
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2002 University of Utah and the Flux Group.
# 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
23
#
# 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) {
24
    $link = "$base/$link";
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
    
    echo "<!-- Table row for button $text -->
          <tr>
            <td valign=center align=left nowrap>
                <b>
         	 <a class=sidebarbutton href=\"$link\">$text</a>\n";
    #
    # XXX these blanks look bad in lynx, but add required
    #     spacing between menu and body
    #
    echo "       &nbsp;&nbsp;\n";

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

#
# WRITESIDEBAR(): Write the menu. The actual menu options the user
# sees depends on the login status and the DB status.
#
function WRITESIDEBAR() {
47
48
    global $login_status, $login_uid;
    global $TBBASE, $TBDOCBASE, $BASEPATH;
49
    global $THISHOMEBASE;
50
51
52

    #
    # The document base cannot be a mix of secure and nonsecure.
53
    #
54
55
    echo "<table cellspacing=2 cellpadding=2 border=0 width=150>\n";

56
    WRITESIDEBARBUTTON("Home", $TBDOCBASE, "index.php3");
57
58
    WRITESIDEBARBUTTON("Tutorial at SIGCOMM'02 <img src=/new.gif>",
		       $TBDOCBASE, "sc2002tut.php3");
Robert Ricci's avatar
Robert Ricci committed
59
    WRITESIDEBARBUTTON("News (Updated Aug 15) <img src=/new.gif>", $TBDOCBASE,
60
		       "docwrapper.php3?docname=news.html");
61
62
    WRITESIDEBARBUTTON("Tutorial", $TBDOCBASE, "tutorial/tutorial.php3");
    WRITESIDEBARBUTTON("FAQ", $TBDOCBASE, "faq.php3");
63
    WRITESIDEBARBUTTON("Documentation", $TBDOCBASE, "doc.php3");
64
    WRITESIDEBARBUTTON("Search Documentation", $TBDOCBASE, "search.php3");
65
    WRITESIDEBARBUTTON("Papers <img src=/new.gif>", $TBDOCBASE, "pubs.php3");
66
    WRITESIDEBARBUTTON("People", $TBDOCBASE, "people.php3");
67
    WRITESIDEBARBUTTON("The Gallery", $TBDOCBASE, "gallery/gallery.php3");
68
    WRITESIDEBARBUTTON("Projects Using $THISHOMEBASE", $TBDOCBASE,
69
		       "projectlist.php3");
Mike Hibler's avatar
Mike Hibler committed
70
71
    WRITESIDEBARBUTTON("Sponsors", $TBDOCBASE,
		       "docwrapper.php3?docname=sponsors.html");
72
73
74
75

    echo "<tr>
            <td height=30 valign=center align=center nowrap>
             <b><span class=sidebarbutton>
76
77
                  Web Interface Options\n";

78
    if ($login_status & CHECKLOGIN_LOGGEDIN) {
79
80
	$freepcs = TBFreePCs();
	
81
82
83
	echo "    <br>($freepcs Free PCs)\n";
    }
    echo "      </span>
84
85
86
87
             </b>
            </td>
          </tr>\n";

88
89
90
91
92
93
94
95
    #
    # 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>",
96
97
			   $TBDOCBASE, "nologins.php3");

98
99
100
101
102
103
104
105
106
	if (!$login_uid || !ISADMIN($login_uid)) {	
	    echo "<tr>
                    <td height=30 valign=center align=center nowrap>
                    <b><span class=sidebarbutton>
                         Please Try Again Later
                       </span>
                    </b>
                 </td>
                </tr>\n";
107
	}
108
109
110
111
    }
    if ($login_status & (CHECKLOGIN_LOGGEDIN|CHECKLOGIN_MAYBEVALID)) {
	if ($login_status & CHECKLOGIN_ACTIVE) {
	    if ($login_status & CHECKLOGIN_PSWDEXPIRED) {
112
		WRITESIDEBARBUTTON("Change Your Password",
113
				   $TBBASE, "moduserinfo.php3");
114
	    }
115
116
117
118
	    else {
		WRITESIDEBARBUTTON("My $THISHOMEBASE",
				   $TBBASE,
				   "showuser.php3?target_uid=$login_uid");
119
	    
120
		if (ISADMIN($login_uid)) {
121
122
123
124
125
126
127
128
129
130
131
132
133
134
		    WRITESIDEBARBUTTON("New Project Approval",
				       $TBBASE, "approveproject_list.php3");
		}
		if ($login_status & CHECKLOGIN_TRUSTED) {
                    # Only project/group 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.
                #
Leigh B. Stoller's avatar
Leigh B. Stoller committed
135
		WRITESIDEBARBUTTON("Project List",
136
				   $TBBASE, "showproject_list.php3");
137
	    
138
		if (ISADMIN($login_uid)) {
139
140
141
142
		    WRITESIDEBARBUTTON("User List",
				       $TBBASE, "showuser_list.php3");
		}
	    
Leigh B. Stoller's avatar
Leigh B. Stoller committed
143
144
		WRITESIDEBARBUTTON("Experiment List",
				   $TBBASE, "showexp_list.php3");
145
146
		WRITESIDEBARBUTTON("Begin an Experiment",
				   $TBBASE, "beginexp.php3");
Leigh B. Stoller's avatar
Leigh B. Stoller committed
147
148
		WRITESIDEBARBUTTON("OSIDs and ImageIDs",
				   $TBBASE, "showosid_list.php3");
149
		WRITESIDEBARBUTTON("Update User Information",
150
151
				   $TBBASE, "moduserinfo.php3");
		WRITESIDEBARBUTTON("Node Reservation Status",
152
				   $TBBASE, "nodecontrol_list.php3");
153
154
155
156
157
158
159
		WRITESIDEBARBUTTON("Node Up/Down Status",
				   $TBDOCBASE, "updown.php3");
		
		if ($login_status & CHECKLOGIN_CVSWEB) {
		    WRITESIDEBARBUTTON("CVS Repository",
				       $TBBASE, "cvsweb/cvsweb.php3");
		}
160
	    }
161
	}
162
	elseif ($login_status & (CHECKLOGIN_UNVERIFIED|CHECKLOGIN_NEWUSER)) {
163
164
	    WRITESIDEBARBUTTON("New User Verification",
			       $TBBASE, "verifyusr_form.php3");
165
	    WRITESIDEBARBUTTON("Update User Information",
166
			       $TBBASE, "moduserinfo.php3");
167
	}
168
	elseif ($login_status & (CHECKLOGIN_UNAPPROVED)) {
169
	    WRITESIDEBARBUTTON("Update User Information",
170
			       $TBBASE, "moduserinfo.php3");
171
172
173
174
175
	}
    }
    #
    # Standard options for anyone.
    #
176
    if (! NOLOGINS()) {
177
178
	WRITESIDEBARBUTTON("Start Project", $TBBASE, "newproject.php3");
	WRITESIDEBARBUTTON("Join Project",  $TBBASE, "joinproject.php3");
179
    }
180

181
182
183
184
185
    #
    # Cons up a nice message.
    # 
    switch ($login_status & CHECKLOGIN_STATUSMASK) {
    case CHECKLOGIN_LOGGEDIN:
186
	$login_message = "$login_uid Logged In";
187
188
	    
	if ($login_status & CHECKLOGIN_PSWDEXPIRED)
189
	    $login_message = "$login_message<br>(Password Expired!)";
190
191
	elseif ($login_status & CHECKLOGIN_UNAPPROVED)
	    $login_message = "$login_message<br>(Unapproved!)";
192
	break;
193
    case CHECKLOGIN_TIMEDOUT:
194
195
	$login_message = "Login Timed Out";
	break;
196
197
    default:
	$login_message = 0;
198
	break;
199
200
201
202
    }

    #
    # Now the login/logout box. Remember, already inside a table.
203
204
    # 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
205
    # http or https, since we do not want to mix them, since they
206
    # cause warnings.
207
    # 
208
    if ($login_status & (CHECKLOGIN_LOGGEDIN|CHECKLOGIN_MAYBEVALID)) {
209
	echo "<tr>
210
211
212
213
214
               <td align=center height=50 valign=center>
                <a href=\"$TBBASE/logout.php3?uid=$login_uid\">
	           <img alt=\"logout\" border=0
                        src=\"$BASEPATH/logoff.gif\"></a>
               </td>
215
216
              </tr>\n";
    }
217
    elseif (!NOLOGINS()) {
218
	echo "<tr>
219
               <td align=center height=50 valign=center>
220
                <a href=\"$TBBASE/login.php3\">
221
222
223
	           <img alt=\"logon\" border=0
                        src=\"$BASEPATH/logon.gif\"></a>
               </td>
224
225
              </tr>\n";
    }
226

227
228
229
230
231
232
233
234
235
236
237
    if ($login_message) {
	echo "<tr>
                <td align=center>
                 <b>
                   <span class=sidebarbutton>
                      $login_message
                   </span>
                 <b>
                </td>
              </tr>\n";
    }
238

239
    #
240
    # MOTD. Set this with the webcontrol script.
241
    #
242
243
    $query_result =
	DBQueryFatal("SELECT message FROM loginmessage");
244
245
246
247
248
    
    if (mysql_num_rows($query_result)) {
    	$row = mysql_fetch_row($query_result);
	$message = $row[0];
    
249
250
	echo "<tr>
                <td align=center>
251
                 <b>
252
253
                   <span class=sidebarbutton>
                    <font size=\"+1\" color=RED>
254
                      $message
255
256
                    </font>
                   </span>
257
                 <b>
258
259
260
                </td>
              </tr>\n";
    }
261
262
263
264
265
266
267
268
269
    echo "</table>
          <br>\n";
}

#
# WRITEBANNER(): write the page banner for a page.
# Called by _STARTPAGE
#
function WRITEBANNER($title) {
270
    global $BANNERCOLOR, $THISPROJECT, $THISHOMEBASE, $BASEPATH;
271
    global $login_uid;
272
273

    echo "<!-- This is the page Banner -->\n";
Leigh B. Stoller's avatar
Leigh B. Stoller committed
274
275

    echo "<table cellpadding=0 cellspacing=0 border=0 width=50%>";
276
    echo "<tr>
277
            <td align=left valign=top width=0%>
278
279
280
             <table cellpadding=5 cellspacing=0 border=0 bgcolor=\"#880000\">
              <tr>
                <td>
Leigh B. Stoller's avatar
Leigh B. Stoller committed
281
                 <b><font size=5 color=white face=Helvetica>
282
                        $THISHOMEBASE
283
284
285
286
287
288
                    </font>
                 </b>
                </td>
              </tr>
             </table>
            </td>
289
            <td align=left valign=top width=70%>
290
291
292
                <table cellpadding=5 cellspacing=0 border=0
                         bgcolor=$BANNERCOLOR>
                  <tr>
Leigh B. Stoller's avatar
Leigh B. Stoller committed
293
                   <td nowrap>
294
                     <b>
Leigh B. Stoller's avatar
Leigh B. Stoller committed
295
                       <font size=5 face=helvetica color=\"#000000\">
296
297
298
299
300
301
302
                            $THISPROJECT
                       </font>
                     </b>
                   </td>
                  <tr>
                </table>
            </td>
303
304
305
306
307
308
309
            <td align=left valign=center width=50%>
                <table cellpadding=0 cellspacing=0 border=0>
                  <tr>
                   <td nowrap align=right>\n";
    if ($login_uid && ISADMININSTRATOR()) {
	if (ISADMIN($login_uid)) {
	    echo "<a href=adminmode.php3?target_uid=$login_uid&adminoff=1>
310
311
	             <img src='/autostatus-icons/redball.gif'
                          border=0 alt='Admin On'></a>\n";
312
313
314
	}
	else {
	    echo "<a href=adminmode.php3?target_uid=$login_uid&adminoff=0>
315
316
	             <img src='/autostatus-icons/greenball.gif'
                          border=0 alt='Admin Off'></a>\n";
317
318
319
320
321
322
323
324
325
326
327
328
329
	}
    }
    else {
	echo "       <b>
                       <font size=5 face=helvetica color=\"#000000\">
                            &nbsp
                       </font>
                     </b>\n";
    }
    echo "         </td>
                  <tr>
                </table>
            </td>
330
331
332
333
334
335
336
337
338
          </tr>
          </table>\n";
}

#
# _WRITETITLE(title): write the page title for a page.
# Called by _STARTPAGE
#
function WRITETITLE($title) {
Leigh B. Stoller's avatar
Leigh B. Stoller committed
339
    global $TITLECOLOR, $BASEPATH;
340
341
342
343
    
    echo "<!-- This is the page Title -->
          <table width=\"100%\">
            <tr>
Leigh B. Stoller's avatar
Leigh B. Stoller committed
344
               <td width=\"10%\" align=left>\n";
345
346
347
                 #
                 # Insert a small logo here if you like.
                 #
Leigh B. Stoller's avatar
Leigh B. Stoller committed
348
    
349
    echo "     </td>
350
               <td align=left width=\"90%\">
Leigh B. Stoller's avatar
Leigh B. Stoller committed
351
                   <b><font size=5 color=$TITLECOLOR>$title</font></b>
352
353
354
355
356
357
358
359
360
               </td>
            </tr>
          </table>\n";
}

#
# Spit out a vanilla page header.
#
function PAGEHEADER($title) {
361
362
    global $login_status, $login_uid, $TBBASE, $TBDOCBASE, $THISHOMEBASE;
    global $BASEPATH, $SSL_PROTOCOL, $drewheader;
363
    global $TBMAINSITE;
364
365

    $drewheader = 1;
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381

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

383
    #
384
    # Figure out who is logged in, if anyone.
385
    # 
386
387
388
389
    if (($known_uid = GETUID()) != FALSE) {
        #
        # Check to make sure the UID is logged in (not timed out).
        #
390
391
392
        $login_status = CHECKLOGIN($known_uid);
	if ($login_status & (CHECKLOGIN_LOGGEDIN|CHECKLOGIN_MAYBEVALID)) {
	    $login_uid = $known_uid;
393
394
395
	}
    }

396
    #
397
398
    # Check for NOLOGINS. 
    # We want to allow admin types to continue using the web interface,
399
400
    # and logout anyone else that is currently logged in!
    #
401
402
403
404
    if (NOLOGINS() && $login_uid && !ISADMIN($login_uid)) {
	DOLOGOUT($login_uid);
	$login_status = CHECKLOGIN_NOTLOGGEDIN;
	$login_uid    = 0;
405
    }
406
    
407
408
    header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
    
409
    if (1) {
410
411
412
413
414
415
416
	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"); 
    }
417

418
419
    echo "<html>
          <head>
420
           <title>$THISHOMEBASE - $title</title>\n";
421

422
423
424
425
426
    if ($TBMAINSITE) {
	echo "  <meta NAME=\"keywords\"
                      CONTENT=\"network, emulation, internet, emulator\">
                <meta NAME=\"ROBOTS\" CONTENT=\"NOARCHIVE\">\n";
    }
427
    
428
    echo " <link rel=\"stylesheet\" href=\"$BASEPATH/tbstyle.css\"
429
430
                 type=\"text/css\">
          </head>\n";
431
    echo "<body>\n";
432
433
434
435
436
437
438
439
440
441
442
443

    WRITEBANNER($title);
    WRITETITLE($title);

    echo "<br>
          <!-- Under banner is a table with two columns: menu and content -->
          <table cellpadding=3 width=\"100%\" height=\"60%\" border=2>
          <tr>
           <!-- everthing is in a single row: two tables side-by-side -->

           <!-- MENU -->
           <td valign=top>\n";
444

445
446
447
448
449
450
    WRITESIDEBAR();

    echo " </td>

           <!-- PAGE BODY -->
           <td valign=top align=left width=\"85%\">
Leigh B. Stoller's avatar
Leigh B. Stoller committed
451

452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
               <!-- Content follows this macro ... -->\n";
}

#
# ENDPAGE(): This terminates the table started above.
# 
function ENDPAGE() {
    echo "     <!-- ... end of page content. -->
            </td>
           </tr>
          </table>
          <br>
          <hr size=2 noshade>\n";
}

#
# Spit out a vanilla page footer.
#
function PAGEFOOTER() {
471
    global $TBDOCBASE, $TBMAILADDR, $THISHOMEBASE;
Leigh B. Stoller's avatar
Leigh B. Stoller committed
472
    global $TBMAINSITE, $SSL_PROTOCOL;
473
474
475
476
477

    ENDPAGE();

    echo "<!-- Force full window! -->
	  <base target=_top>
478
          <center>[<a href=\"$TBDOCBASE\">$THISHOMEBASE Home</a>]</center>
479
480
481
482
483
          <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>
Leigh B. Stoller's avatar
Leigh B. Stoller committed
484
485
486
487
488
489
490
          <center>
           <font size=-1>
             &copy; 2000-2002 University of Utah and the Flux Group.
               <a href='$TBDOCBASE/docwrapper.php3?docname=copyright.html'>
                  All rights reserved.</a>
           </font>
          </center>
491
492
         <p align=right>
         <font size=-2>
493
494
495
496
497
          Problems? Contact $TBMAILADDR\n";

    if ($TBMAINSITE) {
	echo "<p>
              <a href=\"$TBDOCBASE/netemu.php3\"></a>\n";
Leigh B. Stoller's avatar
Leigh B. Stoller committed
498
499
500
501
502
503
504
505

	if (! isset($SSL_PROTOCOL)) {
	    echo "<a href=http://www.addme.com>
	             <img width=8 height=2
	                 src='http://www.addme.com/link8.gif'
   	                 alt='Add Me!' border=0>
	          </a>\n";
	}
506
507
508
    }

    echo "</font>
509
510
511
          </body>
          </html>\n";
}
512
513
514
515
516
517
518
519
520
521
522
523

function PAGEERROR($msg) {
    global $drewheader;

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

    echo "$msg\n";

    PAGEFOOTER();
    die("");
}
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577

#
# Sub Page/Menu Stuff
#
function WRITESUBMENUBUTTON($text, $link) {
    echo "<!-- Table row for button $text -->
          <tr>
            <td valign=center align=left nowrap>
                <b>
         	 <a class=sidebarbutton href='$link'>$text</a>\n";
    #
    # XXX these blanks look bad in lynx, but add required
    #     spacing between menu and body
    #
    echo "       &nbsp;&nbsp;\n";

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

#
# Start/End a page within a page. 
#
function SUBPAGESTART() {
    echo "<table cellspacing=2 cellpadding=2 width='85%' border=0>\n
            <tr>\n
              <td valign=top>\n";
}

function SUBPAGEEND() {
    echo "    </td>\n
            </tr>\n
          </table>\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 "      <table cellspacing=2 cellpadding=2 border=0 width=200>\n
                  <tr>\n
                    <td align=center><b>$title</b></td>\n
                  </tr>\n
                  <tr></tr>\n";
}

function SUBMENUEND() {
    echo "      </table>\n
              </td>\n
              <td valign=top align=left width='85%'>\n";
}

578
?>