';
$text .= '';
if (($GLOBALS['FUD_OPT_3'] & 33554432) && extension_loaded('gd') && function_exists('imagecreate') ) {
// Graphical captcha.
ses_putvar((int)$GLOBALS['usr']->sid, $captcha);
return $text .'
';
} else {
// Text based captcha.
$bg_fill_chars = array(' ', '.', ',', '`', '_', '\'');
$bg_fill = $bg_fill_chars[array_rand($bg_fill_chars)];
$fg_fill_chars = array('#', '@', '$', '*', 'X');
$fg_fill = $fg_fill_chars[array_rand($fg_fill_chars)];
$text .= '
';
// Generate turing text.
for ($i = 0; $i < 7; $i++) {
foreach ($rv as $v) {
$text .= str_replace('#', $fg_fill, str_replace('.', $bg_fill, $t[$i][$v]));
}
$text .= '
';
}
return $text .'';
}
}
/* Test if user entered a valid response to the CAPTCHA test. */
// function test_turing_answer($test, $res)
function test_turing_answer()
{
if (defined('plugins')) {
$ok = plugin_call_hook('CAPTCHA_VALIDATE');
if ($ok == 0) {
return false;
} elseif ($ok == 1) {
return true;
}
}
$test = $_POST['turing_test'];
$res = $_POST['turing_res'];
if (empty($test) || empty($res)) {
return false;
}
if (md5(strtoupper(trim($test))) != $res) {
return false;
} else {
return true;
}
}
?>