GetNodes(array("node_id"=>array($node_id)),$fields); } 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_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 (get_array($_GET, 'peer_id'))) { $peer_id=intval($_GET['peer_id']); if ( ($peer_id == 0) || ($peer_id == "") ) $peer_id=NULL; $nodes=$api->GetNodes(array("node_type"=>"regular","peer_id"=>$peer_id),$fields); } else { echo "
Unexpected args in comon.php
\n"; exit(); } // first pass // * gather interface_ids for local nodes // * gather hostnames for foreign nodes $interface_ids=array(); $hostnames = array(); foreach ($nodes as $node) { if (empty($node['peer_id'])) { foreach ($node['interface_ids'] as $id=>$nnid) { $interface_ids [] = $nnid; } } else { $hostnames[] = $node['hostname']; } } // Gather local ips from primary interfaces // fetch primary interfaces $local_ips=array(); $nns = $api->GetInterfaces(array("is_primary"=>TRUE,"interface_id"=>$interface_ids), array("ip")); foreach ($nns as $nn) { $local_ips[] = $nn['ip']; } // for foreign hosts we're left with dns resolving them $remote_ips=array(); foreach ($hostnames as $hostname) { $resolved=gethostbyname($hostname); // no way to notify this if ($resolved == $hostname) { } else { $remote_ips[] = $resolved; } } // 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); // redirect to comon plc_redirect($url); ?>