query("SELECT ip, location.id as locid,location.name as locname, node.name as nodename FROM ip, node, location WHERE ip.node_id = node.id and node.location_id=location.id"); while ($data = $db->getNextObject()) { $locids[$data->ip]= $data->locid; $nodename[$data->ip]= $data->nodename; } if($conf['acl']['auth']) $db->query("SELECT id as locid, name as locname, pixel_x, pixel_y, gallery_link, location.hastinc as hastinc FROM location ORDER BY name ASC"); else $db->query("SELECT id as locid, name as locname, pixel_x, pixel_y, gallery_link, location.hastinc as hastinc FROM location WHERE location.hidden = 0 ORDER BY name ASC"); while ($data = $db->getNextObject()) { if ($data->pixel_x == "0") continue; $data->lng = $lng_startpoint + ($data->pixel_x - $x_startpoint) / $dx_dLng; $data->lat = $lat_startpoint + ($y_startpoint - $data->pixel_y) / $dy_dLat; $data->state = "offline"; $locations[$data->locid] = $data; } $regmatch = '#\"(.+)\" -> \"(.+)\"\[label=\"([0-9]+.[0-9]+)\"]#'; $lines = file($conf['topo']['file']); $linecnt=0; $i =0; foreach ($lines as $num => $line) { $linecnt++; preg_match($regmatch,$line,$matches); list( , $ipfromLoc, $iptoLoc, $label) = $matches; if (empty($ipfromLoc) || empty($iptoLoc) || empty($label)) continue; if(empty($locations[$locids[$ipfromLoc]]->locid) || empty($locations[$locids[$iptoLoc]]->locid)) continue; if($locations[$locids[$ipfromLoc]]->locid == $locations[$locids[$iptoLoc]]->locid) continue; if($already[$locations[$locids[$ipfromLoc]]->locid . '-' . $locations[$locids[$iptoLoc]]->locid]->used == true) { $jot = $already[$locations[$locids[$ipfromLoc]]->locid . '-' . $locations[$locids[$iptoLoc]]->locid]->i; if($links[$jot]->label != -1) $links[$jot]->label = ($links[$jot]->label + $label)/2; } elseif($already[$locations[$locids[$iptoLoc]]->locid . '-' . $locations[$locids[$ipfromLoc]]->locid]->used == true) { $jot = $already[$locations[$locids[$iptoLoc]]->locid . '-' . $locations[$locids[$ipfromLoc]]->locid]->i; if($links[$jot]->label != -1) $links[$jot]->label = ($links[$jot]->label + $label)/2; } else { $already[$locations[$locids[$ipfromLoc]]->locid . '-' . $locations[$locids[$iptoLoc]]->locid]->used = true; $already[$locations[$locids[$ipfromLoc]]->locid . '-' . $locations[$locids[$iptoLoc]]->locid]->i = $i; $links[$i]->ipfromLoc = $ipfromLoc; $links[$i]->iptoLoc = $iptoLoc; if($links[$i]->label != -1) $links[$i]->label = $label; if($locations[$locids[$ipfromLoc]]->state == "offline") $locations[$locids[$ipfromLoc]]->state = "online"; if($locations[$locids[$iptoLoc]]->state == "offline") $locations[$locids[$iptoLoc]]->state = "online"; if (($nodename[$ipfromLoc] == "tunnel" && $locations[$locids[$ipfromLoc]]->locname=="housing") || ($nodename[$iptoLoc] == "tunnel" && $locations[$locids[$iptoLoc]]->locname=="housing" ) || ($locations[$locids[$iptoLoc]]->hastinc && $locations[$locids[$ipfromLoc]]->hastinc)) { $links[$i]->label = -1; $locations[$locids[$ipfromLoc]]->state = "tunnel"; $locations[$locids[$iptoLoc]]->state = "tunnel"; } $i++; } } echo "\n"; echo "\n"; echo "\n"; foreach ($locations as $location) { $data = $locations[$location->locid]; printf("\t" . '' . "\n", $data->locid, $data->locname, $data->lat, $data->lng, $data->pixel_x, $data->pixel_y, $data->state, $data->gallery_link); } echo "\n"; echo "\n"; foreach ($links as $link) { $data1 = $locations[$locids[$link->ipfromLoc]]; $data2 = $locations[$locids[$link->iptoLoc]]; $count[$data1->locid]=true; $count[$data2->locid]=true; printf("\t" . '' . "\n", $data1->locid, $data1->locname, $data1->lat,$data1->lng,$data2->locid, $data2->locname, $data2->lat, $data2->lng, $link->label); } echo "\n"; echo "\n"; printf("\t" . '' . "\n"); echo "\n"; echo ""; ?>