最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
php 验证码生成程序[可自动判断php gd库]
时间:2009-10-27 编辑:简简单单 来源:一聚教程网
php 验证码生成程序[可自动判断php gd库]
function ShowKey()
{
$key=strtolower(domake_password(4));
$set=esetcookie("checkkey",$key);
//是否支持gd库
if (function_exists("imagejpeg")) {
header ("Content-type: image/jpeg");
$img=imagecreate(69,20);
$black=imagecolorallocate($img,255,255,255);
$gray=imagecolorallocate($img,102,102,102);
imagefill($img,0,0,$gray);
imagestring($img,3,14,3,$key,$black);
imagejpeg($img);
imagedestroy($img);
}
elseif (function_exists("imagegif")) {
header ("Content-type: image/gif");
$img=imagecreate(69,20);
$black=imagecolorallocate($img,255,255,255);
$gray=imagecolorallocate($img,102,102,102);
imagefill($img,0,0,$gray);
imagestring($img,3,14,3,$key,$black);
imagegif($img);
imagedestroy($img);
}
elseif (function_exists("imagepng")) {
header ("Content-type: image/png");
$img=imagecreate(69,20);
$black=imagecolorallocate($img,255,255,255);
$gray=imagecolorallocate($img,102,102,102);
imagefill($img,0,0,$gray);
imagestring($img,3,14,3,$key,$black);
imagepng($img);
imagedestroy($img);
}
elseif (function_exists("imagewbmp")) {
header ("Content-type: image/vnd.wap.wbmp");
$img=imagecreate(69,20);
$black=imagecolorallocate($img,255,255,255);
$gray=imagecolorallocate($img,102,102,102);
imagefill($img,0,0,$gray);
imagestring($img,3,14,3,$key,$black);
imagewbmp($img);
imagedestroy($img);
}
else {
$set=esetcookie("checkkey","ebak");
@include("class/functions.php");
echo ReadFiletext("images/ebak.jpg");
}
}
ShowKey();
相关文章
- PHP导出数据超时的优化建议解读 10-31
- PHP之mysql位运算解析 10-31
- Laravel实现登录跳转功能解析 10-31
- php双向队列解读 10-31
- Laravel异常上下文解决教程 10-24
- php数组查询元素位置方法介绍 10-24