krsort($dcity); } else { ksort($dcity); } $row = 0; foreach (array_keys($dcity) as $cty) { if ($dcity[$cty]['md']) { if ($row % 2) { $bg = $bga; $bi = $bia; } else { $bg = $bgb; $bi = $bib; } $row++; $img = CtyImg($dcity[$cty]['nd']); $tit = $dcity[$cty]['md'] . " monitored devices of " . $dcity[$cty]['nd'] . " in total"; $ucty = str_replace(" ", "%20", $cty); $av = sprintf("%01.2f", $dcity[$cty]['su'] / $dcity[$cty]['md']); $cbar = Bar($av, -99); echo "<tr bgcolor=#{$bg}>\n"; echo "<th bgcolor=#{$bi}><a href=Devices-Table.php?cty={$ucty}><img src=img/{$img}.png border=0 title=\"{$tit}\"></a><p>{$cty}</th>\n"; echo "<td>{$cbar} {$av} %</td></tr>\n"; if ($row == $lim) { break; } } } echo "</table><table bgcolor=#666666 {$tabtag} >\n"; echo "<tr bgcolor=#{$bg2}><td>{$row} cities with {$nmon} monitored devices in total</td></tr></table>\n"; ?>
function TopoCities($r, $siz = 0) { global $link, $map, $debug, $dcity, $locsep, $bg2, $netlbl, $errlbl, $tmplbl, $loclbl, $addlbl, $poplbl, $igrp, $notlbl, $rcvlbl; $ur = urlencode($r); $query = GenQuery('locations', 's', 'id,x,y,ns,ew,locdesc', '', '', array('region', 'city', 'building'), array('=', '=', '='), array($r, '', ''), array('AND', 'AND')); $res = DbQuery($query, $link); if (DbNumRows($res)) { list($id, $x, $y, $ns, $ew, $des) = DbFetchRow($res); echo "<h2>{$r} - {$des}</h2>\n"; } else { echo "<h2>{$r} {$netlbl}</h2>\n"; } echo "<table class=\"content fixed\"><tr>\n"; $col = 0; ksort($dcity[$r]); foreach (array_keys($dcity[$r]) as $c) { $nd = $dcity[$r][$c]['nd']; $ci = CtyImg($dcity[$r][$c]['nd']); $mn = isset($dcity[$r][$c]['mn']) ? $dcity[$r][$c]['mn'] : 0; $al = isset($dcity[$r][$c]['al']) ? $dcity[$r][$c]['al'] : 0; list($statbg, $stat) = StatusBg($nd, $mn, $al, 'imga'); $uc = urlencode($c); if ($col == $_SESSION['col']) { $col = 0; echo "</tr><tr>"; } echo "<td valign=\"bottom\" class=\"{$statbg}\"><center>\n"; $mstat = $mn ? "{$mn} Monitored {$stat}" : ""; if ($siz) { echo "<a href=\"?reg={$ur}&cty={$uc}\"><img src=\"img/{$ci}.png\" title=\"{$nd} Devices {$mstat}\"></a><br>" . substr($c, 0, $_SESSION['lsiz']) . "\n"; } else { $qmap = "{$uc},{$ur}"; $s = $_SESSION['gsiz'] < 3 ? "160x120" : "240x160"; $cp = preg_replace('/\\W/', '', $r) . '/' . preg_replace('/\\W/', '', $c); if ($cp and $map) { if ($map > 1) { if (!file_exists("topo/{$cp}") and !$_SESSION['snap']) { mkdir("topo/{$cp}", 0755, true); } $ns = $ew = 0; $query = GenQuery('locations', 's', 'id,x,y,ns,ew,locdesc', '', '', array('region', 'city', 'building'), array('=', '=', '='), array($r, $c, ''), array('AND', 'AND')); $res = DbQuery($query, $link); if (DbNumRows($res)) { list($id, $x, $y, $ns, $ew, $des) = DbFetchRow($res); echo "{$des}<br>"; $loced = ''; } else { $loced = "<a href=\"Topology-Loced.php?reg={$ur}&cty={$uc}\"><img src=\"img/16/ncfg.png\" title=\"{$addlbl}\"><a/>"; } if ($_SESSION['map']) { $cachd = 2; # Google maps mustn't be cached } else { $cache = "topo/{$cp}/osm-{$s}.png"; $cachd = file_exists($cache); # OSM is cached } if ($ns and $ew) { $ns /= 10000000; $ew /= 10000000; $qmap = "{$ns},{$ew}"; } elseif (($map == 3 or !$cachd) and ini_get('allow_url_fopen')) { # Weather and OSM only works with coordinates... $url = "http://nominatim.openstreetmap.org/search?format=json&limit=1&q={$qmap}"; $geo = json_decode(file_get_contents($url), TRUE); if ($debug) { echo "<div class=\"textpad code good\"><b>{$url}</b><p>"; print_r($geo); echo '</div>'; } if ($geo) { $ns = $geo[0][lat]; $ew = $geo[0][lon]; $qmap = "{$ns},{$ew}"; } } if ($map == 3 and ini_get('allow_url_fopen')) { if ($_SESSION['far']) { $mod = 'imperial'; $teu = 'F'; $wiu = 'mph'; } else { $mod = 'metric'; $teu = 'C'; $wiu = 'm/s'; } $url = "http://api.openweathermap.org/data/2.5/weather?lat={$ns}&lon={$ew}&units={$mod}"; $wtr = json_decode(file_get_contents($url), TRUE); if ($debug) { echo "<div class=\"textpad code good\"><b>{$url}</b><p>"; print_r($wtr); echo '</div>'; } if (is_array($wtr)) { echo "<a href=\"http://openweathermap.org/city/" . $wtr[id] . "\" target=\"window\"><img src=\"http://openweathermap.org/img/w/" . $wtr[weather][0][icon] . ".png\" title=\"" . $wtr[weather][0][description] . "\"></a>"; echo "<img src=\"img/16/temp.png\" title=\"{$tmplbl}\">" . round($wtr[main][temp]) . "{$teu} <img src=\"img/16/drop.png\" title=\"Humidity\">" . $wtr[main][humidity] . "% <img src=\"img/16/fan.png\" title=\"Wind\">" . round($wtr[wind][speed]) . "{$wiu}<br>"; } else { echo "{$igrp['16']} {$notlbl} {$rcvlbl}<br>"; } } else { if ($debug) { echo "<div class=\"textpad code alrm\">Skip {$igrp['16']}: map={$map}, allow_url_fopen " . ini_get('allow_url_fopen') . '</div>'; } } if ($_SESSION['map']) { echo "<a href=\"?reg={$ur}&cty={$uc}&map={$map}\"><img src=\"http://maps.google.com/maps/api/staticmap?center={$qmap}&zoom=11&size={$s}&maptype=roadmap&sensor=false\" title=\"{$nd} Devices {$mstat}, {$com}\" style=\"border:1px solid black\"></a><br>\n"; echo "{$loced}<a href=\"http://maps.google.com/maps?q={$qmap}\" target=\"window\"><img src=\"img/16/map.png\" title=\"Googlemap\"></a>\n"; } else { if ($_SESSION['snap']) { $cache = "img/{$ci}.png"; } elseif (!$cachd and ini_get('allow_url_fopen')) { file_put_contents($cache, file_get_contents("http://staticmap.openstreetmap.de/staticmap.php?center={$qmap}&zoom=11&size={$s}")); } echo "<a href=\"?reg={$ur}&cty={$uc}&map={$map}\"><img src=\"{$cache}\" title=\"{$nd} Devices {$mstat}\" style=\"border:1px solid black\"></a><br>\n"; echo "{$loced}<a href=\"http://nominatim.openstreetmap.org/search.php?q={$qmap}\" target=\"window\"><img src=\"img/16/osm.png\" title=\"Openstreetmap\"></a>\n"; } } else { echo "<center><a href=\"?reg={$ur}&cty={$uc}&map={$map}\"><img src=\"inc/drawmap.php?st[]=^{$ur}{$locsep}{$uc}&dim={$s}&lev=3&pos=s\" title=\"{$nd} Devices {$mstat}\" style=\"border:1px solid black\"></a><br>\n"; //too slow $pop = NodPop( array('location'),array('like'),array("$r$locsep$c$locsep%"),array() ); } } else { echo "<a href=\"?reg={$ur}&cty={$uc}\"><img src=\"img/{$ci}.png\" title=\"{$nd} Devices {$mstat}\"></a><br>\n"; } echo "<a href=\"Topology-Map.php?st[]={$ur}{$locsep}{$uc}{$locsep}%&lev=3&fmt=png\"><img src=\"img/16/paint.png\" title=\"Topology-Map\"></a>\n"; echo "<a href=\"Devices-List.php?in[]=location&op[]=like&st[]={$ur}{$locsep}{$uc}{$locsep}%\"><b>" . substr($c, 0, $_SESSION['lsiz']) . "</b></a>"; } $locp = $pop ? " <a href=\"Nodes-List.php?in[]=location&op[]=like&st[]={$ur}{$locsep}{$uc}{$locsep}%\"><img src=\"img/16/nods.png\" title=\"{$loclbl} {$poplbl}\">{$pop}</a>" : ''; echo " {$locp}</center></td>\n"; $col++; } echo "</tr></table>\n"; }
function Cities() { global $dcity, $maxcol, $bg1, $tabtag; echo "<h2 align=center>Corporate Network</h2>\n"; ksort($dcity); echo "<table bgcolor=#{$bg1} {$tabtag} ><tr>\n"; $col = 0; foreach (array_keys($dcity) as $city) { $nd = $dcity[$city]['nd']; $mn = isset($dcity[$city]['mn']) ? $dcity[$city]['mn'] : 0; $al = isset($dcity[$city]['al']) ? $dcity[$city]['al'] : 0; list($bgm, $stat) = GetStatus($nd, $mn, $al); if ($col == $maxcol) { $col = 0; echo "</tr><tr>"; } $ci = CtyImg($nd); $ucity = str_replace(" ", "%20", $city); echo "\t<th bgcolor=#{$bgm} valign=bottom><a href={$_SERVER['PHP_SELF']}?cty={$ucity}><img src=img/{$ci}.png title=\"{$mn} monitored, {$stat}\" border=0></a>\n"; echo "<br><a href=Monitoring-Setup.php?loc={$city}>{$city}</a></th>\n"; $col++; } echo "<tr></table>\n"; }
function Drawitem($x,$y,$opt,$label,$typ) { global $fmt,$dev,$loi,$ipi,$redbuild; $itxt = ""; $pfont = "1"; $vfont = "font-size=\"9\""; $vicon = "32"; if($opt > 2){$r = 8;}else{$r = 4;} if($typ == "f"){ $cury = $rows = 0; $cols = 1; foreach(array_keys($ndev[$cty][$bld]) as $flr){ # Determine building size $cols = max(count($ndev[$cty][$bld][$flr]),$cols); # find max cols if($cols > $fco){ # Break row, if > Floor columns $rrow = ceil($cols / $fco); # How many rows result? $rows += $rrow; $cols = $fco; }else{ $rows++; } } $woff = intval($fsi*($cols-1)/2); $hoff = intval($fsi*($rows-1)/2); $mapframes .= Drawbox( $xbl[$bld] - $woff - intval($fsi/2) - 10, $ybl[$bld] - $hoff - intval($fsi/2), $xbl[$bld] + $woff + intval($fsi/2), $ybl[$bld] + $hoff + intval($fsi/2), $bld); uksort($ndev[$cty][$bld], "Floorsort"); foreach(array_keys($ndev[$cty][$bld]) as $flr){ $mapitems .= Drawitem( $xbl[$bld] - $woff - intval($fsi/2), $ybl[$bld] - $hoff + $cury*$fsi, 0,$flr,'fl'); usort( $ndev[$cty][$bld][$flr],"Roomsort" ); $curx = 0; foreach($ndev[$cty][$bld][$flr] as $dv){ $xd[$dv] = $xbl[$bld] - $woff + $curx*$fsi; $yd[$dv] = $ybl[$bld] - $hoff + $cury*$fsi; $mapitems .= Drawitem($xd[$dv],$yd[$dv],'0',$dv,'d'); $area = ($xd[$dv]-20) .",". ($yd[$dv]-20) .",". ($xd[$dv]+20) .",". ($yd[$dv]+20); $imgmap .= "<area href=Devices-Status.php?dev=". rawurlencode($dv) ." coords=\"$area\" shape=rect title=\"Show $dv Status\">\n"; $curx++; if($curx == $fco){ $curx = 0; $cury++; } } $cury++; } }elseif($typ == "B"){ if( preg_match("/$redbuild/",$label) ){$bc = "red";}else{$bc = "cornflowerblue";} if($fmt == "svg"){ $itxt .= " <rect fill=\"$bc\" stroke=\"black\" x=\"".($x-$r)."\" y=\"".($y-$r)."\" width=\"".(2*$r)."\" height=\"".(2*$r)."\" />\n"; $itxt .= " <text x=\"".($x-20)."\" y=\"".($y+20)."\" fill=\"blue\">$label</text>\n"; }else{ $itxt .= "Imagefilledrectangle(\$image, ".($x-$r).", ".($y-$r).", ".($x+$r).", ".($y+$r).", \$$bc);\n"; $itxt .= "Imagerectangle(\$image, ".($x-$r).", ".($y-$r).", ".($x+$r).", ".($y+$r).", \"\$black\");\n"; $itxt .= "ImageString(\$image, 1, ".($x-10).", ".($y+10).", \"$label\", \"\$blue\");\n"; } return $itxt; }elseif($typ == "C"){ if($fmt == "svg"){ $itxt .= " <circle fill=\"cornflowerblue\" stroke=\"black\" cx=\"$x\" cy=\"$y\" r=\"$r\"/>\n"; $itxt .= " <text x=\"".($x-20)."\" y=\"".($y+20)."\" fill=\"navy\">$label</text>\n"; }else{ $itxt .= "Imagefilledellipse(\$image, $x, $y, ".(2*$r).", ".(2*$r).", \"\$cornflowerblue\");\n"; $itxt .= "Imageellipse(\$image, $x, $y, ".(2*$r).", ".(2*$r).", \"\$black\");\n"; $itxt .= "ImageString(\$image, 1, ".($x-10).", ".($y+10).", \"$label\", \"\$navy\");\n"; } return $itxt; }elseif($typ == "ci"){ $img = "cityg"; $lcol = "gray"; }elseif($typ == "c"){ $img = CtyImg($opt); $lcol = "navy"; $pfont = "5"; $vfont = "font-size=\"15\" font-weight=\"bold\""; $vicon = "50"; }elseif($typ == "b"){ $img = BldImg($opt,$label); $lcol = "blue"; }elseif($typ == "fl"){ $img = "stair"; $lcol = "navy"; $pfont = "3"; $vfont = "font-size=\"12\" font-weight=\"bold\""; $vicon = "10"; }elseif($typ == "d"){ $img = "dev/" . $dev[$label]['ic']; $lcol = "black"; } if($fmt == "svg"){ $itxt .= " <image x=\"".($x-$vicon/2)."\" y=\"".($y-$vicon/2)."\" width=\"$vicon\" height=\"$vicon\" xlink:href=\"../img/$img.png\"/>\n"; if ($typ == "d"){ if ($loi){$itxt .= " <text x=\"".($x-$vicon/2)."\" y=\"".($y-$vicon/2-4)."\" $vfont fill=\"$lcol\">".$dev[$label]['rom']."</text>\n";} if ($ipi){$itxt .= "<text x=\"".($x-$vicon/2)."\" y=\"".($y+$vicon/2+20)."\" fill=\"gray\">".$dev[$label]['ip']."</text>\n";} } $itxt .= " <text x=\"".($x-$vicon/2)."\" y=\"".($y+$vicon/2+10)."\" $vfont fill=\"$lcol\">".Safelabel($label)."</text>\n"; }else{ $itxt .= "\$icon = Imagecreatefrompng(\"../img/$img.png\");\n"; $itxt .= "\$w = Imagesx(\$icon);\n"; $itxt .= "\$h = Imagesy(\$icon);\n"; $itxt .= "Imagecopy(\$image, \$icon,intval($x - \$w/2),intval($y - \$h/2),0,0,\$w,\$h);\n"; if ($typ == "d"){ if ($loi){$itxt .= "ImageString(\$image, $pfont, intval($x - \$w/1.8), intval($y - \$h/1.6 - 10), \"".$dev[$label]['rom']."\", \$cornflowerblue);\n";} if ($ipi){$itxt .= "ImageString(\$image, $pfont, intval($x - \$w/1.8), intval($y + \$h/1.6 + 10), \"".$dev[$label]['ip']."\", \$gray );\n";} } $itxt .= "ImageString(\$image, $pfont, intval($x - \$w/1.8), intval($y + \$h/1.6), \"".Safelabel($label)."\", \$$lcol);\n"; $itxt .= "Imagedestroy(\$icon);\n"; } return $itxt; }
function Drawitem($x, $y, $opt, $label, $typ) { global $fmt, $dev, $loi, $ipi, $redbuild; $itxt = ""; $pfont = "1"; $vfont = "font-size=\"9\""; $vicon = "32"; if ($opt > 2) { $r = 8; } else { $r = 4; } if ($typ == "C") { if ($fmt == "svg") { $itxt .= "\t<circle fill=\"cornflowerblue\" stroke=\"black\" cx=\"{$x}\" cy=\"{$y}\" r=\"{$r}\"/>\n"; $itxt .= "\t<text x=\"" . ($x - 20) . "\" y=\"" . ($y + 20) . "\" fill=\"navy\">{$label}</text>\n"; } else { $itxt .= "Imagefilledellipse(\$image, {$x}, {$y}, " . 2 * $r . ", " . 2 * $r . ", \"\$cornflowerblue\");\n"; $itxt .= "Imageellipse(\$image, {$x}, {$y}, " . 2 * $r . ", " . 2 * $r . ", \"\$black\");\n"; $itxt .= "ImageString(\$image, 1, " . ($x - 10) . ", " . ($y + 10) . ", \"{$label}\", \"\$navy\");\n"; } return $itxt; } elseif ($typ == "B") { if (preg_match("/{$redbuild}/", $label)) { $bc = "red"; } else { $bc = "cornflowerblue"; } if ($fmt == "svg") { $itxt .= "\t<rect fill=\"{$bc}\" stroke=\"black\" x=\"" . ($x - $r) . "\" y=\"" . ($y - $r) . "\" width=\"" . 2 * $r . "\" height=\"" . 2 * $r . "\" />\n"; $itxt .= "\t<text x=\"" . ($x - 20) . "\" y=\"" . ($y + 20) . "\" fill=\"blue\">{$label}</text>\n"; } else { $itxt .= "Imagefilledrectangle(\$image, " . ($x - $r) . ", " . ($y - $r) . ", " . ($x + $r) . ", " . ($y + $r) . ", \${$bc});\n"; $itxt .= "Imagerectangle(\$image, " . ($x - $r) . ", " . ($y - $r) . ", " . ($x + $r) . ", " . ($y + $r) . ", \"\$black\");\n"; $itxt .= "ImageString(\$image, 1, " . ($x - 10) . ", " . ($y + 10) . ", \"{$label}\", \"\$blue\");\n"; } return $itxt; } elseif ($typ == "ci") { $img = "cityg"; $lcol = "gray"; } elseif ($typ == "c") { $img = CtyImg($opt); $lcol = "navy"; $pfont = "5"; $vfont = "font-size=\"15\" font-weight=\"bold\""; $vicon = "50"; } elseif ($typ == "b") { $img = BldImg($opt, $label); $lcol = "blue"; } elseif ($typ == "fl") { $img = "stair"; $lcol = "navy"; $pfont = "3"; $vfont = "font-size=\"12\" font-weight=\"bold\""; $vicon = "10"; } elseif ($typ == "d") { $img = "dev/" . $dev[$label]['ic']; $lcol = "black"; } if ($fmt == "svg") { $itxt .= "\t<image x=\"" . ($x - $vicon / 2) . "\" y=\"" . ($y - $vicon / 2) . "\" width=\"{$vicon}\" height=\"{$vicon}\" xlink:href=\"../img/{$img}.png\"/>\n"; if ($typ == "d") { if ($loi) { $itxt .= "\t<text x=\"" . ($x - $vicon / 2) . "\" y=\"" . ($y - $vicon / 2 - 4) . "\" {$vfont} fill=\"{$lcol}\">" . $dev[$label]['rom'] . "</text>\n"; } if ($ipi) { $itxt .= "<text x=\"" . ($x - $vicon / 2) . "\" y=\"" . ($y + $vicon / 2 + 20) . "\" fill=\"gray\">" . $dev[$label]['ip'] . "</text>\n"; } } $itxt .= "\t<text x=\"" . ($x - $vicon / 2) . "\" y=\"" . ($y + $vicon / 2 + 10) . "\" {$vfont} fill=\"{$lcol}\">" . Safelabel($label) . "</text>\n"; } else { $itxt .= "\$icon = Imagecreatefrompng(\"../img/{$img}.png\");\n"; $itxt .= "\$w = Imagesx(\$icon);\n"; $itxt .= "\$h = Imagesy(\$icon);\n"; $itxt .= "Imagecopy(\$image, \$icon,intval({$x} - \$w/2),intval({$y} - \$h/2),0,0,\$w,\$h);\n"; if ($typ == "d") { if ($loi) { $itxt .= "ImageString(\$image, {$pfont}, intval({$x} - \$w/1.8), intval({$y} - \$h/1.6 - 10), \"" . $dev[$label]['rom'] . "\", \$cornflowerblue);\n"; } if ($ipi) { $itxt .= "ImageString(\$image, {$pfont}, intval({$x} - \$w/1.8), intval({$y} + \$h/1.6 + 10), \"" . $dev[$label]['ip'] . "\", \$gray );\n"; } } $itxt .= "ImageString(\$image, {$pfont}, intval({$x} - \$w/1.8), intval({$y} + \$h/1.6), \"" . Safelabel($label) . "\", \${$lcol});\n"; $itxt .= "Imagedestroy(\$icon);\n"; } return $itxt; }
function DrawItem($x, $y, $opt, $label, $typ) { global $fmt, $dev, $nod, $pos, $loi, $dvi, $ipd, $redbuild, $cpua, $tmpa, $stco; $r = $opt > 2 ? 12 : 6; $lx = intval($x - strlen($label) * 2); if ($typ == 3) { # Building $bc = preg_match('/$redbuild/', $label) ? "red" : "burlywood"; if ($pos == "s") { $itxt = IconRect($x, $y, $r, $r, $bc); if ($fmt == "json") { $itxt .= ',"name":"' . Safelabel($label) . "\"},\n"; } else { $itxt .= DrawLabel($x, $y + $r, Safelabel($label), 2, "navy"); } } elseif ($pos == "d") { $itxt = IconRect($x, $y, $r / 3, $r / 3, $bc); if ($fmt == "json") { $itxt .= ',"name":"' . Safelabel($label) . "\"},\n"; } } else { $itxt = IconPng($x, $y, BldImg($opt, $label), 30); if ($fmt == "json") { $itxt .= ',"name":"' . Safelabel($label) . "\"},\n"; } else { $itxt .= DrawLabel($x, $y + $r * 2, Safelabel($label), 3, "navy"); } } } elseif ($typ == 2) { # City if ($pos == "s") { $itxt = IconCircle($x, $y, $r, $r, "purple"); if ($fmt == "json") { $itxt .= ',"name":"' . Safelabel($label) . "\"},\n"; } else { $itxt .= DrawLabel($x, $y + $r, Safelabel($label), 2, "navy"); } } elseif ($pos == "d") { $itxt = IconCircle($x, $y, $r / 3, $r / 3, "purple"); if ($fmt == "json") { $itxt .= ',"name":"' . Safelabel($label) . "\"},\n"; } } else { $itxt = IconPng($x, $y, CtyImg($opt), 48); if ($fmt == "json") { $itxt .= ',"name":"' . Safelabel($label) . "\"},\n"; } else { $itxt .= DrawLabel($x, $y + 25, Safelabel($label), 4, "navy"); } } } elseif ($typ == 1) { # Region if ($pos == "s") { $itxt = IconCircle($x, $y, $r, $r, "cornflowerblue"); if ($fmt == "json") { $itxt .= ',"name":"' . Safelabel($label) . "\"},\n"; } else { $itxt .= DrawLabel($x, $y + $r, Safelabel($label), 2, "navy"); } } elseif ($pos == "d") { $itxt = IconCircle($x, $y, $r / 3, $r / 3, "cornflowerblue"); if ($fmt == "json") { $itxt .= ',"name":"' . Safelabel($label) . "\"},\n"; } } else { $itxt = IconPng($x, $y, "32/glob", 32); if ($fmt == "json") { $itxt .= ',"name":"' . Safelabel($label) . "\"},\n"; } else { $itxt .= DrawLabel($x, $y + 12, Safelabel($label), 4, "navy"); } } } elseif ($typ == "ri") { # Regioninfo if ($pos == "s") { $itxt = IconCircle($x, $y, 10, 6, "gainsboro"); } elseif ($pos == "d") { $itxt = IconCircle($x, $y, 4, 2, "gainsboro"); } else { $itxt = IconPng($x, $y, "regg", 25); } $itxt .= DrawLabel($x, $y + 10, Safelabel($label), 2, "cornflowerblue"); } elseif ($typ == "ci") { # Cityinfo if ($pos == "s") { $itxt = IconRect($x, $y, 10, 6, "whitesmoke"); } elseif ($pos == "d") { $itxt = IconRect($x, $y, 4, 2, "whitesmoke"); } else { $itxt = IconPng($x, $y, "cityg", 30); } $itxt .= DrawLabel($x, $y + 10, Safelabel($label), 2, "cornflowerblue"); } elseif ($typ == "bi") { # Bldinfo if ($pos == "s") { $itxt .= IconRect($x, $y, 4, 4, "whitesmoke"); } elseif ($pos == "d") { $itxt .= IconRect($x, $y, 2, 2, "whitesmoke"); } else { $itxt .= IconPng($x, $y, "bldg", 30); } $itxt .= DrawLabel($x, $y + 10, Safelabel($label), 2, "cornflowerblue"); } elseif ($typ == "fl") { # Floorinfo if ($pos == "s") { $itxt = IconRect($x, $y, 3, 2, "black"); $itxt .= DrawLabel($x, $y + 6, Safelabel($label), 3, "navy"); } elseif ($pos == "d") { $itxt .= IconRect($x, $y, 1, 0.5, "black"); } else { $itxt = IconPng($x, $y, "stair", 10); $itxt .= DrawLabel($x, $y + 6, Safelabel($label), 3, "navy"); } } elseif ($typ == "d") { # Device list($clr, $sx, $sy, $shp) = Devshape($dev[$label]['ico']); if ($pos == "s") { if ($shp == "c") { $itxt = IconCircle($x, $y, $sx, $sy, $clr); } else { $itxt = IconRect($x, $y, $sx, $sy, $clr); } if ($dev[$label]['stk'] > 1) { $itxt .= DrawLabel($x + 20, $y - 6, $dev[$label]['stk'], 2, "blue"); } } elseif ($pos == "d") { $sx = intval($sx / 3); $sy = intval($sy / 3); if ($shp == "c") { $itxt = IconCircle($x, $y, $sx, $sy, $clr); } else { $itxt = IconRect($x, $y, $sx, $sy, $clr); } } elseif ($pos == "c") { if ($dev[$label]['cpu'] == "-") { $itxt = IconCircle($x, $y, 8, 4, "gray"); } elseif ($dev[$label]['cpu'] < $cpua / 2) { $itxt = IconRect($x, $y, 12, 6, "green"); $itxt .= DrawLabel($x, $y - 3, $dev[$label]['cpu'] . "%", 1, "whitesmoke"); } elseif ($dev[$label]['cpu'] < $cpua) { $itxt = IconRect($x, $y, 16, 8, "yellow"); $itxt .= DrawLabel($x, $y - 3, $dev[$label]['cpu'] . "%", 1, "black"); } else { $itxt = IconRect($x, $y, intval(0.5 * $dev[$label]['cpu']), intval(0.2 * $dev[$label]['cpu']), "orange"); $itxt .= DrawLabel($x, $y - 3, $dev[$label]['cpu'] . "%", 2, "whitesmoke"); } if ($dev[$label]['stk'] > 1) { $itxt .= DrawLabel($x + 20, $y - 6, $dev[$label]['stk'], 3, "blue"); } } elseif ($pos == "h") { if (!$dev[$label]['tmp']) { $itxt = IconCircle($x, $y, 8, 4, "gray"); } elseif ($dev[$label]['tmp'] < $tmpa / 2) { $itxt = IconRect($x, $y, 12, 6, "blue"); $itxt .= DrawLabel($x, $y - 3, $dev[$label]['tlb'], 1, "whitesmoke"); } elseif ($dev[$label]['tmp'] < $tmpa) { $itxt = IconRect($x, $y, 16, 8, "purple"); $itxt .= DrawLabel($x, $y - 3, $dev[$label]['tlb'], 1, "whitesmoke"); } else { $itxt = IconRect($x, $y, intval(0.5 * $dev[$label]['tmp']), intval(0.2 * $dev[$label]['tmp']), "red"); $itxt .= DrawLabel($x, $y - 3, $dev[$label]['tlb'], 3, "whitesmoke"); } if ($dev[$label]['stk'] > 1) { $itxt .= DrawLabel($x + 20, $y - 6, $dev[$label]['stk'], 2, "blue"); } } elseif ($pos == 'a') { if ($dev[$label]['sta'] == '') { $itxt .= IconCircle($x, $y, 8, 4, "gray"); } elseif ($dev[$label]['sta'] == 0) { $itxt = IconRect($x, $y, 18, 6, "green"); $itxt .= DrawLabel($x - 4, $y - 4, $stco['100'], 1, "whitesmoke"); } elseif ($dev[$label]['sta'] == 1) { $itxt = IconRect($x, $y, 24, 8, "yellow"); $itxt .= DrawLabel($x - 4, $y - 4, $stco['250'], 1, "black"); } else { $itxt = IconRect($x, $y, 24, 8, "red"); $itxt .= DrawLabel($x - 4, $y - 6, $stco['200'], 3, "whitesmoke"); } if ($dev[$label]['stk'] > 1) { $itxt .= DrawLabel($x + 20, $y - 6, $dev[$label]['stk'], 2, "blue"); } } elseif ($pos == "p" or $pos == "P" or $pos == "D") { $itxt = Panel($x, $y, $dev[$label]['typ'], $dev[$label]['stk'], $dev[$label]['ico'], $dev[$label]['siz']); if ($pos != "D") { $boxw = strlen($label); } } else { $itxt = IconPng($x, $y, "dev/" . $dev[$label]['ico'], 30); if ($dev[$label]['stk'] > 1 and $fmt != "json") { $itxt .= IconPng($x + 30, $y, $dev[$label]['stk'], 16); } } if ($fmt == "json") { $itxt .= ',"name":"' . Safelabel($label) . "\"},\n"; } elseif ($pos != "d") { $devl = DrawLabel($x, $y + 18, Safelabel($label), 1, "black"); if ($loi) { if ($loi == 1) { $locl = $dev[$label]['rom']; } elseif ($loi == 2) { $locl = $dev[$label]['rak']; } else { $locl = $dev[$label]['rom'] . " " . $dev[$label]['rak']; } $locw = strlen($locl); $devl .= DrawLabel($x, $y - 28, Safelabel($locl), 1, "cornflowerblue"); } if ($ipd) { $iplw = strlen($dev[$label]['ip']); $devl .= DrawLabel($x, $y + 26, $dev[$label]['ip'], 1, "blue"); } if ($dvi) { if ($dvi == 1) { $dvil = $dev[$label]['con']; } elseif ($dvi == 2) { $dvil = $dev[$label]['mod']; } elseif ($dvi == 3) { $dvil = $dev[$label]['con'] . " " . $dev[$label]['mod']; } $dviw = strlen($dvil); $devl .= DrawLabel($x, $y + ($ipd ? 34 : 26), Safelabel($dvil), 1, "gray"); } if ($boxw) { $boxw = $iplw > $boxw ? $iplw : $boxw; $boxw = $locw > $boxw ? $locw : $boxw; $boxw = $dviw > $boxw ? $dviw : $boxw; $pof = ($ipd ? 4 : 0) + ($dvi ? 4 : 0); $itxt .= IconRect($x + 5, $y + 24 + $pof / 2, $boxw * 4 + 4, 8 + $pof, "whitesmoke"); } $itxt .= $devl; } } elseif ($typ == "n") { if ($pos == "s") { $itxt .= IconCircle($x, $y, 5, 5, "limegreen"); } elseif ($pos == "d") { $itxt = IconCircle($x, $y, 2, 2, "limegreen"); } elseif ($pos == "P") { $itxt = IconPng($x, $y, "32/node", 32); $y += 6; } else { $itxt = IconPng($x, $y, "oui/" . $nod[$label]['ico'], 20); } if ($fmt == "json") { $itxt .= ',"name":"' . Safelabel($nod[$label]['nam']) . "\"},\n"; } elseif ($pos != "d") { $itxt .= DrawLabel($x, $y + 8, Safelabel($nod[$label]['nam']), 1, "black"); if ($ipd) { $itxt .= DrawLabel($x, $y + 16, $nod[$label]['ip'], 1, "blue"); } } } return $itxt; }
function Drawitem($x, $y, $opt, $label, $item) { global $dev, $loi, $ipi, $redbuild, $mapinfo, $mapitems; if ($item == "f") { $img = "dev/" . $dev[$label]['ic']; $lcol = "bl1"; $font = "1"; } elseif ($item == "b") { $img = BldImg($opt, $label); $lcol = "bl2"; $font = "2"; } elseif ($item == "c") { $img = CtyImg($opt); $lcol = "bl1"; $font = "5"; } elseif ($item == "fl") { $img = "stair"; $lcol = "blk"; $font = "3"; } elseif ($item == "ci") { $mapinfo[] = "\$icon = Imagecreatefrompng(\"../img/cityg.png\");"; $mapinfo[] = "\$w = Imagesx(\$icon);"; $mapinfo[] = "\$h = Imagesy(\$icon);"; $mapinfo[] = "Imagecopy(\$image, \$icon,intval({$x} - \$w/2),intval({$y} - \$h/2),0,0,\$w,\$h);"; $mapinfo[] = "ImageString(\$image,2, intval({$x} - \$w/1.5), intval({$y} + \$h/1.5), \"{$label}\", \$bl3);"; $mapinfo[] = "Imagedestroy(\$icon);"; return; } $mapitems[] = "\$icon = Imagecreatefrompng(\"../img/{$img}.png\");"; $mapitems[] = "\$w = Imagesx(\$icon);"; $mapitems[] = "\$h = Imagesy(\$icon);"; if ($item == "f") { if ($loi) { $mapitems[] = "ImageString(\$image, {$font}, intval({$x} - \$w/1.5), intval({$y} - \$h/1.5 - 8), \"" . $dev[$label]['rom'] . "\", \$bl3);"; } if ($ipi) { $mapitems[] = "ImageString(\$image, {$font}, intval({$x} - \$w/1.5), intval({$y} + \$h/1.5 + 8), \"" . $dev[$label]['ip'] . "\", \$gry);"; } } $label = preg_replace('/\\$/', '\\\\$', $label); $mapitems[] = "Imagecopy(\$image, \$icon,intval({$x} - \$w/2),intval({$y} - \$h/2),0,0,\$w,\$h);"; $mapitems[] = "ImageString(\$image, {$font}, intval({$x} - \$w/1.5), intval({$y} + \$h/1.5), \"{$label}\", \${$lcol});"; $mapitems[] = "Imagedestroy(\$icon);"; }
function Cities() { global $dcity, $maxcol, $bg1, $tabtag; echo "<h2>Corporate Network</h2>\n"; ksort($dcity); echo "<table bgcolor=#{$bg1} {$tabtag} ><tr>\n"; $col = 0; foreach (array_keys($dcity) as $city) { if ($col == $maxcol) { $col = 0; echo "</tr><tr>"; } $ci = CtyImg($dcity[$city]); $ucity = str_replace(" ", "%20", $city); echo "\t<th bgcolor=#FFFFFF valign=bottom><a href={$_SERVER['PHP_SELF']}?cty={$ucity}><img src=img/{$ci}.png title=\"{$dcity[$city]} devices\" border=0></a><br>{$city}</th>\n"; $col++; } echo "<tr></table>\n"; }
function TopoCities() { global $dcity, $locsep, $maxcol, $bg2, $tabtag; echo "<h2>Corporate Network</h2>\n"; echo "<table bgcolor=#{$bg2} {$tabtag} STYLE=\"table-layout:fixed\"><tr>\n"; $col = 0; $rec = 0; ksort($dcity); foreach (array_keys($dcity) as $r) { if ($rec == "1") { $rec = "0"; $bi = "FFFFFF"; } else { $rec = "1"; $bi = "F0F0F0"; } $ur = rawurlencode($r); ksort($dcity[$r]); foreach (array_keys($dcity[$r]) as $c) { $nd = $dcity[$r][$c]['nd']; $ci = CtyImg($dcity[$r][$c]['nd']); $mn = isset($dcity[$r][$c]['mn']) ? $dcity[$r][$c]['mn'] : 0; $al = isset($dcity[$r][$c]['al']) ? $dcity[$r][$c]['al'] : 0; list($bgm, $stat) = StatusBg($nd, $mn, $al, $bi); $uc = rawurlencode($c); if ($col == $maxcol) { $col = 0; echo "</tr><tr>"; } echo "<td bgcolor=#{$bgm} valign=top>{$r}<p><center><a href=?reg={$ur}&cty={$uc}>\n"; echo "<img src=img/{$ci}.png title=\"{$nd} devices {$stat}\" border=0></a>\n"; echo "<br><a href=Devices-List.php?ina=location&opa=regexp&sta={$ur}{$locsep}{$uc}{$locsep}>"; echo "<b>{$c}</a><b></center></td>\n"; $col++; } } echo "<tr></table>\n"; }