PHP generates graphic verification code (mixed upper and lower case letters and numbers)

From , 3 Years ago, written in PHP, viewed 100 times.
URL https://pastebin.vip/view/ec1f850d
  1. <?php
  2.         header("content-type:image/png");
  3.         $num = $_GET['num'];
  4.         $imagewidth=60;
  5.         $imageheight=18;
  6.         srand(microtime() * 100000);
  7.  
  8.         $numimage = imagecreate($imagewidth,$imageheight);
  9.         imagecolorallocate($numimage,183,180,83);
  10.         for($i=0;$i<strlen($num);$i++){
  11.                 $font = mt_rand(3,5);
  12.                 $x = mt_rand(1,8)+$imagewidth*$i/4;
  13.                 $y = mt_rand(1,$imageheight/3);
  14.                 $color=imagecolorallocate($numimage,mt_rand(0,50),mt_rand(0,150),mt_rand(0,255));
  15.                 imagestring($numimage,$font,$x,$y,$num[$i],$color);
  16.         }
  17.         imagepng($numimage);
  18.         imagedestroy($numimage);
  19. ?>
  20.  
  21.  
  22.  
  23. 调用方法:
  24. <?php
  25.         session_start();
  26.         include_once 'conn/conn.php';
  27.         $pattern = '1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLOMNOPQRSTUVWXYZ';
  28.         $num = null;
  29.         for($i = 0; $i < 4; $i++) {
  30.         $num .= $pattern{mt_rand(0, 61)};
  31.         }      
  32. ?>
  33.  
  34. <div> 验证码:
  35.   <input id="lgchk" type="text" />
  36.   <img src="valcode.php?num=<?php echo $num; ?>" width="55" height="18" /> </div>
  37.  

Reply to "PHP generates graphic verification code (mixed upper and lower case letters and numbers)"

Here you can reply to the paste above

captcha

https://burned.cc - Burn After Reading Website