#!/usr/bin/perl -w BEGIN {$Defines::calendar_root = 'Calcium3.5'; unshift @INC, $Defines::calendar_root} # Copyright 1999, 2000, Fred Steinberg, Brown Bear Software # Everything starts from here. use strict; use CGI::Carp ('fatalsToBrowser'); use 5.004; use CGI 2.42; use Calendar::User; use Calendar::Audit; use Calendar::GetHTML; use Operation::OperationFactory; $|++; # Parse the CGI params into a hash my %params; my $cgi = new CGI; foreach my $name ($cgi->param) { $params{$name} = $cgi->param($name); # watch out! no multi-valued params! } $params{Op} ||= ($params{'CalendarName'} ? 'ShowIt' : 'Splash'); my $operation = $params{Op}; # If we're testing a cookie, see if it worked if ($params{TestCookie}) { my $ok = $cgi->cookie ('-name' => $params{TestCookie}); if (!defined ($ok)) { warn "Couldn't set cookie: $params{TestCookie}\n"; my $i18n = I18N->new (Preferences->new (MasterDB->new)->Language); my $string = $i18n->get ('Calcium_CookieFailed'); if ($string eq 'Calcium_CookieFailed') { $string =<< " FNORD";
Couldn't set the login cookie!

You can't login to Calcium unless cookies work on your browser. Please check your browser settings and make sure cookies are enabled, then try again.

FNORD } GetHTML->errorPage ($i18n, header => 'Cookie Failed', message => $string, backCount => -2); exit; } } # Get the user, if they've already logged in (undef otherwise) my $user = User->new ($cgi); # will be undef if no login yet # Create the Operation (which sets the language, too) my $object = OperationFactory->create ($operation, \%params, $user); die "Yikes! No such Calcium operation: $operation\n" unless $object; # Check permission, and do it. if ($object->authenticate) { $object->perform; $object->audit; } else { my $login = $object->makeURL ({Op => 'UserLogin', DesiredOp => $operation, DesiredParams => (join $;, %params)}); my $splash = $object->makeURL ({Op => 'Splash', CalendarName => undef}); my $username = $user && $user->name; my $message; my $i18n = I18N->new (Preferences->new (MasterDB->new)->Language); my $string = $i18n->get ('Calcium_NoPermission'); if ($string eq 'Calcium_NoPermission') { $message = $username ? "Sorry $username, you don't have permission to " : "Sorry, you must log in before you can "; $message .= "$object->{AuthLevel}" . ($params{CalendarName} ? " the $params{CalendarName} calendar." : ' the Calendar System.') . "

Go to the login screen, " . "the Calcium home page, or "; } else { $message = $i18n->get ('Calcium_NoPermission'); $message .= "
" . $i18n->get ('Login') . ' ' . "
" . $i18n->get ('Calcium home page') . ''; } GetHTML->errorPage ($i18n, header => $i18n->get ('Permission Denied'), message => $message); }