bugfix: the slice page was broken when nobody is in slice
[plewww.git] / planetlab / nodes / comon.php
index 18b2623..75cde10 100644 (file)
@@ -14,7 +14,7 @@ require_once 'plc_functions.php';
 // http://summer.cs.princeton.edu/
 // "138.96.250.12"
 function plc_ip_to_int ($ip) {
-  $bytes=array_map("intval",split("[.]",$ip));
+  $bytes=array_map("intval",explode(".",$ip));
   $res=0;
   foreach (range(0,3) as $i) {
     $res=256*$res+$bytes[$i];
@@ -46,18 +46,18 @@ function plc_comon_url_from_ips($comon_server_url, $ips) {
 
 $fields=array("hostname","node_id","peer_id", "interface_ids");
 
-if ($_GET['node_id']) {
+if (get_array($_GET, 'node_id')) {
   $node_id=intval($_GET['node_id']);
   $nodes=$api->GetNodes(array("node_id"=>array($node_id)),$fields);
- } else if ($_GET['site_id']) {
+ } else if (get_array($_GET, 'site_id')) {
   $site_id=intval($_GET['site_id']);
   $nodes=$api->GetNodes(array("node_type"=>"regular","site_id"=>array($site_id)),$fields);
- } else if ($_GET['slice_id']) {
+ } else if (get_array($_GET, 'slice_id')) {
   $slice_id=intval($_GET['slice_id']);
   $return=$api->GetSlices(array("slice_id"=>array($slice_id)),array("node_ids"));
   $node_ids=$return[0]['node_ids'];
   $nodes=$api->GetNodes(array("node_type"=>"regular","node_id"=>$node_ids),$fields);
- } else if (isset($_GET['peer_id'])) {
+ } else if (get_array($_GET, 'peer_id'))) {
   $peer_id=intval($_GET['peer_id']);
   if ( ($peer_id == 0) || ($peer_id == "") )
     $peer_id=NULL;
@@ -93,8 +93,6 @@ foreach ($nns as $nn) {
   $local_ips[] = $nn['ip'];
 }
 
-plc_debug('locals',$local_ips);
-
 // for foreign hosts we're left with dns resolving them
 $remote_ips=array();
 foreach ($hostnames as $hostname) {
@@ -106,17 +104,13 @@ foreach ($hostnames as $hostname) {
   }
 }
 
-plc_debug('remote ips',$remote_ips);
-
-
 // add both lists
 $all_ips=$local_ips+$remote_ips;
 // compute comon URL
 $url = plc_comon_url_from_ips("http://comon.cs.princeton.edu",$all_ips);
 
-plc_debug('url',$url);
 
 // redirect to comon
-header("Location: " . $url);
+plc_redirect($url);
 
 ?>