#!/usr/local/bin/gawk -f
# demog - a Web log analysis script
# Copyright © 1998-1999 Saugus.net, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
# Here we're basically just initializing our variables and writing out
# the constant beginning portion of our HTML source.
BEGIN \
{
if(DemogFilename=="")DemogFilename="demog.shtml";
# We're using multi-line input records
RS="";
FS="\n";
LastRef="NoRef";
DefineDomainTable();
DefineRefererTable();
DefineSpiderTable();
};
# The following pattern will match a group of lines beginning
# with the string "Time:" at the beginning of a line and ending
# with a blank line. For our expected input, this should match
# every recorded hit.
#
# Thus we're using this section to process each log entry and
# count up certain things.
/^Time:/ \
{
# don't include any host testing
if(substr($2,7,9)!="localhost") # Host tests.
{
# Don't include search engine robots in the regular count.
for(Engine in SpiderID)
if(substr($4,7,length(SpiderID[Engine]))==SpiderID[Engine])
{
Spider++;
next;
}
for(Engine in SpiderDomain)
if(substr($2,length($2)-length(SpiderDomain[Engine])+1)==\
SpiderDomain[Engine])
{
Spider++;
next;
}
CountBrowsersAndOSs();
CountReferences();
CountGeographyAndTypes();
}
else
HostTest++;
};
# Here we do all our final one-time computations based on
# the counts we've made and print out the results in HTML format.
END \
{
# Do all the final calculations
Browser100=100/Browser; # used for more efficient percentage calcs.
SumBrowsersAndOSs();
SumReferences();
SumContinents();
# Print out raw demographics page
PrintHead(DemogFilename);
PrintDemogIntro(DemogFilename);
PrintOSTable(DemogFilename);
PrintBrowserTable(DemogFilename);
PrintReferenceTable(DemogFilename);
PrintTypeTable(DemogFilename);
PrintGeographyTable(DemogFilename);
PrintTail(DemogFilename);
};
function DefineDomainTable()
{
Domain["USA Commercial"]="com";
Continent["USA Commercial"]="North America";
Domain["USA Educational"]="edu";
Continent["USA Educational"]="North America";
Domain["USA Government"]="gov";
Continent["USA Government"]="North America";
Domain["USA Organization"]="org";
Continent["USA Organization"]="North America";
Domain["USA ISP"]="net";
Continent["USA ISP"]="North America";
Domain["USA Military"]="mil";
Continent["USA Military"]="North America";
Domain["International"]="int"; # original international domain
Continent["International"]="Non-specific; International";
Domain["NATO"]="nato"; # original NATO domain
Continent["NATO"]="Non-specific; International";
Domain["USA Public School"]="us";
Continent["USA Public School"]="North America";
Domain["Afghanistan"]="af";
Continent["Afghanistan"]="Asia";
Domain["Albania"]="al";
Continent["Albania"]="Europe";
Domain["Algeria"]="dz";
Continent["Algeria"]="Africa";
Domain["American Samoa"]="as";
Continent["American Samoa"]="Australia and Oceania";
Domain["Andorra"]="ad";
Continent["Andorra"]="Europe";
Domain["Angola"]="ao";
Continent["Angola"]="Africa";
Domain["Anguilla"]="ai";
Continent["Anguilla"]="North America";
Domain["Antarctica Proper"]="aq";
Continent["Antarctica Proper"]="Antarctica";
Domain["Heard and McDonald Islands"]="hm";
Continent["Heard and McDonald Islands"]="Antarctica";
Domain["French Southern Territories"]="tf";
Continent["French Southern Territories"]="Antarctica";
Domain["Antigua and Barbuda"]="ag";
Continent["Antigua and Barbuda"]="North America";
Domain["Argentina"]="ar";
Continent["Argentina"]="South America";
Domain["Armenia"]="am";
Continent["Armenia"]="Europe";
Domain["Aruba"]="aw";
Continent["Aruba"]="North America";
Domain["Australia"]="au";
Continent["Australia"]="Australia and Oceania";
Domain["Austria"]="at";
Continent["Austria"]="Europe";
Domain["Azerbaijan"]="az";
Continent["Azerbaijan"]="Europe";
Domain["Bahamas"]="bs";
Continent["Bahamas"]="North America";
Domain["Bahrain"]="bh";
Continent["Bahrain"]="Asia";
Domain["Bangladesh"]="bd";
Continent["Bangladesh"]="Asia";
Domain["Barbados"]="bb";
Continent["Barbados"]="South America";
Domain["Belarus"]="by";
Continent["Belarus"]="Europe";
Domain["Belgium"]="be";
Continent["Belgium"]="Europe";
Domain["Belize"]="bz";
Continent["Belize"]="North America";
Domain["Benin"]="bj";
Continent["Benin"]="Africa";
Domain["Bermuda"]="bm";
Continent["Bermuda"]="North America";
Domain["Bhutan"]="bh";
Continent["Bhutan"]="Asia";
Domain["Bolivia"]="bo";
Continent["Bolivia"]="South America";
Domain["Bosnia-Herzegovina"]="ba";
Continent["Bosnia-Herzegovina"]="Europe";
Domain["Botswana"]="bw";
Continent["Botswana"]="Africa";
Domain["Bouvet Island"]="bv";
Continent["Bouvet Island"]="South America";
Domain["Brazil"]="br";
Continent["Brazil"]="South America";
Domain["British Indian Ocean Territory"]="io";
Continent["British Indian Ocean Territory"]="Asia";
Domain["Brunei Darussalam"]="bn";
Continent["Brunei Darussalam"]="Australia and Oceania";
Domain["Bulgaria"]="bg";
Continent["Bulgaria"]="Europe";
Domain["Burkina Faso"]="bf";
Continent["Burkina Faso"]="Africa";
Domain["Burundi"]="bi";
Continent["Burundi"]="Africa";
Domain["Cambodia"]="kh";
Continent["Cambodia"]="Asia";
Domain["Cameroon"]="cm";
Continent["Cameroon"]="Africa";
Domain["Canada"]="ca";
Continent["Canada"]="North America";
Domain["Cape Verde"]="cv";
Continent["Cape Verde"]="Africa";
Domain["Cayman Islands"]="ky";
Continent["Cayman Islands"]="North America";
Domain["Central African Republic"]="cf";
Continent["Central African Republic"]="Africa";
Domain["Chad"]="td";
Continent["Chad"]="Africa";
Domain["Chile"]="cl";
Continent["Chile"]="South America";
Domain["China Proper"]="cn";
Continent["China Proper"]="Asia";
Domain["Christmas Island"]="cx";
Continent["Christmas Island"]="Australia and Oceania";
Domain["Cocos Islands"]="cc";
Continent["Cocos Islands"]="Asia";
Domain["Columbia"]="co";
Continent["Columbia"]="South America";
Domain["Comoros"]="km";
Continent["Comoros"]="Africa";
Domain["Congo"]="cg";
Continent["Congo"]="Africa";
Domain["Cook Islands"]="ck";
Continent["Cook Islands"]="Australia and Oceania";
Domain["Costa Rica"]="cr";
Continent["Costa Rica"]="North America";
Domain["Croatia"]="hr";
Continent["Croatia"]="Europe";
Domain["Cuba"]="cu";
Continent["Cuba"]="North America";
Domain["Cyprus"]="cy";
Continent["Cyprus"]="Europe";
Domain["Czech Republic"]="cz";
Continent["Czech Republic"]="Europe";
Domain["Czechoslovakia"]="cs";
Continent["Czechoslovakia"]="Europe";
Domain["Denmark"]="dk";
Continent["Denmark"]="Europe";
Domain["Djibouti"]="dj";
Continent["Djibouti"]="Africa";
Domain["Dominica"]="dm";
Continent["Dominica"]="North America";
Domain["Dominican Republic"]="do";
Continent["Dominican Republic"]="North America";
Domain["East Timor"]="tp";
Continent["East Timor"]="Australia and Oceania";
Domain["Ecuador"]="ec";
Continent["Ecuador"]="South America";
Domain["Egypt"]="eg";
Continent["Egypt"]="Africa";
Domain["El Salvador"]="sv";
Continent["El Salvador"]="North America";
Domain["Equatorial Guinea"]="gq";
Continent["Equatorial Guinea"]="Africa";
Domain["Estonia"]="ee";
Continent["Estonia"]="Europe";
Domain["Ethiopia"]="et";
Continent["Ethiopia"]="Africa";
Domain["Falkland Islands"]="fk";
Continent["Falkland Islands"]="South America";
Domain["Faeroe Islands"]="fo";
Continent["Faeroe Islands"]="Europe";
Domain["Fiji"]="fj";
Continent["Fiji"]="Australia and Oceania";
Domain["Finland"]="fi";
Continent["Finland"]="Europe";
Domain["France"]="fr";
Continent["France"]="Europe";
Domain["France (European Territory)"]="fx";
Continent["France (European Territory)"]="Europe";
Domain["French Guyana"]="gf";
Continent["French Guyana"]="South America";
Domain["French Polynesia"]="pf";
Continent["French Polynesia"]="Australia and Oceania";
Domain["Gabon"]="ga";
Continent["Gabon"]="Africa";
Domain["Gambia"]="gm";
Continent["Gambia"]="Africa";
Domain["Georgia"]="ge";
Continent["Georgia"]="Europe";
Domain["Germany"]="de";
Continent["Germany"]="Europe";
Domain["Ghana"]="gh";
Continent["Ghana"]="Africa";
Domain["Gibraltar"]="gi";
Continent["Gibraltar"]="Europe";
Domain["Greece"]="gr";
Continent["Greece"]="Europe";
Domain["Greenland"]="gl";
Continent["Greenland"]="North America";
Domain["Grenada"]="gd";
Continent["Grenada"]="North America";
Domain["Guadeloupe"]="gp";
Continent["Guadeloupe"]="North America";
Domain["Guam"]="gu";
Continent["Guam"]="Australia and Oceania";
Domain["Guatemala"]="gt";
Continent["Guatemala"]="North America";
Domain["Guinea"]="gn";
Continent["Guinea"]="Africa";
Domain["Guinea Bissau"]="gw";
Continent["Guinea Bissau"]="Africa";
Domain["Guyana"]="gy";
Continent["Guyana"]="South America";
Domain["Haiti"]="ht";
Continent["Haiti"]="North America";
Domain["Honduras"]="hn";
Continent["Honduras"]="North America";
Domain["Hong Kong"]="hk";
Continent["Hong Kong"]="Asia";
Domain["Hungary"]="hu";
Continent["Hungary"]="Europe";
Domain["Iceland"]="is";
Continent["Iceland"]="Europe";
Domain["India"]="in";
Continent["India"]="Asia";
Domain["Indonesia"]="id";
Continent["Indonesia"]="Asia";
Domain["Iran"]="ir";
Continent["Iran"]="Asia";
Domain["Iraq"]="iq";
Continent["Iraq"]="Asia";
Domain["Ireland"]="ie";
Continent["Ireland"]="Europe";
Domain["Israel"]="il";
Continent["Israel"]="Asia";
Domain["Italy"]="it";
Continent["Italy"]="Europe";
Domain["Ivory Coast"]="ci";
Continent["Ivory Coast"]="Africa";
Domain["Jamaica"]="jm";
Continent["Jamaica"]="North America";
Domain["Japan"]="jp";
Continent["Japan"]="Asia";
Domain["Jordan"]="jo";
Continent["Jordan"]="Asia";
Domain["Kazakhstan"]="kz";
Continent["Kazakhstan"]="Asia";
Domain["Kenya"]="ke";
Continent["Kenya"]="Africa";
Domain["Kiribati"]="ki";
Continent["Kiribati"]="Australia and Oceania";
Domain["Kuwait"]="kw";
Continent["Kuwait"]="Asia";
Domain["Kyrgyzstan"]="kg";
Continent["Kyrgyzstan"]="Asia";
Domain["Laos"]="la";
Continent["Laos"]="Asia";
Domain["Latvia"]="lv";
Continent["Latvia"]="Europe";
Domain["Lebanon"]="lb";
Continent["Lebanon"]="Asia";
Domain["Neutral Zone"]="nt";
Continent["Neutral Zone"]="Asia";
Domain["Lesotho"]="ls";
Continent["Lesotho"]="Africa";
Domain["Liberia"]="lr";
Continent["Liberia"]="Africa";
Domain["Libya"]="ly";
Continent["Libya"]="Africa";
Domain["Liechtenstein"]="li";
Continent["Liechtenstein"]="Europe";
Domain["Lithuania"]="lt";
Continent["Lithuania"]="Europe";
Domain["Luxembourg"]="lu";
Continent["Luxembourg"]="Europe";
Domain["Macau"]="mo";
Continent["Macau"]="Asia";
Domain["Macedonia"]="mk";
Continent["Macedonia"]="Europe";
Domain["Madagascar"]="mg";
Continent["Madagascar"]="Africa";
Domain["Malawi"]="mw";
Continent["Malawi"]="Africa";
Domain["Malaysia"]="my";
Continent["Malaysia"]="Asia";
Domain["Maldives"]="mv";
Continent["Maldives"]="Asia";
Domain["Mali"]="ml";
Continent["Mali"]="Africa";
Domain["Malta"]="mt";
Continent["Malta"]="Europe";
Domain["Marshall Islands"]="mh";
Continent["Marshall Islands"]="Australia and Oceania";
Domain["Martinique"]="mq";
Continent["Martinique"]="North America";
Domain["Mauritania"]="mr";
Continent["Mauritania"]="Africa";
Domain["Maurititus"]="mu";
Continent["Maurititus"]="Africa";
Domain["Mexico"]="mx";
Continent["Mexico"]="North America";
Domain["Micronesia"]="fm";
Continent["Micronesia"]="Australia and Oceania";
Domain["Moldavia"]="md";
Continent["Moldavia"]="Europe";
Domain["Monaco"]="mc";
Continent["Monaco"]="Europe";
Domain["Mongolia"]="mn";
Continent["Mongolia"]="Asia";
Domain["Montserrat"]="ms";
Continent["Montserrat"]="North America";
Domain["Morocco"]="ma";
Continent["Morocco"]="Africa";
Domain["Mozambique"]="mz";
Continent["Mozambique"]="Africa";
Domain["Myanmar"]="my";
Continent["Myanmar"]="Asia";
Domain["Namibia"]="na";
Continent["Namibia"]="Africa";
Domain["Nauru"]="nr";
Continent["Nauru"]="Australia and Oceania";
Domain["Nepal"]="np";
Continent["Nepal"]="Asia";
Domain["Netherland Antilles"]="an";
Continent["Netherland Antilles"]="South America";
Domain["Netherlands"]="nl";
Continent["Netherlands"]="Europe";
Domain["New Caledonia"]="nc";
Continent["New Caledonia"]="Australia and Oceania";
Domain["New Zealand"]="nz";
Continent["New Zealand"]="Australia and Oceania";
Domain["Nicaragua"]="ni";
Continent["Nicaragua"]="North America";
Domain["Niger"]="ne";
Continent["Niger"]="Africa";
Domain["Nigeria"]="ng";
Continent["Nigeria"]="Africa";
Domain["Niue"]="nu";
Continent["Niue"]="Australia and Oceania";
Domain["Norfolk Island"]="nf";
Continent["Norfolk Island"]="Australia and Oceania";
Domain["North Korea"]="kp";
Continent["North Korea"]="Asia";
Domain["Northern Mariana Islands"]="mp";
Continent["Northern Mariana Islands"]="Australia and Oceania";
Domain["Norway"]="no";
Continent["Norway"]="Europe";
Domain["Svalbard and Jan Mayen Islands"]="sj";
Continent["Svalbard and Jan Mayen Islands"]="Europe";
Domain["Oman"]="om";
Continent["Oman"]="Asia";
Domain["Pakistan"]="pk";
Continent["Pakistan"]="Asia";
Domain["Palau"]="pw";
Continent["Palau"]="Australia and Oceania";
Domain["Panama"]="pa";
Continent["Panama"]="North America";
Domain["Papua New Guinea"]="pg";
Continent["Papua New Guinea"]="Australia and Oceania";
Domain["Paraguay"]="py";
Continent["Paraguay"]="South America";
Domain["Peru"]="pe";
Continent["Peru"]="South America";
Domain["Philippines"]="ph";
Continent["Philippines"]="Asia";
Domain["Pitcairn"]="pn";
Continent["Pitcairn"]="Australia and Oceania";
Domain["Poland"]="pl";
Continent["Poland"]="Europe";
Domain["Polynesia"]="pf";
Continent["Polynesia"]="Australia and Oceania";
Domain["Portugal"]="pt";
Continent["Portugal"]="Europe";
Domain["Puerto Rico"]="pr";
Continent["Puerto Rico"]="North America";
Domain["Qatar"]="qa";
Continent["Qatar"]="Asia";
Domain["Reunion"]="re";
Continent["Reunion"]="Africa";
Domain["Romania"]="ro";
Continent["Romania"]="Europe";
Domain["Russia"]="ru";
Continent["Russia"]="Europe";
Domain["Rwanda"]="rw";
Continent["Rwanda"]="Africa";
Domain["Saint Helena"]="sh";
Continent["Saint Helena"]="Africa";
Domain["Saint Kitts Nevis Anguilla"]="kn";
Continent["Saint Kitts Nevis Anguilla"]="North America";
Domain["Saint Lucia"]="lc";
Continent["Saint Lucia"]="North America";
Domain["Saint Pierre and Miquelon"]="pm";
Continent["Saint Pierre and Miquelon"]="North America";
Domain["Saint Tome and Principe"]="st";
Continent["Saint Tome and Principe"]="Africa";
Domain["Saint Vincent and the Grenadines"]="vc";
Continent["Saint Vincent and the Grenadines"]="North America";
Domain["San Marino"]="sm";
Continent["San Marino"]="Europe";
Domain["Saudi Arabia"]="sa";
Continent["Saudi Arabia"]="Asia";
Domain["Senegal"]="sn";
Continent["Senegal"]="Africa";
Domain["Seychelles"]="sc";
Continent["Seychelles"]="Africa";
Domain["Sierra Leone"]="sl";
Continent["Sierra Leone"]="Africa";
Domain["Singapore"]="sg";
Continent["Singapore"]="Asia";
Domain["Slovakia"]="sk";
Continent["Slovakia"]="Europe";
Domain["Slovenia"]="sk";
Continent["Slovenia"]="Europe";
Domain["Soloman Islands"]="sb";
Continent["Soloman Islands"]="Australia and Oceania";
Domain["Somalia"]="so";
Continent["Somalia"]="Africa";
Domain["South Africa"]="za";
Continent["South Africa"]="Africa";
Domain["South Korea"]="kr";
Continent["South Korea"]="Asia";
Domain["Soviet Union"]="su";
Continent["Soviet Union"]="Europe";
Domain["Spain"]="es";
Continent["Spain"]="Europe";
Domain["Sri Lanka"]="lk";
Continent["Sri Lanka"]="Asia";
Domain["Sudan"]="sd";
Continent["Sudan"]="Africa";
Domain["Surinam"]="sr";
Continent["Surinam"]="South America";
Domain["Swaziland"]="sz";
Continent["Swaziland"]="Africa";
Domain["Sweden"]="se";
Continent["Sweden"]="Europe";
Domain["Switzerland"]="ch";
Continent["Switzerland"]="Europe";
Domain["Syria"]="sy";
Continent["Syria"]="Asia";
Domain["Tajikistan"]="tj";
Continent["Tajikistan"]="Asia";
Domain["Taiwan"]="tw";
Continent["Taiwan"]="Asia";
Domain["Tanzania"]="tz";
Continent["Tanzania"]="Africa";
Domain["Thailand"]="th";
Continent["Thailand"]="Asia";
Domain["Togo"]="tg";
Continent["Togo"]="Africa";
Domain["Tokelau"]="tk";
Continent["Tokelau"]="Australia and Oceania";
Domain["Tonga"]="to";
Continent["Tonga"]="Australia and Oceania";
Domain["Trinidad and Tobago"]="tt";
Continent["Trinidad and Tobago"]="South America";
Domain["Tunisia"]="tn";
Continent["Tunisia"]="Africa";
Domain["Turkey"]="tr";
Continent["Turkey"]="Asia";
Domain["Turkmenistan"]="tm";
Continent["Turkmenistan"]="Asia";
Domain["Turks and Caicos Islands"]="tc";
Continent["Turks and Caicos Islands"]="North America";
Domain["Tuvalu"]="tv";
Continent["Tuvalu"]="Australia and Oceania";
Domain["Uganda"]="ug";
Continent["Uganda"]="Africa";
Domain["Ukraine"]="ua";
Continent["Ukraine"]="Europe";
Domain["United Arab Emirates"]="ae";
Continent["United Arab Emirates"]="Asia";
Domain["United Kingdom"]="uk";
Continent["United Kingdom"]="Europe";
Domain["United States Minor Outlying Islands"]="um";
Continent["United States Minor Outlying Islands"]="Australia and Oceania";
Domain["Uruguay"]="uy";
Continent["Uruguay"]="South America";
Domain["Uzbekistan"]="uz";
Continent["Uzbekistan"]="Asia";
Domain["Vanuatu"]="vu";
Continent["Vanuatu"]="Australia and Oceania";
Domain["Vatican"]="va";
Continent["Vatican"]="Europe";
Domain["Venezuela"]="ve";
Continent["Venezuela"]="South America";
Domain["Vietnam"]="vn";
Continent["Vietnam"]="Asia";
Domain["Virgin Islands (British)"]="vg";
Continent["Virgin Islands (British)"]="North America";
Domain["Virgin Islands (USA)"]="vi";
Continent["Virgin Islands (USA)"]="North America";
Domain["Wallis and Futuna Islands"]="wf";
Continent["Wallis and Futuna Islands"]="Australia and Oceania";
Domain["Western Sahara"]="eh";
Continent["Western Sahara"]="Africa";
Domain["Yemen"]="ye";
Continent["Yemen"]="Asia";
Domain["Yugoslavia"]="yu";
Continent["Yugoslavia"]="Europe";
Domain["Zaire"]="zr";
Continent["Zaire"]="Africa";
Domain["Zambia"]="zm";
Continent["Zambia"]="Africa";
Domain["Zimbabwe"]="zw";
Continent["Zimbabwe"]="Africa";
Continent["China"]="Asia";
Continent["USA"]="North America";
return 0;
}
function DefineRefererTable()
{
Referer["AltaVista"]="altavista";
RefererURL["AltaVista"]="AltaVista "
Referer["AOLNetFind"]="netfind.aol";
RefererURL["AOLNetFind"]="AOL NetFind ";
Referer["Businesseek"]="businesseek";
RefererURL["Businesseek"]="Business Seek ";
Referer["Excite"]="excite";
RefererURL["Excite"]="Excite ";
Referer["HotBot"]="hotbot";
RefererURL["HotBot"]="HotBot ";
Referer["InfoSeek"]="infoseek";
RefererURL["InfoSeek"]="InfoSeek ";
Referer["Lycos"]="lycos";
RefererURL["Lycos"]="Lycos ";
Referer["Metacrawler"]="metacrawler";
RefererURL["Metacrawler"]="Metacrawler ";
Referer["NorthernLight"]="northernlight";
RefererURL["NorthernLight"]="Northern Light ";
Referer["Thunderstone"]="thunderstone";
RefererURL["Thunderstone"]="Thunderstone ";
Referer["WebCrawler"]="webcrawler";
RefererURL["WebCrawler"]="WebCrawler ";
Referer["WhatUSeek"]="whatuseek";
RefererURL["WhatUSeek"]="What-U-Seek ";
Referer["Yahoo"]="yahoo";
RefererURL["Yahoo"]="Yahoo ";
return 0;
}
function DefineSpiderTable()
{
# Some spiders have distinctive IDs
SpiderID["AltaVista"]="Scooter";
SpiderID["InfoSeek"]="InfoSeek";
SpiderID["Lycos"]="Lycos";
SpiderID["WebCrawler"]="WebCrawler";
SpiderID["HotBot"]="Slurp"; # and Inktomi too
SpiderID["NorthernLight"]="Gulliver";
SpiderID["Backrub"]="BackRub"; # Stanford experiment
SpiderID["Microsoft"]="Microsoft URL"; # Microsoft spider
SpiderID["Hatch"]="HatchKun"; # Hatch phone number thing
SpiderID["WiseWire"]="WiseWire"; # Not sure what this is
SpiderID["ArchitextSpider"]="ArchitextSpider"; # ditto
# Some can only be picked out by domain name
SpiderDomain["Yahoo"]="yahoo.com";
SpiderDomain["Thunderstone"]=".thunderstone.com";
SpiderDomain["WhoWhere"]=".whowhere.com"; # Not sure what this is
SpiderDomain["Lycos"]=".lycos.com";
return 0;
}
function CountBrowsersAndOSs()
{
Browser++; # increment browser count
if(index($4,"Mozilla"))
{
NetscapeComp++; # inc. Netscape compatible count
if(index($4,"IWENG"))
IWENG++; # AOL claims Netscape comp.
else if(index($4,"LunaSuite"))
{
LunaSuite++; # increment LunaSuite count
Newton++; # Newton only & doesn't tell OS
}
else if(index($4,"Opera"))
Opera++; #increment Opera count
else if(index($4,"ompatible; MSIE"))
{
if(index($4,"AOL"))
AOLMSIE++; # AOL flavor of MSIE
else
MSIE++; # MSIE claims Netscape comp.
}
else if(!index($4,"ompatible;")) # others, too
Netscape++; # otherwise genuine Netscape
}
else if(index($4,"Lynx"))
Lynx++; # increment Lynx count
else if(index($4,"Mosaic"))
Mosaic++; # increment Mosaic count
else if(index($4,"Java"))
HotJava++; # increment HotJava count
else if(index($4,"Chimera"))
{
Chimera++; # increment Chimera count
X11++; # no OS info, but definitely X
}
else if(index($4,"Arena"))
{
Arena++; # increment Arena count
X11++; # no OS info, but definitely X
}
else if(index($4,"NetHopper"))
NetHopper++; # increment NetHopper count
else if(index($4,"Newt's Cape"))
NewtsCape++; # increment Newt's Cape count
else if(index($4,"Voyager"))
Voyager++; # increment Voyager count
else if(index($4,"PocketWeb"))
{
PocketWeb++; # increment PocketWeb count
Newton++; # Newton only & doesn't tell OS
}
else if(index($4,"PRODIGY-WB"))
Prodigy++; # increment Prodigy WB count
else if(index($4,"Cyberdog"))
{
Cyberdog++; # increment Cyberdog count
Mac++; # Mac only & doesn't tell OS
}
else if(index($4,"W3C")||index($4,"Email"))
EMail++; # increment web by e-mail count
else if(length($4)==6)
{
if(substr($2,length($2)-6)==".gmd.de")
EMail++; # does web by e-mail access
else
NoBrowser++; # blank field...
}
if(index($4,"X11")||index($4,"X Win"))
{
X11++; # Some flavor of UNIX
if(index($4,"Sun"))
Sun++; # inc. SunOS / Solaris count
else if(index($4,"Linux"))
Linux++; # increment Linux count
else if(index($4,"FreeBSD"))
FreeBSD++; # increment FreeBSD count
else if(index($4,"IRIX"))
IRIX++; # increment IRIX count
else if(index($4,"AIX"))
AIX++; # increment AIX count
else if(index($4,"HP-UX"))
HPUX++; # increment HP-UX count
}
else if(index($4,"Mac"))
Mac++; # increment Mac count
else if(index($4,"Newt")||index($4,"NEWT"))
Newton++; # increment Newton count
else if(index($4,"WebTV"))
WebTV++; # inc. WebTV box count
else if(index($4,"Amiga"))
Amiga++; # inc. Amiga count
else if(index($4,"OS/2"))
OS2++; # inc. OS/2 count
else if(index($4,"Win"))
{
MSWin++; # some flavor of MS-Win
if(index($4,"NT"))
MSWinNT++; # increment NT count
if(index($4,"98"))
MSWin98++; # increment 98 count
if(index($4,"s CE"))
MSWinCE++; # increment CE count
else if(index($4,"95"))
MSWin95++; # increment 95 count
}
return 0;
}
function CountReferences()
{
$6=tolower($6); # we don't care about case here
if(length($6)==6)
{
Count["NoRef"]++; # No references provided
LastRef="NoRef";
}
else if(index($6,"saugus.net"))
{
InternalLink++; # referenced by internal link
if(index($6,"movies")||index($6,"sounds")||
index($6,"images")||index($6,"log"))
{
Count["UntraceableRef"]++;
LastRef="UntraceableRef";
}
else
Count[LastRef]++;
}
else
{
for(FromAddr in Referer)
{
if(index($6,Referer[FromAddr]))
{
Count[FromAddr]++;
LastRef=FromAddr;
break;
}
}
}
return 0;
}
function CountGeographyAndTypes()
{
if(match($2,"st:[. 0-9]*$"))
NoType++; # just numbers given; no name to work with
else
{
$2=tolower($2); # don't care about case here
for(Place in Domain)
{
if(substr($2,length($2)-length(Domain[Place]))=="."Domain[Place])
{
Count[Place]++;
break;
}
}
if(index($2,".co.")||index($2,".com."))
Count["Foreign Commercial"]++; # foreign commercial domain
else if(index($2,".ed.")||index($2,".edu."))
Count["Foreign Educational"]++; # foreign educational domain
else if(index($2,".ne.")||index($2,".net."))
Count["Foreign ISP"]++; # foreign network / ISP domain
else if(index($2,".or.")||index($2,".org."))
Count["Foreign Organization"]++; # foreign non-profit domain
else if(index($2,".go.")||index($2,".gov."))
Count["Foreign Government"]++; # foreign government domain
else if(index($2,".mi.")||index($2,".mil."))
Count["Foreign Military"]++; # foreign military domain
}
return 0;
}
function SumBrowsersAndOSs()
{
# if it's Netscape compatible but not Netscape itself or MSIE or AOL,
# classify it as an other Netscape compatible
OtherNetscapeComp=NetscapeComp-Netscape-AOLMSIE-MSIE-IWENG-LunaSuite-Opera;
# if it's not Netscape compatible, Lynx, HotJava, or undefined, it's other
OtherBrowser=Browser-NetscapeComp-Lynx-HotJava-Mosaic-EMail-\
Chimera-LunaSuite-Cyberdog-NetHopper-NewtsCape-Prodigy-\
Arena-Voyager-NoBrowser;
# if it's UNIX but not Sun, Linux, FreeBSD, IRIX, AIX, or HP-UX, it's
# some other UNIX
OtherUnix=X11-Sun-Linux-FreeBSD-IRIX-AIX-HPUX;
# if it's MS-Win but not NT, CE, 95, or 98, it's 3.1
MSWin31=MSWin-MSWinNT-MSWinCE-MSWin95-MSWin98;
# if it's not MS-Win, not UNIX, not Mac, not Newton, not WebTV, and
# not Amiga, then it's some other OS
OtherOs=Browser-X11-MSWin-Mac-Newton-WebTV-OS2-Amiga;
return 0;
}
function SumReferences()
{
# if it's not one of the recognized search engines and it's not a blank
# reference, it's another link
Count["OtherRef"]=Browser;
for(FromAddr in Referer)
{
RefCount++;
Count["OtherRef"]-=Count[FromAddr];
}
Count["OtherRef"]-=Count["NoRef"];
Count["OtherRef"]-=Count["UntraceableRef"];
RefCount+=3;
return 0;
}
function SumContinents()
{
for(Place in Domain)
Count[Continent[Place]]+=Count[Place];
Count["USA"]=Count["USA Commercial"]+Count["USA ISP"]+\
Count["USA Educational"]+Count["USA Government"]+\
Count["USA Military"]+Count["USA Organization"]+\
Count["USA Public School"];
Count["China"]=Count["China Proper"]+Count["Hong Kong"]+Count["Macau"];
Count["Commercial"]=Count["USA Commercial"]+Count["Foreign Commercial"];
Count["Educational"]=Count["USA Educational"]+Count["Foreign Educational"]+\
Count["USA Public School"];
Count["Government"]=Count["USA Government"]+Count["Foreign Government"];
Count["Organization"]=Count["USA Organization"]+Count["Foreign Organization"];
Count["Military"]=Count["USA Military"]+Count["Foreign Military"];
Count["ISP"]=Count["USA ISP"]+Count["Foreign ISP"];
UnknownCountry=Browser-Count["North America"]-Count["South America"]-\
Count["Europe"]-Count["Asia"]-Count["Africa"]-\
Count["Australia and Oceania"]-Count["Antarctica"]-\
Count["Non-specific; International"];
OtherType=Browser-Count["Commercial"]-Count["Educational"]-\
Count["Government"]-Count["Organization"]-Count["Military"]-\
Count["ISP"]-Count["NATO"]-Count["International"]-NoType;
return 0;
}
function PrintHead(OutFilename)
{
# Note that this very first output redirection performs an overwrite...
print "" >OutFilename;
print "" >>OutFilename;
print "
" >>OutFilename;
print "Saugus.net Site Visitor Demographics "\
>>OutFilename;
printf " >OutFilename;
print "CONTENT=\"Some (Hopefully) Interesting Statistics\">" >>OutFilename;
print " >OutFilename;
print "CONTENT=\"Saugus, MA, Saugus, Massachusetts, Saugus, Mass., Essex County\">"\
>>OutFilename;
# these link tags are used by some browsers to create special home
# and up buttons. Netscape & MSIE ignore them, though.
print " >OutFilename;
print "HREF=\"http://www.saugus.net/\">" >>OutFilename;
print " >OutFilename;
print "HREF=\"http://www.saugus.net/\">" >>OutFilename;
print "" >>OutFilename;
printf ">OutFilename
print "LINK=\"#957575\" ALINK=\"#FF0000\">" >>OutFilename;
print "" >>OutFilename;
print " " >> OutFilename;
print "
" >>OutFilename;
print "" >>OutFilename;
# this line causes hits to the resulting page to themselves be logged
printf "" >>OutFilename;
printf "" >>OutFilename;
print "
" >>OutFilename;
print "
" >>OutFilename;
print "" >>OutFilename;
# even margins on both sides
print "
" >>OutFilename;
return 0;
}
function PrintDemogIntro(OutFilename)
{
print "
" >>OutFilename;
print "
What's This Page About? " >>OutFilename;
print "This page provides a look at the population of people who visit"\
>>OutFilename;
print "this site and gives a rough breakdown on some simple facts about"\
>>OutFilename;
print "what web
browsers "\
>>OutFilename;
print "are being used on what
platforms , how these pages"\
>>OutFilename;
print "were found, etc.
" >>OutFilename;
print "It is displayed here just for the curiousity value. It's a bit"\
>>OutFilename;
print "more interesting than a simple counter and gives a feel for what"\
>>OutFilename;
print "kinds of computers are being used in town.
" >>OutFilename;
print " " >>OutFilename;
print "
How Were These Data Gathered? " >>OutFilename;
print "The numbers are fairly rough; no
cookies or other nasty tricks are"\
>>OutFilename;
print "used to grab extra information about visitors (for"\
>>OutFilename;
print "example, no user name information is collected). It just relies on the"\
>>OutFilename;
print "normal (and typically incomplete) information automatically provided"\
>>OutFilename;
print "by all browsers to every web server.
" >>OutFilename;
print "What this means is that certain entries in certain categories"\
>>OutFilename;
print "(most notably Systems ," >>OutFilename;
print "Types ," >>OutFilename;
print "Geography , and" >>OutFilename;
print "How Entered ) will have lower numbers"\
>>OutFilename;
print "than they really deserve while the corresponding "other""\
>>OutFilename;
print "entries in these categories will have higher numbers than they"\
>>OutFilename;
print "really deserve. Essentially what's happening is some of the"\
>>OutFilename;
print "hits that really ought to contribute to earlier entries wind up"\
>>OutFilename;
print "in the catch-all "other" entry instead.
" >>OutFilename;
printf "%6.2f%% of all hits to this site are "inhuman"\n",
Spider*100/NR >>OutFilename;
print "hits; they're the work of search engine"\
>>OutFilename;
print "spiders or page statistic"\
>>OutFilename;
print "robots or similar entities from external sources. These hits are"\
>>OutFilename;
print "not counted in any of the following tables. Likewise, hits from all"\
>>OutFilename;
print "our own employees have been removed prior to the counting.
"\
>>OutFilename;
printf "%6.2f%% of the people who hit this site view more than one\n",
InternalLink*Browser100 >>OutFilename;
print "page during their visit." >>OutFilename;
print "
" >>OutFilename;
return 0;
}
function PrintOSTable(OutFilename)
{
# print out the table for OS percentages
Factor=Browser100;
Units="%";
NumFormat="%6.2f";
print " " >>OutFilename;
print "Systems " >>OutFilename;
print "" >>OutFilename;
print "" >>OutFilename;
printf " Total Amiga Systems "\
>>OutFilename;
printf " "NumFormat"%c
\n",
Amiga*Factor,Units >>OutFilename;
printf " Total Macintosh Systems "\
>>OutFilename;
printf " "NumFormat"%c
\n",
Mac*Factor,Units >>OutFilename;
printf "MS-Windows 3.1 " >>OutFilename;
printf " "NumFormat"%c
\n",
MSWin31*Factor,Units >>OutFilename;
printf "MS-Windows 95 " >>OutFilename;
printf " "NumFormat"%c
\n",
MSWin95*Factor,Units >>OutFilename;
printf "MS-Windows 98 " >>OutFilename;
printf " "NumFormat"%c
\n",
MSWin98*Factor,Units >>OutFilename;
printf "MS-Windows CE " >>OutFilename;
printf " "NumFormat"%c
\n",
MSWinCE*Factor,Units >>OutFilename;
printf "MS-Windows NT " >>OutFilename;
printf " "NumFormat"%c
\n",
MSWinNT*Factor,Units >>OutFilename;
printf "Total MS-Windows Systems "\
>>OutFilename;
printf " "NumFormat"%c
\n",
MSWin*Factor,Units >>OutFilename;
printf "Total Newton Systems "\
>>OutFilename;
printf " "NumFormat"%c
\n",
Newton*Factor,Units >>OutFilename;
printf "Total OS/2 Systems "\
>>OutFilename;
printf " "NumFormat"%c
\n",
OS2*Factor,Units >>OutFilename;
printf "AIX "NumFormat"%c
\n",
AIX*Factor,Units >>OutFilename;
printf "FreeBSD "NumFormat"%c
\n",
FreeBSD*Factor,Units >>OutFilename;
printf "HP-UX "NumFormat"%c
\n",
HPUX*Factor,Units >>OutFilename;
printf "IRIX "NumFormat"%c
\n",
IRIX*Factor,Units >>OutFilename;
printf "Linux "NumFormat"%c
\n",
Linux*Factor,Units >>OutFilename;
printf "Solaris " >>OutFilename;
printf "/ SunOS " >>OutFilename;
printf " "NumFormat"%c
\n",
Sun*Factor,Units >>OutFilename;
printf "Other UNIX Types" >>OutFilename;
printf " "NumFormat"%c
\n",
OtherUnix*Factor,Units >>OutFilename;
printf "Total UNIX Systems "\
>>OutFilename;
printf " "NumFormat"%c
\n",
X11*Factor,Units >>OutFilename;
printf "Total WebTV Systems "\
>>OutFilename;
printf " "NumFormat"%c
\n",
WebTV*Factor,Units >>OutFilename;
printf "Other Systems " >>OutFilename;
printf "/ System Not Provided " >>OutFilename;
printf " "NumFormat"%c \n",
OtherOs*Factor,Units >>OutFilename;
print "
" >>OutFilename;
print "" >>OutFilename;
return 0;
}
function PrintBrowserTable(OutFilename)
{
# print out the table for browser percentages
Factor=Browser100;
Units="%";
NumFormat="%6.2f";
print " " >>OutFilename;
print "
Browsers " >>OutFilename;
print "" >>OutFilename;
print "" >>OutFilename;
printf "Arena " >>OutFilename;
printf " "NumFormat"%c
\n",
Arena*Factor,Units >>OutFilename;
printf "Chimera " >>OutFilename;
printf " "NumFormat"%c
\n",
Chimera*Factor,Units >>OutFilename;
printf "Cyberdog " >>OutFilename;
printf " "NumFormat"%c
\n",
Cyberdog*Factor,Units >>OutFilename;
printf "HotJava " >>OutFilename;
printf " "NumFormat"%c
\n",
HotJava*Factor,Units >>OutFilename;
printf "Total Lynx Compatible "\
>>OutFilename;
printf " "NumFormat"%c
\n",
Lynx*Factor,Units >>OutFilename;
printf "Total Mosaic Compatible "\
>>OutFilename;
printf " "NumFormat"%c
\n",
Mosaic*Factor,Units >>OutFilename;
printf "NetHopper " >>OutFilename;
printf " "NumFormat"%c
\n",
NetHopper*Factor,Units >>OutFilename;
printf "Netscape" >>OutFilename;
printf " "NumFormat"%c
\n",
Netscape*Factor,Units >>OutFilename;
printf "MSIE" >>OutFilename;
printf " "NumFormat"%c
\n",
(MSIE-WebTV)*Factor,Units >>OutFilename;
printf "WebTV-MSIE" >>OutFilename;
printf " "NumFormat"%c
\n",
WebTV*Factor,Units >>OutFilename;
printf "AOL-MSIE" >>OutFilename;
printf " "NumFormat"%c
\n",
AOLMSIE*Factor,Units >>OutFilename;
printf "AOL-IWENG" >>OutFilename;
printf " "NumFormat"%c
\n",
IWENG*Factor,Units >>OutFilename;
printf "Opera" >>OutFilename;
printf " "NumFormat"%c
\n",
Opera*Factor,Units >>OutFilename;
printf "LunaSuite" >>OutFilename;
printf " "NumFormat"%c
\n",
LunaSuite*Factor,Units >>OutFilename;
printf "Other Netscape Compatible" >>OutFilename;
printf " "NumFormat"%c
\n",
OtherNetscapeComp*Factor,Units >>OutFilename;
printf "Total Netscape Compatible "\
>>OutFilename;
printf " "NumFormat"%c
\n",
NetscapeComp*Factor,Units >>OutFilename;
printf "Newt's Cape "\
>>OutFilename;
printf " "NumFormat"%c
\n",
NewtsCape*Factor,Units >>OutFilename;
printf "Prodigy Web Browser "\
>>OutFilename;
printf " "NumFormat"%c
\n",
Prodigy*Factor,Units >>OutFilename;
printf "Voyager " >>OutFilename;
printf " "NumFormat"%c
\n",
Voyager*Factor,Units >>OutFilename;
printf "Web Access Via E-Mail "\
>>OutFilename;
printf " "NumFormat"%c
\n",
EMail*Factor,Units >>OutFilename;
printf "No Browser Name Available "\
>>OutFilename;
printf " "NumFormat"%c
\n",
NoBrowser*Factor,Units >>OutFilename;
printf "Other Browsers "\
>>OutFilename;
printf " "NumFormat"%c \n",
OtherBrowser*Factor,Units >>OutFilename;
print "
" >>OutFilename;
print "" >>OutFilename;
return 0;
}
function PrintReferenceTable(OutFilename)
{
# print out the table for reference link percentages
Factor=Browser100;
Units="%";
NumFormat="%6.2f";
print " " >>OutFilename;
print "
How Entered " >>OutFilename;
print "" >>OutFilename;
print "" >>OutFilename;
for(FromAddr in Referer)
{
printf "%s",RefererURL[FromAddr] >>OutFilename;
printf " "NumFormat"%c
\n",
Count[FromAddr]*Factor,Units >>OutFilename;
}
printf "Untraceable Links "\
>>OutFilename;
printf " "NumFormat"%c
\n",
Count["UntraceableRef"]*Factor,Units >>OutFilename;
printf "Other Links "\
>>OutFilename;
printf " "NumFormat"%c
\n",
Count["OtherRef"]*Factor,Units >>OutFilename;
printf "No Reference " >>OutFilename;
printf "/ Direct Hit / Not Provided " >>OutFilename;
printf " "NumFormat"%c \n",
Count["NoRef"]*Factor,Units >>OutFilename;
print "
" >>OutFilename;
print "" >>OutFilename;
return 0;
}
function PrintTypeTable(OutFilename)
{
# print out the table for type percentages
Factor=Browser100;
Units="%";
NumFormat="%6.2f";
print " " >>OutFilename;
print "
Types " >>OutFilename;
print "" >>OutFilename;
print "" >>OutFilename;
printf "Commercial " >>OutFilename;
printf " "NumFormat"%c
\n",
Count["Commercial"]*Factor,Units >>OutFilename;
printf "Educational "\
>>OutFilename;
printf " "NumFormat"%c
\n",
Count["Educational"]*Factor,Units >>OutFilename;
printf "Government " >>OutFilename;
printf " "NumFormat"%c
\n",
Count["Government"]*Factor,Units >>OutFilename;
printf "International Services "\
>>OutFilename;
printf " "NumFormat"%c
\n",
Count["International"]*Factor,Units >>OutFilename;
printf "Internet Service Provider "\
>>OutFilename;
printf " "NumFormat"%c
\n",
Count["ISP"]*Factor,Units >>OutFilename;
printf "Military " >>OutFilename;
printf " "NumFormat"%c
\n",
Count["Military"]*Factor,Units >>OutFilename;
printf "NATO " >>OutFilename;
printf " "NumFormat"%c
\n",
Count["NATO"]*Factor,Units >>OutFilename;
printf "Non-Profit Organization "\
>>OutFilename;
printf " "NumFormat"%c
\n",
Count["Organization"]*Factor,Units >>OutFilename;
printf "Numeric; Type Not Given "\
>>OutFilename;
printf " "NumFormat"%c
\n",
NoType*Factor,Units >>OutFilename;
printf "No Type Provided "\
>>OutFilename;
printf " (Not Specified In Many Countries)" >>OutFilename;
printf " "NumFormat"%c \n",
OtherType*Factor,Units >>OutFilename;
print "
" >>OutFilename;
print "" >>OutFilename;
return 0;
}
function PrintGeographyTable(OutFilename)
{
# print out the table for geography percentages
Factor=Browser100;
Units="%";
NumFormat="%6.2f";
print " " >>OutFilename;
print "
Geography " >>OutFilename;
print "" >>OutFilename;
print "" >>OutFilename;
printf "Total for Africa "\
>>OutFilename;
printf " "NumFormat"%c
\n",
Count["Africa"]*Factor,Units >>OutFilename;
printf "Total for Antarctica "\
>>OutFilename;
printf " "NumFormat"%c
\n",
Count["Antarctica"]*Factor,Units >>OutFilename;
printf "Total for Asia "\
>>OutFilename;
printf " "NumFormat"%c
\n",
Count["Asia"]*Factor,Units >>OutFilename;
printf "Total for Australia" >>OutFilename;
printf " & Oceania " >>OutFilename;
printf " "NumFormat"%c
\n",
Count["Australia and Oceania"]*Factor,Units >>OutFilename;
printf "Total for Europe "\
>>OutFilename;
printf " "NumFormat"%c
\n",
Count["Europe"]*Factor,Units >>OutFilename;
printf "Total for North America "\
>>OutFilename;
printf " "NumFormat"%c
\n",
Count["North America"]*Factor,Units >>OutFilename;
printf "Total for South America "\
>>OutFilename;
printf " "NumFormat"%c
\n",
Count["South America"]*Factor,Units >>OutFilename;
printf "Unknown " >>OutFilename;
printf "/ Numeric; Not Given " >>OutFilename;
printf " "NumFormat"%c \n",
UnknownCountry*Factor,Units >>OutFilename;
print "
" >>OutFilename;
print "" >>OutFilename;
return 0;
}
function PrintTail(OutFilename)
{
# print out the bottom of our HTML file including JavaScript
# enhanced links to the main pages, and a correct date / time
# stamp of when the page was created.
print "
" >>OutFilename;
print "
" >>OutFilename;
print "" >>OutFilename;
print "" >>OutFilename;
return 0;
}