php验证码打叉,phpcms 验证码显示为红叉叉的补丁源码!
BUG表现:
主机GD库启用,但是验证码显示为一红色叉,这是因为生成图片前缓冲区有数据导致,在生成图片前清理缓冲区数据即可正常
如果没有出现这个问题,则不需要下载此补丁(当然,安装此补丁也没有副作用的的!
^v^ )
把下面两个源码两个文件覆盖phpcms根目录下对应的文件即可
PHPCMS Team , Author :zhangxu@ku6.com
toimg.php源码:
require dirname(__FILE__).'/include/common.inc.php';
ob_clean();
if(isset($gd) && $gd==1
&& $auth)
{
header ("Content-type: image/png");
$auth = phpcms_auth($auth, 'DECODE', $PHPCMS['authkey']);
$im = @imagecreate (strlen($auth)*9, 16) or die ("Cannot Initialize
new GD image stream");
$background_color = imagecolorallocate ($im, 255, 255, 255);// RGB
Background Color
$text_color = imagecolorallocate ($im, 0, 0, 0);// RGB Text
Color
imagestring ($im, 5, 0, 0,$auth, $text_color);
imagepng ($im);
imagedestroy ($im);
}
else
{
if(!$auth) exit;
if(function_exists("imagepng"))
{
$output='
src="'.PHPCMS_PATH.'toimg.php?gd=1&auth='.$auth.'"
align="absmiddle">';
}
else
{
$output = phpcms_auth($auth,
'DECODE', $PHPCMS['authkey']);;
}
echo "document.write('".$output."');";
}
?>
checkcode.php源码:
require dirname(__FILE__).'/include/common.inc.php';
//error_reporting(E_ALL);
$session = new phpcms_session();
$enablegd = 1;
$funcs =
array('imagecreatetruecolor','imagecolorallocate','imagefill','imagestring','imageline','imagerotate','imagedestroy','imagecolorallocatealpha','imageellipse','imagepng');
foreach($funcs as $func)
{
if(!function_exists($func))
{
$enablegd = 0;
break;
}
}
//echo $enablegd;
ob_clean();
if($enablegd)
{
//create captcha
$consts = 'bcdfghjkmnpqrstwxyz';
$vowels = 'aei23456789';
for ($x = 0; $x < 6; $x++)
{
$const[$x] = substr($consts,
mt_rand(0,strlen($consts)-1),1);
$vow[$x] = substr($vowels,
mt_rand(0,strlen($vowels)-1),1);
}
$radomstring = $const[0] . $vow[0] .$const[2] . $const[1] . $vow[1]
. $const[3] . $vow[3] . $const[4];
$_SESSION['checkcode'] = $string = substr($radomstring,0,4); //only
display 4 str
//set up image, the first number is the width and the second is the
height
$imageX = strlen($radomstring)*5.5; //the image width
$imageY =
20; //the image height
$im = imagecreatetruecolor($imageX,$imageY);
//var_dump($im);exit;
//creates two variables to store color
$background = imagecolorallocate($im, rand(180, 250), rand(180,
250), rand(180, 250));
$foregroundArr = array(imagecolorallocate($im, rand(0, 20), rand(0,
20), rand(0, 20)),
imagecolorallocate($im, rand(0, 20), rand(0, 10), rand(245,
255)),
imagecolorallocate($im, rand(245, 255), rand(0, 20), rand(0,
10)),
imagecolorallocate($im, rand(245, 255), rand(0, 20), rand(245,
255)));
$foreground2 = imagecolorallocatealpha($im, rand(20, 100), rand(20,
100), rand(20, 100),80);
$middleground = imagecolorallocate($im, rand(200, 160), rand(200,
160), rand(200, 160));
$middleground2 = imagecolorallocatealpha($im, rand(180, 140),
rand(180, 140), rand(180, 140),80);
//fill image with bgcolor
imagefill($im, 0, 0, imagecolorallocate($im, 250, 253, 254));
//writes string
imagestring($im, 5, 3, floor(rand(0,5))-1, $string[0],
$foregroundArr[rand(0,3)]);
imagestring($im, 5, 13, floor(rand(0,5))-1, $string[1],
$foregroundArr[rand(0,3)]);
imagestring($im, 5, 23, floor(rand(0,5))-1, $string[2],
$foregroundArr[rand(0,3)]);
imagestring($im, 5, 33, floor(rand(0,5))-1, $string[3],
$foregroundArr[rand(0,3)]);
for($i=0; $i
{
if(mt_rand(0,ord(substr($string,$i,1)))%2 == 0)
{
$string{$i}
= ' ';
}
}
imagestring($im, 2, 2, 0, $string, $foreground2);
//strikethrough
$border = imagecolorallocate($im, 133, 153, 193);
//imagefilledrectangle($aimg, 0, 0, $x_size - 1, $y_size - 1,
$back);
imagerectangle($im, 0, 0, $imageX - 1, $imageY - 1, $border);
$pointcol = imagecolorallocate($im, rand(0,255), rand(0,255),
rand(0,255));
for ($i=0;$i<20;$i++)
{
imagesetpixel($im,rand(2,$imageX-2),rand(2,$imageX-2),$pointcol);
}
//rotate
$middleground = imagecolorallocatealpha($im, rand(160, 200),
rand(160, 200), rand(160, 200), 80);
//random shapes
for ($x=0; $x<15;$x++)
{
if(mt_rand(0,$x)%2==0)
{
imageline($im, rand(0, 120), rand(0, 120), rand(0, 120), rand(0,
120), $middleground);
imageellipse($im, rand(0, 120), rand(0, 120), rand(0, 120), rand(0,
120), $middleground2);
}
else
{
imageline($im, rand(0, 120), rand(0, 120), rand(0, 120), rand(0,
120), $middleground2);
imageellipse($im, rand(0, 120), rand(0, 120), rand(0, 120), rand(0,
120), $middleground);
}
}
//output to browser
header("content-type:image/jpeg\r\n");
imagejpeg($im);
imagedestroy($im);
}
else
{
$files = glob(PHPCMS_ROOT.'/images/checkcode/*.jpg');
if(!is_array($files))
exit($LANG['please_check_dir_images_checkcode']);
$checkcodefile = $files[rand(0, count($files)-1)];
$_SESSION['checkcode'] = substr(basename($checkcodefile), 0,
4);
header("content-type:image/jpeg");
include $checkcodefile;
}
?>
php验证码打叉,phpcms 验证码显示为红叉叉的补丁源码!相关推荐
- C语言在二叉搜索树找到第k个最小元素(附完整源码)
C语言在二叉搜索树找到第k个最小元素 C语言在二叉搜索树找到第k个最小元素完整源码(定义,实现,main函数测试) C语言在二叉搜索树找到第k个最小元素完整源码(定义,实现,main函数测试) #in ...
- jetson nano 在opencv拉流的视频上显示中文汉字(含c++完整源码)
目录 问题 解决方案 步骤一:生成中文图片 步骤二:中文图片蒙皮到视频帧,形成中文显示效果 问题 在jetson nano这样的嵌入式设备上,用opencv拉流,并在实时视频上面,显示汉字. 关于使用 ...
- 仿酷狗音乐播放器开发日志二十三 修复Option控件显示状态不全的bug(附源码)...
转载请说明原出处,谢谢~~ 整个仿酷狗工程的开发将近尾声,现在还差选项设置窗体的部分,显然在设置窗体里用的最多的就是OptionUI控件,我在写好大致的布局后去测试效果,发现Option控件的显示效果 ...
- Flask+VUE 实现页面增删改查显示开发+测试(图文教程附源码)
目录 一.新建项目并初始化 二.安装依赖 axios.elementUI 三.Vue代码 四.进行接口联调 五.后端接口优化 六.web页面功能测试 七.总结 八.展望 九.附录(截止发文时的代码) ...
- Arduino控制1302颗ws2812灯珠显示圣诞树和圣诞老人(附程序源码)
Arduino控制1302颗ws2812灯珠显示圣诞树和圣诞老人 设计者:STCode(公众号同名) 效果直接看视频~ Arduino控制ws2812灯带显示圣诞树和圣诞老人 1)项目介绍 该设计一共 ...
- 通过SketchRNN、PCA和t-SNE从Google QuickDraw数据集中显示矢量图的潜在空间|附源码
首发地址:https://yq.aliyun.com/articles/98593 更多深度文章,请关注:https://yq.aliyun.com/cloud 本文是作者最近发布的Google Qu ...
- android 显示数学函数,MathView,在Android应用中,显示数学公式的库,下载MathView的源码_GitHub_开发99...
MathView MathView 是第三方视图库,它可以帮助你更轻松地在Android应用程序上显示数学公式. 两个渲染引擎可用:MathJax 和 KaTeX. 支持Android版本 4.1 ( ...
- 仿酷狗播放显示界面返回动画效果(附源码)
分类 奇技淫巧 的第一篇博文,以后会有更多奇技淫巧与大家分享~ 先看看酷狗的效果: [img]http://dl2.iteye.com/upload/attachment/0096/6694/1e91 ...
- 【Android SDM660源码分析】- 03 - UEFI XBL GraphicsOutput BMP图片显示流程
[Android SDM660源码分析]- 03 - UEFI XBL GraphicsOutput BMP图片显示流程 1. GraphicsOutput.h 2. 显示驱动初化 DisplayDx ...
最新文章
- 使用OpenCV和Python高效计算视频的总帧数
- 苹果 开发者账号区别
- php 未定义偏移,未定义的偏移PHP错误,尝试从文件读取
- Redis进阶-Redis对于过期键的三种清除策略
- php files上传错误,php-PHP上传文件的问题$_FILES['file']['error']
- 数据结构与算法:Python语言描述
- SAP CRM WebClient UI点了产品主数据搜索结果超链接后的跳转调试
- axure,购物车数量递增或递减
- wkhtmltopdf网页转PDF程序安装教程
- idea输出目录详解
- shell历史命令记录功能
- 远程桌面工具mRemoteNG与Tsmmc
- 文件转换base64流
- AAA和radius协议学习
- 武田收到CHMP同意ALUNBRIG® (brigatinib)用于ALK+非小细胞肺癌一线治疗的肯定意见
- java实现表白动图
- 短网址生成-nodejs实现
- matlab复合梯形法,matlab实现复合梯形法则
- 使用经典的基本播放命令和 MML 创建 MIDI 文件
- 佛祖保佑永无Bug—— 最好用的注释插件