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 header( "location: index.php?id=$slice_id" );
64 // if no id is set redirect back to slice index
65 if( !$_POST['id'] && !$_GET['id'] ) {
66 header( "location: index.php" );
71 require_once 'plc_drupal.php';
72 drupal_set_title('Slice Renewal');
73 include 'plc_header.php';
80 $slice_id= intval( $_GET['id'] );
82 $slice_id= intval( $_POST['id'] );
85 $slice_info= $api->GetSlices( array( $slice_id ), array( "expires", "name", "site_id", "description", "url" ) );
87 echo "<h2>Slice ". $slice_info[0]['name'] ." Renewal</h2>\n";
90 if( !empty( $slice_info[0]['site_id'] ) ) {
91 // get sliver/slice site info
92 $site_info= $api->GetSites( array( $slice_info[0]['site_id'] ), array( "max_slivers", "max_slices" ) );
94 // do not allow renew if max_slices are 0
95 if( $site_info[0]['max_slices'] <= 0 ) {
97 $site_id= $slice_info[0]['site_id'];
99 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>";
102 // else start renewal form
104 // Calculate possible extension lengths
105 $renewal_lengths = array();
106 foreach ( array( 1 => "One more week", 2 => "Two more weeks", 4 => "One more month" ) as $weeks => $text ) {
107 if ( ( $slice_info[0]['expires'] + ( $weeks * $week ) ) < $max_expiration ) {
108 $renewal_lengths[$weeks]= "$text (". gmstrftime( "%A %b-%d-%y %T %Z", $slice_info[0]['expires'] + ( $weeks * $week ) ) .")";
113 if ( empty( $renewal_lengths ) ) {
114 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";
118 $expiration_date = gmstrftime( "%A %b-%d-%y %T %Z", $slice_info[0]['expires'] );
121 echo "<form action='/db/slices/renew_slice.php' method='post'>\n";
122 echo "<input type=hidden name='id' value='$slice_id'><input type=hidden name='expires' value='". $slice_info[0]['expires'] ."'>\n";
124 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";
126 echo "<p><b>NOTE:</b> Slices cannot be renewed beyond $max_renewal_length weeks of today ($max_expiration_date).</p>\n";
128 echo "<table cellpadding=2><tbody>\n";
130 echo "<tr><th>Name:</th><td colspan=2>". $slice_info[0]['name'] ."</td></tr>\n";
133 $url_style= " style='border: 1px solid red;'";
134 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";
136 if( $error['description'] )
137 $desc_style= " style='border: 1px solid red;'";
138 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";
140 echo "<tr><th>Expiration Date: </th><td colspan=2>$expiration_date</td></tr>\n";
142 echo "<tr><th>Renewal Length: </th><td colspan=2><select name='expire_len'>";
144 // create drop down of lengths to choose
145 foreach ($renewal_lengths as $weeks => $text) {
146 echo "<option value='$weeks'";
147 if( $weeks == $expire_len )
149 echo ">$text</option>\n";
152 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";
160 echo "No data for this slice ID. Go <a href='index.php'>back</a> to slices.\n";
171 include 'plc_footer.php';