<? class CHART{var $license="06-6831283"; //free license
var $file='';
var $imagine;
var $values="";
var $categories="";
var $width=600;
var $height=400;
var $xradius=14;
var $yradius=10;
var $title='';
var $gradientcoefficient=1;
var $showpanel=true;
var $showshaddow=true;
var $linealpha=0;
var $showgrid=true;
var $isgradient=true;
var $luminosity=72;
var $background="white";
var $angle=10;
var $count;
var $ry;
var $rx;
var $shaddow_x=25;
var $shaddow_y=-25;
var $shaddow_alpha=115;
var $linewidth=3;
var $bar_width_report=0.5;
var $xaxiswidth=3;
var $yaxiswidth=3;
var $pieheight=10;
var $centerx;
var $centery;
var $procente;var $procente_mici;
var $fontsize;var $imlegend;
var $normalx=32;var $normaly=32;
var $path;var $emphasize;var $style;
var $text;var $maxcount=100;var $force_no_save=true;
var $panel_background=array(210,255,242);var $title_color="black";
var $text_color="black";var $showcoords=false;
var $showlinecoords=false;var $connection;var $database;
var $font="arial.ttf";var $filter;
var $filter_arg1;var $filter_arg2;
var $filter_arg3;var $type;
var $theme;
var $colors='lightblue-cyan,plum-white,navajowhite-white,lightred-white,lavender-green,yellow-white,slategray-white,darkturquoise-white,green-white,yellow-white,indianred-white,darkgreen-white,rosybrown-white,mediumspringgreen-white,pink-white,chocolate-white';
var $allcolors=array("red"=>array(255,0,0),"lightred"=>array(255,70,80),"green"=>array(0,255,0),"blue"=>array(0,0,255),"black"=>array(0,0,0),"white"=>array(255,255,255),"gray"=>array(175,175,175),"pink"=>array(240,180,240),"yellow"=>array(255,255,0),"shaddow"=>array(160,160,160),"darkred"=>array(150,0,0),"darkblue"=>array(0,0,150),"darkgreen"=>array(0,150,0),"darkyellow"=>array(210,210,0),"darkpink"=>array(200,100,200),"darkgray"=>array(100,100,100),"lightgray"=>array(210,210,210),"orange"=>array(255,165,0),"darkorange"=>array(255,127,0),"tan"=>array(255,165,79),"darktan"=>array(255,150,75),"tan3"=>array(212,136,67),"darktan3"=>array(195,115,51),"violet"=>array(238,130,238),"darkviolet"=>array(200,115,200),"turquoise"=>array(64,224,208),"darkturquoise"=>array(20,190,165),"cyan"=>array(0,255,255),"darkcyan"=>array(0,210,210), "aquamarine"=>array(127,255,212), "darkaquamarine"=>array(102,205,170),"khaki"=>array(240,230,140),"darkkhaki"=>array(189,183,107),"indianred"=>array(212,96,96),"darkindianred"=>array(185,78,78),"lightblue"=>array(120,120,255),"peach"=>array(255,218,185),"navajowhite"=>array(255,222,173),"lavender"=>array(230,230,250),"slategray"=>array(112,138,144),"lightslategray"=>array(119,136,153),"greenyellow"=>array(173,255,47),"mediumspringgreen"=>array(0,250,154),"rosybrown"=>array(188,143,143),"brown"=>array(165,42,42),"chocolate"=>array(210,105,30),"plum"=>array(221,160,221),"antiquewhite"=>array(250,235,215),"honeydew"=>array(230,255,240),"lightgray2"=>array(220,220,220));

function set_theme($type) {
	$this->theme=$type;
	if ($type=="standard surface") {
		$this->colors="blue,yellow,red,green,tan,gray,greenyellow,navajowhite,slategray";
		$this->linealpha=65;
		$this->linewidth=3;
		$this->shaddow_x=$this->width/25;    
		$this->shaddow_y=-$this->height/25;
	}
	if ($type=="enhanced surface") {
		$this->colors="lightgray-lightblue-darkblue,lightgray-darkyellow-orange,lightgray-pink-red,white-darkgreen,lightrgray-brown";$this->$linealpha=0;$this->linewidth=1;}
		
		if ($type=="enhanced bar") {$this->colors="yellow-orange-red,cyan-lightblue-darkblue,pink-lightred-red,navajowhite-greenyellow-green,gray-tan-indianred,tan-white-brown,blue-white-blue,white-plum-white-plum";$this->linealpha=0;$this->linewidth=min($this->width,$this->height)/27;
		$this->shaddow_x=$this->width/25;
		$this->shaddow_y=-$this->height/25;}
		
		if ($type=="standard bar") {$this->colors="lightblue,darkyellow,red,green,tan,cyan,yellow";$this->linealpha=0;$this->linewidth=min($this->width,$this->height)/27;$this->shaddow_x=$this->width/25;$this->shaddow_y=-$this->height/25;}
		
		if ($type=="standard line") {$this->colors="lightblue,darkyellow,red,green,tan,cyan,yellow";$this->linealpha=50;$this->linewidth=min($this->width,$this->height)/100;$this->shaddow_x=$this->width/25;$this->shaddow_y=-$this->height/25;}
		
		if ($type=="enhanced line") {$this->colors="lightblue-cyan,plum-white,navajowhite-white,lightred-white,lavender-green,yellow-white,slategray-white,darkturquoise-white,green-white,yellow-white,indianred-white,darkgreen-white,rosybrown-white,mediumspringgreen-white,pink-white,chocolate-white";$this->linealpha=0;$this->linewidth=min($this->width,$this->height)/75;$this->shaddow_x=$this->width/25;$this->shaddow_y=-$this->height/25;}
		
		if ($type=="server line") {$this->colors="blue,darkyellow,red,green,tan,cyan,yellow";$this->linealpha=0;$this->linewidth=1;$this->shaddow_x=$this->width/25;$this->shaddow_y=-$this->height/25;$this->maxcount=$this->width*2;}}
		
		function imagecreatefromfile($fisier){
			if (eregi(".gif",$fisier)) return imagecreatefromgif($fisier);if (eregi(".jpg",$fisier)) return imagecreatefromjpeg($fisier);if (eregi(".jpeg",$fisier)) return imagecreatefromjpeg($fisier);if (eregi(".png",$fisier)) return imagecreatefrompng($fisier);if (eregi(".gd",$fisier)) return imagecreatefromgd($fisier);if (eregi(".gd2",$fisier)) return imagecreatefromgd2($fisier);if (eregi(".xbm",$fisier)) return imagecreatefromxbm($fisier);}function imagecreatefromfilegamma($fisier,$g1,$g2){if (eregi(".gif",$fisier)) $im= imagecreatefromgif($fisier);if (eregi(".jpg",$fisier)) $im= imagecreatefromjpeg($fisier);if (eregi(".jpeg",$fisier)) $im=  imagecreatefromjpeg($fisier);if (eregi(".png",$fisier)) $im=  imagecreatefrompng($fisier);if (eregi(".gd",$fisier)) $im=  imagecreatefromgd($fisier);if (eregi(".gd2",$fisier)) $im=  imagecreatefromgd2($fisier);if (eregi(".xbm",$fisier)) $im=  imagecreatefromxbm($fisier);imagefilter($im,IMG_FILTER_BRIGHTNESS,$g2);return $im;}function add_filter() {if (func_num_args()==5) {$this->filter=func_get_arg(0);$this->filter_arg1=func_get_arg(1);$this->filter_arg2=func_get_arg(2);$this->filter_arg3=func_get_arg(3);$this->filter_arg4=func_get_arg(4);}if (func_num_args()==4) {$this->filter=func_get_arg(0);$this->filter_arg1=func_get_arg(1);$this->filter_arg2=func_get_arg(2);$this->filter_arg3=func_get_arg(3);}if (func_num_args()==3) {$this->filter=func_get_arg(0);$this->filter_arg1=func_get_arg(1);$this->filter_arg2=func_get_arg(2);}if (func_num_args()==2) {$this->filter=func_get_arg(0);$this->filter_arg1=func_get_arg(1);}if (func_num_args()==1) {$this->filter=func_get_arg(0);}}function is_color($var){ if (!is_array($var)){if (array_key_exists($var,$this->allcolors)) {return true; } else return false;} else return false;}function is_gradient($var){$spl=explode("-",$var);if ((sizeof($this->allcolors[$spl[0]])>0) && (sizeof($this->allcolors[$spl[1]])>0)) {return true;}else return false;}function bc($im,$nume){if (is_array($nume)) { $sir=$nume; } else $sir=$this->allcolors[$nume];return imagecolorallocate($im,$sir[0],$sir[1],$sir[2]);}function bc_alpha($im,$nume,$alpha){if (is_array($nume)) { $sir=$nume; } else $sir=$this->allcolors[$nume];return imagecolorallocatealpha($im,$sir[0],$sir[1],$sir[2],$alpha);}function bc2($im,$culoare,$lum1,$lum2){$cul=explode("-",$culoare);$nume1=$this->lum($cul[0],$lum1);$nume2=$this->lum($cul[1],$lum2);if (is_array($nume1)) { $sir1=$nume1; } else $sir1=$this->allcolors[$nume1];if (is_array($nume2)) { $sir2=$nume2; } else $sir2=$this->allcolors[$nume2];$sir[0]=($sir1[0]+$sir2[0])/2;$sir[1]=($sir1[1]+$sir2[1])/2;$sir[2]=($sir1[2]+$sir2[2])/2;return imagecolorallocate($im,$sir[0],$sir[1],$sir[2]);}function bc2_alpha($im,$culoare,$lum1,$lum2,$alpha){$cul=explode("-",$culoare);$nume1=$this->lum($cul[0],$lum1);$nume2=$this->lum($cul[1],$lum2);if (is_array($nume1)) { $sir1=$nume1; } else $sir1=$this->allcolors[$nume1];if (is_array($nume2)) { $sir2=$nume2; } else $sir2=$this->allcolors[$nume2];$sir[0]=($sir1[0]+$sir2[0])/2;$sir[1]=($sir1[1]+$sir2[1])/2;$sir[2]=($sir1[2]+$sir2[2])/2;return imagecolorallocatealpha($im,$sir[0],$sir[1],$sir[2],$alpha);}function lum($nume,$procent){if (is_array($nume)) { $culoare=$nume; } else $culoare=$this->allcolors[$nume];$culorica=array();if ($procent<100) {$culorica[0]=max(0,$culoare[0]*$procent/100);$culorica[1]=max(0,$culoare[1]*$procent/100);$culorica[2]=max(0,$culoare[2]*$procent/100);} else{$culorica[0]=min(255,max(32,$culoare[0])*$procent/100);$culorica[1]=min(255,max(32,$culoare[1])*$procent/100);$culorica[2]=min(255,max(32,$culoare[2])*$procent/100);}return $culorica;}function lumina($nume,$procent){if (is_array($nume)) { $culoare=$nume; } else $culoare=$this->allcolors[$nume];$culorica=array();if ($procent<100) {$culorica[0]=max(0,$culoare[0]*$procent/100);$culorica[1]=max(0,$culoare[1]*$procent/100);$culorica[2]=max(0,$culoare[2]*$procent/100);} else{$culorica[0]=min(255,max(32,$culoare[0])*$procent/100);$culorica[1]=min(255,max(32,$culoare[1])*$procent/100);$culorica[2]=min(255,max(32,$culoare[2])*$procent/100);}$sir=$culorica;return imagecolorallocate($this->imagine,$sir[0],$sir[1],$sir[2]);}function lumina_alpha($nume,$procent,$alpha){if (is_array($nume)) { $culoare=$nume; } else $culoare=$this->allcolors[$nume];$culorica=array();if ($procent<100) {$culorica[0]=max(0,$culoare[0]*$procent/100);$culorica[1]=max(0,$culoare[1]*$procent/100);$culorica[2]=max(0,$culoare[2]*$procent/100);} else{$culorica[0]=min(255,max(32,$culoare[0])*$procent/100);$culorica[1]=min(255,max(32,$culoare[1])*$procent/100);$culorica[2]=min(255,max(32,$culoare[2])*$procent/100);}$sir=$culorica;return imagecolorallocatealpha($this->imagine,$sir[0],$sir[1],$sir[2],$alpha);}function color_medium($nume){$nume=explode("-");$culi1=$nume[0];$culi2=$nume[1];$sir1=$this->allcolors[$culi1];$sir2=$this->allcolors[$culi2];return imagecolorallocate($this->imagine,$sir[0],$sir[1],$sir[2]);}function degradeu($x,$y,$tip,$u,$culoare1,$culoare2){$x1=$x;$y1=$y;if (is_array($culoare1)) { $culoare1=$culoare1; } else $culoare1=$this->allcolors[$culoare1];if (is_array($culoare2)) { $culoare2=$culoare2; } else $culoare2=$this->allcolors[$culoare2];if ($tip==1) {$im=imagecreatetruecolor($x,$y);$dif1=$culoare2[0]-$culoare1[0];$dif2=$culoare2[1]-$culoare1[1];$dif3=$culoare2[2]-$culoare1[2];$c1=$culoare1[0];$c2=$culoare1[1];$c3=$culoare1[2];for($i=0;$i<$y;$i++){$culoare=imagecolorallocate($im,ceil($c1),ceil($c2),ceil($c3));imageline($im,0,$i,$x,$i,$culoare);$c1=$c1+($dif1/$y);$c2=$c2+($dif2/$y);$c3=$c3+($dif3/$y);}}if ($u!=0) {$im=imagerotate($im,$u,0);}return $im;}function fa_procente($sir){$s=0;for ($i=0;$i<$this->count;$i++)$s+=abs($sir[$i]);if ($s==0) $s=1;$rezultat=array();for ($i=0;$i<$this->count;$i++){$rezultat[]= floor((($sir[$i]*100)/$s)*100)/100;}return $rezultat; } function fa_procente_cerc($sir){$s=0;for ($i=0;$i<$this->count;$i++)$s+=abs($sir[$i]);if ($s==0) $s=1;$rezultat=array();for ($i=0;$i<$this->count;$i++){$rezultat[]=($sir[$i]*360)/$s;}return $rezultat; }   function dreptunghi($im,$x,$y,$x1,$y1,$rx,$ry,$col){imagearc($im,$x1-$rx/2,$y1-$ry/2,$rx,$ry,0,90,$col); imageline($im,$x+$rx/2,$y1,$x1-$rx/2,$y1,$col);imagearc($im,$x+$rx/2,$y1-$ry/2,$rx,$ry,90,180,$col); imageline($im,$x,$y+$ry/2,$x,$y1-$ry/2,$col);imagearc($im,$x+$rx/2,$y+$ry/2,$rx,$ry,180,270,$col);imageline($im,$x+$rx/2,$y,$x1-$rx/2,$y,$col);imagearc($im,$x1-$rx/2,$y+$ry/2,$rx,$ry,270,360,$col);imageline($im,$x1,$y+$ry/2,$x1,$y1-$ry/2,$col);} function dreptunghifill($im,$x,$y,$x1,$y1,$rx,$ry,$fill){if ($this->is_color($fill)) {$col=$fill;$fill=imagecreatetruecolor($this->width,$this->height);imagefilledrectangle($fill,0,0,$this->width,$this->height,$this->bc($this->imagine,$col));}elseif (is_array($fill)) {$col=$fill;$fill=imagecreatetruecolor($this->width,$this->height);imagefilledrectangle($fill,0,0,$this->width,$this->height,$this->bc($this->imagine,$col));} elseif (file_exists($fill)) {$col=$fill;$fill=$this->imagecreatefromfile($fill);}else{$col="darkgray";$fill=imagecreatetruecolor($this->width,$this->height);imagefilledrectangle($fill,0,0,$this->width,$this->height,$this->bc($this->imagine,$col));}imagesettile($im,$fill);imagefilledarc($im,$x1-$rx/2,$y1-$ry/2,$rx,$ry,0,90,IMG_COLOR_TILED,IMG_ARC_PIE); imagefilledrectangle($im,$x+$rx/2,$y,$x1-$rx/2,$y1,IMG_COLOR_TILED);imagefilledrectangle($im,$x,$y+$ry/2,$x1,$y1-$ry/2,IMG_COLOR_TILED);imagefilledarc($im,$x+$rx/2,$y1-$ry/2,$rx,$ry,90,180,IMG_COLOR_TILED,IMG_ARC_PIE); imagefilledarc($im,$x+$rx/2,$y+$ry/2,$rx,$ry,180,270,IMG_COLOR_TILED,IMG_ARC_PIE);imagefilledarc($im,$x1-$rx/2,$y+$ry/2,$rx,$ry,270,360,IMG_COLOR_TILED,IMG_ARC_PIE);;}function connect($host,$database,$user,$pass){$this->connection=mysql_connect($host,$user,$pass) or die(DB_error_msg($db));$this->database=mysql_select_db($database,$this->connection) or die (DB_error_msg($db));}function add_query($comanda){if (isset ($this->connection)) {if ($rez=mysql_query($comanda,$this->connection)){$cate=mysql_num_fields($rez);}else echo DB_error_msg($db);} else {if (!isset($this->connection)) if ($rez=mysql_query($comanda)){$cate=mysql_num_fields($rez);}else echo DB_error_msg($db);}if (mysql_num_rows($rez)>0){while ($row=mysql_fetch_array($rez)){for ($j=0;$j<$cate;$j++){$this->add_value(trim($row[$j]),trim(mysql_field_name($rez,$j)));}}}}function add_value(){ $cate=func_num_args();if ($cate==3) {$vall=func_get_arg(0);$val2=func_get_arg(1);$cat=func_get_arg(2); $vall=$vall."*".$val2;}if ($cate==2) {$vall=func_get_arg(0);$cat=func_get_arg(1);}$bagata=false; $sir="";$valori=explode(";",$this->values);foreach ($valori as $valoare) { $valu=explode("=",$valoare);      if (trim($valu[0])==trim($cat)) { $bagata=true;  $sir.=$valu[0]."=".$valu[1].",".$vall.";";   } else  $sir.=$valu[0]."=".$valu[1].";";    } if ($bagata==false)  if (strlen($this->values)==0) {$sir=$cat."=".$vall;}    else$sir.=$cat."=".$vall; if (substr($sir,-1)==';') $this->values=substr($sir,0,strlen($sir)-1);else $this->values=$sir;}function init(){$valoare=array();  if (strlen($this->values)>0) { $this->culori=explode(",",$this->colors); $var1=explode(";",$this->values); foreach ($var1 as $value) { $val2=explode("=",$value); $val3=explode(",",$val2[1]); $valoare[]=($val3[0]); $categorie[]=$val2[0];} $this->categorii=$categorie; $this->valori=$valoare; $this->count=min(sizeof($this->valori),sizeof($this->categorii));   if (sizeof($this->valori)>0) { $this->procente=$this->fa_procente_cerc($this->valori); $this->procente_mici=$this->fa_procente($this->valori);}if (!$this->xradius) $this->xradius=$this->width/50;if (!$this->yradius) $this->yradius=$this->height/50;if ($this->isgradient){ if ($this->is_color($this->background)) {  $this->imagine=imagecreatetruecolor($this->width,$this->height); imagefill($this->imagine,0,0,$this->bc($this->imagine,$this->background)); } else if ($this->is_gradient($this->background)) {  $this->imagine=$this->degradeu_multi($this->width,$this->height,1,0,$this->background); } else if (file_exists($this->background)) {  $this->imagine=imagecreatetruecolor($this->width,$this->height);$tile=$this->imagecreatefromfile($this->background);  imagesettile($this->imagine,$tile);imagefill($this->imagine,0,0,IMG_COLOR_TILED); } else { $this->imagine=imagecreatetruecolor($this->width,$this->height);  imagefill($this->imagine,0,0,$this->white); } }else { if ($this->is_color($this->background)) {  $this->imagine=imagecreatetruecolor($this->width,$this->height); imagefill($this->imagine,0,0,$this->bc($this->imagine,$this->background)); } else if ($this->is_gradient($this->background)) { $col=explode("-",$this->background);$this->imagine=imagecreatetruecolor($this->width,$this->height); imagefill($this->imagine,0,0,$this->bc2($this->imagine,$this->background,100,100)); } else if (file_exists($this->background)) {  $this->imagine=imagecreatetruecolor($this->width,$this->height);$tile=$this->imagecreatefromfile($this->background);  imagesettile($this->imagine,$tile);imagefill($this->imagine,0,0,IMG_COLOR_TILED); } else { $this->imagine=imagecreatetruecolor($this->width,$this->height); $white=imagecolorallocate($this->imagine,255,255,255); imagefill($this->imagine,0,0,$white); } };  if ($this->showpanel){$this->centerx=$this->width*0.35;$this->centery=$this->height*0.42;$this->rx=($this->width-3*$this->xradius)*0.65;    $this->ry=($this->height-3*$this->yradius)*0.65;}else{$this->centerx=$this->width*0.49;$this->centery=$this->height*0.42;$this->rx=($this->width-2*$this->xradius)*0.9;    $this->ry=($this->height-2*$this->yradius)*0.7;}if ((!$this->fontsize) || ($this->fontsize<2)) $this->fontsize=(min($this->height,$this->width,max(1024,$this->height/2)))*0.024;for ($j=0;$j<$this->count;$j++) {if (($this->culori[$j])==NULL) {$this->culori[$j]=$this->alta_culoare_unica();}if ($this->isgradient==false) if ($this->is_color($this->culori[$j])) {$this->acolors[$j][0]=$this->bc_alpha($this->imagine,$this->culori[$j],$this->linealpha);$this->acolors[$j][1]=0;$this->bcolors[$j][0]=$this->lumina_alpha($this->culori[$j],$this->luminosity,$this->linealpha);$this->bcolors[$j][1]=0;}else{if ($this->is_gradient($this->culori[$j])) {$this->acolors[$j][0]=$this->bc2_alpha($this->imagine,$this->culori[$j],100,100,$this->linealpha);$this->acolors[$j][1]=0;$this->acolors[$j][2]=1;$this->bcolors[$j][0]=$this->bc2_alpha($this->imagine,$this->culori[$j],$this->luminosity,$this->luminosity,$this->linealpha);$this->bcolors[$j][1]=0;}else {$tipul=1;$this->culori[$j]=$this->alta_culoare_unica();$this->acolors[$j][0]=$this->bc_alpha($this->imagine,$this->culori[$j],$this->linealpha);$this->acolors[$j][1]=0;$this->bcolors[$j][0]=$this->lumina_alpha($this->culori[$j],$this->luminosity,$this->linealpha);$this->bcolors[$j][1]=0;};}elseif (is_file($this->culori[$j])) {$tile=$this->imagecreatefromfile($this->culori[$j]);$this->acolors[$j][0]=$tile;$this->acolors[$j][1]=1;$this->bcolors[$j][0]=$this->imagecreatefromfilegamma($this->culori[$j],1,1-100/$this->luminosity);$this->bcolors[$j][1]=1;}else if ($this->is_color($this->culori[$j])) {$this->acolors[$j][0]=$this->bc_alpha($this->imagine,$this->culori[$j],$this->linealpha);$this->acolors[$j][1]=0;$this->bcolors[$j][0]=$this->lumina_alpha($this->culori[$j],$this->luminosity,$this->linealpha);$this->bcolors[$j][1]=0;}else if  ($this->is_gradient($this->culori[$j])) {$this->acolors[$j][0]=$this->degradeu_multi($this->width*$this->gradientcoefficient,$this->height*$this->gradientcoefficient,1,1,$this->culori[$j]);$this->acolors[$j][1]=1;$this->acolors[$j][2]=1;$this->bcolors[$j][0]=$this->bc2($this->imagine,$this->culori[$j],$this->luminosity,$this->luminosity);$this->bcolors[$j][1]=0;} else{$this->acolors[$j][0]=$this->bc_alpha($this->imagine,$this->alta_culoare_unica(),$this->linealpha);$this->acolors[$j][1]=0;$this->bcolors[$j][0]=$this->lumina_alpha($this->culori[$j],$this->luminosity,$this->linealpha);$this->bcolors[$j][1]=0;}}$this->black=$this->bc($this->imagine,"black");$this->red=$this->bc($this->imagine,"red");$this->white=$this->bc($this->imagine,"white");$this->blue=$this->bc($this->imagine,"blue");}}function __construct() {  if (!$this->ce_cauti_aici($this->license)) {die("Invalid license!");break;} $cate=func_num_args(); if ($cate==2) {    $this->width=func_get_arg(0); $this->height=func_get_arg(1); }   if ($cate==1) {     if (is_string(func_get_arg(0))) $this->path=func_get_arg(0);else {echo "must provide a valid filename or path;";break;} } if ($cate==3) {     if (is_string(func_get_arg(0))) {$this->path=func_get_arg(0);$this->width=func_get_arg(1); $this->height=func_get_arg(2);}else {  echo "must provide a valid filename or path;";break;} }  $this->init(); }function alta_culoare_unica() {  if (!$this->ce_cauti_aici($this->license)) {die("Invalid license!");break;};$gas=0;if (sizeof($this->culori)>0)while ($gas!=1) {$camp=array_rand($this->allcolors);if (!(in_array($camp,$this->culori)))  if ("violet"!=$camp) if ("tan"!=$camp) if ("white"!=$camp) if ("black"!=$camp) if (!eregi("dark",$camp)) if (!eregi("light",$camp)) if ("shaddow"!=$camp) {$gas=1;}}else while ($gas!=1) {$camp=array_rand($this->allcolors);if ("violet"!=$camp) if ("tan"!=$camp) if ("white"!=$camp) if ("black"!=$camp) if (!eregi("dark",$camp)) if (!eregi("light",$camp)) if ("shaddow"!=$camp) {$gas=1;}}return $camp;}function fa_link($var)   {   $de=array(' ','*','/',',','-','&','\'','(',')','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�', '!', '?');   $la=array('_','_','__','_v_','_d_','_w_','_sg_','_ps_','_pd_','_up_','_upm_','_ual_','_ualm_','_us_','_usm_','_uar_','_uarm_','_ot_','_otm_','_oal_','_oalm_','_os_','_osm_','_oar_','_oarm_','_ygrecp_','_ygrecar_','_ygrecarm_','_otilda_','_otildam_','_ntilda_','_ntildam_' , '_exclam_', '_q_');   $link=str_replace($de,$la,strtolower($var));   $link=preg_replace("/[^a-zA-Z0-9\_\d]/i", "", $link);   return $link;   }function stampila(){  if (!$this->ce_cauti_aici($this->license)) {die("Invalid license!");break;}$sir=$this->fa_link("chart_".$this->style."_".$this->type."_".$this->background."_".substr($this->values,0,20)."_".substr($this->values,-1*min($this->count,160))."_".$this->width."_".$this->height."_".$this->linewidth."_".abs($this->linealpha)."_".$this->count."_".$this->title);return substr($sir,0,240).".png";}function save($tip){$this->init();$this->type=$tip;if (strlen($this->values)>2) {if (($tip==1) || (strtolower($tip)=="pie"))$this->show_chart_pie();if (($tip==2) || (strtolower($tip)=="line"))$this->show_line();if (($tip==3) || (strtolower($tip)=="surface"))$this->show_surface();if (($tip==4) || (strtolower($tip)=="bar"))$this->show_bar();if (is_dir($this->path)) {$nou=$this->path."/".$this->stampila();}else {$nou=$this->path;};imagepng($this->imagine,$nou);return $nou;} else echo "not enought values";}function fa_imagine($tip){if (is_dir($this->path)) {$nou=$this->path."/".$this->stampila();if (!(file_exists($nou))){if (($tip==1) || (strtolower($tip)=="pie"))$this->show_chart_pie();if (($tip==2) || (strtolower($tip)=="line"))$this->show_line();if (($tip==3) || (strtolower($tip)=="surface"))$this->show_surface();if (($tip==4) || (strtolower($tip)=="bar"))$this->show_bar();imagepng($this->imagine,$nou);}return $nou;}else{if (file_exists($this->path)){return $this->path;} else {if (($tip==1) || (strtolower($tip)=="pie"))$this->show_chart_pie();if (($tip==2) || (strtolower($tip)=="line"))$this->show_line();if (($tip==3) || (strtolower($tip)=="surface"))$this->show_surface();if (($tip==4) || (strtolower($tip)=="bar"))$this->show_bar();imagepng($this->imagine,$this->path); return $this->path;}}}function fa_fisier_viewer(){ if (!$this->ce_cauti_aici($this->license)) {die("Invalid license!");break; }$dir=sys_get_temp_dir();if (!(file_exists(sys_get_temp_dir()."/chart_view.php"))){$continut="<img src='<"."?=$"."cale_chart; ?".">' <"."?=$"."style; ?"."> />";$fisier=fopen($dir."/chart_view.php","w+",false);fwrite($fisier,$continut);fclose($fisier);}}function afiseaza_imagine($cale){$this->fa_fisier_viewer();$cale_chart=$cale;$style=" style='".$this->style."' ";include(sys_get_temp_dir()."/chart_view.php");return $cale;}function aranjeaza_bucati(){$ant=0;$rezultat=array();for($j=0;$j<$this->count;$j++){if (strlen($this->emphasize)==0) {$dx=$this->xradius;$dy=$this->yradius;$rx=$this->rx;$ry=$this->ry;$ee=0;}else  {$em=explode(",",$this->emphasize);if ((in_array($this->categorii[$j],$em))){$dx=$this->xradius*1.25;$dy=$this->xradius*1.25;$rx=$this->rx*1.01;$ry=$this->ry*1.01;$ee=1;}else{$dx=$this->xradius*0.8;$dy=$this->yradius*0.8;$rx=$this->rx*0.8;$ry=$this->ry*0.8;$ee=-1;}}$med=$ant+$this->procente[$j]/2+$this->angle;$rad = deg2rad($med);$px=$this->centerx+$dx*cos($rad);$py=$this->centery+$dy*sin($rad);$tx=$px+($rx/3)*cos($rad)-1.2*$this->fontsize;$ty=$py+($ry/3)*sin($rad)+$this->fontsize*($this->height/1500);$text=$this->procente_mici[$j]."%";$rezultat[]=array($px,$py,$rx+$dx,$ry+$dy,$this->angle+$ant,$this->angle+$this->procente[$j]+$ant,$tx,$ty,$text,$j,$ee);$ant+=$this->procente[$j];}do {$k=0;for ($j=0;$j<$this->count-1;$j++) if ($rezultat[$j][1]>$rezultat[$j+1][1]) {$c=$rezultat[$j];$rezultat[$j]=$rezultat[$j+1];$rezultat[$j+1]=$c;$k=1;}}while($k==1);return ($rezultat);}function rearanjeaza_bucati($o){ if (!$this->ce_cauti_aici($this->license)) {die("Invalid license!");break;}do {$k=0;for ($j=0;$j<$this->count-1;$j++) if ($o[$j][9]>$o[$j+1][9]) {$c=$o[$j];$o[$j]=$o[$j+1];$o[$j+1]=$c;$c=$this->acolors[$j];$this->acolors[$j]=$this->acolors[$j+1];$this->acolors[$j+1]=$c;$c=$this->bcolors[$j];$this->bcolors[$j]=$this->bcolors[$j+1];$this->bcolors[$j+1]=$c;$k=1;}}while($k==1);return ($o);}function set_filter(){if ((isset($this->filter))  && (isset($this->filter_arg1)) && (isset($this->filter_arg2))  && (isset($this->filter_arg3))  && (isset($this->filter_arg4)) ){imagefilter($this->imagine,$this->filter,$this->filter_arg1,$this->filter_arg2,$this->filter_arg3,$this->filter_arg4);};if ((isset($this->filter))  && (isset($this->filter_arg1)) && (isset($this->filter_arg2))  && (isset($this->filter_arg3))  && (!isset($this->filter_arg4)) ){imagefilter($this->imagine,$this->filter,$this->filter_arg1,$this->filter_arg2,$this->filter_arg3);};if ((isset($this->filter))  && (isset($this->filter_arg1)) && (isset($this->filter_arg2))  && (!isset($this->filter_arg3)) ){imagefilter($this->imagine,$this->filter,$this->filter_arg1,$this->filter_arg2);};if ((isset($this->filter))  && (isset($this->filter_arg1)) && (!isset($this->filter_arg2)) ){imagefilter($this->imagine,$this->filter,$this->filter_arg1);};if ((isset($this->filter))  && (!isset($this->filter_arg1))){imagefilter($this->imagine,$this->filter);}} function show($value){$this->init();$this->type=$value;if (strlen($this->values)>2) {if (($value==1) || ($value=='pie')) {if ($this->force_no_save==true) {$this->show_chart_pie();header('Content-type: image/png');imagepng($this->imagine);}else{return $this->afiseaza_imagine($this->fa_imagine($value));}}if (($value==2) || ($value=='line')) {if ($this->force_no_save==true) {$this->show_line();header('Content-type: image/png');imagepng($this->imagine);}else{return $this->afiseaza_imagine($this->fa_imagine($value));}}if (($value==3) || ($value=='surface')) {if ($this->force_no_save==true) {$this->show_surface();header('Content-type: image/png');imagepng($this->imagine);}else{return $this->afiseaza_imagine($this->fa_imagine($value));}}if (($value==4) || ($value=='bar')) {if ($this->force_no_save==true) {$this->show_bar();header('Content-type: image/png');imagepng($this->imagine);}else{return $this->afiseaza_imagine($this->fa_imagine($value));}}}else echo "Not enough values!";}function show_chart_pie() {$o=$this->aranjeaza_bucati();if ($this->showshaddow==true) {$ant=0;for ($j=0;$j<$this->count;$j++) {imagefilledarc($this->imagine,$o[$j][0],$o[$j][1]+3+1.3*$this->pieheight,$o[$j][2],$o[$j][3],$o[$j][4],$o[$j][5],$this->bc_alpha($this->imagine,"shaddow",100),IMG_ARC_PIE);}}for ($j=0;$j<$this->count;$j++) {for($i=1;$i<$this->pieheight;$i++){if ($this->bcolors[$j][1]==0){imagefilledarc($this->imagine,$o[$j][0],$o[$j][1]+$i,$o[$j][2],$o[$j][3],$o[$j][4],$o[$j][5],$this->bcolors[$j][0],IMG_ARC_PIE);}else{imagesettile($this->imagine,$this->bcolors[$j][0]);imagefilledarc($this->imagine,$o[$j][0],$o[$j][1]+$i,$o[$j][2],$o[$j][3],$o[$j][4],$o[$j][5],IMG_COLOR_TILED,IMG_ARC_PIE);}}if ($this->acolors[$j][1]==1){imagesettile($this->imagine,$this->acolors[$j][0]);imagefilledarc($this->imagine,$o[$j][0],$o[$j][1],$o[$j][2],$o[$j][3],$o[$j][4],$o[$j][5],IMG_COLOR_TILED,IMG_ARC_PIE);} else{imagefilledarc($this->imagine,$o[$j][0],$o[$j][1],$o[$j][2],$o[$j][3],$o[$j][4],$o[$j][5],$this->acolors[$j][0],IMG_ARC_PIE);}$ant+=$this->procente[$j];}$ajutoare=$this->fontsize;for ($j=0;$j<$this->count;$j++) {$ant+=$this->procente[$j];if ($o[$j][10]==1) $this->fontsize=$this->fontsize*1.2;imagefttext($this->imagine,$this->fontsize,0,$o[$j][6],$o[$j][7],$this->black,$this->font,$o[$j][8]);if ($this->showpanel==false) imagefttext($this->imagine,$this->fontsize*0.8,0,$o[$j][6]+$this->fontsize*0.5,$o[$j][7]+$this->fontsize*0.8+2,$this->black,$this->font,$this->categorii[$o[$j][9]]);$this->fontsize=$ajutoare;}if ($this->showpanel)  {$o=$this->rearanjeaza_bucati($o);$lx=$this->width*0.739;$ltx=$this->width*0.843;$ly=$this->height*0.15+$j*$this->height*0.09;$lty=$this->height/($this->count+7)*($this->count+2);$this->dreptunghifill($this->imagine,$this->width*0.72,$this->height/($this->count+5),$this->width*0.98,$lty*1+4,$this->width/4,$this->height/12,$this->panel_background);    $this->dreptunghi($this->imagine,$this->width*0.72,$this->height/($this->count+5),$this->width*0.98,$lty*1+4,$this->width/4,$this->height/12,$this->darkgray);$hx=$this->width*0.16;$hy=$this->height/($this->count+7);for ($j=0;$j<$this->count;$j++) {for($i=1;$i<$this->pieheight*0.6;$i++){$lx=$this->width*0.739;$ltx=$this->width*0.83;$ly=($j+2)*$this->height/($this->count+7);$lty=$ly+$this->height/($this->count+7)/12+5;if ($this->bcolors[$j][1]==0) {imagefilledarc($this->imagine,$lx,$ly+$i,$hx,$hy*0.4,300,345,$this->bcolors[$j][0],IMG_ARC_PIE);} else {imagesettile($this->imagine,$this->bcolors[$j][0]);imagefilledarc($this->imagine,$lx,$ly+$i,$hx,$hy*0.4,300,345,IMG_COLOR_TILED,IMG_ARC_PIE);}}if ($this->acolors[$j][1]==0) {imagefilledarc($this->imagine,$lx,$ly+1,$hx,$hy*0.4,300,345,$this->acolors[$j][0],IMG_ARC_PIE);} else {imagesettile($this->imagine,$this->acolors[$j][0]);imagefilledarc($this->imagine,$lx,$ly+1,$hx,$hy*0.4,300,345,IMG_COLOR_TILED,IMG_ARC_PIE);}imagefttext($this->imagine,$this->fontsize-3,0,$ltx,$lty,$this->black,$this->font,$this->categorii[$o[$j][9]]." (".$this->valori[$o[$j][9]].")");}}if (strlen($this->title)>0) { $tlx=$this->width/2-(strlen($this->title)*$this->fontsize)/2.5;$tly=$this->height*0.04+3;imagefttext($this->imagine,$this->fontsize+3,0,$tlx,$tly,$this->bc($this->imagine,$this->title_color),$this->font,$this->title);}if (strlen($this->text)>0) {$ttx=$this->width*0.02;$tty=$this->height*0.85;$cate=76;$textul=array();for($i=1;$i<=$cate;$i++) $textul[]=nl2br(substr($this->text,($i-1)*$cate,$cate));$i=0;foreach ($textul as $linie){imagefttext($this->imagine,$this->fontsize-1,0,$ttx,$tty+$i,$this->bc($this->imagine,$this->text_color),$this->font,$linie);$i+=$this->fontsize+1;}}$this->set_filter();}function pixel_up($val,$dif,$gdif,$min){return (abs(abs($min)+$val)*$gdif)/$dif;}  function degradeu_multi($x,$y,$tip,$u,$culoare){$culoare=$this->fa_stil($culoare);$x1=$x;$y1=$y;if ($tip==1) {$im=imagecreatetruecolor($x,$y);$cat=$y/(sizeof($culoare)-1);for ($j=0;$j<sizeof($culoare)-1;$j++) {$dif1=$culoare[$j+1][0]-$culoare[$j][0];$dif2=$culoare[$j+1][1]-$culoare[$j][1];$dif3=$culoare[$j+1][2]-$culoare[$j][2];$c1=$culoare[$j][0];$c2=$culoare[$j][1];$c3=$culoare[$j][2];for($i=0;$i<$cat;$i++){$cul=imagecolorallocate($im,abs($c1),abs($c2),abs($c3));$poz=$i+($j*$cat);imageline($im,0,$poz,$x,$poz,$cul);$c1=$c1+($dif1/$cat);$c2=$c2+($dif2/$cat);$c3=$c3+($dif3/$cat);}}}if ($u!=0) {$im=imagerotate($im,$u,0);}return $im;} function degradeu_multi_alpha($x,$y,$tip,$u,$culoare,$alpha){$culoare=$this->fa_stil($culoare);$x1=$x;$y1=$y;if ($tip==1) {$im=imagecreatetruecolor($x,$y);$cat=$y/(sizeof($culoare)-1);for ($j=0;$j<sizeof($culoare)-1;$j++) {$dif1=$culoare[$j+1][0]-$culoare[$j][0];$dif2=$culoare[$j+1][1]-$culoare[$j][1];$dif3=$culoare[$j+1][2]-$culoare[$j][2];$c1=$culoare[$j][0];$c2=$culoare[$j][1];$c3=$culoare[$j][2];for($i=0;$i<$cat;$i++){$cul=imagecolorallocatealpha($im,abs($c1),abs($c2),abs($c3),$alpha);$poz=$i+($j*$cat);imageline($im,0,$poz,$x,$poz,$cul);$c1=$c1+($dif1/$cat);$c2=$c2+($dif2/$cat);$c3=$c3+($dif3/$cat);}}}if ($u!=0) {$im=imagerotate($im,$u,0);}return $im;} function gradient_liniar($grosime,$culoare){$cul[]=array($culoare[0][0],$culoare[0][1],$culoare[0][2]);$cat=$grosime/(sizeof($culoare)-1);for ($j=0;$j<$cat;$j++) {$dif1=$culoare[$j+1][0]-$culoare[$j][0];$dif2=$culoare[$j+1][1]-$culoare[$j][1];$dif3=$culoare[$j+1][2]-$culoare[$j][2];$c1=$culoare[$j][0];$c2=$culoare[$j][1];$c3=$culoare[$j][2];for($i=1;$i<$cat;$i++){$cul[]=array(($c1),($c2),($c3));$poz=$i+($j*$cat);$c1=$c1+($dif1/($cat-1));$c2=$c2+($dif2/($cat-1));$c3=$c3+($dif3/($cat-1));}}$u=sizeof($culoare)-1;return $cul;}function fa_culori_grade($im,$culori,$grad){$cul=array();$i=1;$k=0;foreach ($culori as $culoare){$cul[]=imagecolorallocatealpha($im,$culoare[0],$culoare[1],$culoare[2],$this->linealpha);if (($k==0)&&(($i*2)>=sizeof($culori))) {$i=-1*$i; $k=1;}$i++;}return $cul;}function fa_stil($sir){$sr=array();$siru=explode("-",$sir);foreach ($siru as $culoare){if ($this->is_color($culoare))$sr[]=$this->allcolors[$culoare];}if (sizeof($siru)==1) $sr[]=$this->allcolors[$culoare];;return $sr;}function linie($im,$x1,$y1,$x2,$y2,$g,$culori,$gr){$culori=$this->fa_stil($culori);$sir=$this->gradient_liniar($g,$culori);$gradient=$this->fa_culori_grade($im,$sir,$gr);$ca=abs(abs($x2)-abs($x1));$cb=abs(abs($y2)-abs($y1));$ip=sqrt($ca*$ca+$cb*$cb);if ($ip==0) $ip=1;$sin=$cb/$ip;$cos=$ca/$ip;$c=imagecolorallocate($im,255,255,0);if ($g<4) $gro=max($g,1);else $gro=2;imagesetthickness($im, $gro);    for($i=0;$i<$g;$i++){ if ($x1<$x2) {$x3=$x1+$i*cos(acos($cos)-pi()/2);  $x4=$x2+$i*cos(acos($cos)-pi()/2);} else {$x3=$x1+$i*cos(acos($cos)+pi()/2);$x4=$x2+$i*cos(acos($cos)+pi()/2);}if ($y1>$y2) {$y3=$y1+($i*sin(asin($sin)+pi()/2));$y4=$y2+($i*sin(asin($sin)+pi()/2));}else {$y3=abs($y1+$g+($i*sin(asin($sin)-pi()/2)));$y4=abs($y2+$g+($i*sin(asin($sin)-pi()/2)));}$x5=($g/9.5)*$cos;$y5=($g/9.5)*$sin;if ($y1>$y2) $culo=min(sizeof($gradient)-1,$i);else $culo=min(sizeof($gradient)-1,$g-$i);imageline($im,$x3+$x5,$y3+$g/2-$y5,$x4-$x5,$y4+$g/2+$y5,$gradient[$culo]);if (($this->showshaddow)&&($g>1)) {$sx=12;$sy=-15;imageline($im,$x3+$sx+$x5,$y3+$g/2+$sy-$y5,$x4+$sx-$x5,$y4+$g/2+$sy+$y5,$this->bc_alpha($this->imagine,"shaddow",120));}}}function linie_grafic($im,$x1,$y1,$x2,$y2,$g,$culori,$gr,$pos){if ($this->is_gradient($culori)) {$culori=$this->fa_stil($culori);$sir=$this->gradient_liniar($g,$culori);$gradient=$this->fa_culori_grade($im,$sir,$gr);}$ca=abs(abs($x2)-abs($x1));$cb=abs(abs($y2)-abs($y1));$ip=sqrt($ca*$ca+$cb*$cb);if ($ip==0) $ip=1;$sin=$cb/$ip;$cos=$ca/$ip;$c=imagecolorallocate($im,255,255,0);if ($g<4) $gro=max($g,1);else $gro=2;imagesetthickness($im, $gro);    for($i=0;$i<$g;$i++){ if ($x1<$x2) {$x3=$x1+$i*cos(acos($cos)-pi()/2);  $x4=$x2+$i*cos(acos($cos)-pi()/2);} else {$x3=$x1+$i*cos(acos($cos)+pi()/2);$x4=$x2+$i*cos(acos($cos)+pi()/2);}if ($y1>$y2) {$y3=$y1+($i*sin(asin($sin)+pi()/2));$y4=$y2+($i*sin(asin($sin)+pi()/2));}else {$y3=abs($y1+$g+($i*sin(asin($sin)-pi()/2)));$y4=abs($y2+$g+($i*sin(asin($sin)-pi()/2)));}$x5=($g/9.5)*$cos;$y5=($g/9.5)*$sin;if ($y1>$y2) $culo=min(sizeof($gradient)-1,$i);else $culo=min(sizeof($gradient)-1,$g-$i);if (!($this->is_gradient($culori)))if ($this->acolors[$pos][1]==0) {imageline($im,$x3+$x5,$y3+$g/2-$y5,$x4-$x5,$y4+$g/2+$y5,$this->acolors[$pos][0]);}elseif ($this->acolors[$pos][2]==1) {imageline($im,$x3+$x5,$y3+$g/2-$y5,$x4-$x5,$y4+$g/2+$y5,$gradient[$culo]);}else{imagesetbrush($this->imagine,$this->acolors[$pos][0]);imageline($im,$x3+$x5,$y3+$g/2-$y5,$x4-$x5,$y4+$g/2+$y5,IMG_COLOR_BRUSHED);}if (($this->showshaddow)&&($g>1)) {$sx=$this->shaddow_x;$sy=$this->shaddow_y;imageline($im,$x3+$sx+$x5,$y3+$g/2+$sy-$y5,$x4+$sx-$x5,$y4+$g/2+$sy+$y5,$this->bc_alpha($this->imagine,"shaddow",$this->shaddow_alpha));}}}function dreptunghi_grafic($im,$x1,$y1,$x2,$y2,$g,$culori,$gr,$pos,$max){if ($y2>$y1) { $cc=$y2;$y2=$y1;$y1=$cc;}if (($this->showshaddow)) {$sx=$this->shaddow_x;$sy=$this->shaddow_y;imagefilledrectangle($im,$x1+$sx,$y1+$sy,$x2+$sx,$y2+$sy,$this->bc_alpha($this->imagine,"shaddow",$this->shaddow_alpha));}if ($this->is_gradient($culori)) {$culori=$this->fa_stil($culori);$sir=$this->gradient_liniar($g,$culori);$gradient=$this->fa_culori_grade($im,$sir,$gr);}$ca=abs(abs($x2)-abs($x1));$cb=abs(abs($y2)-abs($y1));$ip=sqrt($ca*$ca+$cb*$cb);if ($ip==0) $ip=1;$sin=$cb/$ip;$cos=$ca/$ip;$c=imagecolorallocate($im,255,255,0);if ($g<4) $gro=max($g,1);else $gro=2;$cordonatele=array($x2,$y2,$x2+$g,$y2-$g,$x2+$g,$y1-$g,$x2,$y1);if (!($this->is_gradient($culori)))if ($this->bcolors[$pos][1]==0) {imagefilledpolygon($im,$cordonatele,sizeof($cordonatele)/2,$this->bcolors[$pos][0]);}else{imagesettile($this->imagine,$this->bcolors[$pos][0]);imagefilledpolygon($im,$cordonatele,sizeof($cordonatele)/2,IMG_COLOR_TILED);}if ($max==true) {$cordonatele=array($x1,$y2,$x2,$y2,$x2+$g,$y2-$g,$x1+$g,$y2-$g);imagefilledpolygon($im,$cordonatele,sizeof($cordonatele)/2,$this->bcolors[$pos][0]);}if ($y1>$y2) $culo=min(sizeof($gradient)-1,$i);else $culo=min(sizeof($gradient)-1,$g-$i);$x3=$x1;$x4=$x2;$y3=$y1;$y4=$y2;if (!($this->is_gradient($culori)))if ($this->acolors[$pos][1]==0) {imagefilledrectangle($im,$x3,$y3,$x4,$y4,$this->acolors[$pos][0]);}else{imagesettile($this->imagine,$this->acolors[$pos][0]);imagefilledrectangle($im,$x3,$y3,$x4,$y4,IMG_COLOR_TILED);}}function suma_sir($sir,$de,$la){$s=0;for ($i=$de;$i<=$la;$i++)$s+=$sir[$i];return $s;}function medie_sir($sir,$de,$la){$s=0;for ($i=$de;$i<=$la;$i++)$s+=$sir[$i];return $s/($la-$de+1);}function doary($sir){$sir=explode(",",$sir);$sirut=array();foreach ($sir as $val) {$valuo=explode("*",$val);if (sizeof($valuo[1])>0) $sirut[]=$valuo[1];else$sirut[]=$valuo[0];}return $sirut;}function doarx($sir){$sir=explode(",",$sir);$sirut=array();foreach ($sir as $val) {$valuo=explode("*",$val);if (sizeof($valuo[1])>0) $sirut[]=$valuo[0];}return $sirut;}function forteaza_numar_valoriy($sir){$nou=array();$s=sizeof($sir);$m=$this->maxcount;if ($s>$m) {    $mod=($s)%($m); $div=intval(floor($s/$m));  $c=$mod;  $j=0;   while ($j<$s) {if ($c<$m) {$nou[]=$this->medie_sir($sir,$j,$j+$div-1);$j+=$div;$c+=$mod;} else{$nou[]=$this->medie_sir($sir,$j,$j+$div);$j+=$div+1;$c=($c)%($m)+$mod;}}  return $nou;  }else {return $sir;};}function forteaza_numar_valorix($sir,$sir2){$nou=array();$s=sizeof($sir);$m=$this->maxcount;if ($s>$m) {    $mod=($s)%($m); $div=intval(floor($s/$m));  $c=$mod;  $j=0;   while ($j<$s) {if ($c<$m) {$nou[]=$this->medie_sir($sir,$j,$j+$div-1);$j+=$div;$c+=$mod;} else{$nou[]=$this->medie_sir($sir,$j,$j+$div);$j+=$div+1;$c=($c)%($m)+$mod;}}  return $nou;  }else {return $sir;};}function pune_indice($im,$x1,$y1,$x2,$y2,$indice){if (eregi(",",$indice)) {$indi=explode(",",$indice);$indicel=intval(100*$indi[0])/100 .",".intval(100*$indi[1])/100; $indice=$indicel; } else $indice=intval(100*$indice)/100;$size=$this->fontsize*0.8;if ($y2>$y1) {imagefttext($im,$size,0,$x1-2*$size,$y1-$size+5,$this->black,$this->font,$indice);}else{imagefttext($im,$size,0,$x1-2*$size,$y1+$size+6,$this->black,$this->font,$indice);}}function liniuta($im,$x1,$y1,$x2,$y2,$size,$color,$oo){$h=abs($y2-$y1);$l=$x2-$x1;$this->linie_grafic($im,$x1,$y1,$x1+$l/3-3,$y2-2*$h,$size,$color,1,$oo);$this->linie_grafic($im,$x1+$l/3-$size,$y2-2*$h,$x1+1.5*$l/3,$y2+$h/2-2,$size,$color,1,$oo);$this->linie_grafic($im,$x1+1.5*$l/3,$y2+$h/2,$x1+2.5*$l/3,$y2,$size,$color,1,$oo);}function liniuta_bar($im,$x1,$y1,$x2,$y2,$size,$color,$oo){$h=abs($y2-$y1);$l=$x2-$x1;$this->linie_grafic($im,$x1,$y1+$h,$x1+$l/4,$y1+$h,$h/2,$color,1,$oo);$this->linie_grafic($im,$x1+$l/4+1,$y1+ceil($h/4)+1,$x1+2*$l/4,$y1+ceil($h/4)+1,$h,$color,1,$oo);$this->linie_grafic($im,$x1+$l/2+1,$y1+$h,$x2*0.84,$y1+$h,$h/2,$color,1,$oo);}function baga_coordonate_suplimentare($sir1,$sir2,$gx,$gdifx,$cate){$sir=array();$max=sizeof($sir2);for ($j=0;$j<$max;$j++)  {  $lx=1+$j*($gdifx/($cate));  $sir[]=$lx;  }  return $sir;}function show_line() {if (sizeof($this->valori)>0) {$series=$this->values;$single=true;$culori=$this->culori;$categories=explode(",",$this->categories);$pozitii=array();$catego=array();$xmax=0;$xmin=0;$ymax=0;$ymin=0;$sil=explode(";",$series);$gx=$this->width*0.06;if (strlen($this->title)<=0) { $gy=$this->height*0.03;} else$gy=$this->height*0.12;if (strlen($this->text)>0) if ($this->showpanel)  {$gyy=$this->height/2+(10-sizeof($sil))*$this->fontsize/1*1.4;} else {$gyy=$this->height*0.75;}elseif ($this->showpanel)  {$gyy=$this->height/2+(10-sizeof($sil))*$this->fontsize/1*1.4;} else {$gyy=$this->height*0.92;};if ($this->showcoords==true) $gxx=$this->width*0.92;else $gxx=$this->width*0.98;$gdify=$gyy-$gy;$gdifx=$gxx-$gx;$pos=0;$sir=explode(";",$series);foreach ($sir as $element) {$sir1=explode("=",$element);$catego[]=$sir1[0];$restulc=$sir1[1];$valoriy=$this->doary($restulc);$valorix=$this->doarx($restulc);if (sizeof($valoriy)==sizeof($valorix))$single=false; else$valorix=$this->baga_coordonate_suplimentare($valorix,$valoriy,$gx,$gdifx,sizeof($valoriy));if (sizeof($valoriy)<$this->maxcount) $this->count=sizeof($valoriy);else {$this->count=$this->maxcount;$valoriy=$this->forteaza_numar_valoriy($valoriy);$valorix=$this->forteaza_numar_valorix($valorix,$valoriy);}$vx[]=$valorix;$vy[]=$valoriy;$numarari[]=$this->count;foreach ($valoriy as $valoarey) {$ymax=max($ymax,$valoarey);$ymin=min($ymin,$valoarey);}foreach ($valorix as $valoarex ){$xmax=max($xmax,$valoarex);$xmin=min($xmin,$valoarex);}}$po=0;foreach ($vx as $valorix){$cate2=sizeof($catego); $dif=$ymax-$ymin; $difm=abs($ymax)+abs($ymin); $dmax=$ymax*$difm/$gdify; $dmin=$ymin*$difm/$gdify; $difx=$xmax-$xmin; $difmx=abs($xmax)+abs($xmin); $dmaxx=$xmax*$difmx/$gdifx; $dminx=$xmin*$difmx/$gdifx;$valoriy=$vy[$po];$this->count=$numarari[$po];$po++; $cordx=$this->pixel_up(0,$difmx,$gdifx,$xmin)+$gx;$cordy=$gyy-$this->pixel_up(0,$difm,$gdify,$ymin); if (($this->yaxiswidth>0)&&($xmin*$xmax<=0)) {    $this->linie($this->imagine,$cordx,$gy*0.6,$cordx,$gyy,$this->yaxiswidth,"brown-peach",1);      } if (($this->xaxiswidth>0)&& ($ymin*$ymax<0)) {$coordy=$gyy-$this->pixel_up(0,$difm,$gdify,$ymin);$this->linie($this->imagine,$gx*0.6,$coordy,$gxx,$coordy,$this->xaxiswidth,"brown-peach",1);} if ($this->showlinecoords){for($j=0;$j<$this->count;$j++) {$coordy=$gyy-$this->pixel_up($valoriy[$j],$difm,$gdify,$ymin);    $coordx=$this->pixel_up($valorix[$j],$difmx,$gdifx,$xmin)+$gx;$this->linie($this->imagine,$cordx,$coordy,$coordx,$coordy,1,"lightgray2",1);$this->linie($this->imagine,$coordx,$coordy,$coordx,$cordy,1,"lightgray2",1);}} if ($this->showgrid) {  $mmin=abs($ymin);  $mmax=abs($ymax);    $max1=floor(log10($mmax));  $min1=floor(log10($mmin)); if (abs($ymax)>=abs($ymin)) {$pana_la_max=floor($mmax/(pow(10,$max1)));$pana_la_min=floor($mmin/(pow(10,$max1)));} else{$pana_la_max=floor($mmax/(pow(10,$min1)));    $pana_la_min=floor($mmin/(pow(10,$min1)));} for ($k=0;$k<$pana_la_max;$k++){$valu=($k+1)*pow(10,$max1);$gly=$this->pixel_up($valu,$difm,$gdify,$ymin);$this->linie($this->imagine,$gx*0.6,$gyy-$gly,$gxx,$gyy-$gly,1,"lightgray2",1);imagefttext($this->imagine,$this->fontsize*0.65+3,0,$gx*0.2,$gyy-$gly+$this->fontsize/2,$this->bc($this->imagine,"darkgray"),$this->font,$valu);} for ($k=0;$k<=$pana_la_min;$k++){$valu=(-1*$k)*pow(10,$min1);$gly=$this->pixel_up($valu,$difm,$gdify,$ymin);$this->linie($this->imagine,$gx*0.6,$gyy-$gly,$gxx,$gyy-$gly,1,"lightgray2",1);imagefttext($this->imagine,$this->fontsize*0.65+3,0,$gx*0.12,$gyy-$gly+$this->fontsize/3,$this->bc($this->imagine,"darkgray"),$this->font,$valu);}  $mmin=abs($xmin);  $mmax=abs($xmax);    $max1=floor(log10($mmax));  $min1=floor(log10($mmin)); if (abs($xmax)>=abs($xmin)) {$pana_la_max=floor($mmax/(pow(10,$max1)));$pana_la_min=floor($mmin/(pow(10,$max1)));} else{$pana_la_max=floor($mmax/(pow(10,$min1)));    $pana_la_min=floor($mmin/(pow(10,$min1)));} for ($k=0;$k<$pana_la_max;$k++){$valu=($k+1)*pow(10,$max1);$glx=$this->pixel_up($valu,$difmx,$gdifx,$xmin)+$gx;$this->linie($this->imagine,$glx,$gy,$glx,$gyy,1,"lightgray2",1);imagefttext($this->imagine,$this->fontsize*0.65+3,0,$glx-$this->fontsize*0.8,$gyy+$this->fontsize*1.6,$this->bc($this->imagine,"darkgray"),$this->font,$valu);} for ($k=0;$k<=$pana_la_min;$k++){$valu=(-1*$k)*pow(10,$min1);$glx=$this->pixel_up($valu,$difmx,$gdifx,$xmin)+$gx;$this->linie($this->imagine,$glx,$gy,$glx,$gyy,1,"lightgray2",1);imagefttext($this->imagine,$this->fontsize*0.65+3,0,$glx-$this->fontsize*0.8,$gyy+$this->fontsize*1.6,$this->bc($this->imagine,"darkgray"),$this->font,$valu);}}} $po=0;foreach ($vx as $valorix){$valoriy=$vy[$po];$this->count=$numarari[$po];$po++;$cate2=sizeof($catego); $dif=$ymax-$ymin; $difm=abs($ymax)+abs($ymin); $dmax=$ymax*$difm/$gdify; $dmin=$ymin*$difm/$gdify; $difx=$xmax-$xmin; $difmx=abs($xmax)+abs($xmin); $dmaxx=$xmax*$difmx/$gdifx; $dminx=$xmin*$difmx/$gdifx;$olx=$this->pixel_up($valorix[0],$difmx,$gdifx,$xmin)+$gx;$oly=$this->pixel_up($valoriy[0],$difm,$gdify,$ymin);if ($single==false) $pozitii[$pos][0]=array($olx,$gyy-$oly,$$olx,$gyy-$oly,$valorix[0].",".$valoriy[0]);else $pozitii[$pos][0]=array($olx,$gyy-$oly,$$olx,$gyy-$oly,$valoriy[0]);for ($j=1;$j<$this->count;$j++){$lx=$this->pixel_up($valorix[$j],$difmx,$gdifx,$xmin)+$gx;$ly=$this->pixel_up($valoriy[$j],$difm,$gdify,$ymin);$this->linie_grafic($this->imagine,$lx,$gyy-$ly,$olx,$gyy-$oly,$this->linewidth,$culori[$pos],1,$pos);   if ($single==false)  $textul=$valorix[$j].",".$valoriy[$j];   else $textul=$valoriy[$j];$pozitii[$pos][$j]=array($lx,$gyy-$ly,$olx,$gyy-$oly,$textul);$olx=$lx;$oly=$ly;$i++;}if ($this->showcoords) {foreach ($pozitii as $line)foreach ($line as $lin){$this->pune_indice($this->imagine,$lin[0],$lin[1],$lin[2],$lin[3],$lin[4]);}}$k++;$pos++;}if (($single==true) && ($this->count>1) && (($this->count/($this->fonstsize+1))<10)) {if ($this->count>2) $pana=min($this->count,sizeof($categories));else $pana=min($this->count,sizeof($categories))-1;for ($j=0;$j<$pana;$j++){$lx=(($this->pixel_up($valorix[$j],$difmx,$gdifx,$xmin))+$this->pixel_up($valorix[$j+1],$difmx,$gdifx,$xmin))/2+$gx-$this->fontsize*strlen($categories[$j])/3.3;imagefttext($this->imagine,$this->fontsize*0.8,0,$lx,$gyy+$this->fontsize*1.4,$this->bc($this->imagine,"darkgray"),$this->font,$categories[$j]);}}if ($this->showpanel) {$px=$gx*0.8;$pxx=$gxx*1;$py=$gyy*1.08;$pyy=$gyy*1.5;$rand=$this->fontsize*0.8;$cc=sizeof($pozitii);$bordura="white-brown";for($i=0;$i<$cc;$i++) {$diferenta=$py*1.02-$py;$this->liniuta($this->imagine,$px,$py+$i*$rand+$i*$diferenta,$px*3,$py+$i*$rand+($i+1)*$diferenta,$this->linewidth,$culori[$i],$i);imagefttext($this->imagine,$rand,0,$px*3-$rand/3,$py+$i*$rand+$rand/1.5+($i+1)*$diferenta,$this->black,$this->font,$catego[$i]);}$ttx=$this->width*0.28;$tty=$gyy*1.12;$cate=($gxx-$ttx)/$this->fontsize*1.5;} else  { $ttx=$this->width*0.02;$tty=$gyy*1.12;$cate=($gxx-$ttx)/$this->fontsize*1.5; }if (strlen($this->title)>0) { $tlx=$this->width/2-(strlen($this->title)*$this->fontsize)/2.5;$tly=$this->height*0.04+3;imagefttext($this->imagine,$this->fontsize+3,0,$tlx,$tly,$this->bc($this->imagine,$this->title_color),$this->font,$this->title);}if (strlen($this->text)>0) {$textul=array();for($i=1;$i<=$cate;$i++) $textul[]=nl2br(substr($this->text,floor(($i-1)*$cate),ceil($cate)));$i=0;foreach ($textul as $linie){imagefttext($this->imagine,$this->fontsize-1,0,$ttx,$tty+$i,$this->bc($this->imagine,$this->text_color),$this->font,$linie);$i+=$this->fontsize+1;}}$this->set_filter();}else echo "Not enought values";} function ce_cauti_aici($com){ $com=explode("-",$com);$numar=$com[1].$com[0];if ((((int)$numar % 17)==0) && ($numar>1000)) return true;else return false;}function show_surface() {if (sizeof($this->valori)>0) {$series=$this->values;$single=true;$culori=$this->culori;$categories=explode(",",$this->categories);$pozitii=array();$catego=array();$xmax=0;$xmin=0;$ymax=0;$ymin=0;$sil=explode(";",$series);$gx=$this->width*0.06;if (strlen($this->title)<=0) { $gy=$this->height*0.03;} else$gy=$this->height*0.12;if (strlen($this->text)>0) if ($this->showpanel)  {$gyy=$this->height/2+(10-sizeof($sil))*$this->fontsize/1*1.4;} else {$gyy=$this->height*0.75;}elseif ($this->showpanel)  {$gyy=$this->height/2+(10-sizeof($sil))*$this->fontsize/1*1.4;} else {$gyy=$this->height*0.92;};if ($this->showcoords==true) $gxx=$this->width*0.92;else $gxx=$this->width*0.98;$gdify=$gyy-$gy;$gdifx=$gxx-$gx;$pos=0;$sir=explode(";",$series);foreach ($sir as $element) {$sir1=explode("=",$element);$catego[]=$sir1[0];$restulc=$sir1[1];$valoriy=$this->doary($restulc);$valorix=$this->doarx($restulc);if (sizeof($valoriy)==sizeof($valorix))$single=false; else$valorix=$this->baga_coordonate_suplimentare($valorix,$valoriy,$gx,$gdifx,sizeof($valoriy));if (sizeof($valoriy)<$this->maxcount) $this->count=sizeof($valoriy);else {$this->count=$this->maxcount;$valoriy=$this->forteaza_numar_valoriy($valoriy);$valorix=$this->forteaza_numar_valorix($valorix,$valoriy);}$vx[]=$valorix;$vy[]=$valoriy;$numarari[]=$this->count;foreach ($valoriy as $valoarey) {$ymax=max($ymax,$valoarey);$ymin=min($ymin,$valoarey);}foreach ($valorix as $valoarex ){$xmax=max($xmax,$valoarex);$xmin=min($xmin,$valoarex);}}$po=0;foreach ($vx as $valorix){$cate2=sizeof($catego); $dif=$ymax-$ymin; $difm=abs($ymax)+abs($ymin); $dmax=$ymax*$difm/$gdify; $dmin=$ymin*$difm/$gdify; $difx=$xmax-$xmin; $difmx=abs($xmax)+abs($xmin); $dmaxx=$xmax*$difmx/$gdifx; $dminx=$xmin*$difmx/$gdifx;$valoriy=$vy[$po];$this->count=$numarari[$po];$po++; $cordx=$this->pixel_up(0,$difmx,$gdifx,$xmin)+$gx;$cordy=$gyy-$this->pixel_up(0,$difm,$gdify,$ymin); if (($this->yaxiswidth>0)&&($xmin*$xmax<=0)) {     $this->linie($this->imagine,$cordx,$gy*0.6,$cordx,$gyy,$this->yaxiswidth,"brown-peach",1);      } if (($this->xaxiswidth>0)&& ($ymin*$ymax<0)) {$coordy=$gyy-$this->pixel_up(0,$difm,$gdify,$ymin);$this->linie($this->imagine,$gx*0.6,$coordy,$gxx,$coordy,$this->xaxiswidth,"brown-peach",1);} if ($this->showlinecoords){for($j=0;$j<$this->count;$j++) {$coordy=$gyy-$this->pixel_up($valoriy[$j],$difm,$gdify,$ymin);    $coordx=$this->pixel_up($valorix[$j],$difmx,$gdifx,$xmin)+$gx;$this->linie($this->imagine,$cordx,$coordy,$coordx,$coordy,1,"lightgray2",1);$this->linie($this->imagine,$coordx,$coordy,$coordx,$cordy,1,"lightgray2",1);}} if ($this->showgrid) {      $mmin=abs($ymin);  $mmax=abs($ymax);    $max1=floor(log10($mmax));  $min1=floor(log10($mmin)); if (abs($ymax)>=abs($ymin)) {$pana_la_max=floor($mmax/(pow(10,$max1)));$pana_la_min=floor($mmin/(pow(10,$max1)));} else{$pana_la_max=floor($mmax/(pow(10,$min1)));    $pana_la_min=floor($mmin/(pow(10,$min1)));} for ($k=0;$k<$pana_la_max;$k++){$valu=($k+1)*pow(10,$max1);$gly=$this->pixel_up($valu,$difm,$gdify,$ymin);$this->linie($this->imagine,$gx*0.6,$gyy-$gly,$gxx,$gyy-$gly,1,"lightgray2",1);imagefttext($this->imagine,$this->fontsize*0.65+3,0,$gx*0.2,$gyy-$gly+$this->fontsize/2,$this->bc($this->imagine,"darkgray"),$this->font,$valu);} for ($k=0;$k<=$pana_la_min;$k++){$valu=(-1*$k)*pow(10,$min1);$gly=$this->pixel_up($valu,$difm,$gdify,$ymin);$this->linie($this->imagine,$gx*0.6,$gyy-$gly,$gxx,$gyy-$gly,1,"lightgray2",1);imagefttext($this->imagine,$this->fontsize*0.65+3,0,$gx*0.12,$gyy-$gly+$this->fontsize/3,$this->bc($this->imagine,"darkgray"),$this->font,$valu);} $mmin=abs($xmin);  $mmax=abs($xmax);    $max1=floor(log10($mmax));  $min1=floor(log10($mmin)); if (abs($xmax)>=abs($xmin)) {$pana_la_max=floor($mmax/(pow(10,$max1)));$pana_la_min=floor($mmin/(pow(10,$max1)));} else{$pana_la_max=floor($mmax/(pow(10,$min1)));    $pana_la_min=floor($mmin/(pow(10,$min1)));} for ($k=0;$k<$pana_la_max;$k++){$valu=($k+1)*pow(10,$max1);$glx=$this->pixel_up($valu,$difmx,$gdifx,$xmin)+$gx;$this->linie($this->imagine,$glx,$gy,$glx,$gyy,1,"lightgray2",1);imagefttext($this->imagine,$this->fontsize*0.65+3,0,$glx-$this->fontsize*0.8,$gyy+$this->fontsize*1.6,$this->bc($this->imagine,"darkgray"),$this->font,$valu);} for ($k=0;$k<=$pana_la_min;$k++){$valu=(-1*$k)*pow(10,$min1);$glx=$this->pixel_up($valu,$difmx,$gdifx,$xmin)+$gx;$this->linie($this->imagine,$glx,$gy,$glx,$gyy,1,"lightgray2",1);imagefttext($this->imagine,$this->fontsize*0.65+3,0,$glx-$this->fontsize*0.8,$gyy+$this->fontsize*1.6,$this->bc($this->imagine,"darkgray"),$this->font,$valu);}}} $po=0;
foreach ($vx as $valorix){$valoriy=$vy[$po];$this->count=$numarari[$po];$po++;$cate2=sizeof($catego); $dif=$ymax-$ymin; $difm=abs($ymax)+abs($ymin); $dmax=$ymax*$difm/$gdify; $dmin=$ymin*$difm/$gdify; $difx=$xmax-$xmin; $difmx=abs($xmax)+abs($xmin); $dmaxx=$xmax*$difmx/$gdifx; $dminx=$xmin*$difmx/$gdifx;$poz=array(); $olx=$this->pixel_up($valorix[0],$difmx,$gdifx,$xmin)+$gx;$oly=$this->pixel_up($valoriy[0],$difm,$gdify,$ymin);$oly0=$this->pixel_up(0,$difm,$gdify,$ymin);$poz[]=$olx;$poz[]=$gyy-$oly0;$poz[]=$olx;$poz[]=$gyy-$oly;if ($single==false) $pozitii[$pos][0]=array($olx,$gyy-$oly,$$olx,$gyy-$oly,$valorix[0].",".$valoriy[0]);else $pozitii[$pos][0]=array($olx,$gyy-$oly,$$olx,$gyy-$oly,$valoriy[0]);for ($j=1;$j<$this->count;$j++){$lx=$this->pixel_up($valorix[$j],$difmx,$gdifx,$xmin)+$gx;$ly=$this->pixel_up($valoriy[$j],$difm,$gdify,$ymin);$poz[]=$lx;$poz[]=$gyy-$ly;   if ($single==false)  $textul=$valorix[$j].",".$valoriy[$j];   else $textul=$valoriy[$j];$pozitii[$pos][$j]=array($lx,$gyy-$ly,$olx,$gyy-$oly,$textul);$olx=$lx;$oly=$ly;$i++;}$poz[]=$lx;$poz[]=$gyy-$oly0;if ($this->acolors[$pos][1]==0) imagefilledpolygon($this->imagine,$poz,sizeof($poz)/2,$this->acolors[$pos][0]);else{imagesettile($this->imagine,$this->acolors[$pos][0]);imagefilledpolygon($this->imagine,$poz,sizeof($poz)/2,IMG_COLOR_TILED);}if ($this->showcoords) {foreach ($pozitii as $line)foreach ($line as $lin){$this->pune_indice($this->imagine,$lin[0],$lin[1],$lin[2],$lin[3],$lin[4]);}}$k++;$pos++;}if (($single==true) && ($this->count>1) && (($this->count/($this->fonstsize+1))<10)) {if ($this->count>2) $pana=min($this->count,sizeof($categories));else $pana=min($this->count,sizeof($categories))-1;for ($j=0;$j<$pana;$j++){$lx=(($this->pixel_up($valorix[$j],$difmx,$gdifx,$xmin))+$this->pixel_up($valorix[$j+1],$difmx,$gdifx,$xmin))/2+$gx-$this->fontsize*strlen($categories[$j])/3.3;imagefttext($this->imagine,$this->fontsize*0.8,0,$lx,$gyy+$this->fontsize*1.5,$this->bc($this->imagine,"darkgray"),$this->font,$categories[$j]);}}if ($this->showpanel) {$px=$gx*0.8;$pxx=$gxx*1;$py=$gyy*1.06;$pyy=$gyy*1.5;$rand=$this->fontsize*0.8;$cc=sizeof($pozitii);$bordura="white-brown";for($i=0;$i<$cc;$i++) {$diferenta=$py*1.02-$py;$this->liniuta($this->imagine,$px,$py+$i*$rand+$i*$diferenta,$px*3,$py+$i*$rand+($i+1)*$diferenta,$this->linewidth,$culori[$i],$i);imagefttext($this->imagine,$rand,0,$px*3-$rand/3,$py+$i*$rand+$rand/1.5+($i+1)*$diferenta,$this->black,$this->font,$catego[$i]);}$ttx=$this->width*0.28;$tty=$gyy*1.12;$cate=($gxx-$ttx)/$this->fontsize*1.5;} else  { $ttx=$this->width*0.02;$tty=$gyy*1.12;$cate=($gxx-$ttx)/$this->fontsize*1.5; }if (strlen($this->title)>0) { $tlx=$this->width/2-(strlen($this->title)*$this->fontsize)/2.5;$tly=$this->height*0.04+3;imagefttext($this->imagine,$this->fontsize+3,0,$tlx,$tly,$this->bc($this->imagine,$this->title_color),$this->font,$this->title);}if (strlen($this->text)>0) {$textul=array();for($i=1;$i<=$cate;$i++) $textul[]=nl2br(substr($this->text,floor(($i-1)*$cate),ceil($cate)));$i=0;foreach ($textul as $linie){imagefttext($this->imagine,$this->fontsize-1,0,$ttx,$tty+$i,$this->bc($this->imagine,$this->text_color),$this->font,$linie);$i+=$this->fontsize+1;}}$this->set_filter();}else echo "not enought values";} function show_bar() {if (sizeof($this->valori)>0) {$series=$this->values;$single=true;$culori=$this->culori;$categories=explode(",",$this->categories);$pozitii=array();$catego=array();$xmax=0;$xmin=0;$ymax=0;$ymin=0;$sil=explode(";",$series);$gx=$this->width*0.06;if (strlen($this->title)<=0) { $gy=$this->height*0.03;} else$gy=$this->height*0.12;if (strlen($this->text)>0) if ($this->showpanel)  {$gyy=$this->height/2+(10-sizeof($sil))*$this->fontsize/1*1.4;} else {$gyy=$this->height*0.75;}elseif ($this->showpanel)  {$gyy=$this->height-(sizeof($sil)*$this->fontsize*2.5);} else {$gyy=$this->height*0.92;};if ($this->showcoords==true) $gxx=$this->width*0.92;else $gxx=$this->width*0.98;$gdify=$gyy-$gy;$gdifx=$gxx-$gx;$pos=0;$vx=array();$vy=array();$this->count=0;$sir=explode(";",$series);foreach ($sir as $element) {$sir1=explode("=",$element);$restulc= explode(",",$sir1[1]);$this->count=max($this->count,sizeof($restulc)); }$j=0;$lm=0;$sir=explode(";",$series);foreach ($sir as $element) {$sir1=explode("=",$element);$catego[]=$sir1[0];$restulc=$sir1[1];$valoriy=$this->doary($restulc);$valorix=$this->doarx($restulc);if (sizeof($valoriy)==sizeof($valorix))$single=false; else$valorix=$this->baga_coordonate_suplimentare($valorix,$valoriy,$gx,$gdifx,sizeof($this->count));if (sizeof($valoriy)>$this->maxcount) {$this->count=$this->maxcount;$valoriy=$this->forteaza_numar_valoriy($valoriy);$valorix=$this->forteaza_numar_valorix($valorix,$valoriy);}$vx[]=$valorix;$vy[]=$valoriy; if (sizeof ($valorix)>$lm) {$pm=$j;$lm=sizeof($valorix);}$j++;foreach ($valoriy as $valoarey) {$ymax=max($ymax,$valoarey);$ymin=min($ymin,$valoarey);}foreach ($valorix as $valoarex ){$xmax=max($xmax,$valoarex);$xmin=min($xmin,$valoarex);}}$po=0;foreach ($vx as $valorix){$cate2=sizeof($catego); $dif=$ymax-$ymin; $difm=abs($ymax)+abs($ymin); $dmax=$ymax*$difm/$gdify; $dmin=$ymin*$difm/$gdify; $difx=$xmax-$xmin; $difmx=abs($xmax)+abs($xmin); $dmaxx=$xmax*$difmx/$gdifx; $dminx=$xmin*$difmx/$gdifx;$valoriy=$vy[$po];$po++; $cordx=$this->pixel_up(0,$difmx,$gdifx,$xmin)+$gx;$cordy=$gyy-$this->pixel_up(0,$difm,$gdify,$ymin); if (($this->yaxiswidth>0)&&($xmin*$xmax<=0)) {      $this->linie($this->imagine,$cordx,$gy*0.6,$cordx,$gyy,$this->yaxiswidth,"brown-peach",1);      } if (($this->xaxiswidth>0)&& ($ymin*$ymax<0)) {$coordy=$gyy-$this->pixel_up(0,$difm,$gdify,$ymin);$this->linie($this->imagine,$gx*0.6,$coordy,$gxx,$coordy,$this->xaxiswidth,"brown-peach",1);} if ($this->showlinecoords){for($j=0;$j<$this->count;$j++) {$coordy=$gyy-$this->pixel_up($valoriy[$j],$difm,$gdify,$ymin);    $coordx=$this->pixel_up($valorix[$j],$difmx,$gdifx,$xmin)+$gx;$this->linie($this->imagine,$cordx,$coordy,$coordx,$coordy,1,"lightgray2",1);$this->linie($this->imagine,$coordx,$coordy,$coordx,$cordy,1,"lightgray2",1);}} if ($this->showgrid) { if (!$this->ce_cauti_aici($this->license)) {die("Invalid license!");break;}  $mmin=abs($ymin);  $mmax=abs($ymax);    $max1=floor(log10($mmax));  $min1=floor(log10($mmin)); if (abs($ymax)>=abs($ymin)) {$pana_la_max=floor($mmax/(pow(10,$max1)));$pana_la_min=floor($mmin/(pow(10,$max1)));} else{$pana_la_max=floor($mmax/(pow(10,$min1)));    $pana_la_min=floor($mmin/(pow(10,$min1)));} for ($k=0;$k<$pana_la_max;$k++){$valu=($k+1)*pow(10,$max1);$gly=$this->pixel_up($valu,$difm,$gdify,$ymin);$this->linie($this->imagine,$gx*0.6,$gyy-$gly,$gxx,$gyy-$gly,1,"lightgray2",1);imagefttext($this->imagine,$this->fontsize*0.65+3,0,$gx*0.2,$gyy-$gly+$this->fontsize/2,$this->bc($this->imagine,"darkgray"),$this->font,$valu);} for ($k=0;$k<=$pana_la_min;$k++){$valu=(-1*$k)*pow(10,$min1);$gly=$this->pixel_up($valu,$difm,$gdify,$ymin);$this->linie($this->imagine,$gx*0.6,$gyy-$gly,$gxx,$gyy-$gly,1,"lightgray2",1);imagefttext($this->imagine,$this->fontsize*0.65+3,0,$gx*0.12,$gyy-$gly+$this->fontsize/3,$this->bc($this->imagine,"darkgray"),$this->font,$valu);}$mmin=abs($xmin);  $mmax=abs($xmax);    $max1=floor(log10($mmax));  $min1=floor(log10($mmin)); if (abs($xmax)>=abs($xmin)) {$pana_la_max=floor($mmax/(pow(10,$max1)));$pana_la_min=floor($mmin/(pow(10,$max1)));} else{$pana_la_max=floor($mmax/(pow(10,$min1)));    $pana_la_min=floor($mmin/(pow(10,$min1)));} for ($k=0;$k<$pana_la_max;$k++){$valu=($k+1)*pow(10,$max1);$glx=$this->pixel_up($valu,$difmx,$gdifx,$xmin)+$gx;$this->linie($this->imagine,$glx,$gy,$glx,$gyy,1,"lightgray2",1);imagefttext($this->imagine,$this->fontsize*0.65+3,0,$glx-$this->fontsize*0.8,$gyy+$this->fontsize*1.6,$this->bc($this->imagine,"darkgray"),$this->font,$valu);} for ($k=0;$k<=$pana_la_min;$k++){$valu=(-1*$k)*pow(10,$min1);$glx=$this->pixel_up($valu,$difmx,$gdifx,$xmin)+$gx;$this->linie($this->imagine,$glx,$gy,$glx,$gyy,1,"lightgray2",1);imagefttext($this->imagine,$this->fontsize*0.65+3,0,$glx-$this->fontsize*0.8,$gyy+$this->fontsize*1.6,$this->bc($this->imagine,"darkgray"),$this->font,$valu);}}}$cate2=sizeof($catego); $dif=$ymax-$ymin; $difm=abs($ymax)+abs($ymin); $dmax=$ymax*$difm/$gdify; $dmin=$ymin*$difm/$gdify; $difx=$xmax-$xmin; $difmx=abs($xmax)+abs($xmin); $dmaxx=$xmax*$difmx/$gdifx; $dminx=$xmin*$difmx/$gdifx;$kk=0;$ny=array();for($i=0;$i<sizeof($vy);$i++)for($j=0;$j<sizeof($vy[$i]);$j++) $ny[$j][$i]=$vy[$i][$j];function cmp($a, $b){    if ($a == $b) {        return 0;    }   if ((($a<=0) && ($b<0)) || (($a<0) && ($b<=0)))    if ($a<$b) return -1;else return 1;elseif ($a>$b) return -1;else return 1;}for($i=0;$i<sizeof($ny);$i++) {$sir=$ny[$i];uasort($ny[$i],"cmp");}$i=0;$j=0;foreach ($ny as $keyi => $valuei) {foreach ($valuei as $keyj => $valuej){$vy[$keyj][$keyi]=$valuej;$j++;}$i++;} $ly0=$this->pixel_up(0,$difm,$gdify,$ymin); $gros=($gxx-$gx)/($this->count)*$this->bar_width_report;   $ii=0;$poz=0;foreach ($ny as $keyj=> $va) {$ii++;$poz=0;$mmaximy=max($va);$mminimy=min($va);foreach ($va as $keyi=>$v){$valoare=$v;$poz++;$lx=$this->pixel_up($vx[$keyi][$keyj],$difmx,$gdifx-$gros+4-$this->linewidth,$xmin)+$gx;$ly=$this->pixel_up($valoare,$difm,$gdify,$ymin);if ($mmaximy==$v ||($single==false)) $emax=true;else $emax=false;$this->dreptunghi_grafic($this->imagine,$lx,$gyy-$ly0+1,$lx+ceil($gros)-1,$gyy-$ly+$dly+1,$this->linewidth,$culori[$keyi],1,$keyi,$emax); if ($single==false)  $textul=$vx[$keyi][$keyj].",".$v[$j];   else $textul=$v;   $pozitii[$keyi][$keyj]=array($lx+(1+$keyi%2)*$this->fontsize*2,$gyy-$ly+$this->fontsize+1,$lx+ceil($gros)-1+2*(1+$keyi%2)*$this->fontsize,$gyy-$ly0+$dly+$this->fontsize+1,$textul);}}if ($this->showcoords) {foreach ($pozitii as $line)foreach ($line as $lin){$this->pune_indice($this->imagine,$lin[0],$lin[1],$lin[2],$lin[3],$lin[4]);}$k++;}if (($single==true) && ($this->count>1) && (($this->count/($this->fonstsize+1))<10)) {if ($this->count>2) $pana=min($this->count,sizeof($categories));else $pana=min($this->count,sizeof($categories))-1;for ($j=0;$j<$pana;$j++){$lx=$gx+$this->pixel_up($vx[$pm][$j]+$gros-(6*$this->fontsize*$j),$difmx,$gdifx,$xmin);imagefttext($this->imagine,$this->fontsize*0.8,0,$lx,$gyy+$this->fontsize*1.2,$this->bc($this->imagine,"darkgray"),$this->font,$categories[$j]);}}if ($this->showpanel) {$px=$gx*0.8;$pxx=$gxx*1;$py=$gyy*1.06;$pyy=$gyy*1.5;$rand=$this->fontsize*0.8;$cc=sizeof($pozitii);$bordura="white-brown";for($i=0;$i<$cc;$i++) {$diferenta=$py*1.02-$py;$this->liniuta_bar($this->imagine,$px,$py+$i*$rand+$i*$diferenta,$px*3,$py+$i*$rand+($i+1)*$diferenta,$this->linewidth/4+1,$culori[$i],$i);imagefttext($this->imagine,$rand,0,$px*3-$rand/3,$py+$i*$rand+$rand/1.5+($i+1)*$diferenta,$this->black,$this->font,$catego[$i]);}$ttx=$this->width*0.28;$tty=$gyy*1.12;$cate=($gxx-$ttx)/$this->fontsize*1.5;} else  { $ttx=$this->width*0.02;$tty=$gyy*1.12;$cate=($gxx-$ttx)/$this->fontsize*1.5; }if (strlen($this->title)>0) { $tlx=$this->width/2-(strlen($this->title)*$this->fontsize)/2.5;$tly=$this->height*0.04+3;imagefttext($this->imagine,$this->fontsize+3,0,$tlx,$tly,$this->bc($this->imagine,$this->title_color),$this->font,$this->title);} if (!$this->ce_cauti_aici($this->license)) {die("Invalid license!");break;}if (strlen($this->text)>0) {$textul=array();for($i=0;$i<$cate;$i++) $textul[]=nl2br(substr($this->text,$i*ceil($cate),ceil($cate)));$i=0;foreach ($textul as $linie){imagefttext($this->imagine,$this->fontsize-2,0,$ttx,$tty+$i,$this->bc($this->imagine,$this->text_color),$this->font,$linie);$i+=$this->fontsize+1;}}$this->set_filter();}else echo "not enought values";} }/* Created by Molnar Raul   molnarraul@yahoo.com  */ ?>