phpBB photo-captcha image loading issues

A friend was having trouble with the photo-captcha mod he installed in phpBB. The photo-captcha mod basically presents users with a group of images and asks them to choose all images that fit a certain category (i.e., choose all cars). After installing the mod however (and fixing a couple of silly mistakes), only half of the images would show up. And it wasn't the same images not showing up, it was entirely random.

As is usually the case with debugging, I looked for a working example with which I could compare the non-working one. When I found a working photo-captcha mod, I noticed the images loaded more slowly and consistently than on the non-working example. It was as if the non-working example was on crack, while the working example was practicing yoga.

I compared HTTP headers, checked cache settings, and everything else I could think of, but nothing looked out of the ordinary. So I decided to try something. Why not force the mod to pause between loading each image?

So I opened /forum/includes/usercp_confirm.php and modified it:

$image = $sub;
@imagegammacorrect($image, 1.0, (0.5 + mt_rand(0,1200)*0.001));

header('Content-Type: image/jpg');
header('Cache-control: no-cache, no-store');
// -------- EDIT BY RAAM --------
// -------- END EDIT ---------

And it worked! The code paused for 1 second between loading each image and all the images loaded properly. I have no idea what caused this problem but if you know please leave a comment! And if you're having this same issue, at least now you have a solution. 🙂

Write a Comment


  1. It didn’t help for me but i commented (aka deleted) row
    @imagegammacorrect($image, 1.0, (0.5 + mt_rand(0,1200)*0.001));

    And it probably helped. Not 100% sure.

    PS: Yea this is old.

  2. Thanks for the comment, Jussi!

    If I come across this problem again I’ll definitely try commenting out that line before adding sleep(1). Apparently, imagegammacorrect() is a GD function in PHP, so if GD hasn’t been turned on in your installation of PHP that could be the problem.

  3. Nothing seems to be easier than seeing someone whom you can help but not helping.
    I suggest we start giving it a try. Give love to the ones that need it.
    God will appreciate it.