wideareakeys.php3 4.72 KB
Newer Older
1 2 3
<?php
#
# EMULAB-COPYRIGHT
4
# Copyright (c) 2000-2004, 2006, 2007 University of Utah and the Flux Group.
5 6 7 8 9 10 11
# All rights reserved.
#
include("defs.php3");

#
# Only known and logged in users can do this.
#
12 13 14
$this_user = CheckLoginOrDie();
$uid       = $this_user->uid();
$isadmin   = ISADMIN();
15 16 17 18 19

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

20 21 22 23 24 25 26
#
# Verify Page arguments
#
$optargs = OptionalPageArguments("deletekey",  PAGEARG_STRING,
				 "canceled",   PAGEARG_STRING,
				 "confirmed",  PAGEARG_STRING);

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

    if (! mysql_num_rows($query_result)) {
37
	USERERROR("No such widearea private key!", 1);
38
    }
39
    $row     = mysql_fetch_array($query_result);
40 41 42 43 44
    $name    = $row["user_name"];
    $email   = $row["user_email"];
    $when    = $row["requested"];
    $IP      = $row["IP"];
    $nodeid  = $row["node_id"];
45 46 47 48 49 50 51

    #
    # 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.
    #
52
    if (isset($canceled) && $canceled) {
53
        PAGEHEADER("Widearea Private Key Deletion Request");
54 55
    
        echo "<center><h2><br>
56
              Widearea Private Key deletion has been canceled!
57 58 59
              </h2></center>\n";

        echo "<br>
60
              Back to <a href=wideareakeys.php3>Back to Widearea Keys.</a>\n";
61 62 63 64 65
    
        PAGEFOOTER();
        return;
    }

66
    if (!isset($confirmed)) {
67
        PAGEHEADER("Widearea Private Key Deletion Request");
68

69
	echo "<center><h3><br>
70
              Are you <b>REALLY</b> sure you want to delete this Key?<br>
71
              </h3>\n";
72 73 74 75
	echo "</center>\n";

	echo "<table align=center border=1 cellpadding=2 cellspacing=2>\n";
	echo "<tr>
76 77 78
  	          <td>$name</td>
  	          <td>$email</td>
  	          <td>$IP</td>
79
  	          <td>$nodeid</td>
80
	          <td>$when</td>
81 82 83
             </tr>\n";
	echo "</table>\n";

84 85 86 87 88 89 90 91 92 93 94 95 96 97
	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";

98 99 100
	PAGEFOOTER();
	return;
    }
101
    DBQueryFatal("delete from widearea_privkeys where privkey='$deletekey'");
102 103

    if (isset($nodeid) && $nodeid) {
104 105
	$retval = SUEXEC($uid, $TBADMINGROUP, "webdeletenode -b $nodeid",
			 SUEXEC_ACTION_DIE);
106
    }
107
    header("Location: wideareakeys.php3");
108 109 110 111 112 113 114 115 116 117 118
}

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

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

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

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

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

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

    echo "<tr>
              <td align=center>
155
                  <A href='wideareakeys.php3?deletekey=$privkey'>
156 157 158 159 160 161 162 163 164 165 166 167
	                  <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>
168
	      <td align=center>$cdvers</td>
169
	      <td>$requested</td>
170 171 172 173 174 175 176 177 178 179
	      <td>$updated</td>
         </tr>\n";
}
echo "</table>\n";

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