php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #51337 server in linux
Submitted: 2010-03-20 13:15 UTC Modified: 2010-03-22 06:16 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 1 (0.0%)
From: sapin at 3aces dot in Assigned:
Status: Not a bug Package: *Graphics related
PHP Version: 5.2.13 OS: linux
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: sapin at 3aces dot in
New email:
PHP Version: OS:

 

 [2010-03-20 13:15 UTC] sapin at 3aces dot in
Description:
------------
imagettfbbox() function not working in server

Test script:
---------------
class CaptchaSecurityImages {
	public $font;
	public $code;

	//function CaptchaSecurityImages($width='120',$height='40',$characters='6') {
	function __construct() {
		$code = $this->generateCode(6);
		$font_size = 40 * 0.75;
		$image = @imagecreate(120, 40) or die('Cannot initialize new GD image stream');
		$background_color = imagecolorallocate($image, 255, 255, 255);
		$text_color = imagecolorallocate($image, 20, 40, 100);
		$noise_color = imagecolorallocate($image, 100, 120, 180);
		for( $i=0; $i<(120*40)/3; $i++ ) {
			imagefilledellipse($image, mt_rand(0,120), mt_rand(0,40), 1, 1, $noise_color);
		}
		for( $i=0; $i<(120*40)/150; $i++ ) {
			imageline($image, mt_rand(0,120), mt_rand(0,40), mt_rand(0,120), mt_rand(0,40), $noise_color);
		}
		$font_family= "arial.ttf";
		echo "Hai";
		$textbox = @imagettfbbox($font_size, 0, $font_family, $code) or die('Error in imagettfbbox function');
		imagettftext($image, 20, 0, 11, 21, imagecolorallocate($image, 128, 128, 128), 20, "dggdfg");
		$x = ($width - $textbox[4])/2;
		$y = ($height - $textbox[5])/2;
		imagettftext($image, $font_size, 0, $x, $y, $text_color, $this->font , $code) or die('Error in imagettftext function');
		header('Content-Type: image/jpeg');
		imagejpeg($image);
		imagedestroy($image);
		$_SESSION['security_code'] = $code;
	}
	
	function generateCode($characters) {
		$possible = '23456789bcdfghjkmnpqrstvwxyz';
		$code = '';
		$i = 0;
		while ($i < $characters) { 
			$code .= substr($possible, mt_rand(0, strlen($possible)-1), 1);
			$i++;
		}
		return $code;
	}	

}

$width = isset($_GET['width']) ? $_GET['width'] : '120';
$height = isset($_GET['height']) ? $_GET['height'] : '40';
$characters = isset($_GET['characters']) && $_GET['characters'] > 1 ? $_GET['characters'] : '6';

$captcha = new CaptchaSecurityImages();

Expected result:
----------------
server version problem

Actual result:
--------------
I dont know

Patches

CaptchaSecurityImages (last revision 2010-03-20 12:16 UTC by sapin at 3aces dot in)

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-03-22 06:16 UTC] kalle@php.net
-Status: Open +Status: Bogus
 [2010-03-22 06:16 UTC] kalle@php.net
.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 05:01:30 2024 UTC