File: C:/Users/fred/AppData/Roaming/Code/User/History/655c119a/xpJx.php
<?php
// 1. DATA PROCESSING (Keep this at the very top)
date_default_timezone_set('Asia/Taipei');
$logFile = 'visitor_log.csv';
$ipSummary = [];
if (file_exists($logFile)) {
if (($handle = fopen($logFile, "r")) !== FALSE) {
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
$script = $data[1];
$ip = $data[2];
$area = $data[3];
$key = $script . '___' . $ip;
if (!isset($ipSummary[$key])) {
$ipSummary[$key] = ['script' => $script, 'ip' => $ip, 'area' => $area, 'count' => 0];
}
$ipSummary[$key]['count']++;
}
fclose($handle);
}
}
uasort($ipSummary, function($a, $b) { return $b['count'] <=> $a['count']; });
?>
<!DOCTYPE html>
<html lang="zh-Hant">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Download Dashboard</title>
<style>
/* All the CSS styles go here */
body { font-family: sans-serif; background: #f0f2f5; padding: 20px; }
.card { background: white; border-radius: 8px; padding: 20px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); margin-bottom: 20px; }
table { width: 100%; border-collapse: collapse; margin-top: 10px; }
th, td { padding: 12px; border-bottom: 1px solid #eee; text-align: left; }
.badge { background: #333; color: white; padding: 2px 8px; border-radius: 10px; }
</style>
</head>
<body>
<h1>PBN Tool Statistics</h1>
<div class="card">
<h3>Hits by Script & IP (Grouped)</h3>
<p style="font-size: 0.8rem; color: #666;">Grouped by unique IP per script</p>
<div style="overflow-x: auto;">
<table>
<thead>
<tr style="background:#f8f9fa;">
<th>Script</th>
<th>IP Address</th>
<th>Area</th>
<th style="text-align:center;">Total Hits</th>
</tr>
</thead>
<tbody>
<?php foreach($ipSummary as $item): ?>
<tr>
<td><code><?php echo htmlspecialchars($item['script']); ?></code></td>
<td style="color:#1877f2;"><?php echo $item['ip']; ?></td>
<td><?php echo htmlspecialchars($item['area']); ?></td>
<td style="text-align:center;"><span class="badge"><?php echo $item['count']; ?></span></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
</body>
</html>