Captcha image broken

Phoca Guestbook - creating guestbooks in Joomla! CMS
Riton
Phoca Newbie
Phoca Newbie
Posts: 4
Joined: 17 Jul 2012, 14:37

Captcha image broken

Post by Riton »

In my guestbook vs 1.5.3 the Captcha images appear as broken images.
Only when i use TTF captcha once every 4 to 5 clicks on renew captcha give a picture.
Other methods don´t work at all.

Please help

PS. When i disable SEF everything works.
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48742
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Captcha image broken

Post by Jan »

Hi, the captcha displaying is not related to SEF features, so there should be not a problem, try to test your server path settings and try to see similar posts in this forum - there are different guides to solve similar problems.

Jan
If you find Phoca extensions useful, please support the project
Riton
Phoca Newbie
Phoca Newbie
Posts: 4
Joined: 17 Jul 2012, 14:37

Re: Captcha image broken

Post by Riton »

I found the error (with great help from my provider).

There is a faulty funtion in the helper file phocaguestbookcaptcha.php.

The mt_rand call on line 83 will sometimes have a min value greater than the max value. In later than 5.3.3 PHP versions this gives a fatal error and no image and characters are shown. (min-max check added in PHP 5.3.4)

Fixed the $rand_2 to range between 1 and 6 and deducted 3 from $rand at the end of the function.

Code: Select all

function getRandomPositionX($i) {
		$rand_2 = mt_rand(1,6);
		$rand_3 = $i + ($rand_2);
		$rand 	= mt_rand($i,$rand_3);
		$rand = $rand -3;
		return $rand;
	}
Problem solved....

PS: I see now that in an earlier post you solved the problem by checking if MIN value > Max value etc.
I think my way is easier and needs no extra loops or tries to generate the Captcha images.
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48742
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Captcha image broken

Post by Jan »

Ok
If you find Phoca extensions useful, please support the project
Post Reply