approval.php3 3.7 KB
Newer Older
1
2
3
4
5
6
<html>
<head>
<title>New User Approval</title>
<link rel='stylesheet' href='tbstyle.css' type='text/css'>
</head>
<body>
Logan Axon's avatar
Logan Axon committed
7
<?php
8
9
10
11
12
$auth_usr = "";
if ( ereg("php3\?([[:alnum:]]+)",$REQUEST_URI,$Vals) ) {
  $auth_usr=$Vals[1];
  addslashes($auth_usr);
  $query = "SELECT timeout FROM login WHERE uid=\"$auth_usr\"";
Logan Axon's avatar
Logan Axon committed
13
  $result = mysql_db_query("tbdb", $query);
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
  $n = mysql_num_rows($result);
  if ($n == 0) {
    echo "<h3>You are not logged in. Please go back to the ";
    echo "<a href=\"tbdb.html\" target=\"_top\"> Home Page </a> ";
    echo "and log in first.</h3></body></html>";
    exit;
  } else {
    $row = mysql_fetch_row($result);
    if ($row[0] < time()) { # if their login expired
      echo "<h3>You have been logged out due to inactivity.
Please log in again.</h3>\n</body></html>";
      $cmnd = "DELETE FROM login WHERE uid=\"$auth_usr\"";
      mysql_db_query("tbdb", $cmnd);
      exit;
    } else {
29
      $timeout = time() + 86400;
30
31
32
      $cmnd = "UPDATE login SET timeout=\"$timeout\" where uid=\"$auth_usr\"";
      mysql_db_query("tbdb", $cmnd);
    }
Logan Axon's avatar
Logan Axon committed
33
  }
34
35
} else {
  unset($auth_usr);
Logan Axon's avatar
Logan Axon committed
36
37
}
echo "
38
<h1>Approve new users in your Project</h1>
Jay Lepreau's avatar
Jay Lepreau committed
39
40
Use this page to approve new members of your Project.  Once approved,
they will be able to log into machines in your Project's experiments.</p>
41
42
<p> If you desire, you may set their trust/privilege levels to give them
more or less access to your nodes:
Jay Lepreau's avatar
Jay Lepreau committed
43
44
45
<ul>
	<li>User - Can log into machines in your experiments.
	<li>Local Root - Granted root access on your project's machines; can create new experiments.
46
";
47
#echo "<li>Group Root - Can approve users, create projects, and update any project info or personal info for project members.";
Jay Lepreau's avatar
Jay Lepreau committed
48
echo "</ul>
49
50
</p></h3>\n";
$query="SELECT gid FROM grp_memb WHERE uid='$auth_usr' and trust='group_root'";
Logan Axon's avatar
Logan Axon committed
51
52
53
$result = mysql_db_query("tbdb", $query);
$select = "SELECT";
while ($row = mysql_fetch_row($result)) {
54
55
56
57
58
59
60
61
62
63
64
  $gid = $row[0];
  if ($select == "SELECT") {
    $select .= " DISTINCT uid FROM grp_memb WHERE gid='$gid'";
  } else {
    $select .= " OR gid='$gid'";
  }
}
if ($select=="SELECT") {
  echo "<h3>You do not have Group Root permissions in any group.</h3>";
  echo "</body></html>\n";
  exit;
Logan Axon's avatar
Logan Axon committed
65
66
67
68
}
$selected = mysql_db_query("tbdb", $select);
$find = "SELECT";
while ($row = mysql_fetch_row($selected)) {
69
70
71
72
73
74
  $uid = $row[0];
  if ($find == "SELECT") {
    $find .= " DISTINCT uid,usr_name,usr_email,usr_addr,usr_phone FROM users WHERE (status='newuser' OR status='unapproved') AND (uid='$uid'";
  } else {
    $find .= " OR uid='$uid'";
  }
Logan Axon's avatar
Logan Axon committed
75
}
76
$find .= ")";
Logan Axon's avatar
Logan Axon committed
77
$found = mysql_db_query("tbdb", $find);
78
if ( mysql_num_rows($found) == 0 ) {
79
  echo "<h3>You have no new project members who need approval</h3>\n";
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
} else {
  echo "<table width=\"100%\" border=2 cellpadding=0 cellspacing=2 align='center'>
<tr>
<td>Action</td>
<td>Trust Level</td>
<td>User</td>
<td>Name</td>
<td>E-mail</td>
<td>Addr</td>
<td>Ph&nbsp;#</td>
</tr>
<form action='approved.php3?$auth_usr' method='post'>\n";
  while ($row = mysql_fetch_row($found)) {
    $uid = $row[0];
    $name= $row[1];
    $email=$row[2];
    $addr= $row[3];
    $phone=$row[4];
    echo "<tr><td><select name=\"$uid\">
<option value='approve'>Approve</option>
<option value='deny'>Deny</option>
<option value='later'>Postpone</option></select></td>
<td><select name=\"$uid-trust\">
<option value='user'>User</option>
104
105
106
<option value='local_root'>Local Root</option>";    
    #echo "<option value='group_root'>Group Root</option>";
    echo "</select></td>
107
108
109
110
111
112
113
114
<td>&nbsp;$uid&nbsp;</td><td>&nbsp;$name&nbsp;</td><td>&nbsp;$email&nbsp;</td>
<td>&nbsp;$addr&nbsp;</td><td>&nbsp;$phone&nbsp;</td>
</tr>\n";
  }
  echo "
<tr><td colspan=7><b><input type='submit' value='Submit' name='OK'></td></tr>
</form>
</table>\n";
Logan Axon's avatar
Logan Axon committed
115
116
117
118
}
echo "
</body>
</html>";
119
?>