HEX
Server: Apache/2.4.46 (Win64) OpenSSL/1.1.1j PHP/8.4.25
System: Windows NT DESKTOP-4TAV2RJ 10.0 build 19045 (Windows 10) AMD64
User: fred (0)
PHP: 8.4.25
Disabled: NONE
Upload Files
File: C:/Users/fred/AppData/Roaming/Code/User/History/655c119a/hFHU.php
<?php
date_default_timezone_set('Asia/Taipei');
$logFile = 'visitor_log.csv';
$visitors = [];

// Load the last 20 visitors from the CSV
if (file_exists($logFile)) {
    $rows = array_map('str_getcsv', file($logFile));
    $visitors = array_reverse($rows); // Newest first
}
?>

<div class="card">
    <h3>Recent Visitors (IP & Area)</h3>
    <div style="overflow-x: auto;">
        <table style="width:100%; border-collapse: collapse; font-size: 0.85rem;">
            <thead>
                <tr style="background:#f0f2f5;">
                    <th style="padding:8px;">Time</th>
                    <th style="padding:8px;">Script</th>
                    <th style="padding:8px;">IP</th>
                    <th style="padding:8px;">Area</th>
                </tr>
            </thead>
            <tbody>
                <?php 
                $displayCount = 0;
                foreach($visitors as $v): 
                    if($displayCount >= 15) break; // Only show last 15
                ?>
                <tr>
                    <td style="padding:8px; border-bottom:1px solid #eee; white-space: nowrap;"><?php echo substr($v[0], 5, 11); ?></td>
                    <td style="padding:8px; border-bottom:1px solid #eee;"><?php echo htmlspecialchars($v[1]); ?></td>
                    <td style="padding:8px; border-bottom:1px solid #eee; color:#1877f2;"><?php echo $v[2]; ?></td>
                    <td style="padding:8px; border-bottom:1px solid #eee;"><b><?php echo htmlspecialchars($v[3]); ?></b></td>
                </tr>
                <?php 
                $displayCount++;
                endforeach; 
                ?>
            </tbody>
        </table>
    </div>
</div>