麻辣家族討論版版's Archiver

machingwen 發表於 2015-1-18 09:14

請問程式如何辨識圖形驗證碼

請問各位大大
有很多網頁,需要輸入圖形裡的的驗證碼,才能進入下一步
怎麼讓程式自動辨識這些圖形裡的數字與文字?

momokt1515 發表於 2015-3-30 17:41

[i=s] 本帖最後由 momokt1515 於 2015-3-30 17:43 編輯 [/i]

您好:
你以下這段話、不太懂您的意思
[b]請問各位大大
有很多網頁,需要輸入圖形裡的的驗證碼,才能進入下一步
怎麼[color=Red]讓程式自動辨識這些圖形裡的數字與文字?[/color][/b]

你是需求 圖型驗證碼的語法?
還是要破解他的語法?


這是驗證的code
/////////////////////////////////////////////////////////////////
[color=Red]<?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);
?>[/color]

/////////////////////////////////////////////////////////////////

頁: [1]

麻辣家族討論版版為 麻辣學園 網站成員  由 昱得資訊工作室 © Since 1993 所提供