|
Server : Apache/2.4.62 System : FreeBSD fbsdweb2.web.rcn.net 14.1-RELEASE FreeBSD 14.1-RELEASE releng/14.1-n267679-10e31f0946d8 GENERIC amd64 User : www ( 80) PHP Version : 8.3.8 Disable Function : NONE Directory : /domains/compasssysweb/calendar/CalciumDir39/Calendar/ |
Upload File : |
# Copyright 1999-2003 Fred Steinberg, Brown Bear Software
use strict;
package CalciumStart;
# Everything starts from here.
use strict;
use CGI::Carp;
use 5.004;
use CGI 2.42;
use Calendar::User;
use Calendar::Audit;
use Calendar::GetHTML;
use Operation::OperationFactory;
sub go {
$|++;
# Parse the CGI params into a hash
my %params;
my $cgi = new CGI;
foreach my $name ($cgi->param) {
$params{$name} = $cgi->param($name); # note! no multi-valued params!
}
# Check pathinfo for calendar name
my $pathinfo = $cgi->path_info;
if ($pathinfo and !defined $params{CalendarName}) {
# fixed for broken servers; some give entire url
$pathinfo =~ s{^.*/(.)}{$1}; # delete up to last slash with something
# after it
$pathinfo =~ s{/$}{}; # and delete slash if at end of line,
# so e.g. cgi-bin/calcium/Default/ works
$params{CalendarName} = $pathinfo unless ($pathinfo =~ /\W/);
}
$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";
<center>Couldn't set the login cookie!</center><br>
You can't login to Compass Calendar unless cookies work on your
browser. Please check your browser settings and make sure
cookies are enabled, then try again.<br><hr>
FNORD
}
GetHTML->errorPage ($i18n,
header => 'Cookie Failed',
message => $string,
backCount => -2);
die "\n";
}
}
# Get the user, if they've already logged in (undef otherwise)
my $user = User->new ($cgi);
# Create the Operation (which sets the language, too)
my $object = OperationFactory->create ($operation, \%params, $user);
unless ($object) {
my $i18n = I18N->new (Preferences->new (MasterDB->new)->Language);
GetHTML->errorPage ($i18n,
header => 'Bad parameters',
message =>
$i18n->get ('No such Calcium operation') .
": $operation");
die "bad operation: '$operation'\n";
}
# Check permission, and do it.
if ($object->authenticate) {
$object->perform;
$object->audit;
} else {
my $desired = $operation->mungeParams (%params);
my $login = $object->makeURL ({Op => 'UserLogin',
DesiredOp => $operation,
DesiredParams => $desired});
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 "
: "<center>Sorry, you must log in before you can ";
$message .= "<b>$object->{AuthLevel}</b>" .
($params{CalendarName}
? " the <b>Compass</b> calendar."
: ' the Calendar System.') .
"<p>Go to the <a href=$login>login screen</a>, " .
"the <a href=$splash> Compass Calendar home page</a>, or ";
} else {
$message = $i18n->get ('Calcium_NoPermission');
$message .= "<br><a href=$login>" . $i18n->get ('Login') . '</a>' .
"<br><a href=$splash>" .
$i18n->get ('Calcium home page') . '</a></center>';
}
GetHTML->errorPage ($i18n,
header => $i18n->get ('Permission Denied'),
message => $message);
}
}
1;