#!/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; print qq~ Coranto: $title$Messages{'ContentType'} ~; print PrintCSS(); # HOOK: CRHTMLHead_Head if($Addons{'CRHTMLHead_Head'}){my $w;foreach $w (@{$Addons{'CRHTMLHead_Head'}}){my $addon=$w->[2];eval ${$w->[0]};AErr($addon,$@)if $@;};} print ' '; # HOOK: CRHTMLHead if($Addons{'CRHTMLHead'}){my $w;foreach $w (@{$Addons{'CRHTMLHead'}}){my $addon=$w->[2];eval ${$w->[0]};AErr($addon,$@)if $@;};} print '
'; print qq~ ~ if $CConfig{'SiteLink'}; print $CConfig{'SiteTitle'}; print '' if $CConfig{'SiteLink'}; print '
$title

~; # HOOK: CRHTMLHead_Message if($Addons{'CRHTMLHead_Message'}){my $w;foreach $w (@{$Addons{'CRHTMLHead_Message'}}){my $addon=$w->[2];eval ${$w->[0]};AErr($addon,$@)if $@;};} print qq~
~; if ($CurrentUser) { print qq~
$Messages{'LoggedIn'} $CurrentUser.~; if ($adminnav) { print '
back to the ' . PageLink( {'action' => 'mainpage'} ) . 'Main Page | back to ' . PageLink( {'action' => 'admin'} ) . 'Administration'; } # HOOK: CRHTMLHead_UserBar if($Addons{'CRHTMLHead_UserBar'}){my $w;foreach $w (@{$Addons{'CRHTMLHead_UserBar'}}){my $addon=$w->[2];eval ${$w->[0]};AErr($addon,$@)if $@;};} print'

'; } $HTMLHeaderPrinted = 1; } # end unless $HTMLHeaderPrinted } # This roundabout method of printing CSS code exists to make things easier for addons. sub PrintCSS { unless($CConfig{'HeadCSS'}){ &ReadConfigInfo(); } my $css = $CConfig{'HeadCSS'}; # HOOK: PrintCSS if($Addons{'PrintCSS'}){my $w;foreach $w (@{$Addons{'PrintCSS'}}){my $addon=$w->[2];eval ${$w->[0]};AErr($addon,$@)if $@;};} if ($css) { return qq~~; } else { return q~~; } } sub CRHTMLFoot_NoNav { print '
'; } # CRHTMLFoot: Displays the HTML footer used by all script pages. sub CRHTMLFoot { print ''; print q~
~; # HOOK: CRHTMLFoot_2 if($Addons{'CRHTMLFoot_2'}){my $w;foreach $w (@{$Addons{'CRHTMLFoot_2'}}){my $addon=$w->[2];eval ${$w->[0]};AErr($addon,$@)if $@;};} print ''; } # CRdie: Generates a pretty error message with as much information as possible. sub CRdie { if ($CRdied) { exit; } undef %Addons; $CRdied++; my $msg = shift; my $enableHTML = shift; $msg =~ s/\n//g; $msg =~ s/
/\n/g; unless ($enableHTML) { $msg =~ s//>/g; } $msg =~ s/\n/
/g; if (!$HeaderPrinted) { print "Content-type: text/html\nCache-control: no-cache\n\n"; } if (!$HTMLHeaderPrinted) { CRHTMLHead("Fatal Error"); } print qq~
An error has occurred. The exact description of the error is:
$msg

If this error indicates a problem that you don't know how to solve, see the Coranto documentation and FAQ. If these resources don't help, make a (detailed!) post to the Coranto Forum.


USEFUL INFORMATION
\n
~; if ($!) { print "Perl may have generated the following error: $!\n
"; } print "Perl Version: $]\n
"; print "Script Version: $crcgiVer\n
"; print "Script Build: $crcgiBuild\n
"; print "Script RC: $crcgiRC\n
"; print "Script URL: $scripturl\n
"; print '@INC:
  • ' . join("
  • \n
  • ", @INC) . '
'; ($0 =~ m,(.*)/[^/]+,) && unshift (@INC, "$1"); ($0 =~ m,(.*)\\[^\\]+,) && unshift (@INC, "$1"); print "Script Location (Method 1): $0\n
"; my $dirname = GetDirInfo(); $dirname =~ s/\\/\//g; print "Script Location (Method 2): $dirname\n
"; print "
\nENVIRONMENT VARIABLES\n
"; while (($key, $value) = each %ENV) { unless ($key eq "HTTP_COOKIE") { print "$key: $value\n
"; } } print "
\nMESSAGE: $msg\n
"; print '
'; CRHTMLFoot_NoNav(); exit; } 1;