wideareakeys.php3 4.87 KB
Newer Older
1
2
3
<?php
#
# EMULAB-COPYRIGHT
4
# Copyright (c) 2000-2003 University of Utah and the Flux Group.
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# All rights reserved.
#
include("defs.php3");
include("showstuff.php3");

#
# Only known and logged in users can do this.
#
$uid = GETLOGIN();
LOGGEDINORDIE($uid);
$isadmin = ISADMIN($uid);

if (!$isadmin) {
    USERERROR("You do not have permission to view this page!", 1);
}

if (isset($deletekey)) {
    #
    # Get the actual key.
    #
    $query_result =
26
27
	DBQueryFatal("select wa.*,i.node_id from widearea_privkeys as wa ".
		     "left join interfaces as i on wa.IP=i.IP ".
28
		     "where privkey='$deletekey'");
29
30

    if (! mysql_num_rows($query_result)) {
31
	USERERROR("No such widearea private key!", 1);
32
    }
33
34
35
36
37
38
    $row     = mysql_fetch_array($query_result);
    $name    = $row[user_name];
    $email   = $row[user_email];
    $when    = $row[requested];
    $IP      = $row[IP];
    $nodeid  = $row[node_id];
39
40
41
42
43
44
45
46

    #
    # We run this twice. The first time we are checking for a confirmation
    # by putting up a form. The next time through the confirmation will be
    # set. Or, the user can hit the cancel button, in which case we should
    # Probably redirect the browser back up a level.
    #
    if ($canceled) {
47
        PAGEHEADER("Widearea Private Key Deletion Request");
48
49
    
        echo "<center><h2><br>
50
              Widearea Private Key deletion has been canceled!
51
52
53
              </h2></center>\n";

        echo "<br>
54
              Back to <a href=wideareakeys.php3>Back to Widearea Keys.</a>\n";
55
56
57
58
59
60
    
        PAGEFOOTER();
        return;
    }

    if (!$confirmed) {
61
        PAGEHEADER("Widearea Private Key Deletion Request");
62

63
	echo "<center><h3><br>
64
              Are you <b>REALLY</b> sure you want to delete this Key?<br>
65
              </h3>\n";
66
67
68
69
	echo "</center>\n";

	echo "<table align=center border=1 cellpadding=2 cellspacing=2>\n";
	echo "<tr>
70
71
72
  	          <td>$name</td>
  	          <td>$email</td>
  	          <td>$IP</td>
73
  	          <td>$nodeid</td>
74
	          <td>$when</td>
75
76
77
             </tr>\n";
	echo "</table>\n";

78
79
80
81
82
83
84
85
86
87
88
89
90
91
	echo "<center>\n";
 	echo "<form action=wideareakeys.php3 method=post>";
	echo "<input type=hidden name=deletekey value=$deletekey>\n";
	echo "<b><input type=submit name=confirmed value=Confirm></b>\n";
	echo "<b><input type=submit name=canceled value=Cancel></b>\n";
	echo "</form>\n";
	echo "</center>\n";

	echo "<br><font color=red>
              This will delete all trace including the node, vnodes, and
              interface table entries. Needless to say, deleting a key
              record of an active widearea node is a bad thing. Be sure!
              </font>\n";

92
93
94
	PAGEFOOTER();
	return;
    }
95
    DBQueryFatal("delete from widearea_privkeys where privkey='$deletekey'");
96
97
98
99
100
101
102

    if (isset($nodeid) && $nodeid) {
	DBQueryFatal("delete from widearea_nodeinfo where node_id='$nodeid'");
	DBQueryFatal("delete from widearea_accounts where node_id='$nodeid'");
	DBQueryFatal("delete from interfaces where node_id='$nodeid'");
	DBQueryFatal("delete from nodes where node_id='$nodeid'");
	DBQueryFatal("delete from nodes where phys_nodeid='$nodeid'");
103
	DBQueryFatal("delete from node_status where node_id='$nodeid'");
104
105
	DBQueryFatal("delete from reserved where node_id='$nodeid'");
    }
106
    header("Location: wideareakeys.php3");
107
108
109
110
111
112
113
114
115
116
117
}

#
# Get the list and show it.
#
#
# Standard Testbed Header, now that we know what we want to say.
#
PAGEHEADER("Widearea Private Keys");

$query_result =
118
119
    DBQueryFatal("select wa.*,i.node_id,cd.version ".
		 " from widearea_privkeys as wa ".
120
		 "left join interfaces as i on wa.IP=i.IP ".
121
		 "left join cdroms as cd on wa.cdkey=cd.cdkey ".
122
		 "order by requested DESC");
123
124

if (! mysql_num_rows($query_result)) {
125
    USERERROR("There are no widearea private keys!\n", 1);
126
127
128
129
130
131
}

echo "<table align=center border=1 cellpadding=2 cellspacing=2>\n";

echo "<tr>
          <td>Delete?</td>
132
133
          <td>Name</td>
          <td>Email</td>
134
          <td>IP</td>
135
136
          <td>Node</td>
          <td>Key</td>
137
	  <td>CD</td>
138
          <td>Requested</td>
139
140
141
142
          <td>Updated</td>
      </tr>\n";

while ($row = mysql_fetch_array($query_result)) {
143
144
145
    $name    = $row[user_name];
    $email   = $row[user_email];
    $requested = $row[requested];
146
    $updated  = $row[updated];
147
148
149
    $privkey = $row[privkey];
    $IP      = $row[IP];
    $nodeid  = $row[node_id];
150
    $cdvers  = $row[version];
151
152
153

    echo "<tr>
              <td align=center>
154
                  <A href='wideareakeys.php3?deletekey=$privkey'>
155
156
157
158
159
160
161
162
163
164
165
166
	                  <img alt=X src=redball.gif></A></td>
	      <td>$name</td>
	      <td>$email</td>
	      <td>$IP</td>\n";

    if (isset($nodeid)) {
	echo "<td><A href='shownode.php3?node_id=$nodeid'>$nodeid</a></td>\n";
    }
    else {
	echo "<td>&nbsp</td>\n";
    }
    echo "    <td>$privkey</td>
167
	      <td align=center>$cdvers</td>
168
	      <td>$requested</td>
169
170
171
172
173
174
175
176
177
178
	      <td>$updated</td>
         </tr>\n";
}
echo "</table>\n";

#
# Standard Testbed Footer
# 
PAGEFOOTER();
?>