亚洲第一区香蕉_国产a,国产成人精品免费视频网页大全,www.久久草,成人免费性视频

當前位置:首頁 > 網站建設 > 正文內容

帝國cms更換漂亮美觀的圖形驗證碼

小熊8年前 (2018-03-30)網站建設6960

老威在SEO這一行做了快兩年了,使用帝國cms大概一年半了,之前做的留言反饋都沒加過驗證碼,容易被惡意留言,最近新做的一套網站要用到這個功能,覺得帝國cms的圖形驗證碼有點扎眼,就順手在重新寫了下,外觀比之前漂亮,同時使用弧線和直線,增強了干擾能力;雙擊圖片可以不刷新頁面更換驗證碼,默認的需要刷新頁面。

帝國cms更換美觀的圖形驗證碼

使用方法:

1.將e文件直接復制到網站根目錄;

2.開啟 網站后臺->系統參數->用戶設置->會員登陸驗證碼和會員注冊驗證碼;

3.不要設置 網站后臺->系統參數->基本屬性->驗證碼配色 保持最初默認值即可;

4.(可選)設置完后,認證碼圖片會比input輸入框高可以用下面代碼替換 ,同時用onclick不刷新頁面更換驗證碼,兼容帝國7.0、7.2以及7.5版本。

模版->動態頁面模版管理->會員登錄頁面

源代碼:<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>

代碼下載:鏈接:https://pan.baidu.com/s/1xeU_LzSlk3CVuL9Fh41SCg 密碼:nzv0

貼出源代碼供學習交流:

<?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);
?>


掃描二維碼推送至手機訪問。

版權聲明:本文由小熊SEO發布,如需轉載請注明出處。

本文鏈接:http://www.zhihuishangjia.com/wzjs/72.html

分享給朋友:

相關文章

帝國cms使用靈動標簽調用當前欄目實現高亮的方法

帝國cms使用靈動標簽調用當前欄目實現高亮的方法

這幾天老威又開始做帝國的站,之前都是簡簡單單的弄個欄目導航就完事了,現在看起來真是不太雅觀,找了三種實現當前欄目高亮的方法,記錄下來也供大家參考。方法1.<ul class="...

帝國cms列表頁分頁樣式美化

帝國cms列表頁分頁樣式美化

跟上一篇講過的一樣,帝國自帶的分頁樣式太過于丑,所以老威又找到了幾種修改樣式的方法,本文持續更新·····這是之前的分頁樣式我們首先進入帝國后臺,點擊系統設置->系統參數設置->信息設置,...

帝國cms列表頁怎么調用關鍵字tag標簽

帝國cms列表頁怎么調用關鍵字tag標簽

有很多朋友都在問帝國cms列表頁怎么調用關鍵字tag,tag作為內鏈手法,對于SEO有一定的好處,下面老威就實例講述一下帝國cms列表頁面調用關鍵字tag標簽的方法,分享給大家參考。具體實現方法如下:...

帝國cms如何修改搜索提示頁面?

帝國cms如何修改搜索提示頁面?

喜歡帝國cms的一定會被某些樣式所困擾,感覺不是很美觀,搜索功能是大家常用的功能之一,帝國cms的搜索提示頁面給人一種說不出來的感覺,如下圖所示今天老威SEO博客分享一下修改搜索提示頁面樣式跟文字的方...

帝國cms欄目頁隨機調用當前欄目內容

帝國cms欄目頁隨機調用當前欄目內容

老威做SEO教程也有段時間了,這期間也接觸了大大小小的各種cms,其中還是帝國cms跟dedecms最深得我意,要是玩windows+iis環境的話,aspcms也是個很好的選擇。在用帝國cms做站的...

帝國cms怎么對接熊掌號教程

帝國cms怎么對接熊掌號教程

隨著熊掌號越來越火,不少站長都加入了這一陣營,下面老威給大家說一下帝國cms怎么對接熊掌號教程吧!1.首先加入canonical標簽<link rel="canonical&...

發表評論

訪客

◎歡迎參與討論,請在這里發表您的看法和觀點。