欧美三区_成人在线免费观看视频_欧美极品少妇xxxxⅹ免费视频_a级毛片免费播放_鲁一鲁中文字幕久久_亚洲一级特黄

discuz中的uccenter中的驗證碼

系統(tǒng) 1720 0

花了一個上午的時間,終于提取出來了,效果演示:


discuz中的uccenter中的驗證碼
?下面是代碼:

    <?php
session_start();
class seccode {

    var $code ;			// 驗證碼
    var $type 	= 0;		// 只能是0
    var $width 	= 70;		// 圖像寬度
    var $height 	= 21;		// 圖像高度
    var $background	= 1;		// 1背景隨機(jī)變換,0不變換
    var $adulterate	= 1;		// 1有干擾線,0沒有干擾線
    var $ttf 	= 1;		// 只能是1
    var $angle 	= 0;		// 1角度隨機(jī)旋轉(zhuǎn) 0不旋轉(zhuǎn)
    var $color 	= 1;		// 1字體顏色隨機(jī) 0不隨機(jī)
    var $size 	= 0;		 // 1字體大小隨機(jī) 0不隨機(jī)
    var $shadow 	= 1;		// 1文字有陰影  0沒有陰影
    var $animator 	= 0;		//只能是0
    var $fontpath	= '';		// 字體路徑

    var $fontcolor;
    var $im;

    function display() {
        $this->code = $this->gencode();
       $_SESSION['vdc'] = $this->code;
        $this->width = $this->width >= 0 && $this->width <= 200 ? $this->width : 150;
        $this->height = $this->height >= 0 && $this->height <= 80 ? $this->height : 60;
        if($this->type < 2 && function_exists('imagecreate') && function_exists('imagecolorset') && function_exists('imagecopyresized') &&
            function_exists('imagecolorallocate') && function_exists('imagechar') && function_exists('imagecolorsforindex') &&
            function_exists('imageline') && function_exists('imagecreatefromstring') && (function_exists('imagegif') || function_exists('imagepng') || function_exists('imagejpeg'))) {
            $this->image();
        }
    }

    function gencode() {
        $arr=array('3','4','5','6','7','8','9','Q','W','E','R','T','Y','U','P','L','K','J','H','G','F','D','S','A','X','C','V','B','N','M');//聲明一個數(shù)組,中文驗證碼的來源
        $ss1=rand(0,29);
        $ss2=rand(0,29);
        $ss3=rand(0,29);
        $ss4=rand(0,29);
        $string=$arr[$ss1].$arr[$ss2].$arr[$ss3].$arr[$ss4];//根據(jù)隨機(jī)數(shù),輸出四個隨機(jī)數(shù)組元素,組成字符串
        return $string;
    }

    function fileext($filename) {
        return trim(substr(strrchr($filename, '.'), 1, 10));
    }

    function image() {
        $bgcontent = $this->background();
        $this->im = imagecreatefromstring($bgcontent);
        $this->adulterate && $this->adulterate();
        $this->ttf && function_exists('imagettftext') || $this->type == 1 ? $this->ttffont() : $this->giffont();

        if(function_exists('imagepng')) {
            header('Content-type: image/png');
            imagepng($this->im);
        } else {
            header('Content-type: image/jpeg');
            imagejpeg($this->im, '', 100);
        }
        imagedestroy($this->im);
    }

