diff --git a/webstatistics.php b/webstatistics.php index 8ae22d2..56a6ae0 100644 --- a/webstatistics.php +++ b/webstatistics.php @@ -48,6 +48,8 @@ $top_continents["?"] = $country[1]; } } +$top_origins = array_merge($top_countries, $top_continents); +asort($top_origins); arsort($top_continents); $total_countries = 0; $top_countriesvo = array(); @@ -70,12 +72,25 @@ } } $top_useragents = array(); -foreach($web_analytics_db->query("SELECT `user_agent`, COUNT(*) FROM wa_browsers GROUP BY `user_agent` ORDER BY COUNT(*) DESC;") as $useragent) { +$top_browsers = array(); +$top_oss = array(); +foreach($web_analytics_db->query("SELECT `user_agent`, COUNT(*) FROM wa_browsers GROUP BY `user_agent` ORDER BY COUNT(*) DESC LIMIT 10;") as $useragent) { $top_useragents[$useragent[0]] = $useragent[1]; + $uaa = analyse_user_agent($useragent[0]); + if(isset($top_browsers[$uaa["browser"]["name"]])) { + $top_browsers[$uaa["browser"]["name"]] += $useragent[1]; + } else { + $top_browsers[$uaa["browser"]["name"]] = $useragent[1]; + } + if(isset($top_oss[$uaa["os"]["name"]])) { + $top_oss[$uaa["os"]["name"]] += $useragent[1]; + } else { + $top_oss[$uaa["os"]["name"]] = $useragent[1]; + } } $total_isps = 0; $top_isps = array(); -foreach($web_analytics_db->query("SELECT `isp`, COUNT(*) FROM wa_ips GROUP BY `isp` ORDER BY COUNT(*) DESC;") as $isp) { +foreach($web_analytics_db->query("SELECT `isp`, COUNT(*) FROM wa_ips GROUP BY `isp` ORDER BY COUNT(*) DESC LIMIT 10;") as $isp) { if($isp[0] != "" && $isp[0] != null) { $top_isps[$isp[0]] = $isp[1]; $total_isps++; @@ -84,9 +99,73 @@ } } $top_uris = array(); -foreach($web_analytics_db->query("SELECT `uri`, COUNT(*) FROM wa_requests GROUP BY `uri` ORDER BY COUNT(*) DESC;") as $uri) { +foreach($web_analytics_db->query("SELECT `uri`, COUNT(*) FROM wa_requests GROUP BY `uri` ORDER BY COUNT(*) DESC LIMIT 10;") as $uri) { $top_uris[$uri[0]] = $uri[1]; } +$last_requests = array(); +$last_requests_by_daytime = array(); +$last_requests_by_day = array(); +$last_requests_by_weekday = array(); +$last_visitors = array(); +$last_visitors_by_daytime = array(); +$last_visitors_by_day = array(); +$last_visitors_by_weekday = array(); +foreach($web_analytics_db->query("SELECT `time`, `browser_id` FROM wa_requests ORDER BY `time` ASC LIMIT 1000;") as $request) { + $time = $request[0]; + $daytime = date("[H, 0, 0]", strtotime($time)); + $day = date("Y, m, d", strtotime($time)); + $weekday = date("l", strtotime($time)); + if(isset($last_requests[$time])) { + $last_requests[$time] += 1; + } else { + $last_requests[$time] = 1; + } + if(isset($last_requests_by_day[$day])) { + $last_requests_by_day[$day] += 1; + } else { + $last_requests_by_day[$day] = 1; + } + if(isset($last_requests_by_weekday[$weekday])) { + $last_requests_by_weekday[$weekday] += 1; + } else { + $last_requests_by_weekday[$weekday] = 1; + } + if(isset($last_requests_by_daytime[$daytime])) { + $last_requests_by_daytime[$daytime] += 1; + } else { + $last_requests_by_daytime[$daytime] = 1; + } + if(isset($last_visitors[$time])) { + if(!isset($last_visitors[$time][$request[1]])) { + $last_visitors[$time][$request[1]] = 1; + } + } else { + $last_visitors[$time] = array($request[1] => 1); + } + if(isset($last_visitors_by_day[$day])) { + if(!isset($last_visitors_by_day[$day][$request[1]])) { + $last_visitors_by_day[$day][$request[1]] = 1; + } + } else { + $last_visitors_by_day[$day] = array($request[1] => 1); + } + if(isset($last_visitors_by_weekday[$weekday])) { + if(!isset($last_visitors_by_weekday[$weekday][$request[1]])) { + $last_visitors_by_weekday[$weekday][$request[1]] = 1; + } + } else { + $last_visitors_by_weekday[$weekday] = array($request[1] => 1); + } + if(isset($last_visitors_by_daytime[$daytime])) { + if(!isset($last_visitors_by_daytime[$daytime][$request[1]])) { + $last_visitors_by_daytime[$daytime][$request[1]] = 1; + } + } else { + $last_visitors_by_daytime[$daytime] = array($request[1] => 1); + } +} +ksort($last_requests_by_daytime); +ksort($last_visitors_by_daytime); ?> @@ -99,151 +178,501 @@ -