<?php require_once('../Connections/BE2.php'); ?>
<?php

mysql_select_db($database_BE2, $BE2);
$query_Rt2 =  "SELECT * FROM company_kinds WHERE 1" ;
$Rt2 = mysql_query($query_Rt2, $BE2) or die(mysql_error());
$row_Rt2 = mysql_fetch_assoc($Rt2);
$totalRows_Rt2 = mysql_num_rows($Rt2);
   
?> 


<?php
  $cc1=0;
  do { 
     $cc1++;
	 if ($cc1>15){ $cc1=1 ;} 
     $f='kins_'.sprintf('%02d',$row_Rt2['kid']).".png";
     $word= $row_Rt2['kdoc'] ; //isset($_GET['label'])?$_GET['label']:"skybni";
	 //
	 if(mb_strlen($word>5)){
	  $word=mb_substr($word,0,5,"utf-8");
	 }
	 
	 $imgname="/www2/skybni/kindimg/kindback".sprintf("%02d",$cc1).".png";
     $im = @imagecreatefrompng($imgname);
     // Header("Content-type: image/PNG");
     //$background = imagecreatefromstring(file_get_contents($be_path));
     //$im = imagecreatetruecolor(125, 24); ;//imagecreate(125,24); 
     //imagesavealpha($im, true);
      //$scolor = imagecolorallocatealpha($im, 0, 0, 0, 127);
     //imagefill($im, 0, 0, $scolor);
	  
    // $wcolor = ImageColorAllocate($im, 28,22,225); 
	 $wcolor = ImageColorAllocate($im, 255,255,255); 
     $fontsize=12;
     $myfont="/www2/skybni/fonts/kaiu.ttf";
     $fontBox = imagettfbbox($fontsize,5, $myfont,$word); 
     imagettftext($im,$fontsize,0,ceil((125-$fontBox[2])/ 2),56, $wcolor,$myfont,$word); 
	// imagettftext($im,$fontsize,0,ceil((125-$fontBox[2])/ 2)+1,56+1, $wcolor,$myfont,$word);
     //$img=sprintf('%07d', $id ).".png";
	 imagepng($im,'/www2/skybni/kindimg/'.$f);
	 //ImagePNG($im); 
     imagedestroy($im); 
     } while ($row_Rt2 = mysql_fetch_assoc($Rt2)); 
 
mysql_free_result($Rt2);
  
?>        
     