deleteproject.php3 2.86 KB
Newer Older
1
<?php
Leigh Stoller's avatar
Leigh Stoller committed
2 3
#
# EMULAB-COPYRIGHT
4
# Copyright (c) 2000-2003 University of Utah and the Flux Group.
Leigh Stoller's avatar
Leigh Stoller committed
5 6
# All rights reserved.
#
7 8 9 10 11
include("defs.php3");

#
# Standard Testbed Header
#
12
PAGEHEADER("Terminating Project and Remove all Trace");
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30

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

#
# Currently, only admin users can do this. Change later.
#
$isadmin = ISADMIN($uid);
if (! $isadmin) {
    USERERROR("You do not have permission to remove project '$pid'", 1);
}

#
# Confirm a real project
#
31 32
if (! TBValidProject($pid)) {
    USERERROR("No such project '$pid'", 1);
33 34 35 36 37
}

#
# Check to see if there are any active experiments. Abort if there are.
#
Leigh Stoller's avatar
Leigh Stoller committed
38 39
$query_result =
    DBQueryFatal("SELECT * FROM experiments where pid='$pid'");
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
if (mysql_num_rows($query_result)) {
    USERERROR("Project '$pid' has active experiments. You must terminate ".
	      "those experiments before you can remove the project!", 1);
}

#
# 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>
          Project removal canceled!
          </h2></center>\n";
    
    PAGEFOOTER();
    return;
}

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

if (!$confirmed_twice) {
    echo "<center><h2>
	  Okay, lets be sure.<br>
          Are you <b>REALLY REALLY</b> sure you want to remove Project '$pid?'
          </h2>\n";
    
    echo "<form action=\"deleteproject.php3\" method=\"post\">";
    echo "<input type=hidden name=pid value=\"$pid\">\n";
    echo "<input type=hidden name=confirmed value=Confirm>\n";
    echo "<b><input type=submit name=confirmed_twice value=Confirm></b>\n";
    echo "<b><input type=submit name=canceled value=Cancel></b>\n";
    echo "</form>\n";
    echo "</center>\n";

    PAGEFOOTER();
    return;
}

94 95 96 97 98 99
echo "<br>
      Project '$pid' is being removed!<br><br>
      This will take a minute or two. <b>Please</b> do not click the Stop
      button during this time. If you do not receive notification within
      a reasonable amount of time, please contact $TBMAILADDR.<br>\n";
flush();
100

101 102 103
#
# Remove the project directory and the group.
#
104
SUEXEC($uid, $TBADMINGROUP, "rmproj $pid", 1);
105 106 107 108

#
# Warm fuzzies.
#
109 110 111
echo "<br>
      <b>Done!</b>
      <br>\n";
112 113 114 115 116 117

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