More Than Just Web Design | INTERNET ENGINEERING | APPLICATION | DESIGN

Caught Out By CAPTCHA

Posted: 25/08/13

Imagettftext() Returns Huge Negative Values

Anyone who's ever drowned in spam sent through a form on their website will appreciate how helpful the CAPTCHA puzzle can be in combatting this annoying problem.

So when the built in Secureimage library distributed with Concrete5 failed to work for me on a site I was building, this was something of a concern.

The problem was that the CAPTCHA image was being generated, but there were no characters visible:

CAPTCHAFail.jpg

After a bit of debugging, I found that the imagettfbbox() function was returning this array of values:

array(8) {
  [0]=>
  int(7)
  [1]=>
  int(0)
  [2]=>
  int(-2147483648)
  [3]=>
  int(0)
  [4]=>
  int(-2147483648)
  [5]=>
  int(-102)
  [6]=>
  int(7)
  [7]=>
  int(-102)
}

As you can see, two of the values were minus two billion or thereabouts. Certainly not the few hundred that they should have returned.

Overriding these values with 700 and -100 got the Secureimage Library humming along nicely.

The reason why the function imagettfbbox returns huge negative values is I suspect a bug in PHP but confusingly one that seems to have been patched in the version I was using. It was certainly working OK on other installs of the same Linux version (Ubuntiu 10.04) I've used elsewhere.