brute-force changed access to $_GET['key'] to use get_array instead
[plewww.git] / planetlab / sites / delete_site.php
1 <?php
2 // $Id$
3 //
4
5 // Require login
6 require_once 'plc_login.php';
7
8 // Get session and API handles
9 require_once 'plc_session.php';
10 global $plc, $api;
11
12 // Common functions
13 require_once 'plc_functions.php';
14
15 // Print header
16 require_once 'plc_drupal.php';
17 include 'plc_header.php';
18
19
20 // find person roles
21 $_person= $plc->person;
22 $_roles= $_person['role_ids'];
23
24
25 // if no id redirect
26 if( !get_array($_GET, 'id') ) 
27   plc_redirect (l_sites());
28
29 // set the site_id
30 $site_id= $_GET['id'];
31   
32 // delete it!
33 if( $_POST['delete'] ) {
34   $api->DeleteSite( intval( $site_id ) );
35   drupal_set_title ("Site " . $site_id . " deleted");
36   $api_error=$api->error();
37   if (!empty($error)) {
38     print '<div class="messages error">' . $api_error . '</div>';
39   } else {
40     print '<div class="messages status">';
41     print "Site " . $site_id . " deleted";
42     print "</div>";
43   }
44   echo "<p><a href='index.php'>Back to Sites</a>\n";
45  } else {
46
47
48   // get site info from api
49   $site_info= $api->GetSites( array( intval( $site_id ) ), array( "name" ) );
50   $name= $site_info[0]['name'];
51   drupal_set_title('Confirm site deletion for ' . $name);
52   
53   // start form
54   echo "<form action='delete_site.php?id=$site_id' method=post>\n";
55   
56   echo "<h2>Delete Site</h2>\n";
57   echo "Are you sure you want to delete this site?\n";
58   echo "<table><tbody>\n";
59   echo "<tr><th>Site Name: </th><td> $name </td></tr>\n";
60   echo "<tr><td colspan=2> &nbsp; </td></tr>";
61   echo "<tr><td colspan=2 align=center><input type=submit name='delete' value='Delete Site'></td></tr>\n";
62   echo "<tr><td colspan=2> &nbsp; </td></tr>";
63   echo "</tbody></table>\n";
64   
65   echo "<p><a href='index.php?id=$site_id'>Back to Site</a>\n";
66   
67   echo "</form>\n";
68  }
69   
70   
71
72 // Print footer
73 include 'plc_footer.php';
74
75 ?>