menu.php3 15.1 KB
Newer Older
1 2
<?php

3
$login_status     = CHECKLOGIN_NOTLOGGEDIN;
4
$login_uid        = 0;
5
$drewheader       = 0;
6

7 8 9 10 11 12
#
# 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	  = "";

13 14 15 16 17 18
#
# 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) {
19
    $link = "$base/$link";
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
    
    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() {
42 43
    global $login_status, $login_uid;
    global $TBBASE, $TBDOCBASE, $BASEPATH;
44
    global $THISHOMEBASE;
45 46 47

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

51
    WRITESIDEBARBUTTON("Home", $TBDOCBASE, "index.php3");
52 53
    WRITESIDEBARBUTTON("Tutorial at SIGCOMM'02 <img src=/new.gif>",
		       $TBDOCBASE, "sc2002tut.php3");
Leigh B. Stoller's avatar
Leigh B. Stoller committed
54
    WRITESIDEBARBUTTON("News (<img src=/new.gif> Apr 19)", $TBDOCBASE,
55
		       "docwrapper.php3?docname=news.html");
56 57
    WRITESIDEBARBUTTON("Tutorial", $TBDOCBASE, "tutorial/tutorial.php3");
    WRITESIDEBARBUTTON("FAQ", $TBDOCBASE, "faq.php3");
58
    WRITESIDEBARBUTTON("Documentation", $TBDOCBASE, "doc.php3");
59
    WRITESIDEBARBUTTON("Search Documentation", $TBDOCBASE, "search.php3");
60
    WRITESIDEBARBUTTON("Publications", $TBDOCBASE, "pubs.php3");
61
    WRITESIDEBARBUTTON("People", $TBDOCBASE, "people.php3");
62
    WRITESIDEBARBUTTON("The Gallery", $TBDOCBASE, "gallery/gallery.php3");
63
    WRITESIDEBARBUTTON("Projects Using $THISHOMEBASE", $TBDOCBASE,
64
		       "projectlist.php3");
65 66 67 68

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

71 72 73
    if ($login_status & (CHECKLOGIN_LOGGEDIN|CHECKLOGIN_MAYBEVALID)) {
	$freepcs = TBFreePCs();
	
74 75 76
	echo "    <br>($freepcs Free PCs)\n";
    }
    echo "      </span>
77 78 79 80
             </b>
            </td>
          </tr>\n";

81 82 83 84 85 86 87 88
    #
    # 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>",
89 90
			   $TBDOCBASE, "nologins.php3");

91 92 93 94 95 96 97 98 99
	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";
100
	}
