') )
return esc_html($matches[0]);
return $matches[0];
}
function wp_pre_kses_less_than( $text ) {
return preg_replace_callback('%<[^>]*?((?=<)|>|$)%', 'wp_pre_kses_less_than_callback', $text);
}
function wp_strip_all_tags($string, $remove_breaks = false) {
$string = preg_replace( '@<(script|style)[^>]*?>.*?\\1>@si', '', $string );
$string = strip_tags($string);
if ( $remove_breaks )
$string = preg_replace('/[\r\n\t ]+/', ' ', $string);
return trim( $string );
}
function _sanitize_text_fields( $str, $keep_newlines = false ) {
// leads to error on server - why?
// $filtered = wp_check_invalid_utf8( $str );
$filtered = $str;
if ( strpos($filtered, '<') !== false ) {
$filtered = wp_pre_kses_less_than( $filtered );
// This will strip extra whitespace for us.
$filtered = wp_strip_all_tags( $filtered, false );
// Use html entities in a special case to make sure no later
// newline stripping stage could lead to a functional tag
$filtered = str_replace("<\n", "<\n", $filtered);
}
if ( ! $keep_newlines ) {
$filtered = preg_replace( '/[\r\n\t ]+/', ' ', $filtered );
}
$filtered = trim( $filtered );
$found = false;
while ( preg_match('/%[a-f0-9]{2}/i', $filtered, $match) ) {
$filtered = str_replace($match[0], '', $filtered);
$found = true;
}
if ( $found ) {
// Strip out the whitespace that may now exist after removing the octets.
$filtered = trim( preg_replace('/ +/', ' ', $filtered) );
}
return $filtered;
}
// own code :-)
function obfuscateSPAMKey($key) {
$key = md5($key);
$key = preg_replace("/[0123456789]/", "", $key);
return $key;
}
function nojunk_get_values() {
$num1 = rand(10, 49);
$num2 = rand(10, 49);
$numbers = array($num1, $num2);
sort($numbers);
$operand = array("plus", "minus");
shuffle($operand);
if ($operand[0] == "plus") {
$nojunk = $numbers[1] + $numbers[0];
}
else {
$nojunk = $numbers[1] - $numbers[0];
}
$nojunk_key_1 = obfuscateSPAMKey($nojunk);
$nojunk_key_2 = time();
$nojunk_question = "$numbers[1] $operand[0] $numbers[0] ergibt";
return array($nojunk_question, $nojunk_key_1, $nojunk_key_2);
}
function mailFile($email, $subject, $message, $filename, $filedata) {
$file_data = chunk_split(base64_encode($filedata));
$mail_header = "From: <$email>";
$random_time = md5(time());
$mime_boundary = "==BlogThulOrg- $random_time";
$mail_header .= "\nMIME-Version: 1.0\n" .
"Content-Type: multipart/mixed;\n" .
" boundary=\"{$mime_boundary}\"";
$mail_message = $message;
$mail_message .= "\nAnhang '$filename'\n";
$mail_message = "This is a multi-part message in MIME format.\n\n" .
"--{$mime_boundary}\n" .
"Content-Type: text/plain; charset=\"utf-8\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" . $mail_message . "\n\n";
$mail_message .= "--{$mime_boundary}\n" .
"Content-Type: application/octet-stream;\n" .
" name=\"{$filename}\"\n" .
"Content-Disposition: attachment;\n" .
" filename=\"{$filename}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$file_data . "\n\n--{$mime_boundary}--\n";
mail($email, $subject, $mail_message, $mail_header);
}
?>
Bitte einen Namen eingeben.";
} else {
$comment['comment_author'] = _sanitize_text_fields($_POST['author']);
}
if(trim($_POST['comment']) === '') {
$error .= "
Bitte einen Kommentar eingeben.";
} else {
$comment['comment_content'] = _sanitize_text_fields($_POST['comment'], true);
}
if(trim($_POST['nojunk_answer']) === '') {
$error .= "
Bitte die Rechenaufgabe ausfüllen.";
} else {
$formNojunk = _sanitize_text_fields($_POST['nojunk_answer']);
$formNojunk = obfuscateSPAMKey($formNojunk);
if (!($formNojunk == $_POST['nojunk_key_1'])) {
$error .= "
Bitte das Ergebnis der Rechenaufgabe überprüfen.";
}
}
$time_to_send = time() - $_POST['nojunk_key_2'];
if (($time_to_send < 10) || ($time_to_send > 3600)) {
$error .= "
Das ging ein bisschen zu schnell - sind Sie sicher, daß Sie ein Mensch sind?";
}
if($error === '') {
$slug = _sanitize_text_fields($_POST['post_slug']);
$url = _sanitize_text_fields($_POST['post_url']);
$message = "Kommentar zum Beitrag $url\n";
mailFile("blog@thul.org", "Kommentar [$slug]", $message, date("Y-m-d_H-i-s") . ".json", json_encode($comment, JSON_UNESCAPED_UNICODE));
echo "
Vielen Dank für Ihren Kommentar
";
echo "
Ihr Kommentar wird erst nach manueller Freischaltung angezeigt, was in der Regel ein paar Stunden dauern kann.
";
echo "
Zurück zum Beitrag
";
}
else {
echo "
Fehler beim Ausfüllen des Formulars:
";
echo "
";
echo "
Bitte betätigen Sie den \"Zurück\"-Button in Ihrem Browser und korrigieren Sie Ihre Eingaben.
";
}
}
?>
Beitrag ""
Bitte nur "normalen Text" verwenden. Links, HTML-Tags o.ä. werden beim Versenden entfernt.