Fix captcha bug caused by different decimal point in some environments

This commit is contained in:
Juribiyan 2018-07-11 22:03:18 +05:00
parent 802837959a
commit 0f855daa71
1 changed files with 2 additions and 2 deletions

View File

@ -158,10 +158,10 @@ function generate_code($length = 7) {
foreach($charset as $char) { foreach($charset as $char) {
$balanced = $freqs[$char] / $sum; $balanced = $freqs[$char] / $sum;
$bsum += $balanced; $bsum += $balanced;
$xfq[(string)$bsum] = $char; $xfq[$char] = $bsum;
} }
$roll = frand(); $roll = frand();
foreach($xfq as $freq => $letter) { foreach($xfq as $letter => $freq) {
if($roll < $freq) { if($roll < $freq) {
$result[$i] = $letter; $result[$i] = $letter;
$roll = 2; $roll = 2;