stil/cool-captcha

此包已被废弃,不再维护。未建议替代包。

使用GD扩展生成精美图像验证码的类。

v0.1.0 2015-01-02 22:22 UTC

This package is not auto-updated.

Last update: 2021-03-05 21:22:44 UTC


README

它是精炼的cool-php-captcha库,重新托管在GitHub上。

使用示例

<?php
require __DIR__.'/vendor/autoload.php';

session_start();
use CoolCaptcha\Captcha;
$captcha = new Captcha();

/** OPTIONAL configuration
$captcha->wordsFile = 'words/es.php';
$captcha->session_var = 'secretword';
$captcha->imageFormat = 'png';
$captcha->lineWidth = 3;
$captcha->scale = 3;
$captcha->blur = true;
$captcha->resourcesPath = "/var/cool-php-captcha/resources";
**/

/** OPTIONAL Simple autodetect language example
if (!empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
    $langs = array('en', 'es');
    $lang  = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
    if (in_array($lang, $langs)) {
        $captcha->wordsFile = "words/$lang.php";
    }
}
**/

// Image generation
$text = $captcha->createImage();
$_SESSION['text'] = $text;

生成的验证码

alt alt

alt alt

alt