当前位置: 动力学知识库 > 问答 > 编程问答 >

php - Why Captcha plugin return empty in squirrelmail?

问题描述:

I've install Squirrelmail on my server and i want to add captcha plugin to it, i enable the Watercap captcha in it,it always return this error:

Sorry, you did not provide the correct challenge response.

It is same with other captcha modules like csi and ... . and i've tried all version of it, same result. and I've read install quide and did exactly what it told.

So i did a little digging in it's code. it is PHP and the function that return error is in:

/usr/share/squirrelmail/plugins/captcha/backends/watercap/watercap.php

so i added this line to it :

print(' SQ_FORM :' . SQ_FORM);

print(' SQ_SESSION :' . SQ_SESSION);

print(' captcha code is :' . $captcha_code);

print(' captcha response is :' . $captcha_response);

Just after :

 if (!sqGetGlobalVar('captcha_response', $captcha_response, SQ_FORM)

|| empty($captcha_response)

|| !sqGetGlobalVar('captcha_code', $captcha_code, SQ_SESSION)

|| empty($captcha_code))

and i found the result :

SQ_FORM :6 SQ_SESSION :3 captcha code is : captcha response is :b

The b is correct but $captcha_code is always empty.

So How can i fix it ?

PS 1:

Captcha generate in this function:

 function generateCode($number_characters) {

/* list all possible characters, similar looking characters and vowels have been removed */

// lower case letters such as g, p, q, y get cut off

//$possible = '23456789bcdfghjkmnpqrstvwxyz';

$possible = '23456789ABCDEFGHKMNPRSTVWXYZ';

sq_mt_randomize();

$code = '';

$i = 0;

while ($i < $number_characters) {

$code .= substr($possible, mt_rand(0, strlen($possible)-1), 1);

$i++;

}

return $code;

}

and read by :

$captcha_code = generateCode($captcha_length);

But printing out $captcha_code do not any good in it because it does not show anything.

PS2:

The session module of php is enabled according to phpinfo().

PS3:

Just for making sure php session is working, i saw /var/lib/php5/sessions and it create a session for the request and by refreshing the page, it create a new one. but it is empty!! but it should assign by :

sqsession_register($captcha_code, 'captcha_code');

分享给朋友:
您可能感兴趣的文章:
随机阅读: