if ($ord) {
     krsort($dbuild[$cty]);
 } else {
     ksort($dbuild[$cty]);
 }
 foreach (array_keys($dbuild[$cty]) as $bld) {
     if ($dbuild[$cty][$bld]['md']) {
         if ($row % 2) {
             $bg = $bga;
             $bi = $bia;
         } else {
             $bg = $bgb;
             $bi = $bib;
         }
         $row++;
         $img = BldImg($dbuild[$cty][$bld]['nd'], $bld);
         $tit = $dbuild[$cty][$bld]['md'] . " monitored devices of " . $dbuild[$cty][$bld]['nd'] . " in total";
         $av = sprintf("%01.2f", $dbuild[$cty][$bld]['su'] / $dbuild[$cty][$bld]['md']);
         $cbar = Bar($av, -99);
         $ucty = str_replace(" ", "%20", $cty);
         $ubld = str_replace(" ", "%20", $bld);
         echo "<tr bgcolor=#{$bg}>\n";
         echo "<th bgcolor=#{$bi}><a href=Devices-Table.php?cty={$ucty}&bld={$ubld}><img src=img/{$img}.png border=0 title=\"{$tit}\"></a><p>{$bld}</th>\n";
         echo "<td>{$cbar} {$av} %</td></tr>\n";
         if ($row == $lim) {
             break;
         }
     }
 }
 if ($row == $lim) {
     break;
Esempio n. 2
0
function TopoBuilds($r, $c, $siz = 0)
{
    global $link, $map, $debug, $dbuild, $locsep, $bg2, $netlbl, $loclbl, $poplbl;
    $ur = urlencode($r);
    $uc = urlencode($c);
    $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 "<h2>{$c} - {$des}</h2>\n";
    } else {
        echo "<h2>{$c}, {$r} {$netlbl}</h2>\n";
    }
    echo "<table class=\"content fixed\"><tr>\n";
    $col = 0;
    ksort($dbuild[$r][$c]);
    foreach (array_keys($dbuild[$r][$c]) as $b) {
        $nr = $dbuild[$r][$c][$b]['nr'];
        $nd = $dbuild[$r][$c][$b]['nd'];
        $mn = isset($dbuild[$r][$c][$b]['mn']) ? $dbuild[$r][$c][$b]['mn'] : 0;
        $al = isset($dbuild[$r][$c][$b]['al']) ? $dbuild[$r][$c][$b]['al'] : 0;
        $bi = BldImg($nd, $b);
        list($statbg, $stat) = StatusBg($nd, $mn, $al, "imga");
        $ub = urlencode($b);
        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}&bld={$ub}\"><img src=\"img/{$bi}.png\" title=\"{$nd} Devices {$mstat}\"></a><br>" . substr($b, 0, $_SESSION['lsiz']) . "\n";
        } else {
            $qmap = "{$ub} {$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, $b), 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}&bld={$ub}\"><img src=\"img/16/ncfg.png\" title=\"{$addlbl}\"><a/>";
                    }
                    if ($ns and $ew) {
                        $ns /= 10000000;
                        $ew /= 10000000;
                        $qmap = "{$ns},{$ew}";
                    }
                    if ($_SESSION['map']) {
                        echo "<a href=\"?reg={$ur}&cty={$uc}&bld={$ub}&map={$map}\"><img src=\"http://maps.google.com/maps/api/staticmap?center={$qmap}&zoom=16&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/{$bi}.png";
                        } else {
                            $cache = "topo/{$cp}/osm-" . preg_replace('/\\W/', '', $b) . "-{$s}.png";
                            if (!file_exists($cache) and ini_get('allow_url_fopen')) {
                                if (!$ns and !$ew) {
                                    $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) {
                                        $qmap = $geo[0][lat] . "," . $geo[0][lon];
                                    }
                                }
                                file_put_contents($cache, file_get_contents("http://staticmap.openstreetmap.de/staticmap.php?center={$qmap}&zoom=12&size={$s}"));
                            }
                        }
                        echo "<a href=\"?reg={$ur}&cty={$uc}&bld={$ub}&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 "<a href=\"?reg={$ur}&cty={$uc}&bld={$ub}&map={$map}\"><img src=\"inc/drawmap.php?st[]=^{$ur}{$locsep}{$uc}{$locsep}{$ub}&dim={$s}&lev=4&pos=d&xo=-20\" 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$b$locsep%"),array() );
                }
            } else {
                echo "<a href=\"?reg={$ur}&cty={$uc}&bld={$ub}\"><img src=\"img/{$bi}.png\" title=\"{$nd} Devices {$mstat}\"></a>\n";
                if ($nr > 1) {
                    echo "<img src=\"img/rtr2.png\" title=\"{$nr} routers\">";
                } elseif ($nr == 1) {
                    echo "<img src=\"img/rtr1.png\" title=\"1 router\">";
                }
                echo "<br>";
            }
            echo "<a href=\"Topology-Map.php?st[]={$ur}{$locsep}{$uc}{$locsep}{$ub}{$locsep}%&lev=4&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}{$ub}{$locsep}%\" valign=\"bottom\"><b>" . substr($b, 0, $_SESSION['lsiz']) . "</b></a>";
        }
        $locp = $pop ? " <a href=\"Nodes-List.php?in[]=location&op[]=like&st[]={$ur}{$locsep}{$uc}{$locsep}{$ub}{$locsep}%\"><img src=\"img/16/nods.png\" title=\"{$loclbl} {$poplbl}\">{$pop}</a>" : '';
        echo "{$locp}</center></td>\n";
        $col++;
    }
    echo "</tr></table>\n";
}
function Buildings($city)
{
    global $dcity, $dbuild, $maxcol, $redbuild, $bg2, $tabtag;
    echo "<br><h2>{$city}</h2>\n";
    echo "<table bgcolor=#{$bg2} {$tabtag} ><tr>\n";
    $col = 0;
    ksort($dbuild[$city]);
    foreach (array_keys($dbuild[$city]) as $bld) {
        $nd = $dbuild[$city][$bld]['nd'];
        $mn = isset($dbuild[$city][$bld]['mn']) ? $dbuild[$city][$bld]['mn'] : 0;
        $al = isset($dbuild[$city][$bld]['al']) ? $dbuild[$city][$bld]['al'] : 0;
        list($bgm, $stat) = GetStatus($nd, $mn, $al);
        if ($col == $maxcol) {
            $col = 0;
            echo "</tr><tr>";
        }
        $bi = BldImg($nd, $bld);
        $ucity = str_replace(" ", "%20", $city);
        $ubld = str_replace(" ", "%20", $bld);
        echo "\t<th bgcolor=#{$bgm} valign=bottom>\n";
        echo "<a href={$_SERVER['PHP_SELF']}?cty={$ucity}&bld={$ubld}><img src=img/{$bi}.png title=\"{$mn} monitored, {$stat}\" border=0></a>\n";
        echo "<br><a href=Monitoring-Setup.php?loc={$bld}>{$bld}</a>\n";
        echo "</th>\n";
        $col++;
    }
    echo "<tr></table>\n";
}
Esempio n. 4
0
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;
}
Esempio n. 6
0
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;
}
Esempio n. 7
0
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 Buildings($cty)
{
    global $dbuild, $bpos, $maxcol, $redbuild, $bg2, $tabtag;
    ksort($dbuild[$cty]);
    echo "<h2>{$cty}</h2>\n";
    echo "<table bgcolor=#{$bg2} {$tabtag} ><tr>\n";
    $col = 0;
    foreach (array_keys($dbuild[$cty]) as $bld) {
        $nr = $dbuild[$cty][$bld]['nr'];
        $nd = $dbuild[$cty][$bld]['nd'];
        if ($col == $maxcol) {
            $col = 0;
            echo "</tr><tr>";
        }
        $bi = BldImg($nd, $bld);
        if ($nr > 1) {
            $ri = "<img src=img/dev/rsb2.png title=\"{$nr} routers\" border=0>";
        } elseif ($nr == 1) {
            $ri = "<img src=img/dev/rsbl.png title=\"1 router\" border=0>";
        } else {
            $ri = "";
        }
        $ucity = urlencode($cty);
        $ubld = urlencode($bld);
        echo "\t<td bgcolor=#FFFFFF valign=bottom align=center>\n";
        echo "<a href={$_SERVER['PHP_SELF']}?cty={$ucity}&bld={$ubld}><img src=img/{$bi}.png title=\"{$nd} devices\" border=0>{$ri}</a>\n";
        echo "<br><a href=Devices-List.php?ina=location&opa=regexp&sta={$bld}>{$bld}</a>\n";
        echo "</td>\n";
        $col++;
    }
    echo "<tr></table>\n";
}
Esempio n. 9
0
function TopoBuilds($r, $c)
{
    global $dbuild, $locsep, $maxcol, $redbuild, $bg2, $tabtag;
    $ur = rawurlencode($r);
    $uc = rawurlencode($c);
    echo "<h2>{$r} - {$c}</h2>\n";
    echo "<table bgcolor=#{$bg2} {$tabtag} STYLE=\"table-layout:fixed\"><tr>\n";
    $col = 0;
    ksort($dbuild[$r][$c]);
    foreach (array_keys($dbuild[$r][$c]) as $b) {
        $nr = $dbuild[$r][$c][$b]['nr'];
        $nd = $dbuild[$r][$c][$b]['nd'];
        $mn = isset($dbuild[$r][$c][$b]['mn']) ? $dbuild[$r][$c][$b]['mn'] : 0;
        $al = isset($dbuild[$r][$c][$b]['al']) ? $dbuild[$r][$c][$b]['al'] : 0;
        $bi = BldImg($nd, $b);
        list($bgm, $stat) = StatusBg($nd, $mn, $al);
        if ($nr > 1) {
            $ri = "<img src=img/dev/rsb2.png title=\"{$nr} routers\" border=0>";
        } elseif ($nr == 1) {
            $ri = "<img src=img/dev/rsbl.png title=\"1 router\" border=0>";
        } else {
            $ri = "";
        }
        $ub = rawurlencode($b);
        if ($col == $maxcol) {
            $col = 0;
            echo "</tr><tr>";
        }
        echo "<td bgcolor={$bgm} valign=bottom align=center>\n";
        echo "<a href=?reg={$ur}&cty={$uc}&bld={$ub}><img src=img/{$bi}.png title=\"{$nd} devices {$stat}\" border=0>{$ri}</a>\n";
        echo "<br><a href=Devices-List.php?ina=location&opa=regexp&sta={$ur}{$locsep}{$uc}{$locsep}{$ub}{$locsep}><b>{$b}</b></a>\n";
        echo "</td>\n";
        $col++;
    }
    echo "<tr></table>\n";
}