Пример #1
0
            imagejpeg($this->im);
        } elseif (imagetypes() & IMG_GIF) {
            header('Content-type: image/gif');
            imagegif($this->im);
        } elseif (imagetype() & IMG_PNG) {
            header('Content-type: image/png');
            imagepng($this->im);
        } else {
            die("Don't support image type!");
        }
    }
}
$type = $_GET['type'];
if ($type == "getValidate") {
    $captcha = new Captcha(80, 30, 4);
    $captcha->showImg();
}
/*
//验证码类
class ValidateCode {
 private $charset = 'abcdefghkmnprstuvwxyzABCDEFGHKMNPRSTUVWXYZ23456789';//随机因子
 private $code;//验证码
 private $codelen = 4;//验证码长度
 private $width = 130;//宽度
 private $height = 50;//高度
 private $img;//图形资源句柄
 private $font;//指定的字体
 private $fontsize = 20;//指定字体大小
 private $fontcolor;//指定字体颜色
 //构造方法初始化
 public function __construct() {
Пример #2
0
 /**
  * 获取图形验证码
  *
  */
 public function actionCaptcha()
 {
     Yii::import("application.library.Captcha");
     $captcha = new Captcha();
     $captcha->showImg(78, 37, 4);
 }