    function background() {
        $this->im = imagecreatetruecolor($this->width, $this->height);
        $backgroundcolor = imagecolorallocate($this->im, 255, 255, 255);
        $backgrounds = $c = array();
        if($this->background && function_exists('imagecreatefromjpeg') && function_exists('imagecolorat') &&	function_exists('imagecopymerge') &&
            function_exists('imagesetpixel') && function_exists('imageSX') && function_exists('imageSY')) {
            if($handle = @opendir($this->datapath.'background/')) {
                while($bgfile = @readdir($handle)) {
                    if(preg_match('/\.jpg$/i', $bgfile)) {
                        $backgrounds[] = $this->datapath.'background/'.$bgfile;
                    }
                }
                @closedir($handle);
            }
            if($backgrounds) {
                $imwm = imagecreatefromjpeg($backgrounds[array_rand($backgrounds)]);
                $colorindex = imagecolorat($imwm, 0, 0);
                $this->c = imagecolorsforindex($imwm, $colorindex);
                $colorindex = imagecolorat($imwm, 1, 0);
                imagesetpixel($imwm, 0, 0, $colorindex);
                $c[0] = $c['red'];$c[1] = $c['green'];$c[2] = $c['blue'];
                imagecopymerge($this->im, $imwm, 0, 0, mt_rand(0, 200 - $this->width), mt_rand(0, 80 - $this->height), imageSX($imwm), imageSY($imwm), 100);
                imagedestroy($imwm);
            }
        }
        if(!$this->background || !$backgrounds) {
            for($i = 0;$i < 3;$i++) {
                $start[$i] = mt_rand(200, 255);$end[$i] = mt_rand(100, 150);$step[$i] = ($end[$i] - $start[$i]) / $this->width;$c[$i] = $start[$i];
            }
            for($i = 0;$i < $this->width;$i++) {
                $color = imagecolorallocate($this->im, $c[0], $c[1], $c[2]);
                imageline($this->im, $i, 0, $i-(isset($angle) ? $angle : 0), $this->height, $color);
                $c[0] += $step[0];$c[1] += $step[1];$c[2] += $step[2];
            }
            $c[0] -= 20;$c[1] -= 20;$c[2] -= 20;
        }
        ob_start();
        if(function_exists('imagepng')) {
            imagepng($this->im);
        } else {
            imagejpeg($this->im, '', 100);
        }
        imagedestroy($this->im);
        $bgcontent = ob_get_contents();
        ob_end_clean();
        $this->fontcolor = $c;
        return $bgcontent;
    }

    function adulterate() {
        $linenums = $this->height / 10;
        for($i=0; $i <= $linenums; $i++) {
            $color = $this->color ? imagecolorallocate($this->im, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255)) : imagecolorallocate($this->im, $this->fontcolor[0], $this->fontcolor[1], $this->fontcolor[2]);
            $x = mt_rand(0, $this->width);
            $y = mt_rand(0, $this->height);
            if(mt_rand(0, 1)) {
                imagearc($this->im, $x, $y, mt_rand(0, $this->width), mt_rand(0, $this->height), mt_rand(0, 360), mt_rand(0, 360), $color);
            } else {
                $linemaxlong = isset($linemaxlong) ? $linemaxlong : 0;
                $linex = isset($linex) ? $linex : 0;
                $liney = isset($liney) ? $liney : 0;
                imageline($this->im, $x, $y, $linex + mt_rand(0, $linemaxlong), $liney + mt_rand(0, mt_rand($this->height, $this->width)), $color);
            }
        }
    }

    function ttffont() {
        $seccode = $this->code;
        $charset = isset($GLOBALS['charset']) ? $GLOBALS['charset'] : '';
        $seccoderoot = $this->fontpath;
        $dirs = opendir($seccoderoot);
        $seccodettf = array();
        while($entry = readdir($dirs)) {
            if($entry != '.' && $entry != '..' && in_array(strtolower($this->fileext($entry)), array('ttf', 'ttc'))) {
                $seccodettf[] = $entry;
            }
        }

        $seccodelength = 4;

        $widthtotal = 0;
        for($i = 0; $i < $seccodelength; $i++) {
            $font[$i]['font'] = $seccoderoot.$seccodettf[array_rand($seccodettf)];
            $font[$i]['angle'] = $this->angle ? mt_rand(-30, 30) : 0;
            $font[$i]['size'] = $this->type ? $this->width / 7 : $this->width / 6;
            $this->size && $font[$i]['size'] = mt_rand($font[$i]['size'] - $this->width / 40, $font[$i]['size'] + $this->width / 20);
            $box = imagettfbbox($font[$i]['size'], 0, $font[$i]['font'], $seccode[$i]);
            $font[$i]['zheight'] = max($box[1], $box[3]) - min($box[5], $box[7]);
            $box = imagettfbbox($font[$i]['size'], $font[$i]['angle'], $font[$i]['font'], $seccode[$i]);
            $font[$i]['height'] = max($box[1], $box[3]) - min($box[5], $box[7]);
            $font[$i]['hd'] = $font[$i]['height'] - $font[$i]['zheight'];
            $font[$i]['width'] = (max($box[2], $box[4]) - min($box[0], $box[6])) + mt_rand(0, $this->width / 8);
            $font[$i]['width'] = $font[$i]['width'] > $this->width / $seccodelength ? $this->width / $seccodelength : $font[$i]['width'];
            $widthtotal += $font[$i]['width'];
        }
        $x = mt_rand($font[0]['angle'] > 0 ? cos(deg2rad(90 - $font[0]['angle'])) * $font[0]['zheight'] : 1, $this->width - $widthtotal);
        !$this->color && $text_color = imagecolorallocate($this->im, $this->fontcolor[0], $this->fontcolor[1], $this->fontcolor[2]);
        for($i = 0; $i < $seccodelength; $i++) {
            if($this->color) {
                $this->fontcolor = array(mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
                $this->shadow && $text_shadowcolor = imagecolorallocate($this->im, 255 - $this->fontcolor[0], 255 - $this->fontcolor[1], 255 - $this->fontcolor[2]);
                $text_color = imagecolorallocate($this->im, $this->fontcolor[0], $this->fontcolor[1], $this->fontcolor[2]);
            } elseif($this->shadow) {
                $text_shadowcolor = imagecolorallocate($this->im, 255 - $this->fontcolor[0], 255 - $this->fontcolor[1], 255 - $this->fontcolor[2]);
            }
            $y = $font[0]['angle'] > 0 ? mt_rand($font[$i]['height'], $this->height) : mt_rand($font[$i]['height'] - $font[$i]['hd'], $this->height - $font[$i]['hd']);
            $this->shadow && imagettftext($this->im, $font[$i]['size'], $font[$i]['angle'], $x + 1, $y + 1, $text_shadowcolor, $font[$i]['font'], $seccode[$i]);
            imagettftext($this->im, $font[$i]['size'], $font[$i]['angle'], $x, $y, $text_color, $font[$i]['font'], $seccode[$i]);
            $x += $font[$i]['width'];
        }
    }
}

