-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlog.php
More file actions
75 lines (72 loc) · 3.03 KB
/
log.php
File metadata and controls
75 lines (72 loc) · 3.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
require_once 'config.php';
$rows = [];
$error = '';
if (!file_exists(ATTLOG_FILE)) {
$error = 'No attendance log file found yet.';
} else {
$decoded = json_decode((string) file_get_contents(ATTLOG_FILE), true);
if (is_array($decoded)) {
$rows = array_reverse($decoded);
} else {
$error = 'Attendance log file is not valid JSON.';
}
}
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>ATTLOG Records</title>
<style>
body { font-family: Arial, sans-serif; margin: 20px; background: #f7f7f9; color: #222; }
h1 { margin-bottom: 12px; }
.meta { margin-bottom: 16px; color: #555; }
.error { padding: 10px; background: #ffe7e7; border: 1px solid #ffb3b3; margin-bottom: 12px; }
table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { border: 1px solid #ddd; padding: 8px; text-align: left; font-size: 14px; }
th { background: #efefef; }
tr:nth-child(even) { background: #fafafa; }
.empty { padding: 12px; background: #fff; border: 1px solid #ddd; }
</style>
</head>
<body>
<h1>ATTLOG Records</h1>
<div class="meta">Total records: <?php echo count($rows); ?></div>
<?php if ($error !== ''): ?>
<div class="error"><?php echo htmlspecialchars($error, ENT_QUOTES, 'UTF-8'); ?></div>
<?php elseif (count($rows) === 0): ?>
<div class="empty">No attendance records yet.</div>
<?php else: ?>
<table>
<thead>
<tr>
<th>#</th>
<th>Device SN</th>
<th>User ID</th>
<th>Timestamp</th>
<th>Status</th>
<th>Punch</th>
<th>Stamp</th>
<th>Received At</th>
</tr>
</thead>
<tbody>
<?php foreach ($rows as $index => $row): ?>
<tr>
<td><?php echo $index + 1; ?></td>
<td><?php echo htmlspecialchars((string) ($row['device_sn'] ?? ''), ENT_QUOTES, 'UTF-8'); ?></td>
<td><?php echo htmlspecialchars((string) ($row['user_id'] ?? ''), ENT_QUOTES, 'UTF-8'); ?></td>
<td><?php echo htmlspecialchars((string) ($row['timestamp'] ?? ''), ENT_QUOTES, 'UTF-8'); ?></td>
<td><?php echo htmlspecialchars((string) ($row['status'] ?? ''), ENT_QUOTES, 'UTF-8'); ?></td>
<td><?php echo htmlspecialchars((string) ($row['punch'] ?? ''), ENT_QUOTES, 'UTF-8'); ?></td>
<td><?php echo htmlspecialchars((string) ($row['stamp'] ?? ''), ENT_QUOTES, 'UTF-8'); ?></td>
<td><?php echo htmlspecialchars((string) ($row['received_at'] ?? ''), ENT_QUOTES, 'UTF-8'); ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>
</body>
</html>