mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
git-svn-id: http://www.observium.org/svn/observer/trunk@966 61d68cd4-352d-0410-923a-c4978735b2b8
73 lines
1.5 KiB
PHP
73 lines
1.5 KiB
PHP
<?php
|
|
|
|
include("../includes/defaults.inc.php");
|
|
include("../config.php");
|
|
include("../includes/functions.php");
|
|
include("includes/authenticate.inc.php");
|
|
|
|
if (isset($_GET["dir"])) {
|
|
$dir = $_GET["dir"];
|
|
} else {
|
|
$dir = "h";
|
|
};
|
|
|
|
if (isset($_GET["width"])) {
|
|
$length = $_GET["width"];
|
|
} else {
|
|
$length = 200;
|
|
};
|
|
|
|
if (isset($_GET["per"])) {
|
|
$percent = $_GET["per"];
|
|
} else {
|
|
$percent = 0;
|
|
};
|
|
|
|
//calculate length of percent full
|
|
$percentlength = round(($percent / 100) * $length);
|
|
|
|
//send headers
|
|
Header("Content-Type: image/png");
|
|
|
|
if ($dir == "v") {
|
|
//create image
|
|
$image = ImageCreate(6, $length);
|
|
} else {
|
|
//dir == h
|
|
//create image
|
|
$image = ImageCreate($length, 6);
|
|
};
|
|
|
|
//Make colours
|
|
$grey = ImageColorAllocate($image, 200, 200, 200);
|
|
if($percent < '40') {
|
|
$colour = ImageColorAllocate($image, 0, 128, 0);
|
|
} elseif($percent < '70') {
|
|
$colour = ImageColorAllocate($image, 0, 0, 128);
|
|
} else {
|
|
$colour = ImageColorAllocate($image, 128, 0, 0);
|
|
}
|
|
|
|
//Fill image with grey
|
|
ImageFill($image, 0, 0, $grey);
|
|
|
|
if ($dir == "v") {
|
|
//create colour percent bar
|
|
ImageFilledRectangle($image, 0, $length - $percentlength, 6, $length , $colour);
|
|
} else {
|
|
//dir == h
|
|
//create colour percent bar
|
|
ImageFilledRectangle($image, 0, 0, $percentlength, 6, $colour);
|
|
};
|
|
|
|
//send picture to browser
|
|
$border = @imagecolorallocate($percent, 250, 250, 250);
|
|
imagerectangle($image, 0, 0, $length, 6, $border);
|
|
|
|
ImagePNG($image);
|
|
|
|
//clean up image as to not to crash the server
|
|
@imagedestroy($image);
|
|
|
|
?>
|