[], "weekly" => [], "monthly" => [], "total" => 0, "visitors" => [], "user_agents" => [], "locations" => [] ]; // Funktion för att hämta geodata från IP function getGeoData($ip) { $geoAPI = "http://ip-api.com/json/$ip?fields=status,country,lat,lon"; $response = @file_get_contents($geoAPI); if ($response) { $result = json_decode($response, true); if ($result['status'] === "success") { return [ "country" => $result['country'], "lat" => $result['lat'], "lng" => $result['lon'] ]; } } return ["country" => "Unknown", "lat" => 0, "lng" => 0]; } // Hämta geodata om besökaren är ny if (!isset($data["visitors"][$visitorIP])) { $geoData = getGeoData($visitorIP); $data["visitors"][$visitorIP] = [ "first" => time(), "last" => time(), "count" => 1, "country" => $geoData["country"] ]; $data["locations"][$visitorIP] = [ "lat" => $geoData["lat"], "lng" => $geoData["lng"] ]; } else { $data["visitors"][$visitorIP]["last"] = time(); $data["visitors"][$visitorIP]["count"]++; } // Räkna besökare per webbläsare $data["user_agents"][$userAgent] = ($data["user_agents"][$userAgent] ?? 0) + 1; // Räkna besökare per land $country = $data["visitors"][$visitorIP]["country"]; $data["countries"][$country] = ($data["countries"][$country] ?? 0) + 1; // Om besökaren är ny idag, lägg till den i statistiken if (!isset($data["daily"][$date][$visitorIP])) { $data["daily"][$date][$visitorIP] = true; $data["weekly"][$week][$visitorIP] = true; $data["monthly"][$month][$visitorIP] = true; $data["total_unique"] = isset($data["total_unique"]) ? $data["total_unique"] + 1 : 1; // Räkna unika besökare totalt } // Spara uppdaterad räknardata i lättläst format file_put_contents($counterFile, json_encode($data, JSON_PRETTY_PRINT)); ?>
Preview your video on an LED Rollup by clicking 'Select Video'. The video must be in MP4 format and have dimensions 256 x 768 pixels.