Merge pull request #514 from bbbboom/master

Fix PHP 8 Fatal error
pull/516/head
warlee 2022-12-06 14:26:19 +08:00 committed by GitHub
commit e43c97a0a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 4 deletions

View File

@ -30,12 +30,12 @@ class MyCaptcha{
for($i=0;$i<$fontfile_width && $symbol<$alphabet_length;$i++){ for($i=0;$i<$fontfile_width && $symbol<$alphabet_length;$i++){
$transparent = (imagecolorat($font, $i, 0) >> 24) == 127; $transparent = (imagecolorat($font, $i, 0) >> 24) == 127;
if(!$reading_symbol && !$transparent){ if(!$reading_symbol && !$transparent){
$font_metrics[$alphabet{$symbol}]=array('start'=>$i); $font_metrics[$alphabet[$symbol]]=array('start'=>$i);
$reading_symbol=true; $reading_symbol=true;
continue; continue;
} }
if($reading_symbol && $transparent){ if($reading_symbol && $transparent){
$font_metrics[$alphabet{$symbol}]['end']=$i; $font_metrics[$alphabet[$symbol]]['end']=$i;
$reading_symbol=false; $reading_symbol=false;
$symbol++; $symbol++;
continue; continue;
@ -51,7 +51,7 @@ class MyCaptcha{
$odd=mt_rand(0,1); $odd=mt_rand(0,1);
if($odd==0) $odd=-1; if($odd==0) $odd=-1;
for($i=0;$i<$length;$i++){ for($i=0;$i<$length;$i++){
$m=$font_metrics[$this->keystring{$i}]; $m=$font_metrics[$this->keystring[$i]];
$y=(($i%2)*$fluctuation_amplitude - $fluctuation_amplitude/2)*$odd $y=(($i%2)*$fluctuation_amplitude - $fluctuation_amplitude/2)*$odd
+ mt_rand(-round($fluctuation_amplitude/3), round($fluctuation_amplitude/3)) + mt_rand(-round($fluctuation_amplitude/3), round($fluctuation_amplitude/3))
@ -149,7 +149,7 @@ class MyCaptcha{
while(true){ while(true){
$str = ''; $str = '';
for($i=0;$i<$length;$i++){ for($i=0;$i<$length;$i++){
$str .= $allowed_symbols{mt_rand(0,strlen($allowed_symbols)-1)}; $str .= $allowed_symbols[mt_rand(0,strlen($allowed_symbols)-1)];
} }
if(!preg_match('/cp|cb|ck|c6|c9|rn|rm|mm|co|do|cl|db|qp|qb|dp|ww/',$str)) break; if(!preg_match('/cp|cb|ck|c6|c9|rn|rm|mm|co|do|cl|db|qp|qb|dp|ww/',$str)) break;
} }