Fix PHP 8 Fatal error
Fix PHP Fatal error: Array and string offset access syntax with curly braces is no longer supportedpull/514/head
parent
1f7072c0e1
commit
4acd4d8aa0
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue