deleteosid.php3 1.65 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
<?php
include("defs.php3");

#
# Standard Testbed Header
#
PAGEHEADER("Delete an OSID");

#
# Only known and logged in users can end experiments.
#
$uid = GETLOGIN();
LOGGEDINORDIE($uid);

#
# Must provide the OSID!
# 
if (!isset($osid) ||
    strcmp($osid, "") == 0) {
  USERERROR("The OSID was not provided!", 1);
}

Leigh B. Stoller's avatar
Leigh B. Stoller committed
23
if (! TBValidOSID($osid)) {
24 25 26 27
    USERERROR("The OSID `$osid' is not a valid OSID.", 1);
}

#
Leigh B. Stoller's avatar
Leigh B. Stoller committed
28
# Verify permission.
29
#
Leigh B. Stoller's avatar
Leigh B. Stoller committed
30 31
if (!TBOSIDAccessCheck($uid, $osid, $TB_OSID_DESTROY)) {
    USERERROR("You do not have permission to access OSID $osid!", 1);
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
}

#
# 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) {
    echo "<center><h2><br>
          OSID termination canceled!
          </h2></center>\n";
    
    PAGEFOOTER();
    return;
}

if (!$confirmed) {
    echo "<center><h2><br>
          Are you <b>REALLY</b>
          sure you want to delete OSID `$osid?'
          </h2>\n";
    
    echo "<form action=\"deleteosid.php3\" method=\"post\">";
    echo "<input type=hidden name=osid value=\"$osid\">\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";

    PAGEFOOTER();
    return;
}

#
# Delete the record,
#
Leigh B. Stoller's avatar
Leigh B. Stoller committed
69
DBQueryFatal("DELETE FROM os_info WHERE osid='$osid'");
70 71 72 73 74 75 76 77 78 79 80

echo "<p>
      <center><h2>
      OSID `$osid' has been deleted!
      </h2></center>\n";

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