織夢dedecms不顯示驗證碼,完美解決方法
1,不顯示背景不顯示字符
打開www/include/vdimgck.php
找到下面代碼,大約25行處
if ( !is_dir($sessSavePath) ) mkdir($sessSavePath);
在它上面加入下面代碼
ob_end_clean();
用來清空(擦除)緩沖區并關閉輸出緩沖
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()函數沒有成功的執行,所以驗證碼只顯示背景不顯示字母,原因是字體文件路徑錯誤。
解決方法
1、確認include/data/fonts/ 里面存在字體文件,默認為ggbi.ttf。
2、在for($i=0;$i<$rndcodelen;$i++) 上一行加上如下代碼:
$font_file= str_replace("//","/",$font_file);
即把字體文件路徑中反斜杠替換成斜杠,反斜杠有轉譯字符的功能,$font_file路徑大體為盤符:/appserv/www 系統錯誤的把反斜杠當作轉義用了,導致$font_file不是一個路徑,所以Imagettftext()函數總是返回錯誤。
加上$font_file= str_replace("//","/",$font_file);即可解決。
3,文件丟失
include/data/words/words.txt 文件不存在。
解決方法:
1 拷貝一個進去
2找到代碼
'word_type' => (int)$safe_codetype, // 1:數字 2:英文 3:單詞
換成'word_type' =>1, (或2) 既驗證碼為數字或英文
新聞熱點
疑難解答