File: C:/Users/fred/AppData/Roaming/Code/User/History/655c119a/QtHS.php
<?php
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) {
// CSV Structure: [0]Time, [1]ScriptName, [2]IP, [3]Area
$script = $data[1];
$ip = $data[2];
$area = $data[3];
// Create a unique key for each Script + IP combination
$key = $script . '___' . $ip;
if (!isset($ipSummary[$key])) {
$ipSummary[$key] = [
'script' => $script,
'ip' => $ip,
'area' => $area,
'count' => 0
];
}
$ipSummary[$key]['count']++;
}
fclose($handle);
}
}
// Sort the list so the highest number of hits appears at the top
uasort($ipSummary, function($a, $b) {
return $b['count'] <=> $a['count'];
});
?>