#!/opt/perl-5.8.3/bin/perl -T # # Copyright (c) 2003, Tim Chklovski and Rada Mihalcea # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, # are permitted provided that the following conditions are met: # 1. Redistributions of source code must retain the above copyright notice, this # list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright notice, this # list of conditions and the following disclaimer in the documentation and/or other # materials provided with the distribution. # 3. The use of this code or extensions of the code must be acknowledged with a reference # and a link to http://teach-computers.org. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT # SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT # OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # $Header: /RESEARCH-CVS/web-interface/stats.cgi,v 1.3 2002/04/16 17:48:31 timc Exp $ require 5.001; use strict; use CGI qw(:cgi-lib :standard :html3 :netscape); use CGI::Carp qw(fatalsToBrowser); use DBI; use lib '.'; use lib '../../cgi-lib'; #use lib '/usr/lib/perl5/5.8.0/i386-linux-thread-multi/Digest/'; use lib '/opt/perl-5.8.3/lib/5.8.3/i686-linux/Digest/'; require PresentWSD; require Contributor; require Stats; require CustomizedSettings; #my $db_name = 'EnWsdDB'; my $db_name = 'robk'; my $dbh = &ConnectCollectionDB($db_name); my $activity_id = 20; # load up the customized messages my %messages = LoadMessages(); my %user_info = cookie($db_name); my $ip = $ENV{'REMOTE_ADDR'} || 'unknown'; $user_info{'session-name'} ||= &NewSession($dbh, $ip, time()); my $session_id = &NameToId($dbh, 'sessions', &UntaintAlNum($user_info{'session-name'})) or die("Unable to look up session id for ".$user_info{'session_name'}); my ($uid, $uname) = &SessionToUser($dbh, $session_id); # anonymous user has uid = 1 # refresh the cookie so that it doesn't expire. my $the_cookie = cookie(-name=>$db_name, -value=>\%user_info, -path=>'/', -expires=>'+1h'); if(url_param('userStats')) { # show how this user stacks up to the record my $nav_str = center(div({-class=>'color'}, join(" | ", a({-href=>'stats.cgi'}, "hall of fame"), a({-href=>'tag-words.cgi'}, "tag more")))); print header(-cookie=>$the_cookie), start_html(-title=>"Multilingual Word Expert Stats For $uname", -style=>{'src'=>'../../styles/style.css'}), # print menu &PresentMenu, #h1(img({src=>'/images/openmindexpert_small.gif', # width=>193, # height=>37, # hspace=>20, # align=>'right'}), h1( "Statistics for ".ucfirst($uname)).br, &PresentUserStats(\%messages, $dbh, $uname, $activity_id), $nav_str, end_html; } else { # show the hall of fame my $nav_str = center(join(" | ", a({-href=>'stats.cgi?userStats=1'}, "stats"), a({-href=>'tag-words.cgi'}, "tag more"))); print header(-cookie=>$the_cookie), start_html(-title=>"Word Expert Hall Of Fame", -style=>{'src'=>'../../styles/style.css'}, -class=>'reverse'), # print menu &PresentMenu, &PresentBestUsers(\%messages, $dbh, $activity_id), # h1({-class=>'reverse'}, "These Contributors are Truly Great!"), div({-class=>'reverse'}, "Can You Set a New Record?"), $nav_str, end_html; }