index.php aktualisiert
This commit is contained in:
505
index.php
505
index.php
@ -3,32 +3,29 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>E-Mail Analyse</title>
|
||||
<title>E-Mail Phishing Analyse</title>
|
||||
<style>
|
||||
/* CSS aus der Mehrwertsteuerrechner-Datei */
|
||||
body {
|
||||
font-family: Arial, sans-serif; /* Arial als Standardschriftart */
|
||||
background-color: #fff; /* Weißer Hintergrund */
|
||||
font-family: Arial, sans-serif;
|
||||
background-color: #f4f4f4;
|
||||
color: #333;
|
||||
line-height: 1.6;
|
||||
margin: 0;
|
||||
padding: 20px;
|
||||
}
|
||||
.container {
|
||||
max-width: 900px; /* Angepasst für E-Mail-Analyse */
|
||||
max-width: 900px;
|
||||
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 */
|
||||
border: 1px solid #a81212;
|
||||
}
|
||||
h1, h2, h3 {
|
||||
h1 {
|
||||
text-align: center;
|
||||
color: #a81212; /* Akzentfarbe für Überschrift */
|
||||
color: #a81212;
|
||||
margin-bottom: 30px;
|
||||
border-bottom: 1px solid #eee; /* Beibehalten für Struktur */
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
.form-group {
|
||||
margin-bottom: 20px;
|
||||
@ -38,101 +35,105 @@
|
||||
margin-bottom: 8px;
|
||||
font-weight: bold;
|
||||
}
|
||||
input[type="file"] { /* Angepasst für Dateiupload */
|
||||
input[type="file"] {
|
||||
width: calc(100% - 22px);
|
||||
padding: 10px;
|
||||
border: 1px solid #a81212;
|
||||
margin-bottom: 10px;
|
||||
border: 1px solid #ddd;
|
||||
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 */
|
||||
display: none; /* Versteckt das Standard-Input-Feld */
|
||||
}
|
||||
button[type="submit"], .back-button { /* Angepasst von input[type="submit"] */
|
||||
input[type="submit"] {
|
||||
background-color: #a81212;
|
||||
color: white;
|
||||
padding: 12px 20px;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
font-size: 16px;
|
||||
width: 100%;
|
||||
font-weight: bold;
|
||||
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 */
|
||||
width: 100%;
|
||||
padding: 10px; /* Einheitlicher Abstand */
|
||||
border-radius: 4px; /* Einheitlicher Radius */
|
||||
}
|
||||
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 */
|
||||
input[type="submit"]:hover {
|
||||
background-color: #8c0f0f;
|
||||
}
|
||||
.error {
|
||||
background-color: #f8d7da;
|
||||
border: 1px solid #f5c6cb;
|
||||
color: #721c24;
|
||||
background-color: #ffe0e0;
|
||||
color: #cc0000;
|
||||
border: 1px solid #cc0000;
|
||||
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 */
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.warning {
|
||||
background-color: #fff3cd; /* Gelb für Warnungen */
|
||||
color: #856404;
|
||||
border-color: #ffeeba;
|
||||
font-weight: bold;
|
||||
}
|
||||
.phishing-tendency {
|
||||
background-color: #fff3cd;
|
||||
color: #664d03;
|
||||
border: 1px solid #ffc107;
|
||||
padding: 15px;
|
||||
border-radius: 5px;
|
||||
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;
|
||||
.result {
|
||||
background-color: #e0ffe0;
|
||||
color: #008000;
|
||||
border: 1px solid #008000;
|
||||
padding: 15px;
|
||||
max-height: 400px;
|
||||
overflow-y: auto;
|
||||
white-space: pre-wrap;
|
||||
border-radius: 5px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.result h2 {
|
||||
color: #008000;
|
||||
margin-top: 0;
|
||||
}
|
||||
.phishing-high {
|
||||
background-color: #ffe0e0;
|
||||
color: #cc0000;
|
||||
border: 1px solid #cc0000;
|
||||
}
|
||||
.phishing-low {
|
||||
background-color: #e6ffe6;
|
||||
color: #008000;
|
||||
border: 1px solid #008000;
|
||||
}
|
||||
.result-section {
|
||||
margin-top: 30px;
|
||||
border-top: 1px solid #eee;
|
||||
padding-top: 20px;
|
||||
}
|
||||
.result-section h3 {
|
||||
color: #a81212;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
.header-table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.header-table th, .header-table td {
|
||||
border: 1px solid #ddd;
|
||||
padding: 8px;
|
||||
text-align: left;
|
||||
word-break: break-all;
|
||||
color: #333;
|
||||
}
|
||||
.header-table th {
|
||||
background-color: #f2f2f2;
|
||||
width: 150px;
|
||||
}
|
||||
pre {
|
||||
background-color: #eee;
|
||||
padding: 15px;
|
||||
border-radius: 5px;
|
||||
overflow-x: auto;
|
||||
white-space: pre-wrap;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
footer {
|
||||
text-align: center;
|
||||
margin-top: 40px;
|
||||
font-size: 0.9em;
|
||||
color: #777;
|
||||
font-size: 0.9em;
|
||||
}
|
||||
footer a {
|
||||
color: #a81212;
|
||||
@ -142,38 +143,28 @@
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
/* Drag & Drop Feld CSS */
|
||||
.drop-area {
|
||||
border: 3px dashed #a81212;
|
||||
/* Drag and Drop Styles */
|
||||
.drop-zone {
|
||||
border: 2px dashed #a81212;
|
||||
border-radius: 8px;
|
||||
padding: 40px 20px;
|
||||
padding: 40px;
|
||||
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-zone.highlight {
|
||||
background-color: #f0f8ff;
|
||||
border-color: #007bff;
|
||||
}
|
||||
.drop-area p {
|
||||
.drop-zone p {
|
||||
margin: 0;
|
||||
color: #555;
|
||||
}
|
||||
.drop-area input[type="file"] {
|
||||
display: none; /* Verstecke das ursprüngliche Dateiauswahlfeld */
|
||||
.drop-zone input {
|
||||
display: none;
|
||||
}
|
||||
.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;
|
||||
@ -182,173 +173,195 @@
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>E-Mail Analyse-Tool</h1>
|
||||
<h1>E-Mail Phishing Analyse</h1>
|
||||
|
||||
<form action="process_email.php" method="post" enctype="multipart/form-data" id="uploadForm">
|
||||
<div class="form-group">
|
||||
<label for="email_file">E-Mail (.eml oder .txt) hochladen:</label>
|
||||
<div id="drop_zone" class="drop-zone">
|
||||
<input type="file" name="email_file" id="email_file" accept=".eml,.txt">
|
||||
<p>E-Mail-Datei hierher ziehen oder klicken zum Auswählen</p>
|
||||
<div id="file_name_display" class="file-name-display"></div>
|
||||
</div>
|
||||
</div>
|
||||
<input type="submit" value="E-Mail analysieren">
|
||||
</form>
|
||||
|
||||
<?php
|
||||
$errors = []; // Initialisiere $errors am Anfang, um es immer verfügbar zu haben
|
||||
// PHP-Fehler anzeigen (nur für Entwicklung, im Produktivsystem deaktivieren)
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
|
||||
if (isset($_GET['result'])) {
|
||||
$result = json_decode(base64_decode($_GET['result']), true);
|
||||
// --- Eigene Log-Funktion für index.php ---
|
||||
function log_index_message($message) {
|
||||
$log_file = __DIR__ . '/index_analysis.log';
|
||||
$timestamp = date('Y-m-d H:i:s');
|
||||
file_put_contents($log_file, "$timestamp: $message\n", FILE_APPEND | LOCK_EX);
|
||||
}
|
||||
|
||||
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>';
|
||||
log_index_message("index.php loaded.");
|
||||
|
||||
$tempDir = __DIR__ . '/temp_results/'; // Muss mit process_email.php übereinstimmen
|
||||
|
||||
if (isset($_GET['error'])) {
|
||||
$errorMessage = htmlspecialchars($_GET['error']);
|
||||
echo '<div class="error"><p>Fehler: ' . $errorMessage . '</p></div>';
|
||||
log_index_message("Error displayed: " . $errorMessage);
|
||||
} elseif (isset($_GET['result_id'])) {
|
||||
$resultId = basename($_GET['result_id']); // basename zur Sicherheit
|
||||
$tempFilePath = $tempDir . $resultId;
|
||||
|
||||
log_index_message("Attempting to read result from: " . $tempFilePath);
|
||||
|
||||
if (file_exists($tempFilePath) && is_readable($tempFilePath)) {
|
||||
$jsonResult = file_get_contents($tempFilePath);
|
||||
|
||||
// Temporäre Datei löschen (optional, aber empfohlen für Aufräumen)
|
||||
unlink($tempFilePath); // Jetzt aktiviert für das Aufräumen
|
||||
log_index_message("Temp file read. Deletion status: " . (file_exists($tempFilePath) ? "NOT DELETED" : "DELETED"));
|
||||
|
||||
|
||||
if ($jsonResult === false) {
|
||||
log_index_message("ERROR: Failed to read content from temp file: " . $tempFilePath);
|
||||
echo '<div class="error"><p>Fehler: Analyseergebnisse konnten nicht gelesen werden.</p></div>';
|
||||
} else {
|
||||
$result = json_decode($jsonResult, true);
|
||||
|
||||
if (json_last_error() !== JSON_ERROR_NONE) {
|
||||
log_index_message("ERROR: JSON decoding failed: " . json_last_error_msg());
|
||||
echo '<div class="error"><p>Fehler: Analyseergebnisse konnten nicht dekodiert werden. (' . json_last_error_msg() . ')</p></div>';
|
||||
} elseif (is_array($result)) {
|
||||
log_index_message("Analysis results successfully loaded and decoded.");
|
||||
$headers = $result['headers'] ?? [];
|
||||
$phishingWarnings = $result['phishing_check'] ?? [];
|
||||
$isPhishingTendency = $result['is_phishing_tendency'] ?? false;
|
||||
$fullEmailPreview = $result['full_email_preview'] ?? 'Keine Vorschau verfügbar.';
|
||||
|
||||
$phishingClass = $isPhishingTendency ? 'phishing-high' : 'phishing-low';
|
||||
$phishingText = $isPhishingTendency ? 'Hohe Phishing-Tendenz erkannt!' : 'Geringe Phishing-Tendenz erkannt.';
|
||||
|
||||
echo '<div class="result ' . $phishingClass . '">';
|
||||
echo '<h2>Analyse Ergebnis:</h2>';
|
||||
echo '<p><strong>' . $phishingText . '</strong></p>';
|
||||
echo '</div>';
|
||||
|
||||
if (!empty($phishingWarnings)) {
|
||||
echo '<div class="warning">';
|
||||
echo '<h3>Phishing Warnungen:</h3>';
|
||||
echo '<ul>';
|
||||
foreach ($phishingWarnings as $warning) {
|
||||
echo '<li>' . htmlspecialchars($warning) . '</li>';
|
||||
}
|
||||
echo '</ul>';
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
echo '<div class="result-section">';
|
||||
echo '<h3>Gefundene E-Mail-Header:</h3>';
|
||||
if (!empty($headers)) {
|
||||
echo '<table class="header-table">';
|
||||
echo '<thead><tr><th>Header</th><th>Wert</th></tr></thead>';
|
||||
echo '<tbody>';
|
||||
foreach ($headers as $name => $value) {
|
||||
echo '<tr>';
|
||||
echo '<td>' . htmlspecialchars($name) . '</td>';
|
||||
echo '<td>' . htmlspecialchars($value) . '</td>';
|
||||
echo '</tr>';
|
||||
}
|
||||
echo '</tbody>';
|
||||
echo '</table>';
|
||||
} else {
|
||||
echo '<p>Keine Header gefunden oder verarbeitet.</p>';
|
||||
}
|
||||
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 '<h3>E-Mail-Vorschau (erste 2000 Zeichen):</h3>';
|
||||
echo '<pre>' . htmlspecialchars($fullEmailPreview) . '</pre>';
|
||||
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>';
|
||||
log_index_message("ERROR: Decoded result is not an array.");
|
||||
echo '<div class="error"><p>Fehler: Ungültiges Analyseergebnisformat.</p></div>';
|
||||
}
|
||||
|
||||
|
||||
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
|
||||
log_index_message("ERROR: Temp file not found or not readable: " . $tempFilePath);
|
||||
echo '<div class="error"><p>Fehler: Analyseergebnisse nicht gefunden oder nicht zugänglich.</p></div>';
|
||||
}
|
||||
}
|
||||
|
||||
// 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>
|
||||
|
||||
<script>
|
||||
const dropZone = document.getElementById('drop_zone');
|
||||
const fileInput = document.getElementById('email_file');
|
||||
const fileNameDisplay = document.getElementById('file_name_display');
|
||||
const uploadForm = document.getElementById('uploadForm');
|
||||
|
||||
// Verhindere Standard-Browser-Verhalten für Drag & Drop
|
||||
dropZone.addEventListener('dragover', (e) => {
|
||||
e.preventDefault();
|
||||
dropZone.classList.add('highlight');
|
||||
});
|
||||
|
||||
dropZone.addEventListener('dragleave', () => {
|
||||
dropZone.classList.remove('highlight');
|
||||
});
|
||||
|
||||
dropZone.addEventListener('drop', (e) => {
|
||||
e.preventDefault();
|
||||
dropZone.classList.remove('highlight');
|
||||
|
||||
const files = e.dataTransfer.files;
|
||||
if (files.length > 0) {
|
||||
const file = files[0];
|
||||
handleFile(file);
|
||||
}
|
||||
});
|
||||
|
||||
// Dateiauswahl über Klick
|
||||
dropZone.addEventListener('click', () => {
|
||||
fileInput.click();
|
||||
});
|
||||
|
||||
fileInput.addEventListener('change', (e) => {
|
||||
const file = e.target.files[0];
|
||||
handleFile(file);
|
||||
});
|
||||
|
||||
function handleFile(file) {
|
||||
if (file) {
|
||||
const allowedExtensions = ['eml', 'txt'];
|
||||
const fileExtension = file.name.split('.').pop().toLowerCase();
|
||||
|
||||
if (allowedExtensions.includes(fileExtension)) {
|
||||
// Weisen Sie die Datei dem Input-Feld zu
|
||||
const dataTransfer = new DataTransfer();
|
||||
dataTransfer.items.add(file);
|
||||
fileInput.files = dataTransfer.files;
|
||||
|
||||
fileNameDisplay.textContent = 'Ausgewählte Datei: ' + file.name;
|
||||
fileNameDisplay.style.color = '#008000'; // Grüne Farbe für ausgewählte Datei
|
||||
} else {
|
||||
fileNameDisplay.textContent = 'Ungültiger Dateityp. Bitte .eml oder .txt hochladen.';
|
||||
fileNameDisplay.style.color = '#cc0000'; // Rote Farbe für Fehler
|
||||
fileInput.value = ''; // Input leeren
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Formular-Validierung vor dem Absenden (optional, aber empfohlen)
|
||||
uploadForm.addEventListener('submit', (e) => {
|
||||
if (!fileInput.files || fileInput.files.length === 0) {
|
||||
alert('Bitte wählen Sie eine E-Mail-Datei aus, bevor Sie analysieren.');
|
||||
e.preventDefault(); // Formular nicht absenden
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user