Files
boc/quixzoom-shop/notify-registration.php
T

59 lines
1.8 KiB
PHP
Raw Normal View History

<?php
/**
* Simple registration notification endpoint
* Sends email to hello@quixzoom.com when someone registers
*/
header('Content-Type: application/json');
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: POST');
header('Access-Control-Allow-Headers: Content-Type');
if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') {
http_response_code(200);
exit;
}
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
http_response_code(405);
echo json_encode(['error' => 'Method not allowed']);
exit;
}
$data = json_decode(file_get_contents('php://input'), true);
if (!$data || !isset($data['phone'])) {
http_response_code(400);
echo json_encode(['error' => 'Phone number required']);
exit;
}
$phone = htmlspecialchars($data['phone']);
$country = htmlspecialchars($data['country'] ?? 'Unknown');
$lang = htmlspecialchars($data['lang'] ?? 'en');
$source = htmlspecialchars($data['source'] ?? 'unknown');
$to = 'hello@quixzoom.com';
$subject = 'New Zoomer Registration: ' . $phone;
$message = "New Zoomer Registration\n\n";
$message .= "Phone: " . $phone . "\n";
$message .= "Country: " . $country . "\n";
$message .= "Language: " . $lang . "\n";
$message .= "Source: " . $source . "\n";
$message .= "Time: " . date('Y-m-d H:i:s') . " UTC\n";
$message .= "User Agent: " . ($_SERVER['HTTP_USER_AGENT'] ?? 'Unknown') . "\n";
$message .= "IP: " . ($_SERVER['REMOTE_ADDR'] ?? 'Unknown') . "\n";
$headers = 'From: noreply@quixzoom.com' . "\r\n";
$headers .= 'Reply-To: hello@quixzoom.com' . "\r\n";
$headers .= 'X-Mailer: PHP/' . phpversion();
$success = mail($to, $subject, $message, $headers);
if ($success) {
echo json_encode(['success' => true, 'message' => 'Notification sent']);
} else {
http_response_code(500);
echo json_encode(['error' => 'Failed to send notification']);
}