专注于网站推广优化,承接营销型网站建设,整站优化外包,AI人工智能优化咨询QQ:20167856

帝国cms更换漂亮美观的图形验证码

SEO建站必备 2021-04-17

文章摘要:老威在SEO这一行做了快两年了,使用帝国cms大概一年半了,之前做的留言反馈都没加过验证码,容易被恶意留言,最近新做的一套网站要用到这个功能,觉得帝国cms的图形验证码有点扎眼,就顺...

  老威在SEO这一行做了快两年了,使用帝国cms大概一年半了,之前做的留言反馈都没加过验证码,容易被恶意留言,最近新做的一套网站要用到这个功能,觉得帝国cms的图形验证码有点扎眼,就顺手在重新写了下,外观比之前漂亮,同时使用弧线和直线,增强了干扰能力;双击图片可以不刷新页面更换验证码,默认的需要刷新页面。

  

  使用方法:

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

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

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

  4.(可选)设置完后,认证码图片会比input输入框高可以用下面代码替换 ,同时用onclick不刷新页面更换验证码,兼容帝国7.0、7.2以及7.5版本。

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

  源代码:

  修改为: (点击图片更换)

  代码下载:链接:https://pan.baidu.com/s/1xeU_LzSlk3CVuL9Fh41SCg 密码:nzv0

  贴出源代码供学习交流:

  

  require('http://www.lwseo.cn/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("http://www.lwseo.cn/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);

  ?>

预约SEO大佬

添加微信:bmzkj01 免费交流解答,并送你一份最新运营推广方案

上一篇:帝国cms面包屑导航中的首页两个字怎么更换?

下一篇:帝国CMS怎么随机调用栏目【SEO养站手法】