欢迎来到天天文库
浏览记录
ID:39467286
大小:56.50 KB
页数:11页
时间:2019-07-04
《PHP比较好的验证码》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、*@version1.0*@copyrightEreesoftInc.2009*@update2009-05-1422:32:05*@example*session_sratr();*$vcode=newVcode();*$vcode->setLength(5);*$_SESSION['vcode']=$vcode->paint();//Tobee
2、ncryptedbyMD5*/classVcode{/***@var$widthThewidthoftheimage,autoCalculated验证图片宽度,程序自动计算*/private$width;/***@var$heightImageheight验证图片高度*/private$height;/***@var$lengthVerificationCodelenght验证码长度*/private$length;/***@var$bgColorImagebackgroundcolordefaultrandom验证图片背景色*/pr
3、ivate$bgColor;/***@var$fontColorThetextcolor验证码颜色*/private$fontColor;/***@var$dotNoiseThenumberofnoise噪点数量*/private$dotNoise;/***@var$lineNoiseThenumberofnoiselines干扰线数量*/private$lineNoise;/***@var$imimageresourceGD图像操作资源*/private$im;/***voidVcode::Vcode()**Theconstruct
4、or*/publicfunctionVcode(){$this->dotNoise=20;//初始化噪点数量$this->lineNoise=2;//初始化干扰线数量}/***voidVcode::setLength(integer$length)**SetVerificationCodelength*@accesspublic*@paraminteger$length;*@returnvoid*/publicfunctionsetLength($length){$this->length=$length;}/***voidVcode
5、::setBgColor(string$bgColor)**SetbackgroundcoloroftheVerificationImage*@accesspublic*@paramstring$bgColore.g.:#ffffff;可以直接使用css书写中的16进制写法,但不可简写*@returnvoid*/publicfunctionsetBgColor($bgColor){$this->bgColor=sscanf($bgColor,'#%2x%2x%2x');}/***voidVcode::setFontColor(stri
6、ng$fontgColor)**SettextcoloroftheVerificationImage*@accesspublic*@paramstring$fontColore.g.:#ffffff;可以直接使用css书写中的16进制写法,但不可简写*@returnvoid*/publicfunctionsetFontColor($fontColor){$this->fontColor=sscanf($fontColor,'#%2x%2x%2x');}/***voidVcode::setDotNoise(integer$num)**H
7、owmanynoisedotswanttodraw*@accesspublic*@paraminteger$numToomuchwilllowerperformance*@returnvoid*/publicfunctionsetDotNoise($num){$this->dotNoise=$num;//手动设置噪点数量后,会覆盖初始设置}/***voidVcode::setLineNoise(integer$num)**Howmanynoiselineswanttodraw*@accesspublic*@paraminteger$n
8、umToomuchwilllowerperformance*@returnvoid*/publicfunctionsetLineNoise($num){$this->lineNoise=$num;//手动设置干扰线数量后
此文档下载收益归作者所有