前些时间在一个网站上看到一个很有趣的事情,登陆的时候要输入验证码,但看不清楚。点了一下看不清楚。结果他只换了一张背景图片。今天我也写一个。根据以前写的一个修改而来。
<?php Header("Content-type: image/PNG"); require_once("rndnum.php"); $rndnum=new rndnum("6"); $authnum=$rndnum->rnd(); session_start(); if($_SESSION["extrra_code"]==""){ $_SESSION["extrra_code"]=$authnum; }else{ $authnum=$_SESSION["extrra_code"]; } $im = imagecreate(72,20); $black = ImageColorAllocate($im, 0,0,0); $white = ImageColorAllocate($im, rand(0,255),rand(0,255),rand(0,255)); $gray = ImageColorAllocate($im, rand(200,255),rand(100,255),rand(200,255)); imagefill($im,0,0,$gray); for($i=0;$i<200;$i++) //加入干扰象素 { $randcolor = ImageColorallocate($im,rand(0,255),rand(0,255),rand(0,255)); imagesetpixel($im, rand()%70 , rand()%30 , $randcolor); } ImagePNG($im); ImageDestroy($im); >
|