#!/usr/bin/perl
# Before attempting to set up this script, please read
# readme.txt, which you should have received along with this!
# EXTRA SERVER INFORMATION
# Coranto tries to determine its path and URL automatically. This works in 90%
# of cases, but some servers aren't cooperative and don't allow this information
# to be found automatically. Though it won't hurt, there's no need to fill this out
# unless you encounter problems.
#
# If you encounter problems (particularly with incorrect URLs, or fatal error messages
# about files not being found), fill in the two variables below.
$abspath = '';
# Set the above to the absolute path to Coranto's directory, without a trailing slash.
# Example:
# $abspath = '/www/business/5014a/news/coranto.cgi';
$scripturl = '';
# Set the above to the URL to coranto.cgi.
# Example:
# $scripturl = 'http://www.kartingforheroes.com/news/coranto.cgi';
# END EXTRA SERVER INFORMATION
#####
# START (Unless you know Perl, don't change anything after this point.)
#####
#Fixes content type in browsers other than IE
print "Content-type: text/html\n";
# Don't change these numbers! Used internally.
$crcgiBuild = 40;
$crcgiVer = '1.25.2';
$crcgiRC = 0;
unless ($JustLoadSubs == 1){
eval {
unless ($scripturl){
$scripturl = GetScriptURL();
}
&main();
};
if ($@) {
CRdie("Untrapped Error: $@");
}
}
# In order to trap as many errors as possible, we run everything via an eval.
# If $JustLoadSubs is set, that means we're being included by an external
# script which doesn't want us to run, so don't.
# This is the first sub to be executed.
sub main {
# mod_perl?
if (exists $ENV{'MOD_PERL'}) {
print "Content-Type: text/html\n\nSorry, Coranto does not currently run under mod_perl.";
exit;
}
# Try and be compatible with Microsoft IIS.
unshift @INC, $1 if $0 =~ m!(.*)(\\|\/)!;
# If extra server information was specified, use it.
push @INC, $abspath if $abspath;
# We're done. Now load the core and start running it.
NeedFile('crcore.pl');
RunCoranto();
}
# Takes care of loading in external Perl files.
my %LoadedFiles;
sub NeedFile {
my $file = shift;
unless ($LoadedFiles{$file}) {
eval { require $file; };
if ($@) {
if (-e $file) {
if (-r $file) {
CRdie("Could not include file $file. The file, however, appears to exist. This usually indicates some form of syntax error in the file. Message: $@");
}
else {
CRdie("Could not include file $file. The file appears to exist but is not readable. Check file permissions. Full Message: $@");
}
}
else {
CRdie("Could not include file $file. The file does not appear to exist. Verify that this file is where it should be. Full Message: $@",1);
}
}
$LoadedFiles{$file} = 1;
}
}
# Gets our current absolute path. Needed for error messages.
sub GetDirInfo {
my $cwd;
eval q~use Cwd; $cwd = cwd();~;
unless ($cwd) {
$cwd = `pwd`; chomp $pwd;
}
$cwd =~ s!\\!/!g;
return $cwd;
}
# Gets our full URL. Needed for error messages.
sub GetScriptURL { 'http' . ( defined $ENV{'HTTPS'} and $ENV{'HTTPS'} ne 'off' ? 's' : '' ) . '://' . ($ENV{'HTTP_HOST'} ? $ENV{'HTTP_HOST'} : $ENV{'SERVER_NAME'}) . ($ENV{'SERVER_PORT'} != 80 && $ENV{'HTTP_HOST'} !~ /:/ ? ":$ENV{'SERVER_PORT'}" : '') . $ENV{'SCRIPT_NAME'} }
# CRHTMLHead: Displays the standard HTML header used by all script pages.
sub CRHTMLHead {
unless ($HTMLHeaderPrinted) {
my ($title, $adminnav) = @_;
$title =~ s/</g;
$title =~ s/>/>/g;
$title =~ s/"/"/g;
print qq~