前幾周開始挑選合適的 framwork
在 CodeIgniter & Yii 兩者之前挑來挑去的
最後 就賭上 Yii 了, 不多 Yii 的中文 文件真少 好像也推出不久
不如 CodeIgniter 的 中文文件多 , 推出也久
但既來之 則 安知 慢慢摸索了
本週終於有時間可以研究了
有用到一組 透明背景的數字驗證碼
提供出來給大家
 至少我自己也要有所貢獻
 至少我自己也要有所貢獻
<?php
class CKCaptchaAction extends CCaptchaAction {
public $imageTransparent=false;	//背景是否透明
protected function generateVerifyCode() {
	if($this->minLength < 3)	$this->minLength=3;
	if($this->maxLength > 10)	 $this->maxLength=10;
	if($this->minLength > $this->maxLength)	$this->maxLength=  $this->minLength;
	$length = rand($this->minLength, $this->maxLength);
	$code='';
	for($i=0; $i<$length; $i++) {
		$code .= Chr(48+rand(0, 9));
	}
	return $code;
}
protected function renderImage($code) {
		$image = ImageCreate($this->width, $this->height);
		$backColor = ($this->imageTransparent) ? ImageColorTransparent($image, ImageColorAllocate($image, (int)($this->backColor%0x1000000/0x10000), (int)($this->backColor%0x10000/0x100), $this->backColor%0x100)) : ImageColorAllocate($image, (int)($this->backColor%0x1000000/0x10000), (int)($this->backColor%0x10000/0x100), $this->backColor%0x100);//ImageColorAllocate第1次定義顏色PHP就認為是底色了
		//$backColor = ImageColorTransparent($image, ImageColorAllocate($image, (int)($this->backColor%0x1000000/0x10000), (int)($this->backColor%0x10000/0x100), $this->backColor%0x100));
		//文字顏色為藍色
		$foreColor = ImageColorAllocate($image, (int)($this->foreColor%0x1000000/0x10000), (int)($this->foreColor%0x10000/0x100), $this->foreColor%0x100);
		//圖片背景為白色
		/*
		for($i=1; $i<=200; $i++) {    //先用100個做測試  
			imageString($im, 1, mt_rand(0, $img_width), mt_rand(0, $img_height), "*", imageColorAllocate($im,mt_rand(200,255),mt_rand(200,255),mt_rand(200,255)));  
		}
		*/
		// 將文字放到圖片裡面並靠左上角
		ImageString($image, 5, 4, 0, $code, $foreColor);
		//輸出圖片
		header("Content-type: image/png");
		ImagePNG($image);
}
}
客位可以把它存到 \extensions\CKCaptchaAction.php
再去呼叫他就好,這裡好像沒在討論 CodeIgniter & Yii的喔
不過也好  東西 各有好壞 在用的人的不同嘛!! 