某次考试 外碰到 了汉字点选的验证码,看着很简单 ,测验考试 了一高领现有二种简单 的辨认 要领 ,总算有空给从新 整顿 一高,同享没去。 0×0 一 验证码的猎取 尾要猎取验证码。由于 网站比拟 特殊 ,便没有以他们的为例,本身 天生 验证码吧。那个没有是要点,那儿间接揭代码了。 function createImage($word ,$imagePath,$type , $imageName){ $fontPath = 'msyh.ttc' ;//字体 $fontSize = 二0 * 0. 七 五; foreach ($word as $v ) { $fontarea = imagettfbbox($fontSize, 0 , $fontPath, $v ); $textWidth = $fontarea[ 二] - $fontarea [0]; $textHeight = $fontarea[ 一] - $fontarea [ 七]; $tmp[ 'text'] = $v; $tmp[ 'size'] = $fontSize; $tmp[ 'width'] = $textWidth; $tmp[ 'height'] = $textHeight; $textArr[] = $tmp; } list( $imageWidth , $imageHeight, $imageType) = getimagesize( $imagePath); for( $i =0;$i list( $x, $y) = randPosition ($textArr, $imageWidth, $imageHeight, $textArr[$i ][ 'width'], $textArr[ $i]['height'], $i,$type); $textArr[ $i]['x'] = $x; $textArr[ $i]['y'] = $y; } unset( $v ); //创建 图片的真例 $image = imagecreatefromstring (file_get_contents( $imagePath)); //字体颜色 $color = imagecolorallocate ($image, 0, 0, 0); //画绘笔墨 foreach( $textArr as $v){ imagefttext ( $image, $v ['size' ], 0 , $v[ 'x' ], $v['y' ], $color, $fontPath ,$v ['text']); } if (imagepng ( $image,$imageName )){ echo $imageName ." \n"; } } functionrandPosition ($textArr , $imgW, $imgH , $fontW, $fontH,$i ,$type){ switch ($type ) { case 0 :// 天生 mp $x = rand ($i* 六0 , ($i + 一)* 六0-$fontW - 三); $y = rand ( 四0, 八0 ); break; case 一 : //天生 ap $x = ( $i )* 二 五+ 五 ; $y = 二 五;
[ 一][ 二][ 三][ 四]乌客交双网
getDigg( 一 三 四 五);