<?php require_once('../Connections/BE2.php'); ?>
<?php

mysql_select_db($database_BE2, $BE2);
$query_Rt2 = "SELECT * FROM travel where tbc='旅遊網' order by tbx,tb0" ; 
$Rt2 = mysql_query($query_Rt2, $BE2) or die(mysql_error());
$row_Rt2 = mysql_fetch_assoc($Rt2);
$totalRows_Rt2 = mysql_num_rows($Rt2);
 
?> 


<?php
  do {  
     $f='tr_bg_'.sprintf('%07d',$row_Rt2['tb0']).".png";
     $word= $row_Rt2['tb2'] ; //isset($_GET['label'])?$_GET['label']:"skybni";
	 //
	 if(mb_strlen($word>5)){
	  $word=mb_substr($word,0,5,"utf-8");
	 }
	 $imgname="/www2/skybni/travel/src_img/bg_".rand(0,30).".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); 
	 $bcolor = ImageColorAllocate($im, 0,0,0); 
     $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, $bcolor,$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/travel/trimg/'.$f);
	 //ImagePNG($im); 
     imagedestroy($im); 
     } while ($row_Rt2 = mysql_fetch_assoc($Rt2)); 
 
mysql_free_result($Rt2);
  
?>        
     