'; echo ''; // Check for file upload errors if ($fileError !== UPLOAD_ERR_OK) { echo "

Error in file upload: " . $fileError . "

"; exit; } // Validate file type (XML) if ($fileType != "xml") { echo "

Only XML files are allowed.

"; exit; } // Load XML file libxml_use_internal_errors(true); $xml = simplexml_load_file($file); $errors = libxml_get_errors(); libxml_clear_errors(); // Check if it's a valid DMARC XML if ($xml === false || !empty($errors)) { echo "

Failed to parse the XML file. Ensure it's a valid DMARC report.

"; foreach ($errors as $error) { echo "

Error: " . htmlspecialchars($error->message) . "

"; } exit; } // Verify XML structure if (!isset($xml->report_metadata, $xml->policy_published, $xml->record)) { echo "

Invalid DMARC report structure.

"; exit; } // Extract and display data echo "

DMARC Report Summary

"; $orgName = $xml->report_metadata->org_name; echo "

Organization: $orgName

"; $domain = $xml->policy_published->domain; $policy = $xml->policy_published->p; echo "

Domain: $domain

"; echo "

Policy: $policy

"; // Process record data echo "

Details of Email Activity

"; echo ""; foreach ($xml->record as $record) { $sourceIp = $record->row->source_ip; $count = $record->row->count; $evaluatedPolicy = $record->row->policy_evaluated; $spfResult = $evaluatedPolicy->spf; $dkimResult = $evaluatedPolicy->dkim; echo ""; echo ""; echo ""; echo ""; echo ""; // Plain English Explanation $explanation = getExplanation($spfResult, $dkimResult); echo ""; echo ""; } echo "
Source IPEmail CountSPF ResultDKIM ResultExplanation
$sourceIp$count$spfResult$dkimResult$explanation
"; echo ''; } function getExplanation($spfResult, $dkimResult) { if ($spfResult == "pass" && $dkimResult == "pass") { return "Both SPF and DKIM checks passed. Emails are likely legitimate."; } elseif ($spfResult == "fail" && $dkimResult == "fail") { return "Both SPF and DKIM checks failed. Emails could be fraudulent."; } else { return "Mixed results. Further investigation needed."; } } ?>