search
Homephp教程php手册PHP简单验证码类

PHP简单验证码类

Jun 06, 2016 pm 07:56 PM
linuxphpCommunitySimpleforumEnterverify

欢迎进入Linux社区论坛,与200万技术人员互动交流 >>进入 header ("Content-type: image/jpeg"); $code=imagejpeg($this-im); }elseif (function_exists("imagegif")) { header("Content-type: image/gif"); $code=imagegif($this-im); } imagedestroy($this

欢迎进入Linux社区论坛,与200万技术人员互动交流 >>进入

 

  header ("Content-type: image/jpeg");

  $code=imagejpeg($this->im);

  }elseif (function_exists("imagegif"))

  {

  header("Content-type: image/gif");

  $code=imagegif($this->im);

  }

  imagedestroy($this->im);

  return $code;

  }

  /**

  * 检查验证码

  * @param $code

  * @return bool

  */

  public function checkCode($code) {

  session_start();

  $secode=explode(',', $_SESSION['initphp_code']);

  $time=time();

  //检查时间是否过期

  if($secode[0]>$time||$time-$secode[0]>$this->time)

  {

  return false;

  }

  //验证码密钥 双md5 后是否一致

  if($secode[1]md5(md5($code.'initphpYzmsy'.$secode[0]))){

  return false;

  }

  //检查验证码字符串是否一致

  if($code||$code$secode[2])

  {

  return false;

  }

  return true;

  }

  /*随机扭曲*/

  public function setWarping(){

  $rgb=array();

  $direct=rand(0,1);

  $width = imagesx($this->im);

  $height = imagesy($this->im);

  $level=$width /20;

  for($j = 0;$j

  for($i = 0;$i

  $rgb[$i] = imagecolorat($this->im, $i , $j);

  }

  for($i = 0;$i

  $r = sin($j / $height * 2 * M_PI - M_PI * 0.5) * ($direct ? $level : -$level);

  imagesetpixel($this->im, $i + $r , $j , $rgb[$i]);

  }

  }

  }

  }

  ?>

  效果:

   PHP简单验证码类

  [1] [2] 

PHP简单验证码类

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)