<?php
// Laad IMAP-instellingen
$settings = include __DIR__ .
'/config/mailsettings.php';
// Verbinding maken met IMAP
$imap =
imap_open(
"{" . $settings['imap_server'] . ":" . $settings['imap_port'] .
"/imap/ssl}INBOX",
$settings['imap_user'],
$settings['imap_password']
);
// Als verbinding mislukt
if (!$imap) {
die("Kan mailbox niet
openen.");
}
// Zoek alle mails
$emails = imap_search($imap,
'ALL');
// Geen mails gevonden
if (!$emails) {
$status = "🔴 Geen
meldingen gevonden";
$last = "—";
} else {
rsort($emails); // nieuwste
eerst
$latest = $emails[0];
$header = imap_headerinfo($imap, $latest);
$timestamp = strtotime($header->date);
$last = date("d-m-Y H:i",
$timestamp);
// Bereken tijdsverschil
$diff_hours = (time() -
$timestamp) / 3600;
if ($diff_hours < 24) {
$status = "🟢 OK";
}
else {
$status = "🔴 Geen check‑in in 24 uur";
}
}
imap_close($imap);
?>
<!DOCTYPE html>
<html lang="nl">
<head>
<meta charset="UTF-8">
<title>Eric‑OK Status</title>
<style>
body {
font-family: Arial, sans-serif;
max-width: 500px;
margin: 40px auto;
padding: 20px;
background: #f7f7f7;
border-radius: 12px;
text-align:
center;
}
.status {
font-size: 48px;
margin-bottom: 20px;
}
.time {
font-size: 20px;
color: #333;
}
</style>
</head>
<body>
<div class="status"><?= $status ?></div>
<div
class="time">Laatste melding: <?= $last ?></div>
</body>
</html>