Add optional self-hosted ALTCHA protection and dependency maintenance

This commit is contained in:
parkel committed 2026-10-12 14:10:08 +02:00
1 parent 3b558409f3
commit 2a2f1d5878
59 files changed
+2648 -12

No files matched your search

+5 -1
View File
@@ -1,7 +1,7 @@
<?php
if (!defined('ABSPATH')) exit;
function hgcf_defaults() {
return ['recipient'=>get_option('admin_email'),'site_name'=>get_bloginfo('name'),'contact_name'=>'','sender_email'=>'','sender_name'=>'',
return ['recipient'=>get_option('admin_email'),'site_name'=>get_bloginfo('name'),'contact_name'=>'','sender_email'=>'','sender_name'=>'','altcha_enabled'=>false,
'title_nl'=>'Waarmee kunnen we je helpen?','title_en'=>'How can we help?',
'consent_nl'=>'Mijn gegevens mogen worden gebruikt om op dit bericht te reageren.','consent_en'=>'My details may be used to reply to this message.',
'note_nl'=>'Je bericht wordt per e-mail verstuurd en niet op deze website opgeslagen. Deel hier geen medische of andere gevoelige gegevens.','note_en'=>'Your message is sent by email and is not stored on this website. Please do not include medical or other sensitive details.',
@@ -86,6 +86,10 @@ function hgcf_sanitize_settings($input) {
$old=hgcf_settings();if(!is_array($input))return $old;
if(($_POST['option_page']??'')==='hgcf'&&($input['_complete']??'')!=='1'){add_settings_error('hgcf_settings','incomplete','Niet alle velden zijn ontvangen. Je instellingen zijn niet gewijzigd.');return $old;}
$out=$old;
if(array_key_exists('altcha_enabled',$input)) {
if(in_array($input['altcha_enabled'],['0','1'],true))$out['altcha_enabled']=$input['altcha_enabled']==='1';
else add_settings_error('hgcf_settings','altcha_enabled','Controleer de antispaminstelling.');
}
foreach(['recipient'=>false,'sender_email'=>true] as $key=>$empty){if(array_key_exists($key,$input)){if(hgcf_valid_email($input[$key],$empty))$out[$key]=$input[$key]===''?'':sanitize_email($input[$key]);else add_settings_error('hgcf_settings',$key,'Controleer het e-mailadres.');}}
foreach(['sender_name','site_name','contact_name'] as $key)if(array_key_exists($key,$input)) {
$value=$input[$key];if(is_string($value)&&strlen($value)<=150&&!preg_match('/[\r\n]/',$value)&&($key!=='site_name'||trim($value)!==''))$out[$key]=sanitize_text_field($value);else add_settings_error('hgcf_settings',$key,'Controleer de naam.');