-
<!DOCTYPEC html> <html> <head> <meta charset = "utf-8"/> <title>確認(rèn)驗(yàn)證碼</title> </head> <form method = "post" ation = "./form.php"> <p>驗(yàn)證圖片:<image border = "1" id = "captcha_img" src = "./captcha.php?r=<?php rand()?>" width = "100" height = "30"> <a href = "javascript:void(0)" onclick = "document.getElementById('captcha_img').src = './captcha.php?r='+Math.random()">換一個(gè)?</a></p> <p>請(qǐng)輸入圖片中的內(nèi)容: <input type = "text" name = "authcode" value = ""/></p> <p><input type= "submit" value = "提交" style = "padding:6px 20px;"></p> </form> </body> </html>查看全部
-
/*for($i=0;$i<4;$i++){ $fontsize = 6; $fontcontent = rand(0,9); $fontcolor = imagecolorallocate($image,rand(0,120),rand(0,120),rand(0,120)); $x= ($i*100/4)+rand(5,10); $y= rand(5,10); imagestring($image,$fontsize,$x,$y,$fontcontent,$fontcolor); }*/ for($i=0;$i<200;$i++){ $pointcolor = imagecolorallocate($image,rand(50,200),rand(50,200),rand(50,200)); imagesetpixel($image,rand(1,99),rand(1,29),$pointcolor); } for($i=0;$i<3;$i++){ $linecolor = imagecolorallocate($image,rand(80,200),rand(80,200),rand(80,200)); imageline($image,rand(1,99),rand(1,29),rand(1,99),rand(1,29),$linecolor); } header('content-type:image/png'); imagepng($image); imagedestroy($image); ?>查看全部
-
<?php session_start(); $image =imagecreatetruecolor(100,30); $bgcolor=imagecolorallocate($image,255,255,255); imagefill ($image,0,0,$bgcolor); $captch_code = ""; for($i=0;$i<4;$i++) { $fontsize = 6; $data = "abcdefghijklmnopqrstuvwxyz12345678"; $fontcontent = substr($data,rand(0,strlen($data)),1); $captch_code .=$fontcontent; $fontcolor = imagecolorallocate($image,rand(0,120),rand(0,120),rand(0,120)); $x= ($i*100/4)+rand(5,10); $y= rand(5,10); imagestring($image,$fontsize,$x,$y,$fontcontent,$fontcolor); } $_SESSION['authcode'] = $captch_code;查看全部
-
<?php if(isset($_REQUEST['authcode'])){ session_start(); if(strtolower($_REQUEST['authcode']) == $_SESSION['authcode']) { echo '<font color = "#0000CC">輸入正確</font>'; }else{ echo '<font color = "CC0000"><b>輸入錯(cuò)誤</b></font>'; } exit(); } ?> <!DOCTYPEC html> <html> <head> <meta charset = "utf-8"/> <title>確認(rèn)驗(yàn)證碼</title> </head> <form method = "post" ation = "./form.php"> <p>驗(yàn)證圖片:<image border = "1" src = "./captcha.php?r=<?php rand();?>" width = 100></p> <p>請(qǐng)輸入圖片中的內(nèi)容: <input type = "text" name = "authcode" value = ""/></p> <p><input type= "submit" value = "提交" style = "padding:6px 20px;"></p> </form> </body> </html>查看全部
-
驗(yàn)證碼查看全部
-
scbzyj 服務(wù)端業(yè)務(wù):寫(xiě)請(qǐng)求的消耗要遠(yuǎn)遠(yuǎn)大于讀請(qǐng)求。 驗(yàn)證碼作用:人機(jī)校驗(yàn)區(qū)分,防灌水。查看全部
-
imagecreatetruecolor — 新建一個(gè)真彩色圖像 imagecolorallocate — 為一幅圖像分配顏色 imagefill — 區(qū)域填充 imagesetpixel — 畫(huà)一個(gè)單一像素 imageline — 畫(huà)一條線段 header('content-type: image/png'); imagepng($image); imagedestroy($image);查看全部
-
imagettftext imagettftext — 用 TrueType 字體向圖像寫(xiě)入文本 說(shuō)明 array imagettftext ( resource $image , float $size , float $angle , int $x , int $y , int $color , string $fontfile , string $text ) 使用 TrueType 字體將 指定的 text 寫(xiě)入圖像。查看全部
-
<?php session_start(); $table = array( 'pic0'=>'貓', 'pic1'=>'狗', 'pic2'=>'蛇', 'pic3'=>'馬' ); $index = rand(0,3); $value = $table['pic'.$index]; $_SESSION['authcode'] = $value; $filename = dirname(__FILE__).'\\pic'.$index.'.jpg'; $contents = file_get_contents($filename); header('content-type:imege/jpg'); echo $contents;查看全部
-
JS實(shí)現(xiàn)動(dòng)態(tài)校驗(yàn)驗(yàn)證碼,即用JS修改圖片的 src,為防止緩存使用隨機(jī)數(shù)查看全部
-
bool imagesetpixel ( resource $image , int $x , int $y , int $color ) imagesetpixel() 在 image 圖像中用 color 顏色在 x,y 坐標(biāo)(圖像左上角為 0,0)上畫(huà)一個(gè)點(diǎn)。查看全部
-
$image=imagecreatetruecolor(width,height) 生成畫(huà)布 $background=imagecolorallocate($image,250,250,250) 設(shè)置顏色 imagefill($image,0,0,$background) 填充 在header前不能有任何輸出,否則報(bào)錯(cuò) header("content-type=image/png") 設(shè)置格式 imagepng($image) 輸出 imagedestroy($image) 銷(xiāo)毀資源查看全部
-
驗(yàn)證碼服務(wù)的核心技術(shù)分析 a.底圖的實(shí)現(xiàn),并且添加干擾元素--依賴PHP圖片處理庫(kù)GD,詳情:http://php.net/gd b.生成驗(yàn)證內(nèi)容--簡(jiǎn)單的隨機(jī)數(shù)生成,使用PHP函數(shù)mt_rand();隨機(jī)數(shù)字+字母生成,需要ASCII碼理論基礎(chǔ);隨機(jī)中文內(nèi)容生成,需要UTF-8編碼理論基礎(chǔ); c.驗(yàn)證內(nèi)容保存在服務(wù)器端--需要PHP操作Session基礎(chǔ); d.驗(yàn)證內(nèi)容的校驗(yàn)--需要前段Ajax基礎(chǔ);查看全部
-
服務(wù)端性能:寫(xiě)請(qǐng)求的消耗要遠(yuǎn)遠(yuǎn)大于讀請(qǐng)求。 驗(yàn)證碼:人機(jī)校驗(yàn)區(qū)分,防灌水。查看全部
-
驗(yàn)證碼的設(shè)計(jì)思路!查看全部
舉報(bào)
0/150
提交
取消