web建站教程
  1. 首页
  2. vuejs
  3. js
  4. 好玩
  5. seo教程
  6. 前端知识
  7. 百度echarts
  8. 更多
    php入门
    nodejs
    mockjs
    reactjs
    mysql
    wordpress
    织梦cms
    帝国cms
    git教程
    IT知识
    模板大全
    休息站

漂亮帝国cms图形验证码 模板二次开发

340 ℃
     

使用帝国cms有段时间了,总觉得帝国cms的图形验证码有点扎眼,就顺手在重新写了下

功能

1.外观更漂亮,同时使用弧线和直线,增强了干扰能力;

2.双击图片可以不刷新页面更换验证码,默认的需要刷新页面;

使用方法:

1.将e文件直接复制到网站根目录;

2.开启 网站后台->系统参数->用户设置->会员登陆验证码和会员注册验证码;

3.不要设置 网站后台->系统参数->基本属性->验证码配色 保持最初默认值即可;

4.(可选)设置完后,认证码图片会比input输入框高可以用下面代码替换 ,同时用onclick不刷新页面更换验证码,以帝国cms7.0 用户登陆为例修改

模版->动态页面模版管理->会员登录页面

源代码:<img src="../../ShowKey/?v=login"/>

修改为:<img src="../../ShowKey/?v=login" onclick="javascript:this.src='../../ShowKey/?v=login&tm=+Math.random();'" style="vertical-align:middle"/> <span style="color:#666;vertical-align:bottom"> (点击图片更换)</span>

代码下载:见帖子底部

========================================================================================================

贴出源代码供学习交流:

<?php

require('../class/connect.php');

//取得随机数

function domake_password($pw_length){

global $public_r;

if($public_r['keytog']==1)//字母

{

$low_ascii_bound=65;

$upper_ascii_bound=90;

$notuse=array(91);

}

elseif($public_r['keytog']==2)//数字+字母

{

$low_ascii_bound=50;

$upper_ascii_bound=90;

$notuse=array(58,59,60,61,62,63,64,73,79);

}

else//数字

{

$low_ascii_bound=48;

$upper_ascii_bound=57;

$notuse=array(58);

}

while($i<$pw_length)

{

mt_srand((double)microtime()*1000000);

$randnum=mt_rand($low_ascii_bound,$upper_ascii_bound);

if(!in_array($randnum,$notuse))

{

$password1=$password1.chr($randnum);

$i++;

}

}

return $password1;

}

//返回颜色

function ReturnShowKeyColor($img){

global $public_r;

//背景色

if($public_r['keybgcolor'])

{

$bgcr=ToReturnRGB($public_r['keybgcolor']);

$r['bgcolor']=imagecolorallocate($img,$bgcr[0],$bgcr[1],$bgcr[2]);

}

else

{

$r['bgcolor']=imagecolorallocate($img,245,rand(225,255),225);

}

//文字色

if($public_r['keyfontcolor'])

{

$fcr=ToReturnRGB($public_r['keyfontcolor']);

$r['fontcolor']=ImageColorAllocate($img,$fcr[0],$fcr[1],$fcr[2]);

}

else

{

$r['fontcolor']=ImageColorAllocate($img,mt_rand(0,156),mt_rand(0,156),mt_rand(0,156));

}

//干扰色

if($public_r['keydistcolor'])

{

$dcr=ToReturnRGB($public_r['keydistcolor']);

$r['distcolor']=ImageColorAllocate($img,$dcr[0],$dcr[1],$dcr[2]);

}

else

{

$r['distcolor']=ImageColorAllocate($img,mt_rand(0,255),mt_rand(0,255),mt_rand(0,255));

}

return $r;

}

//显示验证码

