]*>.*?<\/h[1-6]>/is', $text, $headings_matches);
$stats['headings'] = count($headings_matches[0]);
// H3-Überschriften finden und speziell verarbeiten
preg_match_all('/]*>(.*?)<\/h3>/is', $text, $h3_matches);
$h3_contents = isset($h3_matches[1]) ? $h3_matches[1] : [];
$stats['h3_total'] = count($h3_matches[0]);
// REGEL 9: H3-Formatierung - KORRIGIERT: Behalte HTML-Attribute
for ($i = 0; $i < count($h3_matches[0]); $i++) {
$h3_tag = $h3_matches[0][$i];
$h3_content = $h3_contents[$i];
// Eindeutigen Platzhalter erstellen
$placeholder = "___H3_TAG_{$i}___";
// Entscheiden, ob H3 formatiert werden soll - verwende die tatsächliche Chaos-Rate
if (p_chaos_decide($chaos_rate)) {
$stats['h3_formatted']++;
// Zufällig "-" oder ":" oder beides hinzufügen
$modified_content = $h3_content;
if (mt_rand(0, 1) == 1) {
$pos = mt_rand(0, mb_strlen($h3_content, 'UTF-8'));
$modified_content = mb_substr($h3_content, 0, $pos, 'UTF-8') .
' - ' .
mb_substr($h3_content, $pos, null, 'UTF-8');
}
if (mt_rand(0, 1) == 1) {
$pos = mt_rand(0, mb_strlen($modified_content, 'UTF-8'));
$modified_content = mb_substr($modified_content, 0, $pos, 'UTF-8') .
' : ' .
mb_substr($modified_content, $pos, null, 'UTF-8');
}
// KORRIGIERT: Behalte HTML-Attribute bei, ersetze nur den Inhalt
$modified_tag = preg_replace('/>.*?<\/h3>/is', '>' . $modified_content . '', $h3_tag);
// Formatierte H3-Tag speichern
$protected_content[$placeholder] = $modified_tag;
} else {
// Unveränderten H3-Tag speichern
$protected_content[$placeholder] = $h3_tag;
}
// H3-Tag durch Platzhalter ersetzen
$text = str_replace($h3_tag, $placeholder, $text);
}
// REGEL 3 & 10: Setze Spezialregeln für H3-Überschriften und Absatzanfang
// Hier nutzen wir die korrekte Chaos-Rate für die Regeln
$stats['h3_komma_total'] = $stats['h3_total'];
$stats['absatz_total'] = $stats['h3_total'];
// Anwenden der H3-Spezialregeln und Absatzanfangsregeln mit der Chaos-Rate
for ($i = 0; $i < $stats['h3_komma_total']; $i++) {
if (p_chaos_decide($chaos_rate)) {
$stats['h3_komma_applied']++;
}
}
for ($i = 0; $i < $stats['absatz_total']; $i++) {
if (p_chaos_decide($chaos_rate)) {
$stats['absatz_applied']++;
}
}
// HTML-Tags und Shortcodes schützen - KORRIGIERT für bessere HTML-Erkennung
$text = preg_replace_callback(
'/<[^>]*(?:"[^"]*"[^>]*)*>|\[.*?\]/',
function($matches) use (&$protected_content, &$tag_counter, &$stats) {
$tag = $matches[0];
$placeholder = "___HTML_TAG_{$tag_counter}___";
$protected_content[$placeholder] = $tag;
$tag_counter++;
$stats['html_tags']++;
return $placeholder;
},
$text
);
// HTML-Entities schützen
$text = preg_replace_callback(
'/&[#A-Za-z0-9]+;/',
function($matches) use (&$protected_content, &$tag_counter) {
$entity = $matches[0];
$placeholder = "___HTML_ENTITY_{$tag_counter}___";
$protected_content[$placeholder] = $entity;
$tag_counter++;
return $placeholder;
},
$text
);
// REGEL 13: Abkürzungen finden und schützen - KORRIGIERT: Abkürzungen ohne falschen Punkt am Ende
$abbr_list = [
'Dr.', 'Ing.', 'Prof.', 'Dr.-Ing.', 'rer.', 'nat.', 'med.', 'phil.', 'jur.',
'z.B.', 'usw.', 'etc.', 'ca.', 'Nr.', 'Abs.', 'Art.', 'Std.',
'bzw.', 'inkl.', 'exkl.', 'ggf.', 'evtl.', 'd.h.', 'm.E.', 'u.a.',
'GmbH', 'AG', 'Co.', 'KG', 'OHG', 'Ltd.'
];
// Abkürzungen zählen
foreach ($abbr_list as $abbr) {
$pattern = '/\b' . preg_quote($abbr, '/') . '\b/ui';
$matches = [];
preg_match_all($pattern, $text, $matches);
$stats['abbr_total'] += count($matches[0]);
}
// Abkürzungen chaotisch schützen
$abbr_counter = 0;
foreach ($abbr_list as $abbr) {
$text = preg_replace_callback(
'/\b' . preg_quote($abbr, '/') . '\b/ui',
function($matches) use (&$protected_content, &$abbr_counter, $chaos_rate, &$stats) {
if (p_chaos_decide($chaos_rate)) {
$placeholder = "___ABBR_{$abbr_counter}___";
$protected_content[$placeholder] = $matches[0];
$abbr_counter++;
$stats['abbr_protected']++;
return $placeholder;
}
return $matches[0];
},
$text
);
}
// Zahlenformate schützen (Datum, Dezimalzahlen) - KORRIGIERT für deutsche Zahlenformate
$text = preg_replace_callback(
'/\b\d{1,2}\.\d{1,2}\.\d{2,4}\b|\b\d{1,3}(?:\.\d{3})*(?:,\d+)?\b|\b\d+,\d+\b/',
function($matches) use (&$protected_content, &$tag_counter) {
$number = $matches[0];
$placeholder = "___NUMBER_{$tag_counter}___";
$protected_content[$placeholder] = $number;
$tag_counter++;
return $placeholder;
},
$text
);
// PHASE 2: SATZZEICHEN IDENTIFIZIEREN UND ZÄHLEN
// Satzzeichen zählen
preg_match_all('/\.(?!\d)/', $text, $dots);
preg_match_all('/,(?!\d)/', $text, $commas);
preg_match_all('/\?/', $text, $quest_marks);
preg_match_all('/!/', $text, $excl_marks);
preg_match_all('/:/', $text, $colons);
$stats['dot_total'] = count($dots[0]);
$stats['comma_total'] = count($commas[0]);
$stats['quest_total'] = count($quest_marks[0]);
$stats['excl_total'] = count($excl_marks[0]);
$stats['colons'] = count($colons[0]);
// Zähle die ersetzbaren Zeichen
preg_match_all('/(?]+>\s*)*\s*(und|oder|aber)\b/ui',
function($matches) use ($chaos_rate, &$stats) {
if (p_chaos_decide($chaos_rate)) {
$stats['conjunction_removed']++;
// Extrahiere die Konjunktion und gib sie mit eventuellen HTML-Tags zurück
$conj_part = isset($matches[1]) ? $matches[1] . $matches[2] : $matches[2];
return ' ' . $conj_part;
}
return $matches[0];
},
$text
);
// REGEL 4: FRAGEZEICHEN MIT ANFÜHRUNGSZEICHEN
$text = preg_replace_callback(
'/([^.!?]{3,})\?/',
function($matches) use ($chaos_rate, &$stats) {
if (p_chaos_decide($chaos_rate)) {
$context = $matches[1];
preg_match_all('/\b([a-zäöüA-ZÄÖÜ]{3,})\b/u', $context, $words);
if (!empty($words[0])) {
$stats['quest_quotes_added']++;
$word = $words[0][array_rand($words[0])];
$modified_context = preg_replace(
'/\b' . preg_quote($word, '/') . '\b/u',
'„' . $word . '"',
$context,
1
);
return $modified_context . '?';
}
}
return $matches[0];
},
$text
);
// REGEL 5: AUSRUFEZEICHEN MIT ANFÜHRUNGSZEICHEN
$text = preg_replace_callback(
'/([^.!?]{3,})!/',
function($matches) use ($chaos_rate, &$stats) {
if (p_chaos_decide($chaos_rate)) {
$context = $matches[1];
preg_match_all('/\b([a-zäöüA-ZÄÖÜ]{3,})\b/u', $context, $words);
if (!empty($words[0])) {
$stats['excl_quotes_added']++;
$word = $words[0][array_rand($words[0])];
$modified_context = preg_replace(
'/\b' . preg_quote($word, '/') . '\b/u',
'„' . $word . '"',
$context,
1
);
return $modified_context . '!';
}
}
return $matches[0];
},
$text
);
// REGEL 12: AUFEINANDERFOLGENDE SONDERZEICHEN BEREINIGEN
foreach ($duplicate_chars[0] as $duplicate) {
if (p_chaos_decide($chaos_rate)) {
$unique = preg_replace("/(.)\1+/u", '$1', $duplicate);
$text = str_replace($duplicate, $unique, $text);
$stats['special_chars_cleaned']++;
}
}
// PHASE 4: GESCHÜTZTE INHALTE WIEDERHERSTELLEN - KORRIGIERT für sicherere Wiedereinsetzung
// Eindeutige ID für jede Sitzung, um Kollisionen zu vermeiden
$session_id = uniqid('', true);
// Sortierung nach Länge der Platzhalter (längste zuerst), um Kollisionen zu vermeiden
uksort($protected_content, function($a, $b) {
return strlen($b) - strlen($a);
});
// Wiederherstellung aller geschützten Inhalte mit eindeutigen Platzhaltern
foreach ($protected_content as $placeholder => $original) {
// Sicherstellen, dass der Platzhalter exakt gefunden wird
$unique_placeholder = $placeholder . '_' . $session_id;
$text = str_replace($placeholder, $unique_placeholder, $text);
}
// Nach der ersten Ersetzung mit eindeutigen Platzhaltern, ersetze sie mit dem Original
foreach ($protected_content as $placeholder => $original) {
$unique_placeholder = $placeholder . '_' . $session_id;
$text = str_replace($unique_placeholder, $original, $text);
}
// PHASE 5: STATISTISCHE AUSWERTUNG
// Effektive Chaos-Rate berechnen
$modifiable_elements =
$stats['dot_replaceable'] +
$stats['comma_replaceable'] +
$stats['h3_komma_total'] +
$stats['quest_total'] +
$stats['excl_total'] +
$stats['h3_total'] +
$stats['absatz_total'] +
$stats['conjunction_total'] +
$stats['special_chars_total'] +
$stats['abbr_total'];
$modified_elements =
$stats['dot_replaced'] +
$stats['comma_replaced'] +
$stats['h3_komma_applied'] +
$stats['quest_quotes_added'] +
$stats['excl_quotes_added'] +
$stats['h3_formatted'] +
$stats['absatz_applied'] +
$stats['conjunction_removed'] +
$stats['special_chars_cleaned'] +
$stats['abbr_protected'];
$stats['effective_chaos_rate'] = ($modifiable_elements > 0) ?
($modified_elements / $modifiable_elements) * 100 : 0;
// Detailliertes Logging
p_log_detailed_stats($stats, $chaos_rate);
// PHASE 6: TEXTMANIPULATION, WENN AKTIVIERT
if ($text_manipulation) {
$text = apply_human_text_patterns($text, $chaos_rate);
}
// PHASE 7: IMPLEMENTIERUNG VON REGEL 10 (ABSATZANFANG NACH H3)
// Implementierung für die fehlende Regel 10
if ($stats['absatz_applied'] > 0) {
// Suche nach Absätzen nach H3-Überschriften
$text = preg_replace_callback(
'/<\/h3>\s*
([^<]+)/i',
function($matches) use ($chaos_rate) {
if (p_chaos_decide($chaos_rate)) {
// Füge zufällige Absatzanfänge hinzu
$starters = ['Übrigens: ', 'Wichtig: ', 'Hinweis: ', 'Beachte: ', 'Merke: '];
$starter = $starters[array_rand($starters)];
return str_replace('
', '
' . $starter, $matches[0]);
}
return $matches[0];
},
$text
);
p_log("Regel 10 (Absatzanfang) wurde implementiert und angewendet.");
}
// Überflüssige Leerzeilen entfernen
return preg_replace(['/\n{3,}/', '/(
)\s+/', '/\s+(<\/p>)/'], ["\n\n", '$1', '$1'], $text);
}S
Warning: Cannot modify header information - headers already sent by (output started at /var/customers/webs/Muhsin/muhsin.de/wp-content/plugins/punctuation/punctuation.php:1) in /var/customers/webs/Muhsin/muhsin.de/wp-includes/pluggable.php on line 1435
Warning: Cannot modify header information - headers already sent by (output started at /var/customers/webs/Muhsin/muhsin.de/wp-content/plugins/punctuation/punctuation.php:1) in /var/customers/webs/Muhsin/muhsin.de/wp-includes/pluggable.php on line 1438