diff --git a/wp-multi.php b/wp-multi.php
index ae67362..752f831 100644
--- a/wp-multi.php
+++ b/wp-multi.php
@@ -3,7 +3,7 @@
* Plugin Name: WP Multi
* Plugin URI: https://git.viper.ipv64.net/M_Viper/wp-multi
* Description: Erweiterter Anti-Spam-Schutz mit Honeypot, Keyword-Filter, Link-Limit und mehr. Jetzt mit Statistik im Dashboard und HappyForms-Integration.
- * Version: 3.2
+ * Version: 3.4
* Author: M_Viper
* Author URI: https://m-viper.de
* Requires at least: 6.7.2
@@ -21,6 +21,7 @@ if (!defined('ABSPATH')) {
exit;
}
+
// Funktion zur Überprüfung des WP Multi Toolkit Plugins
function wp_multi_check_dependency() {
if (!function_exists('is_plugin_active')) {
@@ -2007,266 +2008,20 @@ function wp_multi_add_analytics_page() {
add_action('admin_menu', 'wp_multi_add_analytics_page');
-/*
- * Verbesserter Kommentar-Filter mit reduzierter Blockierung harmloser Wörter
- */
-define('WP_MULTI_FILTER_OPTION_PREFIX', 'wp_multi_filter_');
-define('WP_MULTI_SWEAR_WORDS_CACHE_KEY', 'wp_multi_swear_words');
-define('WP_MULTI_BAD_WORDS_URL', 'https://git.viper.ipv64.net/M_Viper/wp-multi/raw/branch/main/includes/bad-words.json');
-/**
- * Registriert die Admin-Einstellungen für den Kommentar-Filter.
- */
-function wp_multi_register_comment_filter_settings() {
- $options = [
- 'phone' => '1',
- 'email' => '1',
- 'url' => '1',
- 'swear' => '1',
- 'ip' => '1',
- 'allowed_urls' => '',
- 'allowed_words' => '', // Neue Option für erlaubte Wörter
- 'filter_strength' => 'moderate', // Neue Option für Filterstärke
- ];
- foreach ($options as $key => $default) {
- add_option(WP_MULTI_FILTER_OPTION_PREFIX . $key, $default);
- register_setting('wp_multi_filter_options_group', WP_MULTI_FILTER_OPTION_PREFIX . $key, [
- 'sanitize_callback' => $key === 'allowed_urls' || $key === 'allowed_words' ? 'sanitize_textarea_field' : 'sanitize_text_field',
- ]);
- }
-}
-add_action('admin_init', 'wp_multi_register_comment_filter_settings');
-
-/**
- * Fügt das Admin-Menü für den Kommentar-Filter hinzu.
- */
-function wp_multi_create_menu() {
- add_submenu_page(
- 'users.php',
- __('Benutzer sperren', 'wp-multi'),
- __('Benutzer sperren', 'wp-multi'),
- 'manage_options',
- 'wp-multi-blocked-users',
- 'wp_multi_blocked_users_page'
- );
-
- add_submenu_page(
- 'edit-comments.php',
- __('Kommentar-Filter Einstellungen', 'wp-multi'),
- __('Kommentar-Filter', 'wp-multi'),
- 'manage_options',
- 'wp-multi-comment-filter-settings',
- 'wp_multi_comment_filter_settings_page'
- );
-}
-add_action('admin_menu', 'wp_multi_create_menu');
-
-/**
- * Rendert die Admin-Seite für Kommentar-Filter-Einstellungen.
- */
-function wp_multi_comment_filter_settings_page() {
- ?>
-
-
-

-
-
-
-
-
-
-
-
- 5]);
- if (!is_wp_error($response)) {
- $json_content = wp_remote_retrieve_body($response);
- $decoded_data = json_decode($json_content, true);
- if (json_last_error() === JSON_ERROR_NONE && isset($decoded_data['words']) && is_array($decoded_data['words'])) {
- $swear_words = array_map('strtolower', $decoded_data['words']);
- set_transient(WP_MULTI_SWEAR_WORDS_CACHE_KEY, $swear_words, DAY_IN_SECONDS);
- } else {
- error_log('WP Multi Filter: Fehler beim Dekodieren der Schimpfwort-JSON-Datei.');
- }
- } else {
- error_log('WP Multi Filter: Fehler beim Abrufen der Schimpfwort-Liste: ' . $response->get_error_message());
- }
-
- // Fallback: Standard-Schimpfwörter, falls die externe Liste nicht verfügbar ist
- if (empty($swear_words)) {
- $swear_words = ['beispielwort1', 'beispielwort2']; // Ersetze durch echte Fallback-Wörter
- }
-
- return $swear_words;
-}
-
-/**
- * Filtert Schimpfwörter basierend auf der Filterstärke.
- *
- * @param string $content Kommentarinhalt.
- * @param array $swear_words Schimpfwörter.
- * @param array $allowed_words Erlaubte Wörter.
- * @param string $strength Filterstärke.
- * @return string Gefilterter Inhalt.
- */
-function wp_multi_filter_swear_words($content, $swear_words, $allowed_words, $strength) {
- if (empty($swear_words)) {
- return $content;
- }
-
- foreach ($swear_words as $word) {
- if (in_array(strtolower($word), $allowed_words)) {
- continue;
- }
-
- $pattern = ($strength === 'loose')
- ? '/\b' . preg_quote($word, '/') . '\b/iu'
- : '/\b' . preg_quote($word, '/') . '[a-z0-9]*\b/iu';
-
- if ($strength === 'moderate') {
- $pattern = '/\b' . preg_quote($word, '/') . '\b/iu';
- }
-
- $replacement = str_repeat('*', mb_strlen($word));
- $content = preg_replace($pattern, $replacement, $content);
- }
-
- return $content;
-}
-
-/**
- * Filtert Kommentarinhalte basierend auf den Einstellungen.
- *
- * @param string $comment_content Kommentarinhalt.
- * @return string Gefilterter Inhalt.
- */
-function wp_multi_filter_comment_content($comment_content) {
- if (get_option(WP_MULTI_FILTER_OPTION_PREFIX . 'swear') == 1) {
- $swear_words = wp_multi_load_swear_words();
- $allowed_words = array_map('strtolower', array_map('trim', explode(',', get_option(WP_MULTI_FILTER_OPTION_PREFIX . 'allowed_words', ''))));
- $filter_strength = get_option(WP_MULTI_FILTER_OPTION_PREFIX . 'filter_strength', 'moderate');
- $comment_content = wp_multi_filter_swear_words($comment_content, $swear_words, $allowed_words, $filter_strength);
- }
-
- if (get_option(WP_MULTI_FILTER_OPTION_PREFIX . 'phone') == 1) {
- $comment_content = preg_replace('/\b(\+?[0-9]{1,3}[-.\s]?)?(\(?\d{2,4}\)?[-.\s]?\d{2,4}[-.\s]?\d{2,4})\b/i', '**********', $comment_content);
- }
-
- if (get_option(WP_MULTI_FILTER_OPTION_PREFIX . 'email') == 1) {
- $comment_content = preg_replace('/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/i', '**********', $comment_content);
- }
-
- if (get_option(WP_MULTI_FILTER_OPTION_PREFIX . 'url') == 1) {
- $allowed_urls = array_map('strtolower', array_map('trim', explode(',', get_option(WP_MULTI_FILTER_OPTION_PREFIX . 'allowed_urls', ''))));
- $comment_content = preg_replace_callback(
- '/\b((https?:\/\/)?(www\.)?[a-zA-Z0-9.-]+\.[a-zA-Z]{2,})(\/\S*)?\b/i',
- function ($matches) use ($allowed_urls) {
- $url = strtolower(preg_replace(['/^https?:\/\//', '/^www\./'], '', $matches[0]));
- return in_array($url, $allowed_urls) ? $matches[0] : '**************';
- },
- $comment_content
- );
- }
-
- if (get_option(WP_MULTI_FILTER_OPTION_PREFIX . 'ip') == 1) {
- $comment_content = preg_replace('/\b(?:\d{1,3}\.){3}\d{1,3}\b/', '**********', $comment_content);
- }
-
- return $comment_content;
-}
-add_filter('pre_comment_content', 'wp_multi_filter_comment_content');
/*
-* User Kommentar Blocken
-*/
+ * User Kommentar Blocken
+ */
-
-// Funktion zum Erstellen der Tabelle für gesperrte Benutzer
function wp_multi_create_blocked_users_table() {
global $wpdb;
-
- $table_name = $wpdb->prefix . 'blocked_users';
-
+ $table_name = $wpdb->prefix . 'blocked_users';
$charset_collate = $wpdb->get_charset_collate();
-
$sql = "CREATE TABLE $table_name (
id mediumint(9) NOT NULL AUTO_INCREMENT,
username varchar(100) DEFAULT '' NOT NULL,
@@ -2274,7 +2029,6 @@ function wp_multi_create_blocked_users_table() {
ip_address varchar(45) DEFAULT '' NOT NULL,
PRIMARY KEY (id)
) $charset_collate;";
-
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
dbDelta( $sql );
}
@@ -2285,17 +2039,12 @@ function wp_multi_activate() {
register_activation_hook( __FILE__, 'wp_multi_activate' );
-// Funktion zum Sperren von Benutzernamen, E-Mail-Adressen und IP-Adressen
function wp_multi_block_user($username = '', $email = '', $ip_address = '') {
global $wpdb;
-
- // Sicherstellen, dass mindestens eines der Felder ausgefüllt wurde
if (empty($username) && empty($email) && empty($ip_address)) {
- return;
+ return false;
}
-
- // Eintrag in die Datenbank einfügen
- $wpdb->insert(
+ $result = $wpdb->insert(
$wpdb->prefix . 'blocked_users',
[
'username' => $username,
@@ -2303,35 +2052,58 @@ function wp_multi_block_user($username = '', $email = '', $ip_address = '') {
'ip_address' => $ip_address
]
);
+ return $result !== false;
}
-// Funktion zum Löschen eines gesperrten Benutzers
function wp_multi_delete_blocked_user($id) {
global $wpdb;
- $wpdb->delete($wpdb->prefix . 'blocked_users', ['id' => $id]);
+ return $wpdb->delete($wpdb->prefix . 'blocked_users', ['id' => $id], ['%d']);
}
-// Admin-Seite für die Verwaltung der gesperrten Benutzer
+function wp_multi_register_blocked_users_page() {
+ add_menu_page(
+ 'Gesperrte Benutzer',
+ 'Gesperrte Benutzer',
+ 'manage_options',
+ 'wp-multi-blocked-users',
+ 'wp_multi_blocked_users_page',
+ 'dashicons-shield',
+ 80
+ );
+}
+add_action('admin_menu', 'wp_multi_register_blocked_users_page');
+
function wp_multi_blocked_users_page() {
global $wpdb;
- // Benutzer sperren
if (isset($_POST['block_username']) || isset($_POST['block_email']) || isset($_POST['block_ip'])) {
+ check_admin_referer('wp_multi_block_user');
$username = sanitize_text_field($_POST['block_username']);
$email = sanitize_email($_POST['block_email']);
$ip_address = sanitize_text_field($_POST['block_ip']);
-
- wp_multi_block_user($username, $email, $ip_address);
- echo '';
+ if (wp_multi_block_user($username, $email, $ip_address)) {
+ echo '';
+ } else {
+ echo 'Fehler beim Sperren des Benutzers!
';
+ }
+ }
+
+ if (isset($_GET['delete']) && isset($_GET['_wpnonce'])) {
+ if (wp_verify_nonce($_GET['_wpnonce'], 'wp_multi_delete_user_' . $_GET['delete'])) {
+ $user_id = intval($_GET['delete']);
+ if ($user_id > 0 && wp_multi_delete_blocked_user($user_id)) {
+ echo '';
+ } else {
+ echo 'Fehler beim Löschen des Benutzers!
';
+ }
+ }
}
- // Suche
$search_query = '';
if (isset($_GET['search'])) {
$search_query = sanitize_text_field($_GET['search']);
}
- // Abfrage der gesperrten Benutzer
$blocked_users = $wpdb->get_results($wpdb->prepare(
"SELECT * FROM {$wpdb->prefix}blocked_users WHERE username LIKE %s OR email LIKE %s OR ip_address LIKE %s",
'%' . $search_query . '%', '%' . $search_query . '%', '%' . $search_query . '%'
@@ -2340,8 +2112,8 @@ function wp_multi_blocked_users_page() {
?>
Benutzer sperren
-
-
Gesperrte Benutzer
-
@@ -2376,7 +2146,7 @@ function wp_multi_blocked_users_page() {
email); ?> |
ip_address); ?> |
- Löschen
+ Löschen
|
@@ -2391,36 +2161,18 @@ function wp_multi_blocked_users_page() {
0) {
- wp_multi_delete_blocked_user($user_id);
- // Redirect zur Admin-Seite nach dem Löschen
- wp_redirect(admin_url('admin.php?page=wp-multi-blocked-users'));
- exit;
- }
-}
-
-// Kommentar auf gesperrte Benutzer überprüfen
function wp_multi_check_blocked_user($commentdata) {
global $wpdb;
-
$username = isset($commentdata['comment_author']) ? $commentdata['comment_author'] : '';
$email = isset($commentdata['comment_author_email']) ? $commentdata['comment_author_email'] : '';
$ip_address = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '';
-
$blocked_user = $wpdb->get_row($wpdb->prepare(
"SELECT * FROM {$wpdb->prefix}blocked_users WHERE username = %s OR email = %s OR ip_address = %s",
$username, $email, $ip_address
));
-
if ($blocked_user) {
wp_die('Ihr Kommentar konnte nicht abgesendet werden, da Sie gesperrt sind. Bitte wenden Sie sich an den Support.');
}
-
return $commentdata;
}
add_filter('preprocess_comment', 'wp_multi_check_blocked_user');
@@ -2827,11 +2579,9 @@ function wp_multi_notify_page() {
-
-
-
-
-

-
-
-
-
-
-
-
-
-
-