Add optional self-hosted ALTCHA protection and dependency maintenance
This commit is contained in:
1 parent
3b558409f3
commit
2a2f1d5878
59 files changed
+2648
-12
No files matched your search
+8
-5
@@ -2,18 +2,19 @@
|
||||
/**
|
||||
* Plugin Name: HG Contactformulier
|
||||
* Description: Configureerbaar contactformulier met workflows en talen vanuit de website, zonder inzendingen op te slaan.
|
||||
* Version: 1.2.0
|
||||
* Version: 1.3.0
|
||||
* Requires at least: 6.5
|
||||
* Requires PHP: 8.0
|
||||
* Requires PHP: 8.1
|
||||
* Text Domain: hg-contactform
|
||||
*/
|
||||
if (!defined('ABSPATH')) { exit; }
|
||||
define('HGCF_VERSION','1.2.0');
|
||||
define('HGCF_VERSION','1.3.0');
|
||||
define('HGCF_FILE',__FILE__);
|
||||
require_once __DIR__.'/includes/settings.php';
|
||||
require_once __DIR__.'/includes/language.php';
|
||||
require_once __DIR__.'/includes/form.php';
|
||||
add_action('template_redirect', function () {
|
||||
require_once __DIR__.'/includes/antispam.php';
|
||||
function hgcf_handle_submission() {
|
||||
if(($_SERVER['REQUEST_METHOD']??'')!=='POST' || ($_POST['mlhc_action']??'')!=='send') return;
|
||||
$id=get_queried_object_id(); $post=get_post($id);
|
||||
if(!is_singular() || !$post || (!has_shortcode($post->post_content,'hg_contactform') && !has_shortcode($post->post_content,'mlh_contact'))) wp_die('Invalid form page', '', ['response'=>403]);
|
||||
@@ -30,11 +31,13 @@ add_action('template_redirect', function () {
|
||||
$rate_key='mlhc_rate_'.hash_hmac('sha256',$ip,wp_salt('auth'));
|
||||
$rate=get_transient($rate_key);
|
||||
if($rate && ($rate['count']>=5 || time()-$rate['last']<30)) { $GLOBALS['mlhc_errors']=new WP_Error('rate',hgcf_text('Even geduld: probeer het over een minuut opnieuw of gebruik een andere contactmogelijkheid.','Please wait a minute before trying again, or use another contact option.',$lang)); return; }
|
||||
if(hgcf_altcha_enabled()&&!hgcf_verify_altcha(wp_unslash($_POST['mlhc_altcha']??''),$id)) { $GLOBALS['mlhc_errors']=new WP_Error('altcha',hgcf_text('De antispamcontrole is niet gelukt of verlopen. Probeer de controle opnieuw.','The spam protection check failed or expired. Please verify again.',$lang)); return; }
|
||||
$rate=$rate?:['count'=>0,'last'=>0]; $rate['count']++;$rate['last']=time();set_transient($rate_key,$rate,15*MINUTE_IN_SECONDS);
|
||||
if(!hgcf_send($data,$lang)) { $GLOBALS['mlhc_errors']=new WP_Error('mail',$error); return; }
|
||||
$url=add_query_arg(['contact_status'=>'received','receipt'=>wp_create_nonce('mlhc_received_'.$id)],get_permalink($id));
|
||||
wp_safe_redirect($url.'#contact-form',303);exit;
|
||||
});
|
||||
}
|
||||
add_action('template_redirect','hgcf_handle_submission');
|
||||
add_shortcode('hg_contactform','hgcf_render');
|
||||
add_shortcode('mlh_contact','hgcf_render');
|
||||
add_action('wp_enqueue_scripts',function(){
|
||||
|
||||
Reference in new issue
Block a user