Exemplo n.º 1
0
function getCaptchaBuilder($paramArr)
{
    $options = array('width' => 80, 'height' => 20, 'numCnt' => 4, 'text' => 'ABCD', 'plex' => 5);
    if (is_array($paramArr)) {
        $options = array_merge($options, $paramArr);
    }
    extract($options);
    $textColorArr = array(0 => array(0, 0, 0), 1 => array(8, 46, 84), 2 => array(61, 145, 64), 3 => array(0, 0, 255), 4 => array(11, 23, 70), 5 => array(135, 38, 87));
    $randNum = rand(1, 4);
    $textColor = $textColorArr[$randNum];
    $randStart = 250 - 4 * $plex;
    $angle = 3 * $plex;
    $lines = 3 * $plex;
    $fontNum = rand(1, 5);
    if (!$fontNum) {
        $fontNum = 1;
    }
    $font = LJL_API_ROOT . '/Config/Fonts/captcha' . $fontNum . '.ttf';
    $backgroudColorArr = array(rand($randStart, 255), rand($randStart, 255), rand($randStart, 255));
    $distort = false;
    if (6 < $plex) {
        $distort = true;
    }
    header('Content-type: image/jpeg');
    CaptchaBuilder::create($text)->setTextColor($textColor[0], $textColor[1], $textColor[2])->setBackgroundColor($backgroudColorArr[0], $backgroudColorArr[1], $backgroudColorArr[2])->setMaxBehindLines($lines)->setMaxFrontLines($lines)->setMaxAngle($angle)->setDistortion($distort)->setMaxOffset($plex)->build($width, $height, $font)->output();
    exit;
}