hide random home http://www.byte.com/art/download/browsers.pl (PC Press Internet CD, 03/1996)

# BROWSERS - Analyze link-tracking log by browser and OS # # Expects ADVDIR to contain one or more custom log files written by LOGLINK. # # Jon Udell, BYTE, jon_u@dev5.byte.com,judell@bix.com require '/cgi-bin/cgi-lib.pl'; print &cgi_PrintHeader; print "Browser stats since 10/10/95"; print ""; print &cgi_StdHdr(1); print "

Browser stats since 10/10/95

"; opendir(ADVDIR,"/log/") || print "

Cannot open stats dir."; @advs = grep (!/^\.|^\.\./,sort readdir(ADVDIR)); foreach $adv (@advs) { open (HITS, "d:/jon/adv/$adv") || die "Cannot open stats file."; while () { chop; if (/Mozilla/ && !/MSIE/) # watch out for "cloaked" MSIE! {$Mozilla++;} if (/Mosaic/) {$Mosaic++;} if (/Microsoft/ || /MSIE/) {$Microsoft++;} if (/Lynx/) {$Lynx++;} if (/WebExplorer/) {$WebExplorer++;} if (/NetCruiser/) {$NetCruiser++;} if (/Windows|Microsoft|Win32|Quarterdeck|Chameleon|AIR_Mosaic|SPRY_Mosaic|Win16|WinNT|WindowsNT|Win95/) {$Windows++;} if (/Macintosh/) {$Macintosh++;} if (/X11|X Window/) {$UnixGUI++;} if (/Lynx/) {$UnixText++;} if (/WebExplorer/) {$OS2++;} ($date, $dow, $time, $ip, $browser) = split(/ ~ /); $BrowserList{$browser}++; $links++; } } $hits = 0; foreach $browser (sort keys %BrowserList) { $hits += $BrowserList{$browser}; push (@items,sprintf("%-40.40s%5.5s\n",$browser,$BrowserList{$browser})); } print ""; print ""; print ""; print sprintf ("", $Mozilla, $Mozilla/$hits); print sprintf ("", $Mosaic, $Mosaic/$hits); print sprintf ("", $Microsoft, $Microsoft/$hits); print sprintf ("", $Lynx, $Lynx/$hits); print sprintf ("", $WebExplorer, $WebExplorer/$hits); print sprintf ("", $NetCruiser, $NetCruiser/$hits); print sprintf ("", $Mozilla+$Mosaic+$Microsoft+$Lynx+$WebExplorer+$NetCruiser, ($Mozilla+$Mosaic+$Microsoft+$Lynx+$WebExplorer+$NetCruiser)/$hits); print "
Browser summary
BrowserHits%
Netscape%d%.2f
Mosaic%d%.2f
Microsoft%d%.2f
Lynx%d%.2f
WebExplorer%d%.2f
NetCruiser%d%.2f
Accounted for%d%.2f
"; print "

"; print ""; print ""; print sprintf ("", $Windows, $Windows/$hits); print sprintf ("", $UnixGUI, $UnixGUI/$hits); print sprintf ("", $UnixText, $UnixText/$hits); print sprintf ("", $Macintosh, $Macintosh/$hits); print sprintf ("", $OS2, $OS2/$hits); print sprintf ("", $Windows+$Macintosh+$UnixGUI+$UnixText+$OS2, ($Windows+$Macintosh+$UnixGUI+$UnixText+$OS2)/$hits); print "
Platform summary
PlatformHits%
Windows%d%.2f
UnixGUI%d%.2f
UnixText%d%.2f
Macintosh%d%.2f
OS/2%d%.2f
Accounted for%d%.2f
"; print "

";
foreach $item (@items)
	{print $item;}
print "
"; print "";