dismantle former migration status
[plewww.git] / planetlab / sites / expire.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
13 // Common functions
14 require_once 'plc_functions.php';
15 require_once 'plc_sorts.php';
16
17 // find person roles
18 $_person= $plc->person;
19 $_roles= $_person['role_ids'];
20
21
22 // if no site id redirect
23 if( !$_GET['id'] ) {
24   header( "location: index.php" );
25   exit();
26  }
27
28 // get site id
29 $site_id= $_GET['id'];
30
31 // get site info
32 $site_info= $api->GetSites( array( intval( $site_id ), array( "name", "url", "longitude", "latitude", "login_base", "max_slices", "abbreviated_name", "slice_ids" ) );
33
34 // if submitted expire
35 if( $_POST['action'] ) {
36   $expiration= strtotime( $_POST['expires'] );
37   
38   // loop through all slices for site
39   foreach( $site_info[0]['slice_ids'] as $slice_id ) {
40     $fields= array( "expires" => $expiration );
41     // update all slice's expiration
42     $api->UpdateSlice( $slice_id, $fields );
43   
44   }
45   
46   // update site to not allow slice creation or renewal
47   $site_fields= array( "max_slices" => 0 );
48   $api->UpdateSite( $site_id, $site_fields );
49
50 }
51
52
53 // Print header
54 require_once 'plc_drupal.php';
55 drupal_set_title('Sites');
56 include 'plc_header.php';
57
58 // start form
59 echo "<form method=post action='expire.php?id=$site_id'>\n";
60 echo "<h2>Expire ". $site_info[0]['name'] ."</h2>\n";
61 echo "<b>Expiration:</b>&nbsp;<input name='expires' value='2 days' />\n";
62 echo "<p>Are you sure you want to set the expiration date for all slices that expire after the above date to the above date as well as disable slice creation and renewal at this site?</p>\n";
63 echo "<input type=submit name='action' value='Yes' />\n";
64
65 echo "<p><a href='index.php?id=$site_id'>Back to Site</a>\n";
66
67
68 echo "</form>\n";
69
70
71 // Print footer
72 include 'plc_footer.php';
73
74 ?>