php生成验证码类代码
class securecode
{
private static $instance=null;
private $code = '';
private $fontfile;
private $validate;
private $image;
private $specialadd = 'special string for securecode';
private $codeexpire=86400;
private $codecookiename='secure_code';
/**
* 构造方法
*/
private function securecode()
{
$this->fontfile = dirname( __file__ ) . '/arial.ttf';
}
private function __construct()
{
$this->securecode();
}
public static function getinstance()
{
if (self::$instance==null)
self::$instance=new self();
return self::$instance;
}
/**
* 指定字体文件所在路径,默认为当前文件夹下arial.ttf文件
* @param $fontfile 文件路径
* @return void
*/
function loadfont($fontfile)
{
$this->fontfile = $fontfile;
}
/**
* 图片输出方法,在执行本方法前程序不应该有任何形式的输出
* @return void;
*/
function stroke()
{
$this->savecode();
self::sendheader();
imagegif( $this->validate );
imagedestroy( $this->validate );
imagedestroy( $this->image );
}
/**
* 图片保存方法
* @param $filename 保存路径
* @return void
*/
function save($filename)
{
$this->savecode();
imagegif( $this->validate , $filename );
imagedestroy( $this->validate );
imagedestroy( $this->image );
}
/**
* 验证码验证方法
* @param $input 要验证的字符串,即用户的输入内容
* @return boolean 验证结果
*/
function verify($input)
{
$input=strtolower($input);
$targetcode=$this->authcode($input);
$code=$this->getcookie();
if (empty($code)||$code!=$targetcode)
$result= false;
else
$result=true;
$_cookie[$this->codecookiename]='';
setcookie ( $this->codecookiename, '', - 1 );
return $result;
}
/**
* 图片创建方法
* @return void;
*/
function createimage()
{
$this->randcode();
$size = 30;
$width = 90;
$height = 35;
$degrees = array (
rand( 0 , 30 ), rand( 0 , 30 ), rand( 0 , 30 ), rand( 0 , 30 )
);
for ($i = 0; $i < 4; ++$i)
{
if (rand() % 2);
else $degrees[$i] = -$degrees[$i];
}
$this->image = imagecreatetruecolor( $size , $size );
$this->validate = imagecreatetruecolor( $width , $height );
$back = imagecolorallocate( $this->image , 255 , 255 , 255 );
$border = imagecolorallocate( $this->image , 0 , 0 , 0 );
imagefilledrectangle( $this->validate , 0 , 0 , $width , $height , $back );
for ($i = 0; $i < 4; ++$i)
{
$temp = self::rgbtohsv( rand( 0 , 250 ) , rand( 0 , 150 ) , rand( 0 , 250 ) );
if ($temp[2] > 60) $temp[2] = 60;
$temp = self::hsvtorgb( $temp[0] , $temp[1] , $temp[2] );
$textcolor[$i] = imagecolorallocate( $this->image , $temp[0] , $temp[1] , $temp[2] );
}
for ($i = 0; $i < 200; ++$i)
{
$randpixelcolor = imagecolorallocate( $this->validate , rand( 0 , 255 ) , rand( 0 , 255 ) , rand( 0 , 255 ) );
imagesetpixel( $this->validate , rand( 1 , 87 ) , rand( 1 , 35 ) , $randpixelcolor );
}
$temp = self::rgbtohsv( rand( 220 , 255 ) , rand( 220 , 255 ) , rand( 220 , 255 ) );
if ($temp[2] < 200) $temp[2] = 255;
$temp = self::hsvtorgb( $temp[0] , $temp[1] , $temp[2] );
$randlinecolor = imagecolorallocate( $this->image , $temp[0] , $temp[1] , $temp[2] );
self::imagelinethick( $this->validate , $textcolor[rand( 0 , 3 )] );
imagefilledrectangle( $this->image , 0 , 0 , $size , $size , $back );
putenv( 'gdfontpath=' . realpath( '.' ) );
// name the font to be used (note the lack of the .ttf extension
imagettftext( $this->image , 15 , 0 , 8 , 20 , $textcolor[0] , $this->fontfile , $this->code[0] );
$this->image = imagerotate( $this->image , $degrees[0] , $back );
imagecolortransparent( $this->image , $back );
imagecopymerge( $this->validate , $this->image , 1 , 4 , 4 , 5 , imagesx( $this->image ) - 10 , imagesy( $this->image ) - 10 , 100 );
$this->image = imagecreatetruecolor( $size , $size );
imagefilledrectangle( $this->image , 0 , 0 , $size , $size , $back );
imagettftext( $this->image , 15 , 0 , 8 , 20 , $textcolor[1] , $this->fontfile , $this->code[1] );
$this->image = imagerotate( $this->image , $degrees[1] , $back );
imagecolortransparent( $this->image , $back );
imagecopymerge( $this->validate , $this->image , 21 , 4 , 4 , 5 , imagesx( $this->image ) - 10 , imagesy( $this->image ) - 10 , 100 );
$this->image = imagecreatetruecolor( $size , $size );
imagefilledrectangle( $this->image , 0 , 0 , $size - 1 , $size - 1 , $back );
imagettftext( $this->image , 15 , 0 , 8 , 20 , $textcolor[2] , $this->fontfile , $this->code[2] );
$this->image = imagerotate( $this->image , $degrees[2] , $back );
imagecolortransparent( $this->image , $back );
imagecopymerge( $this->validate , $this->image , 41 , 4 , 4 , 5 , imagesx( $this->image ) - 10 , imagesy( $this->image ) - 10 , 100 );
$this->image = imagecreatetruecolor( $size , $size );
imagefilledrectangle( $this->image , 0 , 0 , $size - 1 , $size - 1 , $back );
imagettftext( $this->image , 15 , 0 , 8 , 20 , $textcolor[3] , $this->fontfile , $this->code[3] );
$this->image = imagerotate( $this->image , $degrees[3] , $back );
imagecolortransparent( $this->image , $back );
imagecopymerge( $this->validate , $this->image , 61 , 4 , 4 , 5 , imagesx( $this->image ) - 10 , imagesy( $this->image ) - 10 , 100 );
imagerectangle( $this->validate , 0 , 0 , $width - 1 , $height - 1 , $border );
}
/**
* 获取随机生成的验证码
* @return string 随机验证码,返回的验证码不进行任何处理
*/
function getcode()
{
return $this->code;
}
/**
* 生成随机码方法
* @return void;
*/
protected function randcode()
{
$alphastr = 'abcdefghijklmnpqrstuvwxyz123456789';
$randstr = array (
$alphastr{rand( 0 , 33 )}, $alphastr{rand( 0 , 33 )}, $alphastr{rand( 0 , 33 )}, $alphastr{rand( 0 , 33 )}
);
$this->code = strtolower( $randstr[0] . $randstr[1] . $randstr[2] . $randstr[3] );
}
/**
* rgb色到hsv色转变方法
* @param $r
* @param $g
* @param $b
* @return array hsv数组
*/
protected static function rgbtohsv($r, $g, $b)
{
$tmp = min( $r , $g );
$min = min( $tmp , $b );
$tmp = max( $r , $g );
$max = max( $tmp , $b );
$v = $max;
$delta = $max - $min;
if ($max != 0) $s = $delta / $max; // s
else
{
$s = 0;
//$h = undefinedcolor;
return;
}
if ($r == $max) $h = ($g - $b) / $delta; // between yellow & magenta
else if ($g == $max) $h = 2 + ($b - $r) / $delta; // between cyan & yellow
else $h = 4 + ($r - $g) / $delta; // between magenta & cyan
$h *= 60; // degrees
if ($h < 0) $h += 360;
return array (
$h, $s, $v
);
}
/**
* 同上一方法功能相反
* @param $h
* @param $s
* @param $v
* @return array rgb数组
*/
protected static function hsvtorgb($h, $s, $v)
{
if ($s == 0)
{
// achromatic (grey)
$r = $g = $b = $v;
return;
}
$h /= 60; // sector 0 to 5
$i = floor( $h );
$f = $h - $i; // factorial part of h
$p = $v * (1 - $s);
$q = $v * (1 - $s * $f);
$t = $v * (1 - $s * (1 - $f));
switch ($i)
{
case 0 :
$r = $v;
$g = $t;
$b = $p;
break;
case 1 :
$r = $q;
$g = $v;
$b = $p;
break;
case 2 :
$r = $p;
$g = $v;
$b = $t;
break;
case 3 :
$r = $p;
$g = $q;
$b = $v;
break;
case 4 :
$r = $t;
$g = $p;
$b = $v;
break;
default : // case 5:
$r = $v;
$g = $p;
$b = $q;
break;
}
return array (
$r, $g, $b
);
}
/**
* 使用cookie保存验证码的方法
* @return void
*/
protected function savecode()
{
$code = $this->authcode($this->code);
$this->setcookie($code);
}
/**
* 验证码cookie值获取方法
* @return string cookie值
*/
protected function getcookie()
{
if (empty( $_cookie[$this->codecookiename] ))
{
return '';
}
else
{
return addslashes($_cookie[$this->codecookiename]);
}
}
/**
* 验证码cookie创建方法
* @param string $code 要保存的验证码
* @return void
*/
protected function setcookie($code)
{
$expire = $this->codeexpire > 0 ? $this->codeexpire + time() : 0;
setcookie( $this->codecookiename , $code, $expire );
}
/**
* 验证码加密方法
* @param string $code 要加密的随机码
* @return mixed 执行结果
*/
protected function authcode($code)
{
return md5($code.$this->specialadd);
}
/**
* 干扰线生成方法
* @param resource $image 图片资源句柄
* @param string $color 干扰线颜色
*/
protected static function imagelinethick($image, $color)
{
$k = rand( 5 , 20 );
for ($px = 0; $px < 400; $px = $px + 1)
{
$y = $k * sin( 0.1 * ($px) ); //$y=200+10*sin(0.1*($px-200));
for ($i = 0; $i < 2; $i++)
{
imagesetpixel( $image , $px , $y + 10 + $i , $color );
}
}
}
/**
* http标头设置方法
* @return void
*/
protected static function sendheader()
{
header( "pragma: no-cache" );
header( "cache-control: max-age=1, s-maxage=1, no-cache, must-revalidate" );
header( 'content-type: image/gif' );
}
}
http://down.111cn.net/down/code/php/qitayuanma/2010/1220/22330.html
下面提供三款生成缩代码,兼容性都相当的不错,也可以自定高度与宽度哦。
function imageresize($srcfile,$tow,$toh,$tofile="")
{
if($tofile==""){ $tofile = $srcfile; }
$info = "";
$data = getimagesize($srcfile,$info);
switch ($data[2])
{
case 1:
if(!function_exists("imagecreatefromgif")){
echo "你的gd库不能使用gif格式的图片,请使用jpeg或png格式!<a href='网页特效:go(-1);'>返回</a>";
exit();
}
$im = imagecreatefromgif($srcfile);
break;
case 2:
if(!function_exists("imagecreatefromjpeg")){
echo "你的gd库不能使用jpeg格式的图片,请使用其它格式的图片!<a href='javascript:go(-1);'>返回</a>";
exit();
}
$im = imagecreatefromjpeg($srcfile);
break;
case 3:
$im = imagecreatefrompng($srcfile);
break;
}
$srcw=imagesx($im);
$srch=imagesy($im);
$towh=$tow/$toh;
$srcwh=$srcw/$srch;
if($towh<=$srcwh){
$ftow=$tow;
$ftoh=$ftow*($srch/$srcw);
}
else{
$ftoh=$toh;
$ftow=$ftoh*($srcw/$srch);
}
if($srcw>$tow||$srch>$toh)
{
if(function_exists("imagecreatetruecolor")){
@$ni = imagecreatetruecolor($ftow,$ftoh);
if($ni) imagecopyresampled($ni,$im,0,0,0,0,$ftow,$ftoh,$srcw,$srch);
else{
$ni=imagecreate($ftow,$ftoh);
imagecopyresized($ni,$im,0,0,0,0,$ftow,$ftoh,$srcw,$srch);
}
}else{
$ni=imagecreate($ftow,$ftoh);
imagecopyresized($ni,$im,0,0,0,0,$ftow,$ftoh,$srcw,$srch);
}
if(function_exists('imagejpeg')) imagejpeg($ni,$tofile);
else imagepng($ni,$tofile);
imagedestroy($ni);
}
imagedestroy($im);
}
实例代码二
<?php教程
/*构造函数-生成缩略图+水印,参数说明:
$srcfile-图片文件名,
$dstfile-另存文件名,
$markwords-水印文字,
$markimage-水印图片,
$dstw-图片保存宽度,
$dsth-图片保存高度,
$rate-图片保存品质*/
makethumb("a.jpg","b.jpg","50","50");
function makethumb($srcfile,$dstfile,$dstw,$dsth,$rate=100,$markwords=null,$markimage=null)
{
$data = getimagesize($srcfile);
switch($data[2])
{
case 1:
$im=@imagecreatefromgif($srcfile);
break;
case 2:
$im=@imagecreatefromjpeg($srcfile);
break;
case 3:
$im=@imagecreatefrompng($srcfile);
break;
}
if(!$im) return false;
$srcw=imagesx($im);
$srch=imagesy($im);
$dstx=0;
$dsty=0;
if ($srcw*$dsth>$srch*$dstw)
{
$fdsth = round($srch*$dstw/$srcw);
$dsty = floor(($dsth-$fdsth)/2);
$fdstw = $dstw;
}
else
{
$fdstw = round($srcw*$dsth/$srch);
$dstx = floor(($dstw-$fdstw)/2);
$fdsth = $dsth;
}
$ni=imagecreatetruecolor($dstw,$dsth);
$dstx=($dstx<0)?0:$dstx;
$dsty=($dstx<0)?0:$dsty;
$dstx=($dstx>($dstw/2))?floor($dstw/2):$dstx;
$dsty=($dsty>($dsth/2))?floor($dsth/s):$dsty;
$white = imagecolorallocate($ni,255,255,255);
$black = imagecolorallocate($ni,0,0,0);
imagefilledrectangle($ni,0,0,$dstw,$dsth,$white);// 填充背景色
imagecopyresized($ni,$im,$dstx,$dsty,0,0,$fdstw,$fdsth,$srcw,$srch);
if($markwords!=null)
{
$markwords=iconv("gb2312","utf-8",$markwords);
//转换文字编码
imagettftext($ni,20,30,450,560,$black,"simhei.ttf",$markwords); //写入文字水印
//参数依次为,文字大小|偏转度|横坐标|纵坐标|文字颜色|文字类型|文字内容
}
elseif($markimage!=null)
{
$wimage_data = getimagesize($markimage);
switch($wimage_data[2])
{
case 1:
$wimage=@imagecreatefromgif($markimage);
break;
case 2:
$wimage=@imagecreatefromjpeg($markimage);
break;
case 3:
$wimage=@imagecreatefrompng($markimage);
break;
}
imagecopy($ni,$wimage,500,560,0,0,88,31); //写入图片水印,水印图片大小默认为88*31
imagedestroy($wimage);
}
imagejpeg($ni,$dstfile,$rate);
imagejpeg($ni,$srcfile,$rate);
imagedestroy($im);
imagedestroy($ni);
}
?>
支持图片上传代码
<?php
$pic_name=date("dmyhis");
// 生成图片的宽度
$pic_width=$_post['width'];// 生成图片的高度
$pic_height=$_post['length'];function resizeimage($im,$maxwidth,$maxheight,$name){
//取得当前图片大小
$width = imagesx($im);
$height = imagesy($im);
//生成缩略图的大小
if(($width > $maxwidth) || ($height > $maxheight)){
$widthratio = $maxwidth/$width;
$heightratio = $maxheight/$height;
if($widthratio < $heightratio){
$ratio = $widthratio;
}else{
$ratio = $heightratio;
}
$newwidth = $width * $ratio;
$newheight = $height * $ratio;
if(function_exists("imagecopyresampled")){
$newim = imagecreatetruecolor($newwidth, $newheight);
imagecopyresampled($newim, $im, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
}else{
$newim = imagecreate($newwidth, $newheight);
imagecopyresized($newim, $im, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
}
imagejpeg ($newim,$name . ".jpg");
imagedestroy ($newim);
}else{
imagejpeg ($im,$name . ".jpg");
}
}if($_files['image']['size']){
//echo $_files['image']['type'];
if($_files['image']['type'] == "image/pjpeg"||$_files['image']['type'] == "image/jpg"||$_files['image']['type'] == "image/jpeg"){
$im = imagecreatefromjpeg($_files['image']['tmp_name']);
}elseif($_files['image']['type'] == "image/x-png"){
$im = imagecreatefrompng($_files['image']['tmp_name']);
}elseif($_files['image']['type'] == "image/gif"){
$im = imagecreatefromgif($_files['image']['tmp_name']);
}
if($im){
if(file_exists($pic_name.'.jpg')){
unlink($pic_name.'.jpg');
}
resizeimage($im,$pic_width,$pic_height,$pic_name);
imagedestroy ($im);
}
}
?><img src="<? echo $pic_name.'.jpg'; ?>"><br><br>
<form enctype="multipart/form-data" method="post" action="small_picture.php">
<br>
<input type="file" name="image" size="50" value="浏览"><p>
生成缩略图宽度:<input type="text" name="width" size="5"><p>
生成缩略图长度:<input type="text" name="length" size="5"><p>
<input type="submit" value="上传图片">
</form>
imagecreatetruecolor()返回一个图像标识符代表指定大小的黑色形象。
根据你的php教程和gd版本中函数定义与否。对于php 4.0.6通过4.1.x这个函数总是存在的
,
*/
$im=imagecreatetruecolor(100,100); //创建图像
$string='n'; //定义字符
$white=imagecolorallocate($im,255,255,255); //定义白色
$black=imagecolorallocate($im,0,0,0); //定义黑色
$red=imagecolorallocate($im,255,0,0); //定义红色
//在白色的背景上输出一个黑色的"z",其实是颠倒的n
imagecharup($im,6,20,20,$string,$white);
imagechar($im,2,40,40,"r",$red); //使用红色画出字符
header('content-type: image/png'); //输出头部信息
imagepng($im); //输出png文件
imagedestroy($im); //销毁图像
//
$img=imagecreatetruecolor(400,400); //创建图像
$white=imagecolorallocate($img,255,255,255); //定义白色
$black=imagecolorallocate($img,0,0,0); //定义黑色
imagearc($img,200,200,350,350,0,360,$white); //画椭圆弧
header("content-type: image/png"); //输出头信息
imagepng($img); //输出为png图像
imagedestroy($img); //销毁图像
//
$size=300;
$image=imagecreatetruecolor($size,$size);
//用白色背景加黑色边框画个方框
$back=imagecolorallocate($image,255,255,255);
$border=imagecolorallocate($image,0,0,0);
imagefilledrectangle($image,0,0,$size-1,$size-1,$back);
imagerectangle($image,0,0,$size-1,$size-1,$border);
$yellow_x=100;
$yellow_y=75;
$red_x=120;
$red_y=165;
$blue_x=187;
$blue_y=125;
$radius=150;
//用alpha值分配一些颜色
$yellow=imagecolorallocatealpha($image,255,255,0,75);
$red=imagecolorallocatealpha($image,255,0,0,75);
$blue=imagecolorallocatealpha($image,0,0,255,75);
//画三个交迭的圆
imagefilledellips教程e($image,$yellow_x,$yellow_y,$radius,$radius,$yellow);
imagefilledellipse($image,$red_x,$red_y,$radius,$radius,$red);
imagefilledellipse($image,$blue_x,$blue_y,$radius,$radius,$blue);
//输出header文件头
header('content-type: image/png');
//最后输出结果
imagepng($image);
imagedestroy($image);
//
$im=imagecreate(100,100); //创建图像
$string='php'; //定义字符串
$bg=imagecolorallocate($im,255,255,255); //定义白色
$black=imagecolorallocate($im,0,0,0); //定义黑色
//在左上角输出指定字符
imagechar($im,1,0,0,$string,$black);
header('content-type: image/png'); //输出头部信息
imagepng($im); //输出png文件
imagedestroy($im); //销毁图像
?>
我利用了getimagesize来获取原图片的大小然后再x0.5就是把图片/5哦。
array getimagesize ( string $filename [, array &$imageinfo ] )
getimagesize() 函数将测定任何 gif,jpg,png,swf,swc,ps教程d,tiff,bmp,iff,jp2,jpx,jb2,jpc,xbm 或 wbmp 图像文件的大小并返回图像的尺寸以及文件类型和一个可以用于普通 html 文件中 <img> 标记中的 height/width 文本字符串。
如果不能访问 filename 指定的图像或者其不是有效的图像,getimagesize() 将返回 false 并产生一条 e_warning 级的错误
*/
//定义一个文件
$filename='1.jpg';
$percent=0.5;
//发送头部文件
header('content-type: image/jpeg');
//获取图像的大小
list($width,$height)=getimagesize($filename);
//定义新的大小
$new_width=$width * $percent;
$new_height=$height * $percent;
$image_p=imagecreatetruecolor($new_width, $new_height);
/*
: int imagecreate(int x_size, int y_size);
返回值: 整数
内容说明
本函数用来建立一张全空的图形。参数 x_size、y_size 为图形的尺寸,单位为像素 (pixel)。
*/
$image=imagecreatefromjpeg($filename);
/*
resource imagecreatefromjpeg ( string filename ) imagecreatefromjpeg() 返回一图像标识符,代表了从给定的文件名取得的图像。 imagecreatefromjpeg() 在失败时返回一个空字符串,并且输出一条错误信息,不幸地在浏览器中显示为断链接。为减轻调试工作下面的例子会产生一个错误 jpeg:
*/
imagecopyresampled($image_p,$image,0,0,0,0,$new_width,$new_height,$width,$height);
/*
):imagecopyresamples() ,其像素插值算法得到的图像边缘比较平滑.质量较好(但该函数的速度比 imagecopyresized() 慢). 两个函数的参数是一样的.如下: imagecopyresampled(dest,src,dx,dy,sx,sy,dw,dh,sw,sh);
*/
//输出图像
imagejpeg($image_p, null, 100);
/*
执行该代码,将把原图像缩放50%,并以新图像输出
*/
在php教程如果想利用它图片处理函数就必须在php.ini里面的gd库开启哦,
*/
//发送头文件
header("content-type: image/png");
//创建图像,如果失败输出内容
$im=@imagecreate(150,50) or die("cannot initialize new gd image stream");
//定义背景颜色
$background_color=imagecolorallocate($im,255,255,255);
//定义文字颜色
$text_color=imagecolorallocate($im,233,14,91);
//在图像上画出文件
imagestring($im,3,5,5,"hello world",$text_color);
//输出图像文件
imagepng($im);
//销毁图像
imagedestroy($im);
/*
该代码的执行结果如图22.5所示:
*/
// 2图片等比例缩小
//定义一个文件
$filename='1.jpg';
//定义缩放百分比
$percent=0.5;
//输出头文件
header('content-type: image/jpeg');
//获取新的大小
list($width,$height)=getimagesize($filename);
$newwidth=$width * $percent;
$newheight=$height * $percent;
//创建图形区域,并载入图像
$thumb=imagecreatetruecolor($newwidth,$newheight);
$source=imagecreatefromjpeg($filename);
//重新调整大小
imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
//输出图像
imagejpeg($thumb);
/*
执行该代码,将把原图像缩放50%,并以新图像输出
*/
//在图片上写文字
//定义内容
$data='ivborw0kggoaaaansuheugaaabwaaaascamaaab/2u7waaaabl'.
'bmveuaaad///+l2z/daaaasuleqvr4xqwquqoaiaxc2/0vxzdr'.
'ex4ijtrkb7lobnustxsb0jixiamssqnwlsv+wulf4avk9flq2r'.
'8a5hse35q3eo2xp1a1wqkzsgetvdtkdqaaaabjru5erkjggg==';
//对内容进行base64编码
$data=base64_decode($data);
//根据字符串新建图像
$im=imagecreatefromstring($data);
if($im!== false)
{
//如果成功创建,则输出图像
header('content-type: image/png');
imagepng($im);
}
else
{
//如果创建失败,则输出内容
echo 'an error occured.';
}
/*
该代码的执行结果如图:22.4所示:
*/
//在图片上写文字
header("content-type: image/png");
//创建图像,如果失败输出内容
$im=@imagecreate(100,50) or die("cannot initialize new gd image stream");
//定义背景颜色
$background_color=imagecolorallocate($im,255,255,255);
//定义文字颜色
$text_color=imagecolorallocate($im,233,14,91);
//在图像上画出文件
imagestring($im,1,5,5,"a simple text string",$text_color);
//输出图像文件
imagepng($im);
//销毁图像
imagedestroy($im);
/*
执行该代码将生成一个jpeg图像。
并输出指定字符串
*/
相关文章
- 最近想自学PHP ,做了个验证码,但不知道怎么搞的,总出现一个如下图的小红叉,但验证码就是显示不出来,原因如下 未修改之前,出现如下错误; (1)修改步骤如下,原因如下,原因是apache权限没开, (2)点击打开php.int., 搜索extension=ph...2013-10-04
jQuery Real Person验证码插件防止表单自动提交
本文介绍的jQuery插件有点特殊,防自动提交表单的验证工具,就是我们经常用到的验证码工具,先给大家看看效果。效果图如下: 使用说明 需要使用jQuery库文件和Real Person库文件 同时需要自定义验证码显示的CSS样式 使用实例...2015-11-08- 这篇文章主要为大家详细介绍了JS实现随机生成验证码,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下...2021-09-06
- 通过jquery.cookie.js插件可以快速实现“点击获取验证码后60秒内禁止重新获取(防刷新)”的功能效果图:先到官网(http://plugins.jquery.com/cookie/)下载cookie插件,放到相应文件夹,代码如下:复制代码 代码如下: <!DOCTYPE ht...2015-03-15
- 验证码类文件 CreateImg.class.php <?php class ValidationCode { private $width,$height,$codenum; public $checkcode; //产生的验证码 private $checkimage; //验证码图片 private $disturbColor = ''; /...2015-11-08
- 这篇文章主要介绍了基于JavaScript实现验证码功能的相关资料...2017-04-03
Bootstrap中文本框的宽度变窄并且加入一副验证码图片的实现方法
这篇文章主要介绍了Bootstrap中文本框的宽度变窄并且加入一副验证码图片的实现方法的相关资料,非常不错,具有参考借鉴价值,需要的朋友可以参考下...2016-06-24- 下面小编就为大家带来一篇单击按钮发送验证码,出现倒计时的简单实例。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧 代码...2017-07-06
- 验证码是一个现在WEB2.0中常见的一个功能了,像注册、登录又或者是留言页面,都需要注册码来验证当前操作者的合法性,我们会看到有些网站没有验证码,但那是更高级的验证了,...2016-11-25
- 这篇文章主要介绍了基于Pytorch版yolov5的滑块验证码破解思路详解,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下...2021-02-25
- 最近接到新需求,需要实现一个点击发送验证码之后,按钮禁用,在5秒之后取消禁用,看似需求很简单,实现起来还真的好好动动脑筋,下面小编把jquery控制按钮禁用核心代码分享给大家,需要的朋友参考下吧...2021-07-24
- 这篇文章主要为大家详细介绍了vue+springboot实现登录验证码,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下...2021-05-28
- 工信部的ICP备案网站登录时验证码一直输入不正确怎么回事,为了防止一些机器采集人工信部对于查询验证做得识别度极低,所以许多的朋友都会发现输入验证码一直有问题了,那...2016-10-10
- web开发中,经常会使用验证码功能,例如登录、注册,或其他关键功能之前经常会使用。下面通过实例代码给大家介绍Web制作验证码功能实例代码,感兴趣的朋友一起看看吧...2017-06-24
- 这篇文章主要为大家详细介绍了vue实现登录验证码,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下...2021-08-13
- GoDaddy怎么开启手机验证码登录?最近老听朋友说gd用户盗了,然后域名丢失了,今天 我们一起来看看关于GoDaddy开启手机验证码登录的教程. 给账户添加多重验证是为了账...2016-10-10
- 这篇文章主要为大家详细介绍了JavaScript实现验证码案例,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下...2021-10-28
- 这篇文章主要介绍了python网络爬虫实现发送短信验证码的方法,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧...2021-02-25
- 这篇文章主要介绍了C#验证码识别基础方法实例分析,较为详细的总结了C#验证码的实现思路及具体步骤,并对实现思路进行了总结归纳,具有很好的实用价值,需要的朋友可以参考下...2020-06-25
- 这篇文章主要为大家详细介绍了uni-app实现获取验证码倒计时功能,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下...2020-11-02