cdromqueue.php3 3.18 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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
<?php
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2002 University of Utah and the Flux Group.
# 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 =
	DBQueryFatal("select * from cdroms where cdkey='$deletekey'");

    if (! mysql_num_rows($query_result)) {
	USERERROR("No such CDROM request!", 1);
    }
    $row   = mysql_fetch_array($query_result);
    $name  = $row[user_name];
    $email = $row[user_email];
    $when  = $row[requested];

    #
    # 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) {
        PAGEHEADER("CDROM Deletion Request");
    
        echo "<center><h2><br>
              CDROM Request deletion has been canceled!
              </h2></center>\n";

        echo "<br>
              Back to <a href=cdromqueue.php3>CDROM request queue.</a>\n";
    
        PAGEFOOTER();
        return;
    }

    if (!$confirmed) {
        PAGEHEADER("CDROM Deletion Request");

	echo "<center><h2><br>
              Are you <b>REALLY</b> sure you want to delete this CDROM request?
              </h2>\n";

	echo "<form action=cdromqueue.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 "<table align=center border=1 cellpadding=2 cellspacing=2>\n";
	echo "<tr>
  	          <td>$name</td>
  	          <td>$email</td>
	          <td>$when</td>
             </tr>\n";
	echo "</table>\n";

	PAGEFOOTER();
	return;
    }
    DBQueryFatal("delete from cdroms where cdkey='$deletekey'");
    header("Location: cdromqueue.php3");
}

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

$query_result =
    DBQueryFatal("select * from cdroms order by requested DESC");

if (! mysql_num_rows($query_result)) {
    USERERROR("There are no requests in the queue!\n", 1);
}

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

echo "<tr>
          <td>Delete?</td>
          <td>Name</td>
          <td>Email</td>
          <td>Key</td>
          <td>When</td>
      </tr>\n";

while ($row = mysql_fetch_array($query_result)) {
    $name  = $row[user_name];
    $email = $row[user_email];
    $when  = $row[requested];
    $cdkey = $row[cdkey];

    echo "<tr>
              <td align=center>
                  <A href='cdromqueue.php3?deletekey=$cdkey'>
	                  <img alt=X src=redball.gif></A>
	      <td>$name</td>
	      <td>$email</td>
	      <td>$cdkey</td>
	      <td>$when</td>
         </tr>\n";
}
echo "</table>\n";

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