PHP基于session图片验证码DEMO示例

所属分类: PHP源码-其它源码    2023-11-27 06:40:27

PHP基于session图片验证码DEMO示例 ie兼容6
反馈问题  查看演示  登录后下载 温馨提示
登录会员即可享受免费下载
 我要建站

PHP基于session图片验证码DEMO示例(共5个文件)

    • validatecode.class.php
    • captcha.php
    • index.php

使用方法

font = './font/elephant.ttf';//注意字体路径要写对,否则显示不了图片
 }
 //生成随机码
 private function createCode() {
  $_len = strlen($this->charset)-1;
  for ($i=0;$i<$this->codelen;$i++) {
   $this->code .= $this->charset[mt_rand(0,$_len)];
  }
 }
 //生成背景
 private function createBg() {
  $this->img = imagecreatetruecolor($this->width, $this->height);
  $color = imagecolorallocate($this->img, mt_rand(157,255), mt_rand(157,255), mt_rand(157,255));
  imagefilledrectangle($this->img,0,$this->height,$this->width,0,$color);
 }
 //生成文字
 private function createFont() {
  $_x = $this->width / $this->codelen;
  for ($i=0;$i<$this->codelen;$i++) {
   $this->fontcolor = imagecolorallocate($this->img,mt_rand(0,156),mt_rand(0,156),mt_rand(0,156));
   imagettftext($this->img,$this->fontsize,mt_rand(-30,30),$_x*$i+mt_rand(1,5),$this->height / 1.4,$this->fontcolor,$this->font,$this->code[$i]);
  }
 }
 //生成线条、雪花
 private function createLine() {
  //线条
  for ($i=0;$i<6;$i++) { $color = imagecolorallocate($this->img,mt_rand(0,156),mt_rand(0,156),mt_rand(0,156));
   imageline($this->img,mt_rand(0,$this->width),mt_rand(0,$this->height),mt_rand(0,$this->width),mt_rand(0,$this->height),$color);
  }
  //雪花
  for ($i=0;$i<100;$i++) { $color = imagecolorallocate($this->img,mt_rand(200,255),mt_rand(200,255),mt_rand(200,255));
   imagestring($this->img,mt_rand(1,5),mt_rand(0,$this->width),mt_rand(0,$this->height),'*',$color);
  }
 }
 //输出
 private function outPut() {
  header('Content-type:image/png');
  imagepng($this->img);
  imagedestroy($this->img);
 }
 //对外生成
 public function doimg() {
  $this->createBg();
  $this->createCode();
  $this->createLine();
  $this->createFont();
  $this->outPut();
 }
 //获取验证码
 public function getCode() {
  return strtolower($this->code);
 }
}

?>

站长提示:
1. 平台上所有素材资源,需注册登录会员方能正常下载。
2. 会员用户积极反馈网站、素材资源BUG或错误问题,每次奖励20K币
3. PHP源码类素材,如需协助安装调试,或你有二次开发需求,可联系苦力吧客服。
4. 付费素材资源,需充值后方能下载,如有任何疑问可直接联系苦力吧客服
相关资源 / 其它源码

PHP站内文档文章关键字搜索查询网站源码

这是一款在线关键字查询网站源码,主要功能包含:支持全局搜索和指定栏目搜索、支持分词搜索、后台可自定义栏目、添加文章等,所有内容都可通过后台管理系统进行操作。
  其它源码
 67  

PHP学校办公校园教务信息OA网站管理系统源码

这是一款校园数字化OA办公多用户管理系统,核心功能:包含4个用户组角色(总管理员、老师、学生、图书管理员)、可在线管理学生信息、老师信息、请假、借书、发布公告等校内日常事务。
  其它源码
 81  

PHP基于session图片验证码DEMO示例

一款基于session缓存变量开发的验证码插件,共包含4个文件(ttf字体及三个php文件)使用了ttf字体,还有php生成背景、线条、雪花、文字、随机码,最后组合生成带有验证码的img图片。
  其它源码
 162  

php简易的医院预约在线挂号网站系统源码

这是一款在线医生挂号网站源码,主要功能包含:医生查询、科室分类、在线留言、会员登录、会员注册(含两种类型:医生和患者)、医生认证等,所有内容都可通过后台管理系统进行操作。
  其它源码
 98  

评论数(2) 回复有机会获得K币 用户协议

    jq小菜鸡0
    2023-12-18 19:26:20
    下载就能用,支持!
    回复
    NoMeaning0
    2023-12-06 16:52:27
    这个非常不错,简单实用~ 轻松拿捏了😀
    回复 1
😀
  • 😀
  • 😊
  • 😂
  • 😍
  • 😑
  • 😷
  • 😵
  • 😛
  • 😣
  • 😱
  • 😋
  • 😎
  • 😵
  • 😕
  • 😶
  • 😚
  • 😜
  • 😭
发表评论