101 102 103 104 105 106
    }
    if ($login_status & (CHECKLOGIN_LOGGEDIN|CHECKLOGIN_MAYBEVALID)) {
	if ($login_status & CHECKLOGIN_ACTIVE) {
	    if ($login_status & CHECKLOGIN_PSWDEXPIRED) {
		WRITESIDEBARBUTTON("Change your Password",
				   $TBBASE, "moduserinfo.php3");
107
	    }
108 109 110 111
	    else {
		WRITESIDEBARBUTTON("My $THISHOMEBASE",
				   $TBBASE,
				   "showuser.php3?target_uid=$login_uid");
112
	    
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
		if ($login_status & CHECKLOGIN_ISADMIN) {
		    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.
                #
		WRITESIDEBARBUTTON("Project Information",
				   $TBBASE, "showproject_list.php3");
130
	    
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
		if ($login_status & CHECKLOGIN_ISADMIN) {
		    WRITESIDEBARBUTTON("User List",
				       $TBBASE, "showuser_list.php3");
		    WRITESIDEBARBUTTON("Node Control",
				       $TBBASE, "nodecontrol_list.php3");
		}
	    
		WRITESIDEBARBUTTON("Begin an Experiment",
				   $TBBASE, "beginexp.php3");
		WRITESIDEBARBUTTON("Experiment Information",
				   $TBBASE, "showexp_list.php3");
		WRITESIDEBARBUTTON("Update user information",
				   $TBBASE, "moduserinfo.php3");
		WRITESIDEBARBUTTON("Node Reservation Status",
				   $TBBASE, "reserved.php3");
		WRITESIDEBARBUTTON("Node Up/Down Status",
				   $TBDOCBASE, "updown.php3");
		
		if ($login_status & CHECKLOGIN_CVSWEB) {
		    WRITESIDEBARBUTTON("CVS Repository",
				       $TBBASE, "cvsweb/cvsweb.php3");
		}
153
	    }
154
	}
155
	elseif ($login_status & (CHECKLOGIN_UNVERIFIED|CHECKLOGIN_NEWUSER)) {
156 157
	    WRITESIDEBARBUTTON("New User Verification",
			       $TBBASE, "verifyusr_form.php3");
158 159
	    WRITESIDEBARBUTTON("Update user information",
			       $TBBASE, "moduserinfo.php3");
160
	}
161 162 163
	elseif ($login_status & (CHECKLOGIN_UNAPPROVED)) {
	    WRITESIDEBARBUTTON("Update user information",
			       $TBBASE, "moduserinfo.php3");
164 165 166 167 168
	}
    }
    #
    # Standard options for anyone.
    #
169
    if (! NOLOGINS()) {
170 171
	WRITESIDEBARBUTTON("Start Project", $TBBASE, "newproject.php3");
	WRITESIDEBARBUTTON("Join Project",  $TBBASE, "joinproject.php3");
172
    }
173

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

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

220 221 222 223 224 225 226 227 228 229 230
    if ($login_message) {
	echo "<tr>
                <td align=center>
                 <b>
                   <span class=sidebarbutton>
                      $login_message
                   </span>
                 <b>
                </td>
              </tr>\n";
    }
231

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

#
# WRITEBANNER(): write the page banner for a page.
# Called by _STARTPAGE
#
function WRITEBANNER($title) {
263
    global $BANNERCOLOR, $THISPROJECT, $THISHOMEBASE, $BASEPATH;
264 265

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

    echo "<table cellpadding=0 cellspacing=0 border=0 width=50%>";
268
    echo "<tr>
Leigh B. Stoller's avatar
Leigh B. Stoller committed
269
            <td align=left valign=top width=\"0%\">
270 271 272
             <table cellpadding=5 cellspacing=0 border=0 bgcolor=\"#880000\">
              <tr>
                <td>
Leigh B. Stoller's avatar
Leigh B. Stoller committed
273
                 <b><font size=5 color=white face=Helvetica>
274
                        $THISHOMEBASE
275 276 277 278 279 280
                    </font>
                 </b>
                </td>
              </tr>
             </table>
            </td>
Leigh B. Stoller's avatar
Leigh B. Stoller committed
281
            <td align=left valign=top width=100%>
282 283 284
                <table cellpadding=5 cellspacing=0 border=0
                         bgcolor=$BANNERCOLOR>
                  <tr>
Leigh B. Stoller's avatar
Leigh B. Stoller committed
285
                   <td nowrap>
286
                     <b>
Leigh B. Stoller's avatar
Leigh B. Stoller committed
287
                       <font size=5 face=helvetica color=\"#000000\">
288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303
                            $THISPROJECT
                       </font>
                     </b>
                   </td>
                  <tr>
                </table>
            </td>
          </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
304
    global $TITLECOLOR, $BASEPATH;
305 306 307 308
    
    echo "<!-- This is the page Title -->
          <table width=\"100%\">
            <tr>
Leigh B. Stoller's avatar
Leigh B. Stoller committed
309
               <td width=\"10%\" align=left>\n";
310 311 312
                 #
                 # Insert a small logo here if you like.
                 #
Leigh B. Stoller's avatar
Leigh B. Stoller committed
313
    
314 315
    echo "     </td>
               <td align=left>
Leigh B. Stoller's avatar
Leigh B. Stoller committed
316
                   <b><font size=5 color=$TITLECOLOR>$title</font></b>
317 318 319 320 321 322 323 324 325
               </td>
            </tr>
          </table>\n";
}

#
# Spit out a vanilla page header.
#
function PAGEHEADER($title) {
326 327
    global $login_status, $login_uid, $TBBASE, $TBDOCBASE, $THISHOMEBASE;
    global $BASEPATH, $SSL_PROTOCOL, $drewheader;
328
    global $TBMAINSITE;
329 330

    $drewheader = 1;
331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346

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

348
    #
349
    # Figure out who is logged in, if anyone.
350
    # 
351 352 353 354
    if (($known_uid = GETUID()) != FALSE) {
        #
        # Check to make sure the UID is logged in (not timed out).
        #
355 356 357
        $login_status = CHECKLOGIN($known_uid);
	if ($login_status & (CHECKLOGIN_LOGGEDIN|CHECKLOGIN_MAYBEVALID)) {
	    $login_uid = $known_uid;
358 359 360
	}
    }

361
    #
362 363
    # Check for NOLOGINS. 
    # We want to allow admin types to continue using the web interface,
364 365
    # and logout anyone else that is currently logged in!
    #
366 367 368 369
    if (NOLOGINS() && $login_uid && !ISADMIN($login_uid)) {
	DOLOGOUT($login_uid);
	$login_status = CHECKLOGIN_NOTLOGGEDIN;
	$login_uid    = 0;
370
    }
371
    
372 373
    header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
    
374
    if (1) {
375 376 377 378 379 380 381
	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"); 
    }
382

383 384
    echo "<html>
          <head>
385
           <title>$THISHOMEBASE - $title</title>\n";
386

387 388 389 390 391
    if ($TBMAINSITE) {
	echo "  <meta NAME=\"keywords\"
                      CONTENT=\"network, emulation, internet, emulator\">
                <meta NAME=\"ROBOTS\" CONTENT=\"NOARCHIVE\">\n";
    }
392
    
393
    echo " <link rel=\"stylesheet\" href=\"$BASEPATH/tbstyle.css\"
394 395
                 type=\"text/css\">
          </head>\n";
396
    echo "<body>\n";
397 398 399 400 401 402 403 404 405 406 407 408

    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";
409

410 411 412 413 414 415
    WRITESIDEBAR();

    echo " </td>

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

417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435
               <!-- 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() {
436
    global $TBDOCBASE, $TBMAILADDR, $THISHOMEBASE;
Leigh B. Stoller's avatar
Leigh B. Stoller committed
437
    global $TBMAINSITE, $SSL_PROTOCOL;
438 439 440 441 442

    ENDPAGE();

    echo "<!-- Force full window! -->
	  <base target=_top>
443
          <center>[<a href=\"$TBDOCBASE\">$THISHOMEBASE Home</a>]</center>
444 445 446 447 448 449 450
          <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>
451 452 453 454 455
          Problems? Contact $TBMAILADDR\n";

    if ($TBMAINSITE) {
	echo "<p>
              <a href=\"$TBDOCBASE/netemu.php3\"></a>\n";
Leigh B. Stoller's avatar
Leigh B. Stoller committed
456 457 458 459 460 461 462 463

	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";
	}
464 465 466
    }

    echo "</font>
467 468 469
          </body>
          </html>\n";
}
470 471 472 473 474 475 476 477 478 479 480 481

function PAGEERROR($msg) {
    global $drewheader;

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

    echo "$msg\n";

    PAGEFOOTER();
    die("");
}
482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535

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

536
?>