Ejemplo n.º 1
0
/**
 * Verify a captcha based on the input value entered by the user and the seed token passed.
 *
 * @param string $input_value
 * @param string $seed_token
 * @return bool
 */
function captcha_verify_captcha($input_value, $seed_token)
{
    if (strcasecmp($input_value, captcha_generate_captcha($seed_token)) == 0) {
        return true;
    }
    return false;
}
Ejemplo n.º 2
0
<?php

/**
 * Elgg captcha plugin graphics file generator
 *
 * @package ElggCaptcha
 */
$token = get_input('captcha_token');
// Output captcha
if ($token) {
    // Generate captcha
    $captcha = captcha_generate_captcha($token);
    // Pick a random background image
    $n = rand(1, elgg_get_plugin_setting('captcha_num_bg', 'captcha'));
    $image = imagecreatefromjpeg(elgg_get_plugins_path() . "captcha/backgrounds/bg{$n}.jpg");
    // Create a colour (black so its not a simple matter of masking out one colour and ocring the rest)
    $colour = imagecolorallocate($image, 0, 0, 0);
    // Write captcha to image
    //imagestring($image, 5, 30, 4, $captcha, $black);
    imagettftext($image, 30, 0, 10, 30, $colour, elgg_get_plugins_path() . "captcha/fonts/1.ttf", $captcha);
    // Output image
    ob_start();
    // start a new output buffer
    imagejpeg($image);
    $ImageData = ob_get_contents();
    $ImageDataLength = ob_get_length();
    ob_end_clean();
    // stop this output buffer
    header("Content-Type: image/jpeg");
    header("Content-Length: " . $ImageDataLength);
    header('Cache-Control: no-cache, no-store, must-revalidate');