<?php $string="welcome to my webside"; getAuthImage($string); function getAuthImage( $string , $im_x = 120 , $im_y = 60) { ob_start(); $im_x = 120; $im_y = 60;
$im = imagecreatetruecolor ($im_x, $im_y); imagefill($im, 0, 0, imagecolorallocate($im,255,255,255) );
//注意以下字体文件需要有 $stringColor = imagecolorallocate($im, 17, 158, 20); imagettftext ($im, 24, rand(-6 , 6), $im_x*0.1, $im_y*0.7, $stringColor, '/usr/local/share/fonts/georgia.ttf', $string);
//扭曲,变形
$distortion_im = imagecreatetruecolor ($im_x*1.5 , $im_y); imagefill($distortion_im, 0, 0, imagecolorallocate($distortion_im,255,255,255) ); for ( $i=0; $i<$im_x; $i++) { for ( $j=0; $j<$im_y; $j++) { $rgb = imagecolorat($im, $i , $j); if( (int)($i+20+sin($j/$im_y*2*M_PI)*10) <= imagesx($distortion_im) && (int)($i+20+sin($j/$im_y*2*M_PI)*10) >=0 ) { imagesetpixel ($distortion_im, (int)($i+20+sin($j/$im_y*2*M_PI-M_PI*0.4)*8) , $j , $rgb); } } }
//pixel
for($i=0; $i <= 64; $i++) { $pointcolor = imagecolorallocate($distortion_im, 17, 158, 20); imagesetpixel($distortion_im, rand(0, imagesx($distortion_im)), rand(0, imagesy($distortion_im)), $pointcolor); }
ob_clean(); header('Content-type: image/jpeg'); imagejpeg ($distortion_im); imagedestroy($im); imagedestroy($distortion_im); }
?>
|
字体扭了是不好破解,因为人都认不出来!
就像Google,yahoo的验证,有时候我要刷新好几次!
呵呵,我还是喜欢做算术
备案那个网站的验证码最变态,人都不认识。。。
怎么玩起php了 用python弄个呀!
@WooGooo 最近做了个刷票的小软件
,无奈那个汉字验证码只能靠人来输入~准备学习一下这个方面的东西
@kangzj 他们那些人的脑筋不是一般的XX……
@houkai 我对php研究的多……python还远征呢……
去年还买过几本PHP的书来看,但今年来很少在碰了,现在很多都忘记了。还有Python也扔了好多

坚持不下去,老是给自己找借口
@ngshaozhu 一直想学Python,可惜也是坚持不了多久……╮(╯▽╰)╭一起努力啊
@TaoGOGO
Me too.
@lostab 哈哈,英语不错
@TaoGOGO
英语...四级勉强才过.
学日语的.