354 lines
14 KiB
PHP
354 lines
14 KiB
PHP
<!DOCTYPE html>
|
|
<html lang="de">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>E-Mail Analyse</title>
|
|
<style>
|
|
/* CSS aus der Mehrwertsteuerrechner-Datei */
|
|
body {
|
|
font-family: Arial, sans-serif; /* Arial als Standardschriftart */
|
|
background-color: #fff; /* Weißer Hintergrund */
|
|
color: #333;
|
|
line-height: 1.6;
|
|
margin: 0;
|
|
padding: 20px;
|
|
}
|
|
.container {
|
|
max-width: 900px; /* Angepasst für E-Mail-Analyse */
|
|
margin: 30px auto;
|
|
background: #fff;
|
|
padding: 30px;
|
|
border-radius: 8px;
|
|
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
|
|
border: 1px solid #a81212; /* Akzentfarbe für den Rand */
|
|
}
|
|
h1, h2, h3 {
|
|
text-align: center;
|
|
color: #a81212; /* Akzentfarbe für Überschrift */
|
|
margin-bottom: 30px;
|
|
border-bottom: 1px solid #eee; /* Beibehalten für Struktur */
|
|
padding-bottom: 10px;
|
|
}
|
|
.form-group {
|
|
margin-bottom: 20px;
|
|
}
|
|
label {
|
|
display: block;
|
|
margin-bottom: 8px;
|
|
font-weight: bold;
|
|
}
|
|
input[type="file"] { /* Angepasst für Dateiupload */
|
|
width: calc(100% - 22px);
|
|
padding: 10px;
|
|
border: 1px solid #a81212;
|
|
border-radius: 4px;
|
|
box-sizing: border-box;
|
|
font-size: 16px;
|
|
display: block; /* Sicherstellen, dass es wie ein Block-Element behandelt wird */
|
|
margin-bottom: 15px; /* Abstand nach unten */
|
|
}
|
|
button[type="submit"], .back-button { /* Angepasst von input[type="submit"] */
|
|
background-color: #a81212;
|
|
color: white;
|
|
padding: 12px 20px;
|
|
border: none;
|
|
border-radius: 4px;
|
|
cursor: pointer;
|
|
font-size: 16px;
|
|
width: 100%;
|
|
transition: background-color 0.3s ease;
|
|
text-decoration: none; /* Für den Button-Link */
|
|
display: block; /* Für den Button-Link */
|
|
text-align: center; /* Für den Button-Link */
|
|
box-sizing: border-box; /* Für den Button-Link */
|
|
}
|
|
button[type="submit"]:hover, .back-button:hover {
|
|
background-color: #8f0e0e;
|
|
}
|
|
.result-section { /* Container für die Ergebnisse */
|
|
background-color: #ffe5e5;
|
|
border: 1px solid #a81212;
|
|
color: #a81212;
|
|
padding: 15px;
|
|
border-radius: 5px;
|
|
margin-top: 20px;
|
|
font-size: 1.1em;
|
|
text-align: left; /* Textausrichtung angepasst */
|
|
}
|
|
.error {
|
|
background-color: #f8d7da;
|
|
border: 1px solid #f5c6cb;
|
|
color: #721c24;
|
|
padding: 15px;
|
|
border-radius: 5px;
|
|
margin-top: 20px;
|
|
font-size: 1.1em;
|
|
text-align: center;
|
|
}
|
|
.header-section p, .phishing-section p {
|
|
background-color: #f9f9f9; /* Leichterer Hintergrund für Header-Einträge */
|
|
border-left: 5px solid #a81212; /* Akzentfarbe für Header-Balken */
|
|
padding: 10px;
|
|
margin-bottom: 10px;
|
|
word-wrap: break-word;
|
|
color: #333; /* Standardtextfarbe */
|
|
}
|
|
.warning {
|
|
background-color: #fff3cd; /* Gelb für Warnungen */
|
|
color: #856404;
|
|
border-color: #ffeeba;
|
|
font-weight: bold;
|
|
}
|
|
.phishing-tendency {
|
|
padding: 15px;
|
|
margin-bottom: 20px;
|
|
border-radius: 8px;
|
|
font-size: 1.4em;
|
|
font-weight: bold;
|
|
text-align: center;
|
|
color: white;
|
|
text-shadow: 1px 1px 2px rgba(0,0,0,0.2);
|
|
}
|
|
.phishing-tendency.red {
|
|
background-color: #dc3545; /* Rot für Phishing */
|
|
border: 1px solid #c82333;
|
|
}
|
|
.phishing-tendency.green {
|
|
background-color: #28a745; /* Grün für keine Phishing-Tendenz */
|
|
border: 1px solid #218838;
|
|
}
|
|
.full-email-preview {
|
|
background-color: #f0f0f0;
|
|
border: 1px solid #ccc;
|
|
padding: 15px;
|
|
max-height: 400px;
|
|
overflow-y: auto;
|
|
white-space: pre-wrap;
|
|
word-break: break-all;
|
|
color: #333;
|
|
}
|
|
footer {
|
|
text-align: center;
|
|
margin-top: 40px;
|
|
font-size: 0.9em;
|
|
color: #777;
|
|
}
|
|
footer a {
|
|
color: #a81212;
|
|
text-decoration: none;
|
|
}
|
|
footer a:hover {
|
|
text-decoration: underline;
|
|
}
|
|
|
|
/* Drag & Drop Feld CSS */
|
|
.drop-area {
|
|
border: 3px dashed #a81212;
|
|
border-radius: 8px;
|
|
padding: 40px 20px;
|
|
text-align: center;
|
|
font-size: 1.2em;
|
|
color: #777;
|
|
cursor: pointer;
|
|
transition: background-color 0.3s ease, border-color 0.3s ease;
|
|
margin-bottom: 20px;
|
|
background-color: #fff;
|
|
}
|
|
.drop-area.highlight {
|
|
background-color: #fff0f0;
|
|
border-color: #dc3545;
|
|
}
|
|
.drop-area p {
|
|
margin: 0;
|
|
}
|
|
.drop-area input[type="file"] {
|
|
display: none; /* Verstecke das ursprüngliche Dateiauswahlfeld */
|
|
}
|
|
.file-name-display {
|
|
margin-top: 10px;
|
|
font-size: 1em;
|
|
color: #333;
|
|
font-weight: bold;
|
|
}
|
|
/* Optional: Dateiname direkt unter dem Drag&Drop Feld */
|
|
#selectedFileName {
|
|
text-align: center;
|
|
margin-top: 10px;
|
|
font-weight: bold;
|
|
color: #a81212;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
<h1>E-Mail Analyse-Tool</h1>
|
|
|
|
<?php
|
|
$errors = []; // Initialisiere $errors am Anfang, um es immer verfügbar zu haben
|
|
|
|
if (isset($_GET['result'])) {
|
|
$result = json_decode(base64_decode($_GET['result']), true);
|
|
|
|
if ($result) {
|
|
// Zurück-Button ganz oben vor den Ergebnissen
|
|
echo '<div class="form-group" style="margin-bottom: 20px;">';
|
|
echo '<a href="index.php" class="back-button">Neue Analyse starten</a>';
|
|
echo '</div>';
|
|
|
|
echo '<div class="result-section">';
|
|
|
|
// Phishing Tendenz Anzeige
|
|
$tendencyClass = $result['is_phishing_tendency'] ? 'red' : 'green';
|
|
$tendencyText = $result['is_phishing_tendency'] ? 'Phishing-Tendenz: HOCH' : 'Phishing-Tendenz: GERING';
|
|
echo '<div class="phishing-tendency ' . $tendencyClass . '">' . $tendencyText . '</div>';
|
|
|
|
echo '<h2>Analyse-Ergebnisse:</h2>';
|
|
|
|
echo '<h3>Phishing-Prüfung (Details):</h3>';
|
|
echo '<div class="phishing-section">';
|
|
if (!empty($result['phishing_check'])) {
|
|
foreach ($result['phishing_check'] as $warning) {
|
|
echo '<p class="warning">' . htmlspecialchars($warning) . '</p>';
|
|
}
|
|
} else {
|
|
echo '<p>Keine offensichtlichen Phishing-Merkmale erkannt (Basierend auf einfacher Prüfung).</p>';
|
|
}
|
|
echo '</div>';
|
|
|
|
|
|
echo '<h3>Header-Daten:</h3>';
|
|
if (!empty($result['headers'])) {
|
|
echo '<div class="header-section">';
|
|
foreach ($result['headers'] as $name => $value) {
|
|
echo '<p><strong>' . htmlspecialchars($name) . ':</strong> ' . nl2br(htmlspecialchars($value)) . '</p>';
|
|
}
|
|
echo '</div>';
|
|
} else {
|
|
echo '<p>Keine Header-Daten gefunden oder Fehler beim Parsen.</p>';
|
|
}
|
|
|
|
|
|
echo '<h3>Vollständige E-Mail (Vorschau):</h3>';
|
|
if (isset($result['full_email_preview'])) {
|
|
echo '<pre class="full-email-preview">' . htmlspecialchars($result['full_email_preview']) . '</pre>';
|
|
} else {
|
|
echo '<p>Vorschau nicht verfügbar.</p>';
|
|
}
|
|
echo '</div>'; // Ende result-section
|
|
|
|
} else {
|
|
echo '<div class="error"><p>Fehler beim Laden der Analyse-Ergebnisse.</p></div>';
|
|
// Auch hier den Zurück-Button anzeigen, falls ein Fehler auftritt
|
|
echo '<div class="form-group" style="margin-top: 30px;">';
|
|
echo '<a href="index.php" class="back-button">Zurück zum Upload</a>';
|
|
echo '</div>';
|
|
}
|
|
} elseif (isset($_GET['error'])) {
|
|
echo '<div class="error"><p>' . htmlspecialchars($_GET['error']) . '</p></div>';
|
|
// Auch hier den Zurück-Button anzeigen, falls ein Fehler auftritt
|
|
echo '<div class="form-group" style="margin-top: 30px;">';
|
|
echo '<a href="index.php" class="back-button">Zurück zum Upload</a>';
|
|
echo '</div>';
|
|
} else {
|
|
// Zeige das Drag & Drop Feld, wenn keine Ergebnisse oder Fehler vorliegen
|
|
?>
|
|
<form id="uploadForm" action="process_email.php" method="post" enctype="multipart/form-data">
|
|
<div class="form-group">
|
|
<label for="email_file">Wählen Sie eine E-Mail-Datei zum Hochladen aus (.eml oder .txt) oder ziehen Sie sie hierher:</label>
|
|
<div id="drop-area" class="drop-area">
|
|
<input type="file" id="email_file" name="email_file" accept=".eml,.txt" required>
|
|
<p>Ziehen Sie Ihre E-Mail-Datei hierher oder klicken Sie, um sie auszuwählen.</p>
|
|
<div id="selectedFileName" class="file-name-display"></div>
|
|
</div>
|
|
</div>
|
|
<div class="form-group">
|
|
<button type="submit" id="submitButton" disabled>E-Mail analysieren</button>
|
|
</div>
|
|
</form>
|
|
|
|
<script>
|
|
const dropArea = document.getElementById('drop-area');
|
|
const fileInput = document.getElementById('email_file');
|
|
const submitButton = document.getElementById('submitButton');
|
|
const selectedFileNameDisplay = document.getElementById('selectedFileName');
|
|
const uploadForm = document.getElementById('uploadForm');
|
|
|
|
// Verhindere Standard-Drag-Verhalten
|
|
['dragenter', 'dragover', 'dragleave', 'drop'].forEach(eventName => {
|
|
dropArea.addEventListener(eventName, preventDefaults, false);
|
|
document.body.addEventListener(eventName, preventDefaults, false); // Für den gesamten Body
|
|
});
|
|
|
|
function preventDefaults(e) {
|
|
e.preventDefault();
|
|
e.stopPropagation();
|
|
}
|
|
|
|
// Highlight Drop Area, wenn Datei darüber gezogen wird
|
|
['dragenter', 'dragover'].forEach(eventName => {
|
|
dropArea.addEventListener(eventName, highlight, false);
|
|
});
|
|
|
|
['dragleave', 'drop'].forEach(eventName => {
|
|
dropArea.addEventListener(eventName, unhighlight, false);
|
|
});
|
|
|
|
function highlight() {
|
|
dropArea.classList.add('highlight');
|
|
}
|
|
|
|
function unhighlight() {
|
|
dropArea.classList.remove('highlight');
|
|
}
|
|
|
|
// Handle Dropped Files
|
|
dropArea.addEventListener('drop', handleDrop, false);
|
|
|
|
function handleDrop(e) {
|
|
const dt = e.dataTransfer;
|
|
const files = dt.files;
|
|
|
|
if (files.length > 0) {
|
|
fileInput.files = files; // Weise die gedroppten Dateien dem Input-Feld zu
|
|
updateFileNameDisplay();
|
|
}
|
|
}
|
|
|
|
// Handle File Selection via Klick
|
|
fileInput.addEventListener('change', updateFileNameDisplay);
|
|
|
|
function updateFileNameDisplay() {
|
|
if (fileInput.files.length > 0) {
|
|
const fileName = fileInput.files[0].name;
|
|
const fileExtension = fileName.split('.').pop().toLowerCase();
|
|
const allowedExtensions = ['eml', 'txt'];
|
|
|
|
if (allowedExtensions.includes(fileExtension)) {
|
|
selectedFileNameDisplay.textContent = `Ausgewählte Datei: ${fileName}`;
|
|
submitButton.disabled = false; // Aktiviere den Submit-Button
|
|
// Optional: Füge hier eine visuelle Bestätigung hinzu
|
|
} else {
|
|
selectedFileNameDisplay.textContent = `Ungültiger Dateityp: ${fileName}. Bitte .eml oder .txt wählen.`;
|
|
submitButton.disabled = true; // Deaktiviere den Submit-Button
|
|
alert('Ungültiger Dateityp. Bitte laden Sie eine .eml- oder .txt-Datei hoch.');
|
|
fileInput.value = ''; // Setze das Feld zurück
|
|
}
|
|
} else {
|
|
selectedFileNameDisplay.textContent = '';
|
|
submitButton.disabled = true; // Deaktiviere den Submit-Button
|
|
}
|
|
}
|
|
|
|
// Initialer Zustand: Button deaktiviert
|
|
updateFileNameDisplay(); // Überprüft, ob beim Laden bereits eine Datei ausgewählt ist (unwahrscheinlich)
|
|
</script>
|
|
<?php
|
|
}
|
|
?>
|
|
</div>
|
|
<footer>
|
|
© <?php echo date("Y"); ?> <a href="https://wachtel-it.de" target="_blank">Philipp Wachtel</a>
|
|
</footer>
|
|
</body>
|
|
</html>
|