Index: html/map.php =================================================================== --- html/map.php (revision 5954) +++ html/map.php (working copy) @@ -72,8 +72,7 @@ # foreach (dbFetch("SELECT * from devices ".$where) as $device) # foreach (dbFetch("SELECT D.*, COUNT(L.local_port_id) FROM devices AS D LEFT JOIN (ports AS I, links AS L) ON (D.device_id = I.device_id AND I.port_id = L.local_port_id) ". $where. " GROUP BY D.hostname ORDER BY COUNT(L.local_port_id) DESC".$where) as $device) - foreach (dbFetch("SELECT D.*, COUNT(L.local_port_id) FROM devices AS D LEFT JOIN (ports AS I, links AS L) ON (D.device_id = I.device_id AND I.port_id = L.local_port_id) ". $where. " - GROUP BY D.hostname ORDER BY COUNT(L.local_port_id) DESC") as $device) + foreach (dbFetch("SELECT D.*, COUNT(L.local_port_id) FROM devices AS D LEFT JOIN (ports AS I, links AS L) ON (D.device_id = I.device_id AND I.port_id = L.local_port_id) ". $where. " GROUP BY D.hostname ORDER BY COUNT(L.local_port_id) DESC") as $device) { if ($device) { @@ -92,10 +91,10 @@ #$loc_id = $locations[$device['location']]; $loc_id = '"'.$ranktype.'"'; - $map .= "\"".$device['hostname']."\" [fontsize=20, fillcolor=\"lightblue\", group=".$loc_id." URL=\"{$config['base_url']}/device/device=".$device['device_id']."/tab=ports/view=map/\" shape=box3d]\n"; + $map .= "\"".$device['hostname']."\" [fontsize=20, fillcolor=\"lightblue\", group=".$loc_id." URL=\"".generate_url(array('page' => 'device', 'device' => $device['device_id'],'tab' => 'ports', 'view' => 'map'))."\" shape=box3d]\n"; } - foreach ($links as $link) + foreach ($links as $link) { $local_port_id = $link['local_port_id']; $remote_port_id = $link['remote_port_id']; @@ -126,8 +125,9 @@ if ($anon) { $src = md5($src); } if ($remote_port_id) { - $dst = dbFetchCell("SELECT `hostname` FROM `devices` AS D, `ports` AS I WHERE I.port_id = ? AND D.device_id = I.device_id", array($remote_port_id)); - $dst_host = dbFetchCell("SELECT D.device_id FROM `devices` AS D, `ports` AS I WHERE I.port_id = ? AND D.device_id = I.device_id", array($remote_port_id)); + $dst_query = dbFetchRow("SELECT D.device_id, hostname FROM `devices` AS D, `ports` AS I WHERE I.port_id = ? AND D.device_id = I.device_id", array($remote_port_id)); + $dst = $dst_query['hostname']; + $dst_host = $dst_query['device_id']; } else { unset($dst_host); $dst = $link['remote_hostname']; @@ -154,7 +154,7 @@ } $ifdone[$src][$sif['port_id']] = 1; } else { - $map .= "\"" . $sif['port_id'] . "\" [label=\"" . $sif['label'] . "\", fontsize=12, fillcolor=lightblue, URL=\"{$config['base_url']}/device/device=".$device['device_id']."/tab=port/port=$local_port_id/\"]\n"; + $map .= "\"" . $sif['port_id'] . "\" [label=\"" . $sif['label'] . "\", fontsize=12, fillcolor=lightblue, URL=\"".generate_url(array('page' => 'device', 'device' => $device['device_id'],'tab' => 'port', 'port' => $local_port_id))."\"]\n"; if (!$ifdone[$src][$sif['port_id']]) { $map .= "\"$src\" -> \"" . $sif['port_id'] . "\" [weight=500000, arrowsize=0, len=0];\n"; @@ -163,7 +163,7 @@ if ($dst_host) { - $map .= "\"$dst\" [URL=\"{$config['base_url']}/device/device=$dst_host/tab=ports/view=map/\", fontsize=20, shape=box3d]\n"; + $map .= "\"$dst\" [URL=\"".generate_url(array('page' => 'device', 'device' => $dst_host,'tab' => 'ports', 'view' => 'map'))."\", fontsize=20, shape=box3d]\n"; } else { $map .= "\"$dst\" [ fontsize=20 shape=box3d]\n"; } @@ -170,12 +170,12 @@ if ($dst_host == $device['device_id'] || $where == '') { - $map .= "\"" . $dif['port_id'] . "\" [label=\"" . $dif['label'] . "\", fontsize=12, fillcolor=lightblue, URL=\"{$config['base_url']}/device/device=$dst_host/tab=port/port=$remote_port_id/\"]\n"; + $map .= "\"" . $dif['port_id'] . "\" [label=\"" . $dif['label'] . "\", fontsize=12, fillcolor=lightblue, URL=\"".generate_url(array('page' => 'device', 'device' => $dst_host,'tab' => 'port', 'port' => $remote_port_id))."\"]\n"; } else { $map .= "\"" . $dif['port_id'] . "\" [label=\"" . $dif['label'] . " \", fontsize=12, fillcolor=lightgray"; if ($dst_host) { - $map .= ", URL=\"{$config['base_url']}/device/device=$dst_host/tab=port/port=$remote_port_id/\""; + $map .= ", URL=\"".generate_url(array('page' => 'device', 'device' => $dst_host,'tab' => 'port', 'port' => $remote_port_id))."\""; } $map .= "]\n"; } @@ -245,7 +245,7 @@ if (is_resource($process)) { - fwrite($pipes[0], "$map"); + fwrite($pipes[0], $map); fclose($pipes[0]); while (! feof($pipes[1])) { $img .= fgets($pipes[1]);} fclose($pipes[1]); @@ -264,7 +264,7 @@ break; } - echo("$img"); + echo($img); } else // No format specified {