45 lines
1.6 KiB
PHP
45 lines
1.6 KiB
PHP
<?php
|
|
error_reporting(0);
|
|
header('Content-Type: application/json');
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
$inputJSON = file_get_contents('php://input');
|
|
$input = json_decode($inputJSON, true);
|
|
|
|
if (!$input || empty($input['email'])) {
|
|
http_response_code(400);
|
|
echo json_encode(['error' => 'Ungültige Eingabe']);
|
|
exit;
|
|
}
|
|
|
|
$email = filter_var($input['email'], FILTER_SANITIZE_EMAIL);
|
|
|
|
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
|
http_response_code(400);
|
|
echo json_encode(['error' => 'Ungültige E-Mail Adresse']);
|
|
exit;
|
|
}
|
|
|
|
// Send notification to Ntfy
|
|
$ntfyUrl = 'https://ntfy.orfel.de/Schnappix-App-Testing';
|
|
$message = "Eine neue Anfrage für das Schnappix App Testing ist eingegangen!\n\nE-Mail: $email\n\nBitte prüfen und ggf. die Registrierungslinks via E-Mail versenden.";
|
|
|
|
$ch = curl_init($ntfyUrl);
|
|
curl_setopt($ch, CURLOPT_POST, 1);
|
|
curl_setopt($ch, CURLOPT_POSTFIELDS, $message);
|
|
curl_setopt($ch, CURLOPT_HTTPHEADER, [
|
|
'Title: Neue Tester-Anmeldung',
|
|
'Tags: mobile_phone,warning,bust_in_silhouette',
|
|
'Click: mailto:' . $email . '?subject=Schnappix%20App%20Testing%20-%20Einladung&body=Hallo,%0A%0Avielen%20Dank%20f%C3%BCr%20dein%20Interesse%20als%20Tester!%20Hier%20sind%20die%20Links:%0A'
|
|
]);
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
|
|
curl_exec($ch);
|
|
curl_close($ch);
|
|
|
|
echo json_encode(['success' => true]);
|
|
exit;
|
|
}
|
|
http_response_code(405);
|
|
echo json_encode(['error' => 'Method not allowed']);
|