forked from SimplesIP/pabx-app
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
1.3 KiB
43 lines
1.3 KiB
<?php |
|
|
|
//FUNCÃO USADA PARA GERAR AS BARRAS DE PROGRESSO UTILIZADA NO MONITOR DO SISTEMA |
|
//UTILIZA A BIBILIOTECA GD |
|
function drawRating($rating) { |
|
$width = $_GET['width']; |
|
$height = $_GET['height']; |
|
if ($width == 0) { |
|
$width = 300; |
|
} |
|
if ($height == 0) { |
|
$height = 15; |
|
} |
|
$rating = $_GET['rating']; |
|
$ratingbar = (($rating / 100) * $width) - 2; |
|
$image = imagecreate($width, $height); |
|
$fill = ImageColorAllocate($image, 0, 255, 0); |
|
if ($rating > 49) { |
|
$fill = ImageColorAllocate($image, 255, 255, 0); |
|
} |
|
if ($rating > 74) { |
|
$fill = ImageColorAllocate($image, 255, 128, 0); |
|
} |
|
if ($rating > 89) { |
|
$fill = ImageColorAllocate($image, 255, 0, 0); |
|
} |
|
if ($rating > 100) { |
|
echo"Overload Error!"; |
|
exit(); |
|
} |
|
$back = ImageColorAllocate($image, 255, 255, 255); |
|
$border = ImageColorAllocate($image, 0, 0, 0); |
|
ImageFilledRectangle($image, 0, 0, $width - 1, $height - 1, $back); |
|
ImageFilledRectangle($image, 1, 1, $ratingbar, $height - 1, $fill); |
|
ImageRectangle($image, 0, 0, $width - 1, $height - 1, $border); |
|
imagePNG($image); |
|
imagedestroy($image); |
|
} |
|
|
|
Header("Content-type: image/png"); |
|
drawRating($rating); |
|
flush(); |
|
?>
|