############################################################################## # The Faq-O-Matic is Copyright 1997 by Jon Howell, all rights reserved. # # # # 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, write to the Free Software # # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.# # # # Jon Howell can be contacted at: # # 6211 Sudikoff Lab, Dartmouth College # # Hanover, NH 03755-3510 # # jonh@cs.dartmouth.edu # # # # An electronic copy of the GPL is available at: # # http://www.gnu.org/copyleft/gpl.html # # # ############################################################################## use strict; package FAQ::OMatic::stats; use CGI; use FAQ::OMatic::Item; use FAQ::OMatic; use FAQ::OMatic::Log; use FAQ::OMatic::I18N; sub main { my $cgi = FAQ::OMatic::dispatch::cgi(); my $rt = ''; my $params = FAQ::OMatic::getParams($cgi); $params->{'duration'} = '' if (not defined($params->{'duration'})); my $simpleHTML = $params->{'simpleHTML'}; # make sure today is summarized in a .smry file FAQ::OMatic::Log::summarizeDay(FAQ::OMatic::Log::numericToday()); # check history now that today is summarized (so there's at least 1 .smry) if ($params->{'duration'} eq 'history') { # tickle the earliestLogHint file so all 8 graph CGIs # don't try to do so simultaneously. FAQ::OMatic::Log::earliestSmry(); } # get today's stats for the text part of the display my $today = $params->{'today'} || ''; $today =~ m/([\d-]*)/; # sanitize user input before treating it as a path $today = $1; if (not -e "$FAQ::OMatic::Config::metaDir/$today.smry") { $today = FAQ::OMatic::Log::numericToday(); } my $todayItem = new FAQ::OMatic::Item("$today.smry", $FAQ::OMatic::Config::metaDir); # The list of properties and corresponding titles my @props = ('Hits', 'CumHits'); my @titles = (gettext("Hits Per Day"), gettext("Cumulative Hits")); if ($FAQ::OMatic::Config::statUniqueHosts) { push @props, ('UniqueHosts', 'CumUniqueHosts'); push @titles, (gettext("New Hosts Per Day"), gettext("Total Hosts")); } push @props, ('HitsPerHost', 'CumOperation-search'); push @titles, (gettext("Hits Per Host"), gettext("Cumulative Searches")); push @props, ('Operation-submitPart', 'CumOperation-submitPart'); push @titles, (gettext("Submissions Per Day"), gettext("Cumulative Submissions")); $rt.= FAQ::OMatic::pageHeader($params); $rt.= gettext("Please be patient ... the image files are generated dynamically, and can take from 20 to 50 seconds to create.\n"); $rt.="
| \n"; } else { # before a pair $rt .= $simpleHTML ? "" : " |
| \n";
}
$rt .= " ".$titles[$i].": ".$value."\n"; if ($i & 0x01) { # after a pair $rt .= $simpleHTML ? " " : " |