Fix PHP 8 Fatal error

Fix PHP Fatal error:  Array and string offset access syntax with curly braces is no longer supported
pull/514/head
bbbboom 2022-11-29 21:34:35 +08:00 committed by GitHub
parent 1f7072c0e1
commit 4acd4d8aa0
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++){
$transparent = (imagecolorat($font, $i, 0) >> 24) == 127;
if(!$reading_symbol && !$transparent){
$font_metrics[$alphabet{$symbol}]=array('start'=>$i);
$font_metrics[$alphabet[$symbol]]=array('start'=>$i);
$reading_symbol=true;
continue;
}
if($reading_symbol && $transparent){
$font_metrics[$alphabet{$symbol}]['end']=$i;
$font_metrics[$alphabet[$symbol]]['end']=$i;
$reading_symbol=false;
$symbol++;
continue;
@ -51,7 +51,7 @@ class MyCaptcha{
$odd=mt_rand(0,1);
if($odd==0) $odd=-1;
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
+ mt_rand(-round($fluctuation_amplitude/3), round($fluctuation_amplitude/3))
@ -149,7 +149,7 @@ class MyCaptcha{
while(true){
$str = '';
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;
}