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

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

 11.1K  3  查看评论 (2)
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. 苦力吧素材官方QQ群:950875342
2. 平台上所有素材资源,需注册登录会员方能正常下载。
3. 会员用户积极反馈网站、素材资源BUG或错误问题,每次奖励2K币
4. PHP源码类素材,如需协助安装调试,或你有二次开发需求,可联系苦力吧客服。
5. 付费素材资源,需充值后方能下载,如有任何疑问可直接联系苦力吧客服
相关资源 / 其它源码

PHP学生在线笔记共享系统网站源码

一款学生笔记共享系统源码,核心就是会员系统+笔记展示、预览、下载功能。主要功能包含:会员注册、会员登录、个人资料修改、密码修改、添加笔记(暂只能上传PDF文件)、编辑笔记、删除笔记。
  其它源码
 41058  0

PHP+Ajax通过邮箱发邮件找回会员登录密码

一款常见的网站通过邮箱发信找回密码的php源码,共包含6个html/php/sql文件,分别为:index.html,connect.php,reset.php,sendmail.php,smtp.class.php,t_user.sql。这是一个完整的DEMO演示程序,需要修改connect.php数据库连接信息,然后再进行sql数据库导入。
  其它源码
 6777  0

PHP在线留言表单信息给邮箱发信源码

一款网页留言表单发信到指定邮箱,用户完成表单输入后提交,使用mail()函数从本地脚本将表单信息发到指定邮箱。
  其它源码
 5904  0

PHP党建空中课堂垃圾分类培训手机网站源码

这是一款手机微信公众号端的学习培训类网站,主要功能包含:按步骤推进学习显示内容、语音播放、倒计时阅读文章内容、填写表单信息等,所有内容都可通过后台管理系统进行操作。
  其它源码
 5757  0

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

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