php declare(strict_types=1); // adesioni.php — Yıllık Sayfa. Kurallar tablo olarak, JSON yanıtı. $regole = [ 'ciclo' = ['max' => 3, 'ok' => fn(string $v): bool => in_array($v, ['nov', 'gen', 'mar'], true)], 'cosa' => ['max' => 8, 'ok' => fn(string $v): bool => in_array($v, ['fondo', 'polizza', 'entrambi'], true)], 'carta' => ['max' => 2, 'ok' => fn(string $v): bool => in_array($v, ['si', 'no'], true)], 'nome' => ['max' => 70, 'ok' => fn(string $v): bool => mb_strlen($v) >= 3], 'email' => ['max' => 120, 'ok' => fn(string $v): bool => (bool) filter_var($v, FILTER_VALIDATE_EMAIL)], 'consenso' => ['max' => 1, 'ok' => fn(string $v): bool => $v === '1'], ]; $cicli = ['nov' => '16–27 Kasım 2026', 'gen' => '11–22 Ocak 2027', 'mar' => '8–19 Mart 2027']; $casella = 'contact@teetotalismwccaxings.digital'; $json = str_contains($_SERVER['HTTP_ACCEPT'] ?? '', 'json'); $fine = function (array $r, int $codice = 200) use ($json): never { if (!$json) { http_response_code($r['ok'] ? 200 : $codice); header('Content-Type: text/html; charset=utf-8'); $testo = $r['ok'] ? 'Başvuru alındı, kod ' . $r['codice'] . '. Havale bilgilerini ileteceğiz.' : $r['messaggio']; echo ' Yıllık Sayfa

' . htmlspecialchars($testo, ENT_QUOTES, 'UTF-8') . '

Forma geri dön · Yıllık Sayfa

Aksaray, Küçük Langa Cd. No:42, 34096, İstanbul, Türkiye

+90 412 773 99 10

contact@teetotalismwccaxings.digital

'; exit; } http_response_code($codice); header('Content-Type: application/json; charset=utf-8'); echo json_encode($r, JSON_UNESCAPED_UNICODE); exit; }; if (($_SERVER['REQUEST_METHOD'] ?? '') !== 'POST') { http_response_code(405); header('Allow: POST'); exit; } $codice = 'PA-' . date('md') . '-' . random_int(1000, 9999); // gizli alan ya da altı saniyeden daha kısa sürede üç adım: insan değil $aperto = (int) ($_POST['aperto'] ?? 0); if (!empty($_POST['website']) || $aperto === 0 || (int) round(microtime(true) * 1000) - $aperto < 6000) { $fine(['ok' => true, 'codice' => $codice]); } $dati = []; $errori = []; foreach ($regole as $campo => $r) { $v = $_POST[$campo] ?? ''; $v = is_string($v) ? mb_substr(trim(strip_tags(preg_replace('/\s+/u', ' ', $v))), 0, $r['max']) : ''; if (!$r['ok']($v)) $errori[] = $campo; $dati[$campo] = $v; } if ($errori) { $fine(['ok' => false, 'messaggio' => 'Gözden geçirilecek: ' . implode(', ', $errori) . '.'], 422); } $testo = "Başvuru $codice\n\nAd: {$dati['nome']}\nMail: {$dati['email']}\nDönem: {$cicli[$dati['ciclo']]}\n" . "Sahip: {$dati['cosa']}\nKağıtta özet: {$dati['carta']}\n"; $testa = "From: Yıllık Sayfa <$casella>\r\nReply-To: {$dati['email']}\r\nContent-Type: text/plain; charset=UTF-8\r\n"; $ok = @mail($casella, '=?UTF-8?B?' . base64_encode("Başvuru $codice") . '?=', $testo, $testa, '-f' . $casella); $fine($ok ? ['ok' => true, 'codice' => $codice] : ['ok' => false, 'messaggio' => 'E-posta gönderilemedi. +90 XXX XXX XX XX numarasından bize ulaşın.'], $ok ? 200 : 503);