Compare commits
3 Commits
7ae47ee590
...
590cbfbb65
Author | SHA1 | Date | |
---|---|---|---|
590cbfbb65 | |||
aebb53e5c1 | |||
7df4a24abd |
@ -6,17 +6,16 @@ function sanitize_text(string $name, string $type) {
|
||||
'text' => FILTER_SANITIZE_SPECIAL_CHARS,
|
||||
'email' => FILTER_SANITIZE_EMAIL,
|
||||
);
|
||||
$text = trim($text);
|
||||
$text = filter_var($_POST[$name], $filters[$type]);
|
||||
$text = filter_var(trim($_POST[$name]), $filters[$type]);
|
||||
$text = stripslashes($text);
|
||||
|
||||
return $text;
|
||||
}
|
||||
|
||||
function prepare_message_body($message) {
|
||||
function prepare_message_body(string $message, string $name) {
|
||||
// Replace HTML-Entities with actual carriage returns and line feeds
|
||||
$message = str_replace(" ", "\r", $message);
|
||||
$message = str_replace(" ", "\r", $message);
|
||||
$message = str_replace(" ", "\n", $message);
|
||||
|
||||
// Ensure line breaks via carriage return + line feed
|
||||
$message = str_replace("\r\n", "\n", $message);
|
||||
@ -34,11 +33,11 @@ function prepare_message_body($message) {
|
||||
* 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($subject, $message, $name, $email) {
|
||||
function send_message_to_office(string $subject, string $message, string $name, string $email) {
|
||||
return mail(
|
||||
getenv('WTF_CONTACT_TO'),
|
||||
"=?UTF-8?B?" . base64_encode($subject) . "?=",
|
||||
prepare_message_body($message),
|
||||
prepare_message_body($message, $name),
|
||||
$additional_headers = array(
|
||||
"From" => getenv('WTF_CONTACT_FROM'),
|
||||
"Reply-To" => $email,
|
||||
@ -49,7 +48,7 @@ function send_message_to_office($subject, $message, $name, $email) {
|
||||
);
|
||||
}
|
||||
|
||||
function send_response($response_data) {
|
||||
function send_response(array $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