index.php3 4.9 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
<?php
#
# Beware empty spaces (cookies)!
# 
require("defs.php3");

$login_status = "";

if (isset($login)) {
    #
    # Login button pressed. 
    #
    unset($login);

    if (!isset($uid) ||
        strcmp($uid, "") == 0) {
            $login_status = "Login Failed";
	    unset($uid);
    }
    else {
        if (DOLOGIN($uid, $password)) {
            $login_status = "Login Failed";
	    unset($uid);
        }
        else {
            $login_status = "$uid Logged In";
        }
    }
}
elseif (isset($logout)) {
    #
    # Logout button pressed.
    #
    unset($logout);

    DOLOGOUT($uid);
    $login_status = "$uid Logged Out";
    unset($uid);
}
elseif (isset($uid)) {
    #
    # Check to make sure the UID is logged in (not timed out).
    #
44
    $status = CHECKLOGIN($uid);
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
    switch ($status) {
    case 0:
        $login_status = "$uid Not Logged In";
        unset($uid);
        break;
    case 1:
        $login_status = "$uid Logged In";
        break;
    case -1:
        $login_status = "$uid Login Timed Out";
        unset($uid);
        break;
    }
}
?>

61 62 63 64
<html>
<head>
<title>Utah Network Testbed</title>
<link rel='stylesheet' href='tbstyle.css' type='text/css'>
65 66 67 68 69 70 71 72

<?php
#
# So I can test on my home machine easily.
# 
echo "<base href=\"$TBBASE\" target=\"dynamic\">\n";
?>

73 74
</head>
<body>
75
<a href="welcome.html"><h3>Utah Network Testbed</h3></a>
76

77
<?php
78 79 80
if (isset($uid)) {
    echo "<hr>";
    $query_result = mysql_db_query($TBDBNAME,
81
	"SELECT status,admin FROM users WHERE uid='$uid'");
82 83
    $row = mysql_fetch_row($query_result);
    $status = $row[0];
84
    $admin  = $row[1];
85

86 87 88
    #
    # See if group_root in any projects, not just the last one in the DB!
    #
89
    $query_result = mysql_db_query($TBDBNAME,
90 91 92 93 94 95 96 97
	"SELECT trust FROM proj_memb WHERE uid='$uid' and trust='group_root'");
    if (mysql_num_rows($query_result)) {
        $trusted = 1;
    }
    else {
        $trusted = 0;
    }

98
    if ($status == "active") {
99
        if ($admin) {
100
            echo "<A href='approveproject_list.php3?uid=$uid'>
101
                     New Project Approval</A><p>\n";
102 103
            echo "<A href='nodecontrol_list.php3?uid=$uid'>
                     Node Control</A><p>\n";
104 105
        }
        if ($trusted) {
106
            # Only group leaders can do these options
107 108
            echo "<A href='approveuser_form.php3?$uid'>
                     New User Approval</A>\n";
109
        }
110
        # Since a user can be a member of more than one project,
111 112 113 114 115 116 117
        # display this option, and let the form decide if the user is
        # allowed to do this.
        echo "<p><A href='beginexp_form.php3?$uid'>
                    Begin an Experiment</A>\n";
        echo "<p><A href='endexp_form.php3?$uid'>
                    End an Experiment</A>\n";
        echo "<p><A href='showexp_form.php3?$uid'>
118
                    Experiment Information</A>\n";
119 120
        echo "<p><A href='modusr_form.php3?$uid'>
                    Update user information</A>\n";
121 122 123 124
        echo "<p><A href='reserved.php3'>
                    Node Reservation Status</A>\n";
        echo "<p><A href='http://www.cs.utah.edu/~danderse/dnard/status.html'>
                    Node Up/Down Status</A>\n";
125
        echo "</p>\n";
126
    }
127 128 129
    elseif ($status == "unapproved") {
        USERERROR("Your account has not been approved yet. ".
                  "Please try back later", 1);
130
    }
131
    elseif (($status == "newuser") || ($status == "unverified")) {
132
        echo "<A href='verifyusr_form.php3?$uid'>New User Verification</A>\n";
133 134 135 136 137
    }
    elseif (($status == "frozen") || ($status == "other")) {
        USERERROR("Your account has been changed to status $status, and is ".
                  "currently unusable. Please contact your project leader ".
                  "to find out why.", 1);
138
    }
139
}
140 141 142 143 144

#
# Standard options for anyone.
# 
if (isset($uid)) {
145
    echo "<p><A href=\"newproject_form.php3?$uid\">Start a Project</A>\n";
146 147 148
    echo "<p><A href=\"addusr.php3?$uid\">Join a Project</A>\n";
}
else {
149
    echo "<p><A href=\"newproject_form.php3\">Start a Project</A>\n";
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166
    echo "<p><A href=\"addusr.php3\">Join a Project</A>\n";
}
echo "<hr>";
echo "<table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">";
echo "<form action=\"index.php3\" method=\"post\" target=\"fixed\">";

echo "<b>$login_status</b>";
#
# Present either a login box, or a logout box
# 
if (isset($uid)) {
    echo "<tr>
              <td><input type='hidden' name='uid' value='$uid'</td>
              <td align='center'>
                  <b><input type='submit' value='Logout' name='logout'></b>
              </td>
          </tr>\n";
Mac Newbold's avatar
Mac Newbold committed
167
}
168 169 170 171 172
else {
    echo "<tr>
              <td>Username:<input type='text' name='uid' size=8></td>
          </tr>
          <tr>
173
              <td>Password:<input type='password' name='password' size=12></td>
174 175 176 177 178
          </tr>
          <tr>
              <td align='center'>
                  <b><input type='submit' value='Login' name='login'></b></td>
          </tr>\n";
179 180 181 182 183 184
}
?>
</form>
</table>
</body>
</html>