織夢(mèng)dedecms不顯示驗(yàn)證碼,完美解決方法
1,不顯示背景不顯示字符
打開www/include/vdimgck.php
找到下面代碼,大約25行處
if ( !is_dir($sessSavePath) ) mkdir($sessSavePath);
在它上面加入下面代碼
ob_end_clean();
用來(lái)清空(擦除)緩沖區(qū)并關(guān)閉輸出緩沖
2,只顯示背景不顯示字符
打開www/include/vdimgck.php
找到下面代碼,大約126行左右
for($i=0;$i<$rndcodelen;$i++) { $bc = mt_rand(0, 1); $rndstring[$i] = strtoupper($rndstring[$i]); $c_fontColor = $fontColor[mt_rand(0,4)]; $y_pos = $i==0 ? 4 : $i*($font_size+2); $c = mt_rand(0, 15); @imagettftext($im, $font_size, $c, $y_pos, 19, $c_fontColor, $font_file, $rndstring[$i]); $lastc = $rndstring[$i];} |
原因是Imagettftext()函數(shù)沒(méi)有成功的執(zhí)行,所以驗(yàn)證碼只顯示背景不顯示字母,原因是字體文件路徑錯(cuò)誤。
解決方法
1、確認(rèn)include/data/fonts/ 里面存在字體文件,默認(rèn)為ggbi.ttf。
2、在for($i=0;$i<$rndcodelen;$i++) 上一行加上如下代碼:
$font_file= str_replace("//","/",$font_file);
即把字體文件路徑中反斜杠替換成斜杠,反斜杠有轉(zhuǎn)譯字符的功能,$font_file路徑大體為盤符:/appserv/www 系統(tǒng)錯(cuò)誤的把反斜杠當(dāng)作轉(zhuǎn)義用了,導(dǎo)致$font_file不是一個(gè)路徑,所以Imagettftext()函數(shù)總是返回錯(cuò)誤。
加上$font_file= str_replace("//","/",$font_file);即可解決。
3,文件丟失
include/data/words/words.txt 文件不存在。
解決方法:
1 拷貝一個(gè)進(jìn)去
2找到代碼
'word_type' => (int)$safe_codetype, // 1:數(shù)字 2:英文 3:單詞
換成'word_type' =>1, (或2) 既驗(yàn)證碼為數(shù)字或英文
新聞熱點(diǎn)
疑難解答
圖片精選