Пример #1
0
                    imagesetpixel(self::$_image, $px + $i, $py + $i, self::$_color);
                    //这里(while)循环画像素点比imagettftext和imagestring用字体大小一次画出
                    //的(不用while循环)性能要好很多
                    $i--;
                }
            }
        }
    }
    /**  
     * 画杂点  
     * 往图片上写不同颜色的字母或数字  
     */
    protected static function _writeNoise()
    {
        for ($i = 0; $i < 10; $i++) {
            //杂点颜色
            $noiseColor = imagecolorallocate(self::$_image, mt_rand(150, 225), mt_rand(150, 225), mt_rand(150, 225));
            for ($j = 0; $j < 5; $j++) {
                // 绘杂点
                imagestring(self::$_image, 5, mt_rand(-10, self::$imageL), mt_rand(-10, self::$imageH), self::$codeSet[mt_rand(0, 28)], $noiseColor);
            }
        }
    }
}
//调用上面定义的验证码类 来生产验证码
YL_Security_Secoder::$useNoise = true;
//是否启用噪点
YL_Security_Secoder::$useCurve = true;
//是否启用干扰曲线
YL_Security_Secoder::entry();
Пример #2
0
<?php

session_start();
require 'secoder.class.php';
$vcode = new YL_Security_Secoder();
$vcode->entry();
?>