[pmwiki-users] Text captcha notes

Marcus prima at wordit.com
Tue Jul 15 21:50:47 CDT 2008


Patrick,

There is one thing which needs adding in text captchas -- comparison
needs to be case-insensitive for some languages and case-sensitive for
others (see below). I think most are case-insensitive so that should
be default.

You may know a better way, but I could only get the comparison to be
case-insensitive for English by converting the response variable to
lower-case.

$resp = strtolower($resp);

i.e.:

function IsCaptcha() {
  global $IsCaptcha, $CaptchaName, $EnableCaptchaSession;
  if (isset($IsCaptcha)) return $IsCaptcha;
  $key = @$_POST['captchakey'];
  $resp = @$_POST[$CaptchaName];
  $resp = strtolower($resp);
...


Notes:

- In some languages it may be expected to write certain words
capitalised, e.g. in German all nouns begin with a capital letter. So
on a website written in German, users would expect the respective
response to the "which is larger, and elephant or an  ant?" challenge,
to be "Elefant", not "elefant".


- For the PHP function "strtolower()" to work with languages with
non-ASCII upper-case letters, e.g. A with umlaut in German, the locale
needs to be set accordingly on the server.


- For multi-byte languages (e.g. many Asian languages), PHP has
special string functions. PHP would need to be compiled with the
mbstring functions and those need to be activated in php.ini.

See:

http://php.net/mbstring


Marcus



More information about the pmwiki-users mailing list