Compare commits
No commits in common. "590cbfbb65d5a615acb396f90fc03207f6896a82" and "7ae47ee5903b55ede96239b857700b1d34112fc2" have entirely different histories.
590cbfbb65
...
7ae47ee590
@ -6,16 +6,17 @@ function sanitize_text(string $name, string $type) {
|
||||
'text' => FILTER_SANITIZE_SPECIAL_CHARS,
|
||||
'email' => FILTER_SANITIZE_EMAIL,
|
||||
);
|
||||
$text = filter_var(trim($_POST[$name]), $filters[$type]);
|
||||
$text = trim($text);
|
||||
$text = filter_var($_POST[$name], $filters[$type]);
|
||||
$text = stripslashes($text);
|
||||
|
||||
return $text;
|
||||
}
|
||||
|
||||
function prepare_message_body(string $message, string $name) {
|
||||
function prepare_message_body($message) {
|
||||
// Replace HTML-Entities with actual carriage returns and line feeds
|
||||
$message = str_replace(" ", "\r", $message);
|
||||
$message = str_replace(" ", "\n", $message);
|
||||
$message = str_replace(" ", "\r", $message);
|
||||
|
||||
// Ensure line breaks via carriage return + line feed
|
||||
$message = str_replace("\r\n", "\n", $message);
|
||||
@ -33,11 +34,11 @@ function prepare_message_body(string $message, string $name) {
|
||||
* mail(): Braucht auf dem Server einen korrekt konfigurierten Mailserver
|
||||
* phpmailer: Bibliothek, der per Composer installiert wird. Tut ganz gut mit SMTP.
|
||||
*/
|
||||
function send_message_to_office(string $subject, string $message, string $name, string $email) {
|
||||
function send_message_to_office($subject, $message, $name, $email) {
|
||||
return mail(
|
||||
getenv('WTF_CONTACT_TO'),
|
||||
"=?UTF-8?B?" . base64_encode($subject) . "?=",
|
||||
prepare_message_body($message, $name),
|
||||
prepare_message_body($message),
|
||||
$additional_headers = array(
|
||||
"From" => getenv('WTF_CONTACT_FROM'),
|
||||
"Reply-To" => $email,
|
||||
@ -48,7 +49,7 @@ function send_message_to_office(string $subject, string $message, string $name,
|
||||
);
|
||||
}
|
||||
|
||||
function send_response(array $response_data) {
|
||||
function send_response($response_data) {
|
||||
$json = json_encode($response_data);
|
||||
if ($json === false) {
|
||||
// Avoid echo of empty string (which is invalid JSON), and
|
||||
|
Loading…
Reference in New Issue
Block a user