Files
wp-multi/includes/disposable-email.php
2026-08-14 07:59:43 +00:00

45 lines
1.3 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
/**
* WP Multi Modul: Sperre Trash-Mail-Adressen
*
* Automatisch aus wp-multi.php ausgelagert. Wird über den Loader in
* wp-multi.php eingebunden (nur wenn das WP Multi Toolkit aktiv ist).
*/
if (!defined('ABSPATH')) { exit; }
/*
* Sperre Trash Mail Adressen
*/
// Funktion zum Laden der Liste von Einweg-Mail-Anbietern
function load_disposable_email_list() {
$file_path = plugin_dir_path(WP_MULTI_FILE) . 'includes/disposable_email_blocklist.conf'; // Pfad zur Datei im includes-Ordner
if (file_exists($file_path)) {
return file($file_path, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
}
return [];
}
// Funktion zum Überprüfen der E-Mail-Adresse eines Kommentators
function check_disposable_email($commentdata) {
$disposable_list = load_disposable_email_list();
$email = $commentdata['comment_author_email'];
$domain = substr(strrchr($email, "@"), 1); // Nur die Domain extrahieren
// Überprüfen, ob die Domain auf der Liste steht
if (in_array($domain, $disposable_list)) {
wp_die(__('Fehler: Trash-Mail-Adressen sind in Kommentaren nicht erlaubt.'));
}
return $commentdata;
}
// Die Funktion wird beim Absenden eines Kommentars ausgeführt
add_filter('preprocess_comment', 'check_disposable_email');