function ShowKey($v){

$vname=ecmsReturnKeyVarname($v);

$key=strtolower(domake_password(4));

ecmsSetShowKey($vname,$key);

//是否支持gd库

if (function_exists("imagegif"))

{

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

$img=imagecreate(80,26);

$colorr=ReturnShowKeyColor($img);

$bgcolor=$colorr['bgcolor'];

$fontcolor=$colorr['fontcolor'];

$distcolor=$colorr['distcolor'];

imagefill($img,0,0,$bgcolor);

 

for($i=0;$i<90;$i++) //加入干扰象素

{

imagesetpixel($img,rand()%70,rand()%30,$distcolor);

}

for($i=0;$i<8;$i++){//加入干扰弧线

imagearc ($img,rand(0,360),rand(0,360),rand(200,350),rand(200,360),10,10,imagecolorallocate($img, rand(0,225), rand(0,225),rand(0,225)));

}

for($i=0;$i<4;$i++){//加入干扰直线

imageline ($img,rand(0,2),rand(0,27),rand(80,80),rand(1,28),imagecolorallocate($img, mt_rand(0,156),mt_rand(0,156),mt_rand(0,156)));

}

for($i=0;$i<4;$i++){

$charcolor=imagecolorallocate($img, mt_rand(0,156),mt_rand(0,156),mt_rand(0,156));

imagettftext ($img,rand(12,16),rand(-30,30),$i*20+2,rand(16,22),$charcolor,"STENCIL.TTF",$key[$i]);

}

imagegif($img);

imagedestroy($img);

}

elseif(function_exists("imagejpeg"))

{

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

$img=imagecreate(80,26);

$colorr=ReturnShowKeyColor($img);

$bgcolor=$colorr['bgcolor'];

$fontcolor=$colorr['fontcolor'];

$distcolor=$colorr['distcolor'];

imagefill($img,0,0,$bgcolor);

 

for($i=0;$i<90;$i++) //加入干扰象素

{

imagesetpixel($img,rand()%70,rand()%30,$distcolor);

}

for($i=0;$i<8;$i++){//加入干扰弧线

imagearc ($img,rand(0,360),rand(0,360),rand(200,350),rand(200,360),10,10,imagecolorallocate($img, rand(0,225), rand(0,225),rand(0,225)));

}

for($i=0;$i<4;$i++){//加入干扰直线

imageline ($img,rand(0,2),rand(0,27),rand(80,80),rand(1,28),imagecolorallocate($img, mt_rand(0,156),mt_rand(0,156),mt_rand(0,156)));

}

for($i=0;$i<4;$i++){

$charcolor=imagecolorallocate($img, mt_rand(0,156),mt_rand(0,156),mt_rand(0,156));

imagettftext ($img,rand(12,16),rand(-30,30),$i*20+2,rand(16,22),$charcolor,"STENCIL.TTF",$key[$i]);

}

imagejpeg($img);

imagedestroy($img);

}

elseif (function_exists("imagepng"))

{

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

$img=imagecreate(80,26);

$colorr=ReturnShowKeyColor($img);

$bgcolor=$colorr['bgcolor'];

$fontcolor=$colorr['fontcolor'];

$distcolor=$colorr['distcolor'];

imagefill($img,0,0,$bgcolor);

 

for($i=0;$i<90;$i++) //加入干扰象素

{

imagesetpixel($img,rand()%70,rand()%30,$distcolor);

}

for($i=0;$i<8;$i++){//加入干扰弧线

imagearc ($img,rand(0,360),rand(0,360),rand(200,350),rand(200,360),10,10,imagecolorallocate($img, rand(0,225), rand(0,225),rand(0,225)));

}

for($i=0;$i<4;$i++){//加入干扰直线

imageline ($img,rand(0,2),rand(0,27),rand(80,80),rand(1,28),imagecolorallocate($img, mt_rand(0,156),mt_rand(0,156),mt_rand(0,156)));

}

for($i=0;$i<4;$i++){

$charcolor=imagecolorallocate($img, mt_rand(0,156),mt_rand(0,156),mt_rand(0,156));

imagettftext ($img,rand(12,16),rand(-30,30),$i*20+2,rand(16,22),$charcolor,"STENCIL.TTF",$key[$i]);

}

imagepng($img);

imagedestroy($img);

}

 

elseif (function_exists("imagewbmp"))

{

header ("Content-type: image/vnd.wap.wbmp");

$img=imagecreate(80,26);

$colorr=ReturnShowKeyColor($img);

$bgcolor=$colorr['bgcolor'];

$fontcolor=$colorr['fontcolor'];

$distcolor=$colorr['distcolor'];

imagefill($img,0,0,$bgcolor);

 

for($i=0;$i<90;$i++) //加入干扰象素

{

imagesetpixel($img,rand()%70,rand()%30,$distcolor);

}

for($i=0;$i<8;$i++){//加入干扰弧线

imagearc ($img,rand(0,360),rand(0,360),rand(200,350),rand(200,360),10,10,imagecolorallocate($img, rand(0,225), rand(0,225),rand(0,225)));

}

for($i=0;$i<4;$i++){//加入干扰直线

imageline ($img,rand(0,2),rand(0,27),rand(80,80),rand(1,28),imagecolorallocate($img, mt_rand(0,156),mt_rand(0,156),mt_rand(0,156)));

}

for($i=0;$i<4;$i++){

$charcolor=imagecolorallocate($img, mt_rand(0,156),mt_rand(0,156),mt_rand(0,156));

imagettftext ($img,rand(12,16),rand(-30,30),$i*20+2,rand(16,22),$charcolor,"STENCIL.TTF",$key[$i]);

}

imagewbmp($img);

imagedestroy($img);

}

else

{

ecmsSetShowKey($vname,'ecms');

echo ReadFiletext("../data/images/ecms.gif");

}

}

//返回变量名

function ecmsReturnKeyVarname($v){

if($v=='login')//登陆

{

$name='checkloginkey';

}

elseif($v=='reg')//注册

{

$name='checkregkey';

}

elseif($v=='info')//信息

{

$name='checkinfokey';

}

elseif($v=='spacefb')//空间反馈

{

$name='checkspacefbkey';

}

elseif($v=='spacegb')//空间留言

{

$name='checkspacegbkey';

}

elseif($v=='gbook')//留言

{

$name='checkgbookkey';

}

elseif($v=='feedback')//反馈

{

$name='checkfeedbackkey';

}

elseif($v=='getpassword')//取回密码

{

$name='checkgetpasskey';

}

elseif($v=='regsend')//重发激活邮件

{

$name='checkregsendkey';

}

else//评论pl

{

$name='checkplkey';

}

return $name;

}

$v=$_GET['v'];

ShowKey($v);

?>

帝国CMS如何获取目录定位(具体操作代码)

帝国cms技巧之内容页的smalltext字数控制方法

帝国cms功能之如何在会员空间调用会员栏目投稿

帝国cms发布文章后直接提交百度(主动推送代码

帝国cms防止黑客入侵,哪些文件可以删掉

标签: 帝国cms

上面是“漂亮帝国cms图形验证码 模板二次开发”的全面内容,想了解更多关于 帝国cms 内容,请继续关注web建站教程。

当前网址:https://ipkd.cn/webs_1393.html

声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

当前位置: 网站首页 > 帝国cms
本文共计6713个字,预计阅读时长45分钟
生活小工具,收录了80多款小工具
上一篇: 程序员正能量文案:乐观积极的治愈系文案,朋友圈满满向上动力句子
下一篇: Lunar组件如何利用I18n实现多语言功能
x 打工人ai神器