• 05-12-2006, 19:23:34
    #1
    bir security kodu dosyası hatası serverda imagemagic yüklü. ama nedense bu hatayı verior.

    Fatal error: Call to undefined function: imagettfbbox() in /home/oyun/public_html/imageclick.php on line 221

    221 i satırda resmin üzerinde ne yazıcağı ve boyutları belirtilmiş

    $tmp = imagettfbbox ($i, 0, $font, $text);

    <?php
    //include "vsys.php";
    //include "gifmerge.php";
    $tmp_save_prefix="";
    $anim_size["h"]=50;
    $anim_size["w"]=350;
    /*if ($cgi["first_image2"]) {
     $fname= "fronts/".$cgi['first_image2'];
     $fname_real=$cgi['first_image2'];
    }else{
     //$fname= $_FILES['first_image']['tmp_name'];
     $fname_real= $_FILES['first_image']['name'];
     //$fname="tmp/".time()."_".$fname_real;
     $fname=time()."_".$fname_real;
     move_uploaded_file($_FILES['first_image']['tmp_name'], $fname);
    }
    if ($cgi["second_image2"]){
     $fname2= "backs/".$cgi['second_image2'];
     $fname2_real=$cgi['second_image2'];
    }else{
     $fname2_real= $_FILES['second_image']['name'];
     //$fname2="tmp/".time()."_".$fname2_real;
     $fname2=time()."_".$fname2_real;
     move_uploaded_file($_FILES['second_image']['tmp_name'], $fname2);
     //$fname2= $_FILES['second_image']['tmp_name'];
     
    }
    */
    
    //if (!$fname){vMessage("You should choose first image.");exit;}
    //if (!$fname2){vMessage("You should choose second image.");exit;}
    //$cgi['first_delay']=100;
    //if (!$cgi['first_delay']){vMessage("You should choose delay for the first image.");exit;}
    //if (!$cgi['second_delay']){vMessage("You should choose delay for the second image.");exit;}
    session_start();
    if ($_SESSION['number1']){
     $txt=$_SESSION['number1'];
    }else{
    switch ($_SESSION['number']){
     case 1: $num='B-i-R';break;
     case 2: $num='i-K-i';break;
     case 3: $num='U-C';break;
     case 4: $num='D-O-R-T';break;
     case 5: $num='B-E-S';break;
     case 6: $num='A-L-T-I';break;
     case 7: $num='Y-E-D-i';break;
     case 8: $num='S-E-K-i-Z';break;
     case 9: $num='D-O-K-U-Z';break;
     case 10: $num='O-N';break;
     case 11: $num='O-N-B-i-R';break;
     case 12: $num='O-N-i-K-i';break;
     case 13: $num='O-N-U-C';break;
     case 14: $num='O-N-D-O-R-T';break;
     case 15: $num='O-N-B-E-S';break;
     default: $num=$_SESSION['number'];
     
    }
    //$num='o-n-e';
    $first=chr(rand(0x21,0x40));
    $last=chr(rand(0x21,0x40));
    $txt=$first.'-'.$num.'-'.$last;
    }
    vMakeImg($txt);
    //vMakeImg($fname2,$fname2_real,"second");
    //vMakeAnimGif();
    exit;
    
    function  vMakeImg($n){
     global $anim_size;
     $img=imagecreatetruecolor($anim_size["w"],$anim_size["h"]);
     $iconf['bgcolor']='00,00,255'; //$cgi[$n.'_backcolor'];
     $iconf['font']='fonts/arialbd.ttf';
     $iconf['text1']=$n;
     //$iconf['text2']=$cgi[$n.'_text2'];
     //$iconf['text3']=$cgi[$n.'_text3'];
     $iconf['textcolor']='255,255,255';//$cgi[$n.'_textcolor'];
     $iconf['textsize']=27;//$cgi[$n.'_size'];
     //if ($iconf['font'])
      vText($img,$iconf['font'],$iconf['text1'],$iconf['text2'],$iconf['text3'],$iconf['textcolor'],$anim_size["h"],$anim_size["w"],$iconf['textsize']);
     
     //while (imagecolorstotal($img)<256){
        //imagecolorallocate ($img,0,0,0);
     //}
     //Ending
     
     //$tmp_save_file=($tmp_save_prefix)?$tmp_save_prefix:"tmp/".time()."_".rand(100,999);
     //$tmp_save_file=($tmp_save_prefix)?$tmp_save_prefix:time()."_".rand(100,999);
     //if (!$tmp_save_prefix)$tmp_save_prefix=$tmp_save_file;
     //$tmp_save_file.="_$n.gif";
     
     //********************************************************************************Uncoment
     //echo $cgi['path'].$tmp_save_file."==";
     //imagegif ($img,$cgi['path'].$tmp_save_file);
     //imagegif ($img,$tmp_save_file);
     //********************************************************************************Comment
     //imagegif ($img,$n.".gif");
     //echo $tmp_save_file."111";
     //echo "hi";
     //imagepng ($img);
     imagejpeg($img);
     //imagepng ($img,$n.".png");
     
    
    }
    function vMakeAnimGif(){
     global $cgi,$tmp_save_prefix;
     
     $animPath=$tmp_save_prefix."_all.gif";
     $filePath1=$tmp_save_prefix."_first.gif";
     $filePath2=$tmp_save_prefix."_second.gif";
     
     $inFiles[0]=$filePath1;
     $inFiles[1]=$filePath2;
     //echo "doing....<br>";
     
     //vMergeToGif("out.gif",$inFiles,20,99999,2);
     
     vMergeToGif($animPath,$inFiles,$cgi['first_delay'],99999);//,-1,$cgi['first_delay']);
     //echo "done.";
     //$str="whirlgif -o $animPath -loop -time {$cgi['first_delay']} $filePath1 -time {$cgi['second_delay']} $filePath2";
     //echo $str;
     //system($str); 
     
     
     //********************************************************************************Uncomment
     //unlink($filePath1);
     //********************************************************************************Uncomment
     //unlink($filePath2);
     //********************************************************************************Uncomment
     //echo "<script>document.location='{$animPath}';</script><a href='{$animPath}'>download</a>";
     //aim:BuddyIcon?src=http://dollisland.com imagename.gif 
     //echo "--";
     echo "<table width=100% height=100% ><tr><td valign=middle align=center><a href=aim:BuddyIcon?src=http://dollisland.com/gif/$animPath ><img src='$animPath' border=0></a></td></tr></table>";
     //echo "++";
     vTrash();
     
    }
    
    function LoadJpeg ($imgname,$imgtype) {
     //echo $imgtype."--";
     if ($imgtype==2){
      $im = @imagecreatefromjpeg ($imgname);//  Attempt to open 
     }elseif($imgtype==1){
      $im = @imagecreatefromgif ($imgname);//  Attempt to open 
     }elseif($imgtype==3){
      $im = @imagecreatefrompng ($imgname);//  Attempt to open 
     }elseif($imgtype==4){
      echo $imgname;
      $im = @imagecreatefromwbmp ($imgname);//  Attempt to open 
     }
     else{ $imgtype=2;}
     
     if (!$im) { // See if it failed 
      //$im  = imagecreatetruecolor (150, 30); // Create a blank image 
      $im  = imagecreate (150, 30); // Create a blank image 
      $bgc = imagecolorallocate ($im, 255, 255, 255);
      $tc  = imagecolorallocate ($im, 0, 0, 0);
      imagefilledrectangle ($im, 0, 0, 150, 30, $bgc);
      // Output an errmsg 
      imagestring ($im, 1, 5, 5, "Error loading $imgname", $tc);
     }
     
     return $im;
    }
    function vMessage($str){
     echo "<table height=100% width=100%><tr><td align=center valign=middle>$str";
    }
    function vBasename ($str){
     $strA=split("[\]",$str);
     $str1=$strA[count($strA)-1];
     $strA=split("[/]",$str1);
     $str1=$strA[count($strA)-1];
     return $str1;
    }
    function vExtType($str){
     $tnameA=split("\.",$str);
     $t_ext=$tnameA[count ($tnameA)-1];
     $t_ext=strtolower($t_ext);
     if ($t_ext=="gif"){$imgtype=1;}
     elseif (($t_ext=="jpg")||($t_ext=="jpeg")){$imgtype=2;}
     elseif ($t_ext=="png"){$imgtype=3;}
     elseif ($t_ext=="bmp"){$imgtype=4;}
     else {$imgtype=0;}
     //echo $imgtype."#;#";
     return $imgtype;
    }
     
    function vTrash(){
     global $cgi;
     if ($dir = @opendir($cgi['path'])) {
      while (($file = readdir($dir)) !== false) {
       if ( ($file!='.')&&($file!='..')){
        //echo $file;
        $tnameA=split("_",$file);
        if (count ($tnameA)>1){
         $time1=$tnameA[0];
         $time2=time();
         if (($time2-$time1)>180)unlink($file); 
        }
       }
      }
      closedir($dir);
     }
     exit;
    }
    function getTXTSize($font,$text,$koef,$max_height,$width){
     
     $TXT['prev_size']=0;
     $TXT['prev_width']=0;
     
     for ($i=3;$i<=$max_height*$koef;$i++){
      $tmp = imagettfbbox ($i, 0, $font, $text);
      $TXT['size']=$i;
      $TXT['width']=$tmp[2]-$tmp[0];
      if ($TXT['width']>$width*$koef){
       $TXT['width']=$TXT['prev_width'];
       $TXT['size']=$TXT['prev_size'];
       break;
      }
      $TXT['prev_width']=$TXT['width'];
      $TXT['prev_size']=$TXT['size'];
     }
     return $TXT;
    }
    function vText(&$img,$font,$text1,$text2,$text3,$textcolor,$h,$w,$size){
     
     $koef=1;
     $max_height=$size;
     //echo "--$max_height--";
     $colorA=split(",",$textcolor); 
     //print_r ($colorA);
     $color=imagecolorclosest ($img, $colorA[0], $colorA[1], $colorA[2]);
     //$color=imagecolorexact ($img, $colorA[0], $colorA[1], $colorA[2]);
     if ($color=-1){
      //echo "Allocating";
      $color=imagecolorallocate ($img, $colorA[0], $colorA[1], $colorA[2]);
     }
     //$color=imagecolorclosest  ($img, 255, 255, 255);
     
     $TXTsize1=getTXTSize($font,$text1,$koef,$max_height,$w-10);
     $TXTsize2=getTXTSize($font,$text2,$koef,$max_height,$w-10);
     $TXTsize3=getTXTSize($font,$text3,$koef,$max_height,$w-10);
     
     $x1=round(($w*$koef-$TXTsize1[width])/2);
     $x2=round(($w*$koef-$TXTsize2[width])/2);
     $x3=round(($w*$koef-$TXTsize3[width])/2);
     
     $y1=$TXTsize1['size']*$koef+5;
     $y2=$y1+$TXTsize2['size']*$koef+5;
     $y3=$y2+$TXTsize3['size']*$koef+5;
     //echo "text1=$text1.x1=$x1.y1=$y1.color=$color.font=$font";
     imagettftext ($img,$TXTsize1['size'],0,$x1, $y1, $color, $font, $text1);
     imagettftext ($img,$TXTsize1['size'],0,$x2, $y2, $color, $font, $text2);
     imagettftext ($img,$TXTsize1['size'],0,$x3, $y3, $color, $font, $text3);
    }
    function vText2(&$dst_img,$src_img,$font,$text,$koef,$max_height,$width,$X,$Y,$Angle,$Color){
     $fontfile=$font;
     $conf['HeadLine_Color']=split(",",$Color);
     $headTextColor=imagecolorallocate ($dst_img, $conf['HeadLine_Color'][0], $conf['HeadLine_Color'][1], $conf['HeadLine_Color'][2]);
     if ($Angle){$padding=$Y;}
     else{$padding=$X;}
     $TXTsize=getTXTSize($fontfile,$text,$koef,$max_height,$width-$padding);
     if ($Angle){
      $start_txt_x=round(($width*$koef+$TXTsize[width])/2);//+$padding*$koef;//-$conf['HeadLine_X']*$conf['CoverImage_Quality'];
     }else{
      $start_txt_x=round(($width*$koef-$TXTsize[width])/2);//+$padding*$koef;//-$conf['HeadLine_X']*$conf['CoverImage_Quality'];
     }
     if ($Angle){
      $y=$start_txt_x;
      $x=$X*$koef;
     }else{
      $x=$start_txt_x;
      $y=$Y*$koef;
     }
     imagettftext ($dst_img,$TXTsize[size],$Angle,$x, $y, $headTextColor, $fontfile, $text);
    }
    ?>
    dosyanın içeriği bu. ben çözemedim nedir sorun.
  • 05-12-2006, 20:44:39
    #2
    Kurumsal PLUS
    sanırım GD1 kitaplıkları gerekiyor bu fonksiyon için çünkü GD2 kitaplıkları yüklü sunucuda da çalışmıyor.
    Benim kullandığım kodlar, GD2'de çalışıyor:
    <?
    header("Content-Type: image/jpeg");
    create_image();
    die();
    
    function create_image()
    {
    	// *** Generate a passcode using md5
    	//	(it will be all lowercase hex letters and numbers ***
    	$hash1 = "cizilecekkod";
    	
    	// *** Create the image resource ***
    	$image = ImageCreatetruecolor(80, 20);  
    
    	// *** We are making two colors, white and black ***
    	$clr_white = ImageColorAllocate($image, 255, 255, 255);
    	$clr_black = ImageColorAllocate($image, 0, 0, 0);
    
    	// *** Make the background black ***
    	imagefill($image, 0, 0, $clr_black);
    
    	// *** Set the image height and width ***
    	imagefontheight(15);
    	imagefontwidth(15);
    
    	// *** Add the passcode in white to the image ***
    	imagestring($image, 5, 5, 3, $hash, $clr_white);
    	
    	// *** Throw in some lines to trick those cheeky bots! ***
    	imageline($image, 5, 1, 50, 20, $clr_white);
    	imageline($image, 60, 1, 96, 20, $clr_white);
    
    	// *** Output the newly created image in jpeg format ***
    	imagejpeg($image);
    	
    	// *** Clear up some memory... ***
    	imagedestroy($image);
    }
    ?>
  • 07-12-2006, 13:08:40
    #3
    sorunu halledemedik. serverda zend yüklü ve imagemagic'de. başka bir güvenlik kodu scripti denedik çalıştı. fakat bu scriptte güvenlik kodlarını aldığı dosyada sorun var ve çözemedik. üstte verdiğim sayfanın kodlarında şöyle birşey bulduk

    function vMakeAnimGif(){
     global $cgi,$tmp_save_prefix;
     
     $animPath=$tmp_save_prefix."_all.gif";
     $filePath1=$tmp_save_prefix."_first.gif";
     $filePath2=$tmp_save_prefix."_second.gif";
     
     $inFiles[0]=$filePath1;
     $inFiles[1]=$filePath2;
     //echo "doing....<br>";
     
     //vMergeToGif("out.gif",$inFiles,20,99999,2);
     
     vMergeToGif($animPath,$inFiles,$cgi['first_delay'],99999);//,-1,$cgi['first_delay']);
     //echo "done.";
     //$str="whirlgif -o $animPath -loop -time {$cgi['first_delay']} $filePath1 -time {$cgi['second_delay']} $filePath2";
     //echo $str;
     //system($str); 
     
     
     //********************************************************************************Uncomment
     //unlink($filePath1);
     //********************************************************************************Uncomment
     //unlink($filePath2);
     //********************************************************************************Uncomment
     //echo "<script>document.location='{$animPath}';</script><a href='{$animPath}'>download</a>";
     //aim:BuddyIcon?src=http://dollisland.com imagename.gif 
     //echo "--";
     echo "<table width=100% height=100% ><tr><td valign=middle align=center><a href=aim:BuddyIcon?src=http://dollisland.com/gif/$animPath ><img src='$animPath' border=0></a></td></tr></table>";
     //echo "++";
     vTrash();
     
    }


    bu fonksiyondan olma ihtimali nedir? çünkü başka hostlardada denedik yinede çalışmadı.
    Not : bu
    http://dollisland.com bizim sitemiz değil.
  • 07-12-2006, 13:17:40
    #4
    Misafir
    PHP Bugs: #19542: imagettfbbox() ... undefined

    I have expirienced the same thing, recompiled PHP time after time, 'till
    i realised not PHP was the faulty one, but GD!

    I have done the following (under RedHat 8.0):

    1) Download and install both RPM's for FreeType (current:
    freetype-2.1.2.7*.rpm and freetype-devel-2.1.2.7*.rpm)
    2) Download GD 1.8.4 from GD Graphics Library
    3) Edit the makefile and BE SURE to check freetype-support
    (various options in the Makefile)
    4) Include /usr/lib/freetype1/freetype in the INCLUDE_DIR= line
    (otherwise make will stumble on "tff.h" or so... )
    5) (optional) Set the "make install" directories to /usr/ instead of
    /usr/local/
    6) "Make" and "Make Install" GD
    7) Configure PHP 4.2.3 --with-gd --with-freetype-dir=/usr/lib/
    --with-ttf-dir=/usr/lib --enable-gd-native-ttf
    8) "Make" and "Make Install" PHP.

    After this, imagettfbbox() was recognised as a function on my
    PHP-pages...
  • 07-12-2006, 13:25:25
    #5
    türkçesi yokmu :P hiç bişi anlamadım
  • 07-12-2006, 13:37:34
    #6
    Misafir
    php infodan bakarmısın freetype diye bişi yüklümü
  • 07-12-2006, 13:53:28
    #7
    baktım göremedim. php version 4.4.4 - Zend Engine v1.3.0

    yani ne yapmamız lazım
  • 07-12-2006, 14:28:52
    #8
    Misafir
    Os nedir acaba ? uygun çözüm bakalım

    Eğerki Cpanel kullanıyorsan, ve whm deysen

    Apache update e girip Freetype Support u seçip yeniden derle derim apacheni.
    En kısa yolu bu


    O kullandığın fonsiyon freetype in php de bulunan 2 fonksiyonundan birisi.
  • 08-12-2006, 15:52:53
    #9
    //include "vsys.php";
    //include "gifmerge.php";

    bunlardan olmasın