$code = new seccode();
$code->width = 80;  // 寬度
$code->height = 25;  // 高度
$code->background = 1;  // 1背景隨機(jī)變換,0不變換
$code->adulterate = 1;  // 1有干擾線,0沒有干擾線
$code->angle = 0;  // 1旋轉(zhuǎn) 0不旋轉(zhuǎn)
$code->color = 1;  // 1字體顏色隨機(jī) 0不隨機(jī)
$code->size = 1;   // 1字體大小隨機(jī) 0不隨機(jī)
$code->shadow = 1;  // 1文字有陰影  0沒有陰影
$code->fontpath = $_SERVER['DOCUMENT_ROOT'].'\\vdtest\\';  // 字體路徑
$code->display();
?>
  

?完全就是從discuz中復(fù)制出來的,然后把一些沒必要的代碼都刪除了的,本地預(yù)覽和在網(wǎng)上預(yù)覽的時候注意要更改那個字體路徑的就行,路徑中可以放多個ttf字體文件,這樣就能隨機(jī)字體也不同了。

?

在我要把我提取出來的整合到niunan.org上時,發(fā)現(xiàn)在本地預(yù)覽出錯,暈,后來查了下,原來不是驗證碼的問題,是我本機(jī)的WAMP升級了,本機(jī)現(xiàn)在是PHP5.3了,但是空間上的還是PHP5.2.9,在判斷是否有URL參數(shù)的時候我是寫

    if($_GET["caid])...
  

?但是在PHP5.3中這樣寫就報錯了,應(yīng)該寫成:

    if(!empty($_GET['caid']))....
  

唉。。還得找時間再改改哦。。。

discuz中的uccenter中的驗證碼


更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯(lián)系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機(jī)微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發(fā)表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 精品国产91乱码一区二区三区 | 天天草b | 奇米影音先锋 | 久草在线视频中文 | 久久久亚洲欧洲日产国码606 | 亚洲网站在线观看 | 成人无码髙潮喷水A片 | 欧美激情综合网 | av黄色在线观看 | 免费中文字幕视频 | 性夜a爽黄爽| 色偷偷888欧美精品久久久 | 日本视频一区在线观看免费 | 狠狠操在线观看 | 久久亚洲一区二区 | 久久大香香蕉国产免费网站 | 日韩卡1卡2 卡三卡2021老狼 | 十六以下岁女子毛片免费 | 日韩一区二区三区在线播放 | 日本高清精品 | 久久久久久国产精品免费免费 | 操久久 | 男进女内免费视频无遮挡 | 天天爱夜夜操 | 日韩精品一二三区 | 国内自拍第五一页 | 欧美日韩国产综合网 | 久久久人成影片一区二区三区 | 天天干电影 | 国产一区二区视频在线观看 | 日韩亚洲一区二区 | 欧美一区二区三区gg高清影视 | 欧美福利视频一区二区三区 | 久久久久国产一区二区三区 | 狠狠躁躁夜夜躁波多野结依 | 一级特黄欧美日韩免费视频 | 君岛美绪一区二区三区在线视频 | 欧美交性又色又爽又黄 | 九九线精品视频 | 精品一本久久中文字幕 | 欧美日韩一区二区三区在线观看 |