- 帖子
- 11
- 主題
- 2
- 精華
- 0
- 積分
- 50
- 點名
- 0
- 作業系統
- windows
- 軟體版本
- office2003
- 閱讀權限
- 20
- 性別
- 女
- 來自
- 火星
- 註冊時間
- 2014-8-25
- 最後登錄
- 2015-11-13
|
2#
發表於 2015-3-30 17:41
| 只看該作者
本帖最後由 momokt1515 於 2015-3-30 17:43 編輯
您好:
你以下這段話、不太懂您的意思
請問各位大大
有很多網頁,需要輸入圖形裡的的驗證碼,才能進入下一步
怎麼讓程式自動辨識這些圖形裡的數字與文字?
你是需求 圖型驗證碼的語法?
還是要破解他的語法?
這是驗證的code
/////////////////////////////////////////////////////////////////
<?php
$CaptchaString = ""; //驗證碼文字
$CaptchaLength = 5; //驗證碼長度
//產生數字驗證碼
for($i=0; $i < $CaptchaLength; $i++)
$CaptchaString = $CaptchaString.rand(0,9);
session_start();
$_SESSION['CAPTCHA'] = $CaptchaString; //驗證碼存入SESSION內
Header("Content-type: image/PNG"); //宣告輸出為PNG影像
$CaptchaWidth = 50; //驗證碼影像寬度
$CaptchaHeight = 15; //驗證碼影像高度
//建立影像
$Captcha = ImageCreate($CaptchaWidth, $CaptchaHeight);
//設定背景顏色,範例是紅色
$BackgroundColor = ImageColorAllocate($Captcha, 255, 0, 0);
//設定文字顏色,範例是黑色
$FontColor = ImageColorAllocate($Captcha, 0, 0, 0);
//影像填滿背景顏色
ImageFill($Captcha, 0, 0, $BackgroundColor);
//影像畫上驗證碼
ImageString($Captcha, 20, 0, 0, $_SESSION['CAPTCHA'] , $FontColor);
//隨機畫上200個點,做為雜訊用
for($i = 0; $i < 200; $i++) {
Imagesetpixel($Captcha, rand() % $CaptchaWidth , rand() % $CaptchaHeight , $FontColor);
}
//輸出驗證碼影像
ImagePNG($Captcha);
ImageDestroy($Captcha);
?>
///////////////////////////////////////////////////////////////// |
|