用户名:
密 码: 记住
您当前的位置:首页 > 网络编程 > php教程

php 验证码生成程序,可自动判断php gd库

时间:2015-01-23  来源:西部数据  作者:西部数据
  1. function ShowKey() 
  2. $key=strtolower(domake_password(4)); 
  3. $set=esetcookie("checkkey",$key); 
  4.  //是否支持gd库 
  5. if (function_exists("imagejpeg")) { 
  6.    header ("Content-type: image/jpeg"); 
  7.    $img=imagecreate(69,20); 
  8.    $black=imagecolorallocate($img,255,255,255); 
  9.    $gray=imagecolorallocate($img,102,102,102); 
  10.    imagefill($img,0,0,$gray); 
  11.    imagestring($img,3,14,3,$key,$black); 
  12.    imagejpeg($img); 
  13.    imagedestroy($img); 
  14. elseif (function_exists("imagegif")) { 
  15.    header ("Content-type: image/gif"); 
  16.    $img=imagecreate(69,20); 
  17.    $black=imagecolorallocate($img,255,255,255); 
  18.    $gray=imagecolorallocate($img,102,102,102); 
  19.    imagefill($img,0,0,$gray); 
  20.    imagestring($img,3,14,3,$key,$black); 
  21.    imagegif($img); 
  22.    imagedestroy($img); 
  23. elseif (function_exists("imagepng")) { 
  24.  header ("Content-type: image/png"); 
  25.    $img=imagecreate(69,20); 
  26.    $black=imagecolorallocate($img,255,255,255); 
  27.    $gray=imagecolorallocate($img,102,102,102); 
  28.    imagefill($img,0,0,$gray); 
  29.    imagestring($img,3,14,3,$key,$black); 
  30.    imagepng($img); 
  31.    imagedestroy($img); 
  32. elseif (function_exists("imagewbmp")) { 
  33.  header ("Content-type: image/vnd.wap.wbmp"); 
  34.    $img=imagecreate(69,20); 
  35.    $black=imagecolorallocate($img,255,255,255); 
  36.    $gray=imagecolorallocate($img,102,102,102); 
  37.    imagefill($img,0,0,$gray); 
  38.    imagestring($img,3,14,3,$key,$black); 
  39.    imagewbmp($img); 
  40.    imagedestroy($img); 
  41. else { 
  42.  $set=esetcookie("checkkey","ebak"); 
  43.  @include("class/functions.php"); 
  44.  echo ReadFiletext("images/ebak.jpg"); 
  45. }//开源代码phpfensi.com 
  46. ShowKey(); 
来顶一下
返回首页
返回首页
推荐资讯
WiFi太不安全:7岁女孩11分钟内入侵公共网络 WiFi太不安全:7岁女孩11分钟内入侵近期刚刚发布研究说WiFi网络能获得人们手机里多少私人信息,
不服跑个分?人工智能也出现“刷分”乱象 不服跑个分?人工智能也出现“刷分2014年,人工智能领域突然爆发,成为了科研和科技创业的热门
相关文章
栏目更新
栏目热门