diff --git a/chat.php b/chat.php
index 1c9b72d..5cd29f5 100644
--- a/chat.php
+++ b/chat.php
@@ -362,6 +362,7 @@ function route_setup(): void
$C['text_settings']=[
'dateformat' => _('Date formating'),
'captchachars' => _('Characters used in Captcha'),
+ 'captchattfont' => _('Font name or path and filename for TrueType font used in some captchas'),
'redirect' => _('Custom redirection script'),
'chatname' => _('Chat name'),
'mailsender' => _('Send mail using this address'),
@@ -648,6 +649,11 @@ function send_captcha(): void
if($difficulty===0 || !extension_loaded('gd')){
return;
}
+ if(function_exists('putenv')) {
+ // from https://www.php.net/manual/en/function.imagefttext.php
+ // enables fonts to be loaded from the directory the script is in
+ putenv('GDFONTPATH=' . realpath('.'));
+ }
$captchachars=get_setting('captchachars');
$length=strlen($captchachars)-1;
$code='';
@@ -662,7 +668,14 @@ function send_captcha(): void
$stmt=$db->prepare('INSERT INTO ' . PREFIX . 'captcha (id, time, code) VALUES (?, ?, ?);');
$stmt->execute([$randid, $time, $code]);
}
- echo '
'._('Copy:').' ';
+ echo '
';
+ if ($difficulty===4) {
+ echo _('Type the characters connected by dotted lines:');
+ } elseif ($difficulty===7 || $difficulty===8) {
+ echo _('Type the five largest characters:');
+ } else {
+ echo _('Type the characters in the image:');
+ }
if($difficulty===1){
$im=imagecreatetruecolor(55, 24);
$bg=imagecolorallocate($im, 0, 0, 0);
@@ -685,7 +698,7 @@ function send_captcha(): void
imagesetpixel($im, mt_rand(0, 55), mt_rand(0, 24), $dots);
}
echo '';
- echo '
'.hidden('challenge', $randid).'
';
+ echo '
'.hidden('challenge', $randid).'
';
}
function send_setup(array $C): void
@@ -912,12 +1060,12 @@ function send_setup(array $C): void
if($captcha===1){
echo ' selected';
}
- echo '>'._('Simple').'';
+ echo '>'._('Simple (deprecated)').'';
echo '';
+ echo '>'._('Moderate (deprecated)').'';
echo '';
+ echo '';
+ echo '';
+ echo '';
+ echo '';
echo '';
}
echo '';
@@ -4256,6 +4424,7 @@ function init_chat(): void
['messageexpire', '14400'],
['messagelimit', '150'],
['maxmessage', 2000],
+ ['captchattfont', '/usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf'],
['captchatime', '600'],
['colbg', '000000'],
['coltxt', 'FFFFFF'],
@@ -4707,6 +4876,9 @@ function update_db(): void
$db->exec('INSERT INTO ' . PREFIX . "settings (setting, value) VALUES ('exitwait', '180'), ('exitingtxt', ' 🚪"); // door emoji
$db->exec('ALTER TABLE ' . PREFIX . 'sessions ADD COLUMN exiting smallint NOT NULL DEFAULT 0;');
}
+ if($dbversion<49){
+ $db->exec('INSERT INTO ' . PREFIX . "settings (setting, value) VALUES ('captchattfont', '/usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf');");
+ }
update_setting('dbversion', DBVERSION);
if($msgencrypted!==MSGENCRYPTED){
if(!extension_loaded('sodium')){
@@ -4909,7 +5081,7 @@ function load_lang(): void
function load_config(): void
{
define('VERSION', '1.24.1'); // Script version
- define('DBVERSION', 48); // Database layout version
+ define('DBVERSION', 49); // Database layout version
define('MSGENCRYPTED', false); // Store messages encrypted in the database to prevent other database users from reading them - true/false - visit the setup page after editing!
define('ENCRYPTKEY_PASS', 'MY_SECRET_KEY'); // Recommended length: 32. Encryption key for messages
define('AES_IV_PASS', '012345678912'); // Recommended length: 12. AES Encryption IV