0
我有一個詞典詞的單詞表.txt格式。我怎樣才能用這個captcha_helper而不是隨機字符?我已經擴展了captcha_helper文件,但在集成我的wordlist.txt
文件以供使用時遇到問題。使用Codeigniter的詞彙表captcha
做一些戳後,我發現了一個解決方案:
// This is the modified version in captcha_helper.php
if($word == ''){
$wordsfile = '../words.php';
$fp = fopen($wordsfile, 'r');
$length = strlen(fgets($fp));
$line = rand(1, (filesize($wordsfile)/$length)-2);
if(fseek($fp, $length*$line) == -1) return FALSE;
$word = trim(fgets($fp));
fclose($fp);
}
但我注意到,有時最後一個字母會得到切斷。有沒有辦法確保第一封和最後一封信永遠不會放在邊界框之外?
在這種情況下,你可以使用一個功能,隨機傳遞你的話給腳本顯示
你可以展示你做了什麼,並解釋你遇到的問題? – 2012-03-02 20:41:34