#!/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/login.cgi,v 1.9 2002/04/24 13:02:10 timc Exp $ require 5.001; 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/'; use strict; use CGI qw(:cgi-lib :standard :html3 :netscape); use CGI::Carp qw(fatalsToBrowser); use DBI; require PresentWSD; require Contributor; require Stats; require CustomizedSettings; #my $db_name = 'EnWsdDB'; my $db_name = 'robk'; my $dbh = &ConnectCollectionDB($db_name); my %user_info = cookie($db_name); my $ip = $ENV{'REMOTE_ADDR'} || 'unknown'; # load up the customized messages my %messages = LoadMessages(); if(not(defined($user_info{'session-name'})) or (url_param('uaction') eq 'logout')) { $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'}); # refresh the cookie so that it doesn't expire. my $the_cookie = cookie(-name=>$db_name, -value=>\%user_info, -path=>'/', -expires=>'+1h'); my $path_info = path_info(); $path_info =~ s!^/!!; my $activity_id = 20; SWITCH: { if(url_param('uaction') eq 'logout') { &PrintLogout(\%messages,$the_cookie); last SWITCH } if((url_param('uaction') eq 'profile') or param('profile')) { &ProcessProfile(\%messages,$dbh, $session_id, $activity_id, $the_cookie, $path_info); last SWITCH } if (param('create')) { &ProcessNewUser(\%messages,$dbh, $activity_id, $the_cookie, $session_id, $path_info); last SWITCH } if (param('login')) { &ProcessExistingUser(\%messages,$dbh, $the_cookie, $session_id, $path_info); last SWITCH } # the user just got here, present the initial login form &PrintOMWELogin(\%messages, $the_cookie, undef, $path_info); } $dbh->disconnect; exit;