/usr/share/netdisco/html/netmap.html is in netdisco-frontend 1.0-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 | %#
%# NAVBAR
%#
<FORM ACTION="<%$r->uri%>" METHOD="GET"><DIV class="navbar">
<SELECT class="navbutton" NAME="t" SIZE=1>
% foreach my $tt (@types_on) {
<OPTION VALUE="<%$tt%>" <% $tt eq $arg_t ? 'SELECTED' : ''%>><%$tt%>
% }
</SELECT>
% if ($arg_t eq 'svg') {
<SELECT class="navbutton" NAME="w" SIZE=1>
% foreach my $ww (@w_opts) {
<OPTION VALUE="<%$ww%>" <% $ww eq $arg_w ? 'SELECTED' : ''%>><%$ww%>
% }
</SELECT>
<SELECT class="navbutton" NAME="a" SIZE=1>
% foreach my $aa (@a_opts) {
<OPTION VALUE="<%$aa|h%>" <% $aa eq $arg_a ? 'SELECTED' : ''%>><%$aa|h%>
% }
</SELECT>
% }
<input class="navbutton" type="submit" value="Update">
<A class="navbutton" HREF="<%$r->uri%>">Reset</A>
<A class="navbutton" HREF="javascript:tlgo('key_view')">Toggle Key</A>
</div></FORM>
%#
%# MAP
%#
%if ($arg_t eq 'svg' and $enabled{svg}) {
% $m->comp("SELF:netmap_svg", f => $exists{svg});
%} elsif ($enabled{$arg_t}) {
% $m->comp("SELF:netmap_img", f => $netdisco::CONFIG{"graph_$arg_t"});
%} else {
<h1>Network Map not enabled</h1>
Please edit <tt>netdisco.conf</tt> and run <tt>netdisco -g</tt>.
%}
%#
%# KEY
%#
<div id="key_view" class="hidden">
<TABLE class="netmap-key">
<TR><TH COLSPAN=4>Key</TH></TR>
% for(my $i = 0; $i <= $#{$left_key} || $i <= $#{$right_key}; $i++) {
<tr>
% if (defined($left_key->[$i])) {
<td class="mapkey"><%$left_key->[$i]->[0]%></td>
<td><%$left_key->[$i]->[1]%></td>
% } else {
<td colspan="2"> </td>
% }
% if (defined($right_key->[$i])) {
<td class="mapkey"><%$right_key->[$i]->[0]%></td>
<td><%$right_key->[$i]->[1]%></td>
% } else {
<td colspan="2"> </td>
% }
</tr>
% }
</TABLE>
</div>
<%args>
$w => 1024
$a => '16:9' # laptop
$t => ''
</%args>
<%shared>
my ($arg_w,$arg_a,$arg_t,$arg_h);
my @types = qw/map png gif svg jpg jpeg/;
my @types_on = ();
my %enabled = ();
my %exists = ();
my $dir;
</%shared>
<%init>
$arg_w = $w; $arg_a = $a; $arg_t = $t;
$dir = $m->current_comp->source_dir;
# Width / Height handling (SVG only)
my @w_opts = qw/400 600 800 1024 1200 1400/;
my @a_opts = qw/4:3 3:2 16:9/;
$arg_h = (9/16)*$arg_w;
if ($arg_a =~ /^(\d+):(\d+)$/) {
$arg_h = ($2/$1)*$arg_w;
}
# Hack for default graph
my $default = $netdisco::CONFIG{graph};
my $def_ext;
if (defined $default) {
$def_ext = $default;
$def_ext =~ s/^.*\.([^\.]+)$/$1/;
$netdisco::CONFIG{"graph_$def_ext"} = $netdisco::CONFIG{graph};
}
#
# Check for each type being enabled and created
#
foreach my $type (@types) {
my $file = $netdisco::CONFIG{"graph_$type"};
$file =~ s,^.*/,,g; # strip path
$enabled{$type} = defined $file;
push(@types_on,$type) if $enabled{$type} and $type ne 'map';
next unless $enabled{$type};
my $path = "$dir/$file";
$exists{$type} = -r $path ? $file : 0;
}
# Select one as default if we haven't selected one
if ($t eq '' or !grep(/^\Q$t\E$/,@types_on)) {
$t = $netdisco::CONFIG{graph_default} || $def_ext || $types_on[0] || 'svg';
$arg_t = $t;
}
# Key creation
my $right_key = [
[ '<span style="color:green;">--------</span>', 'WAN' ],
[ '<span style="color:#f5deb3;">-------</span>', '10Mbps' ],
[ '<span style="color:#f5deb3;">=======</span>', '100Mbps' ],
[ '<span style="color:cyan;">=======</span>', '1.0 Gbps' ] ];
my $left_key = [];
foreach my $map (@{$netdisco::CONFIG{node_map}}) {
my ($var,$regex,$attr,$val,$name,$label) = split(':',$map);
next unless $name && $label;
my ($textcolor) = $netdisco::CONFIG{node_fontcolor} || 'white';
my ($bracketcolor) = $netdisco::CONFIG{graph_color} || 'white';
if ($attr eq 'fillcolor') {
$textcolor = $bracketcolor = $val;
} elsif ($attr eq 'color') {
$bracketcolor = $val;
}
my($txt) = '<span style="color:' . $bracketcolor . ';">[';
if ($textcolor ne $bracketcolor) {
$txt .= '</span><span style="color:' . $textcolor . ';">';
}
$txt .= $name;
if ($textcolor ne $bracketcolor) {
$txt .= '</span><span style="color:' . $bracketcolor . ';">';
}
$txt .= ']</span>';
push(@{$left_key}, [ $txt, $label ]);
}
my $problem = $netdisco::CONFIG{node_problem} || 'red';
my $colorname = $problem; $colorname =~ s/^./\U$&/;
push(@{$left_key}, [ '<span style="color:' . $problem . ';">[bad-dev]</span>', 'Device Unaccessable' ]);
</%init>
%#
%# netmap_map()
%#
<%method netmap_map>
<%perl>
return unless $enabled{'map'};
unless ($exists{'map'}) {
$m->comp("SELF:no_file", f => $netdisco::CONFIG{graph_map});
return;
}
my (@map, $map_age, $secs_per_day, $map_days);
open (MAP, "< $exists{'map'}");
@map = (<MAP>);
close (MAP);
</%perl>
<MAP NAME="netmap">
% foreach my $line (@map){
<%$line%>
% }
</MAP>
</%method>
%#
%# netmap_img()
%#
<%method netmap_img>
<& SELF:netmap_map &>
% my $file = $exists{$arg_t};
% unless ($file) {
% $m->comp('SELF:no_file', f=>$netdisco::CONFIG{"graph_$arg_t"});
% return;
% }
<IMG SRC="<% $file %>" ISMAP USEMAP="#netmap" style="border: none;" alt="Network Map">
<BR><%$file%> is <&SELF:file_age_days, f=>"$dir/$file"&> days old.
</%method>
%#
%# netmap_svg()
%#
<%method netmap_svg>
<%args>
$f => ''
</%args>
<%perl>
unless ($exists{'svg'}) {
$m->comp("SELF:no_file", f => $netdisco::CONFIG{graph_svg});
return;
}
</%perl>
<applet code="net.claribole.zgrviewer.ZGRApplet.class" archive="svg/zvtm-0.9.8.jar,svg/zgrviewer-0.8.2.jar"
width="<%$arg_w|h%>" height="<%$arg_h|h%>">
<param name="type" value="application/x-java-applet;version=1.4" />
<param name="width" value="<%$arg_w|h%>" />
<param name="height" value="<%$arg_h|h%>" />
<param name="svgURL" value="<%$f|h%>" />
<param name="title" value="Interactive Network Map" />
<param name="showNavControls" value="true" />
%# <param name="centerOnLabel" value="main_router">
<param name="appletBackgroundColor" value="#8b7E66" />
<param name="graphBackgroundColor" value="#000" />
<param name="cursorColor" value="#FFF">
<param name="highlightColor" value="red">
<param name="antialiased" value="true">
</applet>
<TABLE class="netmap-svgkey">
<TR>
<TH>Function</TH>
<TH>Mouse</TH>
<TH>Keyboard</TH>
</TR>
<TR>
<TD>Zoom</TD>
<TD>Mouse Wheel / Shift+Click+Vertical Drag</TD>
<TD>+ / -<BR>PageUp / PageDown</TD>
</TR>
<TR>
<TD>Pan</TD>
<TD>Click+Drag</TD>
<TD>Arrow Keys</TD>
</TR>
<TR>
<TD>Open Device</TD>
<TD COLSPAN=2>Double-Click / Middle Click</TD>
</TR>
<TR>
<TD>Tool Pallet</TD>
<TD COLSPAN=2>Move to Top-Left corner</TD>
</TR>
</TABLE>
<UL>
</UL>
</%method>
%#
%# no_file( f=>file )
%#
<%method no_file>
<%args>
$f => ''
</%args>
<h1>Error</h1>
File <%$f|h%> is not accessable. Please run <tt>netdisco -g</tt>
or use the <a href="admin.html">Admin Panel</A>.
</%method>
%#
%# file_age_days(f => file)
%#
<%method file_age_days>
<%args>
$f => undef
</%args>
<%perl>
return -1 unless -r $f;
my $secs_per_day = 60*60*24;
my $age = (stat($f))[9];
$age = time - $age;
my $days = sprintf("%-2.2f", $age/$secs_per_day);
</%perl>
<%$days|h%>\
</%method>
%#
%# Add javascript routines to header
%# tl(layer) - Toggles Layer visibility
%# tlgo(layer,[anchor]) - Toggles layer and goes to anchor,
%# default anchor is same as layer
%#
<%method html_head>
<script type="text/javascript">
function tl ( whichLayer ) {
var elem, vis;
if ( document.getElementById ) elem = document.getElementById( whichLayer );
else if ( document.all ) elem = document.all[whichLayer];
else if ( document.layers ) elem = document.layers[whichLayer];
vis = elem.style;
// safari bug -- if hidden doesn't have any properties, so we know it's hidden.
if (vis == undefined) {
elem.setStyle('display', 'block');
return;
}
if (vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';
vis.display = (vis.display==''||vis.display=='block')?'none':'block';
}
function tlgo ( whichLayer, anchor ) {
if (anchor == undefined) anchor = whichLayer;
tl(whichLayer);
location.href="#"+anchor;
}
</script>
</%method>
<%method title>
- Network Map \
</%method>
%# $Id: netmap.html,v 1.13 2009/06/10 23:04:32 maxbaker Exp $
%# vim:syntax=mason
|