<?php
error_reporting(0);
Class DVD{
private $width;
private $height;
private $bgcolor;
private $SlatColor;
private $Textcolor;
function __construct($width, $height, $bgcolor, $SlatColor, $TextColor)
{
$this->width = $width;
$this->height =$height;
$this->bgcolor = $bgcolor;
$this->type = $type;
}
public function run($capacity)
{
$im = imagecreatetruecolor($this->width, $this->height);
$white = imagecolorallocate($im, 255, 255, 255);
$color = $this->html2rgb($this->bgcolor);
$color = imagecolorallocate($im, $color[0], $color[1], $color[2]);
imagefilledrectangle($im, 0, 0, $this->width, $this->height, $color);
$color = $this->html2rgb($this->SlatColor);
$color = imagecolorallocate($im, $color[0], $color[1], $color[2]);
imagefilledrectangle($im, 20, ($this->height/2)-10, $this->width-20, ($this->height/2)-5, $white);
if($capacity <= 5000)
{
$space = ($this->width-40) / 50;
for($x=0; $x<=5000; $x+=100){
if(($x%200)==0)
{
if($x>=1000) $size=($x/1000).'G'; else $size = $x.'M';
$newheight = ($this->height/2)+5;
$color = $this->html2rgb($this->Textcolor);
$color = imagecolorallocate($im, $color[0], $color[1], $color[2]);
imagefttext($im, 8, 0 ,$y+10, $newheight+10, $color, './tahoma.ttf', $size);
}
else
{
$newheight =($this->height/2);
}
imageline( $im , 20+$y ,($this->height/2)-5 , 20+$y ,$newheight, $white );
$y+=$space;
}
$place = (($capacity * (($this->width)-40)) / 5000)+19;
if($capacity < 4000){
$color = $this->html2rgb("#00FF00");
$color = imagecolorallocate($im, $color[0], $color[1], $color[2]);
}
elseif($capacity >= 4000 && $capacity < 4400){
$color = $this->html2rgb("#FFFF00");
$color = imagecolorallocate($im, $color[0], $color[1], $color[2]);
}
elseif($capacity >= 4400){
$color = $this->html2rgb("#FF0000");
$color = imagecolorallocate($im, $color[0], $color[1], $color[2]);
}
elseif($capacity >= 4700){
imagefttext($im, 8, 0 ,(($this->width)/2)-50, 20, $color, './tahoma.ttf', "Disk is Full");
}
imagefilledrectangle($im, 20, ($this->height/2)-10, $place, ($this->height/2)-5, $color);
}
header("Content-type: image/png");
imagepng($im);
}
public function html2rgb($color)
{
if ($color[0] == '#')
$color = substr($color, 1);
if (strlen($color) == 6)
list($r, $g, $b) = array($color[0].$color[1],
$color[2].$color[3],
$color[4].$color[5]);
elseif (strlen($color) == 3)
list($r, $g, $b) = array($color[0].$color[0], $color[1].$color[1], $color[2].$color[2]);
else
return false;
$r = hexdec($r); $g = hexdec($g); $b = hexdec($b);
return array($r, $g, $b);
}
function __destruct(){
imagedestroy($im);
}
}
?>