PHP Warning: imagettftext(): Could not read font

Asked

Viewed 51 times

0

I have a somewhat old captcha system that started having problems.

Sometimes it works, other times the image is not generated and these errors occur:

[13-Sep-2019 23:48:05 America/Sao_Paulo] PHP Warning:  imagettftext(): Could not read font in /home/user/public_html/captchac_code.php on line 230
[13-Sep-2019 23:48:05 America/Sao_Paulo] PHP Warning:  imagettfbbox(): Could not read font in /home/user/public_html/captchac_code.php on line 71
[13-Sep-2019 23:48:03 America/Sao_Paulo] PHP Warning:  imagefilledrectangle() expects parameter 6 to be long, string given in /home/user/public_html/captchac_code.php on line 200

Below, I provide the file code:

Filing cabinet: captchac_config.php: https://pastebin.com/kck0FKY1

Filing cabinet: captchac_lib.php: https://pastebin.com/Hzd8R65R

Filing cabinet: captchac_code.php: https://pastebin.com/0wTgVkva

Any light? rsrs

1 answer

0


Take a look at the document captchac_config.php, line 44. Has information saying that if Cfontused = 1 (what is the case), the module will randomly choose a "source" in the folder defined in Cfonturl.

Then there’s Fontno = 34 indicating that this gives the number of "sources" of must have in the folder. So, if you have for example only 10 "fonts" in the folder, when randomly it will fetch the font number 5, it will work, but as he thinks (as in the value of Fontno) that has 34, he can fetch the font number 30 and in this case, it will not work.

So you should set up captchac_config.php as in the number of sources you have.

// 3. Fonts settings   
// The font used, can be 1 if random chosed from a fonts directory or 0 if specified
$CFontUsed = 1;
$CFontURL = 'home/'.get_current_user().'/public_html/fonts/font5.ttf';

// The number of fonts in the font directory
$FontNo = 34; 

Browser other questions tagged

You are not signed in. Login or sign up in order to post.