• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

php容易验证码

php 搞代码 3年前 (2022-01-23) 19次浏览 已收录 0个评论

php简单验证码

<?phpclass VerifyImg {	public $fontSize = 15; //定义字体大小	public $length = 4; //定义字符串长度                        	public $width = 70; //定义图片宽度	public $height = 30; //定义图片高度	public $im = null; //生成一张指定宽高的图片	public $font = 'C:/Windows/Fonts/Arial.TTF';	public $strNum = "";	public function Build() {		$strings = Array ('1', '2','3', '4', '5', '6', '7', 'a', 'b', 'c', 'd', 'e', 'f', 'h', 'i', 'j', 'k', 'm', 'n', 'p', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y' );//		$strNum = "";		$count = count ( $strings );		for($i = 1; $i length; $i ++) { //循环随机取字符生成字符串			$strNum .= $strings [rand ( 0, $count - 1 )];		}		session_start ();		$_SESSION ["verifycode"] = $strNum;		$this->im = imagecreate ( $this->width, $this->height );		$backgroundcolor = imagecolorallocate ( $this->im, 255, 255, 255 ); //生成背景色		$frameColor = imageColorAllocate ( $this->im, 0, 255, 0 );		for($i = 0; $i length; $i ++) {			$charY = ($this->height + 9) / 2 + rand ( - 1, 1 ); //定义字符Y坐标			$charX = $i * 15 + 8; //定义字符X坐标			//            $text_color = imagecolorallocate($this->im, 255, 0, 0);                                                //生成字符颜色			$text_color = imagecolorallocate ( $this->im, mt_rand ( 50, 255 ), mt_rand ( 50, 128 ), mt_rand ( 50, 200 ) );			$angle = rand ( - 20, 20 ); //生成字符角度			//写入字符			imagettftext ( $this->im, $this->fontSize, $angle, $charX, $charY, $text_color, $this->font, $strNum [$i] );		}		for($i = 0; $i im, mt_rand ( 0, 255 ),%本文@来源gao@!dai!ma.com搞$$代^@码!网搞代gaodaima码 mt_rand ( 0, 255 ), mt_rand ( 0, 255 ) );			$linex = mt_rand ( 1, $this->width - 1 );			$liney = mt_rand ( 1, $this->height - 1 );			imageline ( $this->im, $linex, $liney, $linex + mt_rand ( 0, 4 ) - 2, $liney + mt_rand ( 0, 4 ) - 2, $linecolor );		}		for($i = 0; $i im, mt_rand ( 0, 255 ), mt_rand ( 0, 255 ), mt_rand ( 0, 255 ) );			imagesetpixel ( $this->im, mt_rand ( 1, $this->width - 1 ), mt_rand ( 1, $this->height - 1 ), $pointcolor );		}		imagerectangle ( $this->im, 0, 0, $this->width - 1, $this->height - 1, $frameColor ); //画边框		ob_clean ();		header ( 'Content-type:image/png' );		imagepng ( $this->im );		imagedestroy ( $this->im );	}}$img = new VerifyImg ();$img->Build ();?>

搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:php容易验证码
喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址