4 require_once 'plc_login.php';
6 // Get session and API handles
7 require_once 'plc_session.php';
11 require_once 'plc_functions.php';
12 require_once 'plc_sorts.php';
15 $_person= $plc->person;
16 $_roles= $_person['role_ids'];
20 $week= 7 * 24 * 60 * 60; // seconds
21 $max_renewal_length= 8; // weeks from today
22 $max_expiration= mktime() + ($max_renewal_length * $week); // seconds since epoch
23 $max_expiration_date= gmstrftime("%A %b-%d-%y %T %Z", $max_expiration);
25 // if submitted validate input
26 if( $_POST['submitted'] ) {
28 $expire_len= $_POST['expire_len'];
29 $expires= $_POST['expires'];
30 $slice_id= intval( $_POST['id'] );
32 // create empty error array
38 if( $url == '' || empty( $url ) )
39 $error['url']= "Provide a link to a project website.";
41 $description= htmlspecialchars( $_POST['description'] );
42 if ( $description == '' || empty( $description ) )
43 $error['description']= "Provide a short description of the slice.";
45 // if no errors update slice info
46 if( empty( $error ) ) {
49 $expires+= ( $expire_len * $week );
51 // make slice field array
52 $slice_fields= array( "url" => $url, "description" => $description, "expires" => $expires );
55 $api->UpdateSlice( $slice_id, $slice_fields );
57 plc_redirect( l_slice($slice_id));
63 // if no id is set redirect back to slice index
64 if( !$_POST['id'] && !$_GET['id'] ) {
65 plc_redirect( l_slices());
69 require_once 'plc_drupal.php';
70 drupal_set_title('Slice Renewal');
71 include 'plc_header.php';
78 $slice_id= intval( $_GET['id'] );
80 $slice_id= intval( $_POST['id'] );
83 $slice_info= $api->GetSlices( array( $slice_id ), array( "expires", "name", "site_id", "description", "url" ) );
85 echo "<h2>Slice ". $slice_info[0]['name'] ." Renewal</h2>\n";
88 if( !empty( $slice_info[0]['site_id'] ) ) {
89 // get sliver/slice site info
90 $site_info= $api->GetSites( array( $slice_info[0]['site_id'] ), array( "max_slivers", "max_slices" ) );
92 // do not allow renew if max_slices are 0
93 if( $site_info[0]['max_slices'] <= 0 ) {
95 $site_id= $slice_info[0]['site_id'];
97 echo "<p>Slice creation and renewal have been temporarily disabled for your site. This may have occurred because your site's nodes have been down or unreachable for several weeks, and multiple attempts to contact your site's PI(s) and Technical Contact(s) have all failed. If so, contact your site's PI(s) and Technical Contact(s) and ask them to bring up your site's nodes. If you believe that your site's nodes are up and reachable. Visit your site's <a href='/db/sites/index.php?id=$site_id'>Site Details</a> page to find out more about your site's nodes, and how to contact your site's PI(s) and Technical Contact(s).</p>";
100 // else start renewal form
102 // Calculate possible extension lengths
103 $renewal_lengths = array();
104 foreach ( array( 1 => "One more week", 2 => "Two more weeks", 4 => "One more month" ) as $weeks => $text ) {
105 if ( ( $slice_info[0]['expires'] + ( $weeks * $week ) ) < $max_expiration ) {
106 $renewal_lengths[$weeks]= "$text (". gmstrftime( "%A %b-%d-%y %T %Z", $slice_info[0]['expires'] + ( $weeks * $week ) ) .")";
111 if ( empty( $renewal_lengths ) ) {
112 echo "<font color='red'>Slice cannot be renewed any further into the future, try again closer to expiration date.</font> Go <a href='index.php?id=$slice_id'>back</a> to ". $slice_info[0]['name'] .".\n";
116 $expiration_date = gmstrftime( "%A %b-%d-%y %T %Z", $slice_info[0]['expires'] );
119 echo "<form action='/db/slices/renew_slice.php' method='post'>\n";
120 echo "<input type=hidden name='id' value='$slice_id'><input type=hidden name='expires' value='". $slice_info[0]['expires'] ."'>\n";
122 echo "<p>You must provide a short description as well as a link to a project website before renewing it. Do <b>not</b> provide bogus information; if a complaint is lodged against your slice and PlanetLab Operations is unable to determine what the normal behavior of your slice is, your slice may be deleted to resolve the complaint.</p>\n";
124 echo "<p><b>NOTE:</b> Slices cannot be renewed beyond $max_renewal_length weeks of today ($max_expiration_date).</p>\n";
126 echo "<table cellpadding=2><tbody>\n";
128 echo "<tr><th>Name:</th><td colspan=2>". $slice_info[0]['name'] ."</td></tr>\n";
131 $url_style= " style='border: 1px solid red;'";
132 echo "<tr><th$url_style>URL: </th><td$url_style><input size=50 name='url' value='". $slice_info[0]['url'] ."' /></td><td$url_style><font color=red>". $error['url'] ."</font></td></tr>\n";
134 if( $error['description'] )
135 $desc_style= " style='border: 1px solid red;'";
136 echo "<tr><th$desc_style>Description: </th><td$desc_style><textarea name='description' rows=5 cols=40>". $slice_info[0]['description'] ."</textarea></td><td$desc_style><font color=red>". $error['description'] ."</font></td></tr>\n";
138 echo "<tr><th>Expiration Date: </th><td colspan=2>$expiration_date</td></tr>\n";
140 echo "<tr><th>Renewal Length: </th><td colspan=2><select name='expire_len'>";
142 // create drop down of lengths to choose
143 foreach ($renewal_lengths as $weeks => $text) {
144 echo "<option value='$weeks'";
145 if( $weeks == $expire_len )
147 echo ">$text</option>\n";
150 echo "</select></td></tr>\n<tr><td colspan=3 align=center><input type=submit value='Renew Slice' name='submitted'></td></tr>\n</tbody></table>\n";
158 echo "No data for this slice ID. Go <a href='index.php'>back</a> to slices.\n";
169 include 'plc_footer.php';