]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - contrib/user-agents.pl
Source Format Enforcement (#763)
[thirdparty/squid.git] / contrib / user-agents.pl
index 8d1706cdf5c2feb976ccc1a2b5315435fa46de17..1202a4fdfe85d136dac3a64b663988a75abb201e 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/perl
 #
-# * Copyright (C) 1996-2017 The Squid Software Foundation and contributors
+# * Copyright (C) 1996-2021 The Squid Software Foundation and contributors
 # *
 # * Squid software is distributed under GPLv2+ license and includes
 # * contributions from numerous individuals and organizations.
@@ -17,20 +17,20 @@ require "getopts.pl";
 open (ACCESS, "/opt/Squid/logs/useragent.0");
 
 while (<ACCESS>) {
-       ($host, $timestamp, $agent) = 
-       /^(\S+) \[(.+)\] \"(.+)\"\s/;
-       if ($agent ne '-') {
-               if ($opt_M) {
-                       $agent =~ tr/\// /;
-                       $agent =~ tr/\(/ /;
-               }
-               if ($opt_F) {
-                       next unless $seen{$agent}++;
-               } else {
-                       @inline=split(/ /, $agent);
-                       next unless $seen{$inline[0]}++;
-               }
-       }
+    ($host, $timestamp, $agent) =
+        /^(\S+) \[(.+)\] \"(.+)\"\s/;
+    if ($agent ne '-') {
+        if ($opt_M) {
+            $agent =~ tr/\// /;
+            $agent =~ tr/\(/ /;
+        }
+        if ($opt_F) {
+            next unless $seen{$agent}++;
+        } else {
+            @inline=split(/ /, $agent);
+            next unless $seen{$inline[0]}++;
+        }
+    }
 }
 
 $total=0;
@@ -39,12 +39,12 @@ if (!$opt_L) {$opt_L=0}
 print "Summary of User-Agent Strings\n(greater than $opt_L percent)\n\n";
 
 foreach $browser (keys(%seen)) {
-        $total=$total+$seen{$browser};
+    $total=$total+$seen{$browser};
 }
 
 foreach $browser (sort keys(%seen)) {
-       $percent=$seen{$browser}/$total*100;
-       if ($percent >= $opt_L) { write; }
+    $percent=$seen{$browser}/$total*100;
+    if ($percent >= $opt_L) { write; }
 }
 
 print "\n\nTotal entries in log = $total\n";