wp-multi.php aktualisiert

This commit is contained in:
M_Viper 2025-03-25 16:35:55 +00:00
parent 7ff5fc952a
commit 5704f6d86b

View File

@ -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: 2.4
* Version: 2.6
* Author: M_Viper
* Author URI: https://m-viper.de
* Requires at least: 6.7.2
@ -12,11 +12,41 @@
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: wp-multi
* Tags: anti-spam, security, honeypot, comment-protection, statistics, happyforms
* Support: [Microsoft Teams Support](https://teams.live.com/l/community/FEAzokphpZTJ2u6OgI)
* Support: [Telegram Support](https://t.me/M_Viper04)
*/
if (!defined('ABSPATH')) exit;
/*
* Admin - Panel Banner
*/
// Admin-Banner als Notice mit Blauem Hintergrund (#0073aa)
function wp_multi_add_warning_banner() {
echo '
<div class="notice notice-warning is-dismissible" style="background-color: #0073aa; color: white; border-left: 4px solid #005177;">
<p><strong>Danke, dass du WP Multi verwendest!</strong> Dein Feedback hilft uns, das Plugin ständig zu verbessern. Wenn du Fehler entdeckst oder Verbesserungsvorschläge hast, besuche bitte unsere <a href="https://git.viper.ipv64.net/M_Viper/wp-multi" target="_blank" style="color: #FFDD00; text-decoration: none;">Gitea-Seite</a> und teile uns deine Ideen mit!</p>
<p><strong>Support:</strong> Bei Fragen oder Supportanfragen kannst du uns über <a href="https://teams.live.com/l/community/FEAzokphpZTJ2u6OgI" target="_blank" style="color: #FFDD00; text-decoration: none;">Microsoft Teams</a> oder <a href="https://t.me/M_Viper04" target="_blank" style="color: #FFDD00; text-decoration: none;">Telegram</a> erreichen.</p>
</div>';
}
add_action('admin_notices', 'wp_multi_add_warning_banner');
// Support-Links in der Plugin-Übersicht anzeigen
function wp_multi_plugin_row_meta($links, $file) {
if ($file == plugin_basename(__FILE__)) {
$new_links = array(
'support_teams' => '<a href="https://teams.live.com/l/community/FEAzokphpZTJ2u6OgI" target="_blank" style="color:rgb(255, 0, 0);">Microsoft Teams Support</a>',
'support_telegram' => '<a href="https://t.me/M_Viper04" target="_blank" style="color:rgb(255, 0, 0);">Telegram Support</a>',
);
// Links an die Plugin-Übersicht anhängen
$links = array_merge($links, $new_links);
}
return $links;
}
add_filter('plugin_row_meta', 'wp_multi_plugin_row_meta', 10, 2);
/*
* Index Verzeichnis [alphabetical_index]
@ -616,21 +646,6 @@ function wp_multi_process_auto_tags_step() {
}
/*
* Admin - Panel Banner
*/
// Admin-Banner als Notice mit Blauem Hintergrund (#0073aa)
function wp_multi_add_warning_banner() {
echo '
<div class="notice notice-warning is-dismissible" style="background-color: #0073aa; color: white; border-left: 4px solid #005177;">
<p><strong>Danke, dass du WP Multi verwendest!</strong> Dein Feedback hilft uns, das Plugin ständig zu verbessern. Wenn du Fehler entdeckst oder Verbesserungsvorschläge hast, besuche bitte unsere <a href="https://git.viper.ipv64.net/M_Viper/wp-multi" target="_blank" style="color: #FFDD00; text-decoration: none;">Gitea-Seite</a> und teile uns deine Ideen mit!</p>
</div>';
}
add_action('admin_notices', 'wp_multi_add_warning_banner');
/*
* Anti Spam Honey
*/
@ -934,8 +949,6 @@ function wp_multi_blocked_ips_callback() {
}
/*
* Schutz vor Brute-Force-Angriffen
*/
@ -1119,7 +1132,7 @@ function wp_multi_display_blocked_ips() {
echo '<div class="tablenav"><div class="alignleft actions">';
for ($i = 1; $i <= $total_pages; $i++) {
$class = ($i == $page) ? ' class="current"' : '';
echo '<a href="' . admin_url('users.php?page=wp_multi_blocked_ips&paged=' . $i) . '" ' . $class . '>' . $i . '</a> ';
echo '<a href="' . admin_url('admin.php?page=wp_multi_blocked_ips&paged=' . $i) . '" ' . $class . '>' . $i . '</a> ';
}
echo '</div></div>';
}
@ -1162,6 +1175,7 @@ add_action('admin_post_remove_blocked_ip', 'wp_multi_remove_blocked_ip');
* Admin - Pinnwand
*/
// Funktion zum Erstellen der Datenbanktabelle für Nachrichten
function wp_multi_create_message_board_table() {
global $wpdb;
@ -1743,50 +1757,44 @@ function wp_multi_register_comment_filter_settings() {
add_option('wp_multi_filter_email', '1');
add_option('wp_multi_filter_url', '1');
add_option('wp_multi_filter_swear', '1');
add_option('wp_multi_filter_ip', '1'); // Neue Option für IP-Filterung
add_option('wp_multi_filter_ip', '1');
add_option('wp_multi_allowed_urls', ''); // NEU: Erlaubte URLs
register_setting('wp_multi_filter_options_group', 'wp_multi_filter_phone');
register_setting('wp_multi_filter_options_group', 'wp_multi_filter_email');
register_setting('wp_multi_filter_options_group', 'wp_multi_filter_url');
register_setting('wp_multi_filter_options_group', 'wp_multi_filter_swear');
register_setting('wp_multi_filter_options_group', 'wp_multi_filter_ip'); // Neue Option für IP-Filterung
register_setting('wp_multi_filter_options_group', 'wp_multi_filter_ip');
register_setting('wp_multi_filter_options_group', 'wp_multi_allowed_urls'); // NEU
}
add_action('admin_init', 'wp_multi_register_comment_filter_settings');
// Admin-Menü & Untermenü hinzufügen
function wp_multi_create_menu() {
add_submenu_page(
'users.php',
'Benutzer sperren',
'Benutzer sperren',
'manage_options',
'wp-multi-blocked-users',
'wp_multi_blocked_users_page'
);
// Admin-Menü & Untermenü hinzufügen
function wp_multi_create_menu() {
// 'Benutzer sperren' Menü als Untermenü im Benutzer-Menü hinzufügen
add_submenu_page(
'users.php', // 'Benutzer' Menü
'Benutzer sperren',
'Benutzer sperren',
'manage_options',
'wp-multi-blocked-users',
'wp_multi_blocked_users_page'
);
// Kommentar-Filter unter Kommentare verschieben
add_submenu_page(
'edit-comments.php', // 'Kommentare' Menü
'Kommentar-Filter Einstellungen',
'Kommentar-Filter',
'manage_options',
'wp-multi-comment-filter-settings',
'wp_multi_comment_filter_settings_page'
);
}
add_action('admin_menu', 'wp_multi_create_menu');
add_submenu_page(
'edit-comments.php',
'Kommentar-Filter Einstellungen',
'Kommentar-Filter',
'manage_options',
'wp-multi-comment-filter-settings',
'wp_multi_comment_filter_settings_page'
);
}
add_action('admin_menu', 'wp_multi_create_menu');
// Admin-Seite für Kommentar-Filter
function wp_multi_comment_filter_settings_page() {
?>
<div class="wrap">
<!-- Blaues Banner mit Logo -->
<div class="wp-multi-banner">
<img src="https://m-viper.de/img/logo.png" alt="Logo" class="wp-multi-logo">
</div>
@ -1796,125 +1804,88 @@ function wp_multi_comment_filter_settings_page() {
<form method="post" action="options.php">
<?php settings_fields('wp_multi_filter_options_group'); ?>
<table class="form-table">
<tr>
<th><label for="wp_multi_filter_phone">Rufnummern filtern</label></th>
<tr><th><label for="wp_multi_filter_phone">Rufnummern filtern</label></th>
<td><input type="checkbox" name="wp_multi_filter_phone" value="1" <?php checked(1, get_option('wp_multi_filter_phone'), true); ?>></td>
</tr>
<tr>
<th><label for="wp_multi_filter_email">E-Mail-Adressen filtern</label></th>
<tr><th><label for="wp_multi_filter_email">E-Mail-Adressen filtern</label></th>
<td><input type="checkbox" name="wp_multi_filter_email" value="1" <?php checked(1, get_option('wp_multi_filter_email'), true); ?>></td>
</tr>
<tr>
<th><label for="wp_multi_filter_url">URLs filtern</label></th>
<tr><th><label for="wp_multi_filter_url">URLs filtern</label></th>
<td><input type="checkbox" name="wp_multi_filter_url" value="1" <?php checked(1, get_option('wp_multi_filter_url'), true); ?>></td>
</tr>
<tr>
<th><label for="wp_multi_filter_swear">Schimpfwörter filtern</label></th>
<tr><th><label for="wp_multi_filter_swear">Schimpfwörter filtern</label></th>
<td><input type="checkbox" name="wp_multi_filter_swear" value="1" <?php checked(1, get_option('wp_multi_filter_swear'), true); ?>></td>
</tr>
<tr>
<th><label for="wp_multi_filter_ip">IP-Adressen filtern</label></th>
<tr><th><label for="wp_multi_filter_ip">IP-Adressen filtern</label></th>
<td><input type="checkbox" name="wp_multi_filter_ip" value="1" <?php checked(1, get_option('wp_multi_filter_ip'), true); ?>></td>
</tr>
<tr>
<th><label for="wp_multi_allowed_urls">Erlaubte URLs</label></th>
<td>
<textarea name="wp_multi_allowed_urls" rows="5" cols="50"><?php echo esc_textarea(get_option('wp_multi_allowed_urls')); ?></textarea>
<p class="description">Trenne mehrere URLs mit einem Komma. Es wird automatisch <strong>http://</strong> und <strong>www.</strong> entfernt, bevor die URL überprüft wird.</p>
</td>
</tr>
</table>
<?php submit_button(); ?>
</form>
</div>
<style>
/* Banner Styling */
.wp-multi-banner {
background-color: #0073aa; /* Blaues Banner */
padding: 20px;
text-align: center;
border-radius: 8px 8px 0 0;
margin-bottom: 30px;
}
.wp-multi-logo {
max-width: 200px;
height: auto;
}
/* Anpassung für die Kommentar-Filter-Seite */
.wrap {
font-family: Arial, sans-serif;
padding: 20px;
background-color: #ffffff;
border-radius: 10px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}
h1 {
color: #0073aa;
font-size: 24px;
font-weight: 600;
margin-bottom: 20px;
}
.form-table th {
padding: 12px 15px;
text-align: left;
background-color: #f9f9f9;
border: 1px solid #ddd;
}
.form-table td {
padding: 12px 15px;
border: 1px solid #ddd;
}
.form-table input[type="checkbox"] {
margin-right: 10px;
}
input[type="submit"] {
background-color: #0073aa;
color: white;
padding: 10px 20px;
border: none;
border-radius: 5px;
cursor: pointer;
font-size: 16px;
transition: background-color 0.3s ease;
}
input[type="submit"]:hover {
background-color: #005177;
}
.wp-multi-banner { background-color: #0073aa; padding: 20px; text-align: center; border-radius: 8px 8px 0 0; margin-bottom: 30px; }
.wp-multi-logo { max-width: 200px; height: auto; }
.wrap { font-family: Arial, sans-serif; padding: 20px; background-color: #ffffff; border-radius: 10px; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); }
h1 { color: #0073aa; font-size: 24px; font-weight: 600; margin-bottom: 20px; }
.form-table th { padding: 12px 15px; text-align: left; background-color: #f9f9f9; border: 1px solid #ddd; }
.form-table td { padding: 12px 15px; border: 1px solid #ddd; }
input[type="submit"] { background-color: #0073aa; color: white; padding: 10px 20px; border: none; border-radius: 5px; cursor: pointer; font-size: 16px; transition: background-color 0.3s ease; }
input[type="submit"]:hover { background-color: #005177; }
</style>
<?php
}
// Kommentar-Filter
// Kommentar-Filter Funktion
function wp_multi_filter_comment_content($comment_content) {
// Rufnummern filtern (mit verschiedenen Trennzeichen und Formaten)
$bad_words_url = 'https://git.viper.ipv64.net/M_Viper/wp-multi/raw/branch/main/includes/bad-words.json';
$swear_words = get_transient('wp_multi_swear_words');
if ($swear_words === false) {
$response = wp_remote_get($bad_words_url);
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 = $decoded_data['words'];
set_transient('wp_multi_swear_words', $swear_words, HOUR_IN_SECONDS);
}
}
}
if (get_option('wp_multi_filter_swear') == 1 && !empty($swear_words)) {
foreach ($swear_words as $word) {
$pattern = '/\b' . preg_quote($word, '/') . '\b/iu';
$replacement = str_repeat('*', mb_strlen($word));
$comment_content = preg_replace($pattern, $replacement, $comment_content);
}
}
if (get_option('wp_multi_filter_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);
}
// E-Mail-Adressen filtern (alle möglichen Varianten, z.B. mit und ohne Subdomains)
if (get_option('wp_multi_filter_email') == 1) {
$comment_content = preg_replace('/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/i', '**********', $comment_content);
}
// URLs filtern (verschiedene Varianten, z.B. mit oder ohne http://, www)
if (get_option('wp_multi_filter_url') == 1) {
$comment_content = preg_replace('/\b((https?:\/\/)?(www\.)?[a-zA-Z0-9.-]+\.[a-zA-Z]{2,})(\/\S*)?\b/i', '**************', $comment_content);
$allowed_urls = array_map('trim', explode(',', get_option('wp_multi_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) {
// Entfernt "http://", "https://" und "www."
$url = strtolower(preg_replace(['/^https?:\/\//', '/^www\./'], '', $matches[0]));
return in_array($url, $allowed_urls) ? $matches[0] : '**************';
}, $comment_content);
}
// Schimpfwörter filtern (verschiedene Schreibweisen und Abkürzungen berücksichtigen)
if (get_option('wp_multi_filter_swear') == 1) {
$swear_words = ['arsch', 'schlechtwort1', 'schlechtwort2', 'examplebadword']; // Echte Wörter einfügen
foreach ($swear_words as $word) {
$comment_content = preg_replace('/\b' . preg_quote($word, '/') . '\b/i', str_repeat('*', strlen($word)), $comment_content);
// Alternative Schreibweisen oder Abkürzungen können hier auch berücksichtigt werden, z.B.:
$comment_content = preg_replace('/\b' . preg_quote($word, '/') . '[s]{0,2}\b/i', str_repeat('*', strlen($word)), $comment_content); // Beispiel für 'arssch' oder 'arschs'
}
}
// IP-Adressen filtern (alle gängigen Formate)
if (get_option('wp_multi_filter_ip') == 1) {
$comment_content = preg_replace('/\b(?:\d{1,3}\.){3}\d{1,3}\b/', '**********', $comment_content);
}