include/chajian/imgcodeChajian.php

(完整代码) 1KB

<?php 
/**
*	图片验证码
*/
class imgcodeChajian extends Chajian{
	
	public function check($key,$val)
	{
		if(isempt($val))return false;
		$code 	= 'abc'.$val.'';
		$geval  = c('cache')->get('code'.$key.'');
		if(md5($code)!=$geval)return false;
		c('cache')->del('code'.$key.'');
		return true;
	}
	
	public function show($key)
	{
		header("Content-type:image/gif");
		$a		= rand(0,9);
		$b		= rand(0,9);
		$h  	= 30;
		$code 	= 'abc'.($a+$b).'';
		$w 		= 70;
		$im		= imagecreatetruecolor($w,$h);
		c('cache')->set('code'.$key.'', md5($code), 5*60);
		$bg		= imagecolorallocate($im,255,255,255);
		imagefill($im,0,0,$bg);	//添加背景颜色

		$black	= imagecolorallocate($im,0,0,0);

		for($i=0;$i<2;$i++){//画线条
			$at1=imagecolorallocate($im,rand(0,255),rand(0,255),rand(0,255));
			imageline($im,0,rand(0,$h),$w,rand(0,$h),$at1);
		}

		for($i=0;$i<200;$i++){//画点
			$at1=imagecolorallocate($im,rand(0,255),rand(0,255),rand(0,255));
			imagesetpixel($im,rand(0,$w),rand(0,$h),$at1);
		}

		imagestring($im,5,rand(0,30),rand(0,$h-15),''.$a.'+'.$b.'=?',$black);
		
		imagegif($im);
		imagedestroy($im);
	}
}                               

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。