php生成GIF动态动画验证码
代码语言:php
所属分类:验证码
代码描述:php生成GIF动态动画验证码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<?php /** * 调用示例 * */ session_start(); $randCode = ''; //验证码随机 $safe=""; $str="abcdefghjkmnpqrstuvwsyzABCDEFGHJKMNPQRSTUVWSYZ23456789"; for($i=0;$i<4;$i++){ $safe.=substr($str,rand(0,strlen($str)),1); } $_SESSION["imgcode"]=$safe; ImageCode($safe, 60); // 显示GIF动画 /** * ImageCode 生成GIF图片验证 * @param $string 字符串 * @param $width 宽度 * @param $height 高度 * */ function ImageCode($string = '', $width = 75, $height = 25){ $authstr = $string ? $string : ((time() % 2 == 0) ? mt_rand(1000, 9999) : mt_rand(10000, 99999)); $board_width = $width; $board_height = $height; $top=0; // 生成一个32帧的GIF动画 for($i = 0; $i < 32; $i++){ ob_start(); $image = imagecreate($board_width, $board_height); imagecolorallocate($image, 0,0,0); // 设定文字颜色数组 $colorList[] = ImageColorAllocate($image, 15,73,210); $colorList[] = ImageColorAllocate($image, 0,64,0); $colorList[] = ImageColorAllocate($image, 0,0,64); $colorList[] = ImageColorAllocate($image, 0,128,128); $colorList[] = ImageColorAllocate($image, 27,52,47); $colorList[] = ImageColorAllocate($image, 51,0,102); $colorList[] = ImageColorAllocate($image, 0,0,145); $colorList[] = ImageColorAllocate($image, 0,0,113); $colorList[] = ImageColorAllocate($image, 0,51,51); $colorList[] = ImageColorAllocate($image, 158,180,35); $colorList[] = ImageColorAllocate($image, 59,59,59); $colorList[] = ImageColorAllocate($image, 0,0,0); $colorList[] = ImageColorAllocate($image, 1,128,180); $colorList[] = ImageColorAllocate($image, 0,153,51); $colorList[] = ImageColorAllocate($image, 60,131,1); $colorList[] = ImageColorAllocate($image, 0,0,0); $fontcolor = ImageColorAllocate(.........完整代码请登录后点击上方下载按钮下载查看
网友评论0